-
Notifications
You must be signed in to change notification settings - Fork 991
Keycard - Allow user to migrate existing Profile [Part 2] #21408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ | |
(take 7))) | ||
|
||
(defn recovery-phrase-screen | ||
[{:keys [banner-offset initial-insets keypair title recovering-keypair? render-controls]}] | ||
[{:keys [banner-offset initial-insets keypair title on-success render-controls]}] | ||
(reagent/with-let [keyboard-shown? (reagent/atom false) | ||
keyboard-show-listener (.addListener rn/keyboard | ||
"keyboardDidShow" | ||
|
@@ -120,14 +120,20 @@ | |
(reset! seed-phrase new-phrase)) | ||
on-submit (fn [] | ||
(swap! seed-phrase clean-seed-phrase) | ||
(if recovering-keypair? | ||
(rf/dispatch [:wallet/seed-phrase-entered | ||
(security/mask-data | ||
@seed-phrase) | ||
set-invalid-seed-phrase]) | ||
(rf/dispatch [:onboarding/seed-phrase-entered | ||
(security/mask-data @seed-phrase) | ||
set-invalid-seed-phrase])))] | ||
(rf/dispatch | ||
[:profile.recover/validate-recovery-phrase | ||
(security/mask-data @seed-phrase) | ||
{:on-success (fn [mnemonic key-uid] | ||
(if on-success | ||
(on-success | ||
{:key-uid key-uid | ||
:phrase mnemonic | ||
:on-error | ||
set-invalid-seed-phrase}) | ||
(rf/dispatch | ||
[:onboarding/seed-phrase-validated | ||
mnemonic key-uid]))) | ||
:on-error set-invalid-seed-phrase}]))] | ||
(let [words-coll (mnemonic/passphrase->words @seed-phrase) | ||
last-word (peek words-coll) | ||
pick-suggested-word (fn [pressed-word] | ||
|
@@ -191,7 +197,7 @@ | |
[rn/view {:style style/keyboard-container} | ||
[quo/predictive-keyboard | ||
{:type suggestions-state | ||
:blur? (not recovering-keypair?) | ||
:blur? (not on-success) | ||
:text suggestions-text | ||
:words (keyboard-suggestions last-word) | ||
:on-press pick-suggested-word}]])]) | ||
|
@@ -200,7 +206,7 @@ | |
(.remove keyboard-hide-listener)))) | ||
|
||
(defn screen | ||
[{:keys [title keypair navigation-icon recovering-keypair? render-controls]}] | ||
[{:keys [title keypair navigation-icon on-success render-controls]}] | ||
(let [[insets _] (rn/use-state (safe-area/get-insets)) | ||
banner-offset (rf/sub [:alert-banners/top-margin])] | ||
[rn/view {:style style/full-layout} | ||
|
@@ -209,21 +215,22 @@ | |
{:margin-top (:top insets) | ||
:background :blur | ||
:icon-name (or navigation-icon | ||
(if recovering-keypair? :i/close :i/arrow-left)) | ||
(if on-success :i/close :i/arrow-left)) | ||
:on-press #(rf/dispatch [:navigate-back])}] | ||
[recovery-phrase-screen | ||
{:title title | ||
:keypair keypair | ||
:render-controls render-controls | ||
:banner-offset banner-offset | ||
:initial-insets insets | ||
:recovering-keypair? recovering-keypair?}]]])) | ||
{:title title | ||
:keypair keypair | ||
:render-controls render-controls | ||
:banner-offset banner-offset | ||
:initial-insets insets | ||
:on-success on-success}]]])) | ||
|
||
(defn view | ||
[] | ||
(let [{:keys [recovering-keypair?]} (rf/sub [:get-screen-params])] | ||
(let [{:keys [on-success]} (rf/sub [:get-screen-params])] | ||
(rn/use-unmount | ||
#(rf/dispatch [:onboarding/clear-navigated-to-enter-seed-phrase-from-screen])) | ||
(when-not on-success | ||
#(rf/dispatch [:onboarding/clear-navigated-to-enter-seed-phrase-from-screen]))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here, later |
||
[screen | ||
{:title (i18n/label :t/use-recovery-phrase) | ||
:recovering-keypair? recovering-keypair?}])) | ||
{:title (i18n/label :t/use-recovery-phrase) | ||
:on-success on-success}])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...keypair/backup_recovery_phrase/style.cljs → ...profile/backup_recovery_phrase/style.cljs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,31 @@ | ||
(ns status-im.contexts.profile.recover.effects | ||
(:require | ||
[native-module.core :as native-module] | ||
[utils.re-frame :as rf])) | ||
[promesa.core :as promesa] | ||
[utils.re-frame :as rf] | ||
[utils.security.core :as security] | ||
[utils.transforms :as transforms])) | ||
|
||
(rf/reg-fx :effects.profile/restore-and-login | ||
(fn [request] | ||
;;"node.login" signal will be triggered as a callback | ||
(native-module/restore-account-and-login request))) | ||
|
||
(defn validate-mnemonic | ||
[mnemonic] | ||
(-> mnemonic | ||
(security/safe-unmask-data) | ||
(native-module/validate-mnemonic) | ||
(promesa/then (fn [result] | ||
(let [{:keys [keyUID]} (transforms/json->clj result)] | ||
{:key-uid keyUID}))))) | ||
|
||
(rf/reg-fx :effects.profile/validate-recovery-phrase | ||
(fn [[mnemonic on-success on-error]] | ||
(-> (validate-mnemonic mnemonic) | ||
(promesa/then (fn [{:keys [key-uid]}] | ||
(when (fn? on-success) | ||
(on-success mnemonic key-uid)))) | ||
(promesa/catch (fn [error] | ||
(when (and error (fn? on-error)) | ||
(on-error error))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onboarding still a special case, should be refactored later