mirror of
https://github.com/status-im/status-react.git
synced 2025-01-26 19:01:17 +00:00
This commit is contained in:
parent
770963447a
commit
0472523a7f
@ -15,13 +15,20 @@
|
|||||||
(rf/dispatch [:open-modal :screen/keycard.empty-create]))
|
(rf/dispatch [:open-modal :screen/keycard.empty-create]))
|
||||||
(rf/dispatch [:keycard/on-application-info-error error])))}]]]}))
|
(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
|
(rf/reg-event-fx :keycard/create.get-phrase
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
{:db (assoc-in db [:keycard :create] nil)
|
{:db (assoc-in db [:keycard :create] nil)
|
||||||
:fx [[:dispatch [:navigate-back]]
|
:fx [[:dispatch [:navigate-back]]
|
||||||
[:dispatch
|
[:dispatch
|
||||||
[:open-modal :screen/backup-recovery-phrase-dark
|
[: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
|
(rf/reg-event-fx :keycard/create.phrase-backed-up
|
||||||
(fn [{:keys [db]} [masked-phrase-vector]]
|
(fn [{:keys [db]} [masked-phrase-vector]]
|
||||||
|
@ -69,6 +69,13 @@
|
|||||||
(rf/dispatch [:keycard/migration.continue])
|
(rf/dispatch [:keycard/migration.continue])
|
||||||
(rf/dispatch [:keycard/on-application-info-error error])))}]]]}))
|
(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
|
(rf/reg-event-fx :keycard/migration.get-phrase
|
||||||
(fn [{:keys [db]}]
|
(fn [{:keys [db]}]
|
||||||
(let [mnemonic (get-in db [:profile/profile :mnemonic])]
|
(let [mnemonic (get-in db [:profile/profile :mnemonic])]
|
||||||
@ -80,7 +87,7 @@
|
|||||||
{:on-success #(rf/dispatch [:keycard/migration.phrase-entered %])}]]
|
{:on-success #(rf/dispatch [:keycard/migration.phrase-entered %])}]]
|
||||||
[:dispatch
|
[:dispatch
|
||||||
[:open-modal :screen/backup-recovery-phrase-dark
|
[: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)}]])]})))
|
:masked-seed-phrase (security/mask-data mnemonic)}]])]})))
|
||||||
|
|
||||||
(rf/reg-event-fx :keycard/migration.phrase-entered
|
(rf/reg-event-fx :keycard/migration.phrase-entered
|
||||||
|
@ -44,19 +44,6 @@
|
|||||||
|
|
||||||
(rf/reg-event-fx :wallet/confirm-account-origin confirm-account-origin)
|
(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
|
(defn seed-phrase-validated
|
||||||
[{:keys [db]} [seed-phrase key-uid on-error]]
|
[{:keys [db]} [seed-phrase key-uid on-error]]
|
||||||
(let [keypair-already-added? (-> db
|
(let [keypair-already-added? (-> db
|
||||||
|
@ -14,15 +14,6 @@
|
|||||||
result-db (:db effects)]
|
result-db (:db effects)]
|
||||||
(is (match? result-db expected-db))))
|
(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
|
(deftest store-account-generated-test
|
||||||
(let [db {:wallet {:ui {:create-account
|
(let [db {:wallet {:ui {:create-account
|
||||||
{:new-keypair {:seed-phrase "test-secret"
|
{:new-keypair {:seed-phrase "test-secret"
|
||||||
|
@ -61,15 +61,43 @@
|
|||||||
:margin-right 12)]
|
:margin-right 12)]
|
||||||
[button (assoc params :word (second options))]])
|
[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
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [random-indices (random-selection)
|
(let [random-indices (random-selection)
|
||||||
quiz-index (reagent/atom 0)
|
quiz-index (reagent/atom 0)
|
||||||
incorrect-count (reagent/atom 0)
|
incorrect-count (reagent/atom 0)
|
||||||
show-error? (reagent/atom false)
|
show-error? (reagent/atom false)
|
||||||
{:keys [seed-phrase]} (rf/sub [:wallet/create-account-new-keypair])
|
{:keys [on-success
|
||||||
unmasked-seed-phrase (security/safe-unmask-data seed-phrase)
|
masked-seed-phrase]} (rf/sub [:get-screen-params])
|
||||||
random-phrase (reagent/atom [])]
|
unmasked-seed-phrase (security/safe-unmask-data masked-seed-phrase)
|
||||||
|
random-phrase (reagent/atom [])]
|
||||||
(fn []
|
(fn []
|
||||||
(rn/use-mount
|
(rn/use-mount
|
||||||
(fn []
|
(fn []
|
||||||
@ -86,10 +114,10 @@
|
|||||||
(reset! quiz-index (inc @quiz-index)))
|
(reset! quiz-index (inc @quiz-index)))
|
||||||
(reset! incorrect-count 0)
|
(reset! incorrect-count 0)
|
||||||
(reset! show-error? false)
|
(reset! show-error? false)
|
||||||
(when (= @quiz-index questions-count)
|
(when (and on-success (= @quiz-index questions-count))
|
||||||
(rf/dispatch [:navigate-to
|
(rf/dispatch [:show-bottom-sheet
|
||||||
:screen/wallet.keypair-name
|
{:content (fn [] [complete-backup-sheet
|
||||||
{:workflow :new-keypair}])))
|
on-success])}])))
|
||||||
(do
|
(do
|
||||||
(when (> @incorrect-count 0)
|
(when (> @incorrect-count 0)
|
||||||
(rf/dispatch [:show-bottom-sheet
|
(rf/dispatch [:show-bottom-sheet
|
||||||
@ -98,7 +126,7 @@
|
|||||||
(reset! show-error? true))))]
|
(reset! show-error? true))))]
|
||||||
[rn/view {:style {:flex 1}}
|
[rn/view {:style {:flex 1}}
|
||||||
[quo/page-nav
|
[quo/page-nav
|
||||||
{:icon-name :i/arrow-left
|
{:icon-name :i/close
|
||||||
:on-press #(rf/dispatch [:navigate-back])
|
:on-press #(rf/dispatch [:navigate-back])
|
||||||
:accessibility-label :top-bar}]
|
:accessibility-label :top-bar}]
|
||||||
[quo/page-top
|
[quo/page-top
|
||||||
|
@ -10,6 +10,13 @@
|
|||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[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
|
(defn- keypair-options
|
||||||
[]
|
[]
|
||||||
[quo/action-drawer
|
[quo/action-drawer
|
||||||
@ -17,10 +24,7 @@
|
|||||||
:accessibility-label :generate-new-keypair
|
:accessibility-label :generate-new-keypair
|
||||||
:label (i18n/label :t/generate-new-keypair)
|
:label (i18n/label :t/generate-new-keypair)
|
||||||
:on-press #(rf/dispatch [:navigate-to :screen/backup-recovery-phrase
|
:on-press #(rf/dispatch [:navigate-to :screen/backup-recovery-phrase
|
||||||
{:on-success (fn [masked-seed-phrase]
|
{:on-success backup-recovery-phrase-success}])}
|
||||||
(rf/dispatch [:wallet/store-new-seed-phrase
|
|
||||||
{:seed-phrase
|
|
||||||
masked-seed-phrase}]))}])}
|
|
||||||
{:icon :i/seed
|
{:icon :i/seed
|
||||||
:accessibility-label :import-using-phrase
|
:accessibility-label :import-using-phrase
|
||||||
:label (i18n/label :t/import-using-phrase)
|
:label (i18n/label :t/import-using-phrase)
|
||||||
|
@ -541,7 +541,7 @@
|
|||||||
:alias-id :wallet.create-account-edit-derivation-path}
|
:alias-id :wallet.create-account-edit-derivation-path}
|
||||||
:component wallet-edit-derivation-path/view}
|
:component wallet-edit-derivation-path/view}
|
||||||
|
|
||||||
{:name :screen/wallet.confirm-backup
|
{:name :screen/confirm-backup
|
||||||
:metrics {:track? true
|
:metrics {:track? true
|
||||||
:alias-id :wallet.create-account-backup-new-keypair-confirm}
|
:alias-id :wallet.create-account-backup-new-keypair-confirm}
|
||||||
:options {:insets {:top? true :bottom? true}}
|
:options {:insets {:top? true :bottom? true}}
|
||||||
|
@ -458,6 +458,7 @@
|
|||||||
"community-thumbnail-image": "Thumbnail image",
|
"community-thumbnail-image": "Thumbnail image",
|
||||||
"community-thumbnail-upload": "Upload",
|
"community-thumbnail-upload": "Upload",
|
||||||
"community-unmuted": "Community unmuted",
|
"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",
|
"complete-hardwallet-setup": "This card is now linked. You need it to sign transactions and unlock your keys",
|
||||||
"completed": "Completed",
|
"completed": "Completed",
|
||||||
"confirm": "Confirm",
|
"confirm": "Confirm",
|
||||||
@ -971,6 +972,7 @@
|
|||||||
"ens-your-your-name": "Your ENS name",
|
"ens-your-your-name": "Your ENS name",
|
||||||
"ensure-both-devices-are-on-the-same-network": "Ensure both devices are on the same network",
|
"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-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-12-words": "Enter the 12 words of your seed phrase, separated by single spaces",
|
||||||
"enter-a-private-key": "Enter a private key",
|
"enter-a-private-key": "Enter a private key",
|
||||||
"enter-a-seed-phrase": "Enter a seed phrase",
|
"enter-a-seed-phrase": "Enter a seed phrase",
|
||||||
@ -2918,6 +2920,7 @@
|
|||||||
"other": "{{count}} words"
|
"other": "{{count}} words"
|
||||||
},
|
},
|
||||||
"write-down-and-store-securely": "Write codes down\n & store them securely",
|
"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-address": "Wrong address",
|
||||||
"wrong-card": "Wrong card",
|
"wrong-card": "Wrong card",
|
||||||
"wrong-card-text": "Tapped card does not correspond to the keys you selected",
|
"wrong-card-text": "Tapped card does not correspond to the keys you selected",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user