Updated on 2026-08-14

This commit is contained in:
Tangem 2025-09-16 17:51:07 +03:00
parent 5c56f04c38
commit 9bd372d0af
6 changed files with 47 additions and 13 deletions

View file

@ -15,6 +15,7 @@ import com.tangem.datasource.api.tangemTech.TangemTechApi
import com.tangem.datasource.local.token.UserTokensResponseStore import com.tangem.datasource.local.token.UserTokensResponseStore
import com.tangem.datasource.local.userwallet.UserWalletsStore import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.card.common.extensions.canHandleBlockchain import com.tangem.domain.card.common.extensions.canHandleBlockchain
import com.tangem.domain.card.common.extensions.hotWalletExcludedBlockchains
import com.tangem.domain.card.common.extensions.supportedBlockchains import com.tangem.domain.card.common.extensions.supportedBlockchains
import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.card.common.util.cardTypesResolver
import com.tangem.domain.managetokens.model.AddCustomTokenForm import com.tangem.domain.managetokens.model.AddCustomTokenForm
@ -252,7 +253,9 @@ internal class DefaultCustomTokensRepository(
is UserWallet.Hot -> { is UserWallet.Hot -> {
Blockchain.entries.mapNotNull { Blockchain.entries.mapNotNull {
// TODO: refactor [REDACTED_JIRA]\ // TODO: refactor [REDACTED_JIRA]\
if (it.isTestnet() || it in excludedBlockchains) return@mapNotNull null if (it.isTestnet() || it in excludedBlockchains || it in hotWalletExcludedBlockchains) {
return@mapNotNull null
}
networkFactory.create( networkFactory.create(
blockchain = it, blockchain = it,

View file

@ -23,6 +23,7 @@ import com.tangem.datasource.local.userwallet.UserWalletsStore
import com.tangem.domain.card.common.TapWorkarounds.isTestCard import com.tangem.domain.card.common.TapWorkarounds.isTestCard
import com.tangem.domain.card.common.extensions.canHandleBlockchain import com.tangem.domain.card.common.extensions.canHandleBlockchain
import com.tangem.domain.card.common.extensions.canHandleToken import com.tangem.domain.card.common.extensions.canHandleToken
import com.tangem.domain.card.common.extensions.hotWalletExcludedBlockchains
import com.tangem.domain.card.common.extensions.supportedBlockchains import com.tangem.domain.card.common.extensions.supportedBlockchains
import com.tangem.domain.card.common.extensions.supportedTokens import com.tangem.domain.card.common.extensions.supportedTokens
import com.tangem.domain.card.common.util.cardTypesResolver import com.tangem.domain.card.common.util.cardTypesResolver
@ -291,13 +292,8 @@ internal class DefaultManageTokensRepository(
userWallet: UserWallet, userWallet: UserWallet,
blockchain: Blockchain, blockchain: Blockchain,
): CurrencyUnsupportedState? { ): CurrencyUnsupportedState? {
if (userWallet !is UserWallet.Cold) { val canHandleBlockchain = userWallet.canHandleBlockchain(
return null
}
val canHandleBlockchain = userWallet.scanResponse.card.canHandleBlockchain(
blockchain = blockchain, blockchain = blockchain,
cardTypesResolver = userWallet.cardTypesResolver,
excludedBlockchains = excludedBlockchains, excludedBlockchains = excludedBlockchains,
) )
@ -312,6 +308,14 @@ internal class DefaultManageTokensRepository(
userWallet: UserWallet, userWallet: UserWallet,
blockchain: Blockchain, blockchain: Blockchain,
): CurrencyUnsupportedState.Token? { ): CurrencyUnsupportedState.Token? {
if (userWallet is UserWallet.Hot) {
return if (blockchain in hotWalletExcludedBlockchains) {
CurrencyUnsupportedState.Token.NetworkTokensUnsupported(networkName = blockchain.fullName)
} else {
null
}
}
if (userWallet !is UserWallet.Cold) { if (userWallet !is UserWallet.Cold) {
return null return null
} }

View file

@ -19,6 +19,11 @@ import com.tangem.domain.models.wallet.UserWallet
val FirmwareVersion.Companion.SolanaTokensAvailable val FirmwareVersion.Companion.SolanaTokensAvailable
get() = FirmwareVersion(4, 52) get() = FirmwareVersion(4, 52)
val hotWalletExcludedBlockchains = setOf(
Blockchain.Hedera,
Blockchain.HederaTestnet,
)
fun UserWallet.supportedBlockchains(excludedBlockchains: ExcludedBlockchains): List<Blockchain> { fun UserWallet.supportedBlockchains(excludedBlockchains: ExcludedBlockchains): List<Blockchain> {
return when (this) { return when (this) {
is UserWallet.Cold -> { is UserWallet.Cold -> {
@ -28,7 +33,9 @@ fun UserWallet.supportedBlockchains(excludedBlockchains: ExcludedBlockchains): L
) )
} }
is UserWallet.Hot -> { is UserWallet.Hot -> {
Blockchain.entries.filter { it.isTestnet().not() && it !in excludedBlockchains } Blockchain.entries.filter {
it.isTestnet().not() && it !in excludedBlockchains && it !in hotWalletExcludedBlockchains
}
} }
} }
} }
@ -80,7 +87,7 @@ fun UserWallet.canHandleToken(supportedTokens: List<Blockchain>, blockchain: Blo
cardTypesResolver = scanResponse.cardTypesResolver, cardTypesResolver = scanResponse.cardTypesResolver,
) )
} }
is UserWallet.Hot -> blockchain in supportedTokens is UserWallet.Hot -> blockchain in supportedTokens && blockchain !in hotWalletExcludedBlockchains
} }
} }
@ -96,6 +103,7 @@ fun UserWallet.canHandleToken(blockchain: Blockchain, excludedBlockchains: Exclu
is UserWallet.Hot -> blockchain.isTestnet().not() && is UserWallet.Hot -> blockchain.isTestnet().not() &&
blockchain !in excludedBlockchains && blockchain !in excludedBlockchains &&
blockchain !in hotWalletExcludedBlockchains &&
blockchain.canHandleTokens() blockchain.canHandleTokens()
} }
} }
@ -110,7 +118,8 @@ fun UserWallet.canHandleBlockchain(blockchain: Blockchain, excludedBlockchains:
) )
} }
is UserWallet.Hot -> blockchain.isTestnet().not() && is UserWallet.Hot -> blockchain.isTestnet().not() &&
blockchain !in excludedBlockchains blockchain !in excludedBlockchains &&
blockchain !in hotWalletExcludedBlockchains
} }
} }

