Updated on 2026-08-14
This commit is contained in:
parent
5ef3837bd5
commit
8d3c2b1cd8
23 changed files with 413 additions and 46 deletions
|
|
@ -15,4 +15,7 @@ dependencies {
|
|||
|
||||
/** Domain models */
|
||||
implementation(projects.domain.models)
|
||||
|
||||
/** Tangem libraries (derived public keys types for VA activation) */
|
||||
implementation(tangemDeps.card.core)
|
||||
}
|
||||
|
|
@ -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>,
|
||||
)
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue