From 8c792a2ce85c5be1de704ff53dd7885c95b0d51d Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 4 Oct 2023 14:33:33 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../wallet/redux/middlewares/WalletMiddleware.kt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt index 889dab19e8..b4f81bd001 100644 --- a/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt +++ b/app/src/main/java/com/tangem/tap/features/wallet/redux/middlewares/WalletMiddleware.kt @@ -180,7 +180,7 @@ class WalletMiddleware { } if (walletState.isMultiwalletAllowed) { - val amountToSend = sendableAmounts.find { it.currencySymbol == currency.currencySymbol } + val amountToSend = findAmountToSend(currency = currency, amounts = sendableAmounts) if (amountToSend == null) { val error = TapError.UnsupportedState("WalletAction.Send: Amount to send is null") FirebaseCrashlytics.getInstance().recordException(IllegalStateException(error.stateError)) @@ -277,6 +277,18 @@ class WalletMiddleware { } } + private fun findAmountToSend(currency: Currency, amounts: List): Amount? { + return amounts.find { amount -> + val amountType = amount.type + if (amountType is AmountType.Token && currency is Currency.Token) { + val token = amountType.token + token.symbol == currency.currencySymbol && token.contractAddress == currency.token.contractAddress + } else { + amount.currencySymbol == currency.currencySymbol + } + } + } + private fun makeInitSendStateActionByAmount( amount: Amount, walletStore: WalletStoreModel,