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.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