Updated on 2026-08-14
This commit is contained in:
parent
4fa5989289
commit
440de0f675
17 changed files with 142 additions and 28 deletions
|
|
@ -20,6 +20,7 @@ dependencies {
|
|||
implementation(projects.features.tester.api)
|
||||
implementation(projects.features.createWalletSelection.api)
|
||||
implementation(projects.features.tangempay.details.api)
|
||||
implementation(projects.features.onboardingV2.api)
|
||||
|
||||
/* Project - Core */
|
||||
implementation(projects.core.decompose)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import com.tangem.domain.models.wallet.UserWallet
|
|||
import com.tangem.domain.wallets.builder.ColdUserWalletBuilder
|
||||
import com.tangem.domain.wallets.usecase.SaveWalletUseCase
|
||||
import com.tangem.features.details.impl.R
|
||||
import com.tangem.features.onboarding.v2.OnboardingV2FeatureToggles
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
|
|
@ -38,6 +39,7 @@ internal class UserWalletSaver @Inject constructor(
|
|||
private val coldUserWalletBuilderFactory: ColdUserWalletBuilder.Factory,
|
||||
private val messageSender: UiMessageSender,
|
||||
private val router: Router,
|
||||
private val onboardingV2FeatureToggles: OnboardingV2FeatureToggles,
|
||||
) {
|
||||
|
||||
suspend fun scanAndSaveUserWallet(scope: CoroutineScope) {
|
||||
|
|
@ -55,7 +57,7 @@ internal class UserWalletSaver @Inject constructor(
|
|||
block = {
|
||||
scanResponse ?: return
|
||||
val userWallet = createUserWallet(scanResponse)
|
||||
saveWallet(userWallet)
|
||||
saveWallet(userWallet, scanResponse)
|
||||
},
|
||||
recover = {
|
||||
val message = it.message
|
||||
|
|
@ -69,7 +71,7 @@ internal class UserWalletSaver @Inject constructor(
|
|||
)
|
||||
}
|
||||
|
||||
private suspend fun Raise<Error>.saveWallet(userWallet: UserWallet) {
|
||||
private suspend fun Raise<Error>.saveWallet(userWallet: UserWallet, scanResponse: ScanResponse) {
|
||||
fold(
|
||||
block = {
|
||||
saveWalletUseCase(
|
||||
|
|
@ -92,7 +94,19 @@ internal class UserWalletSaver @Inject constructor(
|
|||
}
|
||||
},
|
||||
transform = {
|
||||
router.popTo<AppRoute.Wallet>()
|
||||
if (onboardingV2FeatureToggles.isAddressSyncEnabled) {
|
||||
router.push(
|
||||
AppRoute.Onboarding(
|
||||
scanResponse = scanResponse,
|
||||
mode = AppRoute.Onboarding.Mode.AddressSync(
|
||||
userWalletId = userWallet.walletId,
|
||||
isWalletStarted = true,
|
||||
),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
router.popTo<AppRoute.Wallet>()
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue