Updated on 2026-08-14
This commit is contained in:
parent
33b7a53905
commit
c5560c3c6a
101 changed files with 274 additions and 272 deletions
|
|
@ -549,7 +549,7 @@ internal class StakingModel @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onActiveStake(activeStake: BalanceState) {
|
||||
val networkId = cryptoCurrencyStatus.currency.network.id.value
|
||||
val networkId = cryptoCurrencyStatus.currency.network.rawId
|
||||
if (isSingleAction(networkId, activeStake)) {
|
||||
prepareForConfirmation(
|
||||
balanceType = activeStake.type,
|
||||
|
|
@ -854,7 +854,7 @@ internal class StakingModel @Inject constructor(
|
|||
saveBlockchainErrorUseCase(
|
||||
error = BlockchainErrorInfo(
|
||||
errorMessage = errorMessage,
|
||||
blockchainId = network.id.value,
|
||||
blockchainId = network.rawId,
|
||||
derivationPath = network.derivationPath.value,
|
||||
destinationAddress = validator?.address.orEmpty(),
|
||||
tokenSymbol = (cryptoCurrencyStatus.currency as? CryptoCurrency.Token)?.symbol,
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ internal class BalanceItemConverter(
|
|||
|
||||
private fun BalanceItem.getBalanceValue(): BigDecimal {
|
||||
val isIncludeStakingTotalBalance = BlockchainUtils.isIncludeStakingTotalBalance(
|
||||
blockchainId = cryptoCurrencyStatus.currency.network.id.value,
|
||||
blockchainId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
)
|
||||
val yieldBalance = cryptoCurrencyStatus.value.yieldBalance as? YieldBalance.Data
|
||||
return if (isIncludeStakingTotalBalance) {
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ internal class YieldBalancesConverter(
|
|||
.toPersistentList()
|
||||
|
||||
private fun getRewardBlockType(): RewardBlockType {
|
||||
val blockchainId = cryptoCurrencyStatus.currency.network.id.value
|
||||
val blockchainId = cryptoCurrencyStatus.currency.network.rawId
|
||||
val yieldBalance = cryptoCurrencyStatus.value.yieldBalance as? YieldBalance.Data
|
||||
val rewards = yieldBalance?.balance?.items
|
||||
?.filter { it.type == BalanceType.REWARDS && !it.amount.isZero() }
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ internal class StakingFeeTransactionLoader @AssistedInject constructor(
|
|||
?: error("No available address")
|
||||
|
||||
val gasEstimate = if (isCompositePendingActions(
|
||||
networkId = cryptoCurrencyStatus.currency.network.id.value,
|
||||
networkId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
pendingActions = pendingActions,
|
||||
)
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -120,8 +120,8 @@ internal class StakingTransactionSender @AssistedInject constructor(
|
|||
onConstructError: (StakingError) -> Unit,
|
||||
) = coroutineScope {
|
||||
val isComposePendingActions = isCompositePendingActions(
|
||||
cryptoCurrencyStatus.currency.network.id.value,
|
||||
confirmationState.pendingActions,
|
||||
networkId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
pendingActions = confirmationState.pendingActions,
|
||||
)
|
||||
if (isComposePendingActions) {
|
||||
confirmationState.pendingActions?.map { action ->
|
||||
|
|
@ -156,7 +156,7 @@ internal class StakingTransactionSender @AssistedInject constructor(
|
|||
?.map { transaction ->
|
||||
async {
|
||||
getConstructedStakingTransactionUseCase(
|
||||
networkId = cryptoCurrencyStatus.currency.network.id.value,
|
||||
networkId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
fee = fee,
|
||||
amount = amount.convertToSdkAmount(cryptoCurrencyStatus.currency),
|
||||
transactionId = transaction.id,
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ internal class SetConfirmationStateInitTransformer(
|
|||
) : Transformer<StakingUiState> {
|
||||
|
||||
private val networkId
|
||||
get() = cryptoCurrencyStatus.currency.network.id.value
|
||||
get() = cryptoCurrencyStatus.currency.network.rawId
|
||||
|
||||
private val isComposePendingActions
|
||||
get() = isCompositePendingActions(networkId, pendingActions)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,9 @@ import com.tangem.domain.staking.model.stakekit.Yield
|
|||
import com.tangem.domain.staking.model.stakekit.action.StakingActionCommonType
|
||||
import com.tangem.domain.tokens.model.CryptoCurrency
|
||||
import com.tangem.features.staking.impl.R
|
||||
import com.tangem.features.staking.impl.presentation.state.*
|
||||
import com.tangem.features.staking.impl.presentation.state.FeeState
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingStates
|
||||
import com.tangem.features.staking.impl.presentation.state.StakingUiState
|
||||
import com.tangem.features.staking.impl.presentation.state.utils.getRewardScheduleText
|
||||
import com.tangem.utils.transformer.Transformer
|
||||
|
||||
|
|
@ -47,7 +49,7 @@ internal class SetConfirmationStateLoadingTransformer(
|
|||
}
|
||||
val rewardSchedule = getRewardScheduleText(
|
||||
rewardSchedule = yield.metadata.rewardSchedule,
|
||||
networkId = cryptoCurrency.network.id.value,
|
||||
networkId = cryptoCurrency.network.rawId,
|
||||
decapitalize = true,
|
||||
)
|
||||
return if (isEnterAction && amountDecimal != null && rewardSchedule != null) {
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ internal class SetInitialDataStateTransformer(
|
|||
title = TextReference.EMPTY,
|
||||
cryptoCurrencyName = cryptoCurrency.name,
|
||||
cryptoCurrencySymbol = cryptoCurrency.symbol,
|
||||
cryptoCurrencyBlockchainId = cryptoCurrency.network.id.value,
|
||||
cryptoCurrencyBlockchainId = cryptoCurrency.network.rawId,
|
||||
clickIntents = clickIntents,
|
||||
currentStep = StakingStep.InitialInfo,
|
||||
initialInfoState = createInitialInfoState(),
|
||||
|
|
@ -150,7 +150,7 @@ internal class SetInitialDataStateTransformer(
|
|||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
): RoundedListWithDividersItemData? {
|
||||
val minimumCryptoAmount = yield.args.enter.args[Yield.Args.ArgType.AMOUNT]?.minimum ?: return null
|
||||
val blockchainId = cryptoCurrencyStatus.currency.network.id.value
|
||||
val blockchainId = cryptoCurrencyStatus.currency.network.rawId
|
||||
if (!showMinimumRequirementInfo(blockchainId)) return null
|
||||
|
||||
val formattedAmount = minimumCryptoAmount.format { crypto(cryptoCurrencyStatus.currency) }
|
||||
|
|
@ -193,7 +193,7 @@ internal class SetInitialDataStateTransformer(
|
|||
private fun createRewardScheduleItem(): RoundedListWithDividersItemData? {
|
||||
val endTextReference = getRewardScheduleText(
|
||||
rewardSchedule = yield.metadata.rewardSchedule,
|
||||
networkId = cryptoCurrencyStatus.currency.network.id.value,
|
||||
networkId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
decapitalize = false,
|
||||
) ?: return null
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ internal class AmountRequirementStateTransformer(
|
|||
val cryptoAmountValue = amountState.amountTextField.cryptoAmount.value ?: return false
|
||||
|
||||
val isEnterOrExit = actionType is StakingActionCommonType.Enter || actionType is StakingActionCommonType.Exit
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.rawId)
|
||||
|
||||
val isIntegerOnly = cryptoAmountValue.isZero() || cryptoAmountValue.remainder(BigDecimal.ONE).isZero()
|
||||
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ internal class AddStakingNotificationsTransformer(
|
|||
onClick = prevState.clickIntents::openTokenDetails,
|
||||
onAnalyticsEvent = { /* no-op */ },
|
||||
)
|
||||
if (!BlockchainUtils.isCardano(network.id.value)) {
|
||||
if (!BlockchainUtils.isCardano(network.rawId)) {
|
||||
addDustWarningNotification(
|
||||
dustValue = currencyCheck.dustValue,
|
||||
feeValue = feeValue,
|
||||
|
|
@ -278,7 +278,7 @@ internal class AddStakingNotificationsTransformer(
|
|||
|
||||
private fun MutableList<NotificationUM>.addTonUnstakeNotification(actionType: StakingActionCommonType) {
|
||||
val amount = cryptoCurrencyStatusProvider().value.amount.orZero()
|
||||
val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.id.value
|
||||
val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.rawId
|
||||
|
||||
if (isTon(cryptoCurrencyNetworkIdValue) && actionType !is StakingActionCommonType.Enter) {
|
||||
val notification = if (amount < TON_BALANCE_EXTRA_FEE_THRESHOLD) {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
private fun MutableList<NotificationUM>.addExitInfoNotifications(prevState: StakingUiState) {
|
||||
val cooldownPeriodDays = yield.metadata.cooldownPeriod?.days
|
||||
|
||||
val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.id.value
|
||||
val cryptoCurrencyNetworkIdValue = cryptoCurrencyStatusProvider().currency.network.rawId
|
||||
if (cooldownPeriodDays != null) {
|
||||
add(
|
||||
StakingNotification.Info.Unstake(
|
||||
|
|
@ -155,7 +155,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
private fun MutableList<NotificationUM>.addTronRevoteNotification() {
|
||||
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val hasStakedBalance = (cryptoCurrencyStatus.value.yieldBalance as? YieldBalance.Data)?.balance
|
||||
?.items?.any {
|
||||
it.type == BalanceType.PREPARING ||
|
||||
|
|
@ -174,7 +174,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
private fun MutableList<NotificationUM>.addCardanoStakeNotification() {
|
||||
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.rawId)
|
||||
|
||||
if (isCardano) {
|
||||
add(
|
||||
|
|
@ -188,7 +188,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
private fun MutableList<NotificationUM>.addCardanoStakeMinimumAmountNotification(feeValue: BigDecimal) {
|
||||
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val balance = cryptoCurrencyStatus.value.amount.orZero()
|
||||
if (isCardano && balance - feeValue < MINIMUM_STAKE_BALANCE) {
|
||||
add(
|
||||
|
|
@ -202,7 +202,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
private fun MutableList<NotificationUM>.addCardanoRestakeMinimumAmountNotification(feeValue: BigDecimal) {
|
||||
val cryptoCurrencyStatus = cryptoCurrencyStatusProvider()
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isCardano = isCardano(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val balance = cryptoCurrencyStatus.value.amount.orZero()
|
||||
if (isCardano && balance - feeValue < MINIMUM_RESTAKE_BALANCE) {
|
||||
add(
|
||||
|
|
@ -223,7 +223,7 @@ internal class StakingInfoNotificationsFactory(
|
|||
|
||||
val isEntireBalance = sendingAmount.plus(feeValue) == balance
|
||||
|
||||
if (isEntireBalance && isSubtractAvailable && !isCardano(cryptoCurrencyStatus.currency.network.id.value)) {
|
||||
if (isEntireBalance && isSubtractAvailable && !isCardano(cryptoCurrencyStatus.currency.network.rawId)) {
|
||||
add(StakingNotification.Info.StakeEntireBalance)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ internal fun checkAndCalculateSubtractedAmount(
|
|||
reduceAmountBy: BigDecimal,
|
||||
): BigDecimal {
|
||||
val balance = cryptoCurrencyStatus.value.amount ?: return amountValue
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.id.value)
|
||||
val isTron = isTron(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val feeValueRounded = if (isTron) {
|
||||
feeValue.round(MathContext(0, RoundingMode.UP))
|
||||
} else {
|
||||
|
|
@ -32,7 +32,7 @@ internal fun checkAndCalculateSubtractedAmount(
|
|||
)
|
||||
return if (isFeeCoverage) {
|
||||
val reducedAmount = balance.minus(reduceAmountBy).minus(feeValueRounded)
|
||||
if (isTron(cryptoCurrencyStatus.currency.network.id.value)) {
|
||||
if (isTron(cryptoCurrencyStatus.currency.network.rawId)) {
|
||||
reducedAmount.setScale(0, RoundingMode.DOWN)
|
||||
} else {
|
||||
reducedAmount
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue