Updated on 2026-08-14
This commit is contained in:
parent
799a38655e
commit
4570bc334c
54 changed files with 178 additions and 183 deletions
|
|
@ -188,7 +188,7 @@ internal class DefaultRampManager(
|
|||
|
||||
private fun CryptoCurrency.findAssetPredicate(assetId: ExpressAsset.ID): Boolean {
|
||||
val currencyAssedId = ExpressAsset.ID(
|
||||
networkId = this.network.backendId,
|
||||
networkId = this.network.rawId,
|
||||
contractAddress = (this as? CryptoCurrency.Token)?.contractAddress,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ fun StakingBalance.Data.getTotalStakingBalance(blockchainId: String): BigDecimal
|
|||
* StakeKit-specific extension to get total balance including rewards.
|
||||
*/
|
||||
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 }
|
||||
} else {
|
||||
getRewardStakingBalance()
|
||||
|
|
@ -58,7 +58,7 @@ private fun StakingBalance.Data.StakeKit.getTotalWithRewardsStakingBalanceStakeK
|
|||
* StakeKit-specific extension to get total staked balance excluding rewards.
|
||||
*/
|
||||
private fun StakingBalance.Data.StakeKit.getTotalStakingBalanceStakeKit(blockchainId: String): BigDecimal {
|
||||
return if (BlockchainUtils.isIncludeStakingTotalBalance(blockchainId = blockchainId)) {
|
||||
return if (BlockchainUtils.isIncludeStakingTotalBalance(networkId = blockchainId)) {
|
||||
balance.items
|
||||
.filterNot { it.type == BalanceType.REWARDS }
|
||||
.sumOf { it.amount }
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ class CryptoCurrencyFactory(
|
|||
id = cryptoCurrency.id.rawCurrencyId?.value,
|
||||
)
|
||||
val blockchain =
|
||||
Blockchain.fromNetworkId(cryptoCurrency.network.backendId) ?: Blockchain.Unknown
|
||||
Blockchain.fromNetworkId(cryptoCurrency.network.rawId) ?: Blockchain.Unknown
|
||||
val id = getTokenId(network, sdkToken)
|
||||
return CryptoCurrency.Token(
|
||||
id = id,
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ internal class DefaultCardCryptoCurrencyFactory(
|
|||
|
||||
// check if the blockchain of single-currency wallet is the same as network
|
||||
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()
|
||||
|
||||
|
|
@ -145,7 +145,7 @@ internal class DefaultCardCryptoCurrencyFactory(
|
|||
responseCryptoCurrenciesFactory.createCurrencies(
|
||||
tokens = accountDTO.tokens.orEmpty().filter { token ->
|
||||
networks.any {
|
||||
it.backendId == token.networkId && it.derivationPath.value == token.derivationPath
|
||||
it.rawId == token.networkId && it.derivationPath.value == token.derivationPath
|
||||
}
|
||||
},
|
||||
userWallet = userWallet,
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class UserTokensResponseFactory @Inject constructor() {
|
|||
UserTokensResponse.Token(
|
||||
id = id.rawCurrencyId?.value,
|
||||
accountId = accountId?.value,
|
||||
networkId = network.backendId,
|
||||
networkId = network.rawId,
|
||||
derivationPath = network.derivationPath.value,
|
||||
name = name,
|
||||
symbol = symbol,
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ internal class DefaultDynamicAddressesRepository(
|
|||
.flatMap { it.tokens.orEmpty() }
|
||||
.any { token ->
|
||||
val tokenDerivationPath = token.derivationPath ?: return@any false
|
||||
token.networkId == network.backendId &&
|
||||
token.networkId == network.rawId &&
|
||||
tokenDerivationPath != baseDerivationPath &&
|
||||
hasNonZeroChangeOrIndex(tokenDerivationPath, baseDerivationPath)
|
||||
}
|
||||
|
|
@ -151,7 +151,7 @@ internal class DefaultDynamicAddressesRepository(
|
|||
}
|
||||
|
||||
private fun UserTokensResponse.Token.matchesNetwork(network: Network): Boolean {
|
||||
return networkId == network.backendId &&
|
||||
return networkId == network.rawId &&
|
||||
derivationPath == network.derivationPath.value &&
|
||||
contractAddress == null
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ internal class DefaultCustomTokensRepository(
|
|||
|
||||
val response = tangemTechApi.getCoins(
|
||||
contractAddress = contractAddress,
|
||||
networkIds = network.backendId,
|
||||
networkIds = network.rawId,
|
||||
active = true,
|
||||
).getOrThrow()
|
||||
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ internal class SimpleNetworkStatusConverterTest {
|
|||
),
|
||||
expected = SimpleNetworkStatus(
|
||||
id = Network.ID(
|
||||
value = network.backendId,
|
||||
value = network.rawId,
|
||||
derivationPath = Network.DerivationPath.Card("card"),
|
||||
),
|
||||
value = NetworkStatus.Verified(
|
||||
|
|
@ -138,7 +138,7 @@ internal class SimpleNetworkStatusConverterTest {
|
|||
),
|
||||
expected = SimpleNetworkStatus(
|
||||
id = Network.ID(
|
||||
value = network.backendId,
|
||||
value = network.rawId,
|
||||
derivationPath = Network.DerivationPath.Card("card"),
|
||||
),
|
||||
value = NetworkStatus.NoAccount(
|
||||
|
|
|
|||
|
|
@ -568,7 +568,7 @@ internal class DefaultNFTRepository @Inject constructor(
|
|||
|
||||
private fun Network.canHandleNFTs(userWalletId: UserWalletId): Boolean {
|
||||
val userWallet = userWalletsListRepository.getSyncStrict(userWalletId)
|
||||
val blockchain = Blockchain.fromNetworkId(backendId) ?: return false
|
||||
val blockchain = Blockchain.fromNetworkId(rawId) ?: return false
|
||||
|
||||
return blockchain.canHandleNFTs() &&
|
||||
userWallet.canHandleToken(blockchain, excludedBlockchains)
|
||||
|
|
|
|||
|
|
@ -249,7 +249,7 @@ internal class DefaultOnrampRepository(
|
|||
to = listOf(
|
||||
OnrampDestinationDTO(
|
||||
contractAddress = cryptoCurrency.getContractAddress(),
|
||||
network = cryptoCurrency.network.backendId,
|
||||
network = cryptoCurrency.network.rawId,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -314,7 +314,7 @@ internal class DefaultOnrampRepository(
|
|||
to = listOf(
|
||||
OnrampDestinationDTO(
|
||||
contractAddress = cryptoCurrency.getContractAddress(),
|
||||
network = cryptoCurrency.network.backendId,
|
||||
network = cryptoCurrency.network.rawId,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
@ -363,7 +363,7 @@ internal class DefaultOnrampRepository(
|
|||
fromCurrencyCode = currency.code,
|
||||
fromPrecision = currency.precision,
|
||||
toContractAddress = cryptoCurrency.getContractAddress(),
|
||||
toNetwork = cryptoCurrency.network.backendId,
|
||||
toNetwork = cryptoCurrency.network.rawId,
|
||||
paymentMethod = paymentMethod.id,
|
||||
countryCode = country.code,
|
||||
fromAmount = fromAmount,
|
||||
|
|
@ -436,7 +436,7 @@ internal class DefaultOnrampRepository(
|
|||
fromCurrencyCode = currency.code,
|
||||
fromPrecision = currency.precision,
|
||||
toContractAddress = cryptoCurrency.getContractAddress(),
|
||||
toNetwork = cryptoCurrency.network.backendId,
|
||||
toNetwork = cryptoCurrency.network.rawId,
|
||||
paymentMethod = quote.paymentMethod.id,
|
||||
countryCode = country.code,
|
||||
fromAmount = fromAmountString,
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ internal class DefaultQrScanningEventsRepositoryTest {
|
|||
@Test
|
||||
fun testBip021() {
|
||||
every { network.id } returns Network.ID(value = "bitcoin", derivationPath = Network.DerivationPath.None)
|
||||
every { network.backendId } returns "bitcoin"
|
||||
every { network.rawId } returns "bitcoin"
|
||||
positiveCase(
|
||||
"$schema1:$address1",
|
||||
QrResult(address = address1),
|
||||
|
|
@ -129,7 +129,7 @@ internal class DefaultQrScanningEventsRepositoryTest {
|
|||
@Test
|
||||
fun testErc681Coin() {
|
||||
every { network.id } returns Network.ID(value = "ethereum", derivationPath = Network.DerivationPath.None)
|
||||
every { network.backendId } returns "ethereum"
|
||||
every { network.rawId } returns "ethereum"
|
||||
positiveCase(
|
||||
address2,
|
||||
QrResult(address = address2),
|
||||
|
|
@ -185,7 +185,7 @@ internal class DefaultQrScanningEventsRepositoryTest {
|
|||
@Test
|
||||
fun testErc681Token() {
|
||||
every { network.id } returns Network.ID(value = "ethereum", derivationPath = Network.DerivationPath.None)
|
||||
every { network.backendId } returns "ethereum"
|
||||
every { network.rawId } returns "ethereum"
|
||||
positiveCase(
|
||||
address2,
|
||||
QrResult(address = address2),
|
||||
|
|
|
|||
|
|
@ -411,7 +411,7 @@ internal class DefaultStakeKitRepository(
|
|||
}
|
||||
|
||||
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) {
|
||||
TronResource.ENERGY
|
||||
|
|
|
|||
|
|
@ -91,12 +91,12 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
|
|||
val statusFrom = cryptoCurrencyStatusList
|
||||
.firstOrNull { currencyStatus ->
|
||||
currencyStatus.currency.getContractAddress() == pair.from.contractAddress &&
|
||||
currencyStatus.currency.network.backendId == pair.from.network
|
||||
currencyStatus.currency.network.rawId == pair.from.network
|
||||
}
|
||||
val statusTo = cryptoCurrencyStatusList
|
||||
.firstOrNull { currencyStatus ->
|
||||
currencyStatus.currency.getContractAddress() == pair.to.contractAddress &&
|
||||
currencyStatus.currency.network.backendId == pair.to.network
|
||||
currencyStatus.currency.network.rawId == pair.to.network
|
||||
}
|
||||
|
||||
val mappedProviders = pair.providers
|
||||
|
|
@ -143,14 +143,14 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
|
|||
cryptoCurrencyList
|
||||
.firstOrNull { currency ->
|
||||
currency.getContractAddress() == pair.from.contractAddress &&
|
||||
currency.network.backendId == pair.from.network
|
||||
currency.network.rawId == pair.from.network
|
||||
}
|
||||
}
|
||||
val statusToDeferred = async {
|
||||
cryptoCurrencyList
|
||||
.firstOrNull { currency ->
|
||||
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 {
|
||||
null
|
||||
},
|
||||
fromNetwork = fromCryptoCurrency.network.backendId,
|
||||
fromNetwork = fromCryptoCurrency.network.rawId,
|
||||
fromContractAddress = fromCryptoCurrency.getContractAddress(),
|
||||
fromDecimals = fromCryptoCurrency.decimals,
|
||||
toNetwork = toCryptoCurrency.network.backendId,
|
||||
toNetwork = toCryptoCurrency.network.rawId,
|
||||
toContractAddress = toCryptoCurrency.getContractAddress(),
|
||||
toDecimals = toCryptoCurrency.decimals,
|
||||
providerId = provider.providerId,
|
||||
|
|
@ -255,8 +255,8 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
|
|||
val response = tangemExpressApi.getExchangeData(
|
||||
fromContractAddress = fromCurrency.getContractAddress(),
|
||||
toContractAddress = toCryptoCurrency.getContractAddress(),
|
||||
fromNetwork = fromCurrency.network.backendId,
|
||||
toNetwork = toCryptoCurrency.network.backendId,
|
||||
fromNetwork = fromCurrency.network.rawId,
|
||||
toNetwork = toCryptoCurrency.network.rawId,
|
||||
fromAddress = fromStatus.networkAddress?.defaultAddress?.value.orEmpty(),
|
||||
toAddress = toAddress,
|
||||
fromDecimals = fromCurrency.decimals,
|
||||
|
|
@ -316,7 +316,7 @@ internal class DefaultSwapRepositoryV2 @Inject constructor(
|
|||
),
|
||||
body = ExchangeSentRequestBody(
|
||||
txId = txId,
|
||||
fromNetwork = currency.network.backendId,
|
||||
fromNetwork = currency.network.rawId,
|
||||
fromAddress = status.networkAddress?.defaultAddress?.value.orEmpty(),
|
||||
payinAddress = payInAddress,
|
||||
payinExtraId = txExtraId,
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class TokenInfoConverter : Converter<CryptoCurrency, LeastTokenInfo> {
|
|||
override fun convert(value: CryptoCurrency): LeastTokenInfo {
|
||||
return LeastTokenInfo(
|
||||
contractAddress = (value as? CryptoCurrency.Token)?.contractAddress ?: "0",
|
||||
network = value.network.backendId,
|
||||
network = value.network.rawId,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ internal class DefaultCurrenciesRepository(
|
|||
}
|
||||
|
||||
override fun isNetworkFeeZero(userWalletId: UserWalletId, network: Network): Boolean {
|
||||
val blockchain = Blockchain.fromNetworkId(network.backendId)
|
||||
val blockchain = Blockchain.fromNetworkId(network.rawId)
|
||||
return blockchain?.isNetworkFeeZero() == true
|
||||
}
|
||||
}
|
||||
|
|
@ -183,7 +183,7 @@ internal class DefaultTokenSyncRepository(
|
|||
|
||||
if (tokenBalances.isEmpty()) {
|
||||
return NetworkResult.Success(
|
||||
networkId = network.backendId,
|
||||
networkId = network.rawId,
|
||||
responseTokens = emptyList(),
|
||||
)
|
||||
}
|
||||
|
|
@ -195,11 +195,11 @@ internal class DefaultTokenSyncRepository(
|
|||
.map { it.toResponseToken() }
|
||||
|
||||
NetworkResult.Success(
|
||||
networkId = network.backendId,
|
||||
networkId = network.rawId,
|
||||
responseTokens = responseTokens,
|
||||
)
|
||||
} 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 catalogMap = fetchCatalogInfo(
|
||||
networkId = network.backendId,
|
||||
networkId = network.rawId,
|
||||
contractAddresses = tokensToEnrich.mapNotNull(TokenBalance::contractAddress),
|
||||
)
|
||||
|
||||
|
|
@ -240,7 +240,7 @@ internal class DefaultTokenSyncRepository(
|
|||
amount = balance.amount,
|
||||
isNativeToken = false,
|
||||
currencyId = coin.id,
|
||||
networkId = network.backendId,
|
||||
networkId = network.rawId,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ internal class DefaultAllowanceRepository(
|
|||
allowance >= requiredAmount -> AllowanceInfo.Enough(allowance)
|
||||
allowance > BigDecimal.ZERO && allowance < requiredAmount &&
|
||||
BlockchainUtils.isTetherInEthereum(
|
||||
blockchainId = cryptoCurrency.network.rawId,
|
||||
networkId = cryptoCurrency.network.rawId,
|
||||
contractAddress = cryptoCurrency.contractAddress,
|
||||
) -> AllowanceInfo.ResetNeeded(allowance, requiredAmount)
|
||||
else -> AllowanceInfo.NotEnough(allowance, requiredAmount)
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ internal class DefaultTransactionRepository(
|
|||
nonce: BigInteger?,
|
||||
gasLimit: BigInteger?,
|
||||
): TransactionExtras {
|
||||
val blockchain = Blockchain.fromNetworkId(networkId = network.backendId)
|
||||
val blockchain = Blockchain.fromNetworkId(networkId = network.rawId)
|
||||
?: error("Blockchain not found")
|
||||
return when {
|
||||
blockchain.isEvm() -> {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ internal object BlockAidChainNameConverter : Converter<Network, String?> {
|
|||
|
||||
@Suppress("CyclomaticComplexMethod")
|
||||
override fun convert(value: Network): String? {
|
||||
return when (Blockchain.fromNetworkId(value.backendId)) {
|
||||
return when (Blockchain.fromNetworkId(value.rawId)) {
|
||||
Blockchain.Arbitrum -> "arbitrum"
|
||||
Blockchain.Avalanche -> "avalanche"
|
||||
Blockchain.AvalancheTestnet -> "avalanche-fuji"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ internal class DefaultYieldSupplyRepository(
|
|||
|
||||
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 domain = cache.map(YieldMarketTokenConverter::convert)
|
||||
domain.enrichNetworkIds()
|
||||
|
|
@ -62,14 +62,14 @@ internal class DefaultYieldSupplyRepository(
|
|||
}
|
||||
|
||||
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")
|
||||
val response = yieldSupplyApi.getYieldTokenStatus(chainId, cryptoCurrencyToken.contractAddress).getOrThrow()
|
||||
return YieldMarketTokenConverter.convert(response)
|
||||
}
|
||||
|
||||
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")
|
||||
val response = yieldSupplyApi.getYieldTokenChart(chainId, cryptoCurrencyToken.contractAddress).getOrThrow()
|
||||
return YieldTokenChartConverter.convert(response)
|
||||
|
|
@ -99,7 +99,7 @@ internal class DefaultYieldSupplyRepository(
|
|||
cryptoCurrencyToken: CryptoCurrency.Token,
|
||||
address: String,
|
||||
): 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")
|
||||
yieldSupplyApi.activateYieldModule(
|
||||
body = YieldSupplyChangeTokenStatusBody(
|
||||
|
|
@ -113,7 +113,7 @@ internal class DefaultYieldSupplyRepository(
|
|||
|
||||
override suspend fun deactivateProtocol(cryptoCurrencyToken: CryptoCurrency.Token, address: String): 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")
|
||||
yieldSupplyApi.deactivateYieldModule(
|
||||
YieldSupplyChangeTokenStatusBody(
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class DefaultYieldSupplyTransactionRepositoryTest {
|
|||
private val userWalletId = mockk<UserWalletId>()
|
||||
private val cryptoCurrency = mockk<CryptoCurrency.Token>(relaxed = true) {
|
||||
every { network.id } returns networkId
|
||||
every { network.backendId } returns networkId.rawId.value
|
||||
every { network.rawId } returns networkId.rawId.value
|
||||
every { contractAddress } returns mockedContractAddress
|
||||
}
|
||||
private val cryptoCurrencyStatus = mockk<CryptoCurrencyStatus>(relaxed = true) {
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ class ArchiveCryptoPortfolioUseCase(
|
|||
val hasNotReferralToken = statuses.none { status ->
|
||||
val currency = status.currency
|
||||
|
||||
currency.network.backendId == referralToken.networkId &&
|
||||
currency.network.rawId == referralToken.networkId &&
|
||||
(currency as? CryptoCurrency.Token)?.contractAddress == referralToken.contractAddress &&
|
||||
status.value.networkAddress?.availableAddresses?.any { it.value == address } == true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ class ManageCryptoCurrenciesUseCase(
|
|||
val foundToken = accountStatus.tokenList.flattenCurrencies()
|
||||
.mapNotNull { it.currency as? CryptoCurrency.Token }
|
||||
.firstOrNull { token ->
|
||||
token.network.backendId == networkId &&
|
||||
token.network.rawId == networkId &&
|
||||
!token.isCustom &&
|
||||
token.contractAddress.equals(contractAddress, true)
|
||||
}
|
||||
|
|
@ -361,7 +361,7 @@ class ManageCryptoCurrenciesUseCase(
|
|||
launch {
|
||||
val assetIds = currencies.mapTo(hashSetOf()) { currency ->
|
||||
ExpressAsset.ID(
|
||||
networkId = currency.network.backendId,
|
||||
networkId = currency.network.rawId,
|
||||
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress,
|
||||
)
|
||||
}
|
||||
|
|
@ -388,19 +388,19 @@ class ManageCryptoCurrenciesUseCase(
|
|||
) {
|
||||
|
||||
constructor(network: Network) : this(
|
||||
networkId = network.backendId,
|
||||
networkId = network.rawId,
|
||||
derivationPath = network.derivationPath,
|
||||
contractAddress = null,
|
||||
)
|
||||
|
||||
constructor(currency: CryptoCurrency) : this(
|
||||
networkId = currency.network.backendId,
|
||||
networkId = currency.network.rawId,
|
||||
derivationPath = currency.network.derivationPath,
|
||||
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress,
|
||||
)
|
||||
|
||||
constructor(status: CryptoCurrencyStatus) : this(
|
||||
networkId = status.currency.network.backendId,
|
||||
networkId = status.currency.network.rawId,
|
||||
derivationPath = status.currency.network.derivationPath,
|
||||
contractAddress = (status.currency as? CryptoCurrency.Token)?.contractAddress,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ class ArchiveCryptoPortfolioUseCaseTest {
|
|||
val defaultAddress = "0xABC"
|
||||
|
||||
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!!
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class GetEarnNetworksUseCase(
|
|||
accountLists
|
||||
.filter { it.userWalletId in unlockedWalletsId }
|
||||
.flatMap(AccountList::flattenCurrencies)
|
||||
.mapTo(HashSet()) { it.network.backendId }
|
||||
.mapTo(HashSet()) { it.network.rawId }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@ package com.tangem.domain.models.currency
|
|||
import java.math.BigDecimal
|
||||
|
||||
fun CryptoCurrency.Token.yieldSupplyKey(): String {
|
||||
return "${network.backendId}_$contractAddress"
|
||||
return "${network.rawId}_$contractAddress"
|
||||
}
|
||||
|
||||
fun CryptoCurrencyStatus.hasNotSuppliedAmount(): Boolean {
|
||||
|
|
|
|||
|
|
@ -35,11 +35,6 @@ data class Network(
|
|||
val nameResolvingType: NameResolvingType,
|
||||
) {
|
||||
|
||||
/** Backend ID */
|
||||
@Deprecated("Will be removed later")
|
||||
val backendId: String
|
||||
get() = id.rawId.value
|
||||
|
||||
/** Raw ID */
|
||||
val rawId: String
|
||||
get() = id.rawId.value
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ class WalletBalanceFetcher internal constructor(
|
|||
private suspend fun fetchExpressAssets(userWallet: UserWallet, currencies: Set<CryptoCurrency>) {
|
||||
val assetIds = currencies.mapTo(hashSetOf()) { currency ->
|
||||
ExpressAsset.ID(
|
||||
networkId = currency.network.backendId,
|
||||
networkId = currency.network.rawId,
|
||||
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ class GetEthSpecificFeeUseCase(
|
|||
?: (walletManager as? EthereumWalletManager)?.getGasPriceValue()
|
||||
?: error("not supported for ${cryptoCurrency.network}")
|
||||
|
||||
val blockchain = Blockchain.fromNetworkId(networkId = cryptoCurrency.network.backendId)
|
||||
?: error("unknown networkId ${cryptoCurrency.network.backendId}")
|
||||
val blockchain = Blockchain.fromNetworkId(networkId = cryptoCurrency.network.rawId)
|
||||
?: error("unknown networkId ${cryptoCurrency.network.rawId}")
|
||||
|
||||
val minimalFee = getEthLegacyFee(
|
||||
gasPrice = gasPriceResult,
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@ data class AvailableToAddAccount(
|
|||
get() = availableNetworks.size == 1
|
||||
|
||||
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()
|
||||
|
||||
val isAvailableToAdd: Boolean = availableToAddNetworks.isNotEmpty()
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -526,7 +526,7 @@ internal class MarketsTokenDetailsModel @Inject constructor(
|
|||
|
||||
val networks = newInfo.networks?.filter { network ->
|
||||
BlockchainUtils.isSupportedNetworkId(
|
||||
blockchainId = network.networkId,
|
||||
networkId = network.networkId,
|
||||
excludedBlockchains = excludedBlockchains,
|
||||
hotExcludedBlockchains = hotWalletExcludedBlockchains,
|
||||
hasOnlyHotWallets = isAllWalletsIsHot,
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ internal class CustomTokenFormModel @Inject constructor(
|
|||
) = modelScope.launch {
|
||||
val isNeedColdWalletInteraction = coldWalletAndHasMissedDerivationsUseCase.invoke(
|
||||
userWalletId = params.mode.userWalletId,
|
||||
networksWithDerivationPath = mapOf(currency.network.backendId to getDerivationPath().value),
|
||||
networksWithDerivationPath = mapOf(currency.network.rawId to getDerivationPath().value),
|
||||
)
|
||||
|
||||
state.update { state ->
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ internal class ManageTokensModel @Inject constructor(
|
|||
val networks = currenciesToAdd.values
|
||||
.flatten()
|
||||
.toSet()
|
||||
.associate { network -> network.backendId to network.derivationPath.value }
|
||||
.associate { network -> network.rawId to network.derivationPath.value }
|
||||
val isNeedToInteractWithColdWallet = useCasesFacade.needColdWalletInteraction(networks)
|
||||
|
||||
state.update { state ->
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ internal class OnboardingManageTokensModel @Inject constructor(
|
|||
val network = currenciesToAdd.values
|
||||
.flatten()
|
||||
.toSet()
|
||||
.associate { network -> network.backendId to network.derivationPath.value }
|
||||
.associate { network -> network.rawId to network.derivationPath.value }
|
||||
val shouldShowTangemIcon = useCasesFacade.needColdWalletInteraction(network = network)
|
||||
state.update { state ->
|
||||
state.copy(
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ internal class CustomTokenFormUseCasesFacade @AssistedInject constructor(
|
|||
|
||||
private fun CryptoCurrency.getAccountIndex(): Either<Throwable, Int> = either {
|
||||
val currency = this@getAccountIndex
|
||||
val blockchain = Blockchain.fromNetworkId(networkId = currency.network.backendId)
|
||||
val blockchain = Blockchain.fromNetworkId(networkId = currency.network.rawId)
|
||||
if (blockchain == null) {
|
||||
val exception = IllegalStateException("Token has unknown networkId: ${currency.id}")
|
||||
TangemLogger.e("Error", exception)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ internal class ManageTokensUseCasesFacade @AssistedInject constructor(
|
|||
?: return IllegalStateException("Account not found").left()
|
||||
|
||||
(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
|
||||
}
|
||||
.right()
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ internal class OnrampAddTokenModel @Inject constructor(
|
|||
.distinctUntilChanged()
|
||||
.mapLatest { tokenToAdd: AddHotCryptoData ->
|
||||
addTokenJob.join()
|
||||
val backendId = tokenToAdd.cryptoCurrency.network.backendId
|
||||
val backendId = tokenToAdd.cryptoCurrency.network.rawId
|
||||
val userWalletId = tokenToAdd.account.accountId.userWalletId
|
||||
val isTangemIconVisible = needColdWalletInteraction(
|
||||
walletId = userWalletId,
|
||||
|
|
|
|||
|
|
@ -252,7 +252,7 @@ internal class AvailableSwapPairsModel @Inject constructor(
|
|||
is AccountStatus.CryptoPortfolio -> {
|
||||
val statuses = accountStatus.tokenList.flattenCurrencies()
|
||||
.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
|
||||
}
|
||||
.filterByQuery(query = query)
|
||||
|
|
@ -462,7 +462,7 @@ internal class AvailableSwapPairsModel @Inject constructor(
|
|||
private fun CryptoCurrencyStatus.toLeastTokenInfo(): LeastTokenInfo {
|
||||
return LeastTokenInfo(
|
||||
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 ->
|
||||
BlockchainUtils.isSupportedNetworkId(
|
||||
blockchainId = network.networkId,
|
||||
networkId = network.networkId,
|
||||
coinId = tokenMarket.id.value,
|
||||
contractAddress = network.contractAddress,
|
||||
excludedBlockchains = excludedBlockchains,
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ internal class NotificationsModel @Inject constructor(
|
|||
addExceedsBalanceNotification(
|
||||
cryptoCurrencyWarning = currencyWarning,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum(currency.network.backendId),
|
||||
shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum(currency.network.rawId),
|
||||
onClick = ::showTokenDetails,
|
||||
onAnalyticsEvent = {
|
||||
val event = NotificationsAnalyticEvents.NoticeNotEnoughFee(
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ internal class DefaultStakingDeepLinkHandler @AssistedInject constructor(
|
|||
)
|
||||
.orEmpty()
|
||||
.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
|
||||
isNetwork && isCurrency
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ internal class StakingBalanceEntryConverter(
|
|||
|
||||
private fun StakingBalanceEntry.getBalanceValue(): BigDecimal {
|
||||
val isIncludeStakingTotalBalance = BlockchainUtils.isIncludeStakingTotalBalance(
|
||||
blockchainId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
networkId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
)
|
||||
return if (isIncludeStakingTotalBalance) {
|
||||
amount
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ internal class AddStakingNotificationsTransformer(
|
|||
addExceedsBalanceNotification(
|
||||
cryptoCurrencyWarning = currencyWarning,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum(network.backendId),
|
||||
shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum(network.rawId),
|
||||
onClick = prevState.clickIntents::openTokenDetails,
|
||||
onAnalyticsEvent = { prevState.clickIntents.onNotEnoughFeeNotificationShow() },
|
||||
onResetAnalyticsEvent = { /*no-op*/ },
|
||||
|
|
@ -315,7 +315,7 @@ internal class AddStakingNotificationsTransformer(
|
|||
currencyName = name,
|
||||
feeName = name,
|
||||
feeSymbol = symbol,
|
||||
mergeFeeNetworkName = BlockchainUtils.isArbitrum(network.backendId),
|
||||
mergeFeeNetworkName = BlockchainUtils.isArbitrum(network.rawId),
|
||||
onClick = { onClick(this) },
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ internal class SwapChooseContentStateTransformer(
|
|||
|
||||
val isMain = cryptoCurrency is CryptoCurrency.Coin
|
||||
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
|
||||
network.standardType !is Network.StandardType.Unspecified -> network.standardType.name
|
||||
else -> ""
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ class LeastTokenInfoConverter : Converter<CryptoCurrency, LeastTokenInfo> {
|
|||
override fun convert(value: CryptoCurrency): LeastTokenInfo {
|
||||
return LeastTokenInfo(
|
||||
contractAddress = (value as? CryptoCurrency.Token)?.contractAddress ?: "0",
|
||||
network = value.network.backendId,
|
||||
network = value.network.rawId,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -162,7 +162,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
userWallet = userWallet,
|
||||
initialCurrency = LeastTokenInfo(
|
||||
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress ?: "0",
|
||||
network = currency.network.backendId,
|
||||
network = currency.network.rawId,
|
||||
),
|
||||
currenciesList = walletAccountCurrencyStatusesExceptInitial.flatMap { accountStatus ->
|
||||
accountStatus.value.map { it.currency }
|
||||
|
|
@ -199,7 +199,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
}
|
||||
|
||||
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()
|
||||
|
||||
val hasValidStatus =
|
||||
|
|
@ -218,7 +218,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
): CurrenciesGroup {
|
||||
val filteredPairs = leastPairs.filter { pair ->
|
||||
tokenInfoForFilter(pair).contractAddress == currency.getContractAddress() &&
|
||||
tokenInfoForFilter(pair).network == currency.network.backendId
|
||||
tokenInfoForFilter(pair).network == currency.network.rawId
|
||||
}
|
||||
|
||||
val accountCurrencyList = cryptoCurrenciesList.map { (accountEntry, currencyStatusList) ->
|
||||
|
|
@ -259,7 +259,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
|
||||
return swapPairsLeastList.firstNotNullOfOrNull { pair ->
|
||||
val listTokenInfo = tokenInfoForAvailable(pair)
|
||||
if (cryptoCurrencyStatuses.currency.network.backendId == listTokenInfo.network &&
|
||||
if (cryptoCurrencyStatuses.currency.network.rawId == listTokenInfo.network &&
|
||||
cryptoCurrencyStatuses.currency.getContractAddress() == listTokenInfo.contractAddress &&
|
||||
isAvailableForSwap
|
||||
) {
|
||||
|
|
@ -359,7 +359,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
is Account.Payment -> true
|
||||
else -> isBalanceEnough(fromToken, amount, null)
|
||||
}
|
||||
val networkId = fromToken.currency.network.backendId
|
||||
val networkId = fromToken.currency.network.rawId
|
||||
|
||||
return supervisorScope {
|
||||
providers.map { provider ->
|
||||
|
|
@ -453,9 +453,9 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
val maybeQuotes = repository.findBestQuote(
|
||||
userWallet = userWallet,
|
||||
fromContractAddress = fromToken.currency.getContractAddress(),
|
||||
fromNetwork = fromToken.currency.network.backendId,
|
||||
fromNetwork = fromToken.currency.network.rawId,
|
||||
toContractAddress = toToken.currency.getContractAddress(),
|
||||
toNetwork = toToken.currency.network.backendId,
|
||||
toNetwork = toToken.currency.network.rawId,
|
||||
fromAmount = amount.toStringWithRightOffset(),
|
||||
fromDecimals = amount.decimals,
|
||||
toDecimals = toToken.currency.decimals,
|
||||
|
|
@ -527,9 +527,9 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
val maybeQuotes = repository.findBestQuote(
|
||||
userWallet = userWallet,
|
||||
fromContractAddress = fromToken.currency.getContractAddress(),
|
||||
fromNetwork = fromToken.currency.network.backendId,
|
||||
fromNetwork = fromToken.currency.network.rawId,
|
||||
toContractAddress = toToken.currency.getContractAddress(),
|
||||
toNetwork = toToken.currency.network.backendId,
|
||||
toNetwork = toToken.currency.network.rawId,
|
||||
fromAmount = amount.toStringWithRightOffset(),
|
||||
fromDecimals = amount.decimals,
|
||||
toDecimals = toToken.currency.decimals,
|
||||
|
|
@ -672,7 +672,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
FeePaidCurrency.Coin -> {
|
||||
val nativeBalance = walletManagersFacade.getNativeTokenBalance(
|
||||
userWalletId = userWalletId,
|
||||
networkId = fromTokenStatus.currency.network.backendId,
|
||||
networkId = fromTokenStatus.currency.network.rawId,
|
||||
derivationPath = fromTokenStatus.currency.network.derivationPath.value,
|
||||
)
|
||||
|
||||
|
|
@ -780,7 +780,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
)
|
||||
}
|
||||
ExchangeProviderType.DEX, ExchangeProviderType.DEX_BRIDGE -> {
|
||||
val networkId = currencyToSend.currency.network.backendId
|
||||
val networkId = currencyToSend.currency.network.rawId
|
||||
if (isSolana(networkId)) {
|
||||
onSwapSolanaDex(
|
||||
provider = swapProvider,
|
||||
|
|
@ -902,7 +902,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
repository.exchangeSent(
|
||||
userWallet = userWallet,
|
||||
txId = swapData.transaction.txId,
|
||||
fromNetwork = currencyToSendStatus.currency.network.backendId,
|
||||
fromNetwork = currencyToSendStatus.currency.network.rawId,
|
||||
fromAddress = fromAddress,
|
||||
payInAddress = payInAddress,
|
||||
txHash = txHash,
|
||||
|
|
@ -968,10 +968,10 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
val exchangeData = repository.getExchangeData(
|
||||
userWallet = userWallet,
|
||||
fromContractAddress = currencyToSend.currency.getContractAddress(),
|
||||
fromNetwork = currencyToSend.currency.network.backendId,
|
||||
fromNetwork = currencyToSend.currency.network.rawId,
|
||||
toContractAddress = currencyToGet.currency.getContractAddress(),
|
||||
fromAddress = fromAddress,
|
||||
toNetwork = currencyToGet.currency.network.backendId,
|
||||
toNetwork = currencyToGet.currency.network.rawId,
|
||||
fromAmount = amount.toStringWithRightOffset(),
|
||||
fromDecimals = amount.decimals,
|
||||
toDecimals = currencyToGet.currency.decimals,
|
||||
|
|
@ -1016,7 +1016,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
),
|
||||
exchangeData = TangemPayWithdrawExchangeState(
|
||||
txId = exchangeDataCex.txId,
|
||||
fromNetwork = currencyToSend.currency.network.backendId,
|
||||
fromNetwork = currencyToSend.currency.network.rawId,
|
||||
fromAddress = networkAddress?.defaultAddress?.value.orEmpty(),
|
||||
payInAddress = exchangeData.transaction.txTo,
|
||||
payInExtraId = exchangeDataCex.txExtraId,
|
||||
|
|
@ -1080,7 +1080,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
repository.exchangeSent(
|
||||
userWallet = userWallet,
|
||||
txId = exchangeDataCex.txId,
|
||||
fromNetwork = currencyToSend.currency.network.backendId,
|
||||
fromNetwork = currencyToSend.currency.network.rawId,
|
||||
fromAddress = cexFromAddress,
|
||||
payInAddress = getPayoutAddress(txData),
|
||||
txHash = txHash,
|
||||
|
|
@ -1222,10 +1222,10 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
repository.getExchangeData(
|
||||
userWallet = userWallet,
|
||||
fromContractAddress = fromToken.currency.getContractAddress(),
|
||||
fromNetwork = fromToken.currency.network.backendId,
|
||||
fromNetwork = fromToken.currency.network.rawId,
|
||||
toContractAddress = toToken.currency.getContractAddress(),
|
||||
fromAddress = dexFromAddress,
|
||||
toNetwork = toToken.currency.network.backendId,
|
||||
toNetwork = toToken.currency.network.rawId,
|
||||
fromAmount = swapAmount.toStringWithRightOffset(),
|
||||
fromDecimals = swapAmount.decimals,
|
||||
toDecimals = toToken.currency.decimals,
|
||||
|
|
@ -1235,7 +1235,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
refundAddress = fromToken.value.networkAddress?.defaultAddress?.value,
|
||||
expressOperationType = ExpressOperationType.SWAP,
|
||||
).map { swapData ->
|
||||
val networkId = fromToken.currency.network.backendId
|
||||
val networkId = fromToken.currency.network.rawId
|
||||
val transaction = swapData.transaction as ExpressTransactionModel.DEX
|
||||
|
||||
loadFeeForDex(
|
||||
|
|
@ -1361,9 +1361,9 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
val quotes = repository.findBestQuote(
|
||||
userWallet = userWallet,
|
||||
fromContractAddress = fromToken.getContractAddress(),
|
||||
fromNetwork = fromToken.network.backendId,
|
||||
fromNetwork = fromToken.network.rawId,
|
||||
toContractAddress = toToken.getContractAddress(),
|
||||
toNetwork = toToken.network.backendId,
|
||||
toNetwork = toToken.network.rawId,
|
||||
fromAmount = amountToRequest.toStringWithRightOffset(),
|
||||
fromDecimals = amount.decimals,
|
||||
toDecimals = toToken.decimals,
|
||||
|
|
@ -1739,10 +1739,10 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
return repository.getExchangeData(
|
||||
userWallet = userWallet,
|
||||
fromContractAddress = fromToken.currency.getContractAddress(),
|
||||
fromNetwork = fromToken.currency.network.backendId,
|
||||
fromNetwork = fromToken.currency.network.rawId,
|
||||
toContractAddress = toToken.currency.getContractAddress(),
|
||||
fromAddress = dexFromAddress,
|
||||
toNetwork = toToken.currency.network.backendId,
|
||||
toNetwork = toToken.currency.network.rawId,
|
||||
fromAmount = amount.toStringWithRightOffset(),
|
||||
fromDecimals = amount.decimals,
|
||||
toDecimals = toToken.currency.decimals,
|
||||
|
|
@ -1896,7 +1896,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
): Either<ExpressDataError, TransactionFeeResult> = either {
|
||||
val nativeBalance = walletManagersFacade.getNativeTokenBalance(
|
||||
userWalletId = userWalletId,
|
||||
networkId = network.backendId,
|
||||
networkId = network.rawId,
|
||||
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]
|
||||
val fromAddress = requireNotNull(
|
||||
requireNotNull(
|
||||
fromTokenStatus.value.networkAddress?.defaultAddress?.value,
|
||||
) { "networkAddress cant be null" }
|
||||
) { "networkAddress cannot be null" }
|
||||
|
||||
val allowanceInfo = getAllowanceInfoUseCase(
|
||||
userWalletId = userWalletId,
|
||||
cryptoCurrency = fromToken,
|
||||
spenderAddress = requireNotNull(spenderAddress) { "spenderAddress cant be null" },
|
||||
spenderAddress = requireNotNull(spenderAddress) { "spenderAddress cannot be null" },
|
||||
requiredAmount = swapAmount.value,
|
||||
).getOrNull()
|
||||
|
||||
|
|
@ -2229,7 +2229,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
}
|
||||
|
||||
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")
|
||||
val decimalValue = txValueAmount.toBigDecimalOrNull()?.movePointLeft(nativeDecimals)
|
||||
?: error("txValue parse error")
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ internal class MarketBlockDelegate @AssistedInject constructor(
|
|||
|
||||
val networks = tokenMarket.networks?.filter { network ->
|
||||
BlockchainUtils.isSupportedNetworkId(
|
||||
blockchainId = network.networkId,
|
||||
networkId = network.networkId,
|
||||
coinId = tokenMarket.id.value,
|
||||
contractAddress = network.contractAddress,
|
||||
excludedBlockchains = excludedBlockchains,
|
||||
|
|
|
|||
|
|
@ -880,11 +880,11 @@ internal class SwapModel @Inject constructor(
|
|||
|
||||
private fun sendErrorAnalyticsEvent(error: ExpressDataError, provider: SwapProvider) {
|
||||
val receiveToken = dataState.toCryptoCurrency?.currency?.let { currency ->
|
||||
"${currency.network.backendId}:${currency.symbol}"
|
||||
"${currency.network.rawId}:${currency.symbol}"
|
||||
}
|
||||
analyticsErrorEventHandler.sendErrorEvent(
|
||||
SwapEvents.NoticeProviderError(
|
||||
sendToken = "${initialCurrencyFrom.network.backendId}:${initialCurrencyFrom.symbol}",
|
||||
sendToken = "${initialCurrencyFrom.network.rawId}:${initialCurrencyFrom.symbol}",
|
||||
receiveToken = receiveToken.orEmpty(),
|
||||
provider = provider,
|
||||
errorCode = error.code,
|
||||
|
|
@ -1174,7 +1174,7 @@ internal class SwapModel @Inject constructor(
|
|||
}
|
||||
runCatching(dispatchers.io) {
|
||||
swapInteractor.givePermissionToSwap(
|
||||
networkId = fromToken.network.backendId,
|
||||
networkId = fromToken.network.rawId,
|
||||
permissionOptions = PermissionOptions(
|
||||
approveData = approveDataModel,
|
||||
forTokenContractAddress = (fromToken as? CryptoCurrency.Token)?.contractAddress.orEmpty(),
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ internal class StateBuilder(
|
|||
token = null,
|
||||
tokenIconUrl = initialCurrencyFrom.iconUrl,
|
||||
tokenCurrency = initialCurrencyFrom.symbol,
|
||||
coinId = initialCurrencyFrom.network.backendId,
|
||||
coinId = initialCurrencyFrom.network.rawId,
|
||||
canSelectAnotherToken = false,
|
||||
isNotNativeToken = initialCurrencyFrom is CryptoCurrency.Token,
|
||||
balance = "",
|
||||
|
|
@ -108,7 +108,7 @@ internal class StateBuilder(
|
|||
balance = "",
|
||||
isNotNativeToken = initialCurrencyTo is CryptoCurrency.Token,
|
||||
networkIconRes = initialCurrencyTo?.let { getActiveIconRes(it.network.rawId) },
|
||||
coinId = initialCurrencyTo?.network?.backendId,
|
||||
coinId = initialCurrencyTo?.network?.rawId,
|
||||
isBalanceHidden = true,
|
||||
),
|
||||
fee = FeeItemState.Empty,
|
||||
|
|
@ -145,7 +145,7 @@ internal class StateBuilder(
|
|||
amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO),
|
||||
token = fromToken,
|
||||
tokenIconUrl = fromToken.currency.iconUrl,
|
||||
coinId = fromToken.currency.network.backendId,
|
||||
coinId = fromToken.currency.network.rawId,
|
||||
isNotNativeToken = fromToken.currency is CryptoCurrency.Token,
|
||||
tokenCurrency = fromToken.currency.symbol,
|
||||
canSelectAnotherToken = uiStateHolder.sendCardData.canSelectAnotherToken,
|
||||
|
|
@ -196,7 +196,7 @@ internal class StateBuilder(
|
|||
amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO),
|
||||
token = fromToken,
|
||||
tokenIconUrl = fromToken.currency.iconUrl,
|
||||
coinId = fromToken.currency.network.backendId,
|
||||
coinId = fromToken.currency.network.rawId,
|
||||
isNotNativeToken = fromToken.currency is CryptoCurrency.Token,
|
||||
tokenCurrency = fromToken.currency.symbol,
|
||||
canSelectAnotherToken = canSelectSendToken,
|
||||
|
|
@ -214,7 +214,7 @@ internal class StateBuilder(
|
|||
amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO),
|
||||
token = toToken,
|
||||
tokenIconUrl = toToken.currency.iconUrl,
|
||||
coinId = toToken.currency.network.backendId,
|
||||
coinId = toToken.currency.network.rawId,
|
||||
isNotNativeToken = toToken.currency is CryptoCurrency.Token,
|
||||
tokenCurrency = toToken.currency.symbol,
|
||||
canSelectAnotherToken = canSelectReceiveToken,
|
||||
|
|
@ -266,7 +266,7 @@ internal class StateBuilder(
|
|||
token = uiStateHolder.sendCardData.token,
|
||||
tokenIconUrl = fromToken.iconUrl,
|
||||
tokenCurrency = fromToken.symbol,
|
||||
coinId = fromToken.network.backendId,
|
||||
coinId = fromToken.network.rawId,
|
||||
isNotNativeToken = fromToken is CryptoCurrency.Token,
|
||||
canSelectAnotherToken = canSelectSendToken,
|
||||
balance = if (!canSelectSendToken) uiStateHolder.sendCardData.balance else "",
|
||||
|
|
@ -282,7 +282,7 @@ internal class StateBuilder(
|
|||
token = uiStateHolder.receiveCardData.token,
|
||||
tokenIconUrl = toToken.iconUrl,
|
||||
tokenCurrency = toToken.symbol,
|
||||
coinId = toToken.network.backendId,
|
||||
coinId = toToken.network.rawId,
|
||||
isNotNativeToken = toToken is CryptoCurrency.Token,
|
||||
canSelectAnotherToken = canSelectReceiveToken,
|
||||
balance = if (!canSelectReceiveToken) uiStateHolder.receiveCardData.balance else "",
|
||||
|
|
@ -374,7 +374,7 @@ internal class StateBuilder(
|
|||
amountEquivalent = getFormattedFiatAmount(quoteModel.fromTokenInfo.amountFiat),
|
||||
token = fromCurrencyStatus,
|
||||
tokenIconUrl = uiStateHolder.sendCardData.tokenIconUrl,
|
||||
coinId = fromCurrencyStatus.currency.network.backendId,
|
||||
coinId = fromCurrencyStatus.currency.network.rawId,
|
||||
isNotNativeToken = uiStateHolder.sendCardData.isNotNativeToken,
|
||||
tokenCurrency = uiStateHolder.sendCardData.tokenCurrency,
|
||||
canSelectAnotherToken = uiStateHolder.sendCardData.canSelectAnotherToken,
|
||||
|
|
@ -415,7 +415,7 @@ internal class StateBuilder(
|
|||
},
|
||||
token = toCurrencyStatus,
|
||||
tokenIconUrl = uiStateHolder.receiveCardData.tokenIconUrl,
|
||||
coinId = toCurrencyStatus.currency.network.backendId,
|
||||
coinId = toCurrencyStatus.currency.network.rawId,
|
||||
isNotNativeToken = uiStateHolder.receiveCardData.isNotNativeToken,
|
||||
tokenCurrency = uiStateHolder.receiveCardData.tokenCurrency,
|
||||
canSelectAnotherToken = uiStateHolder.receiveCardData.canSelectAnotherToken,
|
||||
|
|
@ -535,7 +535,7 @@ internal class StateBuilder(
|
|||
amountEquivalent = getFormattedFiatAmount(BigDecimal.ZERO),
|
||||
token = toToken,
|
||||
tokenIconUrl = uiStateHolder.receiveCardData.tokenIconUrl,
|
||||
coinId = toToken.currency.network.backendId,
|
||||
coinId = toToken.currency.network.rawId,
|
||||
isNotNativeToken = uiStateHolder.receiveCardData.isNotNativeToken,
|
||||
tokenCurrency = uiStateHolder.receiveCardData.tokenCurrency,
|
||||
canSelectAnotherToken = uiStateHolder.receiveCardData.canSelectAnotherToken,
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ internal class DefaultTokenDetailsDeepLinkHandler @AssistedInject constructor(
|
|||
val derivationPath = queryParams[DERIVATION_PATH_KEY]
|
||||
|
||||
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 isDefaultDerivation = currency.network.derivationPath is Network.DerivationPath.Card
|
||||
|
|
|
|||
|
|
@ -168,6 +168,6 @@ internal class TokenDetailsNotificationConverter(
|
|||
|
||||
// workaround for networks that users have misunderstanding
|
||||
private fun CryptoCurrency.shouldMergeFeeNetworkName(): Boolean {
|
||||
return Blockchain.fromNetworkId(this.network.backendId) == Blockchain.Arbitrum
|
||||
return Blockchain.fromNetworkId(this.network.rawId) == Blockchain.Arbitrum
|
||||
}
|
||||
}
|
||||
|
|
@ -150,7 +150,7 @@ internal class TokenListAnalyticsSender @Inject constructor(
|
|||
) {
|
||||
// for now send only for Polkadot ecosystem blockchains
|
||||
// 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.AlephZero,
|
||||
Blockchain.Kusama,
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class YieldSupplyPromoBannerConverterTest {
|
|||
tokenList = tokenList,
|
||||
)
|
||||
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,
|
||||
)
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ class YieldSupplyPromoBannerConverterTest {
|
|||
tokenList = ungroupedTokenList(statusActive),
|
||||
)
|
||||
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,
|
||||
)
|
||||
|
||||
|
|
@ -90,8 +90,8 @@ class YieldSupplyPromoBannerConverterTest {
|
|||
val statusBig = createLoadedStatus(token = tokenBig, amount = BigDecimal("10.00"), isYieldActive = false)
|
||||
|
||||
val apyMap = mapOf(
|
||||
"${tokenSmall.network.backendId}_${tokenSmall.contractAddress.lowercase()}" to BigDecimal("0.05"),
|
||||
"${tokenBig.network.backendId}_${tokenBig.contractAddress.uppercase()}" to BigDecimal("0.15"),
|
||||
"${tokenSmall.network.rawId}_${tokenSmall.contractAddress.lowercase()}" to BigDecimal("0.05"),
|
||||
"${tokenBig.network.rawId}_${tokenBig.contractAddress.uppercase()}" to BigDecimal("0.15"),
|
||||
)
|
||||
|
||||
val params = TokenConverterParams.Wallet(
|
||||
|
|
@ -114,7 +114,7 @@ class YieldSupplyPromoBannerConverterTest {
|
|||
val token = createToken(networkId = nonEvmId, rawId = nonEvmId, contract = "rAbC123")
|
||||
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 params = TokenConverterParams.Wallet(
|
||||
|
|
@ -140,7 +140,7 @@ class YieldSupplyPromoBannerConverterTest {
|
|||
tokenList = ungroupedTokenList(status),
|
||||
)
|
||||
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,
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ internal class YieldSupplyNotificationsModel @Inject constructor(
|
|||
cryptoCurrencyWarning = cryptoCurrencyWarning,
|
||||
cryptoCurrencyStatus = cryptoCurrencyStatus,
|
||||
shouldMergeFeeNetworkName = BlockchainUtils.isArbitrum(
|
||||
blockchainId = cryptoCurrencyStatus.currency.network.backendId,
|
||||
networkId = cryptoCurrencyStatus.currency.network.rawId,
|
||||
),
|
||||
onClick = ::openTokenDetails,
|
||||
onAnalyticsEvent = { /*no-op*/ },
|
||||
|
|
|
|||
|
|
@ -37,103 +37,103 @@ object BlockchainUtils {
|
|||
}
|
||||
|
||||
/** If current [networkId] is Bitcoin */
|
||||
fun isBitcoin(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isBitcoin(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Bitcoin || blockchain == Blockchain.BitcoinTestnet
|
||||
}
|
||||
|
||||
/** If current [networkId] is use custom fee */
|
||||
fun isUseBitcoinFeeConverter(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
return isBitcoin(blockchainId) || blockchain == Blockchain.Fact0rn
|
||||
/** Checks if the current [blockchainId] uses a custom fee converter */
|
||||
fun isUseBitcoinFeeConverter(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return isBitcoin(networkId) || blockchain == Blockchain.Fact0rn
|
||||
}
|
||||
|
||||
/** If current [blockchainId] is Tezos */
|
||||
fun isTezos(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
/** If current [networkId] is Tezos */
|
||||
fun isTezos(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Tezos
|
||||
}
|
||||
|
||||
fun isCardano(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isCardano(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Cardano
|
||||
}
|
||||
|
||||
/** If current [blockchainId] is BeaconChain */
|
||||
fun isBeaconChain(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
/** If current [networkId] is BeaconChain */
|
||||
fun isBeaconChain(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Binance || blockchain == Blockchain.BinanceTestnet
|
||||
}
|
||||
|
||||
/** If current [blockchainId] is Polygon */
|
||||
fun isPolygonChain(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
/** If current [networkId] is Polygon */
|
||||
fun isPolygonChain(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Polygon || blockchain == Blockchain.PolygonTestnet
|
||||
}
|
||||
|
||||
fun isTron(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isTron(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Tron || blockchain == Blockchain.TronTestnet
|
||||
}
|
||||
|
||||
fun isTon(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isTon(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.TON || blockchain == Blockchain.TONTestnet
|
||||
}
|
||||
|
||||
fun isSupportedNetworkId(
|
||||
blockchainId: String,
|
||||
networkId: String,
|
||||
excludedBlockchains: ExcludedBlockchains,
|
||||
hotExcludedBlockchains: Set<Blockchain>,
|
||||
hasOnlyHotWallets: Boolean = false,
|
||||
coinId: String? = null,
|
||||
contractAddress: String? = null,
|
||||
): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain() ?: return false
|
||||
val blockchain = networkId.toBlockchain() ?: return false
|
||||
|
||||
if (blockchain in excludedBlockchains) return false
|
||||
if (hasOnlyHotWallets && blockchain in hotExcludedBlockchains) return false
|
||||
|
||||
if (!contractAddress.isNullOrEmpty()) {
|
||||
if (!blockchain.canHandleTokens()) return false
|
||||
if (coinId != null && !isNotBlockedByTerraV1Filter(blockchainId, coinId)) return false
|
||||
if (coinId != null && !isNotBlockedByTerraV1Filter(networkId, coinId)) return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
fun isArbitrum(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isArbitrum(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Arbitrum
|
||||
}
|
||||
|
||||
fun isSolana(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isSolana(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Solana
|
||||
}
|
||||
|
||||
fun isPolkadot(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isPolkadot(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Polkadot || blockchain == Blockchain.PolkadotTestnet
|
||||
}
|
||||
|
||||
fun isCosmos(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isCosmos(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Cosmos || blockchain == Blockchain.CosmosTestnet
|
||||
}
|
||||
|
||||
fun isBSC(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isBSC(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.BSC || blockchain == Blockchain.BSCTestnet
|
||||
}
|
||||
|
||||
fun isEthereum(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isEthereum(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return blockchain == Blockchain.Ethereum || blockchain == Blockchain.EthereumTestnet
|
||||
}
|
||||
|
||||
fun isClore(blockchainId: String): Boolean {
|
||||
return blockchainId.toBlockchain() == Blockchain.Clore
|
||||
fun isClore(networkId: String): Boolean {
|
||||
return networkId.toBlockchain() == Blockchain.Clore
|
||||
}
|
||||
|
||||
data class BlockchainInfo(
|
||||
|
|
@ -162,29 +162,29 @@ object BlockchainUtils {
|
|||
/**
|
||||
* Blockchains not affecting total balance counting on errors
|
||||
*/
|
||||
fun isIncludeToBalanceOnError(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isIncludeToBalanceOnError(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return when (blockchain) {
|
||||
Blockchain.Binance, Blockchain.BinanceTestnet -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
fun isIncludeStakingTotalBalance(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isIncludeStakingTotalBalance(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
|
||||
return blockchain != Blockchain.Cardano
|
||||
}
|
||||
|
||||
fun isStakingRewardUnavailable(blockchainId: String, isCoin: Boolean): Boolean {
|
||||
val isP2PEthPool = isEthereum(blockchainId) && isCoin
|
||||
fun isStakingRewardUnavailable(networkId: String, isCoin: Boolean): Boolean {
|
||||
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 */
|
||||
fun isCaseInsensitiveContractAddress(blockchainId: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isCaseInsensitiveContractAddress(networkId: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
|
||||
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.
|
||||
*/
|
||||
fun isTetherInEthereum(blockchainId: String, contractAddress: String): Boolean {
|
||||
val blockchain = blockchainId.toBlockchain()
|
||||
fun isTetherInEthereum(networkId: String, contractAddress: String): Boolean {
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return (blockchain == Blockchain.Ethereum || blockchain == Blockchain.EthereumTestnet) &&
|
||||
contractAddress.equals(TETHER_CONTRACT_ADDRESS, ignoreCase = true)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue