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 4774ef7850..c504cad596 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 @@ -11,7 +11,6 @@ import com.tangem.common.ui.notifications.NotificationsFactory.addRentExemptionN import com.tangem.common.ui.notifications.NotificationsFactory.addReserveAmountErrorNotification import com.tangem.common.ui.notifications.NotificationsFactory.addTransactionLimitErrorNotification import com.tangem.core.ui.extensions.networkIconResId -import com.tangem.core.ui.extensions.resourceReference import com.tangem.core.ui.extensions.stringReference import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.staking.model.stakekit.StakingError @@ -23,7 +22,6 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus 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.features.staking.impl.R import com.tangem.features.staking.impl.presentation.state.FeeState import com.tangem.features.staking.impl.presentation.state.StakingNotification import com.tangem.features.staking.impl.presentation.state.StakingStates @@ -117,6 +115,7 @@ internal class AddStakingNotificationsTransformer( sendingAmount = sendingAmount, actionAmount = amountValue, feeValue = feeValue, + tonBalanceExtraFeeThreshold = TON_BALANCE_EXTRA_FEE_THRESHOLD, ) }.toImmutableList() @@ -178,9 +177,7 @@ internal class AddStakingNotificationsTransformer( cryptoCurrencyStatus = cryptoCurrencyStatus, onClick = prevState.clickIntents::openTokenDetails, ) - addTonUnstakeNotification( - actionType = prevState.actionType, - ) + addTonExtraFeeErrorNotification() addExceedsBalanceNotification( cryptoCurrencyWarning = currencyWarning, cryptoCurrencyStatus = cryptoCurrencyStatus, @@ -276,20 +273,12 @@ internal class AddStakingNotificationsTransformer( } } - private fun MutableList.addTonUnstakeNotification(actionType: StakingActionCommonType) { + private fun MutableList.addTonExtraFeeErrorNotification() { val amount = cryptoCurrencyStatusProvider().value.amount.orZero() val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.id.value - if (isTon(cryptoCurrencyNetworkIdValue) && actionType !is StakingActionCommonType.Enter) { - val notification = if (amount < TON_BALANCE_EXTRA_FEE_THRESHOLD) { - NotificationUM.Error.TonStakingExtraFeeError - } else { - StakingNotification.Info.Ordinary( - title = resourceReference(R.string.staking_notification_ton_extra_reserve_title), - text = resourceReference(R.string.staking_notification_ton_extra_reserve_info), - ) - } - add(notification) + if (isTon(cryptoCurrencyNetworkIdValue) && amount < TON_BALANCE_EXTRA_FEE_THRESHOLD) { + add(NotificationUM.Error.TonStakingExtraFeeError) } } diff --git a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/notifications/StakingInfoNotificationsFactory.kt b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/notifications/StakingInfoNotificationsFactory.kt index 2fe83cd25c..067bb899a0 100644 --- a/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/notifications/StakingInfoNotificationsFactory.kt +++ b/features/staking/impl/src/main/java/com/tangem/features/staking/impl/presentation/state/transformers/notifications/StakingInfoNotificationsFactory.kt @@ -37,14 +37,17 @@ internal class StakingInfoNotificationsFactory( * @param actionAmount any amount being transferred or used action * @param feeValue fee amount payed from user account */ + @Suppress("LongParameterList") fun addInfoNotifications( notifications: MutableList, prevState: StakingUiState, sendingAmount: BigDecimal, actionAmount: BigDecimal, feeValue: BigDecimal, + tonBalanceExtraFeeThreshold: BigDecimal, ) = with(notifications) { addStakingLowBalanceNotification(prevState, actionAmount) + addTonExtraFeeInfoNotification(tonBalanceExtraFeeThreshold) when (prevState.actionType) { is StakingActionCommonType.Enter -> addEnterInfoNotifications(sendingAmount, feeValue) @@ -245,6 +248,20 @@ internal class StakingInfoNotificationsFactory( } } + private fun MutableList.addTonExtraFeeInfoNotification(tonBalanceExtraFeeThreshold: BigDecimal) { + val amount = cryptoCurrencyStatusProvider().value.amount.orZero() + val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.id.value + + if (isTon(cryptoCurrencyNetworkIdValue) && amount >= tonBalanceExtraFeeThreshold) { + add( + StakingNotification.Info.Ordinary( + title = resourceReference(R.string.staking_notification_ton_extra_reserve_title), + text = resourceReference(R.string.staking_notification_ton_extra_reserve_info), + ), + ) + } + } + private companion object { val MINIMUM_STAKE_BALANCE = "5".toBigDecimal() val MINIMUM_RESTAKE_BALANCE = "3".toBigDecimal()