Updated on 2026-08-14

This commit is contained in:
Tangem 2025-05-26 12:35:48 +03:00
parent d24c98889c
commit 5ab0f235d1

View file

@ -17,6 +17,7 @@ import com.tangem.domain.tokens.model.CryptoCurrencyStatus
import com.tangem.features.staking.impl.R
import com.tangem.features.staking.impl.presentation.state.BalanceState
import com.tangem.lib.crypto.BlockchainUtils
import com.tangem.lib.crypto.BlockchainUtils.isTon
import com.tangem.utils.Provider
import com.tangem.utils.converter.Converter
import com.tangem.utils.extensions.orZero
@ -65,7 +66,7 @@ internal class BalanceItemConverter(
),
rawCurrencyId = value.rawCurrencyId,
pendingActions = value.pendingActions.toPersistentList(),
isClickable = value.type.isClickable() && !value.isPending,
isClickable = value.isClickable(),
isPending = value.isPending,
)
}
@ -151,6 +152,17 @@ internal class BalanceItemConverter(
}
}
private fun BalanceItem.isClickable(): Boolean {
val networkId = cryptoCurrencyStatus.currency.network.id.value
return when {
// TON allows withdrawing funds in the preparing state, unlike other networks.
isTon(networkId) && this.type == BalanceType.PREPARING -> {
pendingActions.any { it.type == StakingActionType.WITHDRAW }
}
else -> this.type.isClickable() && !this.isPending
}
}
private fun Calendar.resetHours() {
this[Calendar.HOUR_OF_DAY] = 0
this[Calendar.MINUTE] = 0