Skip to content

Commit

Permalink
[ABW-3992] Customize guarantees fix (#1396)
Browse files Browse the repository at this point in the history
  • Loading branch information
danvleju-rdx authored Nov 25, 2024
1 parent e655502 commit 311da57
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
9 changes: 9 additions & 0 deletions RadixWallet/Core/SharedModels/Assets/ResourceAmount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ extension ResourceAmount {
}
}

var predictedAmount: ExactResourceAmount? {
switch self {
case let .predicted(amount, _):
amount
default:
nil
}
}

func adjustedNominalAmount(_ adjust: (Decimal192) -> Decimal192) -> Self {
switch self {
case let .exact(amount):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,14 +627,14 @@ extension ResourceBalance {
}

/// The transferred amount, for a fungible resource
var fungibleTransferAmount: Decimal192? {
var fungiblePredictedTransferAmount: Decimal192? {
switch details {
case let .fungible(fungible):
fungible.amount.exactAmount?.nominalAmount
fungible.amount.predictedAmount?.nominalAmount
case let .liquidStakeUnit(liquidStakeUnit):
liquidStakeUnit.amount.exactAmount?.nominalAmount
liquidStakeUnit.amount.predictedAmount?.nominalAmount
case let .poolUnit(poolUnit):
poolUnit.details.poolUnitResource.amount.exactAmount?.nominalAmount
poolUnit.details.poolUnitResource.amount.predictedAmount?.nominalAmount
case .nonFungible, .stakeClaimNFT, .none:
nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ struct TransactionReviewGuarantee: Sendable, FeatureReducer {
return nil
}

guard let amount = transfer.value.fungibleTransferAmount, amount > 0 else { return nil }
guard let amount = transfer.value.fungiblePredictedTransferAmount, amount > 0 else { return nil }
self.amount = amount

guard let guarantee = transfer.fungibleGuarantee, guarantee.amount >= 0 else { return nil }
Expand Down

0 comments on commit 311da57

Please sign in to comment.