Updated on 2026-08-14
This commit is contained in:
parent
d48eea4fb0
commit
a88a63d6ef
22 changed files with 95 additions and 37 deletions
|
|
@ -33,7 +33,7 @@ internal object CardDomainModule {
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
fun provideIsDemoCardUseCase(): IsDemoCardUseCase = IsDemoCardUseCase(config = DemoConfig())
|
fun provideIsDemoCardUseCase(): IsDemoCardUseCase = IsDemoCardUseCase(config = DemoConfig)
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@Singleton
|
@Singleton
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ internal object TransactionDomainModule {
|
||||||
fun provideGetFeeUseCase(walletManagersFacade: WalletManagersFacade): GetFeeUseCase {
|
fun provideGetFeeUseCase(walletManagersFacade: WalletManagersFacade): GetFeeUseCase {
|
||||||
return GetFeeUseCase(
|
return GetFeeUseCase(
|
||||||
walletManagersFacade = walletManagersFacade,
|
walletManagersFacade = walletManagersFacade,
|
||||||
demoConfig = DemoConfig(),
|
demoConfig = DemoConfig,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ internal object TransactionDomainModule {
|
||||||
tangemHotWalletSignerFactory: TangemHotWalletSigner.Factory,
|
tangemHotWalletSignerFactory: TangemHotWalletSigner.Factory,
|
||||||
): SendTransactionUseCase {
|
): SendTransactionUseCase {
|
||||||
return SendTransactionUseCase(
|
return SendTransactionUseCase(
|
||||||
demoConfig = DemoConfig(),
|
demoConfig = DemoConfig,
|
||||||
cardSdkConfigRepository = cardSdkConfigRepository,
|
cardSdkConfigRepository = cardSdkConfigRepository,
|
||||||
transactionRepository = transactionRepository,
|
transactionRepository = transactionRepository,
|
||||||
walletManagersFacade = walletManagersFacade,
|
walletManagersFacade = walletManagersFacade,
|
||||||
|
|
@ -126,7 +126,7 @@ internal object TransactionDomainModule {
|
||||||
fun provideEstimateFeeUseCase(walletManagersFacade: WalletManagersFacade): EstimateFeeUseCase {
|
fun provideEstimateFeeUseCase(walletManagersFacade: WalletManagersFacade): EstimateFeeUseCase {
|
||||||
return EstimateFeeUseCase(
|
return EstimateFeeUseCase(
|
||||||
walletManagersFacade = walletManagersFacade,
|
walletManagersFacade = walletManagersFacade,
|
||||||
demoConfig = DemoConfig(),
|
demoConfig = DemoConfig,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,10 +14,11 @@ import com.tangem.common.map
|
||||||
import com.tangem.crypto.bip39.Mnemonic
|
import com.tangem.crypto.bip39.Mnemonic
|
||||||
import com.tangem.crypto.hdWallet.DerivationPath
|
import com.tangem.crypto.hdWallet.DerivationPath
|
||||||
import com.tangem.domain.card.CardTypesResolver
|
import com.tangem.domain.card.CardTypesResolver
|
||||||
import com.tangem.domain.wallets.derivations.DerivationStyleProvider
|
|
||||||
import com.tangem.domain.card.common.TapWorkarounds.isTestCard
|
import com.tangem.domain.card.common.TapWorkarounds.isTestCard
|
||||||
import com.tangem.domain.card.configs.CardConfig
|
import com.tangem.domain.card.configs.CardConfig
|
||||||
|
import com.tangem.domain.demo.models.DemoConfig
|
||||||
import com.tangem.domain.models.scan.CardDTO
|
import com.tangem.domain.models.scan.CardDTO
|
||||||
|
import com.tangem.domain.wallets.derivations.DerivationStyleProvider
|
||||||
import com.tangem.operations.backup.PrimaryCard
|
import com.tangem.operations.backup.PrimaryCard
|
||||||
import com.tangem.operations.backup.StartPrimaryCardLinkingCommand
|
import com.tangem.operations.backup.StartPrimaryCardLinkingCommand
|
||||||
import com.tangem.operations.derivation.DeriveMultipleWalletPublicKeysTask
|
import com.tangem.operations.derivation.DeriveMultipleWalletPublicKeysTask
|
||||||
|
|
@ -60,7 +61,13 @@ class CreateProductWalletTask(
|
||||||
val cardDto = CardDTO(card)
|
val cardDto = CardDTO(card)
|
||||||
|
|
||||||
val commandProcessor = when {
|
val commandProcessor = when {
|
||||||
cardTypesResolver.isTangemNote() -> CreateWalletTangemNote(cardTypesResolver)
|
/**
|
||||||
|
* @workaround isDemoNoteAsMultiwallet
|
||||||
|
* There were produced 20k Note demo cards that should work like multiwallet (except Onboarding)
|
||||||
|
* for that reasons we've just added some specific checks for their BatchId
|
||||||
|
*/
|
||||||
|
DemoConfig.isDemoNoteAsMultiwallet(card.cardId) || cardTypesResolver.isTangemNote() ->
|
||||||
|
CreateWalletTangemNote(cardTypesResolver)
|
||||||
cardTypesResolver.isTangemTwins() ->
|
cardTypesResolver.isTangemTwins() ->
|
||||||
throw UnsupportedOperationException("Use the TwinCardsManager to create a wallet")
|
throw UnsupportedOperationException("Use the TwinCardsManager to create a wallet")
|
||||||
|
|
||||||
|
|
@ -374,7 +381,7 @@ private class CreateWalletTangemWallet(
|
||||||
|
|
||||||
private fun getBlockchains(cardId: String, card: CardDTO): List<Blockchain> {
|
private fun getBlockchains(cardId: String, card: CardDTO): List<Blockchain> {
|
||||||
return when {
|
return when {
|
||||||
DemoHelper.isDemoCardId(cardId) -> DemoHelper.config.demoBlockchains.toList()
|
DemoHelper.isDemoCardId(cardId) -> DemoHelper.config.getDemoBlockchains(cardId).toList()
|
||||||
card.isTestCard -> listOf(Blockchain.BitcoinTestnet, Blockchain.EthereumTestnet)
|
card.isTestCard -> listOf(Blockchain.BitcoinTestnet, Blockchain.EthereumTestnet)
|
||||||
else -> listOf(Blockchain.Bitcoin, Blockchain.Ethereum)
|
else -> listOf(Blockchain.Bitcoin, Blockchain.Ethereum)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ internal class DerivationsFinder(
|
||||||
getBlockchains(userWalletId)
|
getBlockchains(userWalletId)
|
||||||
}.ifEmpty {
|
}.ifEmpty {
|
||||||
if (DemoHelper.isDemoCardId(card.cardId)) {
|
if (DemoHelper.isDemoCardId(card.cardId)) {
|
||||||
getDemoBlockchains(derivationStyle)
|
getDemoBlockchains(derivationStyle, card.cardId)
|
||||||
} else {
|
} else {
|
||||||
getDefaultBlockchains(derivationStyle)
|
getDefaultBlockchains(derivationStyle)
|
||||||
}
|
}
|
||||||
|
|
@ -77,8 +77,8 @@ internal class DerivationsFinder(
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move to user wallet config
|
// TODO: Move to user wallet config
|
||||||
private fun getDemoBlockchains(derivationStyle: DerivationStyle?): MutableSet<BlockchainToDerive> {
|
private fun getDemoBlockchains(derivationStyle: DerivationStyle?, cardId: String): MutableSet<BlockchainToDerive> {
|
||||||
return DemoHelper.config.demoBlockchains.mapToBlockchainsWithDerivations(derivationStyle)
|
return DemoHelper.config.getDemoBlockchains(cardId).mapToBlockchainsWithDerivations(derivationStyle)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move to user wallet config
|
// TODO: Move to user wallet config
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import com.tangem.domain.models.scan.ScanResponse
|
||||||
import com.tangem.tap.common.redux.AppState
|
import com.tangem.tap.common.redux.AppState
|
||||||
|
|
||||||
object DemoHelper {
|
object DemoHelper {
|
||||||
val config = DemoConfig()
|
val config = DemoConfig
|
||||||
|
|
||||||
fun isDemoCard(scanResponse: ScanResponse): Boolean = isDemoCardId(scanResponse.card.cardId)
|
fun isDemoCard(scanResponse: ScanResponse): Boolean = isDemoCardId(scanResponse.card.cardId)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ class UserTokensResponseFactory @Inject constructor() {
|
||||||
accountId: AccountId?,
|
accountId: AccountId?,
|
||||||
): UserTokensResponse {
|
): UserTokensResponse {
|
||||||
val tokens = userWallet?.let {
|
val tokens = userWallet?.let {
|
||||||
getDefaultWalletBlockchains(userWallet = it, demoConfig = DemoConfig())
|
getDefaultWalletBlockchains(userWallet = it, demoConfig = DemoConfig)
|
||||||
.map { blockchain ->
|
.map { blockchain ->
|
||||||
val derivationPath = networkFactory.createDerivationPath(
|
val derivationPath = networkFactory.createDerivationPath(
|
||||||
blockchain = blockchain,
|
blockchain = blockchain,
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ internal object DataCommonModule {
|
||||||
responseCryptoCurrenciesFactory: ResponseCryptoCurrenciesFactory,
|
responseCryptoCurrenciesFactory: ResponseCryptoCurrenciesFactory,
|
||||||
): CardCryptoCurrencyFactory {
|
): CardCryptoCurrencyFactory {
|
||||||
return DefaultCardCryptoCurrencyFactory(
|
return DefaultCardCryptoCurrencyFactory(
|
||||||
demoConfig = DemoConfig(),
|
demoConfig = DemoConfig,
|
||||||
excludedBlockchains = excludedBlockchains,
|
excludedBlockchains = excludedBlockchains,
|
||||||
userWalletsStore = userWalletsStore,
|
userWalletsStore = userWalletsStore,
|
||||||
accountsFeatureToggles = accountsFeatureToggles,
|
accountsFeatureToggles = accountsFeatureToggles,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ fun getDefaultWalletBlockchains(userWallet: UserWallet, demoConfig: DemoConfig):
|
||||||
val card = userWallet.scanResponse.card
|
val card = userWallet.scanResponse.card
|
||||||
|
|
||||||
var blockchainsInternal = if (demoConfig.isDemoCardId(card.cardId)) {
|
var blockchainsInternal = if (demoConfig.isDemoCardId(card.cardId)) {
|
||||||
demoConfig.demoBlockchains
|
demoConfig.getDemoBlockchains(card.cardId)
|
||||||
} else {
|
} else {
|
||||||
listOf(Blockchain.Bitcoin, Blockchain.Ethereum)
|
listOf(Blockchain.Bitcoin, Blockchain.Ethereum)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ internal class DefaultCardCryptoCurrencyFactoryTest {
|
||||||
private val walletAccountsFetcher = mockk<WalletAccountsFetcher>()
|
private val walletAccountsFetcher = mockk<WalletAccountsFetcher>()
|
||||||
|
|
||||||
private val factory = DefaultCardCryptoCurrencyFactory(
|
private val factory = DefaultCardCryptoCurrencyFactory(
|
||||||
demoConfig = DemoConfig(),
|
demoConfig = DemoConfig,
|
||||||
excludedBlockchains = excludedBlockchains,
|
excludedBlockchains = excludedBlockchains,
|
||||||
userWalletsStore = userWalletsStore,
|
userWalletsStore = userWalletsStore,
|
||||||
userTokensResponseStore = userTokensResponseStore,
|
userTokensResponseStore = userTokensResponseStore,
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ internal class MultiWalletCryptoCurrenciesFetcherModule {
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
DefaultMultiWalletCryptoCurrenciesFetcher(
|
DefaultMultiWalletCryptoCurrenciesFetcher(
|
||||||
demoConfig = DemoConfig(),
|
demoConfig = DemoConfig,
|
||||||
userWalletsStore = userWalletsStore,
|
userWalletsStore = userWalletsStore,
|
||||||
tangemTechApi = tangemTechApi,
|
tangemTechApi = tangemTechApi,
|
||||||
customTokensMerger = CustomTokensMerger(
|
customTokensMerger = CustomTokensMerger(
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ internal class DefaultCurrenciesRepository(
|
||||||
excludedBlockchains: ExcludedBlockchains,
|
excludedBlockchains: ExcludedBlockchains,
|
||||||
) : CurrenciesRepository {
|
) : CurrenciesRepository {
|
||||||
|
|
||||||
private val demoConfig = DemoConfig()
|
private val demoConfig = DemoConfig
|
||||||
private val cryptoCurrencyFactory = CryptoCurrencyFactory(excludedBlockchains)
|
private val cryptoCurrencyFactory = CryptoCurrencyFactory(excludedBlockchains)
|
||||||
private val userTokensResponseFactory = UserTokensResponseFactory()
|
private val userTokensResponseFactory = UserTokensResponseFactory()
|
||||||
private val customTokensMerger = CustomTokensMerger(
|
private val customTokensMerger = CustomTokensMerger(
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ internal class DefaultMultiWalletCryptoCurrenciesFetcherTest {
|
||||||
private val expressServiceFetcher: ExpressServiceFetcher = mockk(relaxUnitFun = true)
|
private val expressServiceFetcher: ExpressServiceFetcher = mockk(relaxUnitFun = true)
|
||||||
|
|
||||||
private val fetcher = DefaultMultiWalletCryptoCurrenciesFetcher(
|
private val fetcher = DefaultMultiWalletCryptoCurrenciesFetcher(
|
||||||
demoConfig = DemoConfig(),
|
demoConfig = DemoConfig,
|
||||||
userWalletsStore = userWalletsStore,
|
userWalletsStore = userWalletsStore,
|
||||||
tangemTechApi = tangemTechApi,
|
tangemTechApi = tangemTechApi,
|
||||||
customTokensMerger = customTokensMerger,
|
customTokensMerger = customTokensMerger,
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ internal object TransactionDataModule {
|
||||||
fun providesFeeRepository(walletManagersFacade: WalletManagersFacade): FeeRepository {
|
fun providesFeeRepository(walletManagersFacade: WalletManagersFacade): FeeRepository {
|
||||||
return DefaultFeeRepository(
|
return DefaultFeeRepository(
|
||||||
walletManagersFacade,
|
walletManagersFacade,
|
||||||
demoConfig = DemoConfig(),
|
demoConfig = DemoConfig,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,7 @@ internal class DefaultWalletManagersFacade @Inject constructor(
|
||||||
blockchainSDKFactory: BlockchainSDKFactory,
|
blockchainSDKFactory: BlockchainSDKFactory,
|
||||||
) : WalletManagersFacade {
|
) : WalletManagersFacade {
|
||||||
|
|
||||||
private val demoConfig by lazy { DemoConfig() }
|
private val demoConfig by lazy { DemoConfig }
|
||||||
private val resultFactory by lazy { UpdateWalletManagerResultFactory() }
|
private val resultFactory by lazy { UpdateWalletManagerResultFactory() }
|
||||||
private val walletManagerFactory by lazy { WalletManagerFactory(blockchainSDKFactory) }
|
private val walletManagerFactory by lazy { WalletManagerFactory(blockchainSDKFactory) }
|
||||||
private val sdkTokenConverter by lazy { SdkTokenConverter() }
|
private val sdkTokenConverter by lazy { SdkTokenConverter() }
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.tangem.domain.card
|
package com.tangem.domain.card
|
||||||
|
|
||||||
import com.tangem.blockchain.common.Blockchain
|
import com.tangem.blockchain.common.Blockchain
|
||||||
import com.tangem.blockchain.common.Blockchain.Companion.fromId
|
|
||||||
import com.tangem.blockchain.common.Token
|
import com.tangem.blockchain.common.Token
|
||||||
import com.tangem.common.card.EllipticCurve
|
import com.tangem.common.card.EllipticCurve
|
||||||
import com.tangem.common.card.FirmwareVersion
|
import com.tangem.common.card.FirmwareVersion
|
||||||
|
|
@ -12,6 +11,7 @@ import com.tangem.domain.card.common.TapWorkarounds.isTestCard
|
||||||
import com.tangem.domain.card.common.TapWorkarounds.isWallet2
|
import com.tangem.domain.card.common.TapWorkarounds.isWallet2
|
||||||
import com.tangem.domain.card.common.getTwinCardIdForUser
|
import com.tangem.domain.card.common.getTwinCardIdForUser
|
||||||
import com.tangem.domain.card.common.visa.VisaUtilities
|
import com.tangem.domain.card.common.visa.VisaUtilities
|
||||||
|
import com.tangem.domain.demo.models.DemoConfig
|
||||||
import com.tangem.domain.models.scan.CardDTO
|
import com.tangem.domain.models.scan.CardDTO
|
||||||
import com.tangem.domain.models.scan.ProductType
|
import com.tangem.domain.models.scan.ProductType
|
||||||
import com.tangem.operations.attestation.Attestation
|
import com.tangem.operations.attestation.Attestation
|
||||||
|
|
@ -23,7 +23,16 @@ internal class TangemCardTypesResolver(
|
||||||
private val walletData: WalletData?,
|
private val walletData: WalletData?,
|
||||||
) : CardTypesResolver {
|
) : CardTypesResolver {
|
||||||
|
|
||||||
override fun isTangemNote(): Boolean = productType == ProductType.Note
|
override fun isTangemNote(): Boolean {
|
||||||
|
val isNote = productType == ProductType.Note
|
||||||
|
/**
|
||||||
|
* @workaround
|
||||||
|
* There were produced 20k Note demo cards that should work like multiwallet (except Onboarding)
|
||||||
|
* for that reasons we've just added some specific checks for their BatchId
|
||||||
|
*/
|
||||||
|
val isNotDemoNoteAsMulti = !DemoConfig.isDemoNoteAsMultiwallet(card.cardId)
|
||||||
|
return isNote && isNotDemoNoteAsMulti
|
||||||
|
}
|
||||||
|
|
||||||
override fun isTangemWallet(): Boolean {
|
override fun isTangemWallet(): Boolean {
|
||||||
return card.settings.isBackupAllowed && card.settings.isHDWalletAllowed &&
|
return card.settings.isBackupAllowed && card.settings.isHDWalletAllowed &&
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@ object TapWorkarounds {
|
||||||
private const val TEST_CARD_BATCH = "99FF"
|
private const val TEST_CARD_BATCH = "99FF"
|
||||||
private const val TEST_CARD_ID_STARTS_WITH = "FF99"
|
private const val TEST_CARD_ID_STARTS_WITH = "FF99"
|
||||||
private val backupRequiredFirmwareVersion = FirmwareVersion(major = 6, minor = 21)
|
private val backupRequiredFirmwareVersion = FirmwareVersion(major = 6, minor = 21)
|
||||||
private val demoConfig = DemoConfig()
|
|
||||||
|
|
||||||
val CardDTO.isTangemTwins: Boolean
|
val CardDTO.isTangemTwins: Boolean
|
||||||
get() = TwinsHelper.getTwinCardNumber(cardId) != null
|
get() = TwinsHelper.getTwinCardNumber(cardId) != null
|
||||||
|
|
@ -34,7 +33,7 @@ object TapWorkarounds {
|
||||||
|
|
||||||
// for cards 6.21 and higher backup is not skippable
|
// for cards 6.21 and higher backup is not skippable
|
||||||
val CardDTO.canSkipBackup: Boolean
|
val CardDTO.canSkipBackup: Boolean
|
||||||
get() = this.firmwareVersion < backupRequiredFirmwareVersion || demoConfig.isDemoCardId(cardId)
|
get() = this.firmwareVersion < backupRequiredFirmwareVersion || DemoConfig.isDemoCardId(cardId)
|
||||||
|
|
||||||
val CardDTO.hasOldStyleDerivation: Boolean
|
val CardDTO.hasOldStyleDerivation: Boolean
|
||||||
get() = batchId == "AC01" || batchId == "AC02" || batchId == "CB95"
|
get() = batchId == "AC01" || batchId == "AC02" || batchId == "CB95"
|
||||||
|
|
|
||||||
|
|
@ -5,15 +5,28 @@ import com.tangem.blockchain.common.Blockchain
|
||||||
import java.math.BigDecimal
|
import java.math.BigDecimal
|
||||||
|
|
||||||
@Suppress("LargeClass")
|
@Suppress("LargeClass")
|
||||||
class DemoConfig {
|
object DemoConfig {
|
||||||
|
|
||||||
val demoBlockchains = setOf(
|
/**
|
||||||
|
* @workaround
|
||||||
|
* There were produced 20k Note demo cards that should work like multiwallet (except Onboarding)
|
||||||
|
* for that reasons we've just added some specific checks for their BatchId
|
||||||
|
*/
|
||||||
|
private const val DEMO_NOTE_AS_MILTIWALLET_BATCH = "DE00"
|
||||||
|
|
||||||
|
private val demoBlockchains = setOf(
|
||||||
Blockchain.Bitcoin,
|
Blockchain.Bitcoin,
|
||||||
Blockchain.Ethereum,
|
Blockchain.Ethereum,
|
||||||
Blockchain.Dogecoin,
|
Blockchain.Dogecoin,
|
||||||
Blockchain.Solana,
|
Blockchain.Solana,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val demoBlockchainsSecpOnly = setOf(
|
||||||
|
Blockchain.Bitcoin,
|
||||||
|
Blockchain.Ethereum,
|
||||||
|
Blockchain.Dogecoin,
|
||||||
|
)
|
||||||
|
|
||||||
private val demoCardIds: List<String> by lazy {
|
private val demoCardIds: List<String> by lazy {
|
||||||
val demoIds = getReleaseIds().toMutableList()
|
val demoIds = getReleaseIds().toMutableList()
|
||||||
if (BuildConfig.DEBUG) demoIds.addAll(debugTestDemoCardIds)
|
if (BuildConfig.DEBUG) demoIds.addAll(debugTestDemoCardIds)
|
||||||
|
|
@ -28,13 +41,26 @@ class DemoConfig {
|
||||||
Blockchain.Solana to Amount(13.246.toBigDecimal(), Blockchain.Solana),
|
Blockchain.Solana to Amount(13.246.toBigDecimal(), Blockchain.Solana),
|
||||||
)
|
)
|
||||||
|
|
||||||
fun isDemoCardId(cardId: String): Boolean = demoCardIds.contains(cardId)
|
fun isDemoCardId(cardId: String): Boolean = demoCardIds.contains(cardId) ||
|
||||||
|
cardId.startsWith(DEMO_NOTE_AS_MILTIWALLET_BATCH)
|
||||||
|
|
||||||
fun isTestDemoCardId(cardId: String): Boolean = testDemoCardIds.contains(cardId)
|
fun isTestDemoCardId(cardId: String): Boolean = testDemoCardIds.contains(cardId)
|
||||||
|
|
||||||
fun getBalance(blockchain: Blockchain): Amount = walletBalances[blockchain]?.copy()
|
fun getBalance(blockchain: Blockchain): Amount = walletBalances[blockchain]?.copy()
|
||||||
?: Amount(BigDecimal.ZERO, blockchain).copy()
|
?: Amount(BigDecimal.ZERO, blockchain).copy()
|
||||||
|
|
||||||
|
fun isDemoNoteAsMultiwallet(cardId: String): Boolean {
|
||||||
|
return cardId.startsWith(DEMO_NOTE_AS_MILTIWALLET_BATCH)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getDemoBlockchains(cardId: String): Set<Blockchain> {
|
||||||
|
return if (cardId.startsWith(DEMO_NOTE_AS_MILTIWALLET_BATCH)) {
|
||||||
|
demoBlockchainsSecpOnly
|
||||||
|
} else {
|
||||||
|
demoBlockchains
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getReleaseIds(): List<String> {
|
private fun getReleaseIds(): List<String> {
|
||||||
return (releaseDemoCardIds + testDemoCardIds).distinct()
|
return (releaseDemoCardIds + testDemoCardIds).distinct()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ dependencies {
|
||||||
implementation(projects.domain.tokens.models)
|
implementation(projects.domain.tokens.models)
|
||||||
implementation(projects.domain.wallets.models)
|
implementation(projects.domain.wallets.models)
|
||||||
implementation(projects.domain.notifications.models)
|
implementation(projects.domain.notifications.models)
|
||||||
|
implementation(projects.domain.demo.models)
|
||||||
// endregion
|
// endregion
|
||||||
|
|
||||||
// region Tangem libraries
|
// region Tangem libraries
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.tangem.domain.wallets.builder
|
package com.tangem.domain.wallets.builder
|
||||||
|
|
||||||
import com.tangem.domain.card.common.util.cardTypesResolver
|
import com.tangem.domain.card.common.util.cardTypesResolver
|
||||||
import com.tangem.domain.models.scan.CardDTO
|
|
||||||
import com.tangem.domain.models.scan.ScanResponse
|
import com.tangem.domain.models.scan.ScanResponse
|
||||||
import com.tangem.domain.models.wallet.UserWallet
|
import com.tangem.domain.models.wallet.UserWallet
|
||||||
import com.tangem.domain.wallets.usecase.GenerateWalletNameUseCase
|
import com.tangem.domain.wallets.usecase.GenerateWalletNameUseCase
|
||||||
|
|
@ -16,9 +15,6 @@ class ColdUserWalletBuilder @AssistedInject constructor(
|
||||||
private var backupCardsIds: Set<String> = emptySet()
|
private var backupCardsIds: Set<String> = emptySet()
|
||||||
private var hasBackupError: Boolean = false
|
private var hasBackupError: Boolean = false
|
||||||
|
|
||||||
private val CardDTO.isBackupNotAllowed: Boolean
|
|
||||||
get() = !settings.isBackupAllowed
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DANGEROUS!!!
|
* DANGEROUS!!!
|
||||||
* [backupCardsIds] will be non-empty list if card is backed up on current device.
|
* [backupCardsIds] will be non-empty list if card is backed up on current device.
|
||||||
|
|
@ -44,8 +40,8 @@ class ColdUserWalletBuilder @AssistedInject constructor(
|
||||||
UserWallet.Cold(
|
UserWallet.Cold(
|
||||||
walletId = it,
|
walletId = it,
|
||||||
name = generateWalletNameUseCase(
|
name = generateWalletNameUseCase(
|
||||||
|
card = card,
|
||||||
productType = productType,
|
productType = productType,
|
||||||
isBackupNotAllowed = card.isBackupNotAllowed,
|
|
||||||
isStartToCoin = cardTypesResolver.isStart2Coin(),
|
isStartToCoin = cardTypesResolver.isStart2Coin(),
|
||||||
),
|
),
|
||||||
cardsInWallet = backupCardsIds.plus(card.cardId),
|
cardsInWallet = backupCardsIds.plus(card.cardId),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.tangem.domain.wallets.usecase
|
package com.tangem.domain.wallets.usecase
|
||||||
|
|
||||||
|
import com.tangem.domain.models.scan.CardDTO
|
||||||
|
import com.tangem.domain.demo.models.DemoConfig
|
||||||
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
import com.tangem.domain.common.wallets.UserWalletsListRepository
|
||||||
import com.tangem.domain.common.wallets.requireUserWalletsSync
|
import com.tangem.domain.common.wallets.requireUserWalletsSync
|
||||||
import com.tangem.domain.models.scan.ProductType
|
import com.tangem.domain.models.scan.ProductType
|
||||||
|
|
@ -14,10 +16,14 @@ class GenerateWalletNameUseCase(
|
||||||
private val useNewRepository: Boolean,
|
private val useNewRepository: Boolean,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
operator fun invoke(productType: ProductType, isBackupNotAllowed: Boolean, isStartToCoin: Boolean): String {
|
private val CardDTO.isBackupNotAllowed: Boolean
|
||||||
|
get() = !settings.isBackupAllowed
|
||||||
|
|
||||||
|
operator fun invoke(productType: ProductType, card: CardDTO, isStartToCoin: Boolean): String {
|
||||||
val defaultName = getDefaultName(
|
val defaultName = getDefaultName(
|
||||||
productType = productType,
|
productType = productType,
|
||||||
isBackupNotAllowed = isBackupNotAllowed,
|
card = card,
|
||||||
|
isBackupNotAllowed = card.isBackupNotAllowed,
|
||||||
isStartToCoin = isStartToCoin,
|
isStartToCoin = isStartToCoin,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -55,7 +61,20 @@ class GenerateWalletNameUseCase(
|
||||||
return defaultName
|
return defaultName
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDefaultName(productType: ProductType, isBackupNotAllowed: Boolean, isStartToCoin: Boolean): String {
|
private fun getDefaultName(
|
||||||
|
productType: ProductType,
|
||||||
|
card: CardDTO,
|
||||||
|
isBackupNotAllowed: Boolean,
|
||||||
|
isStartToCoin: Boolean,
|
||||||
|
): String {
|
||||||
|
/**
|
||||||
|
* @workaround
|
||||||
|
* There were produced 20k Note demo cards that should work like multiwallet (except Onboarding)
|
||||||
|
* for that reasons we've just added some specific checks for their BatchId
|
||||||
|
*/
|
||||||
|
if (DemoConfig.isDemoNoteAsMultiwallet(card.cardId)) {
|
||||||
|
return "Wallet"
|
||||||
|
}
|
||||||
return when (productType) {
|
return when (productType) {
|
||||||
ProductType.Note -> "Note"
|
ProductType.Note -> "Note"
|
||||||
ProductType.Twins -> "Twin"
|
ProductType.Twins -> "Twin"
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class HasSingleWalletSignedHashesUseCase @Inject constructor(
|
||||||
|
|
||||||
private fun UserWallet.Cold.isCorrectCardType(): Boolean {
|
private fun UserWallet.Cold.isCorrectCardType(): Boolean {
|
||||||
return with(scanResponse.cardTypesResolver) {
|
return with(scanResponse.cardTypesResolver) {
|
||||||
!DemoConfig().isDemoCardId(cardId) && isReleaseFirmwareType() && !isMultiwalletAllowed() && !isTangemTwins()
|
!DemoConfig.isDemoCardId(cardId) && isReleaseFirmwareType() && !isMultiwalletAllowed() && !isTangemTwins()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -52,6 +52,7 @@ internal class WalletImageResolver @Inject constructor(
|
||||||
cardTypesResolver.isTangemTwins() -> R.drawable.ill_twins_120_106
|
cardTypesResolver.isTangemTwins() -> R.drawable.ill_twins_120_106
|
||||||
cardTypesResolver.isStart2Coin() -> R.drawable.ill_start2coin_120_106
|
cardTypesResolver.isStart2Coin() -> R.drawable.ill_start2coin_120_106
|
||||||
cardTypesResolver.isTangemNote() -> noteImage?.imageResId
|
cardTypesResolver.isTangemNote() -> noteImage?.imageResId
|
||||||
|
DemoConfig.isDemoNoteAsMultiwallet(userWallet.cardId) -> R.drawable.ill_wallet2_cards2_120_106
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +85,7 @@ internal class WalletImageResolver @Inject constructor(
|
||||||
@DrawableRes twoBackupResId: Int = R.drawable.ill_wallet2_cards3_120_106,
|
@DrawableRes twoBackupResId: Int = R.drawable.ill_wallet2_cards3_120_106,
|
||||||
): Int? {
|
): Int? {
|
||||||
return resolveWalletWithBackups { count ->
|
return resolveWalletWithBackups { count ->
|
||||||
if (DemoConfig().isDemoCardId(cardId)) return@resolveWalletWithBackups oneBackupResId
|
if (DemoConfig.isDemoCardId(cardId)) return@resolveWalletWithBackups oneBackupResId
|
||||||
|
|
||||||
when (count) {
|
when (count) {
|
||||||
WALLET_WITH_ONE_BACKUP_COUNT -> oneBackupResId
|
WALLET_WITH_ONE_BACKUP_COUNT -> oneBackupResId
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue