Updated on 2026-08-14
This commit is contained in:
parent
db6157cae4
commit
99f62f79ee
35 changed files with 128 additions and 109 deletions
|
|
@ -2,6 +2,7 @@ package com.tangem.tap.domain.card
|
|||
|
||||
import com.tangem.blockchain.blockchains.cardano.CardanoUtils
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.common.card.EllipticCurve
|
||||
import com.tangem.common.extensions.ByteArrayKey
|
||||
import com.tangem.common.extensions.toMapKey
|
||||
|
|
@ -49,7 +50,7 @@ internal class MissedDerivationsFinder(private val scanResponse: ScanResponse) {
|
|||
private fun List<Network>.mapToNewDerivations(): List<DerivationData> {
|
||||
val config = CardConfig.createConfig(scanResponse.card)
|
||||
return mapNotNull { network ->
|
||||
val blockchain = Blockchain.fromId(id = network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val curve = config.primaryCurve(blockchain) ?: return@mapNotNull null
|
||||
|
||||
findNewDerivations(curve = curve, scanResponse = scanResponse, network = network)
|
||||
|
|
@ -74,7 +75,7 @@ internal class MissedDerivationsFinder(private val scanResponse: ScanResponse) {
|
|||
}
|
||||
|
||||
private fun Network.getDerivationCandidates(curve: EllipticCurve): List<DerivationPath> {
|
||||
val blockchain = Blockchain.fromId(id = rawId)
|
||||
val blockchain = this.toBlockchain()
|
||||
|
||||
return buildList {
|
||||
add(blockchain.getDerivationPath(curve = curve))
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem.tap.domain.walletconnect2.domain
|
||||
|
||||
import arrow.core.flatten
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.network.Network
|
||||
|
|
@ -419,7 +419,8 @@ class WalletConnectInteractor(
|
|||
|
||||
private suspend fun getAccountsForWc(userWallet: UserWallet, networks: List<Network>): List<Account> {
|
||||
val walletManagers = networks.mapNotNull {
|
||||
val blockchain = Blockchain.fromId(it.rawId)
|
||||
val blockchain = it.toBlockchain()
|
||||
|
||||
walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWallet.walletId,
|
||||
blockchain = blockchain,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem.tap.features.wallet.redux.middlewares
|
||||
|
||||
import com.tangem.blockchain.blockchains.ethereum.EthereumWalletManager
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.common.routing.AppRoute
|
||||
import com.tangem.common.routing.AppRouter
|
||||
import com.tangem.core.analytics.Analytics
|
||||
|
|
@ -79,7 +79,7 @@ object TradeCryptoMiddleware {
|
|||
|
||||
val status = action.cryptoCurrencyStatus
|
||||
val currency = status.currency
|
||||
val blockchain = Blockchain.fromId(currency.network.rawId)
|
||||
val blockchain = currency.network.toBlockchain()
|
||||
val exchangeManager = store.state.globalState.exchangeManager
|
||||
val topUrl = exchangeManager.getUrl(
|
||||
action = CurrencyExchangeManager.Action.Buy,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.tap.network.exchangeServices
|
|||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.Token
|
||||
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.tap.common.extensions.inject
|
||||
|
|
@ -44,7 +45,7 @@ internal class CryptoCurrencyConverter(
|
|||
}
|
||||
|
||||
override fun convertBack(value: CryptoCurrency): Currency {
|
||||
val blockchain = Blockchain.fromId(value.network.rawId)
|
||||
val blockchain = value.network.toBlockchain()
|
||||
if (blockchain == Blockchain.Unknown) error("CryptoCurrencyConverter convertBack Unknown blockchain")
|
||||
return when (value) {
|
||||
is CryptoCurrency.Coin -> Currency.Blockchain(
|
||||
|
|
|
|||
|
|
@ -4,9 +4,9 @@ import com.tangem.Message
|
|||
import com.tangem.blockchain.blockchains.ethereum.EthereumWalletManager
|
||||
import com.tangem.blockchain.common.Amount
|
||||
import com.tangem.blockchain.common.AmountType
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.transaction.TransactionFee
|
||||
import com.tangem.blockchain.extensions.Result
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.domain.common.TapWorkarounds.isTangemTwins
|
||||
import com.tangem.domain.core.utils.lceContent
|
||||
import com.tangem.domain.core.utils.lceLoading
|
||||
|
|
@ -68,7 +68,7 @@ class CurrencyExchangeManager(
|
|||
walletAddress: String,
|
||||
isDarkTheme: Boolean,
|
||||
): String? {
|
||||
val blockchain = Blockchain.fromId(cryptoCurrency.network.rawId)
|
||||
val blockchain = cryptoCurrency.network.toBlockchain()
|
||||
if (blockchain.isTestnet()) return blockchain.getTestnetTopUpUrl()
|
||||
|
||||
val urlBuilder = getExchangeUrlBuilder(action)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem.tap.network.exchangeServices.mercuryo
|
||||
|
||||
import android.net.Uri
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.common.extensions.calculateSha512
|
||||
import com.tangem.common.extensions.toHexString
|
||||
import com.tangem.common.services.Result
|
||||
|
|
@ -77,7 +77,7 @@ internal class MercuryoService(private val environment: MercuryoEnvironment) : E
|
|||
): String {
|
||||
if (action == CurrencyExchangeManager.Action.Sell) throw UnsupportedOperationException()
|
||||
|
||||
val blockchain = Blockchain.fromId(cryptoCurrency.network.rawId)
|
||||
val blockchain = cryptoCurrency.network.toBlockchain()
|
||||
|
||||
val builder = Uri.Builder()
|
||||
.scheme(ExchangeUrlBuilder.SCHEME)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.tangem.tap.network.exchangeServices.moonpay
|
|||
|
||||
import android.net.Uri
|
||||
import android.util.Base64
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.common.services.Result
|
||||
import com.tangem.common.services.performRequest
|
||||
import com.tangem.datasource.api.common.createRetrofitInstance
|
||||
|
|
@ -133,7 +133,7 @@ class MoonPayService(
|
|||
): String? {
|
||||
if (action == CurrencyExchangeManager.Action.Buy) throw UnsupportedOperationException()
|
||||
|
||||
val blockchain = Blockchain.fromId(cryptoCurrency.network.rawId)
|
||||
val blockchain = cryptoCurrency.network.toBlockchain()
|
||||
val supportedCurrency = blockchain.moonPaySupportedCurrency ?: return null
|
||||
val moonpayCurrency = status?.availableForSell?.firstOrNull {
|
||||
when (cryptoCurrency) {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.data.common.currency
|
|||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.blockchainsdk.utils.toCoinId
|
||||
import com.tangem.data.common.network.NetworkFactory
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
|
|
@ -97,7 +98,7 @@ class CryptoCurrencyFactory(
|
|||
}
|
||||
|
||||
fun createCoin(network: Network): CryptoCurrency.Coin {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
|
||||
return CryptoCurrency.Coin(
|
||||
id = getCoinId(network, blockchain.toCoinId()),
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
package com.tangem.data.common.currency
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.domain.models.network.Network
|
||||
|
||||
fun getBlockchain(networkId: Network.ID): Blockchain {
|
||||
return Blockchain.fromId(networkId.rawId.value)
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.tangem.data.common.currency
|
|||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.IconsUtil
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.blockchainsdk.utils.toCoinId
|
||||
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
|
|
@ -68,11 +69,10 @@ fun getCoinIconUrl(blockchain: Blockchain): String? {
|
|||
}
|
||||
|
||||
fun List<UserTokensResponse.Token>.hasCoinForToken(network: Network): Boolean {
|
||||
return any {
|
||||
val blockchain = getBlockchain(networkId = network.id)
|
||||
val coinId = network.toBlockchain().toCoinId()
|
||||
val tokenDerivation = network.derivationPath.value
|
||||
it.id == blockchain.toCoinId() && it.derivationPath == tokenDerivation
|
||||
}
|
||||
|
||||
return any { it.id == coinId && it.derivationPath == tokenDerivation }
|
||||
}
|
||||
|
||||
private fun getCurrencyIdBody(network: Network): CurrencyIdBody {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.tangem.data.common.currency
|
||||
|
||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||
import com.tangem.datasource.api.tangemTech.models.UserTokensResponse
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
|
||||
|
|
@ -27,16 +26,16 @@ class UserTokensResponseFactory {
|
|||
}
|
||||
|
||||
fun createResponseToken(currency: CryptoCurrency): UserTokensResponse.Token {
|
||||
val blockchain = getBlockchain(currency.network.id)
|
||||
|
||||
return UserTokensResponse.Token(
|
||||
id = currency.id.rawCurrencyId?.value,
|
||||
networkId = blockchain.toNetworkId(),
|
||||
derivationPath = currency.network.derivationPath.value,
|
||||
name = currency.name,
|
||||
symbol = currency.symbol,
|
||||
decimals = currency.decimals,
|
||||
contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress,
|
||||
return with(currency) {
|
||||
UserTokensResponse.Token(
|
||||
id = id.rawCurrencyId?.value,
|
||||
networkId = network.backendId,
|
||||
derivationPath = network.derivationPath.value,
|
||||
name = name,
|
||||
symbol = symbol,
|
||||
decimals = decimals,
|
||||
contractAddress = (this as? CryptoCurrency.Token)?.contractAddress,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,8 +4,8 @@ import androidx.annotation.VisibleForTesting
|
|||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.FeePaidCurrency
|
||||
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||
import com.tangem.data.common.currency.getBlockchain
|
||||
import com.tangem.domain.common.DerivationStyleProvider
|
||||
import com.tangem.domain.common.extensions.canHandleToken
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
|
|
@ -57,7 +57,7 @@ class NetworkFactory @Inject constructor(
|
|||
* @param scanResponse scan response
|
||||
*/
|
||||
fun create(networkId: Network.ID, derivationPath: Network.DerivationPath, scanResponse: ScanResponse): Network? {
|
||||
val blockchain = getBlockchain(networkId)
|
||||
val blockchain = networkId.toBlockchain()
|
||||
|
||||
return create(
|
||||
blockchain = blockchain,
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@ package com.tangem.data.managetokens
|
|||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||
import com.tangem.crypto.hdWallet.DerivationPath
|
||||
import com.tangem.data.common.currency.CryptoCurrencyFactory
|
||||
import com.tangem.data.common.currency.UserTokensResponseFactory
|
||||
import com.tangem.data.common.currency.UserTokensSaver
|
||||
import com.tangem.data.common.currency.getBlockchain
|
||||
import com.tangem.data.common.network.NetworkFactory
|
||||
import com.tangem.data.managetokens.utils.TokenAddressesConverter
|
||||
import com.tangem.datasource.api.common.response.getOrThrow
|
||||
|
|
@ -48,7 +48,7 @@ internal class DefaultCustomTokensRepository(
|
|||
|
||||
override suspend fun validateContractAddress(contractAddress: String, networkId: Network.ID): Boolean =
|
||||
withContext(dispatchers.io) {
|
||||
when (val blockchain = Blockchain.fromId(networkId.rawId.value)) {
|
||||
when (val blockchain = networkId.toBlockchain()) {
|
||||
Blockchain.Unknown,
|
||||
Blockchain.Binance,
|
||||
Blockchain.BinanceTestnet,
|
||||
|
|
@ -76,7 +76,7 @@ internal class DefaultCustomTokensRepository(
|
|||
}
|
||||
|
||||
storedCurrencies.tokens.none { token ->
|
||||
getBlockchain(networkId).toNetworkId() == token.networkId &&
|
||||
networkId.toBlockchain().toNetworkId() == token.networkId &&
|
||||
derivationPath.value == token.derivationPath &&
|
||||
contractAddress.equals(token.contractAddress, ignoreCase = true)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,11 +4,11 @@ import com.tangem.blockchain.common.Blockchain
|
|||
import com.tangem.blockchainsdk.compatibility.l2BlockchainsCoinIds
|
||||
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.blockchainsdk.utils.toNetworkId
|
||||
import com.tangem.data.common.api.safeApiCall
|
||||
import com.tangem.data.common.currency.CardCryptoCurrencyFactory
|
||||
import com.tangem.data.common.currency.UserTokensResponseFactory
|
||||
import com.tangem.data.common.currency.getBlockchain
|
||||
import com.tangem.data.common.network.NetworkFactory
|
||||
import com.tangem.data.common.utils.retryOnError
|
||||
import com.tangem.data.managetokens.utils.ManageTokensUpdateFetcher
|
||||
|
|
@ -232,10 +232,11 @@ internal class DefaultManageTokensRepository(
|
|||
token.availableNetworks
|
||||
.filter { sourceNetwork -> networks.contains(sourceNetwork.network) }
|
||||
.map { sourceNetwork ->
|
||||
val blockchain = getBlockchain(sourceNetwork.network.id)
|
||||
val networkId = sourceNetwork.network.toBlockchain().toNetworkId()
|
||||
|
||||
UserTokensResponse.Token(
|
||||
id = token.id.value,
|
||||
networkId = blockchain.toNetworkId(),
|
||||
networkId = networkId,
|
||||
derivationPath = sourceNetwork.network.derivationPath.value,
|
||||
name = token.name,
|
||||
symbol = token.symbol,
|
||||
|
|
@ -257,7 +258,8 @@ internal class DefaultManageTokensRepository(
|
|||
sourceNetwork: SourceNetwork,
|
||||
): CurrencyUnsupportedState? {
|
||||
val userWallet = userWalletsStore.getSyncStrict(key = userWalletId)
|
||||
val blockchain = getBlockchain(sourceNetwork.id)
|
||||
val blockchain = sourceNetwork.id.toBlockchain()
|
||||
|
||||
return when (sourceNetwork) {
|
||||
is SourceNetwork.Default -> checkTokenUnsupportedState(userWallet = userWallet, blockchain = blockchain)
|
||||
is SourceNetwork.Main -> checkBlockchainUnsupportedState(userWallet = userWallet, blockchain = blockchain)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package com.tangem.data.managetokens.utils
|
|||
import com.tangem.blockchain.blockchains.cardano.CardanoTokenAddressConverter
|
||||
import com.tangem.blockchain.blockchains.hedera.HederaTokenAddressConverter
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.data.common.currency.getBlockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.domain.models.network.Network
|
||||
|
||||
internal class TokenAddressesConverter {
|
||||
|
|
@ -11,7 +11,7 @@ internal class TokenAddressesConverter {
|
|||
private val cardanoTokenAddressConverter = CardanoTokenAddressConverter()
|
||||
|
||||
fun convertTokenAddress(networkId: Network.ID, contractAddress: String, symbol: String?): String {
|
||||
val convertedAddress = when (getBlockchain(networkId)) {
|
||||
val convertedAddress = when (networkId.toBlockchain()) {
|
||||
Blockchain.Hedera,
|
||||
Blockchain.HederaTestnet,
|
||||
-> hederaTokenAddressConverter.convertToTokenId(contractAddress)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem.data.onramp.legacy
|
||||
|
||||
import android.net.Uri
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.common.extensions.calculateSha512
|
||||
import com.tangem.common.extensions.toHexString
|
||||
import com.tangem.datasource.local.config.environment.EnvironmentConfig
|
||||
|
|
@ -19,7 +19,7 @@ internal class MercuryoTopUpRepository @Inject constructor(
|
|||
|
||||
override suspend fun getTopUpUrl(cryptoCurrency: CryptoCurrency, walletAddress: String): String =
|
||||
withContext(dispatchersProvider.default) {
|
||||
val blockchain = Blockchain.fromId(cryptoCurrency.network.rawId)
|
||||
val blockchain = cryptoCurrency.network.toBlockchain()
|
||||
val environmentConfig = environmentConfigStorage.getConfigSync()
|
||||
|
||||
val builder = Uri.Builder()
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ dependencies {
|
|||
implementation(projects.domain.tokens.models)
|
||||
|
||||
implementation(projects.core.ui)
|
||||
implementation(projects.libs.blockchainSdk)
|
||||
|
||||
/** SdK */
|
||||
implementation(tangemDeps.blockchain)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.tangem.data.qrscanning.repository
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.core.ui.utils.parseBigDecimalOrNull
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.qrscanning.models.QrResult
|
||||
|
|
@ -90,7 +90,7 @@ internal class DefaultQrScanningEventsRepository : QrScanningEventsRepository {
|
|||
}
|
||||
|
||||
private fun stripSchema(raw: String, currency: CryptoCurrency): String {
|
||||
val qrSchemas = Blockchain.fromId(currency.network.rawId).getShareScheme()
|
||||
val qrSchemas = currency.network.toBlockchain().getShareScheme()
|
||||
|
||||
// The most specific (i.e. the most lengthy) prefixes always come first
|
||||
qrSchemas
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ internal class DefaultQrScanningEventsRepositoryTest {
|
|||
|
||||
@Test
|
||||
fun testBip021() {
|
||||
every { network.rawId } returns Blockchain.Bitcoin.id
|
||||
every { network.id.rawId.value } returns Blockchain.Bitcoin.id
|
||||
positiveCase(
|
||||
"$schema1:$address1",
|
||||
QrResult(address = address1),
|
||||
|
|
@ -126,7 +126,7 @@ internal class DefaultQrScanningEventsRepositoryTest {
|
|||
|
||||
@Test
|
||||
fun testErc681Coin() {
|
||||
every { network.rawId } returns Blockchain.Ethereum.id
|
||||
every { network.id.rawId.value } returns Blockchain.Ethereum.id
|
||||
positiveCase(
|
||||
address2,
|
||||
QrResult(address = address2),
|
||||
|
|
@ -181,7 +181,7 @@ internal class DefaultQrScanningEventsRepositoryTest {
|
|||
|
||||
@Test
|
||||
fun testErc681Token() {
|
||||
every { network.rawId } returns Blockchain.Ethereum.id
|
||||
every { network.id.rawId.value } returns Blockchain.Ethereum.id
|
||||
positiveCase(
|
||||
address2,
|
||||
QrResult(address = address2),
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.tangem.blockchain.common.TransactionData
|
|||
import com.tangem.blockchain.common.TransactionStatus
|
||||
import com.tangem.blockchain.common.transaction.Fee
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.blockchainsdk.utils.toCoinId
|
||||
import com.tangem.blockchainsdk.utils.toMigratedCoinId
|
||||
import com.tangem.common.extensions.hexToBytes
|
||||
|
|
@ -245,7 +246,7 @@ internal class DefaultStakingRepository(
|
|||
}
|
||||
|
||||
private fun checkFeatureToggleEnabled(networkId: Network.ID): Boolean {
|
||||
return when (Blockchain.fromId(networkId.rawId.value)) {
|
||||
return when (networkId.toBlockchain()) {
|
||||
Blockchain.TON -> stakingFeatureToggles.isTonStakingEnabled
|
||||
Blockchain.Cardano -> stakingFeatureToggles.isCardanoStakingEnabled
|
||||
else -> true
|
||||
|
|
|
|||
|
|
@ -127,8 +127,7 @@ internal class DefaultCurrenciesRepository(
|
|||
currenciesToAdd: List<CryptoCurrency>,
|
||||
): List<CryptoCurrency> {
|
||||
return currenciesToAdd.filter { currency ->
|
||||
val blockchain = getBlockchain(networkId = currency.network.id)
|
||||
val networkId = blockchain.toNetworkId()
|
||||
val networkId = currency.network.toBlockchain().toNetworkId()
|
||||
val contractAddress = (currency as? CryptoCurrency.Token)?.contractAddress
|
||||
|
||||
savedCurrencies.none { token ->
|
||||
|
|
@ -357,7 +356,7 @@ internal class DefaultCurrenciesRepository(
|
|||
"Unable to find tokens response for user wallet with provided ID: $userWalletId"
|
||||
},
|
||||
)
|
||||
val blockchain = Blockchain.fromId(networkId.rawId.value)
|
||||
val blockchain = networkId.toBlockchain()
|
||||
val blockchainNetworkId = blockchain.toNetworkId()
|
||||
val coinId = blockchain.toCoinId()
|
||||
|
||||
|
|
@ -410,7 +409,7 @@ internal class DefaultCurrenciesRepository(
|
|||
cryptoCurrencyStatus: CryptoCurrencyStatus,
|
||||
coinStatus: CryptoCurrencyStatus?,
|
||||
): Boolean {
|
||||
val blockchain = Blockchain.fromId(cryptoCurrencyStatus.currency.network.rawId)
|
||||
val blockchain = cryptoCurrencyStatus.currency.network.toBlockchain()
|
||||
val isBitcoinBlockchain = blockchain == Blockchain.Bitcoin || blockchain == Blockchain.BitcoinTestnet
|
||||
return when {
|
||||
cryptoCurrencyStatus.currency is CryptoCurrency.Coin && isBitcoinBlockchain -> {
|
||||
|
|
@ -425,7 +424,7 @@ internal class DefaultCurrenciesRepository(
|
|||
|
||||
override suspend fun getFeePaidCurrency(userWalletId: UserWalletId, network: Network): FeePaidCurrency {
|
||||
return withContext(dispatchers.io) {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
when (val feePaidCurrency = blockchain.feePaidCurrency()) {
|
||||
FeePaidSdkCurrency.Coin -> FeePaidCurrency.Coin
|
||||
FeePaidSdkCurrency.SameCurrency -> FeePaidCurrency.SameCurrency
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import com.tangem.blockchain.blockchains.polkadot.AccountCheckProvider
|
|||
import com.tangem.blockchain.blockchains.polkadot.network.accounthealthcheck.ExtrinsicListItemResponse
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.BlockchainSdkError
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||
import com.tangem.datasource.local.preferences.PreferencesKeys.POLKADOT_HEALTH_CHECKED_IMMUTABLE_ACCOUNTS_KEY
|
||||
import com.tangem.datasource.local.preferences.PreferencesKeys.POLKADOT_HEALTH_CHECKED_RESET_ACCOUNTS_KEY
|
||||
|
|
@ -39,7 +40,7 @@ internal class DefaultPolkadotAccountHealthCheckRepository(
|
|||
|
||||
override suspend fun runCheck(userWalletId: UserWalletId, network: Network) {
|
||||
// Run Polkadot account health check
|
||||
if (Blockchain.fromId(network.rawId) != Blockchain.Polkadot) return
|
||||
if (network.toBlockchain() != Blockchain.Polkadot) return
|
||||
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(userWalletId, network)
|
||||
val address = requireNotNull(walletManager?.wallet?.address) {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
package com.tangem.data.transaction
|
||||
|
||||
import com.tangem.blockchain.common.AmountType
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.transaction.FeeRepository
|
||||
|
||||
internal class DefaultFeeRepository : FeeRepository {
|
||||
|
||||
override fun isFeeApproximate(networkId: Network.ID, amountType: AmountType): Boolean {
|
||||
val blockchain = Blockchain.fromId(networkId.rawId.value)
|
||||
return blockchain.isFeeApproximate(amountType)
|
||||
return networkId.toBlockchain().isFeeApproximate(amountType)
|
||||
}
|
||||
}
|
||||
|
|
@ -19,6 +19,7 @@ import com.tangem.blockchain.common.smartcontract.SmartContractCallDataProviderF
|
|||
import com.tangem.blockchain.common.transaction.Fee
|
||||
import com.tangem.blockchain.nft.models.NFTAsset
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.datasource.local.walletmanager.WalletManagersStore
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.network.Network
|
||||
|
|
@ -47,7 +48,7 @@ internal class DefaultTransactionRepository(
|
|||
network: Network,
|
||||
txExtras: TransactionExtras?,
|
||||
): TransactionData.Uncompiled = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -83,7 +84,7 @@ internal class DefaultTransactionRepository(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
): TransactionData.Uncompiled = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -137,7 +138,7 @@ internal class DefaultTransactionRepository(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
): TransactionData.Uncompiled = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
|
||||
val extras = createTransactionDataExtras(
|
||||
callData = SmartContractCallDataProviderFactory.getApprovalCallData(
|
||||
|
|
@ -170,7 +171,7 @@ internal class DefaultTransactionRepository(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
): TransactionData.Uncompiled = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
|
||||
// For now transfer one nft asset at a time
|
||||
val updatedNFTAsset = nftAsset.copy(
|
||||
|
|
@ -228,7 +229,7 @@ internal class DefaultTransactionRepository(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
): Result<Unit> = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = walletManagersStore.getSyncOrNull(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -259,7 +260,7 @@ internal class DefaultTransactionRepository(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
) = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -273,15 +274,15 @@ internal class DefaultTransactionRepository(
|
|||
signer: TransactionSigner,
|
||||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
mode: TransactionSender.MultipleTransactionSendMode,
|
||||
sendMode: TransactionSender.MultipleTransactionSendMode,
|
||||
) = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
derivationPath = network.derivationPath.value,
|
||||
)
|
||||
(walletManager as TransactionSender).sendMultiple(txsData, signer, mode)
|
||||
(walletManager as TransactionSender).sendMultiple(txsData, signer, sendMode)
|
||||
}
|
||||
|
||||
override fun createTransactionDataExtras(
|
||||
|
|
@ -315,7 +316,7 @@ internal class DefaultTransactionRepository(
|
|||
spenderAddress: String,
|
||||
): BigDecimal {
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(userWalletId, cryptoCurrency.network)
|
||||
val blockchain = Blockchain.fromId(cryptoCurrency.network.rawId)
|
||||
val blockchain = cryptoCurrency.network.toBlockchain()
|
||||
val allowanceResult = (walletManager as? Approver)?.getAllowance(
|
||||
spenderAddress,
|
||||
Token(
|
||||
|
|
@ -388,7 +389,7 @@ internal class DefaultTransactionRepository(
|
|||
}
|
||||
|
||||
private suspend fun getPreparer(network: Network, userWalletId: UserWalletId): TransactionPreparer {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import android.net.Uri
|
|||
import androidx.core.text.isDigitsOnly
|
||||
import com.tangem.blockchain.blockchains.near.NearWalletManager
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.transaction.WalletAddressServiceRepository
|
||||
import com.tangem.domain.walletmanager.WalletManagersFacade
|
||||
|
|
@ -21,7 +22,7 @@ class DefaultWalletAddressServiceRepository(
|
|||
|
||||
override suspend fun validateAddress(userWalletId: UserWalletId, network: Network, address: String): Boolean =
|
||||
withContext(dispatchers.io) {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
|
||||
if (blockchain.isNear()) {
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
|
|
@ -50,7 +51,7 @@ class DefaultWalletAddressServiceRepository(
|
|||
}
|
||||
|
||||
override suspend fun parseSharedAddress(input: String, network: Network): ParsedQrCode {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val addressSchemeSplit = when (blockchain) {
|
||||
Blockchain.BitcoinCash, Blockchain.Kaspa -> listOf(input)
|
||||
else -> input.split(":")
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ package com.tangem.data.txhistory.repository
|
|||
import androidx.paging.Pager
|
||||
import androidx.paging.PagingConfig
|
||||
import androidx.paging.PagingData
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.externallinkprovider.TxExploreState
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.data.common.cache.CacheRegistry
|
||||
import com.tangem.data.txhistory.repository.paging.TxHistoryPagingSource
|
||||
import com.tangem.datasource.local.txhistory.TxHistoryItemsStore
|
||||
|
|
@ -77,7 +77,7 @@ class DefaultTxHistoryRepository(
|
|||
|
||||
@Deprecated("Replace with getTxExploreUrl [UserWalletId, Network] instead")
|
||||
override fun getTxExploreUrl(txHash: String, networkId: Network.ID): String {
|
||||
val blockchain = Blockchain.fromId(networkId.rawId.value)
|
||||
val blockchain = networkId.toBlockchain()
|
||||
return when (val txExploreState = blockchain.getExploreTxUrl(txHash)) {
|
||||
is TxExploreState.Url -> txExploreState.url
|
||||
is TxExploreState.Unsupported -> ""
|
||||
|
|
@ -85,7 +85,7 @@ class DefaultTxHistoryRepository(
|
|||
}
|
||||
|
||||
override suspend fun getTxExploreUrl(userWalletId: UserWalletId, network: Network): String {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
network = network,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.data.walletconnect.network.ethereum
|
|||
import com.squareup.moshi.Moshi
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.data.walletconnect.model.CAIP2
|
||||
import com.tangem.data.walletconnect.model.NamespaceKey
|
||||
import com.tangem.data.walletconnect.request.WcRequestToUseCaseConverter
|
||||
|
|
@ -104,8 +105,8 @@ internal class WcEthNetwork(
|
|||
private fun parseTypeData(params: String): WcEthMethod.SignTypedData? {
|
||||
val account = params.substring(params.indexOf("\"") + 1, params.indexOf("\"", startIndex = 2))
|
||||
val data = params.substring(params.indexOfFirst { it == '{' }, params.indexOfLast { it == '}' } + 1)
|
||||
val params = moshi.fromJson<WcEthSignTypedDataParams>(data) ?: return null
|
||||
return WcEthMethod.SignTypedData(params = params, account = account, dataForSign = data)
|
||||
val parsedParams = moshi.fromJson<WcEthSignTypedDataParams>(data) ?: return null
|
||||
return WcEthMethod.SignTypedData(params = parsedParams, account = account, dataForSign = data)
|
||||
}
|
||||
|
||||
internal class NamespaceConverter(
|
||||
|
|
@ -125,7 +126,7 @@ internal class WcEthNetwork(
|
|||
}
|
||||
|
||||
override fun toCAIP2(network: Network): CAIP2? {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
if (!blockchain.isEvm()) return null
|
||||
val chainId = blockchain.getChainId() ?: return null
|
||||
return CAIP2(
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import com.tangem.blockchain.common.TransactionData
|
|||
import com.tangem.blockchain.common.smartcontract.CompiledSmartContractCallData
|
||||
import com.tangem.blockchain.common.transaction.Fee
|
||||
import com.tangem.blockchain.extensions.hexToBigDecimal
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.common.extensions.hexToBytes
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.walletconnect.model.WcEthTransactionParams
|
||||
|
|
@ -20,7 +21,7 @@ internal object WcEthTxHelper {
|
|||
val gasLimit = txParams.gas?.hexToBigDecimal() ?: return null
|
||||
val gasPrice = txParams.gasPrice?.hexToBigDecimal() ?: return null
|
||||
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
|
||||
var feeDecimal = (gasLimit * gasPrice)
|
||||
.movePointLeft(blockchain.decimals())
|
||||
|
|
@ -38,7 +39,7 @@ internal object WcEthTxHelper {
|
|||
txParams: WcEthTransactionParams,
|
||||
): TransactionData.Uncompiled? {
|
||||
val destinationAddress = txParams.to ?: return null
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val value = (txParams.value ?: "0")
|
||||
.hexToBigDecimal()
|
||||
.movePointLeft(blockchain.decimals())
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.squareup.moshi.Moshi
|
|||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.extensions.decodeBase58
|
||||
import com.tangem.blockchainsdk.utils.ExcludedBlockchains
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.common.extensions.toHexString
|
||||
import com.tangem.data.walletconnect.model.CAIP2
|
||||
import com.tangem.data.walletconnect.model.NamespaceKey
|
||||
|
|
@ -84,7 +85,7 @@ internal class WcSolanaNetwork(
|
|||
}
|
||||
|
||||
override fun toCAIP2(network: Network): CAIP2? {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val chainId = when (blockchain) {
|
||||
Blockchain.Solana -> MAINNET_CHAIN_ID
|
||||
Blockchain.SolanaTestnet -> TESTNET_CHAIN_ID
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.tangem.domain.card
|
|||
|
||||
import arrow.core.Either
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.common.extensions.ByteArrayKey
|
||||
import com.tangem.common.extensions.calculateRipemd160
|
||||
import com.tangem.common.extensions.calculateSha256
|
||||
|
|
@ -26,7 +27,7 @@ class GetExtendedPublicKeyForCurrencyUseCase(
|
|||
val userWallet = walletManagersFacade.getOrCreateWalletManager(userWalletId, network)
|
||||
?: error("Wallet not found")
|
||||
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val isSecp256k1Blockchain = Blockchain.secp256k1Blockchains(network.isTestnet).contains(blockchain)
|
||||
|
||||
val hdKey = if (isSecp256k1Blockchain) {
|
||||
|
|
@ -76,7 +77,7 @@ class GetExtendedPublicKeyForCurrencyUseCase(
|
|||
val userWallet = walletManagersFacade.getOrCreateWalletManager(userWalletId, network)
|
||||
?: error("Wallet not found")
|
||||
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val isSecp256k1Blockchain = Blockchain.secp256k1Blockchains(network.isTestnet).contains(blockchain)
|
||||
val isHdKey = userWallet.wallet.publicKey.derivationType?.hdKey
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package com.tangem.domain.card
|
||||
|
||||
import arrow.core.Either
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.domain.common.util.hasDerivation
|
||||
import com.tangem.domain.models.network.Network
|
||||
import com.tangem.domain.models.scan.ScanResponse
|
||||
|
|
@ -9,7 +9,7 @@ import com.tangem.domain.models.scan.ScanResponse
|
|||
class NetworkHasDerivationUseCase {
|
||||
|
||||
operator fun invoke(scanResponse: ScanResponse, network: Network): Either<Throwable, Boolean> {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val derivationPath = network.derivationPath.value
|
||||
return Either.catch { derivationPath != null && scanResponse.hasDerivation(blockchain, derivationPath) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import com.tangem.blockchain.nft.models.NFTAsset
|
|||
import com.tangem.blockchain.nft.models.NFTCollection
|
||||
import com.tangem.blockchain.transactionhistory.models.TransactionHistoryRequest
|
||||
import com.tangem.blockchainsdk.BlockchainSDKFactory
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.crypto.hdWallet.DerivationPath
|
||||
import com.tangem.datasource.asset.loader.AssetLoader
|
||||
import com.tangem.datasource.local.userwallet.UserWalletsStore
|
||||
|
|
@ -78,7 +79,7 @@ class DefaultWalletManagersFacade(
|
|||
extraTokens: Set<CryptoCurrency.Token>,
|
||||
): UpdateWalletManagerResult {
|
||||
val userWallet = getUserWallet(userWalletId)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val derivationPath = network.derivationPath.value
|
||||
|
||||
return getAndUpdateWalletManager(userWallet, blockchain, derivationPath, extraTokens)
|
||||
|
|
@ -88,7 +89,7 @@ class DefaultWalletManagersFacade(
|
|||
if (networks.isEmpty()) return
|
||||
|
||||
val blockchainsToDerivationPaths = networks.map {
|
||||
Blockchain.fromId(it.rawId) to it.derivationPath.value
|
||||
it.toBlockchain() to it.derivationPath.value
|
||||
}
|
||||
|
||||
withContext(dispatchers.io) {
|
||||
|
|
@ -141,7 +142,7 @@ class DefaultWalletManagersFacade(
|
|||
withContext(dispatchers.io) {
|
||||
val walletManager = walletManagersStore.getSyncOrNull(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = Blockchain.fromId(network.rawId),
|
||||
blockchain = network.toBlockchain(),
|
||||
derivationPath = network.derivationPath.value,
|
||||
) ?: return@withContext
|
||||
|
||||
|
|
@ -158,7 +159,7 @@ class DefaultWalletManagersFacade(
|
|||
network: Network,
|
||||
): UpdateWalletManagerResult {
|
||||
val userWallet = getUserWallet(userWalletId)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val derivationPath = network.derivationPath.value
|
||||
|
||||
if (derivationPath != null && !userWallet.scanResponse.hasDerivation(blockchain, derivationPath)) {
|
||||
|
|
@ -181,7 +182,7 @@ class DefaultWalletManagersFacade(
|
|||
addressType: AddressType,
|
||||
contractAddress: String?,
|
||||
): String {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
network = network,
|
||||
|
|
@ -385,7 +386,7 @@ class DefaultWalletManagersFacade(
|
|||
|
||||
@Deprecated("Will be removed in future")
|
||||
override suspend fun getOrCreateWalletManager(userWalletId: UserWalletId, network: Network): WalletManager? {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
return getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -477,7 +478,7 @@ class DefaultWalletManagersFacade(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
): Result<TransactionFee>? = withContext(dispatchers.io) {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -566,7 +567,7 @@ class DefaultWalletManagersFacade(
|
|||
decimals: Int,
|
||||
id: String?,
|
||||
): BigDecimal {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -637,7 +638,7 @@ class DefaultWalletManagersFacade(
|
|||
}
|
||||
|
||||
override suspend fun checkUtxoConsolidationAvailability(userWalletId: UserWalletId, network: Network): Boolean {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -648,7 +649,7 @@ class DefaultWalletManagersFacade(
|
|||
}
|
||||
|
||||
override suspend fun getNFTCollections(userWalletId: UserWalletId, network: Network): List<NFTCollection> {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -663,7 +664,7 @@ class DefaultWalletManagersFacade(
|
|||
network: Network,
|
||||
collectionIdentifier: NFTCollection.Identifier,
|
||||
): List<NFTAsset> {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -679,7 +680,7 @@ class DefaultWalletManagersFacade(
|
|||
collectionIdentifier: NFTCollection.Identifier,
|
||||
assetIdentifier: NFTAsset.Identifier,
|
||||
): NFTAsset? {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -694,7 +695,7 @@ class DefaultWalletManagersFacade(
|
|||
collectionIdentifier: NFTCollection.Identifier,
|
||||
assetIdentifier: NFTAsset.Identifier,
|
||||
): NFTAsset.SalePrice? {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
val walletManager = getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -704,7 +705,7 @@ class DefaultWalletManagersFacade(
|
|||
}
|
||||
|
||||
override suspend fun getNFTExploreUrl(network: Network, assetIdentifier: NFTAsset.Identifier): String? {
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val blockchain = network.toBlockchain()
|
||||
return blockchain.getNFTExploreUrl(assetIdentifier)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.tangem.blockchain.common.smartcontract.SmartContractCallDataProviderF
|
|||
import com.tangem.blockchain.common.transaction.Fee
|
||||
import com.tangem.blockchain.common.transaction.TransactionFee
|
||||
import com.tangem.blockchainsdk.utils.fromNetworkId
|
||||
import com.tangem.blockchainsdk.utils.toBlockchain
|
||||
import com.tangem.core.ui.format.bigdecimal.fiat
|
||||
import com.tangem.core.ui.format.bigdecimal.format
|
||||
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
|
||||
|
|
@ -466,7 +467,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
is TxFeeState.MultipleFeeState -> feeState.normalFee.feeValue
|
||||
is TxFeeState.SingleFeeState -> feeState.fee.feeValue
|
||||
},
|
||||
blockchain = Blockchain.fromId(currency.network.rawId),
|
||||
blockchain = currency.network.toBlockchain(),
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -1387,7 +1388,7 @@ internal class SwapInteractorImpl @AssistedInject constructor(
|
|||
val callData = SmartContractCallDataProviderFactory.getApprovalCallData(
|
||||
spenderAddress = requireNotNull(spenderAddress) { "Spender address is null" },
|
||||
amount = swapAmount.value.convertToSdkAmount(fromToken),
|
||||
blockchain = Blockchain.fromId(fromToken.network.rawId),
|
||||
blockchain = fromToken.network.toBlockchain(),
|
||||
)
|
||||
val feeData = try {
|
||||
val extras = createTransactionExtrasUseCase(
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ dependencies {
|
|||
implementation(projects.core.analytics)
|
||||
// endregion
|
||||
|
||||
api(projects.domain.models)
|
||||
|
||||
// region AndroidX libraries
|
||||
implementation(deps.androidx.datastore)
|
||||
// endregion
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
package com.tangem.blockchainsdk.utils
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.domain.models.network.Network
|
||||
|
||||
/** Converts [Network] to [Blockchain] */
|
||||
fun Network.toBlockchain(): Blockchain = id.toBlockchain()
|
||||
|
||||
/** Converts [Network.ID] to [Blockchain] */
|
||||
fun Network.ID.toBlockchain(): Blockchain = Blockchain.fromId(id = rawId.value)
|
||||
Loading…
Add table
Add a link
Reference in a new issue