Updated on 2026-08-14
This commit is contained in:
parent
9c1931f7d7
commit
96195bfbff
35 changed files with 332 additions and 207 deletions
|
|
@ -1,16 +1,12 @@
|
|||
package com.tangem.tap.domain.extensions
|
||||
|
||||
import com.tangem.common.card.EllipticCurve
|
||||
import com.tangem.common.card.FirmwareVersion
|
||||
import com.tangem.common.extensions.toHexString
|
||||
import com.tangem.common.services.Result
|
||||
import com.tangem.domain.common.CardDTO
|
||||
import com.tangem.domain.common.TapWorkarounds.isSaltPay
|
||||
import com.tangem.domain.common.TapWorkarounds.isStart2Coin
|
||||
import com.tangem.domain.common.TapWorkarounds.isTangemNote
|
||||
import com.tangem.domain.common.TwinCardNumber
|
||||
import com.tangem.domain.common.getTwinCardNumber
|
||||
import com.tangem.domain.common.isTangemTwin
|
||||
import com.tangem.operations.attestation.CardVerifyAndGetInfo
|
||||
import com.tangem.operations.attestation.OnlineCardVerifier
|
||||
import com.tangem.tap.features.wallet.redux.Artwork
|
||||
|
|
@ -21,22 +17,12 @@ val CardDTO.remainingSignatures: Int?
|
|||
val CardDTO.isWalletDataSupported: Boolean
|
||||
get() = this.firmwareVersion.major >= 4
|
||||
|
||||
val CardDTO.isMultiwalletAllowed: Boolean
|
||||
get() {
|
||||
return !isTangemTwin() && !isStart2Coin && !isTangemNote && !isSaltPay &&
|
||||
(firmwareVersion >= FirmwareVersion.MultiWalletAvailable ||
|
||||
wallets.firstOrNull()?.curve == EllipticCurve.Secp256k1)
|
||||
}
|
||||
val CardDTO.isFirmwareMultiwalletAllowed: Boolean
|
||||
get() = firmwareVersion >= FirmwareVersion.MultiWalletAvailable && settings.maxWalletsCount > 1
|
||||
|
||||
val CardDTO.isHdWalletAllowedByApp: Boolean
|
||||
get() = settings.isHDWalletAllowed && !isSaltPay
|
||||
|
||||
val CardDTO.isTangemWallet: Boolean
|
||||
get() = settings.isBackupAllowed
|
||||
&& settings.isHDWalletAllowed
|
||||
&& firmwareVersion >= FirmwareVersion.MultiWalletAvailable
|
||||
&& !isSaltPay
|
||||
|
||||
@Suppress("UnnecessaryParentheses")
|
||||
fun CardDTO.hasSignedHashes(): Boolean {
|
||||
return wallets.any { (it.totalSignedHashes ?: 0) > 0 }
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ fun WalletManagerFactory.makeWalletManagerForApp(
|
|||
|
||||
val seedKey = wallet.extendedPublicKey
|
||||
return when {
|
||||
scanResponse.isTangemTwins() && scanResponse.secondTwinPublicKey != null -> {
|
||||
scanResponse.cardTypesResolver.isTangemTwins() && scanResponse.secondTwinPublicKey != null -> {
|
||||
makeTwinWalletManager(
|
||||
walletPublicKey = wallet.publicKey,
|
||||
pairPublicKey = scanResponse.secondTwinPublicKey!!.hexToBytes(),
|
||||
|
|
@ -119,9 +119,9 @@ fun WalletManagerFactory.makePrimaryWalletManager(
|
|||
scanResponse: ScanResponse,
|
||||
): WalletManager? {
|
||||
val blockchain = if (scanResponse.card.isTestCard) {
|
||||
scanResponse.getBlockchain().getTestnetVersion() ?: return null
|
||||
scanResponse.cardTypesResolver.getBlockchain().getTestnetVersion() ?: return null
|
||||
} else {
|
||||
scanResponse.getBlockchain()
|
||||
scanResponse.cardTypesResolver.getBlockchain()
|
||||
}
|
||||
val derivationParams = getDerivationParams(null, scanResponse.card)
|
||||
return makeWalletManagerForApp(
|
||||
|
|
@ -142,7 +142,7 @@ private fun selectWallet(wallets: List<CardDTO.Wallet>): CardDTO.Wallet? {
|
|||
fun WalletManagerFactory.makeSaltPayWalletManager(
|
||||
scanResponse: ScanResponse,
|
||||
): EthereumWalletManager {
|
||||
val blockchain = scanResponse.getBlockchain()
|
||||
val blockchain = scanResponse.cardTypesResolver.getBlockchain()
|
||||
if (blockchain != Blockchain.SaltPay) {
|
||||
error("WalletManager for the SaltPay can be created based only on Blockchain.SaltPay")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue