Updated on 2026-08-14
This commit is contained in:
parent
f48154daa9
commit
320b3deffb
14 changed files with 199 additions and 22 deletions
|
|
@ -15,6 +15,8 @@ import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
|||
import com.tangem.domain.appcurrency.model.AppCurrency
|
||||
import com.tangem.domain.balancehiding.GetBalanceHidingSettingsUseCase
|
||||
import com.tangem.domain.staking.InitializeStakingProcessUseCase
|
||||
import com.tangem.domain.staking.SaveUnsubmittedHashUseCase
|
||||
import com.tangem.domain.staking.SubmitHashUseCase
|
||||
import com.tangem.domain.staking.model.Yield
|
||||
import com.tangem.domain.staking.model.transaction.StakingTransaction
|
||||
import com.tangem.domain.tokens.GetCryptoCurrencyStatusSyncUseCase
|
||||
|
|
@ -58,6 +60,8 @@ internal class StakingViewModel @Inject constructor(
|
|||
private val initializeStakingProcessUseCase: InitializeStakingProcessUseCase,
|
||||
private val sendTransactionUseCase: SendTransactionUseCase,
|
||||
private val getExplorerTransactionUrlUseCase: GetExplorerTransactionUrlUseCase,
|
||||
private val saveUnsubmittedHashUseCase: SaveUnsubmittedHashUseCase,
|
||||
private val submitHashUseCase: SubmitHashUseCase,
|
||||
savedStateHandle: SavedStateHandle,
|
||||
) : ViewModel(), DefaultLifecycleObserver, StakingClickIntents {
|
||||
|
||||
|
|
@ -286,12 +290,17 @@ internal class StakingViewModel @Inject constructor(
|
|||
)
|
||||
},
|
||||
ifRight = { txHash ->
|
||||
val gasEstimate = stakingTransaction?.gasEstimate ?: return@fold
|
||||
val transaction = stakingTransaction ?: return@fold
|
||||
|
||||
submitHash(transaction.id, txHash)
|
||||
|
||||
val txUrl = getExplorerTransactionUrlUseCase(
|
||||
txHash = txHash,
|
||||
networkId = cryptoCurrencyStatus.currency.network.id,
|
||||
).getOrElse { "" }
|
||||
|
||||
val gasEstimate = transaction.gasEstimate ?: error("No gas for transaction")
|
||||
|
||||
stateController.update(
|
||||
SetConfirmationStateCompletedTransformer(
|
||||
appCurrencyProvider = Provider { appCurrency },
|
||||
|
|
@ -304,6 +313,21 @@ internal class StakingViewModel @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private suspend fun submitHash(transactionId: String, transactionHash: String) {
|
||||
submitHashUseCase.submitHash(
|
||||
transactionId = transactionId,
|
||||
transactionHash = transactionHash,
|
||||
)
|
||||
.onLeft {
|
||||
saveUnsubmittedHashUseCase.invoke(
|
||||
transactionId = transactionId,
|
||||
transactionHash = transactionHash,
|
||||
)
|
||||
}.onRight {
|
||||
Timber.d("Successful hash submission")
|
||||
}
|
||||
}
|
||||
|
||||
private fun isAssentState(): Boolean {
|
||||
return value.currentStep == StakingStep.Confirmation &&
|
||||
(value.confirmationState as? StakingStates.ConfirmationState.Data)?.innerState ==
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue