Updated on 2026-08-14

This commit is contained in:
Tangem 2024-09-12 12:04:51 +03:00
parent 27ae1ee2a0
commit 1f3f592cee
8 changed files with 58 additions and 37 deletions

View file

@ -1,6 +1,7 @@
package com.tangem.data.managetokens
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchainsdk.compatibility.l2BlockchainsCoinIds
import com.tangem.blockchainsdk.utils.isSupportedInApp
import com.tangem.blockchainsdk.utils.toNetworkId
import com.tangem.data.common.currency.getBlockchain
@ -86,6 +87,10 @@ internal class DefaultManageTokensRepository(
} else {
retryOnError(call = call)
}
// filter l2 coins
val updatedCoinsResponse = coinsResponse.copy(
coins = coinsResponse.coins.filterNot { l2BlockchainsCoinIds.contains(it.id) },
)
val tokensResponse = request.params.userWalletId?.let { getSavedUserTokensResponseSync(it) }
val items = if (isFirstBatchFetching &&
@ -94,13 +99,13 @@ internal class DefaultManageTokensRepository(
request.params.searchText.isNullOrBlank()
) {
managedCryptoCurrencyFactory.createWithCustomTokens(
coinsResponse = coinsResponse,
coinsResponse = updatedCoinsResponse,
tokensResponse = tokensResponse,
derivationStyleProvider = userWallet.scanResponse.derivationStyleProvider,
)
} else {
managedCryptoCurrencyFactory.create(
coinsResponse = coinsResponse,
coinsResponse = updatedCoinsResponse,
tokensResponse = tokensResponse,
derivationStyleProvider = userWallet?.scanResponse?.derivationStyleProvider,
)

View file

@ -2,6 +2,7 @@ package com.tangem.data.markets
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchainsdk.compatibility.applyL2Compatibility
import com.tangem.blockchainsdk.compatibility.getTokenIdIfL2Network
import com.tangem.blockchainsdk.utils.fromNetworkId
import com.tangem.data.common.currency.CryptoCurrencyFactory
import com.tangem.data.common.currency.getNetwork
@ -109,9 +110,10 @@ internal class DefaultMarketsTokenRepository(
interval: PriceChangeInterval,
tokenId: String,
): TokenChart {
val mappedTokenId = getTokenIdIfL2Network(tokenId)
val response = marketsApi.getCoinChart(
currency = fiatCurrencyCode,
coinId = tokenId,
coinId = mappedTokenId,
interval = interval.toRequestParam(),
)
@ -123,13 +125,14 @@ internal class DefaultMarketsTokenRepository(
interval: PriceChangeInterval,
tokenId: String,
): TokenChart {
val mappedTokenId = getTokenIdIfL2Network(tokenId)
val response = marketsApi.getCoinsListCharts(
coinIds = tokenId,
coinIds = mappedTokenId,
currency = fiatCurrencyCode,
interval = interval.toRequestParam(),
)
val chart = response.getOrThrow()[tokenId] ?: error("No chart preview data for token $tokenId")
val chart = response.getOrThrow()[mappedTokenId] ?: error("No chart preview data for token $mappedTokenId")
return TokenChartConverter.convert(interval, chart)
}

View file

@ -1,6 +1,7 @@
package com.tangem.data.tokens.utils
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchainsdk.compatibility.l2BlockchainsCoinIds
import com.tangem.blockchainsdk.utils.toCoinId
import com.tangem.datasource.api.tangemTech.models.QuotesResponse
@ -51,16 +52,6 @@ internal class QuotesUnsupportedCurrenciesIdAdapter {
* Map that contains unsupported currencies and their replacement for request
*/
private val ethCoinId = Blockchain.Ethereum.toCoinId()
private val UNSUPPORTED_IDS_WITH_REPLACEMENTS = mapOf(
Blockchain.Optimism.toCoinId() to ethCoinId,
Blockchain.Arbitrum.toCoinId() to ethCoinId,
Blockchain.ZkSyncEra.toCoinId() to ethCoinId,
Blockchain.Manta.toCoinId() to ethCoinId,
Blockchain.PolygonZkEVM.toCoinId() to ethCoinId,
Blockchain.Aurora.toCoinId() to ethCoinId,
Blockchain.Base.toCoinId() to ethCoinId,
Blockchain.Blast.toCoinId() to ethCoinId,
Blockchain.Cyber.toCoinId() to ethCoinId,
)
private val UNSUPPORTED_IDS_WITH_REPLACEMENTS = l2BlockchainsCoinIds.associateWith { ethCoinId }
}
}