[#21586] Keycard migration crashes the app on Android [#21601] Keycard is not empty screen appears at the wrong place of migration flow
This commit is contained in:
parent
2a7da758aa
commit
9f0fb41713
|
@ -71,19 +71,21 @@
|
|||
|
||||
(rf/reg-event-fx :keycard/migration.get-phrase
|
||||
(fn [{:keys [db]}]
|
||||
(let [mnemonic (get-in db [:profile/profile :mnemonic])]
|
||||
{:db (assoc-in db [:keycard :migration] nil)
|
||||
:fx [[:dispatch [:navigate-back]]
|
||||
(if (string/blank? (get-in db [:profile/profile :mnemonic]))
|
||||
(if (string/blank? mnemonic)
|
||||
[:dispatch
|
||||
[:open-modal :screen/use-recovery-phrase
|
||||
[:open-modal :screen/use-recovery-phrase-dark
|
||||
{:on-success #(rf/dispatch [:keycard/migration.phrase-entered %])}]]
|
||||
[:dispatch
|
||||
[:open-modal :screen/backup-recovery-phrase
|
||||
{:on-success #(rf/dispatch [:keycard/migration.phrase-backed-up %])}]])]}))
|
||||
[:open-modal :screen/backup-recovery-phrase-dark
|
||||
{:on-success #(rf/dispatch [:keycard/migration.phrase-backed-up])
|
||||
:masked-seed-phrase (security/mask-data mnemonic)}]])]})))
|
||||
|
||||
(rf/reg-event-fx :keycard/migration.phrase-entered
|
||||
(fn [{:keys [db]} [{:keys [phrase]}]]
|
||||
{:db (assoc-in db [:keycard :migration :masked-phrase] (security/mask-data phrase))
|
||||
{:db (assoc-in db [:keycard :migration :masked-phrase] phrase)
|
||||
:fx [[:dispatch [:navigate-back]]
|
||||
[:dispatch
|
||||
[:open-modal :screen/keycard.authorise
|
||||
|
|
|
@ -53,15 +53,19 @@
|
|||
:3 false})
|
||||
revealed? (reagent/atom false)
|
||||
customization-color (rf/sub [:profile/customization-color])
|
||||
{:keys [on-success]} (rf/sub [:get-screen-params])
|
||||
seed-phrase (reagent/atom [])
|
||||
random-phrase (reagent/atom [])]
|
||||
{:keys [on-success masked-seed-phrase]} (rf/sub [:get-screen-params])
|
||||
seed-phrase (reagent/atom (if masked-seed-phrase
|
||||
(->
|
||||
(security/safe-unmask-data
|
||||
masked-seed-phrase)
|
||||
(string/split #"\s"))
|
||||
[]))]
|
||||
(fn []
|
||||
(let [theme (quo.theme/use-theme)]
|
||||
(rn/use-mount
|
||||
(fn []
|
||||
(native-module/get-random-mnemonic #(reset! seed-phrase (string/split % #"\s")))
|
||||
(native-module/get-random-mnemonic #(reset! random-phrase (string/split % #"\s")))))
|
||||
(when-not masked-seed-phrase
|
||||
(native-module/get-random-mnemonic #(reset! seed-phrase (string/split % #"\s"))))))
|
||||
[rn/view {:style {:flex 1}}
|
||||
[quo/page-nav
|
||||
{:icon-name :i/close
|
||||
|
@ -106,10 +110,7 @@
|
|||
:button-one-label (i18n/label :t/i-have-written)
|
||||
:button-one-props {:disabled? (some false? (vals @checked?))
|
||||
:customization-color customization-color
|
||||
:on-press #(on-success {:masked-seed-phrase
|
||||
(security/mask-data
|
||||
@seed-phrase)
|
||||
:random-phrase @random-phrase})}}]
|
||||
:on-press #(on-success (security/mask-data @seed-phrase))}}]
|
||||
[quo/text
|
||||
{:size :paragraph-2
|
||||
:style (style/description-text theme)}
|
||||
|
|
|
@ -30,12 +30,12 @@
|
|||
(rf/reg-event-fx :wallet/confirm-account-origin confirm-account-origin)
|
||||
|
||||
(defn store-new-seed-phrase
|
||||
[{:keys [db]} [{:keys [seed-phrase random-phrase]}]]
|
||||
[{:keys [db]} [{:keys [seed-phrase]}]]
|
||||
{:db (update-in db
|
||||
[:wallet :ui :create-account :new-keypair]
|
||||
assoc
|
||||
:seed-phrase seed-phrase
|
||||
:random-phrase random-phrase)
|
||||
:seed-phrase
|
||||
seed-phrase)
|
||||
:fx [[:dispatch-later
|
||||
[{:ms 20
|
||||
:dispatch [:navigate-to :screen/wallet.confirm-backup]}]]]})
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
(ns status-im.contexts.wallet.add-account.create-account.new-keypair.confirm-backup.view
|
||||
(:require
|
||||
[clojure.string :as string]
|
||||
[native-module.core :as native-module]
|
||||
[quo.core :as quo]
|
||||
[react-native.core :as rn]
|
||||
[reagent.core :as reagent]
|
||||
|
@ -65,13 +67,18 @@
|
|||
quiz-index (reagent/atom 0)
|
||||
incorrect-count (reagent/atom 0)
|
||||
show-error? (reagent/atom false)
|
||||
{:keys [seed-phrase random-phrase]} (rf/sub [:wallet/create-account-new-keypair])
|
||||
unmasked-seed-phrase (security/safe-unmask-data seed-phrase)]
|
||||
{:keys [seed-phrase]} (rf/sub [:wallet/create-account-new-keypair])
|
||||
unmasked-seed-phrase (security/safe-unmask-data seed-phrase)
|
||||
random-phrase (reagent/atom [])]
|
||||
(fn []
|
||||
(rn/use-mount
|
||||
(fn []
|
||||
(native-module/get-random-mnemonic #(reset! random-phrase (string/split % #"\s")))))
|
||||
(when-not (empty? @random-phrase)
|
||||
(let [current-word-index (get random-indices
|
||||
(min @quiz-index (dec questions-count)))
|
||||
current-word (get unmasked-seed-phrase current-word-index)
|
||||
[options-row-0 options-row-1] (random-words-with-string random-phrase current-word)
|
||||
[options-row-0 options-row-1] (random-words-with-string @random-phrase current-word)
|
||||
on-button-press (fn [word]
|
||||
(if (= word current-word)
|
||||
(do
|
||||
|
@ -129,4 +136,4 @@
|
|||
:options options-row-0}]
|
||||
[buttons-row
|
||||
{:on-press on-button-press
|
||||
:options options-row-1}]]]))))
|
||||
:options options-row-1}]]])))))
|
||||
|
|
|
@ -17,11 +17,10 @@
|
|||
: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 [{:keys [masked-seed-phrase random-phrase]}]
|
||||
{:on-success (fn [masked-seed-phrase]
|
||||
(rf/dispatch [:wallet/store-new-seed-phrase
|
||||
{:seed-phrase masked-seed-phrase
|
||||
:random-phrase
|
||||
random-phrase}]))}])}
|
||||
{:seed-phrase
|
||||
masked-seed-phrase}]))}])}
|
||||
{:icon :i/seed
|
||||
:accessibility-label :import-using-phrase
|
||||
:label (i18n/label :t/import-using-phrase)
|
||||
|
|
|
@ -318,7 +318,8 @@
|
|||
{:name :screen/settings.keycard
|
||||
:metrics {:track? :true
|
||||
:alias-id :settings.keycard}
|
||||
:options {:insets {:top? true :bottom? true}}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component settings.keycard/view}
|
||||
|
||||
{:name :edit-profile
|
||||
|
@ -873,37 +874,44 @@
|
|||
(def keycard-screens
|
||||
[{:name :screen/keycard.check
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component keycard.check/view}
|
||||
|
||||
{:name :screen/keycard.empty
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component keycard.empty/view}
|
||||
|
||||
{:name :screen/keycard.error
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component keycard.error/view}
|
||||
|
||||
{:name :screen/keycard.not-keycard
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component keycard.not-keycard/view}
|
||||
|
||||
{:name :screen/keycard.authorise
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component keycard.authorise/view}
|
||||
|
||||
{:name :screen/keycard.migrate
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component keycard.migrate/view}
|
||||
|
||||
{:name :screen/keycard.re-encrypting
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}
|
||||
:popGesture false
|
||||
:hardwareBackButton {:dismissModalOnPress false
|
||||
:popStackOnPress false}}
|
||||
|
@ -911,7 +919,8 @@
|
|||
|
||||
{:name :screen/keycard.migrate.success
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}
|
||||
:popGesture false
|
||||
:hardwareBackButton {:dismissModalOnPress false
|
||||
:popStackOnPress false}}
|
||||
|
@ -919,7 +928,8 @@
|
|||
|
||||
{:name :screen/keycard.migrate.fail
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}
|
||||
:popGesture false
|
||||
:hardwareBackButton {:dismissModalOnPress false
|
||||
:popStackOnPress false}}
|
||||
|
@ -927,17 +937,20 @@
|
|||
|
||||
{:name :screen/keycard.pin.create
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component keycard.pin.create/view}
|
||||
|
||||
{:name :screen/keycard.pin.enter
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component keycard.pin.enter/view}
|
||||
|
||||
{:name :screen/keycard.profile-keys
|
||||
:metrics {:track? :true}
|
||||
:options {:insets {:top? true :bottom? true}}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component keycard.migrate.profile-keys/view}])
|
||||
|
||||
(defn screens
|
||||
|
@ -1009,10 +1022,21 @@
|
|||
:options {:insets {:top? true :bottom? true}}
|
||||
:component backup-recovery-phrase/view}
|
||||
|
||||
{:name :screen/backup-recovery-phrase-dark
|
||||
:metrics {:track? true}
|
||||
:options {:theme :dark
|
||||
:insets {:top? true :bottom? true}}
|
||||
:component backup-recovery-phrase/view}
|
||||
|
||||
{:name :screen/use-recovery-phrase
|
||||
:metrics {:track? true}
|
||||
:component enter-seed-phrase/view}
|
||||
|
||||
{:name :screen/use-recovery-phrase-dark
|
||||
:metrics {:track? true}
|
||||
:options {:theme :dark}
|
||||
:component enter-seed-phrase/view}
|
||||
|
||||
{:name :screen/profile.profiles
|
||||
:metrics {:track? true
|
||||
:alias-id :app.profiles}
|
||||
|
|
Loading…
Reference in New Issue