Updated on 2026-08-14

This commit is contained in:
Tangem 2025-12-02 12:23:56 +03:00
parent 87f642a653
commit e48ff5956d
24 changed files with 201 additions and 91 deletions

View file

@ -44,6 +44,7 @@ dependencies {
/** Libs */
implementation(projects.libs.blockchainSdk)
implementation(projects.libs.crypto)
/** Other */
implementation(deps.androidx.datastore)

View file

@ -1,12 +1,16 @@
package com.tangem.data.swap.converter.transaction
import com.tangem.blockchain.common.Blockchain
import com.tangem.blockchainsdk.utils.fromNetworkId
import com.tangem.data.common.currency.ResponseCryptoCurrenciesFactory
import com.tangem.data.swap.models.SwapStatusDTO
import com.tangem.data.swap.models.SwapTransactionDTO
import com.tangem.data.swap.models.SwapTxTypeDTO
import com.tangem.domain.models.account.DerivationIndex
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.swap.models.SwapTransactionModel
import com.tangem.domain.swap.models.SwapTxType
import com.tangem.lib.crypto.derivation.AccountNodeRecognizer
import com.tangem.utils.converter.TwoWayConverter
internal class SavedSwapTransactionConverter(
@ -48,9 +52,23 @@ internal class SavedSwapTransactionConverter(
): SwapTransactionModel {
val status = txStatuses[value.txId]
val refundCurrency = status?.refundTokensResponse?.let { id ->
val blockchain = Blockchain.fromNetworkId(id.networkId) ?: return@let null
val derivationPath = id.derivationPath ?: return@let null
val accountIndex = if (blockchain == Blockchain.Chia) {
DerivationIndex.Main
} else {
val recognizer = AccountNodeRecognizer(blockchain = blockchain)
val index = recognizer.recognize(derivationPathValue = derivationPath)?.toInt()
?: return@let null
DerivationIndex(index).getOrNull() ?: return@let null
}
responseCryptoCurrenciesFactory.createCurrency(
responseToken = id,
userWallet = userWallet,
accountIndex = accountIndex,
)
}
val statusWithRefundCurrency = status?.copy(refundCurrency = refundCurrency)

View file

@ -72,7 +72,11 @@ internal class SavedSwapTransactionListConverter(
return SwapTransactionListModel(
transactions = value.transactions.map { tx ->
savedSwapTransactionConverter.convertBack(tx, userWallet, txStatuses)
savedSwapTransactionConverter.convertBack(
value = tx,
userWallet = userWallet,
txStatuses = txStatuses,
)
},
userWalletId = value.userWalletId,
fromCryptoCurrencyId = value.fromCryptoCurrencyId,