Updated on 2026-08-14
This commit is contained in:
commit
2541461d44
954 changed files with 22834 additions and 21200 deletions
|
|
@ -302,12 +302,13 @@ internal class StakingModel @Inject constructor(
|
|||
)
|
||||
modelScope.launch {
|
||||
feeLoader.getFee(
|
||||
onStakingFee = { gasEstimate ->
|
||||
onStakingFee = { gasEstimate, isFeeApproximate ->
|
||||
stateController.update(
|
||||
SetConfirmationStateAssentTransformer(
|
||||
appCurrencyProvider = Provider { appCurrency },
|
||||
feeCryptoCurrencyStatus = feeCryptoCurrencyStatus,
|
||||
fee = gasEstimate,
|
||||
isFeeApproximate = isFeeApproximate,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
),
|
||||
)
|
||||
|
|
@ -363,13 +364,14 @@ internal class StakingModel @Inject constructor(
|
|||
stakingEventFactory.createSendTransactionErrorAlert(error)
|
||||
stateController.update(SetConfirmationStateResetAssentTransformer(cryptoCurrencyStatus))
|
||||
},
|
||||
onFeeIncreased = { increasedFee ->
|
||||
onFeeIncreased = { increasedFee, isFeeApproximate ->
|
||||
stateController.updateAll(
|
||||
SetConfirmationStateResetAssentTransformer(cryptoCurrencyStatus),
|
||||
SetConfirmationStateAssentTransformer(
|
||||
appCurrencyProvider = Provider { appCurrency },
|
||||
feeCryptoCurrencyStatus = feeCryptoCurrencyStatus,
|
||||
fee = increasedFee,
|
||||
isFeeApproximate = isFeeApproximate,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,22 +2,27 @@ package com.tangem.features.staking.impl.presentation.state.converters
|
|||
|
||||
import com.tangem.core.ui.extensions.*
|
||||
import com.tangem.core.ui.format.bigdecimal.crypto
|
||||
import com.tangem.core.ui.format.bigdecimal.fiat
|
||||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
import com.tangem.core.ui.utils.BigDecimalFormatter
|
||||
import com.tangem.core.ui.utils.parseBigDecimal
|
||||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.staking.model.stakekit.BalanceItem
|
||||
import com.tangem.domain.staking.model.stakekit.BalanceType
|
||||
import com.tangem.domain.staking.model.stakekit.BalanceType.Companion.isClickable
|
||||
import com.tangem.domain.staking.model.stakekit.Yield
|
||||
import com.tangem.domain.staking.model.stakekit.YieldBalance
|
||||
import com.tangem.domain.staking.model.stakekit.action.StakingActionType
|
||||
import com.tangem.domain.staking.utils.getRewardStakingBalance
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.features.staking.impl.presentation.state.BalanceState
|
||||
import com.tangem.lib.crypto.BlockchainUtils
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.converter.Converter
|
||||
import com.tangem.utils.extensions.orZero
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import org.joda.time.DateTime
|
||||
import java.math.BigDecimal
|
||||
import java.util.Calendar
|
||||
|
||||
internal class BalanceItemConverter(
|
||||
|
|
@ -33,8 +38,7 @@ internal class BalanceItemConverter(
|
|||
val validator = yield.validators.firstOrNull {
|
||||
value.validatorAddress?.contains(it.address, ignoreCase = true) == true
|
||||
}
|
||||
|
||||
val cryptoAmount = value.amount
|
||||
val cryptoAmount = value.getBalanceValue()
|
||||
val fiatAmount = cryptoCurrencyStatus.value.fiatRate?.times(cryptoAmount)
|
||||
|
||||
val title = value.type.getTitle(validator?.name)
|
||||
|
|
@ -52,11 +56,12 @@ internal class BalanceItemConverter(
|
|||
),
|
||||
fiatAmount = fiatAmount,
|
||||
formattedFiatAmount = stringReference(
|
||||
BigDecimalFormatter.formatFiatAmount(
|
||||
fiatAmount = fiatAmount,
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
),
|
||||
fiatAmount.format {
|
||||
fiat(
|
||||
fiatCurrencyCode = appCurrency.code,
|
||||
fiatCurrencySymbol = appCurrency.symbol,
|
||||
)
|
||||
},
|
||||
),
|
||||
rawCurrencyId = value.rawCurrencyId,
|
||||
pendingActions = value.pendingActions.toPersistentList(),
|
||||
|
|
@ -66,6 +71,18 @@ internal class BalanceItemConverter(
|
|||
}
|
||||
}
|
||||
|
||||
private fun BalanceItem.getBalanceValue(): BigDecimal {
|
||||
val isIncludeStakingTotalBalance = BlockchainUtils.isIncludeStakingTotalBalance(
|
||||
blockchainId = cryptoCurrencyStatus.currency.network.id.value,
|
||||
)
|
||||
val yieldBalance = cryptoCurrencyStatus.value.yieldBalance as? YieldBalance.Data
|
||||
return if (isIncludeStakingTotalBalance) {
|
||||
amount
|
||||
} else {
|
||||
amount - yieldBalance?.getRewardStakingBalance().orZero()
|
||||
}
|
||||
}
|
||||
|
||||
private fun BalanceType.getTitle(validatorName: String?) = when (this) {
|
||||
BalanceType.PREPARING,
|
||||
BalanceType.STAKED,
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.tangem.domain.staking.FetchStakingYieldBalanceUseCase
|
|||
import com.tangem.domain.staking.model.stakekit.Yield
|
||||
import com.tangem.domain.staking.model.stakekit.action.StakingActionStatus
|
||||
import com.tangem.domain.tokens.FetchPendingTransactionsUseCase
|
||||
import com.tangem.domain.tokens.TokensFeatureToggles
|
||||
import com.tangem.domain.tokens.UpdateDelayedNetworkStatusUseCase
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.txhistory.usecase.GetTxHistoryItemsCountUseCase
|
||||
|
|
@ -28,6 +29,7 @@ internal class StakingBalanceUpdater @AssistedInject constructor(
|
|||
private val fetchActionsUseCase: FetchActionsUseCase,
|
||||
private val txHistoryFeatureToggles: TxHistoryFeatureToggles,
|
||||
private val txHistoryContentUpdateEmitter: TxHistoryContentUpdateEmitter,
|
||||
private val tokensFeatureToggles: TokensFeatureToggles,
|
||||
@DelayedWork private val coroutineScope: CoroutineScope,
|
||||
@Assisted private val userWallet: UserWallet,
|
||||
@Assisted private val cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
|
|
@ -89,6 +91,7 @@ internal class StakingBalanceUpdater @AssistedInject constructor(
|
|||
stakingYieldBalanceUseCase(
|
||||
userWalletId = userWallet.walletId,
|
||||
cryptoCurrency = cryptoCurrencyStatus.currency,
|
||||
isRefactoringEnabled = tokensFeatureToggles.isStakingLoadingRefactoringEnabled,
|
||||
refresh = true,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,13 @@ import com.tangem.domain.staking.model.stakekit.Yield
|
|||
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
|
||||
import com.tangem.domain.staking.model.stakekit.transaction.ActionParams
|
||||
import com.tangem.domain.staking.model.stakekit.transaction.StakingGasEstimate
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.staking.getCurrentToken
|
||||
import com.tangem.domain.transaction.error.GetFeeError
|
||||
import com.tangem.domain.transaction.usecase.CreateApprovalTransactionUseCase
|
||||
import com.tangem.domain.transaction.usecase.GetFeeUseCase
|
||||
import com.tangem.domain.transaction.usecase.IsFeeApproximateUseCase
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingStateController
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingStates
|
||||
|
|
@ -38,13 +41,15 @@ internal class StakingFeeTransactionLoader @AssistedInject constructor(
|
|||
private val stateController: StakingStateController,
|
||||
private val getFeeUseCase: GetFeeUseCase,
|
||||
private val estimateGasUseCase: EstimateGasUseCase,
|
||||
private val isFeeApproximateUseCase: IsFeeApproximateUseCase,
|
||||
private val createApprovalTransactionUseCase: CreateApprovalTransactionUseCase,
|
||||
@Assisted private val cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
@Assisted private val userWallet: UserWallet,
|
||||
@Assisted private val yield: Yield,
|
||||
) {
|
||||
|
||||
suspend fun getFee(
|
||||
onStakingFee: (Fee) -> Unit,
|
||||
onStakingFee: (Fee, Boolean) -> Unit,
|
||||
onStakingFeeError: (StakingError) -> Unit,
|
||||
onApprovalFee: (TransactionFee) -> Unit,
|
||||
onFeeError: (GetFeeError) -> Unit,
|
||||
|
|
@ -91,7 +96,7 @@ internal class StakingFeeTransactionLoader @AssistedInject constructor(
|
|||
amount: BigDecimal,
|
||||
validatorAddress: String,
|
||||
onStakingFeeError: (StakingError) -> Unit,
|
||||
onStakingFee: (Fee) -> Unit,
|
||||
onStakingFee: (Fee, Boolean) -> Unit,
|
||||
) {
|
||||
val sourceAddress = cryptoCurrencyStatus.value.networkAddress?.defaultAddress?.value
|
||||
?: error("No available address")
|
||||
|
|
@ -144,14 +149,14 @@ internal class StakingFeeTransactionLoader @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
val amount = Amount(
|
||||
currencySymbol = gasEstimate.token.symbol,
|
||||
value = gasEstimate.amount,
|
||||
decimals = gasEstimate.token.decimals,
|
||||
)
|
||||
onStakingFee(
|
||||
Fee.Common(
|
||||
Amount(
|
||||
currencySymbol = gasEstimate.token.symbol,
|
||||
value = gasEstimate.amount,
|
||||
decimals = gasEstimate.token.decimals,
|
||||
),
|
||||
),
|
||||
Fee.Common(amount),
|
||||
isFeeApproximateUseCase(networkId = cryptoCurrencyStatus.currency.network.id, amountType = amount.type),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -181,11 +186,21 @@ internal class StakingFeeTransactionLoader @AssistedInject constructor(
|
|||
onApprovalFee: (TransactionFee) -> Unit,
|
||||
onApprovalFeeError: (GetFeeError) -> Unit,
|
||||
) {
|
||||
getFeeUseCase(
|
||||
val tokenCurrency = cryptoCurrencyStatus.currency as? CryptoCurrency.Token
|
||||
?: return onApprovalFeeError(GetFeeError.UnknownError)
|
||||
val approvalTransactionData = createApprovalTransactionUseCase(
|
||||
cryptoCurrency = tokenCurrency,
|
||||
userWalletId = userWallet.walletId,
|
||||
amount = amount,
|
||||
destination = validatorAddress,
|
||||
contractAddress = tokenCurrency.contractAddress,
|
||||
spenderAddress = validatorAddress,
|
||||
).getOrElse {
|
||||
return onApprovalFeeError(GetFeeError.DataError(it))
|
||||
}
|
||||
getFeeUseCase(
|
||||
userWallet = userWallet,
|
||||
cryptoCurrency = cryptoCurrencyStatus.currency,
|
||||
network = tokenCurrency.network,
|
||||
transactionData = approvalTransactionData,
|
||||
).fold(
|
||||
ifRight = { fee ->
|
||||
onApprovalFee(fee)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,10 @@ import com.tangem.blockchain.common.TransactionData
|
|||
import com.tangem.blockchain.common.TransactionSender
|
||||
import com.tangem.blockchain.common.transaction.Fee
|
||||
import com.tangem.common.ui.amountScreen.models.AmountState
|
||||
import com.tangem.domain.staking.*
|
||||
import com.tangem.domain.staking.GetConstructedStakingTransactionUseCase
|
||||
import com.tangem.domain.staking.GetStakingTransactionsUseCase
|
||||
import com.tangem.domain.staking.SaveUnsubmittedHashUseCase
|
||||
import com.tangem.domain.staking.SubmitHashUseCase
|
||||
import com.tangem.domain.staking.model.SubmitHashData
|
||||
import com.tangem.domain.staking.model.stakekit.NetworkType
|
||||
import com.tangem.domain.staking.model.stakekit.PendingAction
|
||||
|
|
@ -19,6 +22,7 @@ import com.tangem.domain.staking.model.stakekit.transaction.StakingTransactionTy
|
|||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.domain.tokens.model.staking.getCurrentToken
|
||||
import com.tangem.domain.transaction.error.SendTransactionError
|
||||
import com.tangem.domain.transaction.usecase.IsFeeApproximateUseCase
|
||||
import com.tangem.domain.transaction.usecase.SendTransactionUseCase
|
||||
import com.tangem.domain.txhistory.usecase.GetExplorerTransactionUrlUseCase
|
||||
import com.tangem.domain.utils.convertToSdkAmount
|
||||
|
|
@ -49,6 +53,7 @@ internal class StakingTransactionSender @AssistedInject constructor(
|
|||
private val getExplorerTransactionUrlUseCase: GetExplorerTransactionUrlUseCase,
|
||||
private val submitHashUseCase: SubmitHashUseCase,
|
||||
private val saveUnsubmittedHashUseCase: SaveUnsubmittedHashUseCase,
|
||||
private val isFeeApproximateUseCase: IsFeeApproximateUseCase,
|
||||
@Assisted private val cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
@Assisted private val userWallet: UserWallet,
|
||||
@Assisted private val yield: Yield,
|
||||
|
|
@ -63,7 +68,7 @@ internal class StakingTransactionSender @AssistedInject constructor(
|
|||
onConstructError: (StakingError) -> Unit,
|
||||
onSendSuccess: (String) -> Unit,
|
||||
onSendError: (SendTransactionError?) -> Unit,
|
||||
onFeeIncreased: (Fee) -> Unit,
|
||||
onFeeIncreased: (Fee, Boolean) -> Unit,
|
||||
) {
|
||||
val state = stateController.value
|
||||
|
||||
|
|
@ -101,10 +106,10 @@ internal class StakingTransactionSender @AssistedInject constructor(
|
|||
onSendError = onSendError,
|
||||
)
|
||||
} else {
|
||||
val amount = fee.amount.copy(value = totalFee)
|
||||
onFeeIncreased(
|
||||
Fee.Common(
|
||||
fee.amount.copy(value = totalFee),
|
||||
),
|
||||
Fee.Common(amount),
|
||||
isFeeApproximateUseCase(networkId = cryptoCurrencyStatus.currency.network.id, amountType = amount.type),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ internal class SetConfirmationStateAssentTransformer(
|
|||
private val appCurrencyProvider: Provider<AppCurrency>,
|
||||
private val feeCryptoCurrencyStatus: CryptoCurrencyStatus?,
|
||||
private val fee: Fee,
|
||||
private val isFeeApproximate: Boolean,
|
||||
private val cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
) : Transformer<StakingUiState> {
|
||||
|
||||
|
|
@ -31,7 +32,7 @@ internal class SetConfirmationStateAssentTransformer(
|
|||
rate = feeCryptoCurrencyStatus?.value?.fiatRate,
|
||||
isFeeConvertibleToFiat = isFeeConvertibleToFiat,
|
||||
appCurrency = appCurrencyProvider(),
|
||||
isFeeApproximate = false,
|
||||
isFeeApproximate = isFeeApproximate,
|
||||
),
|
||||
isPrimaryButtonEnabled = with(cryptoCurrencyStatus.value) {
|
||||
sources.yieldBalanceSource.isActual() && sources.networkSource.isActual()
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ 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
|
||||
|
|
@ -22,6 +23,7 @@ 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
|
||||
|
|
@ -29,6 +31,7 @@ import com.tangem.features.staking.impl.presentation.state.StakingUiState
|
|||
import com.tangem.features.staking.impl.presentation.state.utils.checkAndCalculateSubtractedAmount
|
||||
import com.tangem.features.staking.impl.presentation.state.utils.checkFeeCoverage
|
||||
import com.tangem.lib.crypto.BlockchainUtils
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isTon
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.extensions.orZero
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
|
|
@ -175,6 +178,9 @@ internal class AddStakingNotificationsTransformer(
|
|||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
onClick = prevState.clickIntents::openTokenDetails,
|
||||
)
|
||||
addTonUnstakeNotification(
|
||||
actionType = prevState.actionType,
|
||||
)
|
||||
addExceedsBalanceNotification(
|
||||
cryptoCurrencyWarning = currencyWarning,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
|
|
@ -246,7 +252,7 @@ internal class AddStakingNotificationsTransformer(
|
|||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
onClick: (CryptoCurrency) -> Unit,
|
||||
) {
|
||||
val balance = cryptoCurrencyStatus.value.amount ?: BigDecimal.ZERO
|
||||
val balance = cryptoCurrencyStatus.value.amount.orZero()
|
||||
if (!isSubtractionAvailable) return
|
||||
|
||||
val showNotification = sendingAmount + feeAmount > balance
|
||||
|
|
@ -269,4 +275,25 @@ internal class AddStakingNotificationsTransformer(
|
|||
add(notification)
|
||||
}
|
||||
}
|
||||
|
||||
private fun MutableList<NotificationUM>.addTonUnstakeNotification(actionType: StakingActionCommonType) {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
private companion object {
|
||||
val TON_BALANCE_EXTRA_FEE_THRESHOLD = BigDecimal(0.2)
|
||||
}
|
||||
}
|
||||
|
|
@ -11,11 +11,13 @@ import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
|
|||
import com.tangem.domain.staking.model.stakekit.action.StakingActionType
|
||||
import com.tangem.domain.tokens.model.CryptoCurrencyStatus
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.features.staking.impl.presentation.state.InnerYieldBalanceState
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingNotification
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingStates
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingUiState
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isCardano
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isCosmos
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isTon
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isTron
|
||||
import com.tangem.utils.Provider
|
||||
import com.tangem.utils.extensions.isZero
|
||||
|
|
@ -46,7 +48,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
when (prevState.actionType) {
|
||||
is StakingActionCommonType.Enter -> addEnterInfoNotifications(sendingAmount, feeValue)
|
||||
is StakingActionCommonType.Exit -> addExitInfoNotifications()
|
||||
is StakingActionCommonType.Exit -> addExitInfoNotifications(prevState)
|
||||
is StakingActionCommonType.Pending -> {
|
||||
addCardanoRestakeMinimumAmountNotification(feeValue)
|
||||
addPendingInfoNotifications(prevState)
|
||||
|
|
@ -54,13 +56,15 @@ internal class StakingInfoNotificationsFactory(
|
|||
}
|
||||
}
|
||||
|
||||
private fun MutableList<NotificationUM>.addExitInfoNotifications() {
|
||||
private fun MutableList<NotificationUM>.addExitInfoNotifications(prevState: StakingUiState) {
|
||||
val cooldownPeriodDays = yield.metadata.cooldownPeriod?.days
|
||||
|
||||
val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.id.value
|
||||
if (cooldownPeriodDays != null) {
|
||||
add(
|
||||
StakingNotification.Info.Unstake(
|
||||
cooldownPeriodDays = cooldownPeriodDays,
|
||||
subtitleRes = if (isCosmos(cryptoCurrencyStatusProvider().currency.network.id.value)) {
|
||||
subtitleRes = if (isCosmos(cryptoCurrencyNetworkIdValue)) {
|
||||
R.string.staking_notification_unstake_cosmos_text
|
||||
} else {
|
||||
R.string.staking_notification_unstake_text
|
||||
|
|
@ -68,6 +72,19 @@ internal class StakingInfoNotificationsFactory(
|
|||
),
|
||||
)
|
||||
}
|
||||
|
||||
val initialInfoState = prevState.initialInfoState as? StakingStates.InitialInfoState.Data
|
||||
val stakingBalances = (initialInfoState?.yieldBalance as? InnerYieldBalanceState.Data)?.balances
|
||||
val activeStakesCount = stakingBalances.orEmpty().filter { it.type == BalanceType.STAKED }.size
|
||||
|
||||
if (isTon(cryptoCurrencyNetworkIdValue) && activeStakesCount > 1) {
|
||||
add(
|
||||
StakingNotification.Info.Ordinary(
|
||||
title = resourceReference(R.string.staking_notification_ton_have_to_unstake_all_title),
|
||||
text = resourceReference(R.string.staking_notification_ton_have_to_unstake_all_text),
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun MutableList<NotificationUM>.addEnterInfoNotifications(
|
||||
|
|
|
|||
|
|
@ -5,8 +5,10 @@ import com.tangem.domain.staking.model.stakekit.Yield
|
|||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.features.staking.impl.presentation.state.utils.StakingRewardSchedule.COSMOS_SCHEDULE
|
||||
import com.tangem.features.staking.impl.presentation.state.utils.StakingRewardSchedule.SOLANA_SCHEDULE
|
||||
import com.tangem.features.staking.impl.presentation.state.utils.StakingRewardSchedule.TON_SCHEDULE
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isCosmos
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isSolana
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isTon
|
||||
import com.tangem.lib.crypto.BlockchainUtils.isTron
|
||||
import com.tangem.utils.StringsSigns.MINUS
|
||||
import com.tangem.utils.StringsSigns.NON_BREAKING_SPACE
|
||||
|
|
@ -14,6 +16,7 @@ import com.tangem.utils.StringsSigns.NON_BREAKING_SPACE
|
|||
private data object StakingRewardSchedule {
|
||||
val COSMOS_SCHEDULE = 5 to 12
|
||||
val SOLANA_SCHEDULE = 2 to 3
|
||||
val TON_SCHEDULE = 1 to 2
|
||||
}
|
||||
|
||||
internal fun getRewardScheduleText(
|
||||
|
|
@ -71,6 +74,15 @@ private fun getCustomRewardSchedule(networkId: String, decapitalize: Boolean = f
|
|||
)
|
||||
}
|
||||
isTron(networkId) -> resourceReference(id = R.string.staking_reward_schedule_day, decapitalize = decapitalize)
|
||||
isTon(networkId) -> combinedReference(
|
||||
resourceReference(id = R.string.staking_reward_schedule_each_plural, decapitalize = decapitalize),
|
||||
stringReference(NON_BREAKING_SPACE.toString()),
|
||||
stringReference("${TON_SCHEDULE.first}$MINUS${TON_SCHEDULE.second}$NON_BREAKING_SPACE"),
|
||||
pluralReference(
|
||||
id = R.plurals.common_days_no_param,
|
||||
count = TON_SCHEDULE.second,
|
||||
),
|
||||
)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue