diff --git a/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultCustomTokensRepository.kt b/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultCustomTokensRepository.kt index 34beb0198c..3fc333d86f 100644 --- a/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultCustomTokensRepository.kt +++ b/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultCustomTokensRepository.kt @@ -15,6 +15,7 @@ import com.tangem.datasource.api.tangemTech.TangemTechApi import com.tangem.datasource.local.token.UserTokensResponseStore import com.tangem.datasource.local.userwallet.UserWalletsStore 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.util.cardTypesResolver import com.tangem.domain.managetokens.model.AddCustomTokenForm @@ -252,7 +253,9 @@ internal class DefaultCustomTokensRepository( is UserWallet.Hot -> { Blockchain.entries.mapNotNull { // 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( blockchain = it, diff --git a/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultManageTokensRepository.kt b/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultManageTokensRepository.kt index eca48639fe..c5c8b51cdd 100644 --- a/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultManageTokensRepository.kt +++ b/data/manage-tokens/src/main/kotlin/com/tangem/data/managetokens/DefaultManageTokensRepository.kt @@ -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.extensions.canHandleBlockchain 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.supportedTokens import com.tangem.domain.card.common.util.cardTypesResolver @@ -291,13 +292,8 @@ internal class DefaultManageTokensRepository( userWallet: UserWallet, blockchain: Blockchain, ): CurrencyUnsupportedState? { - if (userWallet !is UserWallet.Cold) { - return null - } - - val canHandleBlockchain = userWallet.scanResponse.card.canHandleBlockchain( + val canHandleBlockchain = userWallet.canHandleBlockchain( blockchain = blockchain, - cardTypesResolver = userWallet.cardTypesResolver, excludedBlockchains = excludedBlockchains, ) @@ -312,6 +308,14 @@ internal class DefaultManageTokensRepository( userWallet: UserWallet, blockchain: Blockchain, ): 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) { return null } diff --git a/domain/card/src/main/kotlin/com/tangem/domain/card/common/extensions/CardSdk.kt b/domain/card/src/main/kotlin/com/tangem/domain/card/common/extensions/CardSdk.kt index a189ade273..4606c72970 100644 --- a/domain/card/src/main/kotlin/com/tangem/domain/card/common/extensions/CardSdk.kt +++ b/domain/card/src/main/kotlin/com/tangem/domain/card/common/extensions/CardSdk.kt @@ -19,6 +19,11 @@ import com.tangem.domain.models.wallet.UserWallet val FirmwareVersion.Companion.SolanaTokensAvailable get() = FirmwareVersion(4, 52) +val hotWalletExcludedBlockchains = setOf( + Blockchain.Hedera, + Blockchain.HederaTestnet, +) + fun UserWallet.supportedBlockchains(excludedBlockchains: ExcludedBlockchains): List { return when (this) { is UserWallet.Cold -> { @@ -28,7 +33,9 @@ fun UserWallet.supportedBlockchains(excludedBlockchains: ExcludedBlockchains): L ) } 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: Blo 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() && blockchain !in excludedBlockchains && + blockchain !in hotWalletExcludedBlockchains && blockchain.canHandleTokens() } } @@ -110,7 +118,8 @@ fun UserWallet.canHandleBlockchain(blockchain: Blockchain, excludedBlockchains: ) } is UserWallet.Hot -> blockchain.isTestnet().not() && - blockchain !in excludedBlockchains + blockchain !in excludedBlockchains && + blockchain !in hotWalletExcludedBlockchains } } diff --git a/features/markets/impl/build.gradle.kts b/features/markets/impl/build.gradle.kts index 61d498c799..63c479bfc9 100644 --- a/features/markets/impl/build.gradle.kts +++ b/features/markets/impl/build.gradle.kts @@ -89,4 +89,5 @@ dependencies { /** Tangem libraries */ implementation(tangemDeps.card.core) + implementation(tangemDeps.blockchain) } \ No newline at end of file diff --git a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt index 0778b806c6..6107b6d7a2 100644 --- a/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt +++ b/features/markets/impl/src/main/kotlin/com/tangem/features/markets/details/impl/model/MarketsTokenDetailsModel.kt @@ -24,12 +24,15 @@ import com.tangem.core.ui.format.bigdecimal.percent import com.tangem.core.ui.format.bigdecimal.price import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase 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.models.FeedbackEmailType 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.models.UserCountry 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.impl.analytics.MarketDetailsAnalyticsEvent 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 excludedBlockchains: ExcludedBlockchains, private val getUserCountryUseCase: GetUserCountryUseCase, + private val getUserWalletsUseCase: GetWalletsUseCase, ) : Model() { 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 { - BlockchainUtils.isSupportedNetworkId(it.networkId, excludedBlockchains) + BlockchainUtils.isSupportedNetworkId( + blockchainId = it.networkId, + excludedBlockchains = excludedBlockchains, + hotExcludedBlockchains = hotWalletExcludedBlockchains, + hasOnlyHotWallets = allWalletsIsHot, + ) } networksState.value = if (networks.isNullOrEmpty()) { diff --git a/libs/crypto/src/main/java/com/tangem/lib/crypto/BlockchainUtils.kt b/libs/crypto/src/main/java/com/tangem/lib/crypto/BlockchainUtils.kt index 3f12cb37cb..aec26f5567 100644 --- a/libs/crypto/src/main/java/com/tangem/lib/crypto/BlockchainUtils.kt +++ b/libs/crypto/src/main/java/com/tangem/lib/crypto/BlockchainUtils.kt @@ -77,10 +77,16 @@ object BlockchainUtils { return blockchain == Blockchain.TON || blockchain == Blockchain.TONTestnet } - fun isSupportedNetworkId(blockchainId: String, excludedBlockchains: ExcludedBlockchains): Boolean { + fun isSupportedNetworkId( + blockchainId: String, + excludedBlockchains: ExcludedBlockchains, + hotExcludedBlockchains: Set, + hasOnlyHotWallets: Boolean = false, + ): Boolean { 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 {