Updated on 2026-08-14

This commit is contained in:
Tangem 2024-12-16 13:30:29 +03:00
parent 27303c0096
commit be6f0efeec
4 changed files with 28 additions and 13 deletions

View file

@ -10,7 +10,7 @@ import com.tangem.blockchain.common.TransactionStatus
import com.tangem.blockchain.common.transaction.Fee
import com.tangem.blockchainsdk.utils.fromNetworkId
import com.tangem.blockchainsdk.utils.toCoinId
import com.tangem.blockchainsdk.utils.toMigratedCointId
import com.tangem.blockchainsdk.utils.toMigratedCoinId
import com.tangem.common.extensions.hexToBytes
import com.tangem.common.extensions.toCompressedPublicKey
import com.tangem.data.common.api.safeApiCall
@ -555,7 +555,7 @@ internal class DefaultStakingRepository(
override fun getStakingApproval(cryptoCurrency: CryptoCurrency): StakingApproval {
return when (getIntegrationKey(cryptoCurrency.id)) {
Blockchain.Ethereum.id + Blockchain.Polygon.toCoinId(),
Blockchain.Ethereum.id + Blockchain.Polygon.toMigratedCointId(),
Blockchain.Ethereum.id + Blockchain.Polygon.toMigratedCoinId(),
-> StakingApproval.Needed(ETHEREUM_POLYGON_APPROVE_SPENDER)
else -> StakingApproval.Empty
}
@ -644,7 +644,7 @@ internal class DefaultStakingRepository(
Blockchain.Solana.run { id + toCoinId() } to SOLANA_INTEGRATION_ID,
Blockchain.Cosmos.run { id + toCoinId() } to COSMOS_INTEGRATION_ID,
Blockchain.Tron.run { id + toCoinId() } to TRON_INTEGRATION_ID,
Blockchain.Ethereum.id + Blockchain.Polygon.toMigratedCointId() to ETHEREUM_POLYGON_INTEGRATION_ID,
Blockchain.Ethereum.id + Blockchain.Polygon.toMigratedCoinId() to ETHEREUM_POLYGON_INTEGRATION_ID,
// Blockchain.Ethereum.id + Blockchain.Polygon.toCoinId() to ETHEREUM_POLYGON_INTEGRATION_ID,
Blockchain.BSC.run { id + toCoinId() } to BINANCE_INTEGRATION_ID,
// Blockchain.Polkadot.run { id + toCoinId() } to POLKADOT_INTEGRATION_ID,

View file

@ -2,10 +2,7 @@ package com.tangem.data.tokens.repository
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchainsdk.compatibility.getL2CompatibilityTokenComparison
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
import com.tangem.blockchainsdk.utils.fromNetworkId
import com.tangem.blockchainsdk.utils.toCoinId
import com.tangem.blockchainsdk.utils.toNetworkId
import com.tangem.blockchainsdk.utils.*
import com.tangem.data.common.api.safeApiCall
import com.tangem.data.common.cache.CacheRegistry
import com.tangem.data.common.currency.*
@ -360,7 +357,9 @@ internal class DefaultCurrenciesRepository(
val storedCoin = storedTokens.tokens
.find {
it.networkId == blockchainNetworkId && it.id == coinId && it.derivationPath == derivationPath.value
it.networkId == blockchainNetworkId &&
compareIdWithMigrations(it, coinId) &&
it.derivationPath == derivationPath.value
} ?: error("Coin in this network $networkId not found")
val coin = responseCurrenciesFactory.createCurrency(storedCoin, userWallet.scanResponse)
@ -548,6 +547,13 @@ internal class DefaultCurrenciesRepository(
)
}
private fun compareIdWithMigrations(token: UserTokensResponse.Token, coinId: String): Boolean {
return when {
token.id == OLD_POLYGON_NAME -> NEW_POLYGON_NAME == coinId
else -> token.id == coinId
}
}
private suspend fun fetchTokens(userWallet: UserWallet) {
val userWalletId = userWallet.walletId

View file

@ -61,8 +61,14 @@ internal class EthereumEIPCustomFeeConverter(
value: ImmutableList<SendTextField.CustomFee>,
): Fee.Ethereum.EIP1559 {
val feeAmount = value[FEE_AMOUNT].value.parseToBigDecimal(value[FEE_AMOUNT].decimals)
val maxFee = value[MAX_FEE].value.parseToBigDecimal(GAS_DECIMALS).toBigInteger()
val priorityFee = value[PRIORITY_FEE].value.parseToBigDecimal(GAS_DECIMALS).toBigInteger()
val maxFeeDecimals = value[MAX_FEE].decimals
val maxFee = value[MAX_FEE].value.parseToBigDecimal(maxFeeDecimals)
.movePointRight(maxFeeDecimals)
.toBigInteger()
val priorityFeeDecimals = value[PRIORITY_FEE].decimals
val priorityFee = value[PRIORITY_FEE].value.parseToBigDecimal(priorityFeeDecimals)
.movePointRight(priorityFeeDecimals)
.toBigInteger()
val gasLimit = value[GAS_LIMIT].value.parseToBigDecimal(GAS_DECIMALS).toBigInteger()
return normalFee.copy(

View file

@ -303,7 +303,7 @@ fun Blockchain.toCoinId(): String {
Blockchain.EthereumClassic, Blockchain.EthereumClassicTestnet -> "ethereum-classic"
Blockchain.Stellar, Blockchain.StellarTestnet -> "stellar"
Blockchain.Cardano -> "cardano"
Blockchain.Polygon, Blockchain.PolygonTestnet -> "polygon-ecosystem-token"
Blockchain.Polygon, Blockchain.PolygonTestnet -> NEW_POLYGON_NAME
Blockchain.Arbitrum, Blockchain.ArbitrumTestnet -> "arbitrum-one"
Blockchain.Avalanche, Blockchain.AvalancheTestnet -> "avalanche-2"
Blockchain.Solana, Blockchain.SolanaTestnet -> "solana"
@ -387,8 +387,8 @@ fun Blockchain.toCoinId(): String {
* New CoinId to existing coin "id" field.
* To support both old and new coin id.
*/
fun Blockchain.toMigratedCointId(): String = when (this) {
Blockchain.Polygon, Blockchain.PolygonTestnet -> "polygon-ecosystem-token"
fun Blockchain.toMigratedCoinId(): String = when (this) {
Blockchain.Polygon, Blockchain.PolygonTestnet -> NEW_POLYGON_NAME
else -> toCoinId()
}
@ -422,5 +422,8 @@ fun Blockchain.minimalAmount(): BigDecimal {
return BigDecimal.ONE.movePointLeft(decimals())
}
const val OLD_POLYGON_NAME = "matic-network"
const val NEW_POLYGON_NAME = "polygon-ecosystem-token"
private const val NODL = "NODL"
private const val NODL_AMOUNT_TO_CREATE_ACCOUNT = 1.5