Updated on 2026-08-14

This commit is contained in:
Tangem 2023-11-14 15:25:24 +03:00
commit a99cd65fcb
16 changed files with 278 additions and 20 deletions

View file

@ -1,9 +1,7 @@
package com.tangem.data.tokens.repository
import com.tangem.blockchain.common.Blockchain
import com.tangem.datasource.api.express.models.TangemExpressValues.EMPTY_CONTRACT_ADDRESS_VALUE
import com.tangem.datasource.local.token.AssetsStore
import com.tangem.domain.common.extensions.toNetworkId
import com.tangem.domain.tokens.model.CryptoCurrency
import com.tangem.domain.tokens.repository.MarketCryptoCurrencyRepository
import com.tangem.domain.wallets.models.UserWalletId
@ -13,14 +11,11 @@ class DefaultMarketCryptoCurrencyRepository(
) : MarketCryptoCurrencyRepository {
override suspend fun isExchangeable(userWalletId: UserWalletId, cryptoCurrency: CryptoCurrency): Boolean {
val cryptoCurrencyId = cryptoCurrency.id
val blockchain = Blockchain.fromId(cryptoCurrencyId.rawNetworkId)
val apiNetworkId = blockchain.toNetworkId()
val contractAddress = (cryptoCurrency as? CryptoCurrency.Token)?.contractAddress ?: EMPTY_CONTRACT_ADDRESS_VALUE
return assetsStore.getSyncOrNull(userWalletId)?.find {
it.network == apiNetworkId &&
it.token == cryptoCurrencyId.rawCurrencyId &&
it.network == cryptoCurrency.network.backendId &&
it.token == cryptoCurrency.id.rawCurrencyId &&
it.contractAddress == contractAddress &&
it.isActive
}?.exchangeAvailable ?: false

View file

@ -2,6 +2,7 @@ package com.tangem.data.tokens.utils
import com.tangem.blockchain.common.Blockchain
import com.tangem.domain.common.DerivationStyleProvider
import com.tangem.domain.common.extensions.toNetworkId
import com.tangem.domain.tokens.model.Network
import timber.log.Timber
@ -21,6 +22,7 @@ internal fun getNetwork(
return Network(
id = Network.ID(blockchain.id),
backendId = blockchain.toNetworkId(),
name = blockchain.fullName,
isTestnet = blockchain.isTestnet(),
derivationPath = getNetworkDerivationPath(blockchain, extraDerivationPath, derivationStyleProvider),