View file

@ -89,4 +89,5 @@ dependencies {
/** Tangem libraries */ /** Tangem libraries */
implementation(tangemDeps.card.core) implementation(tangemDeps.card.core)
implementation(tangemDeps.blockchain)
} }

View file

@ -24,12 +24,15 @@ import com.tangem.core.ui.format.bigdecimal.percent
import com.tangem.core.ui.format.bigdecimal.price import com.tangem.core.ui.format.bigdecimal.price
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
import com.tangem.domain.appcurrency.model.AppCurrency import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.card.common.extensions.hotWalletExcludedBlockchains
import com.tangem.domain.feedback.SendFeedbackEmailUseCase import com.tangem.domain.feedback.SendFeedbackEmailUseCase
import com.tangem.domain.feedback.models.FeedbackEmailType import com.tangem.domain.feedback.models.FeedbackEmailType
import com.tangem.domain.markets.* import com.tangem.domain.markets.*
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.settings.usercountry.GetUserCountryUseCase import com.tangem.domain.settings.usercountry.GetUserCountryUseCase
import com.tangem.domain.settings.usercountry.models.UserCountry import com.tangem.domain.settings.usercountry.models.UserCountry
import com.tangem.domain.settings.usercountry.models.needApplyFCARestrictions import com.tangem.domain.settings.usercountry.models.needApplyFCARestrictions
import com.tangem.domain.wallets.usecase.GetWalletsUseCase
import com.tangem.features.markets.details.MarketsTokenDetailsComponent import com.tangem.features.markets.details.MarketsTokenDetailsComponent
import com.tangem.features.markets.details.impl.analytics.MarketDetailsAnalyticsEvent import com.tangem.features.markets.details.impl.analytics.MarketDetailsAnalyticsEvent
import com.tangem.features.markets.details.impl.model.converters.DescriptionConverter import com.tangem.features.markets.details.impl.model.converters.DescriptionConverter
@ -72,6 +75,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
private val analyticsEventHandler: AnalyticsEventHandler, private val analyticsEventHandler: AnalyticsEventHandler,
private val excludedBlockchains: ExcludedBlockchains, private val excludedBlockchains: ExcludedBlockchains,
private val getUserCountryUseCase: GetUserCountryUseCase, private val getUserCountryUseCase: GetUserCountryUseCase,
private val getUserWalletsUseCase: GetWalletsUseCase,
) : Model() { ) : Model() {
private var quotesJob = JobHolder() private var quotesJob = JobHolder()
@ -423,8 +427,15 @@ internal class MarketsTokenDetailsModel @Inject constructor(
) )
} }
val allWalletsIsHot = getUserWalletsUseCase.invokeSync().all { it is UserWallet.Hot }
val networks = newInfo.networks?.filter { val networks = newInfo.networks?.filter {
BlockchainUtils.isSupportedNetworkId(it.networkId, excludedBlockchains) BlockchainUtils.isSupportedNetworkId(
blockchainId = it.networkId,
excludedBlockchains = excludedBlockchains,
hotExcludedBlockchains = hotWalletExcludedBlockchains,
hasOnlyHotWallets = allWalletsIsHot,
)
} }
networksState.value = if (networks.isNullOrEmpty()) { networksState.value = if (networks.isNullOrEmpty()) {

View file

@ -77,10 +77,16 @@ object BlockchainUtils {
return blockchain == Blockchain.TON || blockchain == Blockchain.TONTestnet return blockchain == Blockchain.TON || blockchain == Blockchain.TONTestnet
} }
fun isSupportedNetworkId(blockchainId: String, excludedBlockchains: ExcludedBlockchains): Boolean { fun isSupportedNetworkId(
blockchainId: String,
excludedBlockchains: ExcludedBlockchains,
hotExcludedBlockchains: Set<Blockchain>,
hasOnlyHotWallets: Boolean = false,
): Boolean {
val blockchain = Blockchain.fromNetworkId(blockchainId) val blockchain = Blockchain.fromNetworkId(blockchainId)
return blockchain != null && blockchain !in excludedBlockchains return blockchain != null && blockchain !in excludedBlockchains &&
(hasOnlyHotWallets.not() || blockchain !in hotExcludedBlockchains)
} }
fun isArbitrum(blockchainId: String): Boolean { fun isArbitrum(blockchainId: String): Boolean {