Skip to content

Commit

Permalink
Remove unneeded Option returned by decodeTransactionRejectionEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiotudone-da committed Oct 14, 2021
1 parent 4b4861e commit 7537e93
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ private[state] object Conversions {
def decodeTransactionRejectionEntry(
entry: DamlTransactionRejectionEntry,
errorVersionSwitch: ValueSwitch[Status],
): Option[FinalReason] = {
val status = Some(entry.getReasonCase match {
): FinalReason =
FinalReason(entry.getReasonCase match {
case DamlTransactionRejectionEntry.ReasonCase.INVALID_LEDGER_TIME =>
val rejection = entry.getInvalidLedgerTime
invalidLedgerTimeStatus(entry, rejection, errorVersionSwitch)
Expand Down Expand Up @@ -524,8 +524,6 @@ private[state] object Conversions {
case DamlTransactionRejectionEntry.ReasonCase.REASON_NOT_SET =>
reasonNotSetStatus(entry, errorVersionSwitch)
})
status.map(FinalReason)
}

private def encodeParties(parties: Set[Ref.Party]): List[String] =
(parties.toList: List[String]).sorted
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ object KeyValueConsumption {
}

case DamlLogEntry.PayloadCase.TRANSACTION_REJECTION_ENTRY =>
transactionRejectionEntryToUpdate(
List(transactionRejectionEntryToUpdate(
recordTime,
entry.getTransactionRejectionEntry,
errorVersionSwitch,
).toList
))

case DamlLogEntry.PayloadCase.OUT_OF_TIME_BOUNDS_ENTRY =>
outOfTimeBoundsEntryToUpdate(
Expand Down Expand Up @@ -244,15 +244,14 @@ object KeyValueConsumption {
recordTime: Timestamp,
rejEntry: DamlTransactionRejectionEntry,
errorVersionSwitch: ValueSwitch[Status],
): Option[Update] = Conversions
.decodeTransactionRejectionEntry(rejEntry, errorVersionSwitch)
.map { reason =>
Update.CommandRejected(
recordTime = recordTime,
completionInfo = parseCompletionInfo(parseInstant(recordTime), rejEntry.getSubmitterInfo),
reasonTemplate = reason,
)
}
): Update = {
val reason = Conversions.decodeTransactionRejectionEntry(rejEntry, errorVersionSwitch)
Update.CommandRejected(
recordTime = recordTime,
completionInfo = parseCompletionInfo(parseInstant(recordTime), rejEntry.getSubmitterInfo),
reasonTemplate = reason,
)
}

/** Transform the transaction entry into the [[Update.TransactionAccepted]] event. */
private def transactionEntryToUpdate(
Expand Down

0 comments on commit 7537e93

Please sign in to comment.