Updated on 2026-08-14

This commit is contained in:
Tangem 2023-10-04 14:33:33 +05:00
parent bca3e4e18e
commit 8c792a2ce8

View file

@ -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>): 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,