Updated on 2026-08-14
This commit is contained in:
parent
db6157cae4
commit
99f62f79ee
35 changed files with 128 additions and 109 deletions
|
|
@ -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 tokenDerivation = network.derivationPath.value
|
||||
it.id == blockchain.toCoinId() && it.derivationPath == tokenDerivation
|
||||
}
|
||||
val coinId = network.toBlockchain().toCoinId()
|
||||
val tokenDerivation = network.derivationPath.value
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue