Updated on 2026-08-14
This commit is contained in:
parent
d48eea4fb0
commit
a88a63d6ef
22 changed files with 95 additions and 37 deletions
|
|
@ -1,7 +1,6 @@
|
|||
package com.tangem.domain.card
|
||||
|
||||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.Blockchain.Companion.fromId
|
||||
import com.tangem.blockchain.common.Token
|
||||
import com.tangem.common.card.EllipticCurve
|
||||
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.getTwinCardIdForUser
|
||||
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.ProductType
|
||||
import com.tangem.operations.attestation.Attestation
|
||||
|
|
@ -23,7 +23,16 @@ internal class TangemCardTypesResolver(
|
|||
private val walletData: WalletData?,
|
||||
) : 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 {
|
||||
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_ID_STARTS_WITH = "FF99"
|
||||
private val backupRequiredFirmwareVersion = FirmwareVersion(major = 6, minor = 21)
|
||||
private val demoConfig = DemoConfig()
|
||||
|
||||
val CardDTO.isTangemTwins: Boolean
|
||||
get() = TwinsHelper.getTwinCardNumber(cardId) != null
|
||||
|
|
@ -34,7 +33,7 @@ object TapWorkarounds {
|
|||
|
||||
// for cards 6.21 and higher backup is not skippable
|
||||
val CardDTO.canSkipBackup: Boolean
|
||||
get() = this.firmwareVersion < backupRequiredFirmwareVersion || demoConfig.isDemoCardId(cardId)
|
||||
get() = this.firmwareVersion < backupRequiredFirmwareVersion || DemoConfig.isDemoCardId(cardId)
|
||||
|
||||
val CardDTO.hasOldStyleDerivation: Boolean
|
||||
get() = batchId == "AC01" || batchId == "AC02" || batchId == "CB95"
|
||||
|
|
|
|||
|
|
@ -5,15 +5,28 @@ import com.tangem.blockchain.common.Blockchain
|
|||
import java.math.BigDecimal
|
||||
|
||||
@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.Ethereum,
|
||||
Blockchain.Dogecoin,
|
||||
Blockchain.Solana,
|
||||
)
|
||||
|
||||
private val demoBlockchainsSecpOnly = setOf(
|
||||
Blockchain.Bitcoin,
|
||||
Blockchain.Ethereum,
|
||||
Blockchain.Dogecoin,
|
||||
)
|
||||
|
||||
private val demoCardIds: List<String> by lazy {
|
||||
val demoIds = getReleaseIds().toMutableList()
|
||||
if (BuildConfig.DEBUG) demoIds.addAll(debugTestDemoCardIds)
|
||||
|
|
@ -28,13 +41,26 @@ class DemoConfig {
|
|||
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 getBalance(blockchain: Blockchain): Amount = walletBalances[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> {
|
||||
return (releaseDemoCardIds + testDemoCardIds).distinct()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ dependencies {
|
|||
implementation(projects.domain.tokens.models)
|
||||
implementation(projects.domain.wallets.models)
|
||||
implementation(projects.domain.notifications.models)
|
||||
implementation(projects.domain.demo.models)
|
||||
// endregion
|
||||
|
||||
// region Tangem libraries
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.tangem.domain.wallets.builder
|
||||
|
||||
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.wallet.UserWallet
|
||||
import com.tangem.domain.wallets.usecase.GenerateWalletNameUseCase
|
||||
|
|
@ -16,9 +15,6 @@ class ColdUserWalletBuilder @AssistedInject constructor(
|
|||
private var backupCardsIds: Set<String> = emptySet()
|
||||
private var hasBackupError: Boolean = false
|
||||
|
||||
private val CardDTO.isBackupNotAllowed: Boolean
|
||||
get() = !settings.isBackupAllowed
|
||||
|
||||
/**
|
||||
* DANGEROUS!!!
|
||||
* [backupCardsIds] will be non-empty list if card is backed up on current device.
|
||||
|
|
@ -44,8 +40,8 @@ class ColdUserWalletBuilder @AssistedInject constructor(
|
|||
UserWallet.Cold(
|
||||
walletId = it,
|
||||
name = generateWalletNameUseCase(
|
||||
card = card,
|
||||
productType = productType,
|
||||
isBackupNotAllowed = card.isBackupNotAllowed,
|
||||
isStartToCoin = cardTypesResolver.isStart2Coin(),
|
||||
),
|
||||
cardsInWallet = backupCardsIds.plus(card.cardId),
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
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.requireUserWalletsSync
|
||||
import com.tangem.domain.models.scan.ProductType
|
||||
|
|
@ -14,10 +16,14 @@ class GenerateWalletNameUseCase(
|
|||
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(
|
||||
productType = productType,
|
||||
isBackupNotAllowed = isBackupNotAllowed,
|
||||
card = card,
|
||||
isBackupNotAllowed = card.isBackupNotAllowed,
|
||||
isStartToCoin = isStartToCoin,
|
||||
)
|
||||
|
||||
|
|
@ -55,7 +61,20 @@ class GenerateWalletNameUseCase(
|
|||
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) {
|
||||
ProductType.Note -> "Note"
|
||||
ProductType.Twins -> "Twin"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue