Updated on 2026-08-14
This commit is contained in:
parent
b39427d355
commit
714ec5474a
11 changed files with 148 additions and 67 deletions
|
|
@ -31,8 +31,8 @@ private class ThrowableErrorConverter : Converter<Throwable, Map<String, String>
|
|||
override fun convert(value: Throwable): Map<String, String> {
|
||||
val unknown = "unknown"
|
||||
return mapOf(
|
||||
AnalyticsParam.ErrorKey to AnalyticsParam.Error.App.value,
|
||||
AnalyticsParam.ErrorDescription to (value.message ?: value.cause?.message ?: unknown),
|
||||
AnalyticsParam.ERROR_KEY to AnalyticsParam.Error.App.value,
|
||||
AnalyticsParam.ERROR_DESCRIPTION to (value.message ?: value.cause?.message ?: unknown),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -43,9 +43,9 @@ class CardSdkErrorConverter : Converter<TangemSdkError, Map<String, String>> {
|
|||
if (value is TangemSdkError.UserCancelled) return emptyMap()
|
||||
|
||||
return mapOf(
|
||||
AnalyticsParam.ErrorKey to AnalyticsParam.Error.CardSdk.value,
|
||||
AnalyticsParam.ErrorCode to value.code.toString(),
|
||||
AnalyticsParam.ErrorDescription to value.toString(),
|
||||
AnalyticsParam.ERROR_KEY to AnalyticsParam.Error.CardSdk.value,
|
||||
AnalyticsParam.ERROR_CODE to value.code.toString(),
|
||||
AnalyticsParam.ERROR_DESCRIPTION to value.toString(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -62,9 +62,9 @@ private class BlockchainSdkErrorConverter(
|
|||
}
|
||||
|
||||
return mapOf(
|
||||
AnalyticsParam.ErrorKey to AnalyticsParam.Error.BlockchainSdk.value,
|
||||
AnalyticsParam.ErrorCode to value.code.toString(),
|
||||
AnalyticsParam.ErrorDescription to "${value.javaClass.simpleName}: ${value.customMessage}",
|
||||
AnalyticsParam.ERROR_KEY to AnalyticsParam.Error.BlockchainSdk.value,
|
||||
AnalyticsParam.ERROR_CODE to value.code.toString(),
|
||||
AnalyticsParam.ERROR_DESCRIPTION to "${value.javaClass.simpleName}: ${value.customMessage}",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -93,15 +93,22 @@ sealed class AnalyticsParam {
|
|||
object Sell : TxSentFrom("Sell")
|
||||
}
|
||||
|
||||
sealed class WalletCreationType(val value: String) {
|
||||
object PrivateKey : WalletCreationType("Private key")
|
||||
object NewSeed : WalletCreationType("New seed")
|
||||
object SeedImport : WalletCreationType("Seed import")
|
||||
}
|
||||
|
||||
companion object Key {
|
||||
const val Source = "Source"
|
||||
const val Balance = "Balance"
|
||||
const val Batch = "Batch"
|
||||
const val ProductType = "Product Type"
|
||||
const val Firmware = "Firmware"
|
||||
const val Currency = "Currency"
|
||||
const val ErrorDescription = "Error Description"
|
||||
const val ErrorCode = "Error Code"
|
||||
const val ErrorKey = "Error Key"
|
||||
const val SOURCE = "Source"
|
||||
const val BALANCE = "Balance"
|
||||
const val BATCH = "Batch"
|
||||
const val PRODUCT_TYPE = "Product Type"
|
||||
const val FIRMWARE = "Firmware"
|
||||
const val CURRENCY = "Currency"
|
||||
const val ERROR_DESCRIPTION = "Error Description"
|
||||
const val ERROR_CODE = "Error Code"
|
||||
const val ERROR_KEY = "Error Key"
|
||||
const val CREATION_TYPE = "Creation type"
|
||||
}
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ sealed class Basic(
|
|||
class BalanceLoaded(balance: AnalyticsParam.CardBalanceState) : Basic(
|
||||
event = "Balance Loaded",
|
||||
params = mapOf(
|
||||
AnalyticsParam.Balance to balance.value,
|
||||
AnalyticsParam.BALANCE to balance.value,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ sealed class Basic(
|
|||
) : Basic(
|
||||
event = "Card Was Scanned",
|
||||
params = mapOf(
|
||||
AnalyticsParam.Source to source.value,
|
||||
AnalyticsParam.SOURCE to source.value,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
@ -34,8 +34,8 @@ sealed class Basic(
|
|||
) : Basic(
|
||||
event = "Signed in",
|
||||
params = mapOf(
|
||||
AnalyticsParam.Currency to currency.value,
|
||||
AnalyticsParam.Batch to batch,
|
||||
AnalyticsParam.CURRENCY to currency.value,
|
||||
AnalyticsParam.BATCH to batch,
|
||||
"Sign in type" to signInType.name,
|
||||
),
|
||||
) {
|
||||
|
|
@ -46,12 +46,12 @@ sealed class Basic(
|
|||
|
||||
class ToppedUp(currency: AnalyticsParam.CardCurrency) : Basic(
|
||||
event = "Topped up",
|
||||
params = mapOf(AnalyticsParam.Currency to currency.value),
|
||||
params = mapOf(AnalyticsParam.CURRENCY to currency.value),
|
||||
)
|
||||
|
||||
class TransactionSent(sentFrom: AnalyticsParam.TxSentFrom) : Basic(
|
||||
event = "Transaction sent",
|
||||
params = mapOf(AnalyticsParam.Source to sentFrom.value),
|
||||
params = mapOf(AnalyticsParam.SOURCE to sentFrom.value),
|
||||
)
|
||||
|
||||
class ScanError(error: Throwable) : Basic(
|
||||
|
|
|
|||
|
|
@ -21,7 +21,12 @@ sealed class Onboarding(
|
|||
|
||||
class ScreenOpened : CreateWallet("Create Wallet Screen Opened")
|
||||
class ButtonCreateWallet : CreateWallet("Button - Create Wallet")
|
||||
class WalletCreatedSuccessfully : CreateWallet("Wallet Created Successfully")
|
||||
class WalletCreatedSuccessfully(
|
||||
creationType: AnalyticsParam.WalletCreationType = AnalyticsParam.WalletCreationType.PrivateKey,
|
||||
) : CreateWallet(
|
||||
event = "Wallet Created Successfully",
|
||||
params = mapOf(AnalyticsParam.CREATION_TYPE to creationType.value),
|
||||
)
|
||||
}
|
||||
|
||||
sealed class Backup(
|
||||
|
|
@ -51,7 +56,7 @@ sealed class Onboarding(
|
|||
|
||||
class ButtonBuyCrypto(currency: AnalyticsParam.CurrencyType) : Topup(
|
||||
event = "Button - Buy Crypto",
|
||||
params = mapOf(AnalyticsParam.Currency to currency.value),
|
||||
params = mapOf(AnalyticsParam.CURRENCY to currency.value),
|
||||
)
|
||||
|
||||
class ButtonShowWalletAddress : Topup("Button - Show the Wallet Address")
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ package com.tangem.tap.common.analytics.paramsInterceptor
|
|||
|
||||
import com.tangem.core.analytics.AnalyticsEvent
|
||||
import com.tangem.core.analytics.api.ParamsInterceptor
|
||||
import com.tangem.domain.models.scan.ProductType
|
||||
import com.tangem.domain.common.util.cardTypesResolver
|
||||
import com.tangem.domain.models.scan.ProductType
|
||||
import com.tangem.domain.models.scan.ScanResponse
|
||||
import com.tangem.tap.common.analytics.converters.ParamCardCurrencyConverter
|
||||
import com.tangem.tap.common.analytics.events.AnalyticsParam
|
||||
|
|
@ -31,12 +31,12 @@ class CardContextInterceptor(
|
|||
scanResponse ?: return
|
||||
|
||||
val card = scanResponse.card
|
||||
params[AnalyticsParam.Batch] = card.batchId
|
||||
params[AnalyticsParam.ProductType] = getProductType(scanResponse)
|
||||
params[AnalyticsParam.Firmware] = card.firmwareVersion.stringValue
|
||||
params[AnalyticsParam.BATCH] = card.batchId
|
||||
params[AnalyticsParam.PRODUCT_TYPE] = getProductType(scanResponse)
|
||||
params[AnalyticsParam.FIRMWARE] = card.firmwareVersion.stringValue
|
||||
|
||||
ParamCardCurrencyConverter().convert(scanResponse.cardTypesResolver)?.let {
|
||||
params[AnalyticsParam.Currency] = it.value
|
||||
params[AnalyticsParam.CURRENCY] = it.value
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package com.tangem.tap.features.onboarding.products.wallet.redux
|
|||
import android.net.Uri
|
||||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.feature.onboarding.data.model.CreateWalletResponse
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.analytics.SeedPhraseSource
|
||||
import com.tangem.tap.domain.tasks.product.CreateProductWalletTaskResponse
|
||||
import org.rekotlin.Action
|
||||
|
||||
|
|
@ -37,6 +38,7 @@ sealed class OnboardingWallet2Action : OnboardingWalletAction() {
|
|||
|
||||
data class ImportWallet(
|
||||
val mnemonicComponents: List<String>,
|
||||
val seedPhraseSource: SeedPhraseSource,
|
||||
val callback: (CompletionResult<CreateWalletResponse>) -> Unit,
|
||||
) : OnboardingWallet2Action()
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,10 @@ import com.tangem.domain.common.util.cardTypesResolver
|
|||
import com.tangem.domain.models.scan.CardDTO
|
||||
import com.tangem.domain.models.scan.ScanResponse
|
||||
import com.tangem.feature.onboarding.data.model.CreateWalletResponse
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.analytics.SeedPhraseSource
|
||||
import com.tangem.operations.backup.BackupService
|
||||
import com.tangem.tap.*
|
||||
import com.tangem.tap.common.analytics.events.AnalyticsParam
|
||||
import com.tangem.tap.common.analytics.events.Onboarding
|
||||
import com.tangem.tap.common.extensions.dispatchDialogShow
|
||||
import com.tangem.tap.common.extensions.dispatchOnMain
|
||||
|
|
@ -215,6 +217,7 @@ private fun handleWallet2Action(action: OnboardingWallet2Action, state: () -> Ap
|
|||
scope.launch {
|
||||
val mediateResult = when (val result = tangemSdkManager.createProductWallet(scanResponse)) {
|
||||
is CompletionResult.Success -> {
|
||||
Analytics.send(Onboarding.CreateWallet.WalletCreatedSuccessfully())
|
||||
val response = CreateWalletResponse(
|
||||
card = result.data.card,
|
||||
derivedKeys = result.data.derivedKeys,
|
||||
|
|
@ -243,6 +246,11 @@ private fun handleWallet2Action(action: OnboardingWallet2Action, state: () -> Ap
|
|||
)
|
||||
) {
|
||||
is CompletionResult.Success -> {
|
||||
val creationType = when (action.seedPhraseSource) {
|
||||
SeedPhraseSource.IMPORTED -> AnalyticsParam.WalletCreationType.SeedImport
|
||||
SeedPhraseSource.GENERATED -> AnalyticsParam.WalletCreationType.NewSeed
|
||||
}
|
||||
Analytics.send(Onboarding.CreateWallet.WalletCreatedSuccessfully(creationType))
|
||||
val response = CreateWalletResponse(
|
||||
card = result.data.card,
|
||||
derivedKeys = result.data.derivedKeys,
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.tangem.common.CompletionResult
|
|||
import com.tangem.common.core.CardIdDisplayFormat
|
||||
import com.tangem.core.analytics.Analytics
|
||||
import com.tangem.feature.onboarding.data.model.CreateWalletResponse
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.analytics.SeedPhraseSource
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.viewmodel.SeedPhraseMediator
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.viewmodel.SeedPhraseRouter
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.viewmodel.SeedPhraseViewModel
|
||||
|
|
@ -495,9 +496,10 @@ class OnboardingWalletFragment :
|
|||
|
||||
override fun importWallet(
|
||||
mnemonicComponents: List<String>,
|
||||
seedPhraseSource: SeedPhraseSource,
|
||||
callback: (CompletionResult<CreateWalletResponse>) -> Unit,
|
||||
) {
|
||||
store.dispatch(OnboardingWallet2Action.ImportWallet(mnemonicComponents, callback))
|
||||
store.dispatch(OnboardingWallet2Action.ImportWallet(mnemonicComponents, seedPhraseSource, callback))
|
||||
}
|
||||
|
||||
override fun allowScreenshots(allow: Boolean) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.tangem.feature.onboarding.presentation.wallet2.analytics
|
||||
|
||||
import com.tangem.core.analytics.AnalyticsEvent
|
||||
|
||||
sealed class SeedPhraseEvents(
|
||||
event: String,
|
||||
params: Map<String, String> = mapOf(),
|
||||
) : AnalyticsEvent(ONBOARDING_SEED_PHRASE, event, params) {
|
||||
|
||||
object ButtonGenerateSeedPhrase : SeedPhraseEvents("Button - Generate Seed Phrase")
|
||||
|
||||
object ButtonImportWallet : SeedPhraseEvents("Button - Import Wallet")
|
||||
object ButtonReadMore : SeedPhraseEvents("Button - Read More")
|
||||
object ButtonImport : SeedPhraseEvents("Button - Import")
|
||||
|
||||
object IntroScreenOpened : SeedPhraseEvents("Seed Intro Screen Opened")
|
||||
object GenerationScreenOpened : SeedPhraseEvents("Seed Generation Screen Opened")
|
||||
object CheckingScreenOpened : SeedPhraseEvents("Seed Checking Screen Opened")
|
||||
object ImportScreenOpened : SeedPhraseEvents("Import Seed Phrase Screen Opened")
|
||||
|
||||
companion object {
|
||||
const val ONBOARDING_SEED_PHRASE = "Onboarding / Seed Phrase"
|
||||
}
|
||||
}
|
||||
|
||||
object OnboardingSeedButtonOtherOptions : AnalyticsEvent(
|
||||
category = "Onboarding / Create Wallet",
|
||||
event = "Button - Other Options",
|
||||
)
|
||||
|
||||
enum class SeedPhraseSource {
|
||||
IMPORTED, GENERATED
|
||||
}
|
||||
|
|
@ -2,13 +2,18 @@ package com.tangem.feature.onboarding.presentation.wallet2.viewmodel
|
|||
|
||||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.feature.onboarding.data.model.CreateWalletResponse
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.analytics.SeedPhraseSource
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
interface SeedPhraseMediator {
|
||||
fun createWallet(callback: (CompletionResult<CreateWalletResponse>) -> Unit)
|
||||
fun importWallet(mnemonicComponents: List<String>, callback: (CompletionResult<CreateWalletResponse>) -> Unit)
|
||||
fun importWallet(
|
||||
mnemonicComponents: List<String>,
|
||||
seedPhraseSource: SeedPhraseSource,
|
||||
callback: (CompletionResult<CreateWalletResponse>) -> Unit,
|
||||
)
|
||||
|
||||
fun onWalletCreated(result: CompletionResult<CreateWalletResponse>)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,20 +8,14 @@ import androidx.compose.ui.text.input.TextFieldValue
|
|||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.tangem.common.CompletionResult
|
||||
import com.tangem.core.analytics.api.AnalyticsEventHandler
|
||||
import com.tangem.feature.onboarding.data.model.CreateWalletResponse
|
||||
import com.tangem.feature.onboarding.domain.SeedPhraseError
|
||||
import com.tangem.feature.onboarding.domain.SeedPhraseInteractor
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.AboutUiAction
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.CheckSeedPhraseUiAction
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.ImportSeedPhraseUiAction
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.IntroUiAction
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.MnemonicGridItem
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.OnboardingSeedPhraseState
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.SeedPhraseField
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.TextFieldState
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.TextFieldUiAction
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.UiActions
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.YourSeedPhraseUiAction
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.analytics.OnboardingSeedButtonOtherOptions
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.analytics.SeedPhraseEvents
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.analytics.SeedPhraseSource
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.model.*
|
||||
import com.tangem.feature.onboarding.presentation.wallet2.ui.stateBuiders.StateBuilder
|
||||
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
|
||||
import com.tangem.utils.coroutines.Debouncer
|
||||
|
|
@ -29,29 +23,23 @@ import com.tangem.utils.extensions.isEven
|
|||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import javax.inject.Inject
|
||||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
*/
|
||||
@Suppress("LargeClass")
|
||||
@HiltViewModel
|
||||
class SeedPhraseViewModel @Inject constructor(
|
||||
private val interactor: SeedPhraseInteractor,
|
||||
private val dispatchers: CoroutineDispatcherProvider,
|
||||
private val analyticsEventHandler: AnalyticsEventHandler,
|
||||
) : ViewModel() {
|
||||
|
||||
private var uiBuilder = StateBuilder(createUiActions())
|
||||
private var uiBuilder = StateBuilder(uiActions = createUiActions())
|
||||
|
||||
var uiState: OnboardingSeedPhraseState by mutableStateOf(uiBuilder.init())
|
||||
private set
|
||||
|
|
@ -92,6 +80,35 @@ class SeedPhraseViewModel @Inject constructor(
|
|||
|
||||
fun setRouter(router: SeedPhraseRouter) {
|
||||
this.router = router
|
||||
subscribeToScreenChanges()
|
||||
}
|
||||
|
||||
private fun subscribeToScreenChanges() {
|
||||
router.currentScreen.onEach { screen ->
|
||||
when (screen) {
|
||||
SeedPhraseScreen.Intro -> {
|
||||
analyticsEventHandler.send(SeedPhraseEvents.IntroScreenOpened)
|
||||
}
|
||||
|
||||
SeedPhraseScreen.AboutSeedPhrase -> {
|
||||
mediator.allowScreenshots(true)
|
||||
}
|
||||
|
||||
SeedPhraseScreen.YourSeedPhrase -> {
|
||||
analyticsEventHandler.send(SeedPhraseEvents.GenerationScreenOpened)
|
||||
mediator.allowScreenshots(false)
|
||||
}
|
||||
|
||||
SeedPhraseScreen.CheckSeedPhrase -> {
|
||||
analyticsEventHandler.send(SeedPhraseEvents.CheckingScreenOpened)
|
||||
mediator.allowScreenshots(true)
|
||||
}
|
||||
|
||||
SeedPhraseScreen.ImportSeedPhrase -> {
|
||||
analyticsEventHandler.send(SeedPhraseEvents.ImportScreenOpened)
|
||||
}
|
||||
}
|
||||
}.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
fun setMediator(mediator: SeedPhraseMediator) {
|
||||
|
|
@ -112,7 +129,9 @@ class SeedPhraseViewModel @Inject constructor(
|
|||
buttonContinueClick = ::buttonContinueClick,
|
||||
),
|
||||
checkSeedPhraseActions = CheckSeedPhraseUiAction(
|
||||
buttonCreateWalletClick = { buttonImportWalletClick(generatedMnemonicComponents) },
|
||||
buttonCreateWalletClick = {
|
||||
buttonImportWalletClick(generatedMnemonicComponents, SeedPhraseSource.GENERATED)
|
||||
},
|
||||
secondTextFieldAction = TextFieldUiAction(
|
||||
onTextFieldChanged = { value -> onTextFieldChanged(SeedPhraseField.Second, value) },
|
||||
),
|
||||
|
|
@ -128,7 +147,9 @@ class SeedPhraseViewModel @Inject constructor(
|
|||
onTextFieldChanged = { value -> onSeedPhraseTextFieldChanged(value) },
|
||||
),
|
||||
suggestedPhraseClick = ::buttonSuggestedPhraseClick,
|
||||
buttonCreateWalletClick = { buttonImportWalletClick(importedMnemonicComponents) },
|
||||
buttonCreateWalletClick = {
|
||||
buttonImportWalletClick(importedMnemonicComponents, SeedPhraseSource.IMPORTED)
|
||||
},
|
||||
),
|
||||
menuChatClick = ::menuChatClick,
|
||||
menuNavigateBackClick = ::menuNavigateBackClick,
|
||||
|
|
@ -246,11 +267,12 @@ class SeedPhraseViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun buttonImportWalletClick(mnemonicComponents: List<String>?) {
|
||||
private fun buttonImportWalletClick(mnemonicComponents: List<String>?, seedPhraseSource: SeedPhraseSource) {
|
||||
analyticsEventHandler.send(SeedPhraseEvents.ButtonImport)
|
||||
mnemonicComponents ?: return
|
||||
|
||||
viewModelScope.launch(dispatchers.io) {
|
||||
mediator.importWallet(mnemonicComponents, ::handleWalletCreationResult)
|
||||
mediator.importWallet(mnemonicComponents, seedPhraseSource, ::handleWalletCreationResult)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -259,6 +281,7 @@ class SeedPhraseViewModel @Inject constructor(
|
|||
is CompletionResult.Success -> {
|
||||
isFinished = true
|
||||
}
|
||||
|
||||
is CompletionResult.Failure -> {
|
||||
// errors shows on the TangemSdk bottom sheet dialog
|
||||
}
|
||||
|
|
@ -275,14 +298,17 @@ class SeedPhraseViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun buttonOtherOptionsClick() {
|
||||
analyticsEventHandler.send(OnboardingSeedButtonOtherOptions)
|
||||
router.openScreen(SeedPhraseScreen.AboutSeedPhrase)
|
||||
}
|
||||
|
||||
private fun buttonReadMoreAboutSeedPhraseClick() {
|
||||
analyticsEventHandler.send(SeedPhraseEvents.ButtonReadMore)
|
||||
router.openUri(URI_ABOUT_SEED_PHRASE)
|
||||
}
|
||||
|
||||
private fun buttonGenerateSeedPhraseClick() {
|
||||
analyticsEventHandler.send(SeedPhraseEvents.ButtonGenerateSeedPhrase)
|
||||
viewModelScope.launchSingle {
|
||||
updateUi { uiBuilder.generateMnemonicComponents(uiState) }
|
||||
delay(DELAY_GENERATE_SEED_PHRASE)
|
||||
|
|
@ -290,7 +316,6 @@ class SeedPhraseViewModel @Inject constructor(
|
|||
.onSuccess { mnemonic ->
|
||||
generatedMnemonicComponents = mnemonic.mnemonicComponents
|
||||
val mnemonicGridItems = generateMnemonicGridList(mnemonic.mnemonicComponents)
|
||||
setScreenshotsEnabled()
|
||||
updateUi {
|
||||
router.openScreen(SeedPhraseScreen.YourSeedPhrase)
|
||||
uiBuilder.mnemonicGenerated(uiState, mnemonicGridItems.toImmutableList())
|
||||
|
|
@ -303,13 +328,6 @@ class SeedPhraseViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun setScreenshotsEnabled() {
|
||||
router.currentScreen.onEach {
|
||||
val allowScreenshots = it != SeedPhraseScreen.YourSeedPhrase
|
||||
mediator.allowScreenshots(allowScreenshots)
|
||||
}.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
private suspend fun generateMnemonicGridList(mnemonicComponents: List<String>): ImmutableList<MnemonicGridItem> {
|
||||
val size = mnemonicComponents.size
|
||||
val splitIndex = if (size.isEven()) size / 2 else size / 2 + 1
|
||||
|
|
@ -337,12 +355,13 @@ class SeedPhraseViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun buttonImportSeedPhraseClick() {
|
||||
analyticsEventHandler.send(SeedPhraseEvents.ButtonImportWallet)
|
||||
router.openScreen(SeedPhraseScreen.ImportSeedPhrase)
|
||||
}
|
||||
|
||||
private fun buttonContinueClick() {
|
||||
analyticsEventHandler.send(SeedPhraseEvents.CheckingScreenOpened)
|
||||
router.openScreen(SeedPhraseScreen.CheckSeedPhrase)
|
||||
mediator.allowScreenshots(true)
|
||||
}
|
||||
|
||||
private fun buttonSuggestedPhraseClick(suggestionIndex: Int) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue