Updated on 2026-08-14
This commit is contained in:
parent
33b7a53905
commit
c5560c3c6a
101 changed files with 274 additions and 272 deletions
|
|
@ -7,7 +7,7 @@ import com.tangem.domain.transaction.FeeRepository
|
|||
|
||||
internal class DefaultFeeRepository : FeeRepository {
|
||||
override fun isFeeApproximate(networkId: Network.ID, amountType: AmountType): Boolean {
|
||||
val blockchain = Blockchain.fromId(networkId.value)
|
||||
val blockchain = Blockchain.fromId(networkId.rawId.value)
|
||||
return blockchain.isFeeApproximate(amountType)
|
||||
}
|
||||
}
|
||||
|
|
@ -47,14 +47,14 @@ internal class DefaultTransactionRepository(
|
|||
network: Network,
|
||||
txExtras: TransactionExtras?,
|
||||
): TransactionData.Uncompiled = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
derivationPath = network.derivationPath.value,
|
||||
) ?: error("Wallet manager not found")
|
||||
|
||||
val extras = txExtras ?: getMemoExtras(networkId = network.id.value, memo)
|
||||
val extras = txExtras ?: getMemoExtras(networkId = network.rawId, memo)
|
||||
|
||||
return@withContext if (fee != null) {
|
||||
walletManager.createTransaction(
|
||||
|
|
@ -83,7 +83,7 @@ internal class DefaultTransactionRepository(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
): TransactionData.Uncompiled = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -115,14 +115,14 @@ internal class DefaultTransactionRepository(
|
|||
destination = destination,
|
||||
userWalletId = userWalletId,
|
||||
network = network,
|
||||
txExtras = getMemoExtras(networkId = network.id.value, memo = memo) ?: extras,
|
||||
txExtras = getMemoExtras(networkId = network.rawId, memo = memo) ?: extras,
|
||||
)
|
||||
} else {
|
||||
TransactionData.Uncompiled(
|
||||
amount = amount,
|
||||
sourceAddress = walletManager.wallet.address,
|
||||
destinationAddress = destination,
|
||||
extras = getMemoExtras(networkId = network.id.value, memo = memo) ?: extras,
|
||||
extras = getMemoExtras(networkId = network.rawId, memo = memo) ?: extras,
|
||||
fee = null,
|
||||
)
|
||||
}
|
||||
|
|
@ -137,7 +137,7 @@ internal class DefaultTransactionRepository(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
): TransactionData.Uncompiled = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
|
||||
val extras = createTransactionDataExtras(
|
||||
callData = SmartContractCallDataProviderFactory.getApprovalCallData(
|
||||
|
|
@ -170,7 +170,7 @@ internal class DefaultTransactionRepository(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
): TransactionData.Uncompiled = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
|
||||
// For now transfer one nft asset at a time
|
||||
val updatedNFTAsset = nftAsset.copy(
|
||||
|
|
@ -228,7 +228,7 @@ internal class DefaultTransactionRepository(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
): Result<Unit> = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val walletManager = walletManagersStore.getSyncOrNull(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -243,7 +243,7 @@ internal class DefaultTransactionRepository(
|
|||
fee = fee ?: Fee.Common(amount = amount),
|
||||
destination = destination,
|
||||
).copy(
|
||||
extras = getMemoExtras(networkId = network.id.value, memo = memo),
|
||||
extras = getMemoExtras(networkId = network.rawId, memo = memo),
|
||||
)
|
||||
|
||||
validator.validate(transactionData = transactionData)
|
||||
|
|
@ -259,7 +259,7 @@ internal class DefaultTransactionRepository(
|
|||
userWalletId: UserWalletId,
|
||||
network: Network,
|
||||
) = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -275,7 +275,7 @@ internal class DefaultTransactionRepository(
|
|||
network: Network,
|
||||
mode: TransactionSender.MultipleTransactionSendMode,
|
||||
) = withContext(coroutineDispatcherProvider.io) {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
@ -315,7 +315,7 @@ internal class DefaultTransactionRepository(
|
|||
spenderAddress: String,
|
||||
): BigDecimal {
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(userWalletId, cryptoCurrency.network)
|
||||
val blockchain = Blockchain.fromId(cryptoCurrency.network.id.value)
|
||||
val blockchain = Blockchain.fromId(cryptoCurrency.network.rawId)
|
||||
val allowanceResult = (walletManager as? Approver)?.getAllowance(
|
||||
spenderAddress,
|
||||
Token(
|
||||
|
|
@ -388,7 +388,7 @@ internal class DefaultTransactionRepository(
|
|||
}
|
||||
|
||||
private suspend fun getPreparer(network: Network, userWalletId: UserWalletId): TransactionPreparer {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
userWalletId = userWalletId,
|
||||
blockchain = blockchain,
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ class DefaultWalletAddressServiceRepository(
|
|||
|
||||
override suspend fun validateAddress(userWalletId: UserWalletId, network: Network, address: String): Boolean =
|
||||
withContext(dispatchers.io) {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
|
||||
if (blockchain.isNear()) {
|
||||
val walletManager = walletManagersFacade.getOrCreateWalletManager(
|
||||
|
|
@ -37,7 +37,7 @@ class DefaultWalletAddressServiceRepository(
|
|||
|
||||
override fun validateMemo(network: Network, memo: String): Boolean {
|
||||
if (memo.isEmpty()) return true
|
||||
return when (network.id.value) {
|
||||
return when (network.rawId) {
|
||||
Blockchain.XRP.id -> {
|
||||
val tag = memo.toLongOrNull()
|
||||
tag != null && tag <= XRP_TAG_MAX_NUMBER
|
||||
|
|
@ -50,7 +50,7 @@ class DefaultWalletAddressServiceRepository(
|
|||
}
|
||||
|
||||
override suspend fun parseSharedAddress(input: String, network: Network): ParsedQrCode {
|
||||
val blockchain = Blockchain.fromId(network.id.value)
|
||||
val blockchain = Blockchain.fromId(network.rawId)
|
||||
val addressSchemeSplit = when (blockchain) {
|
||||
Blockchain.BitcoinCash, Blockchain.Kaspa -> listOf(input)
|
||||
else -> input.split(":")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue