Updated on 2026-08-14

This commit is contained in:
Tangem 2025-02-10 17:42:33 +05:00
commit cd846f1092
5 changed files with 28 additions and 11 deletions

View file

@ -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<NotificationUM>.addTransactionLimitErrorNotification(
utxoLimit: UtxoAmountLimit?,
cryptoCurrency: CryptoCurrency,
currencyCheck: CryptoCurrencyCheck?,
sendingAmount: BigDecimal,
cryptoCurrencyStatus: CryptoCurrencyStatus,
feeCurrencyStatus: CryptoCurrencyStatus?,
feeValue: BigDecimal,
onReduceClick: (
reduceAmountTo: BigDecimal,
notification: Class<out NotificationUM>,
) -> 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,

View file

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

View file

@ -64,7 +64,6 @@ internal class FeeStateFactory(
} else {
FeeSelectorState.Loading
},
notifications = persistentListOf(),
isPrimaryButtonEnabled = false,
),
)

View file

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

View file

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