Updated on 2026-08-14

This commit is contained in:
Tangem 2026-04-10 13:26:27 +04:00
parent 799a38655e
commit 4570bc334c
54 changed files with 178 additions and 183 deletions

View file

@ -188,7 +188,7 @@ internal class DefaultRampManager(
private fun CryptoCurrency.findAssetPredicate(assetId: ExpressAsset.ID): Boolean { private fun CryptoCurrency.findAssetPredicate(assetId: ExpressAsset.ID): Boolean {
val currencyAssedId = ExpressAsset.ID( val currencyAssedId = ExpressAsset.ID(
networkId = this.network.backendId, networkId = this.network.rawId,
contractAddress = (this as? CryptoCurrency.Token)?.contractAddress, contractAddress = (this as? CryptoCurrency.Token)?.contractAddress,
) )

View file

@ -47,7 +47,7 @@ fun StakingBalance.Data.getTotalStakingBalance(blockchainId: String): BigDecimal
* StakeKit-specific extension to get total balance including rewards. * StakeKit-specific extension to get total balance including rewards.
*/ */
private fun StakingBalance.Data.StakeKit.getTotalWithRewardsStakingBalanceStakeKit(blockchainId: String): BigDecimal { private fun StakingBalance.Data.StakeKit.getTotalWithRewardsStakingBalanceStakeKit(blockchainId: String): BigDecimal {
return if (BlockchainUtils.isIncludeStakingTotalBalance(blockchainId = blockchainId)) { return if (BlockchainUtils.isIncludeStakingTotalBalance(networkId = blockchainId)) {
balance.items.sumOf { it.amount } balance.items.sumOf { it.amount }
} else { } else {
getRewardStakingBalance() getRewardStakingBalance()
@ -58,7 +58,7 @@ private fun StakingBalance.Data.StakeKit.getTotalWithRewardsStakingBalanceStakeK
* StakeKit-specific extension to get total staked balance excluding rewards. * StakeKit-specific extension to get total staked balance excluding rewards.
*/ */
private fun StakingBalance.Data.StakeKit.getTotalStakingBalanceStakeKit(blockchainId: String): BigDecimal { private fun StakingBalance.Data.StakeKit.getTotalStakingBalanceStakeKit(blockchainId: String): BigDecimal {
return if (BlockchainUtils.isIncludeStakingTotalBalance(blockchainId = blockchainId)) { return if (BlockchainUtils.isIncludeStakingTotalBalance(networkId = blockchainId)) {
balance.items balance.items
.filterNot { it.type == BalanceType.REWARDS } .filterNot { it.type == BalanceType.REWARDS }
.sumOf { it.amount } .sumOf { it.amount }

View file

@ -169,7 +169,7 @@ class CryptoCurrencyFactory(
id = cryptoCurrency.id.rawCurrencyId?.value, id = cryptoCurrency.id.rawCurrencyId?.value,
) )
val blockchain = val blockchain =
Blockchain.fromNetworkId(cryptoCurrency.network.backendId) ?: Blockchain.Unknown Blockchain.fromNetworkId(cryptoCurrency.network.rawId) ?: Blockchain.Unknown
val id = getTokenId(network, sdkToken) val id = getTokenId(network, sdkToken)
return CryptoCurrency.Token( return CryptoCurrency.Token(
id = id, id = id,

View file

@ -47,7 +47,7 @@ internal class DefaultCardCryptoCurrencyFactory(
// check if the blockchain of single-currency wallet is the same as network // check if the blockchain of single-currency wallet is the same as network
val cardNetworkId = userWallet.scanResponse.cardTypesResolver.getBlockchain().toNetworkId() val cardNetworkId = userWallet.scanResponse.cardTypesResolver.getBlockchain().toNetworkId()
val cardNetwork = networks.firstOrNull { it.backendId == cardNetworkId } val cardNetwork = networks.firstOrNull { it.rawId == cardNetworkId }
if (cardNetwork == null) return emptyMap() if (cardNetwork == null) return emptyMap()
@ -145,7 +145,7 @@ internal class DefaultCardCryptoCurrencyFactory(
responseCryptoCurrenciesFactory.createCurrencies( responseCryptoCurrenciesFactory.createCurrencies(
tokens = accountDTO.tokens.orEmpty().filter { token -> tokens = accountDTO.tokens.orEmpty().filter { token ->
networks.any { networks.any {
it.backendId == token.networkId && it.derivationPath.value == token.derivationPath it.rawId == token.networkId && it.derivationPath.value == token.derivationPath
} }
}, },
userWallet = userWallet, userWallet = userWallet,

View file

@ -40,7 +40,7 @@ class UserTokensResponseFactory @Inject constructor() {
UserTokensResponse.Token( UserTokensResponse.Token(
id = id.rawCurrencyId?.value, id = id.rawCurrencyId?.value,
accountId = accountId?.value, accountId = accountId?.value,
networkId = network.backendId, networkId = network.rawId,
derivationPath = network.derivationPath.value, derivationPath = network.derivationPath.value,
name = name, name = name,
symbol = symbol, symbol = symbol,

View file

@ -87,7 +87,7 @@ internal class DefaultDynamicAddressesRepository(
.flatMap { it.tokens.orEmpty() } .flatMap { it.tokens.orEmpty() }
.any { token -> .any { token ->
val tokenDerivationPath = token.derivationPath ?: return@any false val tokenDerivationPath = token.derivationPath ?: return@any false
token.networkId == network.backendId && token.networkId == network.rawId &&
tokenDerivationPath != baseDerivationPath && tokenDerivationPath != baseDerivationPath &&
hasNonZeroChangeOrIndex(tokenDerivationPath, baseDerivationPath) hasNonZeroChangeOrIndex(tokenDerivationPath, baseDerivationPath)
} }
@ -151,7 +151,7 @@ internal class DefaultDynamicAddressesRepository(
} }
private fun UserTokensResponse.Token.matchesNetwork(network: Network): Boolean { private fun UserTokensResponse.Token.matchesNetwork(network: Network): Boolean {
return networkId == network.backendId && return networkId == network.rawId &&
derivationPath == network.derivationPath.value && derivationPath == network.derivationPath.value &&
contractAddress == null contractAddress == null
} }

View file

@ -91,7 +91,7 @@ internal class DefaultCustomTokensRepository(
val response = tangemTechApi.getCoins( val response = tangemTechApi.getCoins(
contractAddress = contractAddress, contractAddress = contractAddress,
networkIds = network.backendId, networkIds = network.rawId,
active = true, active = true,
).getOrThrow() ).getOrThrow()

View file

@ -75,7 +75,7 @@ internal class SimpleNetworkStatusConverterTest {
), ),
expected = SimpleNetworkStatus( expected = SimpleNetworkStatus(
id = Network.ID( id = Network.ID(
value = network.backendId, value = network.rawId,
derivationPath = Network.DerivationPath.Card("card"), derivationPath = Network.DerivationPath.Card("card"),
), ),
value = NetworkStatus.Verified( value = NetworkStatus.Verified(
@ -138,7 +138,7 @@ internal class SimpleNetworkStatusConverterTest {
), ),
expected = SimpleNetworkStatus( expected = SimpleNetworkStatus(
id = Network.ID( id = Network.ID(
value = network.backendId, value = network.rawId,
derivationPath = Network.DerivationPath.Card("card"), derivationPath = Network.DerivationPath.Card("card"),
), ),
value = NetworkStatus.NoAccount( value = NetworkStatus.NoAccount(

View file

@ -568,7 +568,7 @@ internal class DefaultNFTRepository @Inject constructor(
private fun Network.canHandleNFTs(userWalletId: UserWalletId): Boolean { private fun Network.canHandleNFTs(userWalletId: UserWalletId): Boolean {
val userWallet = userWalletsListRepository.getSyncStrict(userWalletId) val userWallet = userWalletsListRepository.getSyncStrict(userWalletId)
val blockchain = Blockchain.fromNetworkId(backendId) ?: return false val blockchain = Blockchain.fromNetworkId(rawId) ?: return false
return blockchain.canHandleNFTs() && return blockchain.canHandleNFTs() &&
userWallet.canHandleToken(blockchain, excludedBlockchains) userWallet.canHandleToken(blockchain, excludedBlockchains)

View file

@ -249,7 +249,7 @@ internal class DefaultOnrampRepository(
to = listOf( to = listOf(
OnrampDestinationDTO( OnrampDestinationDTO(
contractAddress = cryptoCurrency.getContractAddress(), contractAddress = cryptoCurrency.getContractAddress(),
network = cryptoCurrency.network.backendId, network = cryptoCurrency.network.rawId,
), ),
), ),
), ),
@ -314,7 +314,7 @@ internal class DefaultOnrampRepository(
to = listOf( to = listOf(
OnrampDestinationDTO( OnrampDestinationDTO(
contractAddress = cryptoCurrency.getContractAddress(), contractAddress = cryptoCurrency.getContractAddress(),
network = cryptoCurrency.network.backendId, network = cryptoCurrency.network.rawId,
), ),
), ),
), ),
@ -363,7 +363,7 @@ internal class DefaultOnrampRepository(
fromCurrencyCode = currency.code, fromCurrencyCode = currency.code,
fromPrecision = currency.precision, fromPrecision = currency.precision,
toContractAddress = cryptoCurrency.getContractAddress(), toContractAddress = cryptoCurrency.getContractAddress(),
toNetwork = cryptoCurrency.network.backendId, toNetwork = cryptoCurrency.network.rawId,
paymentMethod = paymentMethod.id, paymentMethod = paymentMethod.id,
countryCode = country.code, countryCode = country.code,
fromAmount = fromAmount, fromAmount = fromAmount,
@ -436,7 +436,7 @@ internal class DefaultOnrampRepository(
fromCurrencyCode = currency.code, fromCurrencyCode = currency.code,
fromPrecision = currency.precision, fromPrecision = currency.precision,
toContractAddress = cryptoCurrency.getContractAddress(), toContractAddress = cryptoCurrency.getContractAddress(),
toNetwork = cryptoCurrency.network.backendId, toNetwork = cryptoCurrency.network.rawId,
paymentMethod = quote.paymentMethod.id, paymentMethod = quote.paymentMethod.id,
countryCode = country.code, countryCode = country.code,
fromAmount = fromAmountString, fromAmount = fromAmountString,

View file

@ -78,7 +78,7 @@ internal class DefaultQrScanningEventsRepositoryTest {
@Test @Test
fun testBip021() { fun testBip021() {
every { network.id } returns Network.ID(value = "bitcoin", derivationPath = Network.DerivationPath.None) every { network.id } returns Network.ID(value = "bitcoin", derivationPath = Network.DerivationPath.None)
every { network.backendId } returns "bitcoin" every { network.rawId } returns "bitcoin"
positiveCase( positiveCase(
"$schema1:$address1", "$schema1:$address1",
QrResult(address = address1), QrResult(address = address1),
@ -129,7 +129,7 @@ internal class DefaultQrScanningEventsRepositoryTest {
@Test @Test
fun testErc681Coin() { fun testErc681Coin() {
every { network.id } returns Network.ID(value = "ethereum", derivationPath = Network.DerivationPath.None) every { network.id } returns Network.ID(value = "ethereum", derivationPath = Network.DerivationPath.None)
every { network.backendId } returns "ethereum" every { network.rawId } returns "ethereum"
positiveCase( positiveCase(
address2, address2,
QrResult(address = address2), QrResult(address = address2),
@ -185,7 +185,7 @@ internal class DefaultQrScanningEventsRepositoryTest {
@Test @Test
fun testErc681Token() { fun testErc681Token() {
every { network.id } returns Network.ID(value = "ethereum", derivationPath = Network.DerivationPath.None) every { network.id } returns Network.ID(value = "ethereum", derivationPath = Network.DerivationPath.None)
every { network.backendId } returns "ethereum" every { network.rawId } returns "ethereum"
positiveCase( positiveCase(
address2, address2,
QrResult(address = address2), QrResult(address = address2),

View file

@ -411,7 +411,7 @@ internal class DefaultStakeKitRepository(
} }
private fun getTronResource(network: Network): TronResource? { private fun getTronResource(network: Network): TronResource? {
val blockchain = Blockchain.fromNetworkId(network.backendId) val blockchain = Blockchain.fromNetworkId(network.rawId)
return if (blockchain == Blockchain.Tron || blockchain == Blockchain.TronTestnet) { return if (blockchain == Blockchain.Tron || blockchain == Blockchain.TronTestnet) {
TronResource.ENERGY TronResource.ENERGY

View file

@ -91,12 +91,12 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
val statusFrom = cryptoCurrencyStatusList val statusFrom = cryptoCurrencyStatusList
.firstOrNull { currencyStatus -> .firstOrNull { currencyStatus ->
currencyStatus.currency.getContractAddress() == pair.from.contractAddress && currencyStatus.currency.getContractAddress() == pair.from.contractAddress &&
currencyStatus.currency.network.backendId == pair.from.network currencyStatus.currency.network.rawId == pair.from.network
} }
val statusTo = cryptoCurrencyStatusList val statusTo = cryptoCurrencyStatusList
.firstOrNull { currencyStatus -> .firstOrNull { currencyStatus ->
currencyStatus.currency.getContractAddress() == pair.to.contractAddress && currencyStatus.currency.getContractAddress() == pair.to.contractAddress &&
currencyStatus.currency.network.backendId == pair.to.network currencyStatus.currency.network.rawId == pair.to.network
} }
val mappedProviders = pair.providers val mappedProviders = pair.providers
@ -143,14 +143,14 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
cryptoCurrencyList cryptoCurrencyList
.firstOrNull { currency -> .firstOrNull { currency ->
currency.getContractAddress() == pair.from.contractAddress && currency.getContractAddress() == pair.from.contractAddress &&
currency.network.backendId == pair.from.network currency.network.rawId == pair.from.network
} }
} }
val statusToDeferred = async { val statusToDeferred = async {
cryptoCurrencyList cryptoCurrencyList
.firstOrNull { currency -> .firstOrNull { currency ->
currency.getContractAddress() == pair.to.contractAddress && currency.getContractAddress() == pair.to.contractAddress &&
currency.network.backendId == pair.to.network currency.network.rawId == pair.to.network
} }
} }
@ -198,10 +198,10 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
} else { } else {
null null
}, },
fromNetwork = fromCryptoCurrency.network.backendId, fromNetwork = fromCryptoCurrency.network.rawId,
fromContractAddress = fromCryptoCurrency.getContractAddress(), fromContractAddress = fromCryptoCurrency.getContractAddress(),
fromDecimals = fromCryptoCurrency.decimals, fromDecimals = fromCryptoCurrency.decimals,
toNetwork = toCryptoCurrency.network.backendId, toNetwork = toCryptoCurrency.network.rawId,
toContractAddress = toCryptoCurrency.getContractAddress(), toContractAddress = toCryptoCurrency.getContractAddress(),
toDecimals = toCryptoCurrency.decimals, toDecimals = toCryptoCurrency.decimals,
providerId = provider.providerId, providerId = provider.providerId,
@ -255,8 +255,8 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
val response = tangemExpressApi.getExchangeData( val response = tangemExpressApi.getExchangeData(
fromContractAddress = fromCurrency.getContractAddress(), fromContractAddress = fromCurrency.getContractAddress(),
toContractAddress = toCryptoCurrency.getContractAddress(), toContractAddress = toCryptoCurrency.getContractAddress(),
fromNetwork = fromCurrency.network.backendId, fromNetwork = fromCurrency.network.rawId,
toNetwork = toCryptoCurrency.network.backendId, toNetwork = toCryptoCurrency.network.rawId,
fromAddress = fromStatus.networkAddress?.defaultAddress?.value.orEmpty(), fromAddress = fromStatus.networkAddress?.defaultAddress?.value.orEmpty(),
toAddress = toAddress, toAddress = toAddress,
fromDecimals = fromCurrency.decimals, fromDecimals = fromCurrency.decimals,
@ -316,7 +316,7 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
), ),
body = ExchangeSentRequestBody( body = ExchangeSentRequestBody(
txId = txId, txId = txId,
fromNetwork = currency.network.backendId, fromNetwork = currency.network.rawId,
fromAddress = status.networkAddress?.defaultAddress?.value.orEmpty(), fromAddress = status.networkAddress?.defaultAddress?.value.orEmpty(),
payinAddress = payInAddress, payinAddress = payInAddress,
payinExtraId = txExtraId, payinExtraId = txExtraId,

View file

@ -10,7 +10,7 @@ class TokenInfoConverter : Converter<CryptoCurrency, LeastTokenInfo> {
override fun convert(value: CryptoCurrency): LeastTokenInfo { override fun convert(value: CryptoCurrency): LeastTokenInfo {
return LeastTokenInfo( return LeastTokenInfo(
contractAddress = (value as? CryptoCurrency.Token)?.contractAddress ?: "0", contractAddress = (value as? CryptoCurrency.Token)?.contractAddress ?: "0",
network = value.network.backendId, network = value.network.rawId,
) )
} }

View file

@ -134,7 +134,7 @@ internal class DefaultCurrenciesRepository(
} }
override fun isNetworkFeeZero(userWalletId: UserWalletId, network: Network): Boolean { override fun isNetworkFeeZero(userWalletId: UserWalletId, network: Network): Boolean {
val blockchain = Blockchain.fromNetworkId(network.backendId) val blockchain = Blockchain.fromNetworkId(network.rawId)
return blockchain?.isNetworkFeeZero() == true return blockchain?.isNetworkFeeZero() == true
} }
} }

View file

@ -183,7 +183,7 @@ internal class DefaultTokenSyncRepository(
if (tokenBalances.isEmpty()) { if (tokenBalances.isEmpty()) {
return NetworkResult.Success( return NetworkResult.Success(
networkId = network.backendId, networkId = network.rawId,
responseTokens = emptyList(), responseTokens = emptyList(),
) )
} }
@ -195,11 +195,11 @@ internal class DefaultTokenSyncRepository(
.map { it.toResponseToken() } .map { it.toResponseToken() }
NetworkResult.Success( NetworkResult.Success(
networkId = network.backendId, networkId = network.rawId,
responseTokens = responseTokens, responseTokens = responseTokens,
) )
} catch (e: Exception) { } catch (e: Exception) {
NetworkResult.Error(networkId = network.backendId, cause = e) NetworkResult.Error(networkId = network.rawId, cause = e)
} }
} }
@ -217,7 +217,7 @@ internal class DefaultTokenSyncRepository(
val tokensToEnrich = tokenBalances.filter { !it.isNativeToken } val tokensToEnrich = tokenBalances.filter { !it.isNativeToken }
val catalogMap = fetchCatalogInfo( val catalogMap = fetchCatalogInfo(
networkId = network.backendId, networkId = network.rawId,
contractAddresses = tokensToEnrich.mapNotNull(TokenBalance::contractAddress), contractAddresses = tokensToEnrich.mapNotNull(TokenBalance::contractAddress),
) )
@ -240,7 +240,7 @@ internal class DefaultTokenSyncRepository(
amount = balance.amount, amount = balance.amount,
isNativeToken = false, isNativeToken = false,
currencyId = coin.id, currencyId = coin.id,
networkId = network.backendId, networkId = network.rawId,
) )
} }
} }

View file

@ -38,7 +38,7 @@ internal class DefaultAllowanceRepository(
allowance >= requiredAmount -> AllowanceInfo.Enough(allowance) allowance >= requiredAmount -> AllowanceInfo.Enough(allowance)
allowance > BigDecimal.ZERO && allowance < requiredAmount && allowance > BigDecimal.ZERO && allowance < requiredAmount &&
BlockchainUtils.isTetherInEthereum( BlockchainUtils.isTetherInEthereum(
blockchainId = cryptoCurrency.network.rawId, networkId = cryptoCurrency.network.rawId,
contractAddress = cryptoCurrency.contractAddress, contractAddress = cryptoCurrency.contractAddress,
) -> AllowanceInfo.ResetNeeded(allowance, requiredAmount) ) -> AllowanceInfo.ResetNeeded(allowance, requiredAmount)
else -> AllowanceInfo.NotEnough(allowance, requiredAmount) else -> AllowanceInfo.NotEnough(allowance, requiredAmount)

View file

@ -312,7 +312,7 @@ internal class DefaultTransactionRepository(
nonce: BigInteger?, nonce: BigInteger?,
gasLimit: BigInteger?, gasLimit: BigInteger?,
): TransactionExtras { ): TransactionExtras {
val blockchain = Blockchain.fromNetworkId(networkId = network.backendId) val blockchain = Blockchain.fromNetworkId(networkId = network.rawId)
?: error("Blockchain not found") ?: error("Blockchain not found")
return when { return when {
blockchain.isEvm() -> { blockchain.isEvm() -> {

View file

@ -9,7 +9,7 @@ internal object BlockAidChainNameConverter : Converter<Network, String?> {
@Suppress("CyclomaticComplexMethod") @Suppress("CyclomaticComplexMethod")
override fun convert(value: Network): String? { override fun convert(value: Network): String? {
return when (Blockchain.fromNetworkId(value.backendId)) { return when (Blockchain.fromNetworkId(value.rawId)) {
Blockchain.Arbitrum -> "arbitrum" Blockchain.Arbitrum -> "arbitrum"
Blockchain.Avalanche -> "avalanche" Blockchain.Avalanche -> "avalanche"
Blockchain.AvalancheTestnet -> "avalanche-fuji" Blockchain.AvalancheTestnet -> "avalanche-fuji"

View file

@ -43,7 +43,7 @@ internal class DefaultYieldSupplyRepository(
private val statusMapFlow = MutableStateFlow<Map<String, YieldSupplyPendingStatus>>(emptyMap()) private val statusMapFlow = MutableStateFlow<Map<String, YieldSupplyPendingStatus>>(emptyMap())
override suspend fun getCachedMarkets(): List<YieldMarketToken>? = withContext(dispatchers.io) { override suspend fun getCachedMarkets(): List<YieldMarketToken> = withContext(dispatchers.io) {
val cache = store.getSyncOrNull().orEmpty() val cache = store.getSyncOrNull().orEmpty()
val domain = cache.map(YieldMarketTokenConverter::convert) val domain = cache.map(YieldMarketTokenConverter::convert)
domain.enrichNetworkIds() domain.enrichNetworkIds()
@ -62,14 +62,14 @@ internal class DefaultYieldSupplyRepository(
} }
override suspend fun getTokenStatus(cryptoCurrencyToken: CryptoCurrency.Token): YieldMarketToken { override suspend fun getTokenStatus(cryptoCurrencyToken: CryptoCurrency.Token): YieldMarketToken {
val chainId = Blockchain.fromNetworkId(cryptoCurrencyToken.network.backendId)?.getChainId() val chainId = Blockchain.fromNetworkId(cryptoCurrencyToken.network.rawId)?.getChainId()
?: error("Chain id is required for evm's") ?: error("Chain id is required for evm's")
val response = yieldSupplyApi.getYieldTokenStatus(chainId, cryptoCurrencyToken.contractAddress).getOrThrow() val response = yieldSupplyApi.getYieldTokenStatus(chainId, cryptoCurrencyToken.contractAddress).getOrThrow()
return YieldMarketTokenConverter.convert(response) return YieldMarketTokenConverter.convert(response)
} }
override suspend fun getTokenChart(cryptoCurrencyToken: CryptoCurrency.Token): YieldSupplyMarketChartData { override suspend fun getTokenChart(cryptoCurrencyToken: CryptoCurrency.Token): YieldSupplyMarketChartData {
val chainId = Blockchain.fromNetworkId(cryptoCurrencyToken.network.backendId)?.getChainId() val chainId = Blockchain.fromNetworkId(cryptoCurrencyToken.network.rawId)?.getChainId()
?: error("Chain id is required for evm's") ?: error("Chain id is required for evm's")
val response = yieldSupplyApi.getYieldTokenChart(chainId, cryptoCurrencyToken.contractAddress).getOrThrow() val response = yieldSupplyApi.getYieldTokenChart(chainId, cryptoCurrencyToken.contractAddress).getOrThrow()
return YieldTokenChartConverter.convert(response) return YieldTokenChartConverter.convert(response)
@ -99,7 +99,7 @@ internal class DefaultYieldSupplyRepository(
cryptoCurrencyToken: CryptoCurrency.Token, cryptoCurrencyToken: CryptoCurrency.Token,
address: String, address: String,
): Boolean = withContext(dispatchers.io) { ): Boolean = withContext(dispatchers.io) {
val chainId = Blockchain.fromNetworkId(cryptoCurrencyToken.network.backendId)?.getChainId() val chainId = Blockchain.fromNetworkId(cryptoCurrencyToken.network.rawId)?.getChainId()
?: error("Chain id is required for evm's") ?: error("Chain id is required for evm's")
yieldSupplyApi.activateYieldModule( yieldSupplyApi.activateYieldModule(
body = YieldSupplyChangeTokenStatusBody( body = YieldSupplyChangeTokenStatusBody(
@ -113,7 +113,7 @@ internal class DefaultYieldSupplyRepository(
override suspend fun deactivateProtocol(cryptoCurrencyToken: CryptoCurrency.Token, address: String): Boolean = override suspend fun deactivateProtocol(cryptoCurrencyToken: CryptoCurrency.Token, address: String): Boolean =
withContext(dispatchers.io) { withContext(dispatchers.io) {
val chainId = Blockchain.fromNetworkId(cryptoCurrencyToken.network.backendId)?.getChainId() val chainId = Blockchain.fromNetworkId(cryptoCurrencyToken.network.rawId)?.getChainId()
?: error("Chain id is required for evm's") ?: error("Chain id is required for evm's")
yieldSupplyApi.deactivateYieldModule( yieldSupplyApi.deactivateYieldModule(
YieldSupplyChangeTokenStatusBody( YieldSupplyChangeTokenStatusBody(

View file

@ -36,7 +36,7 @@ class DefaultYieldSupplyTransactionRepositoryTest {
private val userWalletId = mockk<UserWalletId>() private val userWalletId = mockk<UserWalletId>()
private val cryptoCurrency = mockk<CryptoCurrency.Token>(relaxed = true) { private val cryptoCurrency = mockk<CryptoCurrency.Token>(relaxed = true) {
every { network.id } returns networkId every { network.id } returns networkId
every { network.backendId } returns networkId.rawId.value every { network.rawId } returns networkId.rawId.value
every { contractAddress } returns mockedContractAddress every { contractAddress } returns mockedContractAddress
} }
private val cryptoCurrencyStatus = mockk<CryptoCurrencyStatus>(relaxed = true) { private val cryptoCurrencyStatus = mockk<CryptoCurrencyStatus>(relaxed = true) {

View file

@ -80,7 +80,7 @@ class ArchiveCryptoPortfolioUseCase(
val hasNotReferralToken = statuses.none { status -> val hasNotReferralToken = statuses.none { status ->
val currency = status.currency val currency = status.currency
currency.network.backendId == referralToken.networkId && currency.network.rawId == referralToken.networkId &&
(currency as? CryptoCurrency.Token)?.contractAddress == referralToken.contractAddress && (currency as? CryptoCurrency.Token)?.contractAddress == referralToken.contractAddress &&
status.value.networkAddress?.availableAddresses?.any { it.value == address } == true status.value.networkAddress?.availableAddresses?.any { it.value == address } == true
} }

View file

@ -168,7 +168,7 @@ class ManageCryptoCurrenciesUseCase(
val foundToken = accountStatus.tokenList.flattenCurrencies() val foundToken = accountStatus.tokenList.flattenCurrencies()
.mapNotNull { it.currency as? CryptoCurrency.Token } .mapNotNull { it.currency as? CryptoCurrency.Token }
.firstOrNull { token -> .firstOrNull { token ->
token.network.backendId == networkId && token.network.rawId == networkId &&
!token.isCustom && !token.isCustom &&
token.contractAddress.equals(contractAddress, true) token.contractAddress.equals(contractAddress, true)
} }
@ -361,7 +361,7 @@ class ManageCryptoCurrenciesUseCase(
launch { launch {
val assetIds = currencies.mapTo(hashSetOf()) { currency -> val assetIds = currencies.mapTo(hashSetOf()) { currency ->
ExpressAsset.ID( ExpressAsset.ID(
networkId = currency.network.backendId, networkId = currency.network.rawId,
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress, contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress,
) )
} }
@ -388,19 +388,19 @@ class ManageCryptoCurrenciesUseCase(
) { ) {
constructor(network: Network) : this( constructor(network: Network) : this(
networkId = network.backendId, networkId = network.rawId,
derivationPath = network.derivationPath, derivationPath = network.derivationPath,
contractAddress = null, contractAddress = null,
) )
constructor(currency: CryptoCurrency) : this( constructor(currency: CryptoCurrency) : this(
networkId = currency.network.backendId, networkId = currency.network.rawId,
derivationPath = currency.network.derivationPath, derivationPath = currency.network.derivationPath,
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress, contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress,
) )
constructor(status: CryptoCurrencyStatus) : this( constructor(status: CryptoCurrencyStatus) : this(
networkId = status.currency.network.backendId, networkId = status.currency.network.rawId,
derivationPath = status.currency.network.derivationPath, derivationPath = status.currency.network.derivationPath,
contractAddress = (status.currency as? CryptoCurrency.Token)?.contractAddress, contractAddress = (status.currency as? CryptoCurrency.Token)?.contractAddress,
) )

View file

@ -143,7 +143,7 @@ class ArchiveCryptoPortfolioUseCaseTest {
val defaultAddress = "0xABC" val defaultAddress = "0xABC"
val cryptoCurrency = mockk<CryptoCurrency.Token> { val cryptoCurrency = mockk<CryptoCurrency.Token> {
every { this@mockk.network.backendId } returns token.networkId every { this@mockk.network.rawId } returns token.networkId
every { this@mockk.contractAddress } returns token.contractAddress!! every { this@mockk.contractAddress } returns token.contractAddress!!
} }

View file

@ -56,7 +56,7 @@ class GetEarnNetworksUseCase(
accountLists accountLists
.filter { it.userWalletId in unlockedWalletsId } .filter { it.userWalletId in unlockedWalletsId }
.flatMap(AccountList::flattenCurrencies) .flatMap(AccountList::flattenCurrencies)
.mapTo(HashSet()) { it.network.backendId } .mapTo(HashSet()) { it.network.rawId }
} }
} }
} }

View file

@ -3,7 +3,7 @@ package com.tangem.domain.models.currency
import java.math.BigDecimal import java.math.BigDecimal
fun CryptoCurrency.Token.yieldSupplyKey(): String { fun CryptoCurrency.Token.yieldSupplyKey(): String {
return "${network.backendId}_$contractAddress" return "${network.rawId}_$contractAddress"
} }
fun CryptoCurrencyStatus.hasNotSuppliedAmount(): Boolean { fun CryptoCurrencyStatus.hasNotSuppliedAmount(): Boolean {

View file

@ -35,11 +35,6 @@ data class Network(
val nameResolvingType: NameResolvingType, val nameResolvingType: NameResolvingType,
) { ) {
/** Backend ID */
@Deprecated("Will be removed later")
val backendId: String
get() = id.rawId.value
/** Raw ID */ /** Raw ID */
val rawId: String val rawId: String
get() = id.rawId.value get() = id.rawId.value

View file

@ -193,7 +193,7 @@ class WalletBalanceFetcher internal constructor(
private suspend fun fetchExpressAssets(userWallet: UserWallet, currencies: Set<CryptoCurrency>) { private suspend fun fetchExpressAssets(userWallet: UserWallet, currencies: Set<CryptoCurrency>) {
val assetIds = currencies.mapTo(hashSetOf()) { currency -> val assetIds = currencies.mapTo(hashSetOf()) { currency ->
ExpressAsset.ID( ExpressAsset.ID(
networkId = currency.network.backendId, networkId = currency.network.rawId,
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress, contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress,
) )
} }

View file

@ -40,8 +40,8 @@ class GetEthSpecificFeeUseCase(
?: (walletManager as? EthereumWalletManager)?.getGasPriceValue() ?: (walletManager as? EthereumWalletManager)?.getGasPriceValue()
?: error("not supported for ${cryptoCurrency.network}") ?: error("not supported for ${cryptoCurrency.network}")
val blockchain = Blockchain.fromNetworkId(networkId = cryptoCurrency.network.backendId) val blockchain = Blockchain.fromNetworkId(networkId = cryptoCurrency.network.rawId)
?: error("unknown networkId ${cryptoCurrency.network.backendId}") ?: error("unknown networkId ${cryptoCurrency.network.rawId}")
val minimalFee = getEthLegacyFee( val minimalFee = getEthLegacyFee(
gasPrice = gasPriceResult, gasPrice = gasPriceResult,

View file

@ -36,13 +36,13 @@ data class AvailableToAddAccount(
get() = availableNetworks.size == 1 get() = availableNetworks.size == 1
val availableToAddNetworks: Set<TokenMarketInfo.Network> = availableNetworks val availableToAddNetworks: Set<TokenMarketInfo.Network> = availableNetworks
.filter { available -> addedNetworks.none { added -> added.backendId == available.networkId } } .filter { available -> addedNetworks.none { added -> added.rawId == available.networkId } }
.toSet() .toSet()
val isAvailableToAdd: Boolean = availableToAddNetworks.isNotEmpty() val isAvailableToAdd: Boolean = availableToAddNetworks.isNotEmpty()
val addedMarketNetworks: Set<TokenMarketInfo.Network> = availableNetworks val addedMarketNetworks: Set<TokenMarketInfo.Network> = availableNetworks
.filter { available -> addedNetworks.any { added -> added.backendId == available.networkId } } .filter { available -> addedNetworks.any { added -> added.rawId == available.networkId } }
.toSet() .toSet()
} }

View file

@ -526,7 +526,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
val networks = newInfo.networks?.filter { network -> val networks = newInfo.networks?.filter { network ->
BlockchainUtils.isSupportedNetworkId( BlockchainUtils.isSupportedNetworkId(
blockchainId = network.networkId, networkId = network.networkId,
excludedBlockchains = excludedBlockchains, excludedBlockchains = excludedBlockchains,
hotExcludedBlockchains = hotWalletExcludedBlockchains, hotExcludedBlockchains = hotWalletExcludedBlockchains,
hasOnlyHotWallets = isAllWalletsIsHot, hasOnlyHotWallets = isAllWalletsIsHot,

View file

@ -183,7 +183,7 @@ internal class CustomTokenFormModel @Inject constructor(
) = modelScope.launch { ) = modelScope.launch {
val isNeedColdWalletInteraction = coldWalletAndHasMissedDerivationsUseCase.invoke( val isNeedColdWalletInteraction = coldWalletAndHasMissedDerivationsUseCase.invoke(
userWalletId = params.mode.userWalletId, userWalletId = params.mode.userWalletId,
networksWithDerivationPath = mapOf(currency.network.backendId to getDerivationPath().value), networksWithDerivationPath = mapOf(currency.network.rawId to getDerivationPath().value),
) )
state.update { state -> state.update { state ->

View file

@ -293,7 +293,7 @@ internal class ManageTokensModel @Inject constructor(
val networks = currenciesToAdd.values val networks = currenciesToAdd.values
.flatten() .flatten()
.toSet() .toSet()
.associate { network -> network.backendId to network.derivationPath.value } .associate { network -> network.rawId to network.derivationPath.value }
val isNeedToInteractWithColdWallet = useCasesFacade.needColdWalletInteraction(networks) val isNeedToInteractWithColdWallet = useCasesFacade.needColdWalletInteraction(networks)
state.update { state -> state.update { state ->

View file

@ -212,7 +212,7 @@ internal class OnboardingManageTokensModel @Inject constructor(
val network = currenciesToAdd.values val network = currenciesToAdd.values
.flatten() .flatten()
.toSet() .toSet()
.associate { network -> network.backendId to network.derivationPath.value } .associate { network -> network.rawId to network.derivationPath.value }
val shouldShowTangemIcon = useCasesFacade.needColdWalletInteraction(network = network) val shouldShowTangemIcon = useCasesFacade.needColdWalletInteraction(network = network)
state.update { state -> state.update { state ->
state.copy( state.copy(

View file

@ -81,7 +81,7 @@ internal class CustomTokenFormUseCasesFacade @AssistedInject constructor(
private fun CryptoCurrency.getAccountIndex(): Either<Throwable, Int> = either { private fun CryptoCurrency.getAccountIndex(): Either<Throwable, Int> = either {
val currency = this@getAccountIndex val currency = this@getAccountIndex
val blockchain = Blockchain.fromNetworkId(networkId = currency.network.backendId) val blockchain = Blockchain.fromNetworkId(networkId = currency.network.rawId)
if (blockchain == null) { if (blockchain == null) {
val exception = IllegalStateException("Token has unknown networkId: ${currency.id}") val exception = IllegalStateException("Token has unknown networkId: ${currency.id}")
TangemLogger.e("Error", exception) TangemLogger.e("Error", exception)

View file

@ -79,7 +79,7 @@ internal class ManageTokensUseCasesFacade @AssistedInject constructor(
?: return IllegalStateException("Account not found").left() ?: return IllegalStateException("Account not found").left()
(account.cryptoCurrencies + added - removed).any { currency -> (account.cryptoCurrencies + added - removed).any { currency ->
currency is CryptoCurrency.Token && currency.network.backendId == network.backendId && currency is CryptoCurrency.Token && currency.network.rawId == network.rawId &&
currency.network.derivationPath == network.derivationPath currency.network.derivationPath == network.derivationPath
} }
.right() .right()

View file

@ -50,7 +50,7 @@ internal class OnrampAddTokenModel @Inject constructor(
.distinctUntilChanged() .distinctUntilChanged()
.mapLatest { tokenToAdd: AddHotCryptoData -> .mapLatest { tokenToAdd: AddHotCryptoData ->
addTokenJob.join() addTokenJob.join()
val backendId = tokenToAdd.cryptoCurrency.network.backendId val backendId = tokenToAdd.cryptoCurrency.network.rawId
val userWalletId = tokenToAdd.account.accountId.userWalletId val userWalletId = tokenToAdd.account.accountId.userWalletId
val isTangemIconVisible = needColdWalletInteraction( val isTangemIconVisible = needColdWalletInteraction(
walletId = userWalletId, walletId = userWalletId,

View file

@ -252,7 +252,7 @@ internal class AvailableSwapPairsModel @Inject constructor(
is AccountStatus.CryptoPortfolio -> { is AccountStatus.CryptoPortfolio -> {
val statuses = accountStatus.tokenList.flattenCurrencies() val statuses = accountStatus.tokenList.flattenCurrencies()
.filterNot { status -> .filterNot { status ->
status.currency.network.backendId == selectedStatus?.currency?.network?.backendId && status.currency.network.rawId == selectedStatus?.currency?.network?.rawId &&
status.currency.id.contractAddress == selectedStatus.currency.id.contractAddress status.currency.id.contractAddress == selectedStatus.currency.id.contractAddress
} }
.filterByQuery(query = query) .filterByQuery(query = query)
@ -462,7 +462,7 @@ internal class AvailableSwapPairsModel @Inject constructor(
private fun CryptoCurrencyStatus.toLeastTokenInfo(): LeastTokenInfo { private fun CryptoCurrencyStatus.toLeastTokenInfo(): LeastTokenInfo {
return LeastTokenInfo( return LeastTokenInfo(
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress ?: "0", contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress ?: "0",
network = currency.network.backendId, network = currency.network.rawId,
) )
} }
@ -607,7 +607,7 @@ internal class AvailableSwapPairsModel @Inject constructor(
val networks = tokenMarket.networks?.filter { network -> val networks = tokenMarket.networks?.filter { network ->
BlockchainUtils.isSupportedNetworkId( BlockchainUtils.isSupportedNetworkId(
blockchainId = network.networkId, networkId = network.networkId,
coinId = tokenMarket.id.value, coinId = tokenMarket.id.value,
contractAddress = network.contractAddress, contractAddress = network.contractAddress,
excludedBlockchains = excludedBlockchains, excludedBlockchains = excludedBlockchains,

View file

@ -251,7 +251,7 @@ internal class NotificationsModel @Inject constructor(
addExceedsBalanceNotification( addExceedsBalanceNotification(
cryptoCurrencyWarning = currencyWarning, cryptoCurrencyWarning = currencyWarning,
cryptoCurrencyStatus = cryptoCurrencyStatus, cryptoCurrencyStatus = cryptoCurrencyStatus,
shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum(currency.network.backendId), shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum(currency.network.rawId),
onClick = ::showTokenDetails, onClick = ::showTokenDetails,
onAnalyticsEvent = { onAnalyticsEvent = {
val event = NotificationsAnalyticEvents.NoticeNotEnoughFee( val event = NotificationsAnalyticEvents.NoticeNotEnoughFee(

View file

@ -54,7 +54,7 @@ internal class DefaultStakingDeepLinkHandler @AssistedInject constructor(
) )
.orEmpty() .orEmpty()
.firstOrNull { currency -> .firstOrNull { currency ->
val isNetwork = currency.network.backendId.equals(networkId, ignoreCase = true) val isNetwork = currency.network.rawId.equals(networkId, ignoreCase = true)
val isCurrency = currency.id.rawCurrencyId?.value?.equals(tokenId, ignoreCase = true) == true val isCurrency = currency.id.rawCurrencyId?.value?.equals(tokenId, ignoreCase = true) == true
isNetwork && isCurrency isNetwork && isCurrency
} }

View file

@ -85,7 +85,7 @@ internal class StakingBalanceEntryConverter(
private fun StakingBalanceEntry.getBalanceValue(): BigDecimal { private fun StakingBalanceEntry.getBalanceValue(): BigDecimal {
val isIncludeStakingTotalBalance = BlockchainUtils.isIncludeStakingTotalBalance( val isIncludeStakingTotalBalance = BlockchainUtils.isIncludeStakingTotalBalance(
blockchainId = cryptoCurrencyStatus.currency.network.rawId, networkId = cryptoCurrencyStatus.currency.network.rawId,
) )
return if (isIncludeStakingTotalBalance) { return if (isIncludeStakingTotalBalance) {
amount amount

View file

@ -229,7 +229,7 @@ internal class AddStakingNotificationsTransformer(
addExceedsBalanceNotification( addExceedsBalanceNotification(
cryptoCurrencyWarning = currencyWarning, cryptoCurrencyWarning = currencyWarning,
cryptoCurrencyStatus = cryptoCurrencyStatus, cryptoCurrencyStatus = cryptoCurrencyStatus,
shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum(network.backendId), shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum(network.rawId),
onClick = prevState.clickIntents::openTokenDetails, onClick = prevState.clickIntents::openTokenDetails,
onAnalyticsEvent = { prevState.clickIntents.onNotEnoughFeeNotificationShow() }, onAnalyticsEvent = { prevState.clickIntents.onNotEnoughFeeNotificationShow() },
onResetAnalyticsEvent = { /*no-op*/ }, onResetAnalyticsEvent = { /*no-op*/ },
@ -315,7 +315,7 @@ internal class AddStakingNotificationsTransformer(
currencyName = name, currencyName = name,
feeName = name, feeName = name,
feeSymbol = symbol, feeSymbol = symbol,
mergeFeeNetworkName = BlockchainUtils.isArbitrum(network.backendId), mergeFeeNetworkName = BlockchainUtils.isArbitrum(network.rawId),
onClick = { onClick(this) }, onClick = { onClick(this) },
) )
} }

View file

@ -29,7 +29,7 @@ internal class SwapChooseContentStateTransformer(
val isMain = cryptoCurrency is CryptoCurrency.Coin val isMain = cryptoCurrency is CryptoCurrency.Coin
val subtitle = when { val subtitle = when {
BlockchainUtils.isL2Network(networkId = network.backendId) -> MAIN_NETWORK_L2_TYPE_NAME BlockchainUtils.isL2Network(networkId = network.rawId) -> MAIN_NETWORK_L2_TYPE_NAME
isMain -> MAIN_NETWORK_TYPE_NAME isMain -> MAIN_NETWORK_TYPE_NAME
network.standardType !is Network.StandardType.Unspecified -> network.standardType.name network.standardType !is Network.StandardType.Unspecified -> network.standardType.name
else -> "" else -> ""

View file

@ -9,7 +9,7 @@ class LeastTokenInfoConverter : Converter<CryptoCurrency, LeastTokenInfo> {
override fun convert(value: CryptoCurrency): LeastTokenInfo { override fun convert(value: CryptoCurrency): LeastTokenInfo {
return LeastTokenInfo( return LeastTokenInfo(
contractAddress = (value as? CryptoCurrency.Token)?.contractAddress ?: "0", contractAddress = (value as? CryptoCurrency.Token)?.contractAddress ?: "0",
network = value.network.backendId, network = value.network.rawId,
) )
} }
} }

View file

@ -162,7 +162,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
userWallet = userWallet, userWallet = userWallet,
initialCurrency = LeastTokenInfo( initialCurrency = LeastTokenInfo(
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress ?: "0", contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress ?: "0",
network = currency.network.backendId, network = currency.network.rawId,
), ),
currenciesList = walletAccountCurrencyStatusesExceptInitial.flatMap { accountStatus -> currenciesList = walletAccountCurrencyStatusesExceptInitial.flatMap { accountStatus ->
accountStatus.value.map { it.currency } accountStatus.value.map { it.currency }
@ -199,7 +199,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
} }
private fun List<CryptoCurrencyStatus>.filterCurrencies(currency: CryptoCurrency) = this.filter { status -> private fun List<CryptoCurrencyStatus>.filterCurrencies(currency: CryptoCurrency) = this.filter { status ->
val isDifferentCurrency = status.currency.network.backendId != currency.network.backendId || val isDifferentCurrency = status.currency.network.rawId != currency.network.rawId ||
status.currency.getContractAddress() != currency.getContractAddress() status.currency.getContractAddress() != currency.getContractAddress()
val hasValidStatus = val hasValidStatus =
@ -218,7 +218,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
): CurrenciesGroup { ): CurrenciesGroup {
val filteredPairs = leastPairs.filter { pair -> val filteredPairs = leastPairs.filter { pair ->
tokenInfoForFilter(pair).contractAddress == currency.getContractAddress() && tokenInfoForFilter(pair).contractAddress == currency.getContractAddress() &&
tokenInfoForFilter(pair).network == currency.network.backendId tokenInfoForFilter(pair).network == currency.network.rawId
} }
val accountCurrencyList = cryptoCurrenciesList.map { (accountEntry, currencyStatusList) -> val accountCurrencyList = cryptoCurrenciesList.map { (accountEntry, currencyStatusList) ->
@ -259,7 +259,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
return swapPairsLeastList.firstNotNullOfOrNull { pair -> return swapPairsLeastList.firstNotNullOfOrNull { pair ->
val listTokenInfo = tokenInfoForAvailable(pair) val listTokenInfo = tokenInfoForAvailable(pair)
if (cryptoCurrencyStatuses.currency.network.backendId == listTokenInfo.network && if (cryptoCurrencyStatuses.currency.network.rawId == listTokenInfo.network &&
cryptoCurrencyStatuses.currency.getContractAddress() == listTokenInfo.contractAddress && cryptoCurrencyStatuses.currency.getContractAddress() == listTokenInfo.contractAddress &&
isAvailableForSwap isAvailableForSwap
) { ) {
@ -359,7 +359,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
is Account.Payment -> true is Account.Payment -> true
else -> isBalanceEnough(fromToken, amount, null) else -> isBalanceEnough(fromToken, amount, null)
} }
val networkId = fromToken.currency.network.backendId val networkId = fromToken.currency.network.rawId
return supervisorScope { return supervisorScope {
providers.map { provider -> providers.map { provider ->
@ -453,9 +453,9 @@ internal class SwapInteractorImpl @AssistedInject constructor(
val maybeQuotes = repository.findBestQuote( val maybeQuotes = repository.findBestQuote(
userWallet = userWallet, userWallet = userWallet,
fromContractAddress = fromToken.currency.getContractAddress(), fromContractAddress = fromToken.currency.getContractAddress(),
fromNetwork = fromToken.currency.network.backendId, fromNetwork = fromToken.currency.network.rawId,
toContractAddress = toToken.currency.getContractAddress(), toContractAddress = toToken.currency.getContractAddress(),
toNetwork = toToken.currency.network.backendId, toNetwork = toToken.currency.network.rawId,
fromAmount = amount.toStringWithRightOffset(), fromAmount = amount.toStringWithRightOffset(),
fromDecimals = amount.decimals, fromDecimals = amount.decimals,
toDecimals = toToken.currency.decimals, toDecimals = toToken.currency.decimals,
@ -527,9 +527,9 @@ internal class SwapInteractorImpl @AssistedInject constructor(
val maybeQuotes = repository.findBestQuote( val maybeQuotes = repository.findBestQuote(
userWallet = userWallet, userWallet = userWallet,
fromContractAddress = fromToken.currency.getContractAddress(), fromContractAddress = fromToken.currency.getContractAddress(),
fromNetwork = fromToken.currency.network.backendId, fromNetwork = fromToken.currency.network.rawId,
toContractAddress = toToken.currency.getContractAddress(), toContractAddress = toToken.currency.getContractAddress(),
toNetwork = toToken.currency.network.backendId, toNetwork = toToken.currency.network.rawId,
fromAmount = amount.toStringWithRightOffset(), fromAmount = amount.toStringWithRightOffset(),
fromDecimals = amount.decimals, fromDecimals = amount.decimals,
toDecimals = toToken.currency.decimals, toDecimals = toToken.currency.decimals,
@ -672,7 +672,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
FeePaidCurrency.Coin -> { FeePaidCurrency.Coin -> {
val nativeBalance = walletManagersFacade.getNativeTokenBalance( val nativeBalance = walletManagersFacade.getNativeTokenBalance(
userWalletId = userWalletId, userWalletId = userWalletId,
networkId = fromTokenStatus.currency.network.backendId, networkId = fromTokenStatus.currency.network.rawId,
derivationPath = fromTokenStatus.currency.network.derivationPath.value, derivationPath = fromTokenStatus.currency.network.derivationPath.value,
) )
@ -780,7 +780,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
) )
} }
ExchangeProviderType.DEX, ExchangeProviderType.DEX_BRIDGE -> { ExchangeProviderType.DEX, ExchangeProviderType.DEX_BRIDGE -> {
val networkId = currencyToSend.currency.network.backendId val networkId = currencyToSend.currency.network.rawId
if (isSolana(networkId)) { if (isSolana(networkId)) {
onSwapSolanaDex( onSwapSolanaDex(
provider = swapProvider, provider = swapProvider,
@ -902,7 +902,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
repository.exchangeSent( repository.exchangeSent(
userWallet = userWallet, userWallet = userWallet,
txId = swapData.transaction.txId, txId = swapData.transaction.txId,
fromNetwork = currencyToSendStatus.currency.network.backendId, fromNetwork = currencyToSendStatus.currency.network.rawId,
fromAddress = fromAddress, fromAddress = fromAddress,
payInAddress = payInAddress, payInAddress = payInAddress,
txHash = txHash, txHash = txHash,
@ -968,10 +968,10 @@ internal class SwapInteractorImpl @AssistedInject constructor(
val exchangeData = repository.getExchangeData( val exchangeData = repository.getExchangeData(
userWallet = userWallet, userWallet = userWallet,
fromContractAddress = currencyToSend.currency.getContractAddress(), fromContractAddress = currencyToSend.currency.getContractAddress(),
fromNetwork = currencyToSend.currency.network.backendId, fromNetwork = currencyToSend.currency.network.rawId,
toContractAddress = currencyToGet.currency.getContractAddress(), toContractAddress = currencyToGet.currency.getContractAddress(),
fromAddress = fromAddress, fromAddress = fromAddress,
toNetwork = currencyToGet.currency.network.backendId, toNetwork = currencyToGet.currency.network.rawId,
fromAmount = amount.toStringWithRightOffset(), fromAmount = amount.toStringWithRightOffset(),
fromDecimals = amount.decimals, fromDecimals = amount.decimals,
toDecimals = currencyToGet.currency.decimals, toDecimals = currencyToGet.currency.decimals,
@ -1016,7 +1016,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
), ),
exchangeData = TangemPayWithdrawExchangeState( exchangeData = TangemPayWithdrawExchangeState(
txId = exchangeDataCex.txId, txId = exchangeDataCex.txId,
fromNetwork = currencyToSend.currency.network.backendId, fromNetwork = currencyToSend.currency.network.rawId,
fromAddress = networkAddress?.defaultAddress?.value.orEmpty(), fromAddress = networkAddress?.defaultAddress?.value.orEmpty(),
payInAddress = exchangeData.transaction.txTo, payInAddress = exchangeData.transaction.txTo,
payInExtraId = exchangeDataCex.txExtraId, payInExtraId = exchangeDataCex.txExtraId,
@ -1080,7 +1080,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
repository.exchangeSent( repository.exchangeSent(
userWallet = userWallet, userWallet = userWallet,
txId = exchangeDataCex.txId, txId = exchangeDataCex.txId,
fromNetwork = currencyToSend.currency.network.backendId, fromNetwork = currencyToSend.currency.network.rawId,
fromAddress = cexFromAddress, fromAddress = cexFromAddress,
payInAddress = getPayoutAddress(txData), payInAddress = getPayoutAddress(txData),
txHash = txHash, txHash = txHash,
@ -1222,10 +1222,10 @@ internal class SwapInteractorImpl @AssistedInject constructor(
repository.getExchangeData( repository.getExchangeData(
userWallet = userWallet, userWallet = userWallet,
fromContractAddress = fromToken.currency.getContractAddress(), fromContractAddress = fromToken.currency.getContractAddress(),
fromNetwork = fromToken.currency.network.backendId, fromNetwork = fromToken.currency.network.rawId,
toContractAddress = toToken.currency.getContractAddress(), toContractAddress = toToken.currency.getContractAddress(),
fromAddress = dexFromAddress, fromAddress = dexFromAddress,
toNetwork = toToken.currency.network.backendId, toNetwork = toToken.currency.network.rawId,
fromAmount = swapAmount.toStringWithRightOffset(), fromAmount = swapAmount.toStringWithRightOffset(),
fromDecimals = swapAmount.decimals, fromDecimals = swapAmount.decimals,
toDecimals = toToken.currency.decimals, toDecimals = toToken.currency.decimals,
@ -1235,7 +1235,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
refundAddress = fromToken.value.networkAddress?.defaultAddress?.value, refundAddress = fromToken.value.networkAddress?.defaultAddress?.value,
expressOperationType = ExpressOperationType.SWAP, expressOperationType = ExpressOperationType.SWAP,
).map { swapData -> ).map { swapData ->
val networkId = fromToken.currency.network.backendId val networkId = fromToken.currency.network.rawId
val transaction = swapData.transaction as ExpressTransactionModel.DEX val transaction = swapData.transaction as ExpressTransactionModel.DEX
loadFeeForDex( loadFeeForDex(
@ -1361,9 +1361,9 @@ internal class SwapInteractorImpl @AssistedInject constructor(
val quotes = repository.findBestQuote( val quotes = repository.findBestQuote(
userWallet = userWallet, userWallet = userWallet,
fromContractAddress = fromToken.getContractAddress(), fromContractAddress = fromToken.getContractAddress(),
fromNetwork = fromToken.network.backendId, fromNetwork = fromToken.network.rawId,
toContractAddress = toToken.getContractAddress(), toContractAddress = toToken.getContractAddress(),
toNetwork = toToken.network.backendId, toNetwork = toToken.network.rawId,
fromAmount = amountToRequest.toStringWithRightOffset(), fromAmount = amountToRequest.toStringWithRightOffset(),
fromDecimals = amount.decimals, fromDecimals = amount.decimals,
toDecimals = toToken.decimals, toDecimals = toToken.decimals,
@ -1739,10 +1739,10 @@ internal class SwapInteractorImpl @AssistedInject constructor(
return repository.getExchangeData( return repository.getExchangeData(
userWallet = userWallet, userWallet = userWallet,
fromContractAddress = fromToken.currency.getContractAddress(), fromContractAddress = fromToken.currency.getContractAddress(),
fromNetwork = fromToken.currency.network.backendId, fromNetwork = fromToken.currency.network.rawId,
toContractAddress = toToken.currency.getContractAddress(), toContractAddress = toToken.currency.getContractAddress(),
fromAddress = dexFromAddress, fromAddress = dexFromAddress,
toNetwork = toToken.currency.network.backendId, toNetwork = toToken.currency.network.rawId,
fromAmount = amount.toStringWithRightOffset(), fromAmount = amount.toStringWithRightOffset(),
fromDecimals = amount.decimals, fromDecimals = amount.decimals,
toDecimals = toToken.currency.decimals, toDecimals = toToken.currency.decimals,
@ -1896,7 +1896,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
): Either<ExpressDataError, TransactionFeeResult> = either { ): Either<ExpressDataError, TransactionFeeResult> = either {
val nativeBalance = walletManagersFacade.getNativeTokenBalance( val nativeBalance = walletManagersFacade.getNativeTokenBalance(
userWalletId = userWalletId, userWalletId = userWalletId,
networkId = network.backendId, networkId = network.rawId,
derivationPath = fromToken.network.derivationPath.value, derivationPath = fromToken.network.derivationPath.value,
) )
@ -2059,14 +2059,14 @@ internal class SwapInteractorImpl @AssistedInject constructor(
) )
} }
// setting up amount for approve with given amount for swap [SwapApproveType.Limited] // setting up amount for approve with given amount for swap [SwapApproveType.Limited]
val fromAddress = requireNotNull( requireNotNull(
fromTokenStatus.value.networkAddress?.defaultAddress?.value, fromTokenStatus.value.networkAddress?.defaultAddress?.value,
) { "networkAddress cant be null" } ) { "networkAddress cannot be null" }
val allowanceInfo = getAllowanceInfoUseCase( val allowanceInfo = getAllowanceInfoUseCase(
userWalletId = userWalletId, userWalletId = userWalletId,
cryptoCurrency = fromToken, cryptoCurrency = fromToken,
spenderAddress = requireNotNull(spenderAddress) { "spenderAddress cant be null" }, spenderAddress = requireNotNull(spenderAddress) { "spenderAddress cannot be null" },
requiredAmount = swapAmount.value, requiredAmount = swapAmount.value,
).getOrNull() ).getOrNull()
@ -2229,7 +2229,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
} }
private fun createNativeAmountForDex(txValueAmount: String, network: Network): Amount { private fun createNativeAmountForDex(txValueAmount: String, network: Network): Amount {
val nativeDecimals = Blockchain.fromNetworkId(network.backendId)?.decimals() val nativeDecimals = Blockchain.fromNetworkId(network.rawId)?.decimals()
?: error("Blockchain not found") ?: error("Blockchain not found")
val decimalValue = txValueAmount.toBigDecimalOrNull()?.movePointLeft(nativeDecimals) val decimalValue = txValueAmount.toBigDecimalOrNull()?.movePointLeft(nativeDecimals)
?: error("txValue parse error") ?: error("txValue parse error")

View file

@ -187,7 +187,7 @@ internal class MarketBlockDelegate @AssistedInject constructor(
val networks = tokenMarket.networks?.filter { network -> val networks = tokenMarket.networks?.filter { network ->
BlockchainUtils.isSupportedNetworkId( BlockchainUtils.isSupportedNetworkId(
blockchainId = network.networkId, networkId = network.networkId,
coinId = tokenMarket.id.value, coinId = tokenMarket.id.value,
contractAddress = network.contractAddress, contractAddress = network.contractAddress,
excludedBlockchains = excludedBlockchains, excludedBlockchains = excludedBlockchains,

View file

@ -880,11 +880,11 @@ internal class SwapModel @Inject constructor(
private fun sendErrorAnalyticsEvent(error: ExpressDataError, provider: SwapProvider) { private fun sendErrorAnalyticsEvent(error: ExpressDataError, provider: SwapProvider) {
val receiveToken = dataState.toCryptoCurrency?.currency?.let { currency -> val receiveToken = dataState.toCryptoCurrency?.currency?.let { currency ->
"${currency.network.backendId}:${currency.symbol}" "${currency.network.rawId}:${currency.symbol}"
} }
analyticsErrorEventHandler.sendErrorEvent( analyticsErrorEventHandler.sendErrorEvent(
SwapEvents.NoticeProviderError( SwapEvents.NoticeProviderError(
sendToken = "${initialCurrencyFrom.network.backendId}:${initialCurrencyFrom.symbol}", sendToken = "${initialCurrencyFrom.network.rawId}:${initialCurrencyFrom.symbol}",
receiveToken = receiveToken.orEmpty(), receiveToken = receiveToken.orEmpty(),
provider = provider, provider = provider,
errorCode = error.code, errorCode = error.code,
@ -1174,7 +1174,7 @@ internal class SwapModel @Inject constructor(
} }
runCatching(dispatchers.io) { runCatching(dispatchers.io) {
swapInteractor.givePermissionToSwap( swapInteractor.givePermissionToSwap(
networkId = fromToken.network.backendId, networkId = fromToken.network.rawId,
permissionOptions = PermissionOptions( permissionOptions = PermissionOptions(
approveData = approveDataModel, approveData = approveDataModel,
forTokenContractAddress = (fromToken as? CryptoCurrency.Token)?.contractAddress.orEmpty(), forTokenContractAddress = (fromToken as? CryptoCurrency.Token)?.contractAddress.orEmpty(),

View file

@ -90,7 +90,7 @@ internal class StateBuilder(
token = null, token = null,
tokenIconUrl = initialCurrencyFrom.iconUrl, tokenIconUrl = initialCurrencyFrom.iconUrl,
tokenCurrency = initialCurrencyFrom.symbol, tokenCurrency = initialCurrencyFrom.symbol,
coinId = initialCurrencyFrom.network.backendId, coinId = initialCurrencyFrom.network.rawId,
canSelectAnotherToken = false, canSelectAnotherToken = false,
isNotNativeToken = initialCurrencyFrom is CryptoCurrency.Token, isNotNativeToken = initialCurrencyFrom is CryptoCurrency.Token,
balance = "", balance = "",
@ -108,7 +108,7 @@ internal class StateBuilder(
balance = "", balance = "",
isNotNativeToken = initialCurrencyTo is CryptoCurrency.Token, isNotNativeToken = initialCurrencyTo is CryptoCurrency.Token,
networkIconRes = initialCurrencyTo?.let { getActiveIconRes(it.network.rawId) }, networkIconRes = initialCurrencyTo?.let { getActiveIconRes(it.network.rawId) },
coinId = initialCurrencyTo?.network?.backendId, coinId = initialCurrencyTo?.network?.rawId,
isBalanceHidden = true, isBalanceHidden = true,
), ),
fee = FeeItemState.Empty, fee = FeeItemState.Empty,
@ -145,7 +145,7 @@ internal class StateBuilder(
amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO), amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO),
token = fromToken, token = fromToken,
tokenIconUrl = fromToken.currency.iconUrl, tokenIconUrl = fromToken.currency.iconUrl,
coinId = fromToken.currency.network.backendId, coinId = fromToken.currency.network.rawId,
isNotNativeToken = fromToken.currency is CryptoCurrency.Token, isNotNativeToken = fromToken.currency is CryptoCurrency.Token,
tokenCurrency = fromToken.currency.symbol, tokenCurrency = fromToken.currency.symbol,
canSelectAnotherToken = uiStateHolder.sendCardData.canSelectAnotherToken, canSelectAnotherToken = uiStateHolder.sendCardData.canSelectAnotherToken,
@ -196,7 +196,7 @@ internal class StateBuilder(
amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO), amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO),
token = fromToken, token = fromToken,
tokenIconUrl = fromToken.currency.iconUrl, tokenIconUrl = fromToken.currency.iconUrl,
coinId = fromToken.currency.network.backendId, coinId = fromToken.currency.network.rawId,
isNotNativeToken = fromToken.currency is CryptoCurrency.Token, isNotNativeToken = fromToken.currency is CryptoCurrency.Token,
tokenCurrency = fromToken.currency.symbol, tokenCurrency = fromToken.currency.symbol,
canSelectAnotherToken = canSelectSendToken, canSelectAnotherToken = canSelectSendToken,
@ -214,7 +214,7 @@ internal class StateBuilder(
amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO), amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO),
token = toToken, token = toToken,
tokenIconUrl = toToken.currency.iconUrl, tokenIconUrl = toToken.currency.iconUrl,
coinId = toToken.currency.network.backendId, coinId = toToken.currency.network.rawId,
isNotNativeToken = toToken.currency is CryptoCurrency.Token, isNotNativeToken = toToken.currency is CryptoCurrency.Token,
tokenCurrency = toToken.currency.symbol, tokenCurrency = toToken.currency.symbol,
canSelectAnotherToken = canSelectReceiveToken, canSelectAnotherToken = canSelectReceiveToken,
@ -266,7 +266,7 @@ internal class StateBuilder(
token = uiStateHolder.sendCardData.token, token = uiStateHolder.sendCardData.token,
tokenIconUrl = fromToken.iconUrl, tokenIconUrl = fromToken.iconUrl,
tokenCurrency = fromToken.symbol, tokenCurrency = fromToken.symbol,
coinId = fromToken.network.backendId, coinId = fromToken.network.rawId,
isNotNativeToken = fromToken is CryptoCurrency.Token, isNotNativeToken = fromToken is CryptoCurrency.Token,
canSelectAnotherToken = canSelectSendToken, canSelectAnotherToken = canSelectSendToken,
balance = if (!canSelectSendToken) uiStateHolder.sendCardData.balance else "", balance = if (!canSelectSendToken) uiStateHolder.sendCardData.balance else "",
@ -282,7 +282,7 @@ internal class StateBuilder(
token = uiStateHolder.receiveCardData.token, token = uiStateHolder.receiveCardData.token,
tokenIconUrl = toToken.iconUrl, tokenIconUrl = toToken.iconUrl,
tokenCurrency = toToken.symbol, tokenCurrency = toToken.symbol,
coinId = toToken.network.backendId, coinId = toToken.network.rawId,
isNotNativeToken = toToken is CryptoCurrency.Token, isNotNativeToken = toToken is CryptoCurrency.Token,
canSelectAnotherToken = canSelectReceiveToken, canSelectAnotherToken = canSelectReceiveToken,
balance = if (!canSelectReceiveToken) uiStateHolder.receiveCardData.balance else "", balance = if (!canSelectReceiveToken) uiStateHolder.receiveCardData.balance else "",
@ -374,7 +374,7 @@ internal class StateBuilder(
amountEquivalent = getFormattedFiatAmount(quoteModel.fromTokenInfo.amountFiat), amountEquivalent = getFormattedFiatAmount(quoteModel.fromTokenInfo.amountFiat),
token = fromCurrencyStatus, token = fromCurrencyStatus,
tokenIconUrl = uiStateHolder.sendCardData.tokenIconUrl, tokenIconUrl = uiStateHolder.sendCardData.tokenIconUrl,
coinId = fromCurrencyStatus.currency.network.backendId, coinId = fromCurrencyStatus.currency.network.rawId,
isNotNativeToken = uiStateHolder.sendCardData.isNotNativeToken, isNotNativeToken = uiStateHolder.sendCardData.isNotNativeToken,
tokenCurrency = uiStateHolder.sendCardData.tokenCurrency, tokenCurrency = uiStateHolder.sendCardData.tokenCurrency,
canSelectAnotherToken = uiStateHolder.sendCardData.canSelectAnotherToken, canSelectAnotherToken = uiStateHolder.sendCardData.canSelectAnotherToken,
@ -415,7 +415,7 @@ internal class StateBuilder(
}, },
token = toCurrencyStatus, token = toCurrencyStatus,
tokenIconUrl = uiStateHolder.receiveCardData.tokenIconUrl, tokenIconUrl = uiStateHolder.receiveCardData.tokenIconUrl,
coinId = toCurrencyStatus.currency.network.backendId, coinId = toCurrencyStatus.currency.network.rawId,
isNotNativeToken = uiStateHolder.receiveCardData.isNotNativeToken, isNotNativeToken = uiStateHolder.receiveCardData.isNotNativeToken,
tokenCurrency = uiStateHolder.receiveCardData.tokenCurrency, tokenCurrency = uiStateHolder.receiveCardData.tokenCurrency,
canSelectAnotherToken = uiStateHolder.receiveCardData.canSelectAnotherToken, canSelectAnotherToken = uiStateHolder.receiveCardData.canSelectAnotherToken,
@ -535,7 +535,7 @@ internal class StateBuilder(
amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO), amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO),
token = toToken, token = toToken,
tokenIconUrl = uiStateHolder.receiveCardData.tokenIconUrl, tokenIconUrl = uiStateHolder.receiveCardData.tokenIconUrl,
coinId = toToken.currency.network.backendId, coinId = toToken.currency.network.rawId,
isNotNativeToken = uiStateHolder.receiveCardData.isNotNativeToken, isNotNativeToken = uiStateHolder.receiveCardData.isNotNativeToken,
tokenCurrency = uiStateHolder.receiveCardData.tokenCurrency, tokenCurrency = uiStateHolder.receiveCardData.tokenCurrency,
canSelectAnotherToken = uiStateHolder.receiveCardData.canSelectAnotherToken, canSelectAnotherToken = uiStateHolder.receiveCardData.canSelectAnotherToken,

View file

@ -140,7 +140,7 @@ internal class DefaultTokenDetailsDeepLinkHandler @AssistedInject constructor(
val derivationPath = queryParams[DERIVATION_PATH_KEY] val derivationPath = queryParams[DERIVATION_PATH_KEY]
getCryptoCurrencies(userWalletId = userWallet.walletId)?.firstOrNull { currency -> getCryptoCurrencies(userWalletId = userWallet.walletId)?.firstOrNull { currency ->
val isNetwork = currency.network.backendId.equals(networkId, ignoreCase = true) val isNetwork = currency.network.rawId.equals(networkId, ignoreCase = true)
val isCurrency = currency.id.rawCurrencyId?.value?.equals(tokenId, ignoreCase = true) == true val isCurrency = currency.id.rawCurrencyId?.value?.equals(tokenId, ignoreCase = true) == true
val isDefaultDerivation = currency.network.derivationPath is Network.DerivationPath.Card val isDefaultDerivation = currency.network.derivationPath is Network.DerivationPath.Card

View file

@ -168,6 +168,6 @@ internal class TokenDetailsNotificationConverter(
// workaround for networks that users have misunderstanding // workaround for networks that users have misunderstanding
private fun CryptoCurrency.shouldMergeFeeNetworkName(): Boolean { private fun CryptoCurrency.shouldMergeFeeNetworkName(): Boolean {
return Blockchain.fromNetworkId(this.network.backendId) == Blockchain.Arbitrum return Blockchain.fromNetworkId(this.network.rawId) == Blockchain.Arbitrum
} }
} }

View file

@ -150,7 +150,7 @@ internal class TokenListAnalyticsSender @Inject constructor(
) { ) {
// for now send only for Polkadot ecosystem blockchains // for now send only for Polkadot ecosystem blockchains
// later dependency on Blockchain will be removed and use token name // later dependency on Blockchain will be removed and use token name
when (val blockchain = Blockchain.fromNetworkId(currencyStatus.currency.network.backendId)) { when (val blockchain = Blockchain.fromNetworkId(currencyStatus.currency.network.rawId)) {
Blockchain.Polkadot, Blockchain.Polkadot,
Blockchain.AlephZero, Blockchain.AlephZero,
Blockchain.Kusama, Blockchain.Kusama,

View file

@ -35,7 +35,7 @@ class YieldSupplyPromoBannerConverterTest {
tokenList = tokenList, tokenList = tokenList,
) )
val converter = YieldSupplyPromoBannerConverter( val converter = YieldSupplyPromoBannerConverter(
yieldModuleApyMap = mapOf("${token.network.backendId}_${token.contractAddress}" to BigDecimal("0.10")), yieldModuleApyMap = mapOf("${token.network.rawId}_${token.contractAddress}" to BigDecimal("0.10")),
shouldShowMainPromo = false, shouldShowMainPromo = false,
) )
@ -71,7 +71,7 @@ class YieldSupplyPromoBannerConverterTest {
tokenList = ungroupedTokenList(statusActive), tokenList = ungroupedTokenList(statusActive),
) )
val converter = YieldSupplyPromoBannerConverter( val converter = YieldSupplyPromoBannerConverter(
yieldModuleApyMap = mapOf("${token.network.backendId}_${token.contractAddress}" to BigDecimal("0.12")), yieldModuleApyMap = mapOf("${token.network.rawId}_${token.contractAddress}" to BigDecimal("0.12")),
shouldShowMainPromo = true, shouldShowMainPromo = true,
) )
@ -90,8 +90,8 @@ class YieldSupplyPromoBannerConverterTest {
val statusBig = createLoadedStatus(token = tokenBig, amount = BigDecimal("10.00"), isYieldActive = false) val statusBig = createLoadedStatus(token = tokenBig, amount = BigDecimal("10.00"), isYieldActive = false)
val apyMap = mapOf( val apyMap = mapOf(
"${tokenSmall.network.backendId}_${tokenSmall.contractAddress.lowercase()}" to BigDecimal("0.05"), "${tokenSmall.network.rawId}_${tokenSmall.contractAddress.lowercase()}" to BigDecimal("0.05"),
"${tokenBig.network.backendId}_${tokenBig.contractAddress.uppercase()}" to BigDecimal("0.15"), "${tokenBig.network.rawId}_${tokenBig.contractAddress.uppercase()}" to BigDecimal("0.15"),
) )
val params = TokenConverterParams.Wallet( val params = TokenConverterParams.Wallet(
@ -114,7 +114,7 @@ class YieldSupplyPromoBannerConverterTest {
val token = createToken(networkId = nonEvmId, rawId = nonEvmId, contract = "rAbC123") val token = createToken(networkId = nonEvmId, rawId = nonEvmId, contract = "rAbC123")
val status = createLoadedStatus(token = token, amount = BigDecimal("3"), isYieldActive = false) val status = createLoadedStatus(token = token, amount = BigDecimal("3"), isYieldActive = false)
val mismatchedKey = "${token.network.backendId}_${token.contractAddress.lowercase()}" val mismatchedKey = "${token.network.rawId}_${token.contractAddress.lowercase()}"
val apyMap = mapOf(mismatchedKey to BigDecimal("0.07")) val apyMap = mapOf(mismatchedKey to BigDecimal("0.07"))
val params = TokenConverterParams.Wallet( val params = TokenConverterParams.Wallet(
@ -140,7 +140,7 @@ class YieldSupplyPromoBannerConverterTest {
tokenList = ungroupedTokenList(status), tokenList = ungroupedTokenList(status),
) )
val converter = YieldSupplyPromoBannerConverter( val converter = YieldSupplyPromoBannerConverter(
yieldModuleApyMap = mapOf("${token.network.backendId}_${token.contractAddress}" to BigDecimal("0.10")), yieldModuleApyMap = mapOf("${token.network.rawId}_${token.contractAddress}" to BigDecimal("0.10")),
shouldShowMainPromo = true, shouldShowMainPromo = true,
) )

View file

@ -61,7 +61,7 @@ internal class YieldSupplyNotificationsModel @Inject constructor(
cryptoCurrencyWarning = cryptoCurrencyWarning, cryptoCurrencyWarning = cryptoCurrencyWarning,
cryptoCurrencyStatus = cryptoCurrencyStatus, cryptoCurrencyStatus = cryptoCurrencyStatus,
shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum( shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum(
blockchainId = cryptoCurrencyStatus.currency.network.backendId, networkId = cryptoCurrencyStatus.currency.network.rawId,
), ),
onClick = ::openTokenDetails, onClick = ::openTokenDetails,
onAnalyticsEvent = { /*no-op*/ }, onAnalyticsEvent = { /*no-op*/ },

View file

@ -37,103 +37,103 @@ object BlockchainUtils {
} }
/** If current [networkId] is Bitcoin */ /** If current [networkId] is Bitcoin */
fun isBitcoin(blockchainId: String): Boolean { fun isBitcoin(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Bitcoin || blockchain == Blockchain.BitcoinTestnet return blockchain == Blockchain.Bitcoin || blockchain == Blockchain.BitcoinTestnet
} }
/** If current [networkId] is use custom fee */ /** Checks if the current [blockchainId] uses a custom fee converter */
fun isUseBitcoinFeeConverter(blockchainId: String): Boolean { fun isUseBitcoinFeeConverter(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return isBitcoin(blockchainId) || blockchain == Blockchain.Fact0rn return isBitcoin(networkId) || blockchain == Blockchain.Fact0rn
} }
/** If current [blockchainId] is Tezos */ /** If current [networkId] is Tezos */
fun isTezos(blockchainId: String): Boolean { fun isTezos(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Tezos return blockchain == Blockchain.Tezos
} }
fun isCardano(blockchainId: String): Boolean { fun isCardano(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Cardano return blockchain == Blockchain.Cardano
} }
/** If current [blockchainId] is BeaconChain */ /** If current [networkId] is BeaconChain */
fun isBeaconChain(blockchainId: String): Boolean { fun isBeaconChain(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Binance || blockchain == Blockchain.BinanceTestnet return blockchain == Blockchain.Binance || blockchain == Blockchain.BinanceTestnet
} }
/** If current [blockchainId] is Polygon */ /** If current [networkId] is Polygon */
fun isPolygonChain(blockchainId: String): Boolean { fun isPolygonChain(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Polygon || blockchain == Blockchain.PolygonTestnet return blockchain == Blockchain.Polygon || blockchain == Blockchain.PolygonTestnet
} }
fun isTron(blockchainId: String): Boolean { fun isTron(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Tron || blockchain == Blockchain.TronTestnet return blockchain == Blockchain.Tron || blockchain == Blockchain.TronTestnet
} }
fun isTon(blockchainId: String): Boolean { fun isTon(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.TON || blockchain == Blockchain.TONTestnet return blockchain == Blockchain.TON || blockchain == Blockchain.TONTestnet
} }
fun isSupportedNetworkId( fun isSupportedNetworkId(
blockchainId: String, networkId: String,
excludedBlockchains: ExcludedBlockchains, excludedBlockchains: ExcludedBlockchains,
hotExcludedBlockchains: Set<Blockchain>, hotExcludedBlockchains: Set<Blockchain>,
hasOnlyHotWallets: Boolean = false, hasOnlyHotWallets: Boolean = false,
coinId: String? = null, coinId: String? = null,
contractAddress: String? = null, contractAddress: String? = null,
): Boolean { ): Boolean {
val blockchain = blockchainId.toBlockchain() ?: return false val blockchain = networkId.toBlockchain() ?: return false
if (blockchain in excludedBlockchains) return false if (blockchain in excludedBlockchains) return false
if (hasOnlyHotWallets && blockchain in hotExcludedBlockchains) return false if (hasOnlyHotWallets && blockchain in hotExcludedBlockchains) return false
if (!contractAddress.isNullOrEmpty()) { if (!contractAddress.isNullOrEmpty()) {
if (!blockchain.canHandleTokens()) return false if (!blockchain.canHandleTokens()) return false
if (coinId != null && !isNotBlockedByTerraV1Filter(blockchainId, coinId)) return false if (coinId != null && !isNotBlockedByTerraV1Filter(networkId, coinId)) return false
} }
return true return true
} }
fun isArbitrum(blockchainId: String): Boolean { fun isArbitrum(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Arbitrum return blockchain == Blockchain.Arbitrum
} }
fun isSolana(blockchainId: String): Boolean { fun isSolana(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Solana return blockchain == Blockchain.Solana
} }
fun isPolkadot(blockchainId: String): Boolean { fun isPolkadot(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Polkadot || blockchain == Blockchain.PolkadotTestnet return blockchain == Blockchain.Polkadot || blockchain == Blockchain.PolkadotTestnet
} }
fun isCosmos(blockchainId: String): Boolean { fun isCosmos(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Cosmos || blockchain == Blockchain.CosmosTestnet return blockchain == Blockchain.Cosmos || blockchain == Blockchain.CosmosTestnet
} }
fun isBSC(blockchainId: String): Boolean { fun isBSC(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.BSC || blockchain == Blockchain.BSCTestnet return blockchain == Blockchain.BSC || blockchain == Blockchain.BSCTestnet
} }
fun isEthereum(blockchainId: String): Boolean { fun isEthereum(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain == Blockchain.Ethereum || blockchain == Blockchain.EthereumTestnet return blockchain == Blockchain.Ethereum || blockchain == Blockchain.EthereumTestnet
} }
fun isClore(blockchainId: String): Boolean { fun isClore(networkId: String): Boolean {
return blockchainId.toBlockchain() == Blockchain.Clore return networkId.toBlockchain() == Blockchain.Clore
} }
data class BlockchainInfo( data class BlockchainInfo(
@ -162,29 +162,29 @@ object BlockchainUtils {
/** /**
* Blockchains not affecting total balance counting on errors * Blockchains not affecting total balance counting on errors
*/ */
fun isIncludeToBalanceOnError(blockchainId: String): Boolean { fun isIncludeToBalanceOnError(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return when (blockchain) { return when (blockchain) {
Blockchain.Binance, Blockchain.BinanceTestnet -> true Blockchain.Binance, Blockchain.BinanceTestnet -> true
else -> false else -> false
} }
} }
fun isIncludeStakingTotalBalance(blockchainId: String): Boolean { fun isIncludeStakingTotalBalance(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain != Blockchain.Cardano return blockchain != Blockchain.Cardano
} }
fun isStakingRewardUnavailable(blockchainId: String, isCoin: Boolean): Boolean { fun isStakingRewardUnavailable(networkId: String, isCoin: Boolean): Boolean {
val isP2PEthPool = isEthereum(blockchainId) && isCoin val isP2PEthPool = isEthereum(networkId) && isCoin
return isSolana(blockchainId) || isBSC(blockchainId) || isTon(blockchainId) || isP2PEthPool return isSolana(networkId) || isBSC(networkId) || isTon(networkId) || isP2PEthPool
} }
/** Checks if the blockchain uses case-insensitive contract addresses */ /** Checks if the blockchain uses case-insensitive contract addresses */
fun isCaseInsensitiveContractAddress(blockchainId: String): Boolean { fun isCaseInsensitiveContractAddress(networkId: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return blockchain?.isEvm() == true return blockchain?.isEvm() == true
} }
@ -222,8 +222,8 @@ object BlockchainUtils {
/** /**
* Checks if the given coin is Tether on Ethereum network, which may require special handling in some cases. * Checks if the given coin is Tether on Ethereum network, which may require special handling in some cases.
*/ */
fun isTetherInEthereum(blockchainId: String, contractAddress: String): Boolean { fun isTetherInEthereum(networkId: String, contractAddress: String): Boolean {
val blockchain = blockchainId.toBlockchain() val blockchain = networkId.toBlockchain()
return (blockchain == Blockchain.Ethereum || blockchain == Blockchain.EthereumTestnet) && return (blockchain == Blockchain.Ethereum || blockchain == Blockchain.EthereumTestnet) &&
contractAddress.equals(TETHER_CONTRACT_ADDRESS, ignoreCase = true) contractAddress.equals(TETHER_CONTRACT_ADDRESS, ignoreCase = true)
} }