From a058fba39600787f027dcb47510b983a4eef58c6 Mon Sep 17 00:00:00 2001 From: Tangem Date: Mon, 10 Feb 2025 16:26:29 +0500 Subject: [PATCH] Updated on 2026-08-14 --- .../ui/notifications/NotificationsFactory.kt | 20 +++++++++++++++---- .../state/confirm/SendNotificationFactory.kt | 6 ++++-- .../presentation/state/fee/FeeStateFactory.kt | 1 - .../AddStakingNotificationsTransformer.kt | 6 ++++-- .../presentation/SwapNotificationsFactory.kt | 6 ++++-- 5 files changed, 28 insertions(+), 11 deletions(-) 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 06a15df8af..78d11c9b2f 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 @@ -12,7 +12,7 @@ import com.tangem.core.ui.utils.parseBigDecimal import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.tokens.model.CryptoCurrency import com.tangem.domain.tokens.model.CryptoCurrencyStatus -import com.tangem.domain.tokens.model.blockchains.UtxoAmountLimit +import com.tangem.domain.tokens.model.warnings.CryptoCurrencyCheck import com.tangem.domain.tokens.model.warnings.CryptoCurrencyWarning import com.tangem.domain.transaction.error.GetFeeError import com.tangem.utils.extensions.isZero @@ -124,17 +124,29 @@ object NotificationsFactory { } } + @Suppress("LongParameterList") fun MutableList.addTransactionLimitErrorNotification( - utxoLimit: UtxoAmountLimit?, - cryptoCurrency: CryptoCurrency, + currencyCheck: CryptoCurrencyCheck?, + sendingAmount: BigDecimal, + cryptoCurrencyStatus: CryptoCurrencyStatus, + feeCurrencyStatus: CryptoCurrencyStatus?, feeValue: BigDecimal, onReduceClick: ( reduceAmountTo: BigDecimal, notification: Class, ) -> Unit, ) { + val cryptoCurrency = cryptoCurrencyStatus.currency + val utxoLimit = currencyCheck?.utxoAmountLimit val availableToSend = utxoLimit?.availableToSend - if (availableToSend != null && !feeValue.isZero()) { + val isDustLimit = checkDustLimits( + feeAmount = feeValue, + sendingAmount = sendingAmount, + dustValue = currencyCheck?.dustValue.orZero(), + cryptoCurrencyStatus = cryptoCurrencyStatus, + feeCurrencyStatus = feeCurrencyStatus, + ) + if (availableToSend != null && !feeValue.isZero() && !isDustLimit) { add( NotificationUM.Error.TransactionLimitError( cryptoCurrency = cryptoCurrency.name, 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 38c478b425..ea3dc027aa 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 @@ -211,8 +211,10 @@ internal class SendNotificationFactory( ) } addTransactionLimitErrorNotification( - utxoLimit = currencyCheck.utxoAmountLimit, - cryptoCurrency = currency, + currencyCheck = currencyCheck, + sendingAmount = sendingAmount, + cryptoCurrencyStatus = cryptoCurrencyStatus, + feeCurrencyStatus = feeCryptoCurrencyStatusProvider(), feeValue = feeValue, onReduceClick = clickIntents::onAmountReduceToClick, ) diff --git a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/FeeStateFactory.kt b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/FeeStateFactory.kt index e31d57f978..83e40651a2 100644 --- a/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/FeeStateFactory.kt +++ b/features/send/impl/src/main/java/com/tangem/features/send/impl/presentation/state/fee/FeeStateFactory.kt @@ -64,7 +64,6 @@ internal class FeeStateFactory( } else { FeeSelectorState.Loading }, - notifications = persistentListOf(), isPrimaryButtonEnabled = false, ), ) diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/notifications/AddStakingNotificationsTransformer.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/notifications/AddStakingNotificationsTransformer.kt index 1d7f631da5..6aeb94cc74 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/notifications/AddStakingNotificationsTransformer.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/notifications/AddStakingNotificationsTransformer.kt @@ -168,8 +168,10 @@ internal class AddStakingNotificationsTransformer( ) } addTransactionLimitErrorNotification( - utxoLimit = currencyCheck.utxoAmountLimit, - cryptoCurrency = cryptoCurrency, + currencyCheck = currencyCheck, + sendingAmount = sendingAmount, + cryptoCurrencyStatus = cryptoCurrencyStatus, + feeCurrencyStatus = feeCryptoCurrencyStatus, feeValue = feeValue, onReduceClick = prevState.clickIntents::onAmountReduceToClick, ) diff --git a/features/swap/presentation/src/main/java/com/tangem/feature/swap/presentation/SwapNotificationsFactory.kt b/features/swap/presentation/src/main/java/com/tangem/feature/swap/presentation/SwapNotificationsFactory.kt index 3bc9bd6767..021b53941d 100644 --- a/features/swap/presentation/src/main/java/com/tangem/feature/swap/presentation/SwapNotificationsFactory.kt +++ b/features/swap/presentation/src/main/java/com/tangem/feature/swap/presentation/SwapNotificationsFactory.kt @@ -199,8 +199,10 @@ internal class SwapNotificationsFactory( onReduceByAmount = actions.onReduceByAmount, ) addTransactionLimitErrorNotification( - utxoLimit = quoteModel.currencyCheck?.utxoAmountLimit, - cryptoCurrency = fromCurrencyStatus.currency, + currencyCheck = quoteModel.currencyCheck, + sendingAmount = amountToRequest.value, + cryptoCurrencyStatus = fromCurrencyStatus, + feeCurrencyStatus = feeCryptoCurrencyStatus, feeValue = fee?.feeValue.orZero(), onReduceClick = { reduceTo, _ -> actions.onReduceToAmount(amountToRequest.copy(value = reduceTo))