Updated on 2026-08-14
This commit is contained in:
parent
44f7f23a95
commit
d6735f937f
11 changed files with 1 additions and 143 deletions
|
|
@ -57,7 +57,6 @@ internal sealed class StakingStates {
|
|||
val aprRange: TextReference,
|
||||
val onInfoClick: (InfoType) -> Unit,
|
||||
val yieldBalance: InnerYieldBalanceState,
|
||||
val isStakeMoreAvailable: Boolean,
|
||||
) : InitialInfoState()
|
||||
|
||||
data class Empty(
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ internal object InitialStakingStatePreview {
|
|||
),
|
||||
onInfoClick = {},
|
||||
yieldBalance = InnerYieldBalanceState.Empty,
|
||||
isStakeMoreAvailable = true,
|
||||
)
|
||||
|
||||
val stateWithYield = defaultState.copy(
|
||||
|
|
|
|||
|
|
@ -119,7 +119,6 @@ internal class SetButtonsStateTransformer : Transformer<StakingUiState> {
|
|||
private fun List<PendingAction>.getSecondaryAction(): PendingAction? = getOrNull(1)
|
||||
|
||||
private fun StakingUiState.isButtonsVisible(): Boolean = when (currentStep) {
|
||||
StakingStep.InitialInfo -> isStakeMoreAvailable()
|
||||
StakingStep.RewardsValidators -> false
|
||||
else -> true
|
||||
}
|
||||
|
|
@ -170,7 +169,7 @@ internal class SetButtonsStateTransformer : Transformer<StakingUiState> {
|
|||
private fun StakingUiState.onPrimaryClick() {
|
||||
when (currentStep) {
|
||||
StakingStep.InitialInfo -> {
|
||||
val actionType = StakingActionCommonType.ENTER.takeIf { isStakeMoreAvailable() }
|
||||
val actionType = StakingActionCommonType.ENTER
|
||||
clickIntents.onAmountValueChange("") // reset amount state
|
||||
clickIntents.onNextClick(actionType)
|
||||
}
|
||||
|
|
@ -241,9 +240,4 @@ internal class SetButtonsStateTransformer : Transformer<StakingUiState> {
|
|||
StakingActionType.UNKNOWN -> TextReference.EMPTY
|
||||
null -> TextReference.EMPTY
|
||||
}
|
||||
|
||||
private fun StakingUiState.isStakeMoreAvailable(): Boolean {
|
||||
val initialState = initialInfoState as? StakingStates.InitialInfoState.Data
|
||||
return initialState?.isStakeMoreAvailable == true || initialState?.yieldBalance is InnerYieldBalanceState.Empty
|
||||
}
|
||||
}
|
||||
|
|
@ -33,7 +33,6 @@ import java.math.BigDecimal
|
|||
internal class SetInitialDataStateTransformer(
|
||||
private val clickIntents: StakingClickIntents,
|
||||
private val yield: Yield,
|
||||
private val isStakeMoreAvailable: Boolean,
|
||||
private val isApprovalNeeded: Boolean,
|
||||
private val cryptoCurrencyStatusProvider: Provider<CryptoCurrencyStatus>,
|
||||
private val userWalletProvider: Provider<UserWallet>,
|
||||
|
|
@ -84,7 +83,6 @@ internal class SetInitialDataStateTransformer(
|
|||
infoItems = getInfoItems(),
|
||||
onInfoClick = clickIntents::onInfoClick,
|
||||
yieldBalance = yieldBalancesConverter.convert(Unit),
|
||||
isStakeMoreAvailable = isStakeMoreAvailable,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,7 +89,6 @@ internal class StakingViewModel @Inject constructor(
|
|||
private val getExplorerTransactionUrlUseCase: GetExplorerTransactionUrlUseCase,
|
||||
private val saveUnsubmittedHashUseCase: SaveUnsubmittedHashUseCase,
|
||||
private val submitHashUseCase: SubmitHashUseCase,
|
||||
private val isStakeMoreAvailableUseCase: IsStakeMoreAvailableUseCase,
|
||||
private val stakingYieldBalanceUseCase: FetchStakingYieldBalanceUseCase,
|
||||
private val updateDelayedNetworkStatusUseCase: UpdateDelayedNetworkStatusUseCase,
|
||||
private val fetchPendingTransactionsUseCase: FetchPendingTransactionsUseCase,
|
||||
|
|
@ -581,13 +580,10 @@ internal class StakingViewModel @Inject constructor(
|
|||
|
||||
setupApprovalNeeded()
|
||||
|
||||
val networkId = cryptoCurrencyStatus.currency.network.id
|
||||
val isStakeMoreAvailable = isStakeMoreAvailableUseCase(networkId)
|
||||
stateController.update(
|
||||
transformer = SetInitialDataStateTransformer(
|
||||
clickIntents = this@StakingViewModel,
|
||||
yield = yield,
|
||||
isStakeMoreAvailable = isStakeMoreAvailable.getOrElse { false },
|
||||
isApprovalNeeded = stakingApproval is StakingApproval.Needed,
|
||||
cryptoCurrencyStatusProvider = Provider { cryptoCurrencyStatus },
|
||||
userWalletProvider = Provider { userWallet },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue