From 99cdc003c88561f6f7de953f89dbfac00a7ff721 Mon Sep 17 00:00:00 2001 From: Tangem Date: Thu, 15 Jan 2026 20:15:37 +0300 Subject: [PATCH] Updated on 2026-08-14 --- app/src/main/assets/tangem-app-config | 2 +- .../DefaultGaslessTransactionRepository.kt | 3 - .../IsAmountSubtractAvailableUseCase.kt | 11 +- .../domain/transaction/error/GetFeeError.kt | 1 + .../gasless/EstimateFeeForGaslessTxUseCase.kt | 2 +- .../gasless/EstimateFeeForTokenUseCase.kt | 111 ++++++++++-------- .../gasless/GetAvailableFeeTokensUseCase.kt | 2 +- .../gasless/GetFeeForGaslessUseCase.kt | 2 +- .../usecase/gasless/GetFeeForTokenUseCase.kt | 87 ++++++++------ .../usecase/gasless/TokenFeeCalculator.kt | 12 +- .../usecase/gasless/TokenFeeCalculatorTest.kt | 8 +- .../v2/send/confirm/model/SendConfirmModel.kt | 16 +-- .../notifications/model/NotificationsModel.kt | 4 +- .../impl/presentation/model/StakingModel.kt | 6 +- .../confirm/model/SendWithSwapConfirmModel.kt | 8 +- gradle/tangem_dependencies.toml | 2 +- 16 files changed, 156 insertions(+), 121 deletions(-) diff --git a/app/src/main/assets/tangem-app-config b/app/src/main/assets/tangem-app-config index 5ba0959d72..098662beb5 160000 --- a/app/src/main/assets/tangem-app-config +++ b/app/src/main/assets/tangem-app-config @@ -1 +1 @@ -Subproject commit 5ba0959d72f41e49a22f792e9a3d53e5e24e7713 +Subproject commit 098662beb5b0123b11f5ee4873d4bd667ac93c73 diff --git a/data/transaction/src/main/java/com/tangem/data/transaction/DefaultGaslessTransactionRepository.kt b/data/transaction/src/main/java/com/tangem/data/transaction/DefaultGaslessTransactionRepository.kt index 9587374de8..3e75ce78f5 100644 --- a/data/transaction/src/main/java/com/tangem/data/transaction/DefaultGaslessTransactionRepository.kt +++ b/data/transaction/src/main/java/com/tangem/data/transaction/DefaultGaslessTransactionRepository.kt @@ -116,9 +116,6 @@ class DefaultGaslessTransactionRepository( } private companion object { - - const val TOKEN_RECEIVER_ADDRESS = "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045" - val BASE_GAS_FOR_TRANSACTION: BigInteger = BigInteger("100000") } } \ No newline at end of file diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/IsAmountSubtractAvailableUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/IsAmountSubtractAvailableUseCase.kt index bdbc0507df..2ff85923ae 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/IsAmountSubtractAvailableUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/IsAmountSubtractAvailableUseCase.kt @@ -1,6 +1,7 @@ package com.tangem.domain.tokens import arrow.core.Either +import com.tangem.blockchain.common.transaction.Fee import com.tangem.domain.models.currency.CryptoCurrency import com.tangem.domain.models.wallet.UserWalletId import com.tangem.domain.tokens.model.FeePaidCurrency @@ -16,9 +17,15 @@ class IsAmountSubtractAvailableUseCase( suspend operator fun invoke( userWalletId: UserWalletId, currency: CryptoCurrency, - isGaslessEthTx: Boolean = false, + maybeGaslessFee: Pair? = null, ): Either = Either.catch { - if (isGaslessEthTx) return@catch true + val maybeTokenCurrency = currency as? CryptoCurrency.Token + if (maybeGaslessFee != null && + maybeGaslessFee.second is Fee.Ethereum.TokenCurrency && + maybeGaslessFee.first.contractAddress.equals(maybeTokenCurrency?.contractAddress, true) + ) { + return@catch true + } when (val feeCurrency = currenciesRepository.getFeePaidCurrency(userWalletId, currency.network)) { is FeePaidCurrency.Coin -> currency is CryptoCurrency.Coin is FeePaidCurrency.SameCurrency -> true diff --git a/domain/transaction/models/src/main/kotlin/com/tangem/domain/transaction/error/GetFeeError.kt b/domain/transaction/models/src/main/kotlin/com/tangem/domain/transaction/error/GetFeeError.kt index 6bfb7e06d4..1e8b733d5c 100644 --- a/domain/transaction/models/src/main/kotlin/com/tangem/domain/transaction/error/GetFeeError.kt +++ b/domain/transaction/models/src/main/kotlin/com/tangem/domain/transaction/error/GetFeeError.kt @@ -14,5 +14,6 @@ sealed class GetFeeError { data object NetworkIsNotSupported : GaslessError() data object NoSupportedTokensFound : GaslessError() data object NotEnoughFunds : GaslessError() + data class DataError(val cause: Throwable?) : GaslessError() } } \ No newline at end of file diff --git a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/EstimateFeeForGaslessTxUseCase.kt b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/EstimateFeeForGaslessTxUseCase.kt index 53856d8603..3d375e367d 100644 --- a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/EstimateFeeForGaslessTxUseCase.kt +++ b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/EstimateFeeForGaslessTxUseCase.kt @@ -89,7 +89,7 @@ class EstimateFeeForGaslessTxUseCase( ) }, catch = { - raise(GetFeeError.DataError(it)) + raise(GaslessError.DataError(it)) }, ) } diff --git a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/EstimateFeeForTokenUseCase.kt b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/EstimateFeeForTokenUseCase.kt index d41eb24d0c..a3165f0349 100644 --- a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/EstimateFeeForTokenUseCase.kt +++ b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/EstimateFeeForTokenUseCase.kt @@ -2,6 +2,7 @@ package com.tangem.domain.transaction.usecase.gasless import arrow.core.Either import arrow.core.raise.Raise +import arrow.core.raise.catch import arrow.core.raise.either import com.tangem.blockchain.blockchains.ethereum.EthereumWalletManager import com.tangem.blockchain.common.transaction.Fee @@ -17,6 +18,7 @@ import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.tokens.repository.CurrencyChecksRepository import com.tangem.domain.transaction.GaslessTransactionRepository import com.tangem.domain.transaction.error.GetFeeError +import com.tangem.domain.transaction.error.GetFeeError.GaslessError import com.tangem.domain.transaction.error.mapToFeeError import com.tangem.domain.transaction.models.TransactionFeeExtended import com.tangem.domain.transaction.raiseIllegalStateError @@ -45,62 +47,69 @@ class EstimateFeeForTokenUseCase( amount: BigDecimal, ): Either { return either { - val token = tokenCurrencyStatus.currency - if (!currencyChecksRepository.isNetworkSupportedForGaslessTx(token.network)) { - raise(GetFeeError.GaslessError.NetworkIsNotSupported) - } + catch( + block = { + val token = tokenCurrencyStatus.currency + if (!currencyChecksRepository.isNetworkSupportedForGaslessTx(token.network)) { + raise(GetFeeError.GaslessError.NetworkIsNotSupported) + } - val amountData = amount.convertToSdkAmount(tokenCurrencyStatus) - val result = if (userWallet is UserWallet.Cold && - demoConfig.isDemoCardId(userWallet.scanResponse.card.cardId) - ) { - demoTransactionSender(userWallet, token).estimateFee( - amount = amountData, - destination = "", - ) - } else { - walletManagersFacade.estimateFee( - amount = amountData, - userWalletId = userWallet.walletId, - network = token.network, - ) - } + val amountData = amount.convertToSdkAmount(tokenCurrencyStatus) + val result = if (userWallet is UserWallet.Cold && + demoConfig.isDemoCardId(userWallet.scanResponse.card.cardId) + ) { + demoTransactionSender(userWallet, token).estimateFee( + amount = amountData, + destination = "", + ) + } else { + walletManagersFacade.estimateFee( + amount = amountData, + userWalletId = userWallet.walletId, + network = token.network, + ) + } - val initialTxFee = when (result) { - is Result.Success -> result.data - is Result.Failure -> raise(result.mapToFeeError()) - null -> raise(GetFeeError.UnknownError) - } + val initialTxFee = when (result) { + is Result.Success -> result.data + is Result.Failure -> raise(result.mapToFeeError()) + null -> raise(GetFeeError.UnknownError) + } - val initialFeeEth = initialTxFee.normal as? Fee.Ethereum - ?: raiseIllegalStateError( - error = "only Fee.Ethereum supported, but was different", - ) + val initialFeeEth = initialTxFee.normal as? Fee.Ethereum + ?: raiseIllegalStateError( + error = "only Fee.Ethereum supported, but was different", + ) - val nativeCurrency = currenciesRepository.getNetworkCoin( - userWalletId = userWallet.walletId, - networkId = token.network.id, - derivationPath = token.network.derivationPath, + val nativeCurrency = currenciesRepository.getNetworkCoin( + userWalletId = userWallet.walletId, + networkId = token.network.id, + derivationPath = token.network.derivationPath, + ) + + val userCurrenciesStatusesByNetwork = getMultiCryptoCurrencyStatusUseCase.invokeMultiWalletSync( + userWallet.walletId, + ).getOrNull()?.filter { + it.currency.network.id == token.network.id + } ?: raiseIllegalStateError("currencies list is null for userWalletId=${userWallet.walletId}") + + val nativeCurrencyStatus = userCurrenciesStatusesByNetwork.find { + it.currency.id == nativeCurrency.id + } ?: raiseIllegalStateError("native currency not found for network ${token.network.id}") + + val walletManager = prepareWalletManager(userWallet, token.network) + + tokenFeeCalculator.calculateTokenFee( + walletManager = walletManager, + tokenForPayFeeStatus = tokenCurrencyStatus, + nativeCurrencyStatus = nativeCurrencyStatus, + initialFee = initialFeeEth, + ).bind() + }, + catch = { + raise(GaslessError.DataError(it)) + }, ) - - val userCurrenciesStatusesByNetwork = getMultiCryptoCurrencyStatusUseCase.invokeMultiWalletSync( - userWallet.walletId, - ).getOrNull()?.filter { - it.currency.network.id == token.network.id - } ?: raiseIllegalStateError("currencies list is null for userWalletId=${userWallet.walletId}") - - val nativeCurrencyStatus = userCurrenciesStatusesByNetwork.find { - it.currency.id == nativeCurrency.id - } ?: raiseIllegalStateError("native currency not found for network ${token.network.id}") - - val walletManager = prepareWalletManager(userWallet, token.network) - - tokenFeeCalculator.calculateTokenFee( - walletManager = walletManager, - tokenForPayFeeStatus = tokenCurrencyStatus, - nativeCurrencyStatus = nativeCurrencyStatus, - initialFee = initialFeeEth, - ).bind() } } diff --git a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetAvailableFeeTokensUseCase.kt b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetAvailableFeeTokensUseCase.kt index cf57b14f21..96435ad705 100644 --- a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetAvailableFeeTokensUseCase.kt +++ b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetAvailableFeeTokensUseCase.kt @@ -53,7 +53,7 @@ class GetAvailableFeeTokensUseCase( } }, catch = { - raise(GetFeeError.DataError(it)) + raise(GetFeeError.GaslessError.DataError(it)) }, ) } diff --git a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetFeeForGaslessUseCase.kt b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetFeeForGaslessUseCase.kt index 9beebc0a2f..1bb6b4074c 100644 --- a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetFeeForGaslessUseCase.kt +++ b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetFeeForGaslessUseCase.kt @@ -86,7 +86,7 @@ class GetFeeForGaslessUseCase( ) }, catch = { - raise(GetFeeError.DataError(it)) + raise(GaslessError.DataError(it)) }, ) } diff --git a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetFeeForTokenUseCase.kt b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetFeeForTokenUseCase.kt index 4e4efd2880..f20c162b52 100644 --- a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetFeeForTokenUseCase.kt +++ b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/GetFeeForTokenUseCase.kt @@ -2,6 +2,7 @@ package com.tangem.domain.transaction.usecase.gasless import arrow.core.Either import arrow.core.raise.Raise +import arrow.core.raise.catch import arrow.core.raise.either import com.tangem.blockchain.blockchains.ethereum.EthereumWalletManager import com.tangem.blockchain.common.TransactionData @@ -15,6 +16,7 @@ import com.tangem.domain.tokens.repository.CurrenciesRepository import com.tangem.domain.tokens.repository.CurrencyChecksRepository import com.tangem.domain.transaction.GaslessTransactionRepository import com.tangem.domain.transaction.error.GetFeeError +import com.tangem.domain.transaction.error.GetFeeError.GaslessError import com.tangem.domain.transaction.models.TransactionFeeExtended import com.tangem.domain.transaction.raiseIllegalStateError import com.tangem.domain.walletmanager.WalletManagersFacade @@ -40,50 +42,57 @@ class GetFeeForTokenUseCase( transactionData: TransactionData, ): Either { return either { - if (!currencyChecksRepository.isNetworkSupportedForGaslessTx(token.network)) { - raise(GetFeeError.GaslessError.NetworkIsNotSupported) - } + catch( + block = { + if (!currencyChecksRepository.isNetworkSupportedForGaslessTx(token.network)) { + raise(GaslessError.NetworkIsNotSupported) + } - val walletManager = prepareWalletManager(userWallet, token.network) + val walletManager = prepareWalletManager(userWallet, token.network) - val initialTxFee = tokenFeeCalculator.calculateInitialFee( - userWallet = userWallet, - network = token.network, - walletManager = walletManager, - transactionData = transactionData, - ).bind() + val initialTxFee = tokenFeeCalculator.calculateInitialFee( + userWallet = userWallet, + network = token.network, + walletManager = walletManager, + transactionData = transactionData, + ).bind() - val initialFeeEth = initialTxFee.normal as? Fee.Ethereum - ?: raiseIllegalStateError( - error = "only Fee.Ethereum supported, but was different", - ) + val initialFeeEth = initialTxFee.normal as? Fee.Ethereum + ?: raiseIllegalStateError( + error = "only Fee.Ethereum supported, but was different", + ) - val nativeCurrency = currenciesRepository.getNetworkCoin( - userWalletId = userWallet.walletId, - networkId = token.network.id, - derivationPath = token.network.derivationPath, + val nativeCurrency = currenciesRepository.getNetworkCoin( + userWalletId = userWallet.walletId, + networkId = token.network.id, + derivationPath = token.network.derivationPath, + ) + + val userCurrenciesStatusesByNetwork = getMultiCryptoCurrencyStatusUseCase.invokeMultiWalletSync( + userWallet.walletId, + ).getOrNull()?.filter { + it.currency.network.id == token.network.id + } ?: raiseIllegalStateError("currencies list is null for userWalletId=${userWallet.walletId}") + + val nativeCurrencyStatus = userCurrenciesStatusesByNetwork.find { + it.currency.id == nativeCurrency.id + } ?: raiseIllegalStateError("native currency not found for network ${token.network.id}") + + val tokenCurrencyStatus = userCurrenciesStatusesByNetwork.find { + it.currency.id == token.id + } ?: raiseIllegalStateError("token currency not found for network ${token.network.id}") + + tokenFeeCalculator.calculateTokenFee( + walletManager = walletManager, + tokenForPayFeeStatus = tokenCurrencyStatus, + nativeCurrencyStatus = nativeCurrencyStatus, + initialFee = initialFeeEth, + ).bind() + }, + catch = { + raise(GaslessError.DataError(it)) + }, ) - - val userCurrenciesStatusesByNetwork = getMultiCryptoCurrencyStatusUseCase.invokeMultiWalletSync( - userWallet.walletId, - ).getOrNull()?.filter { - it.currency.network.id == token.network.id - } ?: raiseIllegalStateError("currencies list is null for userWalletId=${userWallet.walletId}") - - val nativeCurrencyStatus = userCurrenciesStatusesByNetwork.find { - it.currency.id == nativeCurrency.id - } ?: raiseIllegalStateError("native currency not found for network ${token.network.id}") - - val tokenCurrencyStatus = userCurrenciesStatusesByNetwork.find { - it.currency.id == token.id - } ?: raiseIllegalStateError("token currency not found for network ${token.network.id}") - - tokenFeeCalculator.calculateTokenFee( - walletManager = walletManager, - tokenForPayFeeStatus = tokenCurrencyStatus, - nativeCurrencyStatus = nativeCurrencyStatus, - initialFee = initialFeeEth, - ).bind() } } diff --git a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/TokenFeeCalculator.kt b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/TokenFeeCalculator.kt index 8934f4fb11..c7d9a57ea7 100644 --- a/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/TokenFeeCalculator.kt +++ b/domain/transaction/src/main/java/com/tangem/domain/transaction/usecase/gasless/TokenFeeCalculator.kt @@ -26,6 +26,7 @@ import com.tangem.domain.transaction.raiseIllegalStateError import com.tangem.domain.utils.convertToSdkAmount import com.tangem.domain.walletmanager.WalletManagersFacade import java.math.BigDecimal +import java.math.BigInteger import java.math.RoundingMode internal class TokenFeeCalculator( @@ -51,7 +52,7 @@ internal class TokenFeeCalculator( val maybeFee = when (val result = transactionSender.getFee(transactionData = transactionData)) { is Result.Success -> result.data - is Result.Failure -> raise(result.mapToFeeError()) + is Result.Failure -> raise(GaslessError.DataError(result.error)) } maybeFee } @@ -115,7 +116,7 @@ internal class TokenFeeCalculator( val feeTransferGasLimit = when (feeTransferGasLimitResult) { is Result.Failure -> raise(GetFeeError.DataError(feeTransferGasLimitResult.error)) is Result.Success -> feeTransferGasLimitResult.data - } + }.increaseByPercent(PERCENT_TO_INCREASE_TRANSFER_GASLIMIT) val baseGas = gaslessTransactionRepository.getBaseGasForTransaction() @@ -197,6 +198,7 @@ internal class TokenFeeCalculator( /** Gas price safety multiplier for fee calculation */ const val GAS_PRICE_MULTIPLIER = 2 const val PERCENT_TO_INCREASE_TOKEN_PRICE = 1 + const val PERCENT_TO_INCREASE_TRANSFER_GASLIMIT = 10 /** * Increases BigDecimal value by specified percentage. @@ -216,5 +218,11 @@ internal class TokenFeeCalculator( val multiplier = BigDecimal.ONE.add(BigDecimal(percent).divide(BigDecimal("100"))) return this.multiply(multiplier) } + + private fun BigInteger.increaseByPercent(percent: Int): BigInteger { + require(percent >= 0) { "Percent must be non-negative" } + val multiplier = BigDecimal.ONE.add(BigDecimal(percent).divide(BigDecimal("100"))) + return BigDecimal(this).multiply(multiplier).toBigInteger() + } } } \ No newline at end of file diff --git a/domain/transaction/src/test/java/com/tangem/domain/transaction/usecase/gasless/TokenFeeCalculatorTest.kt b/domain/transaction/src/test/java/com/tangem/domain/transaction/usecase/gasless/TokenFeeCalculatorTest.kt index 8e58e9f4eb..a5ba8d69b6 100644 --- a/domain/transaction/src/test/java/com/tangem/domain/transaction/usecase/gasless/TokenFeeCalculatorTest.kt +++ b/domain/transaction/src/test/java/com/tangem/domain/transaction/usecase/gasless/TokenFeeCalculatorTest.kt @@ -110,7 +110,7 @@ class TokenFeeCalculatorTest { // Then assertTrue(result.isLeft()) result.onLeft { error -> - assertTrue(error is GetFeeError.DataError) + assertTrue(error is GetFeeError.GaslessError) } } @@ -363,7 +363,7 @@ class TokenFeeCalculatorTest { // Expected val expectedAmount = Amount( - value = BigDecimal("36.200000000000000000000000000000000000"), + value = BigDecimal("37.400000000000000000000000000000000000"), token = Token( name = "USDC", symbol = "USDC", @@ -371,9 +371,9 @@ class TokenFeeCalculatorTest { decimals = 6, ) ) - val expectedGasLimit = "181000".toBigInteger() + val expectedGasLimit = "187000".toBigInteger() val expectedCoinPriceInToken = BigInteger("2020000000") // 2000 * 1.01 * 10^6 - val expectedFeeTransferLimit = "60000".toBigInteger() + val expectedFeeTransferLimit = "66000".toBigInteger() val expectedBaseGas = "21000".toBigInteger() // Given diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt index f99abc7f71..a83a0a796c 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/send/confirm/model/SendConfirmModel.kt @@ -628,14 +628,14 @@ internal class SendConfirmModel @Inject constructor( private fun updateAmountSubtractAvailability() { modelScope.launch { - val isGaslessEthTx = - feeUMV2?.feeExtraInfo?.transactionFeeExtended?.transactionFee?.normal is Fee.Ethereum.TokenCurrency - isAmountSubtractAvailable = - isAmountSubtractAvailableUseCase( - userWalletId = userWallet.walletId, - currency = cryptoCurrency, - isGaslessEthTx = isGaslessEthTx, - ).getOrElse { false } + val fee = feeUMV2?.feeExtraInfo?.transactionFeeExtended?.transactionFee?.normal + // we assume if feeExtraInfo is empty then pay fee in the main currency + val feeTokenId = feeUMV2?.feeExtraInfo?.transactionFeeExtended?.feeTokenId ?: cryptoCurrency.id + isAmountSubtractAvailable = isAmountSubtractAvailableUseCase( + userWalletId = userWallet.walletId, + currency = cryptoCurrency, + maybeGaslessFee = fee?.let { feeTokenId to fee }, + ).getOrElse { false } } } diff --git a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt index eb07ae00ec..7c4bc6ef9d 100644 --- a/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt +++ b/features/send-v2/impl/src/main/java/com/tangem/features/send/v2/subcomponents/notifications/model/NotificationsModel.kt @@ -106,10 +106,12 @@ internal class NotificationsModel @Inject constructor( } private suspend fun checkIfSubtractAvailable() { + val feeCurrencyId = notificationData.feeCryptoCurrencyStatus.currency.id + val fee = notificationData.fee isAmountSubtractAvailable = isAmountSubtractAvailableUseCase( userWalletId = userWalletId, currency = currency, - isGaslessEthTx = notificationData.fee is Fee.Ethereum.TokenCurrency, + maybeGaslessFee = fee?.let { feeCurrencyId to fee }, ).getOrElse { false } } diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt index bac16c9edc..fa875ef820 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/model/StakingModel.kt @@ -1439,8 +1439,10 @@ internal class StakingModel @Inject constructor( } private suspend fun checkIfSubtractAvailable() { - isAmountSubtractAvailable = isAmountSubtractAvailableUseCase(userWalletId, cryptoCurrencyStatus.currency) - .getOrElse { false } + isAmountSubtractAvailable = isAmountSubtractAvailableUseCase( + userWalletId = userWalletId, + currency = cryptoCurrencyStatus.currency, + ).getOrElse { false } } private fun isTopHeatupCase(): Boolean { diff --git a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt index 72cfe665f9..62e8af81b4 100644 --- a/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt +++ b/features/swap-v2/impl/src/main/java/com/tangem/features/swap/v2/impl/sendviaswap/confirm/model/SendWithSwapConfirmModel.kt @@ -3,7 +3,6 @@ package com.tangem.features.swap.v2.impl.sendviaswap.confirm.model import arrow.core.Either import arrow.core.getOrElse import arrow.core.left -import com.tangem.blockchain.common.transaction.Fee import com.tangem.blockchain.common.transaction.TransactionFee import com.tangem.common.routing.AppRouter import com.tangem.common.ui.amountScreen.converters.AmountReduceByTransformer @@ -349,13 +348,14 @@ internal class SendWithSwapConfirmModel @Inject constructor( private fun updateAmountSubtractAvailability() { modelScope.launch { - val isGaslessEthTx = - feeUMV2?.feeExtraInfo?.transactionFeeExtended?.transactionFee?.normal is Fee.Ethereum.TokenCurrency + val fee = feeUMV2?.feeExtraInfo?.transactionFeeExtended?.transactionFee?.normal + val feeTokenId = + feeUMV2?.feeExtraInfo?.transactionFeeExtended?.feeTokenId ?: primaryCurrencyStatus.currency.id isAmountSubtractAvailable = isAmountSubtractAvailableUseCase( userWalletId = params.userWallet.walletId, currency = primaryCurrencyStatus.currency, - isGaslessEthTx = isGaslessEthTx, + maybeGaslessFee = fee?.let { feeTokenId to fee }, ).getOrElse { false } } } diff --git a/gradle/tangem_dependencies.toml b/gradle/tangem_dependencies.toml index 49a960701f..fdc2399973 100644 --- a/gradle/tangem_dependencies.toml +++ b/gradle/tangem_dependencies.toml @@ -5,7 +5,7 @@ # https://github.com/tangem/tangem-sdk-android/ # https://github.com/tangem/vico -tangemBlockchainSdk = "develop-1364" +tangemBlockchainSdk = "develop-1365" #tangemBlockchainSdk = "0.0.1" # Keep it! - used for local builds tangemCardSdk = "develop-573" #tangemCardSdk = "0.0.1" # Keep it! - used for local builds ^