Updated on 2026-08-14
This commit is contained in:
parent
770fad5955
commit
e1aee494ef
14 changed files with 174 additions and 36 deletions
|
|
@ -1,10 +1,11 @@
|
|||
package com.tangem.tap.domain.model
|
||||
|
||||
import com.tangem.blockchain.common.TransactionData
|
||||
import com.tangem.blockchain.common.address.AddressType
|
||||
import com.tangem.tap.domain.model.WalletDataModel.AddressData
|
||||
import com.tangem.tap.domain.model.WalletDataModel.Status
|
||||
import com.tangem.tap.features.wallet.models.Currency
|
||||
import com.tangem.tap.features.wallet.models.PendingTransaction
|
||||
import com.tangem.tap.features.wallet.redux.AddressData
|
||||
import java.math.BigDecimal
|
||||
|
||||
/**
|
||||
|
|
@ -21,7 +22,8 @@ import java.math.BigDecimal
|
|||
data class WalletDataModel(
|
||||
val currency: Currency,
|
||||
val status: Status,
|
||||
val walletAddresses: List<AddressData>,
|
||||
// FIXME: Left only selected wallet address here and move list of wallet addresses to WalletStoreModel
|
||||
val walletAddresses: WalletAddresses?,
|
||||
val existentialDeposit: BigDecimal?,
|
||||
val fiatRate: BigDecimal?,
|
||||
val isCardSingleToken: Boolean,
|
||||
|
|
@ -29,6 +31,18 @@ data class WalletDataModel(
|
|||
val historyTransactions: List<TransactionData>?,
|
||||
) {
|
||||
|
||||
data class WalletAddresses(
|
||||
val selectedAddress: AddressData,
|
||||
val list: List<AddressData>,
|
||||
)
|
||||
|
||||
data class AddressData(
|
||||
val address: String,
|
||||
val type: AddressType,
|
||||
val shareUrl: String,
|
||||
val exploreUrl: String,
|
||||
)
|
||||
|
||||
/**
|
||||
* Represent current status of currency
|
||||
* @property amount Currency amount
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.tangem.tap.domain.tokens.models.BlockchainNetwork
|
|||
import com.tangem.tap.features.wallet.models.Currency
|
||||
import java.math.BigDecimal
|
||||
|
||||
// FIXME: Move list of wallet addresses from WalletDataModel to this class
|
||||
/**
|
||||
* Contains info about the blockchain and its currencies
|
||||
*
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.tangem.blockchain.blockchains.polkadot.ExistentialDepositProvider
|
|||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.DerivationStyle
|
||||
import com.tangem.blockchain.common.Token
|
||||
import com.tangem.blockchain.common.Wallet
|
||||
import com.tangem.blockchain.common.WalletManager
|
||||
import com.tangem.common.hdWallet.DerivationPath
|
||||
import com.tangem.domain.common.TapWorkarounds.derivationStyle
|
||||
|
|
@ -107,7 +108,7 @@ private fun BlockchainNetwork.getBlockchainWalletData(
|
|||
return WalletDataModel(
|
||||
currency = currency,
|
||||
status = WalletDataModel.Loading,
|
||||
walletAddresses = walletManager?.wallet?.createAddressesData().orEmpty(),
|
||||
walletAddresses = walletManager?.wallet?.getWalletAddresses(),
|
||||
existentialDeposit = getExistentialDeposit(walletManager),
|
||||
fiatRate = null,
|
||||
isCardSingleToken = false,
|
||||
|
|
@ -131,7 +132,7 @@ private fun BlockchainNetwork.getTokensWalletsData(
|
|||
WalletDataModel(
|
||||
currency = currency,
|
||||
status = WalletDataModel.Loading,
|
||||
walletAddresses = walletManager?.wallet?.createAddressesData().orEmpty(),
|
||||
walletAddresses = walletManager?.wallet?.getWalletAddresses(),
|
||||
existentialDeposit = getExistentialDeposit(walletManager),
|
||||
fiatRate = null,
|
||||
isCardSingleToken = token == primaryToken,
|
||||
|
|
@ -149,7 +150,7 @@ private fun Blockchain.toBlockchainWalletData(walletManager: WalletManager): Wal
|
|||
derivationPath = wallet.publicKey.derivationPath?.rawPath,
|
||||
),
|
||||
status = WalletDataModel.Loading,
|
||||
walletAddresses = wallet.createAddressesData(),
|
||||
walletAddresses = wallet.getWalletAddresses(),
|
||||
existentialDeposit = getExistentialDeposit(walletManager),
|
||||
fiatRate = null,
|
||||
isCardSingleToken = false,
|
||||
|
|
@ -167,7 +168,7 @@ private fun Token.toTokenWalletData(walletManager: WalletManager, primaryToken:
|
|||
derivationPath = wallet.publicKey.derivationPath?.rawPath,
|
||||
),
|
||||
status = WalletDataModel.Loading,
|
||||
walletAddresses = wallet.createAddressesData(),
|
||||
walletAddresses = wallet.getWalletAddresses(),
|
||||
existentialDeposit = getExistentialDeposit(walletManager),
|
||||
fiatRate = null,
|
||||
isCardSingleToken = this == primaryToken,
|
||||
|
|
@ -178,4 +179,19 @@ private fun Token.toTokenWalletData(walletManager: WalletManager, primaryToken:
|
|||
|
||||
private fun getExistentialDeposit(walletManager: WalletManager?): BigDecimal? {
|
||||
return (walletManager as? ExistentialDepositProvider)?.getExistentialDeposit()
|
||||
}
|
||||
|
||||
private fun Wallet.getWalletAddresses(): WalletDataModel.WalletAddresses? {
|
||||
return this.createAddressesData()
|
||||
.takeIf { it.isNotEmpty() }
|
||||
?.map {
|
||||
// TODO: Will be removed in next MR
|
||||
with(it) { WalletDataModel.AddressData(address, type, shareUrl, exploreUrl) }
|
||||
}
|
||||
?.let { addresses ->
|
||||
WalletDataModel.WalletAddresses(
|
||||
list = addresses,
|
||||
selectedAddress = addresses.first(),
|
||||
)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue