fix(@desktop/keycard): onboarding flow `I'm new to Status` -> `Import a seed phrase` -> `Import a seed phrase into a new Keycard` updated

Onboarding flow updated according to the latest related
figma changes.
This commit is contained in:
Sale Djenic 2022-09-29 09:41:20 +02:00 committed by saledjenic
parent 9be07efec3
commit eb5ad8c911
11 changed files with 46 additions and 23 deletions

View File

@ -13,8 +13,9 @@ proc delete*(self: KeycardCreatePinState) =
method executeBackCommand*(self: KeycardCreatePinState, controller: Controller) =
controller.setPin("")
controller.setPinMatch(false)
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
controller.cancelCurrentFlow()
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys or
self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
controller.cancelCurrentFlow()
method getNextPrimaryState*(self: KeycardCreatePinState, controller: Controller): State =
if not self.pinValid:

View File

@ -9,8 +9,9 @@ proc delete*(self: KeycardInsertKeycardState) =
self.State.delete
method executeBackCommand*(self: KeycardInsertKeycardState, controller: Controller) =
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
controller.cancelCurrentFlow()
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys or
self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
controller.cancelCurrentFlow()
method resolveKeycardNextState*(self: KeycardInsertKeycardState, keycardFlowType: string, keycardEvent: KeycardEvent,
controller: Controller): State =

View File

@ -9,8 +9,9 @@ proc delete*(self: KeycardInsertedKeycardState) =
self.State.delete
method executeBackCommand*(self: KeycardInsertedKeycardState, controller: Controller) =
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
controller.cancelCurrentFlow()
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys or
self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
controller.cancelCurrentFlow()
method getNextPrimaryState*(self: KeycardInsertedKeycardState, controller: Controller): State =
return createState(StateType.KeycardReadingKeycard, self.flowType, self.getBackState)

View File

@ -9,8 +9,9 @@ proc delete*(self: KeycardPluginReaderState) =
self.State.delete
method executeBackCommand*(self: KeycardPluginReaderState, controller: Controller) =
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
controller.cancelCurrentFlow()
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys or
self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
controller.cancelCurrentFlow()
method resolveKeycardNextState*(self: KeycardPluginReaderState, keycardFlowType: string, keycardEvent: KeycardEvent,
controller: Controller): State =

View File

@ -9,8 +9,9 @@ proc delete*(self: KeycardReadingKeycardState) =
self.State.delete
method executeBackCommand*(self: KeycardReadingKeycardState, controller: Controller) =
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
controller.cancelCurrentFlow()
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys or
self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
controller.cancelCurrentFlow()
method getNextPrimaryState*(self: KeycardReadingKeycardState, controller: Controller): State =
let (flowType, flowEvent) = controller.getLastReceivedKeycardData()

View File

@ -9,9 +9,12 @@ proc delete*(self: KeycardRecognizedKeycardState) =
self.State.delete
method executeBackCommand*(self: KeycardRecognizedKeycardState, controller: Controller) =
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
controller.cancelCurrentFlow()
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys or
self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
controller.cancelCurrentFlow()
method getNextPrimaryState*(self: KeycardRecognizedKeycardState, controller: Controller): State =
if self.flowType == FlowType.FirstRunNewUserNewKeycardKeys:
return createState(StateType.KeycardCreatePin, self.flowType, self.getBackState)
if self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
return createState(StateType.UserProfileEnterSeedPhrase, self.flowType, self.getBackState)

View File

