Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ABW-3992] Customize guarantees fix #1396

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading