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
[key-uid path hashed-password type accounts]
(fn [value]
(let [{:keys [id error]} (types/json->clj value)]
(let [{:keys [id error keyUid]} (types/json->clj value)]
(if error
(re-frame/dispatch [::new-account-error :password-error error])
(native-module/multiaccount-derive-addresses
@ -96,6 +96,7 @@
[:wallet.accounts/account-stored
{:address address
:public-key publicKey
:key-uid keyUid
:type type
:path (normalize-path path)}])))))))))))))
@ -192,13 +193,33 @@
(rf/defn save-new-account
[{:keys [db] :as cofx}]
(let [{:keys [latest-derived-path]} (:multiaccount db)
{:keys [account type]} (:add-account db)
accounts (:multiaccount/accounts db)
new-accounts (conj accounts account)]
{:keys [account type]} (:add-account db)
{:keys [address name key-uid]} 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
(rf/merge cofx
{:json-rpc/call [{:method "accounts_saveAccount"
:params [account]
{:json-rpc/call [{:method method
:params params
:on-success #(re-frame/dispatch [::wallet/restart])}]
:db (-> db
(assoc :multiaccount/accounts new-accounts)

View File

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