[#21652] The main part of a backup flow is missing at Keycard migrati… (#21893)

This commit is contained in:
flexsurfer 2025-01-09 19:20:45 +01:00 committed by GitHub
parent 770963447a
commit 0472523a7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 68 additions and 41 deletions

View File

@ -15,13 +15,20 @@
(rf/dispatch [:open-modal :screen/keycard.empty-create]))
(rf/dispatch [:keycard/on-application-info-error error])))}]]]}))
(defn- backup-recovery-phrase-success
[masked-seed-phrase]
(rf/dispatch [:navigate-back])
(rf/dispatch [:open-modal :screen/confirm-backup
{:masked-seed-phrase masked-seed-phrase
:on-success #(rf/dispatch [:keycard/create.phrase-backed-up %])}]))
(rf/reg-event-fx :keycard/create.get-phrase
(fn [{:keys [db]}]
{:db (assoc-in db [:keycard :create] nil)
:fx [[:dispatch [:navigate-back]]
[:dispatch
[:open-modal :screen/backup-recovery-phrase-dark
{:on-success #(rf/dispatch [:keycard/create.phrase-backed-up %])}]]]}))
{:on-success backup-recovery-phrase-success}]]]}))
(rf/reg-event-fx :keycard/create.phrase-backed-up
(fn [{:keys [db]} [masked-phrase-vector]]

View File

@ -69,6 +69,13 @@
(rf/dispatch [:keycard/migration.continue])
(rf/dispatch [:keycard/on-application-info-error error])))}]]]}))
(defn- backup-recovery-phrase-success
[masked-seed-phrase]
(rf/dispatch [:navigate-back])
(rf/dispatch [:open-modal :screen/confirm-backup
{:masked-seed-phrase masked-seed-phrase
:on-success #(rf/dispatch [:keycard/migration.phrase-backed-up])}]))
(rf/reg-event-fx :keycard/migration.get-phrase
(fn [{:keys [db]}]
(let [mnemonic (get-in db [:profile/profile :mnemonic])]
@ -80,7 +87,7 @@
{:on-success #(rf/dispatch [:keycard/migration.phrase-entered %])}]]
[:dispatch
[:open-modal :screen/backup-recovery-phrase-dark
{:on-success #(rf/dispatch [:keycard/migration.phrase-backed-up])
{:on-success backup-recovery-phrase-success
:masked-seed-phrase (security/mask-data mnemonic)}]])]})))
(rf/reg-event-fx :keycard/migration.phrase-entered

View File

@ -44,19 +44,6 @@
(rf/reg-event-fx :wallet/confirm-account-origin confirm-account-origin)
(defn store-new-seed-phrase
[{:keys [db]} [{:keys [seed-phrase]}]]
{:db (update-in db
[:wallet :ui :create-account :new-keypair]
assoc
:seed-phrase
seed-phrase)
:fx [[:dispatch-later
[{:ms 20
:dispatch [:navigate-to :screen/wallet.confirm-backup]}]]]})
(rf/reg-event-fx :wallet/store-new-seed-phrase store-new-seed-phrase)
(defn seed-phrase-validated
[{:keys [db]} [seed-phrase key-uid on-error]]
(let [keypair-already-added? (-> db

View File

@ -14,15 +14,6 @@
result-db (:db effects)]
(is (match? result-db expected-db))))
(deftest store-seed-phrase-test
(let [db {}
props [{:seed-phrase "test-secret" :random-phrase "random-test"}]
expected-db {:wallet {:ui {:create-account {:new-keypair {:seed-phrase "test-secret"
:random-phrase "random-test"}}}}}
effects (events/store-new-seed-phrase {:db db} props)
result-db (:db effects)]
(is (match? result-db expected-db))))
(deftest store-account-generated-test
(let [db {:wallet {:ui {:create-account
{:new-keypair {:seed-phrase "test-secret"

View File

@ -61,15 +61,43 @@
:margin-right 12)]
[button (assoc params :word (second options))]])
(defn- complete-backup-sheet
[on-success]
(let [customization-color (rf/sub [:profile/customization-color])
[checked? set-checked] (rn/use-state false)]
[:<>
[quo/drawer-top {:title (i18n/label :t/complete-backup)}]
[quo/text
{:style style/cheat-description}
(i18n/label :t/ensure-written-recovery)]
[quo/disclaimer
{:checked? checked?
:container-style {:margin-horizontal 20}
:on-change #(set-checked (not checked?))}
(i18n/label :t/written-seed-ready)]
[quo/bottom-actions
{:actions :two-actions
:button-one-label (i18n/label :t/done)
:button-one-props {:disabled? (not checked?)
:customization-color customization-color
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet])
(on-success))}
:button-two-label (i18n/label :t/cancel)
:button-two-props {:type :grey
:on-press (fn []
(rf/dispatch [:hide-bottom-sheet]))}}]]))
(defn view
[]
(let [random-indices (random-selection)
quiz-index (reagent/atom 0)
incorrect-count (reagent/atom 0)
show-error? (reagent/atom false)
{:keys [seed-phrase]} (rf/sub [:wallet/create-account-new-keypair])
unmasked-seed-phrase (security/safe-unmask-data seed-phrase)
random-phrase (reagent/atom [])]
(let [random-indices (random-selection)
quiz-index (reagent/atom 0)
incorrect-count (reagent/atom 0)
show-error? (reagent/atom false)
{:keys [on-success
masked-seed-phrase]} (rf/sub [:get-screen-params])
unmasked-seed-phrase (security/safe-unmask-data masked-seed-phrase)
random-phrase (reagent/atom [])]
(fn []
(rn/use-mount
(fn []
@ -86,10 +114,10 @@
(reset! quiz-index (inc @quiz-index)))
(reset! incorrect-count 0)
(reset! show-error? false)
(when (= @quiz-index questions-count)
(rf/dispatch [:navigate-to
:screen/wallet.keypair-name
{:workflow :new-keypair}])))
(when (and on-success (= @quiz-index questions-count))
(rf/dispatch [:show-bottom-sheet
{:content (fn [] [complete-backup-sheet
on-success])}])))
(do
(when (> @incorrect-count 0)
(rf/dispatch [:show-bottom-sheet
@ -98,7 +126,7 @@
(reset! show-error? true))))]
[rn/view {:style {:flex 1}}
[quo/page-nav
{:icon-name :i/arrow-left
{:icon-name :i/close
:on-press #(rf/dispatch [:navigate-back])
:accessibility-label :top-bar}]
[quo/page-top

View File

@ -10,6 +10,13 @@
[utils.i18n :as i18n]
[utils.re-frame :as rf]))
(defn- backup-recovery-phrase-success
[masked-seed-phrase]
(rf/dispatch [:navigate-to :screen/confirm-backup
{:masked-seed-phrase masked-seed-phrase
:on-success #(rf/dispatch [:navigate-to :screen/wallet.keypair-name
{:workflow :new-keypair}])}]))
(defn- keypair-options
[]
[quo/action-drawer
@ -17,10 +24,7 @@
:accessibility-label :generate-new-keypair
:label (i18n/label :t/generate-new-keypair)
:on-press #(rf/dispatch [:navigate-to :screen/backup-recovery-phrase
{:on-success (fn [masked-seed-phrase]
(rf/dispatch [:wallet/store-new-seed-phrase
{:seed-phrase
masked-seed-phrase}]))}])}
{:on-success backup-recovery-phrase-success}])}
{:icon :i/seed
:accessibility-label :import-using-phrase
:label (i18n/label :t/import-using-phrase)

View File

@ -541,7 +541,7 @@
:alias-id :wallet.create-account-edit-derivation-path}
:component wallet-edit-derivation-path/view}
{:name :screen/wallet.confirm-backup
{:name :screen/confirm-backup
:metrics {:track? true
:alias-id :wallet.create-account-backup-new-keypair-confirm}
:options {:insets {:top? true :bottom? true}}

View File

@ -458,6 +458,7 @@
"community-thumbnail-image": "Thumbnail image",
"community-thumbnail-upload": "Upload",
"community-unmuted": "Community unmuted",
"complete-backup": "Complete backup",
"complete-hardwallet-setup": "This card is now linked. You need it to sign transactions and unlock your keys",
"completed": "Completed",
"confirm": "Confirm",
@ -971,6 +972,7 @@
"ens-your-your-name": "Your ENS name",
"ensure-both-devices-are-on-the-same-network": "Ensure both devices are on the same network",
"ensure-qr-code-is-in-focus-to-scan": "Ensure that the QR code is in focus to scan",
"ensure-written-recovery": "Ensure you have written down your recovery phrase and have a safe place to keep it. Remember, anyone who has your recovery phrase has access to your funds.",
"enter-12-words": "Enter the 12 words of your seed phrase, separated by single spaces",
"enter-a-private-key": "Enter a private key",
"enter-a-seed-phrase": "Enter a seed phrase",
@ -2918,6 +2920,7 @@
"other": "{{count}} words"
},
"write-down-and-store-securely": "Write codes down\n & store them securely",
"written-seed-ready": "I have written down my recovery phrase and ready to complete backup and remove it from device",
"wrong-address": "Wrong address",
"wrong-card": "Wrong card",
"wrong-card-text": "Tapped card does not correspond to the keys you selected",