diff --git a/mobile/js_files/package.json b/mobile/js_files/package.json index e0e15ff74c..8a26360e16 100644 --- a/mobile/js_files/package.json +++ b/mobile/js_files/package.json @@ -38,7 +38,7 @@ "react-native-screens": "^1.0.0-alpha.23", "react-native-shake": "^3.3.1", "react-native-splash-screen": "^3.2.0", - "react-native-status-keycard": "^2.5.12", + "react-native-status-keycard": "^2.5.14", "react-native-svg": "^9.8.4", "react-native-touch-id": "^4.4.1", "react-native-webview": "^6.11.1", diff --git a/mobile/js_files/yarn.lock b/mobile/js_files/yarn.lock index 0797badf48..203c44683f 100644 --- a/mobile/js_files/yarn.lock +++ b/mobile/js_files/yarn.lock @@ -4877,10 +4877,10 @@ react-native-splash-screen@^3.2.0: resolved "https://registry.yarnpkg.com/react-native-splash-screen/-/react-native-splash-screen-3.2.0.tgz#d47ec8557b1ba988ee3ea98d01463081b60fff45" integrity sha512-Ls9qiNZzW/OLFoI25wfjjAcrf2DZ975hn2vr6U9gyuxi2nooVbzQeFoQS5vQcbCt9QX5NY8ASEEAtlLdIa6KVg== -react-native-status-keycard@^2.5.12: - version "2.5.12" - resolved "https://registry.yarnpkg.com/react-native-status-keycard/-/react-native-status-keycard-2.5.12.tgz#96cf98f955d3a354d0c4e9324e25fd359b99206c" - integrity sha512-QCGiL5Sir8Gm53dG+PXB7fFGWLozej3GPt12dj9aU5EdNUPL7qG5gYCKFRlKMV/nPlpvKBikY4h1dDxwoCEcBg== +react-native-status-keycard@^2.5.14: + version "2.5.14" + resolved "https://registry.yarnpkg.com/react-native-status-keycard/-/react-native-status-keycard-2.5.14.tgz#105ac4642ae3df777b87020dd5d484445fff46ba" + integrity sha512-qt8+BcDMwtjhAwVahF5WryeLRU0auUcYrRhCci+O6rX/Roz0a+NHZ8a23NAducvNco7uOBuleYL7yyhMbwxXQw== react-native-svg@^9.8.4: version "9.11.1" diff --git a/src/status_im/chat/commands/impl/transactions.cljs b/src/status_im/chat/commands/impl/transactions.cljs index 37f092d172..0ac15aa400 100644 --- a/src/status_im/chat/commands/impl/transactions.cljs +++ b/src/status_im/chat/commands/impl/transactions.cljs @@ -308,7 +308,7 @@ current-chat-id (:current-chat-id db) amount-hex (str "0x" (abi-spec/number-to-hex (money/formatted->internal value symbol decimals))) to (ethereum/public-key->address current-chat-id) - to-norm (ethereum/normalized-address (if (= symbol :ETH) to address)) + to-norm (ethereum/normalized-hex (if (= symbol :ETH) to address)) tx-obj (if (= symbol :ETH) {:to to-norm :value amount-hex} diff --git a/src/status_im/ethereum/core.cljs b/src/status_im/ethereum/core.cljs index 7a5b965873..0275785085 100644 --- a/src/status_im/ethereum/core.cljs +++ b/src/status_im/ethereum/core.cljs @@ -55,15 +55,15 @@ (def hex-prefix "0x") -(defn normalized-address [address] - (when address - (if (string/starts-with? address hex-prefix) - address - (str hex-prefix address)))) +(defn normalized-hex [hex] + (when hex + (if (string/starts-with? hex hex-prefix) + hex + (str hex-prefix hex)))) (defn current-address [db] (-> (get-in db [:multiaccount :address]) - normalized-address)) + normalized-hex)) (defn get-default-account [accounts] (some #(when (:wallet %) %) accounts)) @@ -82,8 +82,8 @@ (defn coordinates [public-key] (when-let [hex (naked-address public-key)] (when (= public-key-length (count (subs hex 2))) - {:x (normalized-address (subs hex 2 66)) - :y (normalized-address (subs hex 66))}))) + {:x (normalized-hex (subs hex 2 66)) + :y (normalized-hex (subs hex 66))}))) (defn address? [s] (when s @@ -126,8 +126,8 @@ (defn address= [address1 address2] (and address1 address2 - (= (normalized-address address1) - (normalized-address address2)))) + (= (normalized-hex address1) + (normalized-hex address2)))) (defn public-key->address [public-key] (let [length (count public-key) diff --git a/src/status_im/ethereum/ens.cljs b/src/status_im/ethereum/ens.cljs index aa345738d4..b06f542838 100644 --- a/src/status_im/ethereum/ens.cljs +++ b/src/status_im/ethereum/ens.cljs @@ -21,7 +21,7 @@ (defn namehash [s] - (ethereum/normalized-address + (ethereum/normalized-hex (if (string/blank? s) default-namehash (let [[label remainder] (-> s diff --git a/src/status_im/events.cljs b/src/status_im/events.cljs index 361f170f20..dd789f90fc 100644 --- a/src/status_im/events.cljs +++ b/src/status_im/events.cljs @@ -157,8 +157,13 @@ ;; multiaccounts login module (handlers/register-handler-fx :multiaccounts.login.ui/multiaccount-selected - (fn [cofx [_ address photo-path name public-key]] - (multiaccounts.login/open-login cofx address photo-path name public-key))) + (fn [{:keys [db] :as cofx} [_ address]] + (let [{:keys [photo-path name public-key]} + (get-in db [:multiaccounts/multiaccounts address])] + (fx/merge + cofx + {:db (dissoc db :intro-wizard)} + (multiaccounts.login/open-login address photo-path name public-key))))) ;; multiaccounts logout module diff --git a/src/status_im/hardwallet/core.cljs b/src/status_im/hardwallet/core.cljs index 1d061af150..2bb9492510 100644 --- a/src/status_im/hardwallet/core.cljs +++ b/src/status_im/hardwallet/core.cljs @@ -21,7 +21,8 @@ [status-im.ui.components.react :as react] [status-im.constants :as constants] [status-im.multiaccounts.update.core :as multiaccounts.update] - [status-im.ui.components.bottom-sheet.core :as bottom-sheet])) + [status-im.ui.components.bottom-sheet.core :as bottom-sheet] + [status-im.multiaccounts.recover.core :as recover])) (def default-pin "000000") @@ -38,12 +39,12 @@ (filter #(= keycard-instance-uid (:keycard-instance-uid %))) first))) -(defn- find-multiaccount-by-keycard-key-uid - [db keycard-key-uid] - (when keycard-key-uid +(defn- find-multiaccount-by-key-uid + [db key-uid] + (when key-uid (->> (:multiaccounts/multiaccounts db) vals - (filter #(= keycard-key-uid (:keycard-key-uid %))) + (filter #(= (ethereum/normalized-hex key-uid) (:key-uid %))) first))) (defn get-pairing @@ -55,7 +56,7 @@ (get-in db [:hardwallet :secrets :pairing]) (when key-uid (:keycard-pairing - (find-multiaccount-by-keycard-key-uid db key-uid)))))) + (find-multiaccount-by-key-uid db key-uid)))))) (fx/defn listen-to-hardware-back-button [{:keys [db]}] @@ -514,9 +515,9 @@ (load-pin-screen))) (when (and (= card-state :multiaccount) (= flow :import)) - (let [existing-multiaccount (find-multiaccount-by-keycard-key-uid db key-uid)] - (if existing-multiaccount - (show-existing-multiaccount-alert) + (let [{:keys [address]} (find-multiaccount-by-key-uid db key-uid)] + (if address + (recover/show-existing-multiaccount-alert address) (if pairing (load-recovery-pin-screen) (load-pair-screen))))) @@ -539,11 +540,12 @@ (fx/defn navigate-to-enter-pin-screen [{:keys [db] :as cofx}] - (let [keycard-key-uid (get-in db [:hardwallet :application-info :key-uid]) - multiaccount-key-uid (get-in db [:multiaccount :keycard-key-uid])] - (if (or (nil? multiaccount-key-uid) - (and keycard-key-uid - (= keycard-key-uid multiaccount-key-uid))) + (let [key-uid (get-in db [:hardwallet :application-info :key-uid]) + multiaccount-key-uid (get-in db [:multiaccount :key-uid]) + keycard-multiaccount? (boolean (get-in db [:multiaccount :keycard-pairing]))] + (if (or (nil? keycard-multiaccount?) + (and key-uid + (= key-uid multiaccount-key-uid))) (fx/merge cofx {:db (assoc-in db [:hardwallet :pin :current] [])} (navigation/navigate-to-cofx :enter-pin-settings nil)) @@ -635,17 +637,17 @@ {:events [:hardwallet/login-with-keycard]} [{:keys [db] :as cofx}] (let [application-info (get-in db [:hardwallet :application-info]) - keycard-key-uid (get-in db [:hardwallet :application-info :key-uid]) + key-uid (get-in db [:hardwallet :application-info :key-uid]) multiaccount (get-in db [:multiaccounts/multiaccounts (get-in db [:multiaccounts/login :address])]) - multiaccount-key-uid (get multiaccount :keycard-key-uid) + multiaccount-key-uid (get multiaccount :key-uid) multiaccount-mismatch? (or (nil? multiaccount) - (not= multiaccount-key-uid keycard-key-uid)) + (not= multiaccount-key-uid key-uid)) pairing (:keycard-pairing multiaccount)] (cond (empty? application-info) (navigation/navigate-to-cofx cofx :not-keycard nil) - (empty? keycard-key-uid) + (empty? key-uid) (navigation/navigate-to-cofx cofx :keycard-blank nil) multiaccount-mismatch? @@ -665,13 +667,15 @@ (fx/defn on-get-application-info-success [{:keys [db] :as cofx} info on-success] - (let [info' (js->clj info :keywordize-keys true) - {:keys [pin-retry-counter puk-retry-counter instance-uid]} info' + (let [info' (-> info + (js->clj :keywordize-keys true) + (update :key-uid ethereum/normalized-hex)) + {:keys [pin-retry-counter puk-retry-counter]} info' view-id (:view-id db) connect-screen? (contains? #{:hardwallet-connect :hardwallet-connect-sign :hardwallet-connect-settings} view-id) - {:keys [card-state on-card-read]} (:hardwallet db) + {:keys [on-card-read]} (:hardwallet db) on-success' (or on-success on-card-read) enter-step (if (zero? pin-retry-counter) :puk @@ -1006,11 +1010,10 @@ (fx/defn delete-card [{:keys [db] :as cofx}] - (let [keycard-key-uid (get-in db [:hardwallet :application-info :key-uid]) - multiaccount-key-uid (get-in db [:multiaccount :keycard-key-uid])] - (if (or (nil? multiaccount-key-uid) - (and keycard-key-uid - (= keycard-key-uid multiaccount-key-uid))) + (let [key-uid (get-in db [:hardwallet :application-info :key-uid]) + multiaccount-key-uid (get-in db [:multiaccount :key-uid])] + (if (and key-uid + (= key-uid multiaccount-key-uid)) {:hardwallet/delete nil} (unauthorized-operation cofx)))) @@ -1752,7 +1755,7 @@ :address address :publicKey public-key :keycard-instance-uid instance-uid - :keycard-key-uid key-uid + :keyUid (ethereum/normalized-hex key-uid) :keycard-pairing pairing :keycard-paired-on paired-on :chat-key whisper-private-key} @@ -1858,7 +1861,7 @@ ; https://github.com/ethereum/go-ethereum/blob/master/internal/ethapi/api.go#L431 (clojure.string/replace-first #"00$", "1b") (clojure.string/replace-first #"01$", "1c") - (ethereum/normalized-address))] + (ethereum/normalized-hex))] {:dispatch [:signing/sign-message-completed (types/clj->json {:result signature'})]})) diff --git a/src/status_im/init/core.cljs b/src/status_im/init/core.cljs index c115b8a992..c15cfd807f 100644 --- a/src/status_im/init/core.cljs +++ b/src/status_im/init/core.cljs @@ -41,10 +41,10 @@ (fx/defn initialize-multiaccounts {:events [::initialize-multiaccounts]} [{:keys [db] :as cofx} all-multiaccounts] - (let [multiaccounts (reduce (fn [acc {:keys [address keycard-key-uid keycard-pairing] :as multiaccount}] + (let [multiaccounts (reduce (fn [acc {:keys [address key-uid keycard-pairing] :as multiaccount}] (-> (assoc acc address multiaccount) - (assoc-in [address :keycard-key-uid] (when-not (string/blank? keycard-key-uid) - keycard-key-uid)) + (assoc-in [address :key-uid] (when-not (string/blank? key-uid) + key-uid)) (assoc-in [address :keycard-pairing] (when-not (string/blank? keycard-pairing) keycard-pairing)))) {} diff --git a/src/status_im/multiaccounts/create/core.cljs b/src/status_im/multiaccounts/create/core.cljs index e45d57820d..3aa66cdce0 100644 --- a/src/status_im/multiaccounts/create/core.cljs +++ b/src/status_im/multiaccounts/create/core.cljs @@ -205,37 +205,44 @@ (fx/defn on-multiaccount-created [{:keys [signing-phrase random-guid-generator db] :as cofx} - {:keys [address chat-key keycard-instance-uid keycard-key-uid keycard-pairing keycard-paired-on mnemonic] :as multiaccount} + {:keys [address chat-key keycard-instance-uid keyUid + keycard-pairing keycard-paired-on mnemonic public-key] + :as multiaccount} password {:keys [seed-backed-up? login?] :or {login? true}}] (let [[wallet-account {:keys [publicKey]} :as accounts-data] (prepare-accounts-data multiaccount) name (gfycat/generate-gfy publicKey) photo-path (identicon/identicon publicKey) - multiaccount-data {:name name :address address :photo-path photo-path} - new-multiaccount (cond-> {; address of the master key - :address address + multiaccount-data {:name name + :address address + :photo-path photo-path + :key-uid keyUid} + keycard-multiaccount? (boolean keycard-pairing) + new-multiaccount (cond-> {;; address of the master key + :address address + ;; sha256 of master public key + :key-uid keyUid ;; The address from which we derive any wallet - :wallet-root-address (get-in multiaccount [:derived constants/path-wallet-root-keyword :address]) + :wallet-root-address (get-in multiaccount [:derived constants/path-wallet-root-keyword :address]) ;; The address from which we derive any chat account/encryption keys - :eip1581-address (get-in multiaccount [:derived constants/path-eip1581-keyword :address]) - :name name - :photo-path photo-path - ; public key of the chat account - :public-key publicKey - ; default address for Dapps - :dapps-address (:address wallet-account) - :latest-derived-path 0 - :accounts [wallet-account] - :signing-phrase signing-phrase + :eip1581-address (get-in multiaccount [:derived constants/path-eip1581-keyword :address]) + :name name + :photo-path photo-path + ;; public key of the chat account + :public-key publicKey + ;; default address for Dapps + :dapps-address (:address wallet-account) + :latest-derived-path 0 + :accounts [wallet-account] + :signing-phrase signing-phrase + :installation-id (random-guid-generator) + :mnemonic mnemonic + :settings constants/default-multiaccount-settings} - :installation-id (random-guid-generator) - :mnemonic mnemonic - :settings constants/default-multiaccount-settings} - - keycard-key-uid (assoc :keycard-instance-uid keycard-instance-uid - :keycard-key-uid keycard-key-uid - :keycard-pairing keycard-pairing - :keycard-paired-on keycard-paired-on)) + keycard-multiaccount? + (assoc :keycard-instance-uid keycard-instance-uid + :keycard-pairing keycard-pairing + :keycard-paired-on keycard-paired-on)) db (assoc db :multiaccounts/login {:address address :name name @@ -250,7 +257,7 @@ {:db (cond-> db seed-backed-up? (assoc-in [:multiaccount :seed-backed-up?] true))} - (if keycard-key-uid + (if keycard-multiaccount? (save-account-and-login-with-keycard new-multiaccount password (node/get-new-config db) diff --git a/src/status_im/multiaccounts/db.cljs b/src/status_im/multiaccounts/db.cljs index f75d11342a..768dd1fc5e 100644 --- a/src/status_im/multiaccounts/db.cljs +++ b/src/status_im/multiaccounts/db.cljs @@ -38,10 +38,9 @@ (spec/def :multiaccount/hide-home-tooltip? (spec/nilable boolean?)) (spec/def :multiaccount/desktop-alpha-release-warning-shown? (spec/nilable boolean?)) (spec/def :multiaccount/keycard-instance-uid (spec/nilable string?)) -(spec/def :multiaccount/keycard-key-uid (spec/nilable string?)) +(spec/def :multiaccount/key-uid (spec/nilable string?)) (spec/def :multiaccount/keycard-pairing (spec/nilable string?)) (spec/def :multiaccount/keycard-paired-on (spec/nilable int?)) - (spec/def :multiaccount/multiaccount (spec/keys :opt-un [:multiaccount/name :multiaccount/address :multiaccount/photo-path :multiaccount/signing-phrase @@ -57,7 +56,7 @@ :multiaccount/bootnodes :multiaccount/desktop-alpha-release-warning-shown? :multiaccount/keycard-instance-uid - :multiaccount/keycard-key-uid + :multiaccount/key-uid :multiaccount/keycard-pairing :multiaccount/keycard-paired-on :multiaccount/root-address diff --git a/src/status_im/multiaccounts/login/core.cljs b/src/status_im/multiaccounts/login/core.cljs index 229b861b91..72cec23b68 100644 --- a/src/status_im/multiaccounts/login/core.cljs +++ b/src/status_im/multiaccounts/login/core.cljs @@ -248,12 +248,15 @@ (fx/defn multiaccount-login-success [{:keys [db] :as cofx}] - (let [{:keys [address password save-password? name photo-path creating?]} (:multiaccounts/login db) + (let [{:keys [address password save-password? creating?]} (:multiaccounts/login db) recovering? (get-in db [:intro-wizard :recovering?]) login-only? (not (or creating? recovering? (keycard-setup? cofx))) nodes nil] + (log/debug "[multiaccount] multiaccount-login-success" + "login-only?" login-only? + "recovering?" recovering?) (fx/merge cofx {:db (-> db (dissoc :multiaccounts/login) @@ -288,7 +291,7 @@ (fx/defn open-login [{:keys [db] :as cofx} address photo-path name public-key] - (let [keycard-multiaccount? (get-in db [:multiaccounts/multiaccounts address :keycard-key-uid])] + (let [keycard-multiaccount? (boolean (get-in db [:multiaccounts/multiaccounts address :keycard-pairing]))] (fx/merge cofx {:db (-> db (update :multiaccounts/login assoc diff --git a/src/status_im/multiaccounts/recover/core.cljs b/src/status_im/multiaccounts/recover/core.cljs index dbc72cf656..fd0b6ee916 100644 --- a/src/status_im/multiaccounts/recover/core.cljs +++ b/src/status_im/multiaccounts/recover/core.cljs @@ -14,7 +14,13 @@ [status-im.utils.security :as security] [status-im.utils.types :as types] [status-im.utils.platform :as platform] - [status-im.utils.utils :as utils])) + [status-im.utils.utils :as utils] + [status-im.ethereum.eip55 :as eip55])) + +(defn existing-account? + [root-key multiaccounts] + (contains? multiaccounts ((fnil clojure.string/lower-case "") + (:address root-key)))) (defn check-phrase-warnings [recovery-phrase] (cond (string/blank? recovery-phrase) :required-field @@ -47,7 +53,7 @@ multiaccount-address (-> (:address multiaccount) (string/lower-case) (string/replace-first "0x" "")) - keycard-multiaccount? (boolean (get-in db [:multiaccounts/multiaccounts multiaccount-address :keycard-key-uid]))] + keycard-multiaccount? (boolean (get-in db [:multiaccounts/multiaccounts multiaccount-address :keycard-pairing]))] (if keycard-multiaccount? ;; trying to recover multiaccount created with keycard {:db (-> db @@ -105,16 +111,31 @@ (re-frame/dispatch [::import-multiaccount-success root-data derived-data]))))))))) +(fx/defn show-existing-multiaccount-alert + [_ address] + {:utils/show-confirmation + {:title (i18n/label :t/multiaccount-exists-title) + :content (i18n/label :t/multiaccount-exists-content) + :confirm-button-text (i18n/label :t/unlock) + :on-accept #(re-frame/dispatch + [:multiaccounts.login.ui/multiaccount-selected + (clojure.string/lower-case address)]) + :on-cancel #(re-frame/dispatch [:navigate-to :multiaccounts])}}) + (fx/defn on-import-multiaccount-success {:events [::import-multiaccount-success]} - [{:keys [db] :as cofx} root-data derived-data] - (fx/merge cofx - {:db (update db :intro-wizard - assoc :root-key root-data - :derived derived-data - :step :recovery-success - :forward-action :multiaccounts.recover/re-encrypt-pressed)} - (navigation/navigate-to-cofx :recover-multiaccount-success nil))) + [{:keys [db] :as cofx} {:keys [address] :as root-data} derived-data] + (let [multiaccounts (:multiaccounts/multiaccounts db)] + (fx/merge + cofx + {:db (update db :intro-wizard + assoc :root-key root-data + :derived derived-data + :step :recovery-success + :forward-action :multiaccounts.recover/re-encrypt-pressed)} + (when (existing-account? root-data multiaccounts) + (show-existing-multiaccount-alert address)) + (navigation/navigate-to-cofx :recover-multiaccount-success nil)))) (fx/defn enter-phrase-pressed {:events [::enter-phrase-pressed]} diff --git a/src/status_im/signing/core.cljs b/src/status_im/signing/core.cljs index 5ed624b7a5..e8f06adea3 100644 --- a/src/status_im/signing/core.cljs +++ b/src/status_im/signing/core.cljs @@ -47,7 +47,7 @@ (let [to (utils.hex/normalize-hex to)] (or (get-in db [:contacts/contacts to]) - {:address (ethereum/normalized-address to)}))) + {:address (ethereum/normalized-hex to)}))) (fx/defn change-password {:events [:signing.ui/password-is-changed]} @@ -156,7 +156,7 @@ token :else {:to to - :contact {:address (ethereum/normalized-address to)}}))))) + :contact {:address (ethereum/normalized-hex to)}}))))) (defn prepare-tx [db {{:keys [data gas gasPrice] :as tx-obj} :tx-obj :as tx}] (merge @@ -169,7 +169,7 @@ (fx/defn show-sign [{:keys [db] :as cofx}] (let [{:signing/keys [queue]} db {{:keys [gas gasPrice] :as tx-obj} :tx-obj {:keys [data typed?] :as message} :message :as tx} (last queue) - keycard-multiaccount? (boolean (get-in db [:multiaccount :keycard-key-uid])) + keycard-multiaccount? (boolean (get-in db [:multiaccount :keycard-pairing])) wallet-set-up-passed? (get-in db [:multiaccount :wallet-set-up-passed?]) updated-db (if wallet-set-up-passed? db (assoc db :popover/popover {:view :signing-phrase}))] (if message diff --git a/src/status_im/subs.cljs b/src/status_im/subs.cljs index c411448187..b29e17f357 100644 --- a/src/status_im/subs.cljs +++ b/src/status_im/subs.cljs @@ -22,6 +22,7 @@ [status-im.multiaccounts.model :as multiaccounts.model] [status-im.multiaccounts.core :as multiaccounts] [status-im.multiaccounts.db :as multiaccounts.db] + [status-im.multiaccounts.recover.core :as recover] [status-im.pairing.core :as pairing] [status-im.tribute-to-talk.core :as tribute-to-talk] [status-im.tribute-to-talk.db :as tribute-to-talk.db] @@ -264,6 +265,13 @@ {:pubkey (get-in wizard-state [:derived constants/path-whisper-keyword :publicKey]) :processing? (:processing? wizard-state)})) +(re-frame/reg-sub + :intro-wizard/recover-existing-account? + :<- [:intro-wizard] + :<- [:multiaccounts/multiaccounts] + (fn [[intro-wizard multiaccounts]] + (recover/existing-account? (:root-key intro-wizard) multiaccounts))) + (re-frame/reg-sub :settings/logging-enabled :<- [:desktop/desktop] @@ -446,7 +454,7 @@ :multiaccount/default-address :<- [:multiaccount] (fn [{:keys [accounts]}] - (ethereum/normalized-address + (ethereum/normalized-hex (:address (ethereum/get-default-account accounts))))) (re-frame/reg-sub diff --git a/src/status_im/ui/screens/ens/views.cljs b/src/status_im/ui/screens/ens/views.cljs index c61b4c9241..ec1047100b 100644 --- a/src/status_im/ui/screens/ens/views.cljs +++ b/src/status_im/ui/screens/ens/views.cljs @@ -497,7 +497,7 @@ [react/view {:style {:margin-top 22}} (when-not pending? [section {:title (i18n/label :t/wallet-address) - :content (ethereum/normalized-address address)}]) + :content (ethereum/normalized-hex address)}]) (when-not pending? [react/view {:style {:margin-top 14}} [section {:title (i18n/label :t/key) @@ -668,4 +668,4 @@ (i18n/label :t/ens-usernames)] (if (seq names) [registered names multiaccount show?] - [welcome])])) \ No newline at end of file + [welcome])])) diff --git a/src/status_im/ui/screens/hardwallet/settings/subs.cljs b/src/status_im/ui/screens/hardwallet/settings/subs.cljs index e52e6ad093..4f9cb51e62 100644 --- a/src/status_im/ui/screens/hardwallet/settings/subs.cljs +++ b/src/status_im/ui/screens/hardwallet/settings/subs.cljs @@ -50,4 +50,4 @@ :keycard-multiaccount? (fn [db] (boolean - (get-in db [:multiaccount :keycard-key-uid])))) + (get-in db [:multiaccount :keycard-pairing])))) diff --git a/src/status_im/ui/screens/intro/styles.cljs b/src/status_im/ui/screens/intro/styles.cljs index 54377c85cf..feffcf8fa0 100644 --- a/src/status_im/ui/screens/intro/styles.cljs +++ b/src/status_im/ui/screens/intro/styles.cljs @@ -89,6 +89,12 @@ :align-items :center :flex-direction :row}) +(def disabled-bottom-button + (assoc bottom-button :background-color colors/gray-transparent-10)) + +(def disabled-bottom-button-text + {:color colors/gray-transparent-40}) + (def bottom-button-container {:margin-bottom 24 :margin-top 16}) diff --git a/src/status_im/ui/screens/intro/views.cljs b/src/status_im/ui/screens/intro/views.cljs index 95e168f41f..0fc61725b1 100644 --- a/src/status_im/ui/screens/intro/views.cljs +++ b/src/status_im/ui/screens/intro/views.cljs @@ -253,7 +253,7 @@ (defn bottom-bar [{:keys [step weak-password? encrypt-with-password? forward-action next-button-disabled? - processing?] :as wizard-state}] + processing? existing-account?] :as wizard-state}] [react/view {:style {:margin-bottom (if (or (#{:choose-key :select-key-storage :enter-phrase :recovery-success} step) (and (#{:create-code :confirm-code} step) @@ -271,11 +271,16 @@ :recovery-success :re-encrypt-key :intro-wizard-title6)] [react/view {:min-height 46 :max-height 46} - [components.common/button {:button-style styles/bottom-button - :on-press #(re-frame/dispatch - [forward-action]) - :accessibility-label :onboarding-next-button - :label (i18n/label label-kw)}]]) + [components.common/button + {:button-style (if existing-account? + styles/disabled-bottom-button + styles/bottom-button) + :on-press (when-not existing-account? + #(re-frame/dispatch [forward-action])) + :accessibility-label :onboarding-next-button + :label (i18n/label label-kw) + :label-style (when existing-account? + styles/disabled-bottom-button-text)}]]) (and (#{:create-code :confirm-code} step) (not encrypt-with-password?)) [components.common/button {:button-style styles/bottom-button @@ -555,7 +560,8 @@ wizard-state)]]])) (defview wizard-recovery-success [] - (letsubs [{:keys [pubkey processing?]} [:intro-wizard/recovery-success]] + (letsubs [{:keys [pubkey processing?]} [:intro-wizard/recovery-success] + existing-account? [:intro-wizard/recover-existing-account?]] [react/view {:style {:flex 1}} [toolbar/toolbar {:style {:border-bottom-width 0 @@ -567,6 +573,7 @@ :justify-content :space-between}} [top-bar {:step :recovery-success}] [recovery-success pubkey] - [bottom-bar {:step :recovery-success - :forward-action :multiaccounts.recover/re-encrypt-pressed - :processing? processing?}]]])) + [bottom-bar {:step :recovery-success + :forward-action :multiaccounts.recover/re-encrypt-pressed + :processing? processing? + :existing-account? existing-account?}]]])) diff --git a/src/status_im/ui/screens/multiaccounts/views.cljs b/src/status_im/ui/screens/multiaccounts/views.cljs index 5fb08bbf84..b309a32126 100644 --- a/src/status_im/ui/screens/multiaccounts/views.cljs +++ b/src/status_im/ui/screens/multiaccounts/views.cljs @@ -15,8 +15,9 @@ [status-im.ui.screens.privacy-policy.views :as privacy-policy] [status-im.react-native.resources :as resources])) -(defn multiaccount-view [{:keys [address photo-path name public-key keycard-key-uid]}] - [react/touchable-highlight {:on-press #(re-frame/dispatch [:multiaccounts.login.ui/multiaccount-selected address photo-path name public-key])} +(defn multiaccount-view + [{:keys [address photo-path name public-key keycard-pairing]}] + [react/touchable-highlight {:on-press #(re-frame/dispatch [:multiaccounts.login.ui/multiaccount-selected address])} [react/view styles/multiaccount-view [photos/photo photo-path {:size styles/multiaccount-image-size}] [react/view styles/multiaccount-badge-text-view @@ -28,7 +29,7 @@ [react/text {:style styles/multiaccount-badge-pub-key-text} (utils/get-shortened-address public-key)]] [react/view {:flex 1}] - (when keycard-key-uid + (when keycard-pairing [react/view {:justify-content :center :align-items :center :margin-right 7 diff --git a/src/status_im/ui/screens/privacy_and_security_settings/views.cljs b/src/status_im/ui/screens/privacy_and_security_settings/views.cljs index 3b5b7309a8..f01b0f5764 100644 --- a/src/status_im/ui/screens/privacy_and_security_settings/views.cljs +++ b/src/status_im/ui/screens/privacy_and_security_settings/views.cljs @@ -85,7 +85,7 @@ settings [:multiaccount-settings] supported-biometric-auth [:supported-biometric-auth] auth-method [:auth-method] - {:keys [keycard-key-uid]} [:multiaccount]] + keycard-multiaccount? [:keycard-multiaccount?]] (let [show-backup-seed? (and (not seed-backed-up?) (not (string/blank? mnemonic)))] [react/view {:flex 1 :background-color colors/white} @@ -93,6 +93,6 @@ (i18n/label :t/privacy-and-security)] [list/flat-list {:data (list-data show-backup-seed? settings supported-biometric-auth - (= auth-method "biometric") (boolean keycard-key-uid)) + (= auth-method "biometric") keycard-multiaccount?) :key-fn (fn [_ i] (str i)) - :render-fn list/flat-list-generic-render-fn}]]))) \ No newline at end of file + :render-fn list/flat-list-generic-render-fn}]]))) diff --git a/src/status_im/ui/screens/profile/user/views.cljs b/src/status_im/ui/screens/profile/user/views.cljs index e4d406aa8e..46d7173907 100644 --- a/src/status_im/ui/screens/profile/user/views.cljs +++ b/src/status_im/ui/screens/profile/user/views.cljs @@ -218,7 +218,7 @@ preferred-name seed-backed-up? mnemonic - keycard-key-uid + keycard-pairing address notifications-enabled?] :as multiaccount} @(re-frame/subscribe [:multiaccount]) @@ -233,7 +233,7 @@ (flat-list-content preferred-name registrar tribute-to-talk active-contacts-count show-backup-seed? - keycard-key-uid notifications-enabled?) + keycard-pairing notifications-enabled?) list-ref scroll-y])) diff --git a/src/status_im/ui/screens/wallet/account/views.cljs b/src/status_im/ui/screens/wallet/account/views.cljs index b59f637978..5c56b4129d 100644 --- a/src/status_im/ui/screens/wallet/account/views.cljs +++ b/src/status_im/ui/screens/wallet/account/views.cljs @@ -55,7 +55,7 @@ :line-height 22 :font-size 13 :font-family "monospace" :color colors/white-transparent-70}} - (ethereum/normalized-address address)]] + (ethereum/normalized-hex address)]] [react/view {:position :absolute :top 12 :right 12} [react/touchable-highlight {:on-press #(re-frame/dispatch [:show-popover {:view :share-account :address address}])} [icons/icon :main-icons/share {:color colors/white diff --git a/src/status_im/ui/screens/wallet/accounts/views.cljs b/src/status_im/ui/screens/wallet/accounts/views.cljs index 2b82212c2e..fdfb8dad79 100644 --- a/src/status_im/ui/screens/wallet/accounts/views.cljs +++ b/src/status_im/ui/screens/wallet/accounts/views.cljs @@ -122,14 +122,14 @@ [icons/icon :main-icons/more {:accessibility-label :accounts-more-options}]]]])) (views/defview accounts [] - (views/letsubs [{:keys [accounts keycard-key-uid]} [:multiaccount]] + (views/letsubs [{:keys [accounts keycard-pairing]} [:multiaccount]] [react/scroll-view {:horizontal true} [react/view {:flex-direction :row :padding-top 11 :padding-bottom 12} (for [account accounts] ^{:key account} [account-card account]) ; TODO: enable keycard support for adding new accounts - (when-not keycard-key-uid + (when-not keycard-pairing [add-card])]])) (defn accounts-overview [] diff --git a/src/status_im/ui/screens/wallet/components/views.cljs b/src/status_im/ui/screens/wallet/components/views.cljs index 02d7f44226..f9ada6352e 100644 --- a/src/status_im/ui/screens/wallet/components/views.cljs +++ b/src/status_im/ui/screens/wallet/components/views.cljs @@ -43,4 +43,4 @@ :on-change-text #(reset! content %) :accessibility-label :recipient-address-input}] [react/text {:style {:color colors/gray :margin-horizontal 16}} - "Enter address or username of the recepient"]]])) \ No newline at end of file + "Enter address or username of the recepient"]]])) diff --git a/src/status_im/ui/screens/wallet/settings/views.cljs b/src/status_im/ui/screens/wallet/settings/views.cljs index e8d310dcd1..43fedf5282 100644 --- a/src/status_im/ui/screens/wallet/settings/views.cljs +++ b/src/status_im/ui/screens/wallet/settings/views.cljs @@ -100,7 +100,7 @@ :render-fn render-token-wrapper}]]])) (defn- create-payload [address] - {:address (ethereum/normalized-address address)}) + {:address (ethereum/normalized-hex address)}) (defview settings-hook [] (letsubs [{:keys [label view on-close]} [:get-screen-params :wallet-settings-hook] diff --git a/src/status_im/utils/contenthash.cljs b/src/status_im/utils/contenthash.cljs index 017bc93421..387eb3e303 100644 --- a/src/status_im/utils/contenthash.cljs +++ b/src/status_im/utils/contenthash.cljs @@ -56,7 +56,7 @@ b58/encode))}))) (defn url [hex] - (let [{:keys [namespace hash]} (decode (ethereum/normalized-address hex))] + (let [{:keys [namespace hash]} (decode (ethereum/normalized-hex hex))] (case namespace :ipfs (str "https://ipfs.infura.io/ipfs/" hash) ""))) diff --git a/src/status_im/utils/utils.cljs b/src/status_im/utils/utils.cljs index 910f898583..ffb843095b 100644 --- a/src/status_im/utils/utils.cljs +++ b/src/status_im/utils/utils.cljs @@ -86,7 +86,7 @@ (defn get-shortened-checksum-address [address] (when address - (get-shortened-address (eip55/address->checksum (ethereum/normalized-address address))))) + (get-shortened-address (eip55/address->checksum (ethereum/normalized-hex address))))) ;; debounce, taken from https://github.com/johnswanson/re-frame-debounce-fx ; {:dispatch-debounce {:key :search diff --git a/src/status_im/wallet/core.cljs b/src/status_im/wallet/core.cljs index 93a303627a..b06b1fdb72 100644 --- a/src/status_im/wallet/core.cljs +++ b/src/status_im/wallet/core.cljs @@ -362,7 +362,7 @@ [{:keys [db] :as cofx} {:keys [to amount from token from-chat? gas gasPrice]}] (let [{:keys [symbol address]} token amount-hex (str "0x" (abi-spec/number-to-hex amount)) - to-norm (ethereum/normalized-address (if (string? to) to (:address to))) + to-norm (ethereum/normalized-hex (if (string? to) to (:address to))) from-address (:address from)] (fx/merge cofx {:db (dissoc db :wallet/prepare-transaction)} @@ -372,7 +372,7 @@ {:to to-norm :from from-address :value amount-hex} - {:to (ethereum/normalized-address address) + {:to (ethereum/normalized-hex address) :from from-address :data (abi-spec/encode "transfer(address,uint256)" @@ -446,4 +446,4 @@ (fx/merge cofx {:db (assoc-in db [:wallet/prepare-transaction :modal-opened?] true)} (bottom-sheet/hide-bottom-sheet) - (navigation/navigate-to-cofx :contact-code nil))) \ No newline at end of file + (navigation/navigate-to-cofx :contact-code nil))) diff --git a/status-go-version.json b/status-go-version.json index 9652291837..db33c45030 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -2,7 +2,7 @@ "_comment": "DO NOT EDIT THIS FILE BY HAND. USE 'scripts/update-status-go.sh ' instead", "owner": "status-im", "repo": "status-go", - "version": "v0.35.0", - "commit-sha1": "2dd74da23d9fcca116e02a2a35d964172c98ffdf", - "src-sha256": "16zb6a5svh7hqm77jnsf5dyrl173mvddd6rxhmvcs6prblg4j7f8" + "version": "develop", + "commit-sha1": "5f6c7008e19227392589a917def8db3780fcc5db", + "src-sha256": "0akpf4k7i5rpna0vb2m6lsy7lgsgv19g5lszxhysiacpf37q0hxv" } diff --git a/translations/en.json b/translations/en.json index 87a811ef71..127fc68ab9 100644 --- a/translations/en.json +++ b/translations/en.json @@ -679,6 +679,8 @@ "mobile-syncing-sheet-details": "Status tends to use a lot of data when syncing chats. You can choose not to sync when on mobile network", "mobile-syncing-sheet-title": "Sync using Mobile data", "more": "more", + "multiaccount-exists-title": "Multiaccount already exists", + "multiaccount-exists-content": "This multiaccount already exists. You just need to unlock it", "multiaccounts-recover-enter-phrase-text": "Enter 12, 15, 18, 21 or 24 words.\nSeparate words by a single space.", "multiaccounts-recover-enter-phrase-title": "Enter your seed phrase", "name": "Name",