Updated on 2026-08-14
This commit is contained in:
parent
6e7b57a57d
commit
6f22bf53b2
4 changed files with 39 additions and 10 deletions
|
|
@ -1,12 +1,15 @@
|
|||
package com.tangem.tap.features.onboarding.products.otherCards.redux
|
||||
|
||||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.common.core.TangemSdkError
|
||||
import com.tangem.core.analytics.Analytics
|
||||
import com.tangem.domain.common.extensions.withMainContext
|
||||
import com.tangem.tap.common.analytics.events.Onboarding
|
||||
import com.tangem.tap.common.extensions.dispatchDialogShow
|
||||
import com.tangem.tap.common.postUi
|
||||
import com.tangem.tap.common.redux.AppState
|
||||
import com.tangem.tap.common.redux.global.GlobalAction
|
||||
import com.tangem.tap.features.onboarding.OnboardingDialog
|
||||
import com.tangem.tap.features.onboarding.OnboardingHelper
|
||||
import com.tangem.tap.scope
|
||||
import com.tangem.tap.store
|
||||
|
|
@ -72,7 +75,10 @@ private fun handleOtherCardsAction(action: Action) {
|
|||
}
|
||||
is OnboardingOtherCardsAction.CreateWallet -> {
|
||||
scope.launch {
|
||||
val result = tangemSdkManager.createProductWallet(onboardingManager.scanResponse)
|
||||
val result = tangemSdkManager.createProductWallet(
|
||||
scanResponse = onboardingManager.scanResponse,
|
||||
shouldReset = globalState.onboardingState.shouldResetOnCreate,
|
||||
)
|
||||
withMainContext {
|
||||
when (result) {
|
||||
is CompletionResult.Success -> {
|
||||
|
|
@ -87,7 +93,11 @@ private fun handleOtherCardsAction(action: Action) {
|
|||
delay(DELAY_SDK_DIALOG_CLOSE)
|
||||
store.dispatch(OnboardingOtherCardsAction.SetStepOfScreen(OnboardingOtherCardsStep.Done))
|
||||
}
|
||||
is CompletionResult.Failure -> Unit
|
||||
is CompletionResult.Failure -> {
|
||||
if (result.error is TangemSdkError.WalletAlreadyCreated) {
|
||||
handleActivationError()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -101,4 +111,14 @@ private fun handleOtherCardsAction(action: Action) {
|
|||
}
|
||||
else -> Unit
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleActivationError() {
|
||||
store.dispatchDialogShow(
|
||||
OnboardingDialog.WalletActivationError(
|
||||
onConfirm = {
|
||||
store.dispatch(GlobalAction.Onboarding.ShouldResetCardOnCreate(true))
|
||||
},
|
||||
),
|
||||
)
|
||||
}
|
||||
|
|
@ -129,7 +129,14 @@ internal class SaveWalletMiddleware {
|
|||
}
|
||||
|
||||
store.dispatchOnMain(SaveWalletAction.Save.Success)
|
||||
store.dispatchOnMain(NavigationAction.PopBackTo(AppScreen.Wallet))
|
||||
|
||||
store.dispatchOnMain(
|
||||
if (store.state.navigationState.backStack.contains(AppScreen.Wallet)) {
|
||||
NavigationAction.PopBackTo(AppScreen.Wallet)
|
||||
} else {
|
||||
NavigationAction.NavigateTo(AppScreen.Wallet)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ sealed interface CardConfig {
|
|||
) {
|
||||
return MultiWalletCardConfig
|
||||
}
|
||||
return GenericCardConfig
|
||||
return GenericCardConfig(cardDTO.settings.maxWalletsCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,12 +4,14 @@ import com.tangem.blockchain.common.Blockchain
|
|||
import com.tangem.common.card.EllipticCurve
|
||||
import timber.log.Timber
|
||||
|
||||
object GenericCardConfig : CardConfig {
|
||||
override val mandatoryCurves: List<EllipticCurve>
|
||||
get() = listOf(
|
||||
EllipticCurve.Secp256k1,
|
||||
EllipticCurve.Ed25519,
|
||||
)
|
||||
internal class GenericCardConfig(maxWalletCount: Int) : CardConfig {
|
||||
|
||||
override val mandatoryCurves: List<EllipticCurve> = buildList {
|
||||
add(EllipticCurve.Secp256k1)
|
||||
if (maxWalletCount > 1) {
|
||||
add(EllipticCurve.Ed25519)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Old logic to determine primary curve for blockchain
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue