Updated on 2026-08-14
This commit is contained in:
parent
9e986a6cb3
commit
1cfaf5a283
19 changed files with 830 additions and 56 deletions
|
|
@ -0,0 +1,15 @@
|
|||
package com.tangem.domain.wallets.registration
|
||||
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
|
||||
/**
|
||||
* Domain port for triggering Tangem Auth Service wallet registration.
|
||||
*
|
||||
* Fire-and-forget from the caller's perspective: implementations must not throw — registration is
|
||||
* best-effort and retried later.
|
||||
*/
|
||||
interface WalletRegistrationTrigger {
|
||||
|
||||
/** Registers a freshly created/imported MOBILE (hot) wallet while its unlock context is fresh. */
|
||||
suspend fun onMobileWalletCreated(userWallet: UserWallet.Hot)
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.tangem.domain.wallets.usecase
|
|||
import arrow.core.Either
|
||||
import com.tangem.domain.models.wallet.UserWallet
|
||||
import com.tangem.domain.wallets.builder.HotUserWalletBuilder
|
||||
import com.tangem.domain.wallets.registration.WalletRegistrationTrigger
|
||||
import com.tangem.hot.sdk.TangemHotSdk
|
||||
import com.tangem.hot.sdk.model.HotAuth
|
||||
import com.tangem.hot.sdk.model.MnemonicType
|
||||
|
|
@ -15,6 +16,7 @@ class CreateHotWalletUseCase @Inject constructor(
|
|||
private val hotUserWalletBuilderFactory: HotUserWalletBuilder.Factory,
|
||||
private val saveWalletUseCase: SaveWalletUseCase,
|
||||
private val syncWalletWithRemoteUseCase: SyncWalletWithRemoteUseCase,
|
||||
private val walletRegistrationTrigger: WalletRegistrationTrigger,
|
||||
private val appCoroutineScope: AppCoroutineScope,
|
||||
) {
|
||||
suspend operator fun invoke(auth: HotAuth, mnemonicType: MnemonicType): Either<Throwable, UserWallet.Hot> {
|
||||
|
|
@ -28,6 +30,11 @@ class CreateHotWalletUseCase @Inject constructor(
|
|||
syncWalletWithRemoteUseCase(userWalletId = userWallet.walletId)
|
||||
}
|
||||
|
||||
// Register the wallet with the Auth Service while its unlock context is still fresh.
|
||||
appCoroutineScope.launch {
|
||||
walletRegistrationTrigger.onMobileWalletCreated(userWallet)
|
||||
}
|
||||
|
||||
userWallet
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue