Updated on 2026-08-14

This commit is contained in:
Tangem 2025-02-04 12:21:17 +05:00
parent 1fe12ed9d7
commit ce63ab2d17
5 changed files with 38 additions and 12 deletions

View file

@ -784,6 +784,8 @@
<string name="staking_details_unbonding_period_info">The period you must wait after requesting to withdraw funds from staking before the tokens become available.</string>
<string name="staking_details_warmup_period">Warmup period</string>
<string name="staking_details_warmup_period_info">The allocated time for activating participation in staking.</string>
<string name="staking_error_no_validators_message">No available validators at the moment. Please try again later.</string>
<string name="staking_error_no_validators_title">Staking Unavailable</string>
<string name="staking_give_permission_fee_footer">The network will charge a token approval fee to verify that you are authorizing the use of your token for the staking.</string>
<string name="staking_legal">By using staking functionality, you agree with providers %1$s and %2$s</string>
<string name="staking_locked">Locked</string>

View file

@ -18,6 +18,8 @@ data class Yield(
val isAvailable: Boolean,
) {
val allValidatorsFull: Boolean = validators.all { it.status == Validator.ValidatorStatus.FULL }
val preferredValidators: List<Validator>
get() = validators.filter { it.preferred }

View file

@ -41,4 +41,11 @@ internal sealed class StakingAlertUM : AlertUM {
override val message: TextReference = resourceReference(id = R.string.send_notification_high_fee_title)
override val confirmButtonText: TextReference = resourceReference(id = R.string.common_ok)
}
data object ValidatorsUnavailable : StakingAlertUM() {
override val onConfirmClick: (() -> Unit)? = null
override val title: TextReference = resourceReference(id = R.string.staking_error_no_validators_title)
override val message: TextReference = resourceReference(id = R.string.staking_error_no_validators_message)
override val confirmButtonText: TextReference = resourceReference(id = R.string.common_ok)
}
}

View file

@ -41,4 +41,9 @@ internal class StakingEventFactory(
)
stateController.updateEvent(alert)
}
fun createStakingValidatorsUnavailableAlert() {
val alert = StakingEvent.ShowAlert(alert = StakingAlertUM.ValidatorsUnavailable)
stateController.updateEvent(alert)
}
}

View file

@ -232,18 +232,28 @@ internal class StakingViewModel @Inject constructor(
}
override fun onNextClick(balanceState: BalanceState?) {
if (value.currentStep == StakingStep.InitialInfo && balanceState == null) {
stateController.update(
SetConfirmationStateInitTransformer(
isEnter = true,
isExplicitExit = false,
balanceState = null,
cryptoCurrencyStatus = cryptoCurrencyStatus,
stakingApproval = stakingApproval,
stakingAllowance = stakingAllowance,
yieldArgs = yield.args,
),
)
val isInitialInfoStep = value.currentStep == StakingStep.InitialInfo
val noBalanceState = balanceState == null
val noYieldBalanceData = cryptoCurrencyStatus.value.yieldBalance !is YieldBalance.Data
when {
isInitialInfoStep && noBalanceState && yield.allValidatorsFull && noYieldBalanceData -> {
stakingEventFactory.createStakingValidatorsUnavailableAlert()
return
}
isInitialInfoStep && noBalanceState -> {
stateController.update(
SetConfirmationStateInitTransformer(
isEnter = true,
isExplicitExit = false,
balanceState = null,
cryptoCurrencyStatus = cryptoCurrencyStatus,
stakingApproval = stakingApproval,
stakingAllowance = stakingAllowance,
yieldArgs = yield.args,
),
)
}
}
stakingStateRouter.onNextClick()
}