Allign to latest accounts changes

This commit is contained in:
Roman Volosovskyi 2023-05-30 13:57:09 +02:00
parent 15211865fb
commit d395ca6cc6
No known key found for this signature in database
GPG Key ID: 0238A4B5ECEE70DE
2 changed files with 30 additions and 9 deletions

View File

@ -71,7 +71,7 @@
(defn derive-and-store-account (defn derive-and-store-account
[key-uid path hashed-password type accounts] [key-uid path hashed-password type accounts]
(fn [value] (fn [value]
(let [{:keys [id error]} (types/json->clj value)] (let [{:keys [id error keyUid]} (types/json->clj value)]
(if error (if error
(re-frame/dispatch [::new-account-error :password-error error]) (re-frame/dispatch [::new-account-error :password-error error])
(native-module/multiaccount-derive-addresses (native-module/multiaccount-derive-addresses
@ -96,6 +96,7 @@
[:wallet.accounts/account-stored [:wallet.accounts/account-stored
{:address address {:address address
:public-key publicKey :public-key publicKey
:key-uid keyUid
:type type :type type
:path (normalize-path path)}]))))))))))))) :path (normalize-path path)}])))))))))))))
@ -192,13 +193,33 @@
(rf/defn save-new-account (rf/defn save-new-account
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [{:keys [latest-derived-path]} (:multiaccount db) (let [{:keys [latest-derived-path]} (:multiaccount db)
{:keys [account type]} (:add-account db) {:keys [account type]} (:add-account db)
accounts (:multiaccount/accounts db) {:keys [address name key-uid]} account
new-accounts (conj accounts account)] main-key-uid (or key-uid (get-in db [:multiaccount :key-uid]))
accounts (:multiaccount/accounts db)
new-accounts (conj accounts account)
;; Note(rasom): in case if a new account is created using a mnemonic or
;; a private key we add a new keypair to the database, otherwise we just
;; keep using "profile" keypair
[method params]
(if key-uid
["accounts_saveKeypair"
[{:key-uid main-key-uid
:name name
:type (if (= type :seed)
"seed"
"key")
:derived-from address
:last-used-derivation-index 0
:synced-from ""
:clock 0
:accounts [account]}]]
["accounts_saveAccount"
[(assoc account :key-uid key-uid)]])]
(when account (when account
(rf/merge cofx (rf/merge cofx
{:json-rpc/call [{:method "accounts_saveAccount" {:json-rpc/call [{:method method
:params [account] :params params
:on-success #(re-frame/dispatch [::wallet/restart])}] :on-success #(re-frame/dispatch [::wallet/restart])}]
:db (-> db :db (-> db
(assoc :multiaccount/accounts new-accounts) (assoc :multiaccount/accounts new-accounts)

View File

@ -3,7 +3,7 @@
"_comment": "Instead use: scripts/update-status-go.sh <rev>", "_comment": "Instead use: scripts/update-status-go.sh <rev>",
"owner": "status-im", "owner": "status-im",
"repo": "status-go", "repo": "status-go",
"version": "v0.152.2", "version": "v0.152.3",
"commit-sha1": "ee4003279aee0f8f1c80e4382fb16108aaac1384", "commit-sha1": "aded83fc6e9a2834c061f1a268fff071bcdc5621",
"src-sha256": "1a4v8bgxals5v4agbqssddq9vwjkz9k005zmyjs3mfyqsq0ahk35" "src-sha256": "02hrlv2484x5d2ycvk3p58bkng7q40z7nyl2k2f6xhxzx9ppnbjs"
} }