@ -230,15 +230,22 @@ proc ensureReaderAndCardPresenceAndResolveNextOnboardingState*(state: State, key
if keycardFlowType == ResponseTypeValueEnterNewPIN and
keycardEvent.error.len > 0 and
keycardEvent.error == ErrorRequireInit:
return createState(StateType.KeycardCreatePin, state.flowType, state.getBackState)
if state.stateType == StateType.UserProfileEnterSeedPhrase:
return createState(StateType.KeycardCreatePin, state.flowType, state.getBackState)
return createState(StateType.KeycardRecognizedKeycard, state.flowType, state.getBackState)
if keycardFlowType == ResponseTypeValueEnterPIN and
keycardEvent.error.len == 0:
return createState(StateType.KeycardNotEmpty, state.flowType, state.getBackState)
if keycardFlowType == ResponseTypeValueSwapCard and
keycardEvent.error.len > 0 and
(keycardEvent.error == ErrorHasKeys or
keycardEvent.error == RequestParamPUKRetries):
return createState(StateType.KeycardNotEmpty, state.flowType, state.getBackState)
keycardEvent.error.len > 0:
if keycardEvent.error == ErrorNotAKeycard:
return createState(StateType.KeycardNotKeycard, state.flowType, state.getBackState)
if keycardEvent.error == RequestParamFreeSlots:
return createState(StateType.KeycardLocked, state.flowType, state.getBackState)
if keycardEvent.error == RequestParamPUKRetries:
return createState(StateType.KeycardLocked, state.flowType, state.getBackState)
if keycardEvent.error == ErrorHasKeys:
return createState(StateType.KeycardNotEmpty, state.flowType, state.getBackState)
if keycardFlowType == ResponseTypeValueKeycardFlowResult and
keycardEvent.keyUid.len > 0:
controller.setKeyUid(keycardEvent.keyUid)

View File

@ -31,7 +31,7 @@ method executePrimaryCommand*(self: UserProfileEnterSeedPhraseState, controller:
self.successfulImport = controller.importMnemonic()
if self.successfulImport:
if self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
controller.runLoadAccountFlow(controller.getSeedPhraseLength(), controller.getSeedPhrase(), puk = "", factoryReset = true)
controller.storeSeedPhraseToKeycard(controller.getSeedPhraseLength(), controller.getSeedPhrase())
elif self.flowType == FlowType.FirstRunOldUserKeycardImport:
controller.runLoadAccountFlow(controller.getSeedPhraseLength(), controller.getSeedPhrase(), puk = "", factoryReset = true)

View File

@ -8,8 +8,17 @@ proc newUserProfileImportSeedPhraseState*(flowType: FlowType, backState: State):
proc delete*(self: UserProfileImportSeedPhraseState) =
self.State.delete
method executeBackCommand*(self: UserProfileImportSeedPhraseState, controller: Controller) =
if self.flowType == FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard:
controller.cancelCurrentFlow()
method getNextPrimaryState*(self: UserProfileImportSeedPhraseState, controller: Controller): State =
return createState(StateType.UserProfileEnterSeedPhrase, FlowType.FirstRunNewUserImportSeedPhrase, self)
method getNextSecondaryState*(self: UserProfileImportSeedPhraseState, controller: Controller): State =
return createState(StateType.UserProfileEnterSeedPhrase, FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard, self.getBackState)
method executeSecondaryCommand*(self: UserProfileImportSeedPhraseState, controller: Controller) =
self.setFlowType(FlowType.FirstRunNewUserImportSeedPhraseIntoKeycard)
controller.runLoadAccountFlow()
method resolveKeycardNextState*(self: UserProfileImportSeedPhraseState, keycardFlowType: string, keycardEvent: KeycardEvent,
controller: Controller): State =
return ensureReaderAndCardPresenceAndResolveNextOnboardingState(self, keycardFlowType, keycardEvent, controller)

View File

@ -159,9 +159,7 @@ QtObject:
self.threadpool.start(arg)
proc startLoadAccountFlow*(self: Service, seedPhraseLength: int, seedPhrase: string, puk: string, factoryReset: bool) =
var payload = %* {
RequestParamOverwrite: true
}
var payload = %* { }
if seedPhrase.len > 0 and seedPhraseLength > 0:
payload[RequestParamMnemonic] = %* seedPhrase
payload[RequestParamMnemonicLen] = %* seedPhraseLength

View File

@ -133,6 +133,7 @@ Item {
PropertyChanges {
target: info
text: qsTr("It is very important that you do not lose this PIN")
color: Theme.palette.dangerColor1
}
PropertyChanges {
target: message