Updated on 2026-08-14
This commit is contained in:
parent
4aa6a9666b
commit
c3bfe301a5
11 changed files with 133 additions and 24 deletions
|
|
@ -1,24 +1,20 @@
|
|||
package com.tangem.data.walletmanager
|
||||
|
||||
import com.tangem.blockchain.common.Amount
|
||||
import com.tangem.blockchain.common.AmountType
|
||||
import com.tangem.blockchain.common.Token
|
||||
import com.tangem.blockchain.common.TransactionData
|
||||
import com.tangem.blockchain.common.TransactionStatus
|
||||
import com.tangem.blockchain.common.WalletManager
|
||||
import com.tangem.blockchain.common.*
|
||||
import com.tangem.blockchain.common.address.Address
|
||||
import com.tangem.blockchainsdk.models.UpdateWalletManagerResult
|
||||
import com.tangem.blockchainsdk.utils.amountToCreateAccount
|
||||
import com.tangem.data.walletmanager.utils.SdkAddressToAddressConverter
|
||||
import com.tangem.data.walletmanager.utils.TransactionDataToTxHistoryItemConverter
|
||||
import com.tangem.domain.models.currency.CryptoCurrency
|
||||
import com.tangem.domain.models.yield.supply.YieldSupplyStatus
|
||||
import timber.log.Timber
|
||||
import java.math.BigDecimal
|
||||
|
||||
/** Factory for creating [com.tangem.blockchainsdk.models.UpdateWalletManagerResult] */
|
||||
/** Factory for creating [UpdateWalletManagerResult] */
|
||||
internal class UpdateWalletManagerResultFactory {
|
||||
|
||||
/** Get [com.tangem.blockchainsdk.models.UpdateWalletManagerResult.Verified] result for [walletManager] */
|
||||
/** Get [UpdateWalletManagerResult.Verified] result for [walletManager] */
|
||||
fun getResult(walletManager: WalletManager): UpdateWalletManagerResult.Verified {
|
||||
val wallet = walletManager.wallet
|
||||
val addresses = getAvailableAddresses(wallet.addresses)
|
||||
|
|
@ -110,7 +106,7 @@ internal class UpdateWalletManagerResultFactory {
|
|||
is AmountType.Token -> {
|
||||
val value = getCurrencyAmountValue(amount) ?: return null
|
||||
|
||||
UpdateWalletManagerResult.CryptoCurrencyAmount.Token(
|
||||
UpdateWalletManagerResult.CryptoCurrencyAmount.Token.BasicToken(
|
||||
currencyRawId = type.token.id?.let(CryptoCurrency::RawID),
|
||||
contractAddress = type.token.contractAddress,
|
||||
value = value,
|
||||
|
|
@ -121,6 +117,20 @@ internal class UpdateWalletManagerResultFactory {
|
|||
|
||||
UpdateWalletManagerResult.CryptoCurrencyAmount.Coin(value = value)
|
||||
}
|
||||
is AmountType.TokenYieldSupply -> {
|
||||
val value = getCurrencyAmountValue(amount) ?: return null
|
||||
|
||||
UpdateWalletManagerResult.CryptoCurrencyAmount.Token.YieldSupplyToken(
|
||||
value = value,
|
||||
currencyRawId = type.token.id?.let(CryptoCurrency::RawID),
|
||||
contractAddress = type.token.contractAddress,
|
||||
yieldSupplyStatus = YieldSupplyStatus(
|
||||
isActive = type.isActive,
|
||||
isInitialized = type.isInitialized,
|
||||
isAllowedToSpend = type.isAllowedToSpend,
|
||||
),
|
||||
)
|
||||
}
|
||||
is AmountType.FeeResource,
|
||||
is AmountType.Reserve,
|
||||
-> null
|
||||
|
|
@ -147,7 +157,7 @@ internal class UpdateWalletManagerResultFactory {
|
|||
)
|
||||
|
||||
return tokens.mapTo(demoAmounts) { token ->
|
||||
UpdateWalletManagerResult.CryptoCurrencyAmount.Token(
|
||||
UpdateWalletManagerResult.CryptoCurrencyAmount.Token.BasicToken(
|
||||
currencyRawId = token.id?.let(CryptoCurrency::RawID),
|
||||
contractAddress = token.contractAddress,
|
||||
value = amountValue,
|
||||
|
|
@ -188,6 +198,15 @@ internal class UpdateWalletManagerResultFactory {
|
|||
txInfo = txHistoryItem,
|
||||
)
|
||||
}
|
||||
is AmountType.TokenYieldSupply -> {
|
||||
val txHistoryItem = txHistoryItemConverter.convert(data) ?: return null
|
||||
|
||||
UpdateWalletManagerResult.CryptoCurrencyTransaction.Token(
|
||||
tokenId = type.token.id,
|
||||
contractAddress = type.token.contractAddress,
|
||||
txInfo = txHistoryItem,
|
||||
)
|
||||
}
|
||||
is AmountType.FeeResource,
|
||||
is AmountType.Reserve,
|
||||
-> null
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue