Updated on 2026-08-14
This commit is contained in:
commit
9aacdb2ed3
695 changed files with 22022 additions and 5116 deletions
|
|
@ -0,0 +1,46 @@
|
|||
package com.tangem.domain.card
|
||||
|
||||
import com.tangem.common.card.EllipticCurve
|
||||
import com.tangem.domain.card.configs.CardConfig
|
||||
import com.tangem.domain.models.scan.CardDTO
|
||||
|
||||
object BackupValidator {
|
||||
|
||||
fun isValidFull(cardDTO: CardDTO): Boolean {
|
||||
return validateBackupStatus(cardDTO) && validateCurves(cardDTO)
|
||||
}
|
||||
|
||||
fun isValidBackupStatus(cardDTO: CardDTO): Boolean {
|
||||
return validateBackupStatus(cardDTO)
|
||||
}
|
||||
|
||||
private fun validateCurves(cardDTO: CardDTO): Boolean {
|
||||
val config = CardConfig.createConfig(cardDTO)
|
||||
// / Since the curve `bls12381_G2_AUG` was added later into first generation of wallets,
|
||||
// we cannot determine whether this curve is missing due to an error or because the user
|
||||
// did not want to recreate the wallet.
|
||||
val expectedCurves = config.mandatoryCurves
|
||||
.filterNot { it == EllipticCurve.Bls12381G2Aug }
|
||||
val curves = cardDTO.wallets.map { it.curve }
|
||||
for (expectedCurve in expectedCurves) {
|
||||
val cardCurvesCount = curves.count { it == expectedCurve }
|
||||
|
||||
// missing curve
|
||||
if (cardCurvesCount == 0) {
|
||||
return false
|
||||
}
|
||||
|
||||
// duplicated curve
|
||||
if (cardCurvesCount > 1) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun validateBackupStatus(cardDTO: CardDTO): Boolean {
|
||||
val backupStatus = cardDTO.backupStatus
|
||||
backupStatus ?: return true // for card with null backup status, validation should always returns true
|
||||
return backupStatus !is CardDTO.BackupStatus.CardLinked
|
||||
}
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.tangem.domain.card.common.visa
|
|||
import com.tangem.blockchain.common.Blockchain
|
||||
import com.tangem.blockchain.common.derivation.DerivationStyle
|
||||
import com.tangem.common.card.FirmwareVersion
|
||||
import com.tangem.crypto.hdWallet.DerivationPath
|
||||
import com.tangem.domain.models.scan.CardDTO
|
||||
|
||||
private const val VISA_BATCH_START = "AE"
|
||||
|
|
@ -16,6 +17,7 @@ object VisaUtilities {
|
|||
|
||||
val visaDefaultDerivationPath
|
||||
get() = visaBlockchain.derivationPath(DerivationStyle.V3)
|
||||
val customDerivationPath = DerivationPath("m/44'/60'/999999'/0/0")
|
||||
|
||||
fun visaDefaultDerivationPath(style: DerivationStyle) = visaBlockchain.derivationPath(style)
|
||||
|
||||
|
|
|
|||
|
|
@ -212,9 +212,9 @@ data object Wallet2CardConfig : CardConfig {
|
|||
Blockchain.HyperliquidTestnet -> EllipticCurve.Secp256k1
|
||||
Blockchain.Quai -> EllipticCurve.Secp256k1
|
||||
Blockchain.QuaiTestnet -> EllipticCurve.Secp256k1
|
||||
// Blockchain.Linea -> EllipticCurve.Secp256k1
|
||||
// Blockchain.LineaTestnet -> EllipticCurve.Secp256k1
|
||||
// Blockchain.ArbitrumNova -> EllipticCurve.Secp256k1
|
||||
Blockchain.Linea -> EllipticCurve.Secp256k1
|
||||
Blockchain.LineaTestnet -> EllipticCurve.Secp256k1
|
||||
Blockchain.ArbitrumNova -> EllipticCurve.Secp256k1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -168,9 +168,9 @@ class Wallet2CardConfigTest {
|
|||
Blockchain.HyperliquidTestnet to EllipticCurve.Secp256k1,
|
||||
Blockchain.Quai to EllipticCurve.Secp256k1,
|
||||
Blockchain.QuaiTestnet to EllipticCurve.Secp256k1,
|
||||
// Blockchain.Linea to EllipticCurve.Secp256k1,
|
||||
// Blockchain.LineaTestnet to EllipticCurve.Secp256k1,
|
||||
// Blockchain.ArbitrumNova to EllipticCurve.Secp256k1,
|
||||
Blockchain.Linea to EllipticCurve.Secp256k1,
|
||||
Blockchain.LineaTestnet to EllipticCurve.Secp256k1,
|
||||
Blockchain.ArbitrumNova to EllipticCurve.Secp256k1,
|
||||
)
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue