Updated on 2026-08-14
This commit is contained in:
parent
c9be7fa5c5
commit
d47433ee6c
24 changed files with 193 additions and 90 deletions
|
|
@ -44,6 +44,7 @@ dependencies {
|
|||
|
||||
/** Libs */
|
||||
implementation(projects.libs.blockchainSdk)
|
||||
implementation(projects.libs.crypto)
|
||||
|
||||
/** Other */
|
||||
implementation(deps.androidx.datastore)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue