Updated on 2026-08-14

This commit is contained in:
Tangem 2024-04-19 15:20:47 +02:00
parent 0450c67d59
commit 8b566c31ae
11 changed files with 391 additions and 45 deletions

View file

@ -13,8 +13,10 @@ import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.operations.derivation.DerivationTaskResponse
import com.tangem.crypto.hdWallet.bip32.ExtendedPublicKey
import com.tangem.operations.wallet.CreateWalletResponse
import com.tangem.tap.domain.tasks.product.CreateProductWalletTaskResponse
@Suppress("TooManyFunctions")
interface TangemSdkManager {
val canUseBiometry: Boolean
@ -38,6 +40,7 @@ interface TangemSdkManager {
shouldReset: Boolean = false,
): CompletionResult<CreateProductWalletTaskResponse>
// Wallet2 specific
suspend fun importWallet(
scanResponse: ScanResponse,
mnemonic: String,
@ -80,6 +83,10 @@ interface TangemSdkManager {
allowRequestAccessCodeFromRepository: Boolean = false,
): CompletionResult<CardDTO>
@Deprecated(
"TangemSdkManager shouldn't run custom tasks. " +
"All of them should be specified in TangemSdkManager certain methods.",
)
suspend fun <T> runTaskAsync(
runnable: CardSessionRunnable<T>,
cardId: String? = null,
@ -95,4 +102,27 @@ interface TangemSdkManager {
fun getString(@StringRes stringResId: Int, vararg formatArgs: Any?): String
fun setUserCodeRequestPolicy(policy: UserCodeRequestPolicy)
// region Twin-specific
suspend fun finalizeTwin(
secondCardPublicKey: ByteArray,
issuerKeyPair: KeyPair,
cardId: String,
initialMessage: Message,
): CompletionResult<ScanResponse>
suspend fun createFirstTwinWallet(cardId: String, initialMessage: Message): CompletionResult<CreateWalletResponse>
@Suppress("LongParameterList")
suspend fun createSecondTwinWallet(
firstPublicKey: String,
firstCardId: String,
issuerKeys: KeyPair,
preparingMessage: Message,
creatingWalletMessage: Message,
initialMessage: Message,
): CompletionResult<CreateWalletResponse>
// endregion
}

View file

@ -28,12 +28,16 @@ import com.tangem.operations.pins.SetUserCodeCommand
import com.tangem.operations.usersetttings.SetUserCodeRecoveryAllowedTask
import com.tangem.crypto.hdWallet.bip32.ExtendedPublicKey
import com.tangem.operations.derivation.DeriveWalletPublicKeyTask
import com.tangem.operations.wallet.CreateWalletResponse
import com.tangem.tap.derivationsFinder
import com.tangem.tap.domain.sdk.TangemSdkManager
import com.tangem.tap.domain.tasks.product.CreateProductWalletTask
import com.tangem.tap.domain.tasks.product.CreateProductWalletTaskResponse
import com.tangem.tap.domain.tasks.product.ResetToFactorySettingsTask
import com.tangem.tap.domain.tasks.product.ScanProductTask
import com.tangem.tap.domain.twins.CreateFirstTwinWalletTask
import com.tangem.tap.domain.twins.CreateSecondTwinWalletTask
import com.tangem.tap.domain.twins.FinalizeTwinTask
import com.tangem.wallet.R
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.suspendCancellableCoroutine
@ -274,6 +278,52 @@ class DefaultTangemSdkManager(
tangemSdk.config.userCodeRequestPolicy = policy
}
// region Twin-specific
override suspend fun createFirstTwinWallet(
cardId: String,
initialMessage: Message,
): CompletionResult<CreateWalletResponse> {
return runTaskAsync(
runnable = CreateFirstTwinWalletTask(cardId),
cardId = cardId,
initialMessage = initialMessage,
)
}
override suspend fun createSecondTwinWallet(
firstPublicKey: String,
firstCardId: String,
issuerKeys: KeyPair,
preparingMessage: Message,
creatingWalletMessage: Message,
initialMessage: Message,
): CompletionResult<CreateWalletResponse> {
val task = CreateSecondTwinWalletTask(
firstPublicKey = firstPublicKey,
firstCardId = firstCardId,
issuerKeys = issuerKeys,
preparingMessage = preparingMessage,
creatingWalletMessage = creatingWalletMessage,
)
return runTaskAsync(task, null, initialMessage)
}
override suspend fun finalizeTwin(
secondCardPublicKey: ByteArray,
issuerKeyPair: KeyPair,
cardId: String,
initialMessage: Message,
): CompletionResult<ScanResponse> {
return runTaskAsync(
runnable = FinalizeTwinTask(secondCardPublicKey, issuerKeyPair),
cardId = cardId,
initialMessage = initialMessage,
)
}
// endregion
companion object {
@Deprecated("Use [DefaultCardSdkProvider] instead")
val config = Config(

View file

@ -5,54 +5,51 @@ import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import com.tangem.Message
import com.tangem.common.*
import com.tangem.common.authentication.keystore.KeystoreManager
import com.tangem.common.authentication.keystore.DummyKeystoreManager
import com.tangem.common.core.*
import com.tangem.common.extensions.ByteArrayKey
import com.tangem.common.services.secure.SecureStorage
import com.tangem.common.services.InMemoryStorage
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.operations.derivation.DerivationTaskResponse
import com.tangem.crypto.hdWallet.bip32.ExtendedPublicKey
import com.tangem.operations.wallet.CreateWalletResponse
import com.tangem.tap.domain.sdk.TangemSdkManager
import com.tangem.tap.domain.sdk.mocks.MockProvider
import com.tangem.tap.domain.tasks.product.CreateProductWalletTaskResponse
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@Suppress("TooManyFunctions")
class MockTangemSdkManager(
private val resources: Resources,
) : TangemSdkManager {
override val canUseBiometry: Boolean
get() = false
override val canUseBiometry = false
override val needEnrollBiometrics: Boolean
get() = TODO()
override val needEnrollBiometrics = false
override val keystoreManager: KeystoreManager
get() = TODO()
override val keystoreManager = DummyKeystoreManager()
override val secureStorage: SecureStorage
get() = TODO()
override val secureStorage = InMemoryStorage()
override val userCodeRequestPolicy: UserCodeRequestPolicy
get() = TODO()
get() = userCodeRequestPolicyInternal
private var userCodeRequestPolicyInternal: UserCodeRequestPolicy = UserCodeRequestPolicy.Default
override suspend fun scanProduct(
cardId: String?,
messageRes: Int?,
allowsRequestAccessCodeFromRepository: Boolean,
): CompletionResult<ScanResponse> {
return CompletionResult.Success(MockProvider.getScanResponse())
return MockProvider.getScanResponse()
}
override suspend fun createProductWallet(
scanResponse: ScanResponse,
shouldReset: Boolean,
): CompletionResult<CreateProductWalletTaskResponse> {
TODO()
return MockProvider.getCreateProductWalletResponse()
}
override suspend fun importWallet(
@ -61,14 +58,14 @@ class MockTangemSdkManager(
passphrase: String?,
shouldReset: Boolean,
): CompletionResult<CreateProductWalletTaskResponse> {
TODO()
return MockProvider.getImportWalletResponse()
}
override suspend fun derivePublicKeys(
cardId: String?,
derivations: Map<ByteArrayKey, List<DerivationPath>>,
): CompletionResult<DerivationTaskResponse> {
TODO()
return MockProvider.getDerivationTaskResponse()
}
override suspend fun deriveExtendedPublicKey(
@ -76,52 +73,52 @@ class MockTangemSdkManager(
walletPublicKey: ByteArray,
derivation: DerivationPath,
): CompletionResult<ExtendedPublicKey> {
TODO()
return MockProvider.getExtendedPublicKey()
}
override suspend fun resetToFactorySettings(
cardId: String,
allowsRequestAccessCodeFromRepository: Boolean,
): CompletionResult<CardDTO> {
TODO()
return MockProvider.getCardDto()
}
override suspend fun saveAccessCode(accessCode: String, cardsIds: Set<String>): CompletionResult<Unit> {
TODO()
return CompletionResult.Success(Unit)
}
override suspend fun deleteSavedUserCodes(cardsIds: Set<String>): CompletionResult<Unit> {
TODO()
return CompletionResult.Success(Unit)
}
override suspend fun clearSavedUserCodes(): CompletionResult<Unit> {
TODO()
return CompletionResult.Success(Unit)
}
override suspend fun setPasscode(cardId: String?): CompletionResult<SuccessResponse> {
TODO()
return MockProvider.getSuccessResponse()
}
override suspend fun setAccessCode(cardId: String?): CompletionResult<SuccessResponse> {
TODO()
return MockProvider.getSuccessResponse()
}
override suspend fun setLongTap(cardId: String?): CompletionResult<SuccessResponse> {
TODO()
return MockProvider.getSuccessResponse()
}
override suspend fun setAccessCodeRecoveryEnabled(
cardId: String?,
enabled: Boolean,
): CompletionResult<SuccessResponse> {
TODO()
return MockProvider.getSuccessResponse()
}
override suspend fun scanCard(
cardId: String?,
allowRequestAccessCodeFromRepository: Boolean,
): CompletionResult<CardDTO> {
TODO()
return MockProvider.getCardDto()
}
override suspend fun <T> runTaskAsync(
@ -130,12 +127,10 @@ class MockTangemSdkManager(
initialMessage: Message?,
accessCode: String?,
@DrawableRes iconScanRes: Int?,
): CompletionResult<T> = withContext(Dispatchers.Main) {
TODO()
}
): CompletionResult<T> = error("This method is deprecated")
@Suppress("MagicNumber")
override fun changeDisplayedCardIdNumbersCount(scanResponse: ScanResponse?) {
// intentionally do nothing
}
@Deprecated("TangemSdkManager shouldn't returns a string from resources")
@ -144,6 +139,37 @@ class MockTangemSdkManager(
}
override fun setUserCodeRequestPolicy(policy: UserCodeRequestPolicy) {
TODO()
userCodeRequestPolicyInternal = policy
}
// region Twin-specific
override suspend fun createFirstTwinWallet(
cardId: String,
initialMessage: Message,
): CompletionResult<CreateWalletResponse> {
return MockProvider.createFirstTwinWallet()
}
override suspend fun createSecondTwinWallet(
firstPublicKey: String,
firstCardId: String,
issuerKeys: KeyPair,
preparingMessage: Message,
creatingWalletMessage: Message,
initialMessage: Message,
): CompletionResult<CreateWalletResponse> {
return MockProvider.createSecondTwinWallet()
}
override suspend fun finalizeTwin(
secondCardPublicKey: ByteArray,
issuerKeyPair: KeyPair,
cardId: String,
initialMessage: Message,
): CompletionResult<ScanResponse> {
return MockProvider.finalizeTwin()
}
// endregion
}

View file

@ -0,0 +1,8 @@
package com.tangem.tap.domain.sdk.mocks
import arrow.core.Either
import com.tangem.domain.models.scan.ProductType
data class MockConfig(
val content: Either<ProductType, Mocks>,
)

View file

@ -1,14 +1,43 @@
package com.tangem.tap.domain.sdk.mocks
import com.tangem.common.CompletionResult
import com.tangem.domain.models.scan.ProductType
import com.tangem.tap.domain.sdk.mocks.wallet.WalletMocks
import com.tangem.tap.domain.sdk.mocks.wallet2.Wallet2Mocks
import com.tangem.tap.domain.tasks.product.CreateProductWalletTaskResponse
object MockProvider {
var productType: ProductType = ProductType.Wallet
private var mocks: Mocks = getMocks(ProductType.Wallet)
fun getScanResponse() = getMocks(productType).scanResponse
fun setMockConfig(mockConfig: MockConfig) {
mockConfig.content.fold(
ifLeft = {
mocks = getMocks(it)
},
ifRight = {
mocks = it
},
)
}
fun getSuccessResponse() = CompletionResult.Success(mocks.successResponse)
fun getScanResponse() = CompletionResult.Success(mocks.scanResponse)
fun getDerivationTaskResponse() = CompletionResult.Success(mocks.derivationTaskResponse)
fun getCardDto() = CompletionResult.Success(mocks.cardDto)
fun getExtendedPublicKey() = CompletionResult.Success(mocks.extendedPublicKey)
fun getCreateProductWalletResponse(): CompletionResult<CreateProductWalletTaskResponse> {
return CompletionResult.Success(mocks.createProductWalletTaskResponse)
}
fun getImportWalletResponse(): CompletionResult<CreateProductWalletTaskResponse> {
return CompletionResult.Success(mocks.importWalletResponse)
}
private fun getMocks(productType: ProductType): Mocks {
return when (productType) {
@ -17,4 +46,14 @@ object MockProvider {
else -> TODO()
}
}
// region Twin-specific
fun finalizeTwin() = CompletionResult.Success(mocks.finalizeTwinResponse)
fun createFirstTwinWallet() = CompletionResult.Success(mocks.createFirstTwinResponse)
fun createSecondTwinWallet() = CompletionResult.Success(mocks.createSecondTwinResponse)
// endregion
}

View file

@ -1,8 +1,32 @@
package com.tangem.tap.domain.sdk.mocks
import com.tangem.common.SuccessResponse
import com.tangem.crypto.hdWallet.bip32.ExtendedPublicKey
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.operations.derivation.DerivationTaskResponse
import com.tangem.operations.wallet.CreateWalletResponse
import com.tangem.tap.domain.tasks.product.CreateProductWalletTaskResponse
interface Mocks {
val successResponse: SuccessResponse
val scanResponse: ScanResponse
val derivationTaskResponse: DerivationTaskResponse
val cardDto: CardDTO
val extendedPublicKey: ExtendedPublicKey
val createProductWalletTaskResponse: CreateProductWalletTaskResponse
val importWalletResponse: CreateProductWalletTaskResponse
val finalizeTwinResponse: ScanResponse
val createFirstTwinResponse: CreateWalletResponse
val createSecondTwinResponse: CreateWalletResponse
}

View file

@ -1,21 +1,49 @@
package com.tangem.tap.domain.sdk.mocks.wallet
import com.tangem.common.card.CardWallet
import com.tangem.common.card.EllipticCurve
import com.tangem.common.card.EncryptionMode
import com.tangem.common.card.FirmwareVersion
import com.tangem.common.SuccessResponse
import com.tangem.common.card.*
import com.tangem.common.extensions.ByteArrayKey
import com.tangem.crypto.hdWallet.DerivationPath
import com.tangem.crypto.hdWallet.bip32.ExtendedPublicKey
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ProductType
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.operations.attestation.Attestation
import com.tangem.operations.backup.PrimaryCard
import com.tangem.operations.derivation.DerivationTaskResponse
import com.tangem.operations.derivation.ExtendedPublicKeysMap
import com.tangem.operations.wallet.CreateWalletResponse
import com.tangem.tap.domain.sdk.mocks.Mocks
import com.tangem.tap.domain.tasks.product.CreateProductWalletTaskResponse
import java.util.Date
object WalletMocks : Mocks {
private val cardDto = CardDTO(
private val primaryCard = PrimaryCard(
cardId = "AC05000000086747",
batchId = "AC05",
cardPublicKey = byteArrayOf(2, -120, -3, -32, -122, -127, -120, -104, 59, 72, 76, 114, 94, 75, -37, -55, 55, 99, 66, 123, 85, -87, 80, 106, 105, -116, 87, -83, -12, 70, 108, -68, -39),
linkingKey = byteArrayOf(
2, 121, 98, 127, -70, 14, 5, -23, -76, 115, -30, -26, 111, 17, 110, 34, -100, -121,
-57, -123, 74, 3, -91, 56, -20, 56, 50, -40, -101, 96, 82, 70, -91,
),
existingWalletsCount = 3, isHDWalletAllowed = true,
issuer = Card.Issuer(
name = "TANGEM AG",
publicKey = byteArrayOf(3, 86, -25, -61, 55, 99, 41, -33, -82, 115, -120, -33, 22, -107, 103, 3, -122, 16, 60, -110, 72, 106, -121, 100, 79, -87, -27, 18, -55, -49, 78, -110, -2),
),
walletCurves = listOf(EllipticCurve.Secp256k1, EllipticCurve.Ed25519, EllipticCurve.Bls12381G2Aug),
firmwareVersion = FirmwareVersion(
major = 4,
minor = 52,
patch = 0,
type = FirmwareVersion.FirmwareType.Release,
),
isKeysImportAllowed = false,
certificate = null,
)
override val cardDto = CardDTO(
cardId = "AC05000000086747",
batchId = "AC05",
cardPublicKey = byteArrayOf(2, -120, -3, -32, -122, -127, -120, -104, 59, 72, 76, 114, 94, 75, -37, -55, 55, 99, 66, 123, 85, -87, 80, 106, 105, -116, 87, -83, -12, 70, 108, -68, -39),
@ -124,4 +152,96 @@ object WalletMocks : Mocks {
derivedKeys = emptyMap(),
primaryCard = null,
)
override val derivationTaskResponse = DerivationTaskResponse(
entries = mapOf(
ByteArrayKey(
byteArrayOf(2, -109, 28, -27, -124, -58, -97, -61, 43, -84, 90, -9, -5, 4, 90, 17, 112, -125, -108, 44, 19, -79, -60, -23, 34, -20, -20, 61, 84, 113, 120, -90, -5),
)
to
ExtendedPublicKeysMap(
mapOf(
DerivationPath("m/44'/0'/0'/0/0") to ExtendedPublicKey( // btc
publicKey = byteArrayOf(3, 45, 58, -110, -52, -51, -83, -4, -45, -118, 119, 37, 123, -17, 66, -83, 61, -106, 115, 47, 121, 66, 84, -122, -57, -45, 7, -79, 70, -13, 28, -125, -52),
chainCode = byteArrayOf(93, 51, 52, -66, -39, -38, 34, -84, 50, 1, -127, -20, 80, -20, -30, -72, 2, 1, -78, -81, -17, 51, -52, -25, 12, 108, 50, 89, -66, 18, 65, 70),
depth = 0,
parentFingerprint = byteArrayOf(0, 0, 0, 0),
childNumber = 0,
),
DerivationPath("m/44'/60'/0'/0/0") to ExtendedPublicKey( // eth
publicKey = byteArrayOf(2, 34, 6, 119, -106, 5, -119, 111, -22, 8, 23, -108, -72, -56, 6, 77, -17, -61, -101, -85, 16, 28, 18, 3, -3, -89, -81, -108, 48, -7, -86, -82, -67),
chainCode = byteArrayOf(-75, 55, 107, -106, -37, -81, -15, 72, -102, 94, 55, -39, 9, -112, 1, 90, -50, 103, 53, 120, -92, -36, -85, -39, -65, 1, 88, 46, 92, 104, -13, -109),
depth = 0,
parentFingerprint = byteArrayOf(0, 0, 0, 0),
childNumber = 0,
),
DerivationPath("m/44'/145'/0'/0/0") to ExtendedPublicKey( // bch
publicKey = byteArrayOf(2, 38, -6, 92, -37, -91, -59, -108, -18, -119, -55, 41, 38, -33, 44, 59, 24, -79, -14, -38, -10, -123, 106, 56, 39, 8, 112, 29, -41, 99, 70, -104, -121),
chainCode = byteArrayOf(105, -21, -61, -50, 68, -89, 119, 53, -96, -40, 119, 77, -122, 121, 16, 40, -50, -48, -105, -101, -74, -7, -94, -59, -90, 96, 59, 99, 43, -91, 115, -29),
depth = 0,
parentFingerprint = byteArrayOf(0, 0, 0, 0),
childNumber = 0,
),
DerivationPath("m/44'/3'/0'/0/0") to ExtendedPublicKey( // doge
publicKey = byteArrayOf(3, -25, -24, -97, -124, 24, -89, 44, 75, 123, 92, -86, -73, -93, 25, -90, -89, -95, 88, 3, 107, 37, -1, -85, -32, -57, -123, -41, 108, -9, -96, 77, -124),
chainCode = byteArrayOf(119, 3, 41, 112, 71, 54, 72, 30, 39, 25, 25, -104, 92, 46, -109, 63, 93, 67, 43, -102, -87, 39, -95, 106, 45, 67, 109, -29, -35, 10, -107, 104),
depth = 0,
parentFingerprint = byteArrayOf(0, 0, 0, 0),
childNumber = 0,
),
),
),
),
)
override val extendedPublicKey = ExtendedPublicKey(
publicKey = byteArrayOf(3, 2, 95, 53, 40, -87, -60, 11, -8, -47, 41, 37, 100, 15, -69, 1, -122, 127, -20, -81, -32, -20, -24, 5, -28, 113, 106, -90, -59, -30, -27, -110, -110),
chainCode = byteArrayOf(-95, -87, -95, -25, 27, 96, -57, -92, -69, -106, -45, 10, 85, 4, -92, -68, 49, -24, -28, -50, -49, -77, -20, 118, -50, -27, 104, -93, 115, -50, -46, -34),
depth = 0,
parentFingerprint = byteArrayOf(0, 0, 0, 0),
childNumber = 0,
)
override val successResponse = SuccessResponse(cardId = "AC05000000086747")
override val createProductWalletTaskResponse = CreateProductWalletTaskResponse(
card = cardDto,
derivedKeys = mapOf(
ByteArrayKey(
byteArrayOf(2, -109, 28, -27, -124, -58, -97, -61, 43, -84, 90, -9, -5, 4, 90, 17, 112, -125, -108, 44, 19, -79, -60, -23, 34, -20, -20, 61, 84, 113, 120, -90, -5),
)
to
ExtendedPublicKeysMap(
mapOf(
DerivationPath("m/44'/0'/0'/0/0") to ExtendedPublicKey( // btc
publicKey = byteArrayOf(3, 45, 58, -110, -52, -51, -83, -4, -45, -118, 119, 37, 123, -17, 66, -83, 61, -106, 115, 47, 121, 66, 84, -122, -57, -45, 7, -79, 70, -13, 28, -125, -52),
chainCode = byteArrayOf(93, 51, 52, -66, -39, -38, 34, -84, 50, 1, -127, -20, 80, -20, -30, -72, 2, 1, -78, -81, -17, 51, -52, -25, 12, 108, 50, 89, -66, 18, 65, 70),
depth = 0,
parentFingerprint = byteArrayOf(0, 0, 0, 0),
childNumber = 0,
),
DerivationPath("m/44'/60'/0'/0/0") to ExtendedPublicKey( // eth
publicKey = byteArrayOf(2, 34, 6, 119, -106, 5, -119, 111, -22, 8, 23, -108, -72, -56, 6, 77, -17, -61, -101, -85, 16, 28, 18, 3, -3, -89, -81, -108, 48, -7, -86, -82, -67),
chainCode = byteArrayOf(-75, 55, 107, -106, -37, -81, -15, 72, -102, 94, 55, -39, 9, -112, 1, 90, -50, 103, 53, 120, -92, -36, -85, -39, -65, 1, 88, 46, 92, 104, -13, -109),
depth = 0,
parentFingerprint = byteArrayOf(0, 0, 0, 0),
childNumber = 0,
),
),
),
),
primaryCard = primaryCard,
)
override val importWalletResponse: CreateProductWalletTaskResponse
get() = error("Available only for Wallet 2")
override val createFirstTwinResponse: CreateWalletResponse
get() = error("Available only for Twin")
override val createSecondTwinResponse: CreateWalletResponse
get() = error("Available only for Twin")
override val finalizeTwinResponse: ScanResponse
get() = error("Available only for Twin")
}

View file

@ -1,10 +1,43 @@
package com.tangem.tap.domain.sdk.mocks.wallet2
import com.tangem.common.SuccessResponse
import com.tangem.crypto.hdWallet.bip32.ExtendedPublicKey
import com.tangem.domain.models.scan.CardDTO
import com.tangem.domain.models.scan.ScanResponse
import com.tangem.operations.derivation.DerivationTaskResponse
import com.tangem.operations.wallet.CreateWalletResponse
import com.tangem.tap.domain.sdk.mocks.Mocks
import com.tangem.tap.domain.tasks.product.CreateProductWalletTaskResponse
object Wallet2Mocks : Mocks {
override val scanResponse: ScanResponse
get() = TODO("Not yet implemented")
override val cardDto: CardDTO
get() = TODO("Not yet implemented")
override val derivationTaskResponse: DerivationTaskResponse
get() = TODO("Not yet implemented")
override val extendedPublicKey: ExtendedPublicKey
get() = TODO("Not yet implemented")
override val successResponse: SuccessResponse
get() = TODO("Not yet implemented")
override val createProductWalletTaskResponse: CreateProductWalletTaskResponse
get() = TODO("Not yet implemented")
override val importWalletResponse: CreateProductWalletTaskResponse
get() = TODO("Not yet implemented")
override val createFirstTwinResponse: CreateWalletResponse
get() = error("Available only for Twin")
override val createSecondTwinResponse: CreateWalletResponse
get() = error("Available only for Twin")
override val finalizeTwinResponse: ScanResponse
get() = error("Available only for Twin")
}

View file

@ -27,8 +27,7 @@ class TwinCardsManager(
private val issuerKeyPair: KeyPair = getIssuerKeys(assetReader, card.issuer.publicKey.toHexString())
suspend fun createFirstWallet(message: Message): CompletionResult<CreateWalletResponse> {
val response = tangemSdkManager.runTaskAsync(
runnable = CreateFirstTwinWalletTask(firstCardId),
val response = tangemSdkManager.createFirstTwinWallet(
cardId = firstCardId,
initialMessage = message,
)
@ -44,14 +43,15 @@ class TwinCardsManager(
preparingMessage: Message,
creatingWalletMessage: Message,
): CompletionResult<CreateWalletResponse> {
val task = CreateSecondTwinWalletTask(
val response = tangemSdkManager.createSecondTwinWallet(
firstPublicKey = currentCardPublicKey!!,
firstCardId = firstCardId,
issuerKeys = issuerKeyPair,
preparingMessage = preparingMessage,
creatingWalletMessage = creatingWalletMessage,
initialMessage = initialMessage,
)
val response = tangemSdkManager.runTaskAsync(task, null, initialMessage)
when (response) {
is CompletionResult.Success -> {
secondCardPublicKey = response.data.wallet.publicKey.toHexString()
@ -62,8 +62,9 @@ class TwinCardsManager(
}
suspend fun complete(message: Message): Result<ScanResponse> {
val response = tangemSdkManager.runTaskAsync(
runnable = FinalizeTwinTask(secondCardPublicKey!!.hexToBytes(), issuerKeyPair),
val response = tangemSdkManager.finalizeTwin(
secondCardPublicKey = secondCardPublicKey!!.hexToBytes(),
issuerKeyPair = issuerKeyPair,
cardId = firstCardId,
initialMessage = message,
)

View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="tangem_app_name" translatable="false">Mocked Tangem</string>
</resources>

View file

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="user" />
<certificates src="system" />
</trust-anchors>
</base-config>
</network-security-config>