Updated on 2026-08-14
This commit is contained in:
parent
fa55c16871
commit
85b00c4c65
18 changed files with 269 additions and 16 deletions
|
|
@ -4,6 +4,7 @@ import com.tangem.TangemSdk
|
|||
import com.tangem.blockchain.common.TransactionSigner
|
||||
import com.tangem.domain.card.models.TwinKey
|
||||
import com.tangem.domain.models.scan.ProductType
|
||||
import com.tangem.domain.models.wallet.UserWalletId
|
||||
|
||||
/**
|
||||
* Repository for managing with CardSDK config
|
||||
|
|
@ -28,8 +29,13 @@ interface CardSdkConfigRepository {
|
|||
/** Update the card ID display format according to the [productType] of the scanned card */
|
||||
fun updateCardIdDisplayFormat(productType: ProductType)
|
||||
|
||||
/** Get common signer by [cardId] */
|
||||
fun getCommonSigner(cardId: String?, twinKey: TwinKey?): TransactionSigner
|
||||
/**
|
||||
* Get common signer by [cardId].
|
||||
*
|
||||
* @param userWalletId ID of the user wallet being signed. Used to persist the updated number of signed hashes
|
||||
* back into the wallet after a successful signing operation.
|
||||
*/
|
||||
fun getCommonSigner(cardId: String?, twinKey: TwinKey?, userWalletId: UserWalletId): TransactionSigner
|
||||
|
||||
/** Check if linked terminal is enabled */
|
||||
fun isLinkedTerminal(): Boolean?
|
||||
|
|
|
|||
|
|
@ -65,14 +65,15 @@ class AssociateAssetUseCase(
|
|||
private fun createSigner(userWallet: UserWallet): TransactionSigner {
|
||||
return when (userWallet) {
|
||||
is UserWallet.Hot -> getHotTransactionSigner(userWallet)
|
||||
is UserWallet.Cold -> getColdSigner()
|
||||
is UserWallet.Cold -> getColdSigner(userWallet)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getColdSigner(): TransactionSigner {
|
||||
private fun getColdSigner(userWallet: UserWallet.Cold): TransactionSigner {
|
||||
return cardSdkConfigRepository.getCommonSigner(
|
||||
cardId = null,
|
||||
twinKey = null, // use null here because no assets support for Twin cards
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,14 +62,15 @@ class OpenTrustlineUseCase(
|
|||
private fun createSigner(userWallet: UserWallet): TransactionSigner {
|
||||
return when (userWallet) {
|
||||
is UserWallet.Hot -> getHotTransactionSigner(userWallet)
|
||||
is UserWallet.Cold -> getColdSigner()
|
||||
is UserWallet.Cold -> getColdSigner(userWallet)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getColdSigner(): TransactionSigner {
|
||||
private fun getColdSigner(userWallet: UserWallet.Cold): TransactionSigner {
|
||||
return cardSdkConfigRepository.getCommonSigner(
|
||||
cardId = null,
|
||||
twinKey = null, // use null here because no assets support for Twin cards
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -70,6 +70,7 @@ class PrepareAndSignUseCase(
|
|||
val signer = cardSdkConfigRepository.getCommonSigner(
|
||||
cardId = card.cardId.takeIf { isCardNotBackedUp },
|
||||
twinKey = TwinKey.getOrNull(scanResponse = userWallet.scanResponse),
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
return signer
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ class PrepareForSendUseCase(
|
|||
val signer = cardSdkConfigRepository.getCommonSigner(
|
||||
cardId = card.cardId.takeIf { isCardNotBackedUp },
|
||||
twinKey = TwinKey.getOrNull(scanResponse = userWallet.scanResponse),
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
return signer
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,14 +58,15 @@ class RetryIncompleteTransactionUseCase(
|
|||
private fun createSigner(userWallet: UserWallet): TransactionSigner {
|
||||
return when (userWallet) {
|
||||
is UserWallet.Hot -> getHotTransactionSigner(userWallet)
|
||||
is UserWallet.Cold -> getColdSigner()
|
||||
is UserWallet.Cold -> getColdSigner(userWallet)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getColdSigner(): TransactionSigner {
|
||||
private fun getColdSigner(userWallet: UserWallet.Cold): TransactionSigner {
|
||||
return cardSdkConfigRepository.getCommonSigner(
|
||||
cardId = null,
|
||||
twinKey = null, // use null here because no assets support for Twin cards
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,7 @@ class SendLargeSolanaTransactionUseCase(
|
|||
val signer = cardSdkConfigRepository.getCommonSigner(
|
||||
cardId = card.cardId.takeIf { isCardNotBackedUp },
|
||||
twinKey = TwinKey.getOrNull(scanResponse = userWallet.scanResponse),
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
|
||||
val walletManager = walletManagersFacade
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ class SendTransactionUseCase(
|
|||
val coldSigner = cardSdkConfigRepository.getCommonSigner(
|
||||
cardId = card.cardId.takeIf { isCardNotBackedUp },
|
||||
twinKey = TwinKey.getOrNull(scanResponse = userWallet.scanResponse),
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
|
||||
coldSigner
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ class SignCloreMessageUseCase(
|
|||
cardSdkConfigRepository.getCommonSigner(
|
||||
cardId = card.cardId.takeIf { isCardNotBackedUp },
|
||||
twinKey = null,
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
}
|
||||
is UserWallet.Hot -> getHotWalletSigner(userWallet)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ class SignUseCase(
|
|||
return cardSdkConfigRepository.getCommonSigner(
|
||||
cardId = card.cardId.takeIf { isCardNotBackedUp },
|
||||
twinKey = TwinKey.getOrNull(scanResponse = userWallet.scanResponse),
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -235,6 +235,7 @@ class CreateAndSendGaslessTransactionUseCase(
|
|||
cardSdkConfigRepository.getCommonSigner(
|
||||
cardId = card.cardId.takeIf { isCardNotBackedUp },
|
||||
twinKey = TwinKey.getOrNull(scanResponse = userWallet.scanResponse),
|
||||
userWalletId = userWallet.walletId,
|
||||
)
|
||||
}
|
||||
is UserWallet.Hot -> getHotWalletSigner(userWallet)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue