Updated on 2026-08-14

This commit is contained in:
Tangem 2026-06-22 20:31:03 +05:00
parent 5ef3837bd5
commit 8d3c2b1cd8
23 changed files with 413 additions and 46 deletions

View file

@ -15,4 +15,7 @@ dependencies {
/** Domain models */
implementation(projects.domain.models)
/** Tangem libraries (derived public keys types for VA activation) */
implementation(tangemDeps.card.core)
}

View file

@ -0,0 +1,16 @@
package com.tangem.domain.visa.model
import com.tangem.common.extensions.ByteArrayKey
import com.tangem.operations.derivation.ExtendedPublicKeysMap
/**
* Result of deriving the Virtual Account key on the card.
*
* @property address the VA deposit address generated from the derived key
* @property derivedKeys the derived extended public key(s) keyed by the seed wallet public key,
* ready to be persisted into the wallet (see `DerivationsRepository.storeDerivedKeys`)
*/
data class VirtualAccountActivationData(
val address: String,
val derivedKeys: Map<ByteArrayKey, ExtendedPublicKeysMap>,
)

View file

@ -4,11 +4,14 @@ import arrow.core.Either
import com.tangem.domain.models.wallet.UserWallet
import com.tangem.domain.pay.WithdrawalSignatureResult
import com.tangem.domain.visa.model.TangemPayInitialCredentials
import com.tangem.domain.visa.model.VirtualAccountActivationData
interface TangemPayAuthDataSource {
suspend fun produceInitialCredentials(userWallet: UserWallet): Either<Throwable, TangemPayInitialCredentials>
suspend fun produceVirtualAccountData(userWallet: UserWallet): Either<Throwable, VirtualAccountActivationData>
suspend fun getWithdrawalSignature(
userWallet: UserWallet,
hash: String,

View file

@ -0,0 +1,13 @@
package com.tangem.domain.virtualaccount.repository
import com.tangem.domain.models.wallet.UserWalletId
interface VirtualAccountActivationRepository {
/**
* Derives the Virtual Account key on the card (NFC) and persists it into the wallet, so the
* on-chain VA balance can later be fetched without re-deriving. Throws on failure.
*/
@Throws
suspend fun activateVirtualAccount(userWalletId: UserWalletId)
}

View file

@ -0,0 +1,17 @@
package com.tangem.domain.virtualaccount.usecase
import arrow.core.Either
import arrow.core.Either.Companion.catch
import com.tangem.domain.models.wallet.UserWalletId
import com.tangem.domain.virtualaccount.repository.VirtualAccountActivationRepository
class ActivateVirtualAccountUseCase(
private val repository: VirtualAccountActivationRepository,
) {
suspend operator fun invoke(userWalletId: UserWalletId): Either<Throwable, Unit> {
return catch {
repository.activateVirtualAccount(userWalletId)
}
}
}