From f7ff9ca8b216e91205a0afac26cf4cb2013912ed Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 25 Oct 2024 12:06:13 +0300 Subject: [PATCH 1/4] Updated on 2026-08-14 --- .../com/tangem/common/ui/notifications/NotificationsFactory.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/ui/src/main/java/com/tangem/common/ui/notifications/NotificationsFactory.kt b/common/ui/src/main/java/com/tangem/common/ui/notifications/NotificationsFactory.kt index 36c15ab3c6..ade6bf5a42 100644 --- a/common/ui/src/main/java/com/tangem/common/ui/notifications/NotificationsFactory.kt +++ b/common/ui/src/main/java/com/tangem/common/ui/notifications/NotificationsFactory.kt @@ -66,7 +66,7 @@ object NotificationsFactory { add( NotificationUM.Error.ReserveAmount( BigDecimalFormatter.formatCryptoAmount( - cryptoAmount = sendingAmount, + cryptoAmount = reserveAmount, cryptoCurrency = cryptoCurrency, ), ), From 2eed92d8e98b4668708ae92004b92ac79177081e Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 25 Oct 2024 13:27:52 +0300 Subject: [PATCH 2/4] Updated on 2026-08-14 --- .../domain/tokens/model/warnings/CryptoCurrencyCheck.kt | 1 + .../com/tangem/domain/tokens/GetCurrencyCheckUseCase.kt | 9 +++++++++ .../state/confirm/SendNotificationFactory.kt | 7 +++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyCheck.kt b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyCheck.kt index 04018ed4aa..780c6c48fe 100644 --- a/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyCheck.kt +++ b/domain/tokens/models/src/main/java/com/tangem/domain/tokens/model/warnings/CryptoCurrencyCheck.kt @@ -8,4 +8,5 @@ data class CryptoCurrencyCheck( val reserveAmount: BigDecimal?, val existentialDeposit: BigDecimal?, val utxoAmountLimit: UtxoAmountLimit?, + val isAccountFunded: Boolean, ) \ No newline at end of file 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 4e74a21591..f335e654bf 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 @@ -15,11 +15,19 @@ class GetCurrencyCheckUseCase( currencyStatus: CryptoCurrencyStatus, amount: BigDecimal?, fee: BigDecimal?, + recipientAddress: String? = null, ): CryptoCurrencyCheck { val network = currencyStatus.currency.network val dustValue = currencyChecksRepository.getDustValue(userWalletId, network) val reserveAmount = currencyChecksRepository.getReserveAmount(userWalletId, network) val existentialDeposit = currencyChecksRepository.getExistentialDeposit(userWalletId, network) + val isAccountFunded = recipientAddress?.let { + currencyChecksRepository.checkIfAccountFunded( + userWalletId, + network, + recipientAddress, + ) + } ?: false val utxoAmountLimit = if (amount != null && fee != null) { currencyChecksRepository.checkUtxoAmountLimit( userWalletId = userWalletId, @@ -36,6 +44,7 @@ class GetCurrencyCheckUseCase( reserveAmount = reserveAmount, existentialDeposit = existentialDeposit, utxoAmountLimit = utxoAmountLimit, + isAccountFunded = isAccountFunded, ) } } \ No newline at end of file diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/confirm/SendNotificationFactory.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/confirm/SendNotificationFactory.kt index 23f483ef38..48ec5be5b1 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/confirm/SendNotificationFactory.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/confirm/SendNotificationFactory.kt @@ -45,7 +45,7 @@ import kotlinx.coroutines.flow.map import java.math.BigDecimal @Suppress("LongParameterList", "LargeClass") -internal class SendNotificationFactory constructor( +internal class SendNotificationFactory( private val analyticsEventHandler: AnalyticsEventHandler, private val validateTransactionUseCase: ValidateTransactionUseCase, private val getCurrencyCheckUseCase: GetCurrencyCheckUseCase, @@ -90,11 +90,14 @@ internal class SendNotificationFactory constructor( reduceAmountBy = reduceAmountBy, ) val feeError = (feeState.feeSelectorState as? FeeSelectorState.Error)?.error + + val recipientAddress = state.recipientState?.addressTextField?.value val currencyCheck = getCurrencyCheckUseCase( userWalletId = userWalletId, currencyStatus = cryptoCurrencyStatus, amount = sendingAmount, fee = feeValue, + recipientAddress = recipientAddress, ) buildList { addErrorNotifications( @@ -187,7 +190,7 @@ internal class SendNotificationFactory constructor( reserveAmount = currencyCheck.reserveAmount, sendingAmount = sendingAmount, cryptoCurrency = currency, - isAccountFunded = false, + isAccountFunded = currencyCheck.isAccountFunded, ) } From 03f965673a4d32aa42cfd28bf2fd09a29ec2abde Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 25 Oct 2024 14:57:41 +0300 Subject: [PATCH 3/4] Updated on 2026-08-14 --- .../tap/di/domain/TokensDomainModule.kt | 7 ++- .../domain/tokens/GetCurrencyCheckUseCase.kt | 61 ++++++++++--------- 2 files changed, 38 insertions(+), 30 deletions(-) diff --git a/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt b/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt index 5245e5a7ec..545a7a7fe5 100644 --- a/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt +++ b/app/src/main/java/com/tangem/tap/di/domain/TokensDomainModule.kt @@ -371,7 +371,10 @@ internal object TokensDomainModule { @Provides @Singleton - fun provideGetCurrencyCheckUseCase(currencyChecksRepository: CurrencyChecksRepository): GetCurrencyCheckUseCase { - return GetCurrencyCheckUseCase(currencyChecksRepository) + fun provideGetCurrencyCheckUseCase( + currencyChecksRepository: CurrencyChecksRepository, + dispatchers: CoroutineDispatcherProvider, + ): GetCurrencyCheckUseCase { + return GetCurrencyCheckUseCase(currencyChecksRepository, dispatchers) } } \ No newline at end of file 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 f335e654bf..aa488b2671 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 @@ -4,10 +4,13 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus import com.tangem.domain.tokens.model.warnings.CryptoCurrencyCheck import com.tangem.domain.tokens.repository.CurrencyChecksRepository import com.tangem.domain.wallets.models.UserWalletId +import com.tangem.utils.coroutines.CoroutineDispatcherProvider +import kotlinx.coroutines.withContext import java.math.BigDecimal class GetCurrencyCheckUseCase( private val currencyChecksRepository: CurrencyChecksRepository, + private val dispatchers: CoroutineDispatcherProvider, ) { suspend operator fun invoke( @@ -17,34 +20,36 @@ class GetCurrencyCheckUseCase( fee: BigDecimal?, recipientAddress: String? = null, ): CryptoCurrencyCheck { - val network = currencyStatus.currency.network - val dustValue = currencyChecksRepository.getDustValue(userWalletId, network) - val reserveAmount = currencyChecksRepository.getReserveAmount(userWalletId, network) - val existentialDeposit = currencyChecksRepository.getExistentialDeposit(userWalletId, network) - val isAccountFunded = recipientAddress?.let { - currencyChecksRepository.checkIfAccountFunded( - userWalletId, - network, - recipientAddress, - ) - } ?: false - val utxoAmountLimit = if (amount != null && fee != null) { - currencyChecksRepository.checkUtxoAmountLimit( - userWalletId = userWalletId, - network = network, - amount = amount, - fee = fee, - ) - } else { - null - } + return withContext(dispatchers.io) { + val network = currencyStatus.currency.network + val dustValue = currencyChecksRepository.getDustValue(userWalletId, network) + val reserveAmount = currencyChecksRepository.getReserveAmount(userWalletId, network) + val existentialDeposit = currencyChecksRepository.getExistentialDeposit(userWalletId, network) + val isAccountFunded = recipientAddress?.let { + currencyChecksRepository.checkIfAccountFunded( + userWalletId, + network, + recipientAddress, + ) + } ?: false + val utxoAmountLimit = if (amount != null && fee != null) { + currencyChecksRepository.checkUtxoAmountLimit( + userWalletId = userWalletId, + network = network, + amount = amount, + fee = fee, + ) + } else { + null + } - return CryptoCurrencyCheck( - dustValue = dustValue, - reserveAmount = reserveAmount, - existentialDeposit = existentialDeposit, - utxoAmountLimit = utxoAmountLimit, - isAccountFunded = isAccountFunded, - ) + CryptoCurrencyCheck( + dustValue = dustValue, + reserveAmount = reserveAmount, + existentialDeposit = existentialDeposit, + utxoAmountLimit = utxoAmountLimit, + isAccountFunded = isAccountFunded, + ) + } } } \ No newline at end of file From 8816b4e20a8f24dd86c55fb7a862401e84e039d9 Mon Sep 17 00:00:00 2001 From: Tangem Date: Fri, 25 Oct 2024 19:40:56 +0300 Subject: [PATCH 4/4] Updated on 2026-08-14 --- .../tangem/data/staking/converters/YieldConverter.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/data/staking/src/main/java/com/tangem/data/staking/converters/YieldConverter.kt b/data/staking/src/main/java/com/tangem/data/staking/converters/YieldConverter.kt index 8489a8772d..1ef336d4f8 100644 --- a/data/staking/src/main/java/com/tangem/data/staking/converters/YieldConverter.kt +++ b/data/staking/src/main/java/com/tangem/data/staking/converters/YieldConverter.kt @@ -124,7 +124,7 @@ class YieldConverter( stakedBalance = validatorDTO.stakedBalance, votingPower = validatorDTO.votingPower, preferred = validatorDTO.preferred, - isStrategicPartner = isStrategicPartner(validatorDTO.address), + isStrategicPartner = isStrategicPartner(validatorDTO.address, validatorDTO.name), ) } @@ -177,11 +177,17 @@ class YieldConverter( } } - private fun isStrategicPartner(validatorAddress: String): Boolean = PARTNERS.any { it == validatorAddress } + private fun isStrategicPartner(validatorAddress: String, validatorName: String): Boolean { + return PARTNERS.any { it == validatorAddress } || PARTNERS_NAMES.any { it.equals(validatorName, true) } + } private companion object { val PARTNERS = listOf( "cosmosvaloper1wrx0x9m9ykdhw9sg04v7uljme53wuj03aa5d4f", + "H2tJNyMHnRF6ahCQLQ1sSycM4FGchymuzyYzUqKEuydk", + ) + val PARTNERS_NAMES = listOf( + "Meria", ) } } \ No newline at end of file