Updated on 2026-08-14
This commit is contained in:
parent
2d5e434c5f
commit
e9801d4e47
2 changed files with 22 additions and 16 deletions
|
|
@ -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<NotificationUM>.addTonUnstakeNotification(actionType: StakingActionCommonType) {
|
||||
private fun MutableList<NotificationUM>.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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<NotificationUM>,
|
||||
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<NotificationUM>.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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue