Updated on 2026-08-14
This commit is contained in:
parent
e33bd4d849
commit
b98b0f659c
138 changed files with 686 additions and 346 deletions
|
|
@ -15,6 +15,8 @@ import com.tangem.domain.models.network.Network
|
|||
import com.tangem.domain.models.scan.ScanResponse
|
||||
import com.tangem.domain.wallets.models.UserWallet
|
||||
import com.tangem.domain.wallets.models.UserWalletId
|
||||
import com.tangem.domain.wallets.models.isMultiCurrency
|
||||
import com.tangem.domain.wallets.models.requireColdWallet
|
||||
|
||||
/**
|
||||
* Default implementation of factory for creating list of [CryptoCurrency] for selected card
|
||||
|
|
@ -39,7 +41,7 @@ internal class DefaultCardCryptoCurrencyFactory(
|
|||
val blockchain = Blockchain.fromNetworkId(networkId = network.backendId)
|
||||
|
||||
// multi-currency wallet
|
||||
if (userWallet.isMultiCurrency) {
|
||||
if (userWallet !is UserWallet.Cold || userWallet.isMultiCurrency) {
|
||||
return getMultiWalletCurrencies(userWallet = userWallet, networks = setOf(network))[network].orEmpty()
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +64,7 @@ internal class DefaultCardCryptoCurrencyFactory(
|
|||
val blockchain = networkRawId.toBlockchain()
|
||||
|
||||
// multi-currency wallet
|
||||
if (userWallet.isMultiCurrency) {
|
||||
if (userWallet.isMultiCurrency || userWallet !is UserWallet.Cold) {
|
||||
return getMultiWalletCurrenciesByRawId(
|
||||
userWallet = userWallet,
|
||||
rawIds = setOf(networkRawId),
|
||||
|
|
@ -146,7 +148,7 @@ internal class DefaultCardCryptoCurrencyFactory(
|
|||
tokens = response.tokens.filter { token ->
|
||||
networks.any { it.backendId == token.networkId && it.derivationPath.value == token.derivationPath }
|
||||
},
|
||||
scanResponse = userWallet.scanResponse,
|
||||
scanResponse = userWallet.requireColdWallet().scanResponse, // TODO [REDACTED_TASK_KEY]
|
||||
)
|
||||
.groupBy(CryptoCurrency::network)
|
||||
}
|
||||
|
|
@ -164,7 +166,7 @@ internal class DefaultCardCryptoCurrencyFactory(
|
|||
|
||||
return responseCurrenciesFactory.createCurrencies(
|
||||
tokens = response.tokens.filter { token -> token.networkId in networkIds },
|
||||
scanResponse = userWallet.scanResponse,
|
||||
scanResponse = userWallet.requireColdWallet().scanResponse, // TODO [REDACTED_TASK_KEY]
|
||||
)
|
||||
.groupBy { it.network.id.rawId }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -333,7 +333,7 @@ internal class DefaultCardCryptoCurrencyFactoryTest {
|
|||
)
|
||||
}
|
||||
|
||||
data class CreateDefaultForMultiWalletModel(val multiWallet: UserWallet, val expected: List<CryptoCurrency>)
|
||||
data class CreateDefaultForMultiWalletModel(val multiWallet: UserWallet.Cold, val expected: List<CryptoCurrency>)
|
||||
|
||||
@Nested
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
|
|
@ -381,7 +381,7 @@ internal class DefaultCardCryptoCurrencyFactoryTest {
|
|||
}
|
||||
|
||||
data class CreatePrimaryCurrencyForSingleWalletModel(
|
||||
val singleWallet: UserWallet,
|
||||
val singleWallet: UserWallet.Cold,
|
||||
val expected: Result<CryptoCurrency>,
|
||||
)
|
||||
|
||||
|
|
@ -424,7 +424,7 @@ internal class DefaultCardCryptoCurrencyFactoryTest {
|
|||
|
||||
private fun provideTestModels() = listOf(
|
||||
CreateForSingleWalletWithTokenModel(
|
||||
singleWalletWithToken = UserWallet(
|
||||
singleWalletWithToken = UserWallet.Cold(
|
||||
name = "NODL",
|
||||
walletId = UserWalletId("011"),
|
||||
cardsInWallet = setOf(),
|
||||
|
|
@ -457,13 +457,13 @@ internal class DefaultCardCryptoCurrencyFactoryTest {
|
|||
}
|
||||
|
||||
data class CreateForSingleWalletWithTokenModel(
|
||||
val singleWalletWithToken: UserWallet,
|
||||
val singleWalletWithToken: UserWallet.Cold,
|
||||
val isPrimaryTokenExpected: Boolean = false,
|
||||
val expected: Result<List<CryptoCurrency>>,
|
||||
)
|
||||
|
||||
private fun createMultiWallet(cardId: String? = null, batchId: String? = null): UserWallet {
|
||||
return UserWallet(
|
||||
private fun createMultiWallet(cardId: String? = null, batchId: String? = null): UserWallet.Cold {
|
||||
return UserWallet.Cold(
|
||||
name = "Wallet 1",
|
||||
walletId = UserWalletId("011"),
|
||||
cardsInWallet = setOf(),
|
||||
|
|
@ -483,8 +483,8 @@ internal class DefaultCardCryptoCurrencyFactoryTest {
|
|||
)
|
||||
}
|
||||
|
||||
private fun createSingleWallet(batchId: String? = null, addWalletData: Boolean = false): UserWallet {
|
||||
return UserWallet(
|
||||
private fun createSingleWallet(batchId: String? = null, addWalletData: Boolean = false): UserWallet.Cold {
|
||||
return UserWallet.Cold(
|
||||
name = "Note",
|
||||
walletId = UserWalletId("011"),
|
||||
cardsInWallet = setOf(),
|
||||
|
|
@ -515,8 +515,8 @@ internal class DefaultCardCryptoCurrencyFactoryTest {
|
|||
)
|
||||
}
|
||||
|
||||
private fun createSingleWalletWithToken(): UserWallet {
|
||||
return UserWallet(
|
||||
private fun createSingleWalletWithToken(): UserWallet.Cold {
|
||||
return UserWallet.Cold(
|
||||
name = "NODL",
|
||||
walletId = UserWalletId("011"),
|
||||
cardsInWallet = setOf(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue