chore: Revise code for wallet settings (#20439)
* fix: use correct error message when displaying seed phrase as incorrect * tidy: cleanup naming of events and effects * tweak: show incorrect-seed-phrase error for any import error * fix: show correct error message for incorrect private key * chore: move import-private-key and import-seed-phrase namespaces * chore: move encrypted-qr namespace * chore: move scan-qr namespace * tidy: rename key-pair to keypair inside for wallet settings * tweak: use :open-modal navigation instead of :navigate-to-within-stack * tweak: rename screen for importing missing key-pair by seed-phrase * tidy: refactor code
This commit is contained in:
parent
e0c7ecc6df
commit
dc335cc333
|
@ -2,6 +2,7 @@
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[legacy.status-im.ethereum.mnemonic :as mnemonic]
|
[legacy.status-im.ethereum.mnemonic :as mnemonic]
|
||||||
|
[oops.core :as oops]
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[quo.foundations.colors :as colors]
|
[quo.foundations.colors :as colors]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
|
@ -104,16 +105,17 @@
|
||||||
"keyboardDidHide"
|
"keyboardDidHide"
|
||||||
#(reset! keyboard-shown? false))
|
#(reset! keyboard-shown? false))
|
||||||
invalid-seed-phrase? (reagent/atom false)
|
invalid-seed-phrase? (reagent/atom false)
|
||||||
|
incorrect-seed-phrase? (reagent/atom false)
|
||||||
input-ref (reagent/atom nil)
|
input-ref (reagent/atom nil)
|
||||||
focus-input (fn []
|
focus-input #(some-> @input-ref
|
||||||
(let [ref @input-ref]
|
(oops/ocall "focus"))
|
||||||
(when ref
|
set-incorrect-seed-phrase #(reset! incorrect-seed-phrase? true)
|
||||||
(.focus ref))))
|
|
||||||
set-invalid-seed-phrase #(reset! invalid-seed-phrase? true)
|
set-invalid-seed-phrase #(reset! invalid-seed-phrase? true)
|
||||||
seed-phrase (reagent/atom "")
|
seed-phrase (reagent/atom "")
|
||||||
on-change-seed-phrase (fn [new-phrase]
|
on-change-seed-phrase (fn [new-phrase]
|
||||||
(when @invalid-seed-phrase?
|
(when @invalid-seed-phrase?
|
||||||
(reset! invalid-seed-phrase? false))
|
(reset! invalid-seed-phrase? false)
|
||||||
|
(reset! incorrect-seed-phrase? false))
|
||||||
(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)
|
||||||
|
@ -143,7 +145,8 @@
|
||||||
suggestions-state (cond
|
suggestions-state (cond
|
||||||
(or error-in-words?
|
(or error-in-words?
|
||||||
words-exceeded?
|
words-exceeded?
|
||||||
@invalid-seed-phrase?) :error
|
@invalid-seed-phrase?
|
||||||
|
@incorrect-seed-phrase?) :error
|
||||||
(string/blank? @seed-phrase) :info
|
(string/blank? @seed-phrase) :info
|
||||||
(string/ends-with? @seed-phrase " ") :empty
|
(string/ends-with? @seed-phrase " ") :empty
|
||||||
:else :words)
|
:else :words)
|
||||||
|
@ -152,6 +155,7 @@
|
||||||
words-exceeded? (i18n/label :t/seed-phrase-words-exceeded)
|
words-exceeded? (i18n/label :t/seed-phrase-words-exceeded)
|
||||||
error-in-words? (i18n/label :t/seed-phrase-error)
|
error-in-words? (i18n/label :t/seed-phrase-error)
|
||||||
@invalid-seed-phrase? (i18n/label :t/seed-phrase-invalid)
|
@invalid-seed-phrase? (i18n/label :t/seed-phrase-invalid)
|
||||||
|
@incorrect-seed-phrase? (i18n/label :t/seed-phrase-incorrect)
|
||||||
:else (i18n/label :t/seed-phrase-info))
|
:else (i18n/label :t/seed-phrase-info))
|
||||||
error-state? (= suggestions-state :error)
|
error-state? (= suggestions-state :error)
|
||||||
button-disabled? (or error-state?
|
button-disabled? (or error-state?
|
||||||
|
@ -172,7 +176,7 @@
|
||||||
:prepare-seed-phrase secure-clean-seed-phrase
|
:prepare-seed-phrase secure-clean-seed-phrase
|
||||||
:focus-input focus-input
|
:focus-input focus-input
|
||||||
:seed-phrase (security/mask-data @seed-phrase)
|
:seed-phrase (security/mask-data @seed-phrase)
|
||||||
:set-invalid-seed-phrase set-invalid-seed-phrase})
|
:set-incorrect-seed-phrase set-incorrect-seed-phrase})
|
||||||
[quo/button
|
[quo/button
|
||||||
{:container-style (style/continue-button @keyboard-shown?)
|
{:container-style (style/continue-button @keyboard-shown?)
|
||||||
:type :primary
|
:type :primary
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
:blur? true
|
:blur? true
|
||||||
:action :arrow}
|
:action :arrow}
|
||||||
{:title (i18n/label :t/wallet)
|
{:title (i18n/label :t/wallet)
|
||||||
:on-press #(rf/dispatch [:navigate-to-within-stack [:screen/settings.wallet :settings]])
|
:on-press #(rf/dispatch [:open-modal :screen/settings.wallet])
|
||||||
:image-props :i/wallet
|
:image-props :i/wallet
|
||||||
:image :icon
|
:image :icon
|
||||||
:blur? true
|
:blur? true
|
||||||
|
|
|
@ -167,9 +167,9 @@
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/verify-private-key-for-keypair verify-private-key-for-keypair)
|
(rf/reg-event-fx :wallet/verify-private-key-for-keypair verify-private-key-for-keypair)
|
||||||
|
|
||||||
(defn import-keypair-by-seed-phrase
|
(defn import-missing-keypair-by-seed-phrase
|
||||||
[_ [{:keys [keypair-key-uid seed-phrase password on-success on-error]}]]
|
[_ [{:keys [keypair-key-uid seed-phrase password on-success on-error]}]]
|
||||||
{:fx [[:import-keypair-by-seed-phrase
|
{:fx [[:effects.wallet/import-missing-keypair-by-seed-phrase
|
||||||
{:keypair-key-uid keypair-key-uid
|
{:keypair-key-uid keypair-key-uid
|
||||||
:seed-phrase seed-phrase
|
:seed-phrase seed-phrase
|
||||||
:password password
|
:password password
|
||||||
|
@ -178,24 +178,26 @@
|
||||||
#{keypair-key-uid}])
|
#{keypair-key-uid}])
|
||||||
(rf/call-continuation on-success))
|
(rf/call-continuation on-success))
|
||||||
:on-error (fn [error]
|
:on-error (fn [error]
|
||||||
(rf/dispatch [:wallet/import-keypair-by-seed-phrase-failed error])
|
(rf/dispatch [:wallet/import-missing-keypair-by-seed-phrase-failed error])
|
||||||
|
(log/error "failed to import missing keypair with seed phrase"
|
||||||
|
{:error error})
|
||||||
(rf/call-continuation on-error error))}]]})
|
(rf/call-continuation on-error error))}]]})
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/import-keypair-by-seed-phrase import-keypair-by-seed-phrase)
|
(rf/reg-event-fx :wallet/import-missing-keypair-by-seed-phrase import-missing-keypair-by-seed-phrase)
|
||||||
|
|
||||||
(defn import-keypair-by-seed-phrase-failed
|
(defn import-missing-keypair-by-seed-phrase-failed
|
||||||
[_ [error]]
|
[_ [error]]
|
||||||
(let [error-type (-> error ex-message keyword)
|
(let [error-type (-> error ex-message keyword)
|
||||||
error-data (ex-data error)]
|
error-data (ex-data error)]
|
||||||
(when-not (and (= error-type :import-keypair-by-seed-phrase/import-error)
|
(when-not (= error-type :import-missing-keypair-by-seed-phrase/import-error)
|
||||||
(= (:hint error-data) :incorrect-seed-phrase-for-keypair))
|
|
||||||
{:fx [[:dispatch
|
{:fx [[:dispatch
|
||||||
[:toasts/upsert
|
[:toasts/upsert
|
||||||
{:type :negative
|
{:type :negative
|
||||||
:theme :dark
|
:theme :dark
|
||||||
:text (:error error-data)}]]]})))
|
:text (:error error-data)}]]]})))
|
||||||
|
|
||||||
(rf/reg-event-fx :wallet/import-keypair-by-seed-phrase-failed import-keypair-by-seed-phrase-failed)
|
(rf/reg-event-fx :wallet/import-missing-keypair-by-seed-phrase-failed
|
||||||
|
import-missing-keypair-by-seed-phrase-failed)
|
||||||
|
|
||||||
(defn import-missing-keypair-by-private-key
|
(defn import-missing-keypair-by-private-key
|
||||||
[_ [{:keys [keypair-key-uid private-key password on-success on-error]}]]
|
[_ [{:keys [keypair-key-uid private-key password on-success on-error]}]]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.actions.view
|
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.actions.view
|
||||||
(:require [quo.core :as quo]
|
(:require [quo.core :as quo]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.remove.view :as remove-key-pair]
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.remove.view :as remove-keypair]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
||||||
|
|
||||||
|
@ -14,20 +14,22 @@
|
||||||
[(:key-uid keypair)]])
|
[(:key-uid keypair)]])
|
||||||
[keypair])
|
[keypair])
|
||||||
on-show-qr (rn/use-callback #(rf/dispatch [:open-modal
|
on-show-qr (rn/use-callback #(rf/dispatch [:open-modal
|
||||||
:screen/settings.encrypted-key-pair-qr
|
:screen/settings.encrypted-keypair-qr
|
||||||
keypair])
|
keypair])
|
||||||
[keypair])
|
[keypair])
|
||||||
on-remove-keypair (rn/use-callback #(rf/dispatch
|
on-remove-keypair (rn/use-callback #(rf/dispatch
|
||||||
[:show-bottom-sheet
|
[:show-bottom-sheet
|
||||||
{:theme :dark
|
{:theme :dark
|
||||||
:content (fn []
|
:content (fn []
|
||||||
[remove-key-pair/view keypair])}])
|
[remove-keypair/view keypair])}])
|
||||||
[keypair])
|
[keypair])
|
||||||
on-rename-keypair (rn/use-callback #(rf/dispatch [:open-modal :screen/settings.rename-keypair
|
on-rename-keypair (rn/use-callback #(rf/dispatch [:open-modal :screen/settings.rename-keypair
|
||||||
keypair])
|
keypair])
|
||||||
[keypair])
|
[keypair])
|
||||||
on-import-seed-phrase (rn/use-callback
|
on-import-seed-phrase (rn/use-callback
|
||||||
#(rf/dispatch [:open-modal :screen/settings.import-seed-phrase keypair])
|
#(rf/dispatch [:open-modal
|
||||||
|
:screen/settings.missing-keypair.import-seed-phrase
|
||||||
|
keypair])
|
||||||
[keypair])
|
[keypair])
|
||||||
on-import-private-key (rn/use-callback
|
on-import-private-key (rn/use-callback
|
||||||
#(rf/dispatch [:open-modal
|
#(rf/dispatch [:open-modal
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.encrypted-qr.countdown.view
|
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.encrypted-qr.countdown.view
|
||||||
(:require
|
(:require
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[quo.foundations.colors :as colors]
|
[quo.foundations.colors :as colors]
|
|
@ -1,4 +1,4 @@
|
||||||
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.encrypted-qr.style
|
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.encrypted-qr.style
|
||||||
(:require
|
(:require
|
||||||
[quo.foundations.colors :as colors]
|
[quo.foundations.colors :as colors]
|
||||||
[react-native.safe-area :as safe-area]))
|
[react-native.safe-area :as safe-area]))
|
|
@ -1,4 +1,4 @@
|
||||||
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.encrypted-qr.view
|
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.encrypted-qr.view
|
||||||
(:require
|
(:require
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[quo.foundations.colors :as colors]
|
[quo.foundations.colors :as colors]
|
||||||
|
@ -7,8 +7,10 @@
|
||||||
[status-im.common.qr-codes.view :as qr-codes]
|
[status-im.common.qr-codes.view :as qr-codes]
|
||||||
[status-im.common.resources :as resources]
|
[status-im.common.resources :as resources]
|
||||||
[status-im.common.standard-authentication.core :as standard-auth]
|
[status-im.common.standard-authentication.core :as standard-auth]
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.encrypted-qr.countdown.view :as countdown]
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.encrypted-qr.countdown.view
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.encrypted-qr.style :as style]
|
:as countdown]
|
||||||
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.encrypted-qr.style
|
||||||
|
:as style]
|
||||||
[status-im.contexts.syncing.utils :as sync-utils]
|
[status-im.contexts.syncing.utils :as sync-utils]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
[utils.re-frame :as rf]))
|
[utils.re-frame :as rf]))
|
|
@ -1,4 +1,4 @@
|
||||||
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.import-private-key.style)
|
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.import-private-key.style)
|
||||||
|
|
||||||
(def form-container
|
(def form-container
|
||||||
{:row-gap 8
|
{:row-gap 8
|
|
@ -1,4 +1,4 @@
|
||||||
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.import-private-key.view
|
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.import-private-key.view
|
||||||
(:require
|
(:require
|
||||||
[clojure.string :as string]
|
[clojure.string :as string]
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
|
@ -7,7 +7,8 @@
|
||||||
[react-native.safe-area :as safe-area]
|
[react-native.safe-area :as safe-area]
|
||||||
[status-im.common.floating-button-page.view :as floating-button-page]
|
[status-im.common.floating-button-page.view :as floating-button-page]
|
||||||
[status-im.common.standard-authentication.core :as standard-auth]
|
[status-im.common.standard-authentication.core :as standard-auth]
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.import-private-key.style :as style]
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.import-private-key.style
|
||||||
|
:as style]
|
||||||
[status-im.contexts.wallet.common.validation :as validation]
|
[status-im.contexts.wallet.common.validation :as validation]
|
||||||
[utils.debounce :as debounce]
|
[utils.debounce :as debounce]
|
||||||
[utils.i18n :as i18n]
|
[utils.i18n :as i18n]
|
||||||
|
@ -68,8 +69,7 @@
|
||||||
[on-change])
|
[on-change])
|
||||||
on-import-error (rn/use-callback
|
on-import-error (rn/use-callback
|
||||||
(fn [_error]
|
(fn [_error]
|
||||||
(rf/dispatch [:hide-bottom-sheet])
|
(rf/dispatch [:hide-bottom-sheet])))
|
||||||
(show-invalid)))
|
|
||||||
on-import-success (rn/use-callback
|
on-import-success (rn/use-callback
|
||||||
(fn []
|
(fn []
|
||||||
(rf/dispatch [:hide-bottom-sheet])
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
|
@ -134,5 +134,5 @@
|
||||||
(case flow-state
|
(case flow-state
|
||||||
:correct-private-key (i18n/label :t/correct-private-key)
|
:correct-private-key (i18n/label :t/correct-private-key)
|
||||||
:invalid-private-key (i18n/label :t/invalid-private-key)
|
:invalid-private-key (i18n/label :t/invalid-private-key)
|
||||||
:incorrect-private-key (i18n/label :t/incorrect-private-key {:name (:name keypair)})
|
:incorrect-private-key (i18n/label :t/incorrect-private-key)
|
||||||
nil)])]]]))
|
nil)])]]]))
|
|
@ -1,4 +1,4 @@
|
||||||
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.import-seed-phrase.view
|
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.import-seed-phrase.view
|
||||||
(:require
|
(:require
|
||||||
[quo.core :as quo]
|
[quo.core :as quo]
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
|
@ -14,16 +14,17 @@
|
||||||
container-style
|
container-style
|
||||||
prepare-seed-phrase
|
prepare-seed-phrase
|
||||||
seed-phrase
|
seed-phrase
|
||||||
set-invalid-seed-phrase
|
set-incorrect-seed-phrase
|
||||||
focus-input]}]
|
focus-input]}]
|
||||||
(let [keypair (rf/sub [:get-screen-params])
|
(let [keypair (rf/sub [:get-screen-params])
|
||||||
customization-color (rf/sub [:profile/customization-color])
|
customization-color (rf/sub [:profile/customization-color])
|
||||||
show-errors (rn/use-callback
|
show-errors (rn/use-callback
|
||||||
#(js/setTimeout
|
(fn [_error]
|
||||||
|
(js/setTimeout
|
||||||
(fn []
|
(fn []
|
||||||
(focus-input)
|
(focus-input)
|
||||||
(reagent/next-tick set-invalid-seed-phrase))
|
(reagent/next-tick set-incorrect-seed-phrase))
|
||||||
600))
|
600)))
|
||||||
on-import-error (rn/use-callback
|
on-import-error (rn/use-callback
|
||||||
(fn [_error]
|
(fn [_error]
|
||||||
(rf/dispatch [:hide-bottom-sheet])
|
(rf/dispatch [:hide-bottom-sheet])
|
||||||
|
@ -34,7 +35,7 @@
|
||||||
(rf/dispatch [:navigate-back])))
|
(rf/dispatch [:navigate-back])))
|
||||||
on-auth-success (rn/use-callback
|
on-auth-success (rn/use-callback
|
||||||
(fn [password]
|
(fn [password]
|
||||||
(rf/dispatch [:wallet/import-keypair-by-seed-phrase
|
(rf/dispatch [:wallet/import-missing-keypair-by-seed-phrase
|
||||||
{:keypair-key-uid (:key-uid keypair)
|
{:keypair-key-uid (:key-uid keypair)
|
||||||
:seed-phrase (prepare-seed-phrase seed-phrase)
|
:seed-phrase (prepare-seed-phrase seed-phrase)
|
||||||
:password password
|
:password password
|
|
@ -1,4 +1,4 @@
|
||||||
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.scan-qr.view
|
(ns status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.scan-qr.view
|
||||||
(:require
|
(:require
|
||||||
[react-native.core :as rn]
|
[react-native.core :as rn]
|
||||||
[status-im.common.scan-qr-code.view :as scan-qr-code]
|
[status-im.common.scan-qr-code.view :as scan-qr-code]
|
|
@ -159,9 +159,7 @@
|
||||||
:ens address-or-ens
|
:ens address-or-ens
|
||||||
:ens? ens-name?}])
|
:ens? ens-name?}])
|
||||||
(rf/dispatch
|
(rf/dispatch
|
||||||
[:navigate-to-within-stack
|
[:open-modal :screen/settings.save-address]))
|
||||||
[:screen/settings.save-address
|
|
||||||
:screen/settings.add-address-to-save]]))
|
|
||||||
[address ens-name? address-or-ens])]
|
[address ens-name? address-or-ens])]
|
||||||
(rn/use-unmount #(rf/dispatch [:wallet/clear-address-to-save]))
|
(rn/use-unmount #(rf/dispatch [:wallet/clear-address-to-save]))
|
||||||
[quo/overlay {:type :shell}
|
[quo/overlay {:type :shell}
|
||||||
|
|
|
@ -66,8 +66,7 @@
|
||||||
|
|
||||||
(defn- add-address-to-save
|
(defn- add-address-to-save
|
||||||
[]
|
[]
|
||||||
(rf/dispatch [:navigate-to-within-stack
|
(rf/dispatch [:open-modal :screen/settings.add-address-to-save]))
|
||||||
[:screen/settings.add-address-to-save :screen/settings.saved-addresses]]))
|
|
||||||
|
|
||||||
(defn view
|
(defn view
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
|
|
||||||
(defn open-saved-addresses-settings-modal
|
(defn open-saved-addresses-settings-modal
|
||||||
[]
|
[]
|
||||||
(rf/dispatch [:navigate-to-within-stack [:screen/settings.saved-addresses :settings]]))
|
(rf/dispatch [:open-modal :screen/settings.saved-addresses]))
|
||||||
|
|
||||||
(defn open-keypairs-and-accounts-settings-modal
|
(defn open-keypairs-and-accounts-settings-modal
|
||||||
[]
|
[]
|
||||||
(rf/dispatch [:navigate-to-within-stack [:screen/settings.keypairs-and-accounts :settings]]))
|
(rf/dispatch [:open-modal :screen/settings.keypairs-and-accounts]))
|
||||||
|
|
||||||
(defn basic-settings-options
|
(defn basic-settings-options
|
||||||
[]
|
[]
|
||||||
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
(defn open-network-settings-modal
|
(defn open-network-settings-modal
|
||||||
[]
|
[]
|
||||||
(rf/dispatch [:navigate-to-within-stack [:screen/settings.network-settings :settings]]))
|
(rf/dispatch [:open-modal :screen/settings.network-settings]))
|
||||||
|
|
||||||
(defn advanced-settings-options
|
(defn advanced-settings-options
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
:on-success (fn [value]
|
:on-success (fn [value]
|
||||||
(resolver {:value value}))}))))
|
(resolver {:value value}))}))))
|
||||||
|
|
||||||
(defn import-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)
|
(-> (validate-mnemonic seed-phrase)
|
||||||
(promesa/then
|
(promesa/then
|
||||||
|
@ -87,20 +87,20 @@
|
||||||
(if (not= keypair-key-uid key-uid)
|
(if (not= keypair-key-uid key-uid)
|
||||||
(promesa/rejected
|
(promesa/rejected
|
||||||
(ex-info
|
(ex-info
|
||||||
(error-message :import-keypair-by-seed-phrase/import-error)
|
(error-message :import-missing-keypair-by-seed-phrase/import-error)
|
||||||
{:hint :incorrect-seed-phrase-for-keypair}))
|
{:hint :incorrect-seed-phrase-for-keypair}))
|
||||||
(make-seed-phrase-fully-operable seed-phrase password))))
|
(make-seed-phrase-fully-operable seed-phrase password))))
|
||||||
(promesa/catch
|
(promesa/catch
|
||||||
(fn [error]
|
(fn [error]
|
||||||
(promesa/rejected
|
(promesa/rejected
|
||||||
(ex-info
|
(ex-info
|
||||||
(error-message :import-keypair-by-seed-phrase/import-error)
|
(error-message :import-missing-keypair-by-seed-phrase/import-error)
|
||||||
(ex-data error)))))))
|
(ex-data error)))))))
|
||||||
|
|
||||||
(rf/reg-fx
|
(rf/reg-fx
|
||||||
:import-keypair-by-seed-phrase
|
:effects.wallet/import-missing-keypair-by-seed-phrase
|
||||||
(fn [{:keys [keypair-key-uid seed-phrase password on-success on-error]}]
|
(fn [{:keys [keypair-key-uid seed-phrase password on-success on-error]}]
|
||||||
(-> (import-keypair-by-seed-phrase keypair-key-uid seed-phrase password)
|
(-> (import-missing-keypair-by-seed-phrase keypair-key-uid seed-phrase password)
|
||||||
(promesa/then (partial rf/call-continuation on-success))
|
(promesa/then (partial rf/call-continuation on-success))
|
||||||
(promesa/catch (partial rf/call-continuation on-error)))))
|
(promesa/catch (partial rf/call-continuation on-error)))))
|
||||||
|
|
||||||
|
|
|
@ -57,14 +57,15 @@
|
||||||
[status-im.contexts.profile.settings.screens.password.change-password.view :as change-password]
|
[status-im.contexts.profile.settings.screens.password.change-password.view :as change-password]
|
||||||
[status-im.contexts.profile.settings.screens.password.view :as settings-password]
|
[status-im.contexts.profile.settings.screens.password.view :as settings-password]
|
||||||
[status-im.contexts.profile.settings.view :as settings]
|
[status-im.contexts.profile.settings.view :as settings]
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.encrypted-qr.view :as
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.encrypted-qr.view
|
||||||
encrypted-key-pair-qr]
|
:as encrypted-keypair-qr]
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.import-private-key.view :as
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.import-private-key.view
|
||||||
import-private-key]
|
:as missing-keypairs.import-private-key]
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.import-seed-phrase.view :as
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.import-seed-phrase.view
|
||||||
import-seed-phrase]
|
:as missing-keypairs.import-seed-phrase]
|
||||||
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.missing-keypairs.scan-qr.view
|
||||||
|
:as scan-keypair-qr]
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.rename.view :as keypair-rename]
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.rename.view :as keypair-rename]
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.scan-qr.view :as scan-keypair-qr]
|
|
||||||
[status-im.contexts.settings.wallet.keypairs-and-accounts.view :as keypairs-and-accounts]
|
[status-im.contexts.settings.wallet.keypairs-and-accounts.view :as keypairs-and-accounts]
|
||||||
[status-im.contexts.settings.wallet.network-settings.view :as network-settings]
|
[status-im.contexts.settings.wallet.network-settings.view :as network-settings]
|
||||||
[status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.view :as
|
[status-im.contexts.settings.wallet.saved-addresses.add-address-to-save.view :as
|
||||||
|
@ -535,9 +536,9 @@
|
||||||
:options (assoc options/dark-screen :sheet? true)
|
:options (assoc options/dark-screen :sheet? true)
|
||||||
:component keypair-rename/view}
|
:component keypair-rename/view}
|
||||||
|
|
||||||
{:name :screen/settings.encrypted-key-pair-qr
|
{:name :screen/settings.encrypted-keypair-qr
|
||||||
:options options/transparent-screen-options
|
:options options/transparent-screen-options
|
||||||
:component encrypted-key-pair-qr/view}
|
:component encrypted-keypair-qr/view}
|
||||||
|
|
||||||
{:name :screen/settings.saved-addresses
|
{:name :screen/settings.saved-addresses
|
||||||
:options options/transparent-modal-screen-options
|
:options options/transparent-modal-screen-options
|
||||||
|
@ -551,13 +552,13 @@
|
||||||
:options options/transparent-modal-screen-options
|
:options options/transparent-modal-screen-options
|
||||||
:component scan-keypair-qr/view}
|
:component scan-keypair-qr/view}
|
||||||
|
|
||||||
{:name :screen/settings.import-seed-phrase
|
{:name :screen/settings.missing-keypair.import-seed-phrase
|
||||||
:options options/transparent-screen-options
|
:options options/transparent-screen-options
|
||||||
:component import-seed-phrase/view}
|
:component missing-keypairs.import-seed-phrase/view}
|
||||||
|
|
||||||
{:name :screen/settings.missing-keypair-import-private-key
|
{:name :screen/settings.missing-keypair-import-private-key
|
||||||
:options options/transparent-screen-options
|
:options options/transparent-screen-options
|
||||||
:component import-private-key/view}
|
:component missing-keypairs.import-private-key/view}
|
||||||
|
|
||||||
{:name :screen/settings.network-settings
|
{:name :screen/settings.network-settings
|
||||||
:options options/transparent-modal-screen-options
|
:options options/transparent-modal-screen-options
|
||||||
|
|
|
@ -260,21 +260,21 @@
|
||||||
:<- [:wallet/keypairs]
|
:<- [:wallet/keypairs]
|
||||||
(fn [keypairs [_ format-options]]
|
(fn [keypairs [_ format-options]]
|
||||||
(let [grouped-keypairs (group-by :lowest-operability keypairs)
|
(let [grouped-keypairs (group-by :lowest-operability keypairs)
|
||||||
operable-key-pair-ids (->> (concat (:fully grouped-keypairs)
|
operable-keypair-ids (->> (concat (:fully grouped-keypairs)
|
||||||
(:partially grouped-keypairs))
|
(:partially grouped-keypairs))
|
||||||
(map :key-uid)
|
(map :key-uid)
|
||||||
(into #{}))
|
(into #{}))
|
||||||
missing-key-pair-ids (->> (map :key-uid (:no grouped-keypairs))
|
missing-keypair-ids (->> (map :key-uid (:no grouped-keypairs))
|
||||||
(into #{}))]
|
(into #{}))]
|
||||||
{:operable (->> keypairs
|
{:operable (->> keypairs
|
||||||
(filter #(contains? operable-key-pair-ids (:key-uid %)))
|
(filter #(contains? operable-keypair-ids (:key-uid %)))
|
||||||
(map (fn [{:keys [accounts name type key-uid]}]
|
(map (fn [{:keys [accounts name type key-uid]}]
|
||||||
{:type (keyword type)
|
{:type (keyword type)
|
||||||
:name name
|
:name name
|
||||||
:key-uid key-uid
|
:key-uid key-uid
|
||||||
:accounts (format-settings-keypair-accounts accounts format-options)})))
|
:accounts (format-settings-keypair-accounts accounts format-options)})))
|
||||||
:missing (->> keypairs
|
:missing (->> keypairs
|
||||||
(filter #(contains? missing-key-pair-ids (:key-uid %)))
|
(filter #(contains? missing-keypair-ids (:key-uid %)))
|
||||||
(map (fn [{:keys [accounts name type key-uid]}]
|
(map (fn [{:keys [accounts name type key-uid]}]
|
||||||
{:type (keyword type)
|
{:type (keyword type)
|
||||||
:name name
|
:name name
|
||||||
|
|
|
@ -1587,6 +1587,7 @@
|
||||||
"seed-phrase-words-uppercase": "Recovery phrase cannot contain uppercase characters",
|
"seed-phrase-words-uppercase": "Recovery phrase cannot contain uppercase characters",
|
||||||
"seed-phrase-error": "Recovery phrase contains invalid words",
|
"seed-phrase-error": "Recovery phrase contains invalid words",
|
||||||
"seed-phrase-invalid": "Invalid recovery phrase",
|
"seed-phrase-invalid": "Invalid recovery phrase",
|
||||||
|
"seed-phrase-incorrect": "Recovery phrase does not match key pair",
|
||||||
"seed-phrase-info": "Enter 12, 18 or 24 words separated by spaces",
|
"seed-phrase-info": "Enter 12, 18 or 24 words separated by spaces",
|
||||||
"word-count": "Word count",
|
"word-count": "Word count",
|
||||||
"word-n": "Word #{{number}}",
|
"word-n": "Word #{{number}}",
|
||||||
|
@ -2659,7 +2660,7 @@
|
||||||
"import-private-key-info": "New addresses cannot be derived from an account imported from a private key. Import using a seed phrase if you wish to derive addresses.",
|
"import-private-key-info": "New addresses cannot be derived from an account imported from a private key. Import using a seed phrase if you wish to derive addresses.",
|
||||||
"invalid-private-key": "It’s not a valid private key",
|
"invalid-private-key": "It’s not a valid private key",
|
||||||
"correct-private-key": "Correct private key",
|
"correct-private-key": "Correct private key",
|
||||||
"incorrect-private-key": "This is not the private key for {{name}}",
|
"incorrect-private-key": "This is not the private key for this key pair",
|
||||||
"private-key-public-address": "Public address of private key",
|
"private-key-public-address": "Public address of private key",
|
||||||
"this-account-has-no-activity": "This account has no activity",
|
"this-account-has-no-activity": "This account has no activity",
|
||||||
"this-address-has-activity": "This address has activity",
|
"this-address-has-activity": "This address has activity",
|
||||||
|
|
Loading…
Reference in New Issue