From 311da573f33ec53fe69f07ea4b6c3fcda0b7bc55 Mon Sep 17 00:00:00 2001 From: danvleju-rdx <163979791+danvleju-rdx@users.noreply.github.com> Date: Mon, 25 Nov 2024 21:58:00 +0200 Subject: [PATCH] [ABW-3992] Customize guarantees fix (#1396) --- .../Core/SharedModels/Assets/ResourceAmount.swift | 9 +++++++++ .../TransactionReviewFeature/TransactionReview.swift | 8 ++++---- .../TransactionReviewGuarantees.swift | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/RadixWallet/Core/SharedModels/Assets/ResourceAmount.swift b/RadixWallet/Core/SharedModels/Assets/ResourceAmount.swift index a0328ae1d7..00042e8146 100644 --- a/RadixWallet/Core/SharedModels/Assets/ResourceAmount.swift +++ b/RadixWallet/Core/SharedModels/Assets/ResourceAmount.swift @@ -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): diff --git a/RadixWallet/Features/TransactionReviewFeature/TransactionReview.swift b/RadixWallet/Features/TransactionReviewFeature/TransactionReview.swift index abbc042f13..ce4076df6f 100644 --- a/RadixWallet/Features/TransactionReviewFeature/TransactionReview.swift +++ b/RadixWallet/Features/TransactionReviewFeature/TransactionReview.swift @@ -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 } diff --git a/RadixWallet/Features/TransactionReviewFeature/TransactionReviewGuarantees/TransactionReviewGuarantees.swift b/RadixWallet/Features/TransactionReviewFeature/TransactionReviewGuarantees/TransactionReviewGuarantees.swift index 786fc150a3..faec708c6f 100644 --- a/RadixWallet/Features/TransactionReviewFeature/TransactionReviewGuarantees/TransactionReviewGuarantees.swift +++ b/RadixWallet/Features/TransactionReviewFeature/TransactionReviewGuarantees/TransactionReviewGuarantees.swift @@ -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 }