From 1b061d2d2bed9d0d289082e608c1daeaf0206994 Mon Sep 17 00:00:00 2001 From: Tangem Date: Wed, 10 Dec 2025 16:14:08 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../tokens/repository/DefaultCurrencyChecksRepository.kt | 3 ++- .../com/tangem/domain/tokens/GetCurrencyCheckUseCase.kt | 4 +++- .../domain/tokens/repository/CurrencyChecksRepository.kt | 2 +- .../subcomponents/notifications/model/NotificationsModel.kt | 1 + .../staking/impl/presentation/model/StakingModel.kt | 1 + .../com/tangem/feature/swap/domain/SwapInteractorImpl.kt | 6 ++++++ 6 files changed, 14 insertions(+), 3 deletions(-) diff --git a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrencyChecksRepository.kt b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrencyChecksRepository.kt index 8c77f51a78..de056fb431 100644 --- a/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrencyChecksRepository.kt +++ b/data/tokens/src/main/kotlin/com/tangem/data/tokens/repository/DefaultCurrencyChecksRepository.kt @@ -155,9 +155,10 @@ internal class DefaultCurrencyChecksRepository( override suspend fun getRentExemptionError( userWalletId: UserWalletId, - currencyStatus: CryptoCurrencyStatus, + currencyStatus: CryptoCurrencyStatus?, balanceAfterTransaction: BigDecimal, ): CryptoCurrencyWarning.Rent? { + if (currencyStatus == null) return null val rentData = walletManagersFacade.getRentInfo(userWalletId, currencyStatus.currency.network) ?: return null return when { balanceAfterTransaction.isZero() -> null diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyCheckUseCase.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyCheckUseCase.kt index 43c65d397a..e1073f1bd0 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyCheckUseCase.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/GetCurrencyCheckUseCase.kt @@ -14,9 +14,11 @@ class GetCurrencyCheckUseCase( private val dispatchers: CoroutineDispatcherProvider, ) { + @Suppress("LongParameterList") suspend operator fun invoke( userWalletId: UserWalletId, currencyStatus: CryptoCurrencyStatus, + feeCurrencyStatus: CryptoCurrencyStatus?, amount: BigDecimal?, fee: BigDecimal?, feeCurrencyBalanceAfterTransaction: BigDecimal?, @@ -31,7 +33,7 @@ class GetCurrencyCheckUseCase( val existentialDeposit = currencyChecksRepository.getExistentialDeposit(userWalletId, network) val rentWarning = currencyChecksRepository.getRentExemptionError( userWalletId = userWalletId, - currencyStatus = currencyStatus, + currencyStatus = feeCurrencyStatus, balanceAfterTransaction = feeCurrencyBalanceAfterTransaction ?: BigDecimal.ZERO, ) val isAccountFunded = recipientAddress?.let { diff --git a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/CurrencyChecksRepository.kt b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/CurrencyChecksRepository.kt index 8351958b10..41266e0b39 100644 --- a/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/CurrencyChecksRepository.kt +++ b/domain/tokens/src/main/kotlin/com/tangem/domain/tokens/repository/CurrencyChecksRepository.kt @@ -58,7 +58,7 @@ interface CurrencyChecksRepository { */ suspend fun getRentExemptionError( userWalletId: UserWalletId, - currencyStatus: CryptoCurrencyStatus, + currencyStatus: CryptoCurrencyStatus?, balanceAfterTransaction: BigDecimal, ): CryptoCurrencyWarning.Rent? } \ No newline at end of file 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 7642f338a8..7efbe2186d 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 @@ -136,6 +136,7 @@ internal class NotificationsModel @Inject constructor( val currencyCheck = getCurrencyCheckUseCase( userWalletId = userWalletId, currencyStatus = cryptoCurrencyStatus, + feeCurrencyStatus = feeCryptoCurrencyStatus, amount = sendingAmount, fee = feeValue, recipientAddress = destinationAddress, 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 eebecedbcf..9e1aaa62ba 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 @@ -772,6 +772,7 @@ internal class StakingModel @Inject constructor( val currencyStatus = getCurrencyCheckUseCase( userWalletId = userWalletId, currencyStatus = cryptoCurrencyStatus, + feeCurrencyStatus = feeCryptoCurrencyStatus, amount = amount, fee = fee, feeCurrencyBalanceAfterTransaction = balanceAfterTransaction, diff --git a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt index 8146ac1c63..aa8415a3c9 100644 --- a/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt +++ b/features/swap/domain/src/main/java/com/tangem/feature/swap/domain/SwapInteractorImpl.kt @@ -92,6 +92,7 @@ internal class SwapInteractorImpl @AssistedInject constructor( private val amountFormatter: AmountFormatter, private val rampStateManager: RampStateManager, private val singleAccountStatusListSupplier: SingleAccountStatusListSupplier, + private val getFeePaidCryptoCurrencyStatusSyncUseCase: GetFeePaidCryptoCurrencyStatusSyncUseCase, private val accountsFeatureToggles: AccountsFeatureToggles, @Assisted private val userWalletId: UserWalletId, ) : SwapInteractor { @@ -631,9 +632,14 @@ internal class SwapInteractorImpl @AssistedInject constructor( } else { amount } + val feePaidCurrencyStatus = getFeePaidCryptoCurrencyStatusSyncUseCase( + userWalletId = userWalletId, + cryptoCurrencyStatus = fromTokenStatus, + ).getOrNull() val currencyCheck = getCurrencyCheckUseCase( userWalletId = userWalletId, currencyStatus = fromTokenStatus, + feeCurrencyStatus = feePaidCurrencyStatus, amount = amountToRequest.value, fee = fee, feeCurrencyBalanceAfterTransaction = balanceAfterTransaction,