Updated on 2026-08-14

This commit is contained in:
Tangem 2025-12-30 11:46:31 +03:00
commit 14a7ac4f5e
431 changed files with 23077 additions and 3701 deletions

View file

@ -2,6 +2,7 @@ package com.tangem.feature.tokendetails.presentation.router
import com.tangem.common.routing.AppRoute
import com.tangem.common.routing.AppRouter
import com.tangem.domain.staking.model.StakingIntegrationID
import com.tangem.core.decompose.di.ModelScoped
import com.tangem.core.navigation.share.ShareManager
import com.tangem.core.navigation.url.UrlOpener
@ -37,12 +38,16 @@ internal class DefaultTokenDetailsRouter @Inject constructor(
)
}
override fun openStaking(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency, yieldId: String) {
override fun openStaking(
userWalletId: UserWalletId,
cryptoCurrency: CryptoCurrency,
integrationId: StakingIntegrationID,
) {
router.push(
AppRoute.Staking(
userWalletId = userWalletId,
cryptoCurrency = cryptoCurrency,
yieldId = yieldId,
integrationId = integrationId,
),
)
}

View file

@ -1,5 +1,6 @@
package com.tangem.feature.tokendetails.presentation.router
import com.tangem.domain.staking.model.StakingIntegrationID
import com.tangem.domain.models.currency.CryptoCurrency
import com.tangem.domain.models.wallet.UserWalletId
@ -16,5 +17,5 @@ internal interface InnerTokenDetailsRouter {
fun openTokenDetails(userWalletId: UserWalletId, currency: CryptoCurrency)
fun openStaking(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency, yieldId: String)
fun openStaking(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency, integrationId: StakingIntegrationID)
}

View file

@ -54,7 +54,6 @@ import com.tangem.domain.promo.models.PromoId
import com.tangem.domain.redux.ReduxStateHolder
import com.tangem.domain.staking.GetStakingAvailabilityUseCase
import com.tangem.domain.staking.GetStakingEntryInfoUseCase
import com.tangem.domain.staking.GetYieldUseCase
import com.tangem.domain.staking.model.StakingAvailability
import com.tangem.domain.tokens.*
import com.tangem.domain.tokens.legacy.TradeCryptoAction
@ -124,7 +123,6 @@ internal class TokenDetailsModel @Inject constructor(
private val getExtendedPublicKeyForCurrencyUseCase: GetExtendedPublicKeyForCurrencyUseCase,
private val getStakingEntryInfoUseCase: GetStakingEntryInfoUseCase,
private val getStakingAvailabilityUseCase: GetStakingAvailabilityUseCase,
private val getYieldUseCase: GetYieldUseCase,
private val networkHasDerivationUseCase: NetworkHasDerivationUseCase,
private val isDemoCardUseCase: IsDemoCardUseCase,
private val associateAssetUseCase: AssociateAssetUseCase,
@ -1119,18 +1117,28 @@ internal class TokenDetailsModel @Inject constructor(
private fun openStaking() {
modelScope.launch {
getYieldUseCase.invoke(
cryptoCurrencyId = cryptoCurrency.id,
symbol = cryptoCurrency.symbol,
).onRight { yield ->
router.openStaking(userWalletId, cryptoCurrency, yield.id)
}.onLeft {
Timber.e("Staking is unavailable for ${cryptoCurrency.name}")
uiMessageSender.send(SnackbarMessage(resourceReference(R.string.staking_error_no_validators_title)))
}
getStakingAvailabilityUseCase.invokeSync(userWalletId, cryptoCurrency)
.onRight { availability ->
val option = (availability as? StakingAvailability.Available)?.option
if (option != null) {
router.openStaking(
userWalletId = userWalletId,
cryptoCurrency = cryptoCurrency,
integrationId = option.integrationId,
)
} else {
showStakingUnavailable()
}
}
.onLeft { showStakingUnavailable() }
}
}
private fun showStakingUnavailable() {
Timber.e("Staking is unavailable for ${cryptoCurrency.name}")
uiMessageSender.send(SnackbarMessage(resourceReference(R.string.staking_error_no_validators_title)))
}
private fun checkForActionUpdates() {
combine(
tokenDetailsDeepLinkActionListener.tokenDetailsActionFlow,

View file

@ -62,12 +62,12 @@ internal class TokenDetailsStakingInfoConverter(
val hasPendingBalances = when (stakingBalance) {
is StakingBalance.Data.StakeKit -> stakingBalance.balance.items.isNotEmpty()
is StakingBalance.Data.P2P -> !stakingBalance.unstakingAmount.isNullOrZero()
is StakingBalance.Data.P2PEthPool -> !stakingBalance.unstakingAmount.isNullOrZero()
null -> false
}
val pendingAmount = when (stakingBalance) {
is StakingBalance.Data.StakeKit -> stakingBalance.balance.items.sumOf { it.amount }
is StakingBalance.Data.P2P -> stakingBalance.unstakingAmount
is StakingBalance.Data.P2PEthPool -> stakingBalance.unstakingAmount
null -> BigDecimal.ZERO
}
@ -98,7 +98,7 @@ internal class TokenDetailsStakingInfoConverter(
stakingAmount = stakingCryptoAmount,
rewardAmount = when (stakingBalance) {
is StakingBalance.Data.StakeKit -> stakingBalance.getRewardStakingBalance()
is StakingBalance.Data.P2P -> stakingBalance.totalRewards
is StakingBalance.Data.P2PEthPool -> stakingBalance.totalRewards
else -> BigDecimal.ZERO
},
)
@ -174,8 +174,12 @@ internal class TokenDetailsStakingInfoConverter(
private fun getRewardText(status: CryptoCurrencyStatus, stakingRewardAmount: BigDecimal?): TextReference {
val blockchainId = status.currency.network.rawId
val isCoin = status.currency.id.isCoin
val rewardBlockType = when {
isStakingRewardUnavailable(blockchainId) -> RewardBlockType.RewardUnavailable.DefaultRewardUnavailable
isStakingRewardUnavailable(blockchainId, isCoin) -> {
RewardBlockType.RewardUnavailable.DefaultRewardUnavailable
}
stakingRewardAmount.isNullOrZero() -> RewardBlockType.NoRewards
else -> RewardBlockType.Rewards
}