Updated on 2026-08-14

This commit is contained in:
Tangem 2024-09-03 11:48:29 +05:00
parent 0d185108da
commit 2a6fd5ee3d
2 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,23 @@
package com.tangem.features.staking.impl.presentation.state.transformers
import com.tangem.features.staking.impl.presentation.state.InnerConfirmationStakingState
import com.tangem.features.staking.impl.presentation.state.StakingStates
import com.tangem.features.staking.impl.presentation.state.StakingUiState
import com.tangem.utils.transformer.Transformer
internal object SetConfirmationStateResetAssentTransformer : Transformer<StakingUiState> {
override fun transform(prevState: StakingUiState): StakingUiState {
val confirmationState = prevState.confirmationState
return prevState.copy(
confirmationState = if (confirmationState is StakingStates.ConfirmationState.Data) {
confirmationState.copy(
isPrimaryButtonEnabled = true,
innerState = InnerConfirmationStakingState.ASSENT,
validatorState = confirmationState.validatorState.copySealed(isClickable = true),
)
} else {
confirmationState
},
)
}
}

View file

@ -253,6 +253,7 @@ internal class StakingViewModel @Inject constructor(
).getOrElse {
Timber.e(it.toString())
stakingEventFactory.createStakingErrorAlert(it)
stateController.update(SetConfirmationStateResetAssentTransformer)
return@launch
}
@ -266,6 +267,7 @@ internal class StakingViewModel @Inject constructor(
).getOrElse {
Timber.e(it.toString())
stakingEventFactory.createStakingErrorAlert(it)
stateController.update(SetConfirmationStateResetAssentTransformer)
return@launch
}
@ -469,6 +471,7 @@ internal class StakingViewModel @Inject constructor(
),
)
stakingEventFactory.createGenericErrorAlert(error.message ?: error.toString())
stateController.update(SetConfirmationStateResetAssentTransformer)
return@launch
},
ifRight = { it },
@ -489,6 +492,7 @@ internal class StakingViewModel @Inject constructor(
),
)
stakingEventFactory.createSendTransactionErrorAlert(error)
stateController.update(SetConfirmationStateResetAssentTransformer)
},
ifRight = {
stateController.update(SetApprovalInProgressTransformer)
@ -687,6 +691,7 @@ internal class StakingViewModel @Inject constructor(
ifLeft = {
Timber.e(it.toString())
stakingEventFactory.createGenericErrorAlert(it.toString())
stateController.update(SetConfirmationStateResetAssentTransformer)
},
)
getCryptoCurrencyStatusSyncUseCase(userWalletId, cryptoCurrencyId).fold(
@ -711,6 +716,7 @@ internal class StakingViewModel @Inject constructor(
ifLeft = {
Timber.e(it.toString())
stakingEventFactory.createGenericErrorAlert(it.toString())
stateController.update(SetConfirmationStateResetAssentTransformer)
},
)
}
@ -759,6 +765,7 @@ internal class StakingViewModel @Inject constructor(
),
)
stakingEventFactory.createSendTransactionErrorAlert(error)
stateController.update(SetConfirmationStateResetAssentTransformer)
},
ifRight = { transactionHashes ->
transactionsInProgress.clear()