Updated on 2026-08-14
This commit is contained in:
commit
b2da68216a
501 changed files with 16767 additions and 5720 deletions
|
|
@ -0,0 +1,25 @@
|
|||
package com.tangem.data.walletmanager.utils
|
||||
|
||||
import com.tangem.domain.models.network.SdkAmount
|
||||
import com.tangem.domain.models.network.SdkAmountType
|
||||
import com.tangem.blockchain.common.Amount as BlockchainAmount
|
||||
import com.tangem.blockchain.common.AmountType as BlockchainAmountType
|
||||
|
||||
/** Maps the blockchain SDK [BlockchainAmount] to the serializable domain [SdkAmount]. */
|
||||
internal fun BlockchainAmount.toDomain(): SdkAmount = SdkAmount(
|
||||
currencySymbol = currencySymbol,
|
||||
value = value,
|
||||
decimals = decimals,
|
||||
type = type.toDomain(),
|
||||
)
|
||||
|
||||
private fun BlockchainAmountType.toDomain(): SdkAmountType = when (this) {
|
||||
BlockchainAmountType.Coin -> SdkAmountType.Coin
|
||||
BlockchainAmountType.Reserve -> SdkAmountType.Reserve
|
||||
is BlockchainAmountType.FeeResource -> SdkAmountType.FeeResource(name = name)
|
||||
is BlockchainAmountType.Token -> SdkAmountType.Token(contractAddress = token.contractAddress, id = token.id)
|
||||
is BlockchainAmountType.TokenYieldSupply -> SdkAmountType.Token(
|
||||
contractAddress = token.contractAddress,
|
||||
id = token.id,
|
||||
)
|
||||
}
|
||||
|
|
@ -32,6 +32,7 @@ internal class SdkTransactionHistoryItemConverter(
|
|||
},
|
||||
type = typeConverter.convert(value),
|
||||
amount = requireNotNull(value.amount.value) { "Transaction amount value must not be null" },
|
||||
fee = value.fee.toDomain(),
|
||||
)
|
||||
|
||||
private fun SdkTransactionHistoryItem.SourceType.toDomain(): TxInfo.SourceType = when (this) {
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ internal class TransactionDataToTxHistoryItemConverter(
|
|||
},
|
||||
type = getTransactionType(value),
|
||||
amount = amount,
|
||||
fee = value.fee?.amount?.toDomain(),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue