Keycard - Allow user to migrate existing Profile [Part 2] (#21408)
This commit is contained in:
parent
9e43aa04c7
commit
15a1a15c08
|
@ -96,7 +96,7 @@
|
||||||
(take 7)))
|
(take 7)))
|
||||||
|
|
||||||
(defn recovery-phrase-screen
|
(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)
|
(reagent/with-let [keyboard-shown? (reagent/atom false)
|
||||||
keyboard-show-listener (.addListener rn/keyboard
|
keyboard-show-listener (.addListener rn/keyboard
|
||||||
"keyboardDidShow"
|
"keyboardDidShow"
|
||||||
|
@ -120,14 +120,20 @@
|
||||||
(reset! seed-phrase new-phrase))
|
(reset! seed-phrase new-phrase))
|
||||||
on-submit (fn []
|
on-submit (fn []
|
||||||
(swap! seed-phrase clean-seed-phrase)
|
(swap! seed-phrase clean-seed-phrase)
|
||||||
(if recovering-keypair?
|
(rf/dispatch
|
||||||
(rf/dispatch [:wallet/seed-phrase-entered
|
[:profile.recover/validate-recovery-phrase
|
||||||
(security/mask-data
|
(security/mask-data @seed-phrase)
|
||||||
@seed-phrase)
|
{:on-success (fn [mnemonic key-uid]
|
||||||
set-invalid-seed-phrase])
|
(if on-success
|
||||||
(rf/dispatch [:onboarding/seed-phrase-entered
|
(on-success
|
||||||
(security/mask-data @seed-phrase)
|
{:key-uid key-uid
|
||||||
set-invalid-seed-phrase])))]
|
: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)
|
(let [words-coll (mnemonic/passphrase->words @seed-phrase)
|
||||||
last-word (peek words-coll)
|
last-word (peek words-coll)
|
||||||
pick-suggested-word (fn [pressed-word]
|
pick-suggested-word (fn [pressed-word]
|
||||||
|
@ -191,7 +197,7 @@
|
||||||
[rn/view {:style style/keyboard-container}
|
[rn/view {:style style/keyboard-container}
|
||||||
[quo/predictive-keyboard
|
[quo/predictive-keyboard
|
||||||
{:type suggestions-state
|
{:type suggestions-state
|
||||||
:blur? (not recovering-keypair?)
|
:blur? (not on-success)
|
||||||
:text suggestions-text
|
:text suggestions-text
|
||||||
:words (keyboard-suggestions last-word)
|
:words (keyboard-suggestions last-word)
|
||||||
:on-press pick-suggested-word}]])])
|
:on-press pick-suggested-word}]])])
|
||||||
|
@ -200,7 +206,7 @@
|
||||||
(.remove keyboard-hide-listener))))
|
(.remove keyboard-hide-listener))))
|
||||||
|
|
||||||
(defn screen
|
(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))
|
(let [[insets _] (rn/use-state (safe-area/get-insets))
|
||||||
banner-offset (rf/sub [:alert-banners/top-margin])]
|
banner-offset (rf/sub [:alert-banners/top-margin])]
|
||||||
[rn/view {:style style/full-layout}
|
[rn/view {:style style/full-layout}
|
||||||
|
@ -209,21 +215,22 @@
|
||||||
{:margin-top (:top insets)
|
{:margin-top (:top insets)
|
||||||
:background :blur
|
:background :blur
|
||||||
:icon-name (or navigation-icon
|
: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])}]
|
:on-press #(rf/dispatch [:navigate-back])}]
|
||||||
[recovery-phrase-screen
|
[recovery-phrase-screen
|
||||||
{:title title
|
{:title title
|
||||||
:keypair keypair
|
:keypair keypair
|
||||||
:render-controls render-controls
|
:render-controls render-controls
|
||||||
:banner-offset banner-offset
|
:banner-offset banner-offset
|
||||||
:initial-insets insets
|
:initial-insets insets
|
||||||
:recovering-keypair? recovering-keypair?}]]]))
|
:on-success on-success}]]]))
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [{:keys [recovering-keypair?]} (rf/sub [:get-screen-params])]
|
(let [{:keys [on-success]} (rf/sub [:get-screen-params])]
|
||||||
(rn/use-unmount
|
(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])))
|
||||||
[screen
|
[screen
|
||||||
{:title (i18n/label :t/use-recovery-phrase)
|
{:title (i18n/label :t/use-recovery-phrase)
|
||||||
:recovering-keypair? recovering-keypair?}]))
|
:on-success on-success}]))
|
||||||
|
|
|
@ -72,22 +72,21 @@
|
||||||
|
|
||||||
(rf/reg-event-fx :keycard/on-get-application-info-success
|
(rf/reg-event-fx :keycard/on-get-application-info-success
|
||||||
(fn [{:keys [db]} [application-info {:keys [key-uid on-success-fx]}]]
|
(fn [{:keys [db]} [application-info {:keys [key-uid on-success-fx]}]]
|
||||||
(let [error (keycard.utils/validate-application-info key-uid application-info)]
|
(if-let [error (keycard.utils/validate-application-info key-uid application-info)]
|
||||||
(if error
|
(case error
|
||||||
(case error
|
:keycard/error.not-keycard
|
||||||
:keycard/error.not-keycard
|
{:fx [[:dispatch [:keycard/disconnect]]
|
||||||
{:fx [[:dispatch [:keycard/disconnect]]
|
[:dispatch [:open-modal :screen/keycard.not-keycard]]]}
|
||||||
[:dispatch [:open-modal :screen/keycard.not-keycard]]]}
|
:keycard/error.keycard-blank
|
||||||
:keycard/error.keycard-blank
|
{:fx [[:dispatch [:keycard/disconnect]]
|
||||||
{:fx [[:dispatch [:keycard/disconnect]]
|
[:dispatch [:open-modal :screen/keycard.empty]]]}
|
||||||
[:dispatch [:open-modal :screen/keycard.empty]]]}
|
{:db (assoc-in db [:keycard :application-info-error] error)
|
||||||
{:db (assoc-in db [:keycard :application-info-error] error)
|
:fx [[:dispatch [:keycard/disconnect]]
|
||||||
:fx [[:dispatch [:keycard/disconnect]]
|
[:dispatch [:open-modal :screen/keycard.error]]]})
|
||||||
[:dispatch [:open-modal :screen/keycard.error]]]})
|
{:db (-> db
|
||||||
{:db (-> db
|
(assoc-in [:keycard :application-info] application-info)
|
||||||
(assoc-in [:keycard :application-info] application-info)
|
(assoc-in [:keycard :pin :status] :verifying))
|
||||||
(assoc-in [:keycard :pin :status] :verifying))
|
:fx on-success-fx})))
|
||||||
:fx on-success-fx}))))
|
|
||||||
|
|
||||||
(rf/reg-event-fx :keycard/get-application-info
|
(rf/reg-event-fx :keycard/get-application-info
|
||||||
(fn [_ [{:keys [on-success on-failure]}]]
|
(fn [_ [{:keys [on-success on-failure]}]]
|
||||||
|
|
|
@ -6,9 +6,10 @@
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [profile-name (rf/sub [:profile/name])
|
(let [profile-name (rf/sub [:profile/name])
|
||||||
profile-picture (rf/sub [:profile/image])
|
profile-picture (rf/sub [:profile/image])
|
||||||
customization-color (rf/sub [:profile/customization-color])]
|
customization-color (rf/sub [:profile/customization-color])
|
||||||
|
recovery-phrase-backed-up? (rf/sub [:profile/recovery-phrase-backed-up?])]
|
||||||
[:<>
|
[:<>
|
||||||
[quo/drawer-top
|
[quo/drawer-top
|
||||||
{:type :context-tag
|
{:type :context-tag
|
||||||
|
@ -27,7 +28,11 @@
|
||||||
[quo/bottom-actions
|
[quo/bottom-actions
|
||||||
{:actions :two-actions
|
{:actions :two-actions
|
||||||
:button-one-label (i18n/label :t/continue)
|
:button-one-label (i18n/label :t/continue)
|
||||||
:button-one-props {:on-press #()}
|
:button-one-props {:on-press #(if recovery-phrase-backed-up?
|
||||||
|
(rf/dispatch [:open-modal :screen/use-recovery-phrase
|
||||||
|
{:on-success (fn [])}])
|
||||||
|
(rf/dispatch [:open-modal :screen/backup-recovery-phrase
|
||||||
|
{:on-success (fn [])}]))}
|
||||||
:button-two-label (i18n/label :t/cancel)
|
:button-two-label (i18n/label :t/cancel)
|
||||||
:button-two-props {:type :grey
|
:button-two-props {:type :grey
|
||||||
:on-press #(rf/dispatch [:hide-bottom-sheet])}}]]))
|
:on-press #(rf/dispatch [:hide-bottom-sheet])}}]]))
|
||||||
|
|
|
@ -131,15 +131,6 @@
|
||||||
[:open-modal :screen/onboarding.enable-biometrics]
|
[:open-modal :screen/onboarding.enable-biometrics]
|
||||||
[:open-modal :screen/onboarding.enable-notifications])}))
|
[:open-modal :screen/onboarding.enable-notifications])}))
|
||||||
|
|
||||||
(rf/defn seed-phrase-entered
|
|
||||||
{:events [:onboarding/seed-phrase-entered]}
|
|
||||||
[_ seed-phrase on-error]
|
|
||||||
{:multiaccount/validate-mnemonic [seed-phrase
|
|
||||||
(fn [mnemonic key-uid]
|
|
||||||
(re-frame/dispatch [:onboarding/seed-phrase-validated
|
|
||||||
mnemonic key-uid]))
|
|
||||||
on-error]})
|
|
||||||
|
|
||||||
(rf/defn seed-phrase-validated
|
(rf/defn seed-phrase-validated
|
||||||
{:events [:onboarding/seed-phrase-validated]}
|
{:events [:onboarding/seed-phrase-validated]}
|
||||||
[{:keys [db]} seed-phrase key-uid]
|
[{:keys [db]} seed-phrase key-uid]
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(ns status-im.contexts.wallet.add-account.create-account.new-keypair.backup-recovery-phrase.style
|
(ns status-im.contexts.profile.backup-recovery-phrase.style
|
||||||
(:require
|
(:require
|
||||||
[quo.foundations.colors :as colors]
|
[quo.foundations.colors :as colors]
|
||||||
[react-native.platform :as platform]))
|
[react-native.platform :as platform]))
|
|
@ -1,4 +1,4 @@
|
||||||
(ns status-im.contexts.wallet.add-account.create-account.new-keypair.backup-recovery-phrase.view
|
(ns status-im.contexts.profile.backup-recovery-phrase.view
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[native-module.core :as native-module]
|
[native-module.core :as native-module]
|
||||||
|
@ -6,8 +6,7 @@
|
||||||
[quo.theme :as quo.theme]
|
[quo.theme :as quo.theme]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[reagent.core :as reagent]
|
[reagent.core :as reagent]
|
||||||
[status-im.contexts.wallet.add-account.create-account.new-keypair.backup-recovery-phrase.style :as
|
[status-im.contexts.profile.backup-recovery-phrase.style :as style]
|
||||||
style]
|
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]
|
[utils.re-frame :as rf]
|
||||||
[utils.security.core :as security]))
|
[utils.security.core :as security]))
|
||||||
|
@ -45,20 +44,20 @@
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [step-labels [:t/backup-step-1 :t/backup-step-2 :t/backup-step-3
|
(let [step-labels [:t/backup-step-1 :t/backup-step-2 :t/backup-step-3
|
||||||
:t/backup-step-4]
|
:t/backup-step-4]
|
||||||
checked? (reagent/atom
|
checked? (reagent/atom
|
||||||
{:0 false
|
{:0 false
|
||||||
:1 false
|
:1 false
|
||||||
:2 false
|
:2 false
|
||||||
:3 false})
|
:3 false})
|
||||||
revealed? (reagent/atom false)
|
revealed? (reagent/atom false)
|
||||||
customization-color (rf/sub [:profile/customization-color])
|
customization-color (rf/sub [:profile/customization-color])
|
||||||
seed-phrase (reagent/atom [])
|
{:keys [on-success]} (rf/sub [:get-screen-params])
|
||||||
random-phrase (reagent/atom [])]
|
seed-phrase (reagent/atom [])
|
||||||
|
random-phrase (reagent/atom [])]
|
||||||
(fn []
|
(fn []
|
||||||
(let [theme (quo.theme/use-theme)]
|
(let [theme (quo.theme/use-theme)]
|
||||||
|
|
||||||
(rn/use-mount
|
(rn/use-mount
|
||||||
(fn []
|
(fn []
|
||||||
(native-module/get-random-mnemonic #(reset! seed-phrase (string/split % #"\s")))
|
(native-module/get-random-mnemonic #(reset! seed-phrase (string/split % #"\s")))
|
||||||
|
@ -107,10 +106,10 @@
|
||||||
:button-one-label (i18n/label :t/i-have-written)
|
:button-one-label (i18n/label :t/i-have-written)
|
||||||
:button-one-props {:disabled? (some false? (vals @checked?))
|
:button-one-props {:disabled? (some false? (vals @checked?))
|
||||||
:customization-color customization-color
|
:customization-color customization-color
|
||||||
:on-press #(rf/dispatch [:wallet/store-new-seed-phrase
|
:on-press #(on-success {:masked-seed-phrase
|
||||||
{:seed-phrase (security/mask-data
|
(security/mask-data
|
||||||
@seed-phrase)
|
@seed-phrase)
|
||||||
:random-phrase @random-phrase}])}}]
|
:random-phrase @random-phrase})}}]
|
||||||
[quo/text
|
[quo/text
|
||||||
{:size :paragraph-2
|
{:size :paragraph-2
|
||||||
:style (style/description-text theme)}
|
:style (style/description-text theme)}
|
|
@ -1,9 +1,31 @@
|
||||||
(ns status-im.contexts.profile.recover.effects
|
(ns status-im.contexts.profile.recover.effects
|
||||||
(:require
|
(:require
|
||||||
[native-module.core :as native-module]
|
[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
|
(rf/reg-fx :effects.profile/restore-and-login
|
||||||
(fn [request]
|
(fn [request]
|
||||||
;;"node.login" signal will be triggered as a callback
|
;;"node.login" signal will be triggered as a callback
|
||||||
(native-module/restore-account-and-login request)))
|
(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)))))))
|
||||||
|
|
|
@ -24,3 +24,7 @@
|
||||||
:imagePath (profile.config/strip-file-prefix image-path)
|
:imagePath (profile.config/strip-file-prefix image-path)
|
||||||
:customizationColor (or color constants/profile-default-color)
|
:customizationColor (or color constants/profile-default-color)
|
||||||
:fetchBackup true)}))
|
:fetchBackup true)}))
|
||||||
|
|
||||||
|
(rf/reg-event-fx :profile.recover/validate-recovery-phrase
|
||||||
|
(fn [_ [phrase {:keys [on-success on-error]}]]
|
||||||
|
{:effects.profile/validate-recovery-phrase [phrase on-success on-error]}))
|
||||||
|
|
|
@ -49,13 +49,14 @@
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
(let [theme (quo.theme/use-theme)
|
(let [theme (quo.theme/use-theme)
|
||||||
insets (safe-area/get-insets)
|
insets (safe-area/get-insets)
|
||||||
customization-color (rf/sub [:profile/customization-color])
|
customization-color (rf/sub [:profile/customization-color])
|
||||||
scroll-y (reanimated/use-shared-value 0)
|
scroll-y (reanimated/use-shared-value 0)
|
||||||
profile (rf/sub [:profile/profile])
|
profile (rf/sub [:profile/profile])
|
||||||
full-name (profile.utils/displayed-name profile)
|
recovery-phrase-backed-up? (rf/sub [:profile/recovery-phrase-backed-up?])
|
||||||
on-scroll (rn/use-callback #(scroll-handler % scroll-y))]
|
full-name (profile.utils/displayed-name profile)
|
||||||
|
on-scroll (rn/use-callback #(scroll-handler % scroll-y))]
|
||||||
[quo/overlay {:type :shell}
|
[quo/overlay {:type :shell}
|
||||||
[rn/view
|
[rn/view
|
||||||
{:style (style/navigation-wrapper {:customization-color customization-color
|
{:style (style/navigation-wrapper {:customization-color customization-color
|
||||||
|
@ -79,7 +80,7 @@
|
||||||
profile)}}])}]}]]
|
profile)}}])}]}]]
|
||||||
[rn/flat-list
|
[rn/flat-list
|
||||||
{:header [settings.header/view {:scroll-y scroll-y}]
|
{:header [settings.header/view {:scroll-y scroll-y}]
|
||||||
:data (settings.items/items (boolean (seq (:mnemonic profile))))
|
:data (settings.items/items (not recovery-phrase-backed-up?))
|
||||||
:shows-vertical-scroll-indicator false
|
:shows-vertical-scroll-indicator false
|
||||||
:render-fn settings-category-view
|
:render-fn settings-category-view
|
||||||
:get-item-layout get-item-layout
|
:get-item-layout get-item-layout
|
||||||
|
|
|
@ -160,7 +160,7 @@
|
||||||
|
|
||||||
(defn wallet-validate-seed-phrase
|
(defn wallet-validate-seed-phrase
|
||||||
[_ [seed-phrase on-success on-error]]
|
[_ [seed-phrase on-success on-error]]
|
||||||
{:fx [[:multiaccount/validate-mnemonic [seed-phrase on-success on-error]]]})
|
{:fx [[:effects.profile/validate-recovery-phrase [seed-phrase on-success on-error]]]})
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/validate-seed-phrase wallet-validate-seed-phrase)
|
(rf/reg-event-fx :wallet/validate-seed-phrase wallet-validate-seed-phrase)
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
seed-phrase-masked (security/mask-data "seed phrase")
|
seed-phrase-masked (security/mask-data "seed phrase")
|
||||||
on-success #(prn "success")
|
on-success #(prn "success")
|
||||||
on-error #(prn "error")
|
on-error #(prn "error")
|
||||||
expected {:fx [[:multiaccount/validate-mnemonic
|
expected {:fx [[:effects.profile/validate-recovery-phrase
|
||||||
[seed-phrase-masked on-success on-error]]]}]
|
[seed-phrase-masked on-success on-error]]]}]
|
||||||
(is (= expected
|
(is (= expected
|
||||||
(sut/wallet-validate-seed-phrase
|
(sut/wallet-validate-seed-phrase
|
||||||
|
|
|
@ -61,16 +61,6 @@
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/seed-phrase-validated seed-phrase-validated)
|
(rf/reg-event-fx :wallet/seed-phrase-validated seed-phrase-validated)
|
||||||
|
|
||||||
(defn seed-phrase-entered
|
|
||||||
[_ [seed-phrase on-error]]
|
|
||||||
{:fx [[:multiaccount/validate-mnemonic
|
|
||||||
[seed-phrase
|
|
||||||
(fn [mnemonic key-uid]
|
|
||||||
(rf/dispatch [:wallet/seed-phrase-validated mnemonic key-uid on-error]))
|
|
||||||
on-error]]]})
|
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/seed-phrase-entered seed-phrase-entered)
|
|
||||||
|
|
||||||
(defn store-account-generated-with-mnemonic
|
(defn store-account-generated-with-mnemonic
|
||||||
[{:keys [db]} [{:keys [new-account-data keypair-name]}]]
|
[{:keys [db]} [{:keys [new-account-data keypair-name]}]]
|
||||||
(let [new-account (update new-account-data :mnemonic security/mask-data)]
|
(let [new-account (update new-account-data :mnemonic security/mask-data)]
|
||||||
|
|
|
@ -16,13 +16,21 @@
|
||||||
[[{:icon :i/add
|
[[{:icon :i/add
|
||||||
: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/wallet.backup-recovery-phrase])}
|
:on-press #(rf/dispatch [:navigate-to :screen/backup-recovery-phrase
|
||||||
|
{:on-success (fn [{:keys [masked-seed-phrase random-phrase]}]
|
||||||
|
(rf/dispatch [:wallet/store-new-seed-phrase
|
||||||
|
{:seed-phrase masked-seed-phrase
|
||||||
|
:random-phrase
|
||||||
|
random-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)
|
||||||
:add-divider? true
|
:add-divider? true
|
||||||
:on-press #(rf/dispatch [:navigate-to :screen/wallet.enter-seed-phrase
|
:on-press (fn []
|
||||||
{:recovering-keypair? true}])}
|
(rf/dispatch [:navigate-to :screen/use-recovery-phrase
|
||||||
|
{:on-success (fn [{:keys [key-uid phrase on-error]}]
|
||||||
|
(rf/dispatch [:wallet/seed-phrase-validated
|
||||||
|
phrase key-uid on-error]))}]))}
|
||||||
(when (ff/enabled? ::ff/wallet.import-private-key)
|
(when (ff/enabled? ::ff/wallet.import-private-key)
|
||||||
{:icon :i/key
|
{:icon :i/key
|
||||||
:accessibility-label :import-private-key
|
:accessibility-label :import-private-key
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
[native-module.core :as native-module]
|
[native-module.core :as native-module]
|
||||||
[promesa.core :as promesa]
|
[promesa.core :as promesa]
|
||||||
[status-im.common.json-rpc.events :as json-rpc]
|
[status-im.common.json-rpc.events :as json-rpc]
|
||||||
|
[status-im.contexts.profile.recover.effects :as profile.recover.effects]
|
||||||
[taoensso.timbre :as log]
|
[taoensso.timbre :as log]
|
||||||
[utils.re-frame :as rf]
|
[utils.re-frame :as rf]
|
||||||
[utils.security.core :as security]
|
[utils.security.core :as security]
|
||||||
|
@ -26,26 +27,6 @@
|
||||||
:paths paths}
|
:paths paths}
|
||||||
on-success))))
|
on-success))))
|
||||||
|
|
||||||
(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
|
|
||||||
:multiaccount/validate-mnemonic
|
|
||||||
(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)))))))
|
|
||||||
|
|
||||||
(defn create-account-from-private-key
|
(defn create-account-from-private-key
|
||||||
[private-key]
|
[private-key]
|
||||||
(-> private-key
|
(-> private-key
|
||||||
|
@ -81,7 +62,7 @@
|
||||||
|
|
||||||
(defn import-missing-keypair-by-seed-phrase
|
(defn import-missing-keypair-by-seed-phrase
|
||||||
[keypair-key-uid seed-phrase password]
|
[keypair-key-uid seed-phrase password]
|
||||||
(-> (validate-mnemonic seed-phrase)
|
(-> (profile.recover.effects/validate-mnemonic seed-phrase)
|
||||||
(promesa/then
|
(promesa/then
|
||||||
(fn [{:keys [key-uid]}]
|
(fn [{:keys [key-uid]}]
|
||||||
(if (not= keypair-key-uid key-uid)
|
(if (not= keypair-key-uid key-uid)
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
[status-im.contexts.preview.quo.component-preview.view :as component-preview]
|
[status-im.contexts.preview.quo.component-preview.view :as component-preview]
|
||||||
[status-im.contexts.preview.quo.main :as quo.preview]
|
[status-im.contexts.preview.quo.main :as quo.preview]
|
||||||
[status-im.contexts.preview.status-im.main :as status-im-preview]
|
[status-im.contexts.preview.status-im.main :as status-im-preview]
|
||||||
|
[status-im.contexts.profile.backup-recovery-phrase.view :as backup-recovery-phrase]
|
||||||
[status-im.contexts.profile.contact.share.view :as share-contact]
|
[status-im.contexts.profile.contact.share.view :as share-contact]
|
||||||
[status-im.contexts.profile.contact.view :as contact-profile]
|
[status-im.contexts.profile.contact.view :as contact-profile]
|
||||||
[status-im.contexts.profile.edit.accent-colour.view :as edit-accent-colour]
|
[status-im.contexts.profile.edit.accent-colour.view :as edit-accent-colour]
|
||||||
|
@ -107,8 +108,6 @@
|
||||||
wallet-import-private-key]
|
wallet-import-private-key]
|
||||||
[status-im.contexts.wallet.add-account.create-account.key-pair-name.view :as
|
[status-im.contexts.wallet.add-account.create-account.key-pair-name.view :as
|
||||||
wallet-key-pair-name]
|
wallet-key-pair-name]
|
||||||
[status-im.contexts.wallet.add-account.create-account.new-keypair.backup-recovery-phrase.view :as
|
|
||||||
wallet-backup-recovery-phrase]
|
|
||||||
[status-im.contexts.wallet.add-account.create-account.new-keypair.confirm-backup.view :as
|
[status-im.contexts.wallet.add-account.create-account.new-keypair.confirm-backup.view :as
|
||||||
wallet-confirm-backup]
|
wallet-confirm-backup]
|
||||||
[status-im.contexts.wallet.add-account.create-account.select-keypair.view :as wallet-select-keypair]
|
[status-im.contexts.wallet.add-account.create-account.select-keypair.view :as wallet-select-keypair]
|
||||||
|
@ -476,9 +475,9 @@
|
||||||
:options {:insets {:top? true}}
|
:options {:insets {:top? true}}
|
||||||
:component wallet-create-account/view}
|
:component wallet-create-account/view}
|
||||||
|
|
||||||
{:name :screen/wallet.backup-recovery-phrase
|
{:name :screen/backup-recovery-phrase
|
||||||
:options {:insets {:top? true :bottom? true}}
|
:options {:insets {:top? true :bottom? true}}
|
||||||
:component wallet-backup-recovery-phrase/view}
|
:component backup-recovery-phrase/view}
|
||||||
|
|
||||||
{:name :screen/wallet.confirm-backup
|
{:name :screen/wallet.confirm-backup
|
||||||
:options {:insets {:top? true :bottom? true}}
|
:options {:insets {:top? true :bottom? true}}
|
||||||
|
@ -488,7 +487,7 @@
|
||||||
:options {:insets {:top? true}}
|
:options {:insets {:top? true}}
|
||||||
:component wallet-key-pair-name/view}
|
:component wallet-key-pair-name/view}
|
||||||
|
|
||||||
{:name :screen/wallet.enter-seed-phrase
|
{:name :screen/use-recovery-phrase
|
||||||
:component enter-seed-phrase/view}
|
:component enter-seed-phrase/view}
|
||||||
|
|
||||||
{:name :screen/wallet.share-address
|
{:name :screen/wallet.share-address
|
||||||
|
|
|
@ -345,6 +345,12 @@
|
||||||
(fn [{:keys [processing]}]
|
(fn [{:keys [processing]}]
|
||||||
processing))
|
processing))
|
||||||
|
|
||||||
|
(re-frame/reg-sub
|
||||||
|
:profile/recovery-phrase-backed-up?
|
||||||
|
:<- [:profile/profile]
|
||||||
|
(fn [profile]
|
||||||
|
(not (boolean (seq (:mnemonic profile))))))
|
||||||
|
|
||||||
;; LINK PREVIEW
|
;; LINK PREVIEW
|
||||||
;; ========================================================================================================
|
;; ========================================================================================================
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue