Updated on 2026-08-14

This commit is contained in:
Tangem 2022-12-14 19:10:06 +03:00
commit 74bc6e7282
4 changed files with 16 additions and 10 deletions

View file

@ -208,7 +208,7 @@ class TangemSdkManager(private val tangemSdk: TangemSdk, private val context: Co
}
fun getString(@StringRes stringResId: Int, vararg formatArgs: Any?): String {
return context.getString(stringResId, formatArgs)
return context.getString(stringResId, *formatArgs)
}
fun setAccessCodeRequestPolicy(

View file

@ -4,13 +4,12 @@ import com.tangem.common.CompletionResult
import com.tangem.common.card.EllipticCurve
import com.tangem.common.core.CardSession
import com.tangem.common.core.CardSessionRunnable
import com.tangem.domain.common.TwinCardNumber
import com.tangem.domain.common.TwinsHelper
import com.tangem.operations.wallet.CreateWalletResponse
import com.tangem.operations.wallet.CreateWalletTask
import com.tangem.operations.wallet.PurgeWalletCommand
class CreateFirstTwinWalletTask : CardSessionRunnable<CreateWalletResponse> {
class CreateFirstTwinWalletTask(private val firstCardId: String) : CardSessionRunnable<CreateWalletResponse> {
override fun run(
session: CardSession,
callback: (result: CompletionResult<CreateWalletResponse>) -> Unit,
@ -18,8 +17,11 @@ class CreateFirstTwinWalletTask : CardSessionRunnable<CreateWalletResponse> {
val card = session.environment.card
val publicKey = card?.wallets?.firstOrNull()?.publicKey
if (publicKey != null) {
if (TwinsHelper.getTwinCardNumber(card.cardId) == TwinCardNumber.Second) {
callback(CompletionResult.Failure(WrongTwinCard(TwinCardNumber.First)))
val requiredTwinCardNumber = TwinsHelper.getTwinCardNumber(firstCardId)
if (requiredTwinCardNumber != TwinsHelper.getTwinCardNumber(card.cardId)) {
requiredTwinCardNumber?.let {
callback(CompletionResult.Failure(WrongTwinCard(it)))
}
return
}

View file

@ -7,7 +7,6 @@ import com.tangem.common.card.EllipticCurve
import com.tangem.common.core.CardSession
import com.tangem.common.core.CardSessionRunnable
import com.tangem.common.extensions.hexToBytes
import com.tangem.domain.common.TwinCardNumber
import com.tangem.domain.common.TwinsHelper
import com.tangem.operations.wallet.CreateWalletResponse
import com.tangem.operations.wallet.CreateWalletTask
@ -15,6 +14,7 @@ import com.tangem.operations.wallet.PurgeWalletCommand
class CreateSecondTwinWalletTask(
private val firstPublicKey: String,
private val firstCardId: String,
private val issuerKeys: KeyPair,
private val preparingMessage: Message,
private val creatingWalletMessage: Message,
@ -24,8 +24,11 @@ class CreateSecondTwinWalletTask(
val card = session.environment.card
val publicKey = card?.wallets?.firstOrNull()?.publicKey
if (publicKey != null) {
if (TwinsHelper.getTwinCardNumber(card.cardId) == TwinCardNumber.First) {
callback(CompletionResult.Failure(WrongTwinCard(TwinCardNumber.Second)))
val currentTwinCardNumber = TwinsHelper.getTwinCardNumber(card.cardId)
if (TwinsHelper.getTwinCardNumber(firstCardId) == currentTwinCardNumber) {
currentTwinCardNumber?.pairNumber()?.let {
callback(CompletionResult.Failure(WrongTwinCard(it)))
}
return
}

View file

@ -8,9 +8,9 @@ import com.tangem.common.CompletionResult
import com.tangem.common.KeyPair
import com.tangem.common.extensions.hexToBytes
import com.tangem.common.extensions.toHexString
import com.tangem.datasource.api.common.MoshiConverter
import com.tangem.domain.common.CardDTO
import com.tangem.domain.common.ScanResponse
import com.tangem.datasource.api.common.MoshiConverter
import com.tangem.operations.wallet.CreateWalletResponse
import com.tangem.tap.common.AssetReader
import com.tangem.tap.tangemSdkManager
@ -30,7 +30,7 @@ class TwinCardsManager(
suspend fun createFirstWallet(message: Message): CompletionResult<CreateWalletResponse> {
val response = tangemSdkManager.runTaskAsync(
runnable = CreateFirstTwinWalletTask(),
runnable = CreateFirstTwinWalletTask(firstCardId),
cardId = firstCardId,
initialMessage = message,
)
@ -48,6 +48,7 @@ class TwinCardsManager(
): CompletionResult<CreateWalletResponse> {
val task = CreateSecondTwinWalletTask(
firstPublicKey = currentCardPublicKey!!,
firstCardId = firstCardId,
issuerKeys = issuerKeyPair,
preparingMessage = preparingMessage,
creatingWalletMessage = creatingWalletMessage,