Updated on 2026-08-14

This commit is contained in:
Tangem 2024-07-18 19:05:50 +03:00
parent 4354a1f64d
commit 97ff092d70
4 changed files with 64 additions and 10 deletions

View file

@ -453,12 +453,7 @@ internal class TokenDetailsViewModel @Inject constructor(
}
override fun onStakeBannerClick() {
viewModelScope.launch {
val yield = getYieldUseCase.invoke(cryptoCurrency.id, cryptoCurrency.symbol).getOrNull()
yield ?: error("Staking is unavailable")
router.openStaking(userWalletId, cryptoCurrency, yield)
}
openStaking()
}
override fun onReloadClick() {
@ -559,7 +554,9 @@ internal class TokenDetailsViewModel @Inject constructor(
}
override fun onStakeClick(unavailabilityReason: ScenarioUnavailabilityReason) {
Timber.e("Not implemented yet")
if (handleUnavailabilityReason(unavailabilityReason)) return
openStaking()
}
override fun onGenerateExtendedKey() {
@ -835,6 +832,19 @@ internal class TokenDetailsViewModel @Inject constructor(
return true
}
private fun openStaking() {
viewModelScope.launch {
val yield = getYieldUseCase.invoke(
cryptoCurrencyId = cryptoCurrency.id,
symbol = cryptoCurrency.symbol,
).getOrElse {
error("Staking is unavailable for ${cryptoCurrency.name}")
}
router.openStaking(userWalletId, cryptoCurrency, yield)
}
}
private companion object {
const val EXCHANGE_STATUS_UPDATE_DELAY = 10_000L
}