multiaccounts refactoring part1 (#16414)

This commit is contained in:
flexsurfer 2023-06-28 13:48:34 +02:00 committed by GitHub
parent e0a0c6331f
commit c5a7bf39d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
141 changed files with 723 additions and 988 deletions

View File

@ -22,7 +22,7 @@
(rf/defn fetch (rf/defn fetch
[cofx id] [cofx id]
(let [network (get-in cofx [:db :networks/current-network])] (let [network (get-in cofx [:db :networks/current-network])]
(get-in cofx [:db :multiaccount :custom-bootnodes network id]))) (get-in cofx [:db :profile/profile :custom-bootnodes network id])))
(rf/defn set-input (rf/defn set-input
{:events [:bootnodes.ui/input-changed]} {:events [:bootnodes.ui/input-changed]}
@ -54,26 +54,26 @@
(defn custom-bootnodes-in-use? (defn custom-bootnodes-in-use?
[{:keys [db]}] [{:keys [db]}]
(let [network (:networks/current-network db)] (let [network (:networks/current-network db)]
(get-in db [:multiaccount :custom-bootnodes-enabled? network]))) (get-in db [:profile/profile :custom-bootnodes-enabled? network])))
(rf/defn delete (rf/defn delete
[{{:keys [multiaccount] :as db} :db :as cofx} id] [{{:profile/keys [profile] :as db} :db :as cofx} id]
(let [network (:networks/current-network db) (let [network (:networks/current-network db)
new-multiaccount (update-in multiaccount [:custom-bootnodes network] dissoc id)] new-profile (update-in profile [:custom-bootnodes network] dissoc id)]
(rf/merge cofx (rf/merge cofx
{:db (assoc db :multiaccount new-multiaccount)} {:db (assoc db :profile/profile new-profile)}
(multiaccounts.update/multiaccount-update (multiaccounts.update/multiaccount-update
:custom-bootnodes :custom-bootnodes
(:custom-bootnodes new-multiaccount) (:custom-bootnodes new-profile)
{:success-event (when (custom-bootnodes-in-use? cofx) {:success-event (when (custom-bootnodes-in-use? cofx)
[:multiaccounts.update.callback/save-settings-success])})))) [:multiaccounts.update.callback/save-settings-success])}))))
(rf/defn upsert (rf/defn upsert
{:events [:bootnodes.ui/save-pressed] {:events [:bootnodes.ui/save-pressed]
:interceptors [(re-frame/inject-cofx :random-id-generator)]} :interceptors [(re-frame/inject-cofx :random-id-generator)]}
[{{:bootnodes/keys [manage] :keys [multiaccount] :as db} :db [{{:bootnodes/keys [manage] :profile/keys [profile] :as db} :db
random-id-generator :random-id-generator random-id-generator :random-id-generator
:as cofx}] :as cofx}]
(let [{:keys [name id url]} manage (let [{:keys [name id url]} manage
network (:networks/current-network db) network (:networks/current-network db)
bootnode (build bootnode (build
@ -82,7 +82,7 @@
(:value url) (:value url)
network) network)
new-bootnodes (assoc-in new-bootnodes (assoc-in
(:custom-bootnodes multiaccount) (:custom-bootnodes profile)
[network (:id bootnode)] [network (:id bootnode)]
bootnode)] bootnode)]
@ -99,7 +99,7 @@
{:events [:bootnodes.ui/custom-bootnodes-switch-toggled]} {:events [:bootnodes.ui/custom-bootnodes-switch-toggled]}
[{:keys [db] :as cofx} value] [{:keys [db] :as cofx} value]
(let [current-network (:networks/current-network db) (let [current-network (:networks/current-network db)
bootnodes-settings (get-in db [:multiaccount :custom-bootnodes-enabled?])] bootnodes-settings (get-in db [:profile/profile :custom-bootnodes-enabled?])]
(multiaccounts.update/multiaccount-update (multiaccounts.update/multiaccount-update
cofx cofx
:custom-bootnodes-enabled? :custom-bootnodes-enabled?

View File

@ -20,9 +20,9 @@
{:random-id-generator (constantly "some-id") {:random-id-generator (constantly "some-id")
:db {:bootnodes/manage new-bootnode :db {:bootnodes/manage new-bootnode
:networks/current-network "mainnet_rpc" :networks/current-network "mainnet_rpc"
:multiaccount {:not-empty :profile/profile {:not-empty
"would throw an error if was empty"}}})] "would throw an error if was empty"}}})]
(is (= expected (get-in actual [:db :multiaccount :custom-bootnodes]))))) (is (= expected (get-in actual [:db :profile/profile :custom-bootnodes])))))
(testing "adding an existing bootnode" (testing "adding an existing bootnode"
(let [new-bootnode {:id {:value "a"} (let [new-bootnode {:id {:value "a"}
:name {:value "new-name"} :name {:value "new-name"}
@ -35,13 +35,13 @@
{:random-id-generator (constantly "some-id") {:random-id-generator (constantly "some-id")
:db {:bootnodes/manage new-bootnode :db {:bootnodes/manage new-bootnode
:networks/current-network "mainnet_rpc" :networks/current-network "mainnet_rpc"
:multiaccount {:custom-bootnodes :profile/profile {:custom-bootnodes
{"mainnet_rpc" {"mainnet_rpc"
{"a" {:name "name" {"a" {:name "name"
:address "url" :address "url"
:chain "mainnet_rpc" :chain "mainnet_rpc"
:id "a"}}}}}})] :id "a"}}}}}})]
(is (= expected (get-in actual [:db :multiaccount :custom-bootnodes])))))) (is (= expected (get-in actual [:db :profile/profile :custom-bootnodes]))))))
(deftest set-input-bootnode (deftest set-input-bootnode
(testing "it validates names" (testing "it validates names"
@ -72,7 +72,7 @@
(deftest edit-bootnode (deftest edit-bootnode
(let [db {:networks/current-network "mainnet_rpc" (let [db {:networks/current-network "mainnet_rpc"
:multiaccount :profile/profile
{:custom-bootnodes {:custom-bootnodes
{"mainnet_rpc" {"mainnet_rpc"
{"a" {:id "a" {"a" {:id "a"
@ -123,7 +123,7 @@
(deftest fetch-bootnode (deftest fetch-bootnode
(testing "it fetches the bootnode from the db" (testing "it fetches the bootnode from the db"
(let [cofx {:db {:networks/current-network "mainnet_rpc" (let [cofx {:db {:networks/current-network "mainnet_rpc"
:multiaccount {:custom-bootnodes :profile/profile {:custom-bootnodes
{"mainnet_rpc" {"mainnet_rpc"
{"a" {:id "a" {"a" {:id "a"
:name "name" :name "name"
@ -138,7 +138,7 @@
(testing "it returns true when enabled" (testing "it returns true when enabled"
(is (model/custom-bootnodes-in-use? (is (model/custom-bootnodes-in-use?
{:db {:networks/current-network "mainnet_rpc" {:db {:networks/current-network "mainnet_rpc"
:multiaccount {:custom-bootnodes-enabled? :profile/profile {:custom-bootnodes-enabled?
{"mainnet_rpc" true}}}})))) {"mainnet_rpc" true}}}}))))
(testing "is on a different network" (testing "is on a different network"
(testing "it returns false when not enabled" (testing "it returns false when not enabled"
@ -146,13 +146,13 @@
(testing "it returns true when enabled" (testing "it returns true when enabled"
(is (not (model/custom-bootnodes-in-use? (is (not (model/custom-bootnodes-in-use?
{:db {:networks/current-network "goerli_rpc" {:db {:networks/current-network "goerli_rpc"
:multiaccount {:custom-bootnodes-enabled? :profile/profile {:custom-bootnodes-enabled?
{"mainnnet_rpc" true}}}})))))) {"mainnnet_rpc" true}}}}))))))
(deftest delete-bootnode (deftest delete-bootnode
(testing "non existing bootnode" (testing "non existing bootnode"
(let [cofx {:db {:networks/current-network "mainnet_rpc" (let [cofx {:db {:networks/current-network "mainnet_rpc"
:multiaccount {:custom-bootnodes :profile/profile {:custom-bootnodes
{"mainnet_rpc" {"mainnet_rpc"
{"a" {:id "a" {"a" {:id "a"
:name "name" :name "name"
@ -165,7 +165,7 @@
(is (model/fetch actual "a"))))) (is (model/fetch actual "a")))))
(testing "existing bootnode" (testing "existing bootnode"
(let [cofx {:db {:networks/current-network "mainnet_rpc" (let [cofx {:db {:networks/current-network "mainnet_rpc"
:multiaccount {:custom-bootnodes :profile/profile {:custom-bootnodes
{"mainnet_rpc" {"mainnet_rpc"
{"a" {:id "a" {"a" {:id "a"
:name "name" :name "name"

View File

@ -385,7 +385,7 @@
(rf/defn web3-send-async (rf/defn web3-send-async
[cofx dapp-name {:keys [method params id] :as payload} message-id] [cofx dapp-name {:keys [method params id] :as payload} message-id]
(let [message? (web3-sign-message? method) (let [message? (web3-sign-message? method)
dapps-address (get-in cofx [:db :multiaccount :dapps-address]) dapps-address (get-in cofx [:db :profile/profile :dapps-address])
typed? (and (not= constants/web3-personal-sign method) typed? (and (not= constants/web3-personal-sign method)
(not= constants/web3-eth-sign method))] (not= constants/web3-eth-sign method))]
(if (or message? (= constants/web3-send-transaction method)) (if (or message? (= constants/web3-send-transaction method))

View File

@ -42,7 +42,7 @@
(defn get-permission-data (defn get-permission-data
[cofx allowed-permission] [cofx allowed-permission]
(let [multiaccount (get-in cofx [:db :multiaccount])] (let [multiaccount (get-in cofx [:db :profile/profile])]
(get {constants/dapp-permission-contact-code (:public-key multiaccount) (get {constants/dapp-permission-contact-code (:public-key multiaccount)
constants/dapp-permission-web3 [(:dapps-address multiaccount)]} constants/dapp-permission-web3 [(:dapps-address multiaccount)]}
allowed-permission))) allowed-permission)))

View File

@ -9,7 +9,7 @@
(let [dapp-name "test.com" (let [dapp-name "test.com"
dapp-name2 "test2.org" dapp-name2 "test2.org"
cofx {:db (assoc-in (:db (browser/open-url {:db {}} dapp-name)) cofx {:db (assoc-in (:db (browser/open-url {:db {}} dapp-name))
[:multiaccount :public-key] [:profile/profile :public-key]
"public-key")} "public-key")}
dapp-id (core.tests/get-dapp-id cofx dapp-name)] dapp-id (core.tests/get-dapp-id cofx dapp-name)]
(testing "dapps permissions are initialized" (testing "dapps permissions are initialized"

View File

@ -148,7 +148,7 @@
(when-not (string/blank? input-text) (when-not (string/blank? input-text)
(let [{:keys [message-id]} (let [{:keys [message-id]}
(get-in db [:chat/inputs current-chat-id :metadata :responding-to-message]) (get-in db [:chat/inputs current-chat-id :metadata :responding-to-message])
preferred-name (get-in db [:multiaccount :preferred-name]) preferred-name (get-in db [:profile/profile :preferred-name])
emoji? (message-content/emoji-only-content? {:text input-text emoji? (message-content/emoji-only-content? {:text input-text
:response-to message-id})] :response-to message-id})]
{:chat-id current-chat-id {:chat-id current-chat-id

View File

@ -83,7 +83,7 @@
[{db :db} chat-id] [{db :db} chat-id]
{:db (mark-chat-all-read db chat-id) {:db (mark-chat-all-read db chat-id)
:clear-message-notifications [[chat-id] :clear-message-notifications [[chat-id]
(get-in db [:multiaccount :remote-push-notifications-enabled?])] (get-in db [:profile/profile :remote-push-notifications-enabled?])]
:json-rpc/call [{:method "wakuext_markAllRead" :json-rpc/call [{:method "wakuext_markAllRead"
:params [chat-id] :params [chat-id]
:on-success #(re-frame/dispatch [::mark-all-read-successful])}]}) :on-success #(re-frame/dispatch [::mark-all-read-successful])}]})
@ -94,7 +94,7 @@
(let [community-chat-ids (map #(str community-id %) (let [community-chat-ids (map #(str community-id %)
(keys (get-in db [:communities community-id :chats])))] (keys (get-in db [:communities community-id :chats])))]
{:clear-message-notifications [community-chat-ids {:clear-message-notifications [community-chat-ids
(get-in db [:multiaccount :remote-push-notifications-enabled?])] (get-in db [:profile/profile :remote-push-notifications-enabled?])]
:json-rpc/call [{:method "wakuext_markAllReadInCommunity" :json-rpc/call [{:method "wakuext_markAllReadInCommunity"
:params [community-id] :params [community-id]
:on-success #(re-frame/dispatch :on-success #(re-frame/dispatch

View File

@ -9,7 +9,7 @@
{:db (assoc db {:db (assoc db
:commands/select-account :commands/select-account
{:message message {:message message
:from (ethereum/get-default-account (:multiaccount/accounts db))}) :from (ethereum/get-default-account (:profile/wallet-accounts db))})
:show-select-acc-sheet nil}) :show-select-acc-sheet nil})
(rf/defn set-selected-account (rf/defn set-selected-account

View File

@ -102,7 +102,7 @@
(rf/defn handle-requests-to-join (rf/defn handle-requests-to-join
[{:keys [db]} requests] [{:keys [db]} requests]
(let [my-public-key (get-in db [:multiaccount :public-key])] (let [my-public-key (get-in db [:profile/profile :public-key])]
{:db (reduce (fn [db {:keys [public-key] :as request}] {:db (reduce (fn [db {:keys [public-key] :as request}]
(let [my-request? (= my-public-key public-key)] (let [my-request? (= my-public-key public-key)]
(if my-request? (if my-request?
@ -278,7 +278,7 @@
(let [community-chat-ids (map #(str community-id %) (let [community-chat-ids (map #(str community-id %)
(keys (get-in db [:communities community-id :chats])))] (keys (get-in db [:communities community-id :chats])))]
{:clear-message-notifications [community-chat-ids {:clear-message-notifications [community-chat-ids
(get-in db [:multiaccount :remote-push-notifications-enabled?])] (get-in db [:profile/profile :remote-push-notifications-enabled?])]
:dispatch [:shell/close-switcher-card community-id] :dispatch [:shell/close-switcher-card community-id]
:json-rpc/call [{:method "wakuext_leaveCommunity" :json-rpc/call [{:method "wakuext_leaveCommunity"
:params [community-id] :params [community-id]
@ -795,14 +795,14 @@
(rf/defn store-category-state (rf/defn store-category-state
{:events [::store-category-state]} {:events [::store-category-state]}
[{:keys [db]} community-id category-id state-open?] [{:keys [db]} community-id category-id state-open?]
(let [public-key (get-in db [:multiaccount :public-key]) (let [public-key (get-in db [:profile/profile :public-key])
hash (category-hash public-key community-id category-id)] hash (category-hash public-key community-id category-id)]
{::async-storage/set! {hash state-open?}})) {::async-storage/set! {hash state-open?}}))
(rf/defn update-category-states-in-db (rf/defn update-category-states-in-db
{:events [::category-states-loaded]} {:events [::category-states-loaded]}
[{:keys [db]} community-id hashes states] [{:keys [db]} community-id hashes states]
(let [public-key (get-in db [:multiaccount :public-key]) (let [public-key (get-in db [:profile/profile :public-key])
categories-old (get-in db [:communities community-id :categories]) categories-old (get-in db [:communities community-id :categories])
categories (reduce (fn [acc [category-id category]] categories (reduce (fn [acc [category-id category]]
(let [hash (get hashes category-id) (let [hash (get hashes category-id)
@ -816,7 +816,7 @@
(rf/defn load-category-states (rf/defn load-category-states
{:events [:communities/load-category-states]} {:events [:communities/load-category-states]}
[{:keys [db]} community-id] [{:keys [db]} community-id]
(let [public-key (get-in db [:multiaccount :public-key]) (let [public-key (get-in db [:profile/profile :public-key])
categories (get-in db [:communities community-id :categories]) categories (get-in db [:communities community-id :categories])
{:keys [keys hashes]} (reduce (fn [acc category] {:keys [keys hashes]} (reduce (fn [acc category]
(let [category-id (get category 0) (let [category-id (get category 0)

View File

@ -49,7 +49,7 @@
(assoc-in [:contacts/contacts public-key :added?] false)) (assoc-in [:contacts/contacts public-key :added?] false))
:dispatch [:shell/close-switcher-card public-key] :dispatch [:shell/close-switcher-card public-key]
:clear-message-notifications :clear-message-notifications
[[public-key] (get-in db [:multiaccount :remote-push-notifications-enabled?])]} [[public-key] (get-in db [:profile/profile :remote-push-notifications-enabled?])]}
(activity-center/notifications-fetch-unread-count) (activity-center/notifications-fetch-unread-count)
fxs))) fxs)))

View File

@ -5,7 +5,7 @@
(defn get-currency (defn get-currency
[db] [db]
(get-in db [:multiaccount :currency] :usd)) (get-in db [:profile/profile :currency] :usd))
(rf/defn set-currency (rf/defn set-currency
{:events [:wallet.settings.ui/currency-selected]} {:events [:wallet.settings.ui/currency-selected]}

View File

@ -3,16 +3,18 @@
[status-im.currency.core :as models])) [status-im.currency.core :as models]))
(deftest get-currency (deftest get-currency
(is (= :usd (models/get-currency {:multiaccount {:currency :usd}}))) (is (= :usd (models/get-currency {:profile/profile {:currency :usd}})))
(is (= :usd (models/get-currency {:multiaccount {:not-empty "would throw an error if was empty"}}))) (is (= :usd (models/get-currency {:profile/profile {:not-empty "would throw an error if was empty"}})))
(is (= :aud (models/get-currency {:multiaccount {:currency :aud}})))) (is (= :aud (models/get-currency {:profile/profile {:currency :aud}}))))
(deftest set-currency (deftest set-currency
(let [cofx (models/set-currency {:db {:multiaccount {:not-empty "would throw an error if was empty"}}} (let [cofx (models/set-currency {:db {:profile/profile {:not-empty
"would throw an error if was empty"}}}
:usd)] :usd)]
(is (= :usd (get-in cofx [:db :multiaccount :currency])))) (is (= :usd (get-in cofx [:db :profile/profile :currency]))))
(is (is
(= :jpy (= :jpy
(get-in (models/set-currency {:db {:multiaccount {:not-empty "would throw an error if was empty"}}} (get-in (models/set-currency {:db {:profile/profile {:not-empty
"would throw an error if was empty"}}}
:jpy) :jpy)
[:db :multiaccount :currency])))) [:db :profile/profile :currency]))))

View File

@ -83,7 +83,7 @@
{:events [::save-username]} {:events [::save-username]}
[{:keys [db] :as cofx} custom-domain? username redirectToSummary] [{:keys [db] :as cofx} custom-domain? username redirectToSummary]
(let [name (fullname custom-domain? username) (let [name (fullname custom-domain? username)
names (get-in db [:multiaccount :usernames] []) names (get-in db [:profile/profile :usernames] [])
new-names (conj names name)] new-names (conj names name)]
(rf/merge cofx (rf/merge cofx
(multiaccounts.update/multiaccount-update (multiaccounts.update/multiaccount-update
@ -102,7 +102,7 @@
[{:keys [db]}] [{:keys [db]}]
(let [{:keys [username address custom-domain?]} (:ens/registration db) (let [{:keys [username address custom-domain?]} (:ens/registration db)
address (or address (ethereum/default-address db)) address (or address (ethereum/default-address db))
{:keys [public-key]} (:multiaccount db) {:keys [public-key]} (:profile/profile db)
chain-id (ethereum/chain-id db) chain-id (ethereum/chain-id db)
username (fullname custom-domain? username)] username (fullname custom-domain? username)]
(ens/set-pub-key-prepare-tx (ens/set-pub-key-prepare-tx
@ -169,7 +169,7 @@
[{:keys [db]} address] [{:keys [db]} address]
(let [{:keys [username]} (let [{:keys [username]}
(:ens/registration db) (:ens/registration db)
{:keys [public-key]} (:multiaccount db) {:keys [public-key]} (:profile/profile db)
chain-id (ethereum/chain-id db)] chain-id (ethereum/chain-id db)]
(ens/register-prepare-tx (ens/register-prepare-tx
chain-id chain-id
@ -211,7 +211,7 @@
{:events [::set-username-candidate]} {:events [::set-username-candidate]}
[{:keys [db]} username] [{:keys [db]} username]
(let [{:keys [custom-domain?]} (:ens/registration db) (let [{:keys [custom-domain?]} (:ens/registration db)
usernames (into #{} (get-in db [:multiaccount :usernames])) usernames (into #{} (get-in db [:profile/profile :usernames]))
state (state custom-domain? username usernames)] state (state custom-domain? username usernames)]
(reset! resolve-last-id (random/id)) (reset! resolve-last-id (random/id))
(merge (merge
@ -220,10 +220,10 @@
:username username :username username
:state state)} :state state)}
(when (= state :searching) (when (= state :searching)
(let [{:keys [multiaccount]} db (let [{:profile/keys [profile]} db
{:keys [public-key]} multiaccount {:keys [public-key]} profile
addresses (ethereum/addresses-without-watch db) addresses (ethereum/addresses-without-watch db)
chain-id (ethereum/chain-id db)] chain-id (ethereum/chain-id db)]
{::resolve-owner [chain-id {::resolve-owner [chain-id
(fullname custom-domain? username) (fullname custom-domain? username)
#(on-resolve-owner #(on-resolve-owner
@ -323,8 +323,8 @@
(rf/defn remove-username (rf/defn remove-username
{:events [::remove-username]} {:events [::remove-username]}
[{:keys [db] :as cofx} name] [{:keys [db] :as cofx} name]
(let [names (get-in db [:multiaccount :usernames] []) (let [names (get-in db [:profile/profile :usernames] [])
preferred-name (get-in db [:multiaccount :preferred-name]) preferred-name (get-in db [:profile/profile :preferred-name])
new-names (remove #(= name %) names)] new-names (remove #(= name %) names)]
(rf/merge cofx (rf/merge cofx
(multiaccounts.update/multiaccount-update (multiaccounts.update/multiaccount-update

View File

@ -82,7 +82,7 @@
(defn current-address (defn current-address
[db] [db]
(-> (get-in db [:multiaccount :address]) (-> (get-in db [:profile/profile :address])
normalized-hex)) normalized-hex))
(defn get-default-account (defn get-default-account
@ -91,7 +91,7 @@
(defn default-address (defn default-address
[db] [db]
(-> (get db :multiaccount/accounts) (-> (get db :profile/wallet-accounts)
get-default-account get-default-account
:address)) :address))
@ -99,7 +99,7 @@
[db] [db]
(into #{} (into #{}
(remove #(= (:type %) :watch) (remove #(= (:type %) :watch)
(map #(eip55/address->checksum (:address %)) (get db :multiaccount/accounts))))) (map #(eip55/address->checksum (:address %)) (get db :profile/wallet-accounts)))))
(defn naked-address (defn naked-address
[s] [s]

View File

@ -401,5 +401,5 @@
[{:keys [db]}] [{:keys [db]}]
{:transactions/get-transfers {:transactions/get-transfers
{:chain-tokens (:wallet/all-tokens db) {:chain-tokens (:wallet/all-tokens db)
:addresses (map :address (get db :multiaccount/accounts)) :addresses (map :address (get db :profile/wallet-accounts))
:fetch-more? false}}) :fetch-more? false}})

View File

@ -117,11 +117,11 @@
(rf/defn system-theme-mode-changed (rf/defn system-theme-mode-changed
{:events [:system-theme-mode-changed]} {:events [:system-theme-mode-changed]}
[{:keys [db] :as cofx} _] [{:keys [db] :as cofx} _]
(let [current-theme-type (get-in cofx [:db :multiaccount :appearance])] (let [current-theme-type (get-in cofx [:db :profile/profile :appearance])]
(when (and (multiaccounts.model/logged-in? db) (when (and (multiaccounts.model/logged-in? db)
(= current-theme-type status-im2.constants/theme-type-system)) (= current-theme-type status-im2.constants/theme-type-system))
{:multiaccounts.ui/switch-theme-fx {:multiaccounts.ui/switch-theme-fx
[(get-in db [:multiaccount :appearance]) [(get-in db [:profile/profile :appearance])
(:view-id db) true]}))) (:view-id db) true]})))
(def authentication-options (def authentication-options
@ -146,7 +146,7 @@
[{:keys [db now] :as cofx}] [{:keys [db now] :as cofx}]
(let [new-account? (get db :onboarding-2/new-account?) (let [new-account? (get db :onboarding-2/new-account?)
app-in-background-since (get db :app-in-background-since) app-in-background-since (get db :app-in-background-since)
signed-up? (get-in db [:multiaccount :signed-up?]) signed-up? (get-in db [:profile/profile :signed-up?])
biometric-auth? (= (:auth-method db) "biometric") biometric-auth? (= (:auth-method db) "biometric")
requires-bio-auth (and requires-bio-auth (and
signed-up? signed-up?
@ -202,7 +202,7 @@
(cond (cond
(= :chat view-id) (= :chat view-id)
{::async-storage/set! {:chat-id (get-in cofx [:db :current-chat-id]) {::async-storage/set! {:chat-id (get-in cofx [:db :current-chat-id])
:key-uid (get-in cofx [:db :multiaccount :key-uid])} :key-uid (get-in cofx [:db :profile/profile :key-uid])}
:db (assoc db :screens/was-focused-once? true)} :db (assoc db :screens/was-focused-once? true)}
(= :login view-id) (= :login view-id)
@ -291,7 +291,7 @@
(rf/defn close-information-box (rf/defn close-information-box
{:events [:close-information-box]} {:events [:close-information-box]}
[{:keys [db]} id global?] [{:keys [db]} id global?]
(let [public-key (get-in db [:multiaccount :public-key]) (let [public-key (get-in db [:profile/profile :public-key])
hash (information-box-id-hash id public-key global?)] hash (information-box-id-hash id public-key global?)]
{::async-storage/set! {hash true} {::async-storage/set! {hash true}
:db (assoc-in db [:information-box-states id] true)})) :db (assoc-in db [:information-box-states id] true)}))
@ -310,7 +310,7 @@
(rf/defn load-information-box-states (rf/defn load-information-box-states
{:events [:load-information-box-states]} {:events [:load-information-box-states]}
[{:keys [db]}] [{:keys [db]}]
(let [public-key (get-in db [:multiaccount :public-key]) (let [public-key (get-in db [:profile/profile :public-key])
{:keys [keys hashes]} (reduce (fn [acc {:keys [id global?]}] {:keys [keys hashes]} (reduce (fn [acc {:keys [id global?]}]
(let [hash (information-box-id-hash (let [hash (information-box-id-hash
id id

View File

@ -75,7 +75,7 @@
(rf/defn save (rf/defn save
{:events [:fleet.ui/save-fleet-confirmed]} {:events [:fleet.ui/save-fleet-confirmed]}
[{:keys [db now] :as cofx} fleet] [{:keys [db now] :as cofx} fleet]
(let [old-fleet (get-in db [:multiaccount :fleet])] (let [old-fleet (get-in db [:profile/profile :fleet])]
(when (not= fleet old-fleet) (when (not= fleet old-fleet)
(rf/merge (rf/merge
cofx cofx

View File

@ -12,7 +12,6 @@
status-im2.navigation.core status-im2.navigation.core
status-im2.subs.root ; so integration tests can run independently status-im2.subs.root ; so integration tests can run independently
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.security.core :as security]
[status-im2.constants :as constants])) [status-im2.constants :as constants]))
(def password "testabc") (def password "testabc")
@ -25,7 +24,7 @@
(defn initialize-app! (defn initialize-app!
[] []
(rf/dispatch [:setup/app-started])) (rf/dispatch [:app-started]))
(defn generate-and-derive-addresses! (defn generate-and-derive-addresses!
[] []
@ -37,20 +36,8 @@
(defn assert-app-initialized (defn assert-app-initialized
[] []
(let [app-state @(rf/subscribe [:app-state]) (let [app-state @(rf/subscribe [:app-state])]
multiaccounts-loading? @(rf/subscribe [:multiaccounts/loading])] (is (= "active" app-state))))
(is (= "active" app-state))
(is (false? multiaccounts-loading?))))
(defn assert-logout
[]
(let [multiaccounts-loading? @(rf/subscribe [:multiaccounts/loading])]
(is multiaccounts-loading?)))
(defn assert-multiaccounts-generated
[]
(let [wizard-state @(rf/subscribe [:intro-wizard/choose-key])]
(is (= 5 (count (:multiaccounts wizard-state))))))
(defn messenger-started (defn messenger-started
[] []
@ -60,10 +47,6 @@
[] []
(is (messenger-started))) (is (messenger-started)))
(defn assert-multiaccount-loaded
[]
(is (false? @(rf/subscribe [:multiaccounts/loading]))))
(defn assert-community-created (defn assert-community-created
[] []
(is (= @(rf/subscribe [:communities/create]) community))) (is (= @(rf/subscribe [:communities/create]) community)))
@ -77,7 +60,7 @@
(defn assert-new-account-created (defn assert-new-account-created
[] []
(is (true? (some #(= (:name %) account-name) (is (true? (some #(= (:name %) account-name)
@(rf/subscribe [:multiaccount/accounts]))))) @(rf/subscribe [:profile/wallet-accounts])))))
(defn logout! (defn logout!
[] []
@ -86,11 +69,11 @@
(deftest initialize-app-test (deftest initialize-app-test
(log/info "========= initialize-app-test ==================") (log/info "========= initialize-app-test ==================")
(rf-test/run-test-async (rf-test/run-test-async
(rf/dispatch [:setup/app-started]) (rf/dispatch [:app-started])
(rf-test/wait-for (rf-test/wait-for
;; use initialize-view because it has the longest avg. time and ;; use initialize-view because it has the longest avg. time and
;; is dispatched by initialize-multiaccounts (last non-view event) ;; is dispatched by initialize-multiaccounts (last non-view event)
[:setup/initialize-view] [:profile/get-profiles-overview-success]
(assert-app-initialized)))) (assert-app-initialized))))
(deftest create-account-test (deftest create-account-test
@ -98,29 +81,26 @@
(rf-test/run-test-async (rf-test/run-test-async
(initialize-app!) ; initialize app (initialize-app!) ; initialize app
(rf-test/wait-for (rf-test/wait-for
[:setup/initialize-view] [:profile/get-profiles-overview-success]
(generate-and-derive-addresses!) ; generate 5 new keys (generate-and-derive-addresses!) ; generate 5 new keys
(rf-test/wait-for (rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] ; wait for the keys [:multiaccount-generate-and-derive-addresses-success] ; wait for the keys
(assert-multiaccount-loaded) ; assert keys are generated
(create-multiaccount!) ; create a multiaccount (create-multiaccount!) ; create a multiaccount
(rf-test/wait-for ; wait for login (rf-test/wait-for ; wait for login
[::transport/messenger-started] [::transport/messenger-started]
(assert-messenger-started) (assert-messenger-started)
(logout!) (logout!)
(rf-test/wait-for [::logout/logout-method] (rf-test/wait-for [::logout/logout-method]))))))
(assert-logout)))))))
(deftest create-community-test (deftest create-community-test
(log/info "====== create-community-test ==================") (log/info "====== create-community-test ==================")
(rf-test/run-test-async (rf-test/run-test-async
(initialize-app!) ; initialize app (initialize-app!) ; initialize app
(rf-test/wait-for (rf-test/wait-for
[:setup/initialize-view] [:profile/get-profiles-overview-success]
(generate-and-derive-addresses!) ; generate 5 new keys (generate-and-derive-addresses!) ; generate 5 new keys
(rf-test/wait-for (rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] [:multiaccount-generate-and-derive-addresses-success]
(assert-multiaccount-loaded) ; assert keys are generated
(create-multiaccount!) ; create a multiaccount (create-multiaccount!) ; create a multiaccount
(rf-test/wait-for ; wait for login (rf-test/wait-for ; wait for login
[::transport/messenger-started] [::transport/messenger-started]
@ -133,19 +113,17 @@
[:status-im.communities.core/community-created] [:status-im.communities.core/community-created]
(assert-community-created) (assert-community-created)
(logout!) (logout!)
(rf-test/wait-for [::logout/logout-method] (rf-test/wait-for [::logout/logout-method])))))))
(assert-logout))))))))
(deftest create-wallet-account-test (deftest create-wallet-account-test
(log/info "====== create-wallet-account-test ==================") (log/info "====== create-wallet-account-test ==================")
(rf-test/run-test-async (rf-test/run-test-async
(initialize-app!) (initialize-app!)
(rf-test/wait-for (rf-test/wait-for
[:setup/initialize-view] [:profile/get-profiles-overview-success]
(generate-and-derive-addresses!) ; generate 5 new keys (generate-and-derive-addresses!) ; generate 5 new keys
(rf-test/wait-for (rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] [:multiaccount-generate-and-derive-addresses-success]
(assert-multiaccount-loaded) ; assert keys are generated
(create-multiaccount!) ; create a multiaccount (create-multiaccount!) ; create a multiaccount
(rf-test/wait-for ; wait for login (rf-test/wait-for ; wait for login
[::transport/messenger-started] [::transport/messenger-started]
@ -155,30 +133,28 @@
[:wallet.accounts/account-stored] [:wallet.accounts/account-stored]
(assert-new-account-created) ; assert account was created (assert-new-account-created) ; assert account was created
(logout!) (logout!)
(rf-test/wait-for [::logout/logout-method] (rf-test/wait-for [::logout/logout-method])))))))
(assert-logout))))))))
(deftest back-up-seed-phrase-test (deftest back-up-seed-phrase-test
(log/info "========= back-up-seed-phrase-test ==================") (log/info "========= back-up-seed-phrase-test ==================")
(rf-test/run-test-async (rf-test/run-test-async
(initialize-app!) (initialize-app!)
(rf-test/wait-for (rf-test/wait-for
[:setup/initialize-view] [:profile/get-profiles-overview-success]
(generate-and-derive-addresses!) (generate-and-derive-addresses!)
(rf-test/wait-for (rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] [:multiaccount-generate-and-derive-addresses-success]
(assert-multiaccount-loaded)
(create-multiaccount!) (create-multiaccount!)
(rf-test/wait-for (rf-test/wait-for
[::transport/messenger-started] [::transport/messenger-started]
(assert-messenger-started) (assert-messenger-started)
(rf/dispatch-sync [:set-in [:my-profile/seed :step] :12-words]) ; display seed phrase to user (rf/dispatch-sync [:set-in [:my-profile/seed :step] :12-words]) ; display seed phrase to user
(rf/dispatch-sync [:my-profile/enter-two-random-words]) ; begin prompting user for seed words (rf/dispatch-sync [:my-profile/enter-two-random-words]) ; begin prompting user for seed words
(let [ma @(rf/subscribe [:multiaccount]) (let [{:keys [mnemonic]} @(rf/subscribe [:profile/profile])
seed @(rf/subscribe [:my-profile/seed]) seed @(rf/subscribe [:my-profile/seed])
word1 (second (:first-word seed)) word1 (second (:first-word seed))
word2 (second (:second-word seed))] word2 (second (:second-word seed))]
(is (= 12 (count (string/split (:mnemonic ma) #" ")))) ; assert 12-word seed phrase (is (= 12 (count (string/split mnemonic #" ")))) ; assert 12-word seed phrase
(rf/dispatch-sync [:set-in [:my-profile/seed :word] word1]) (rf/dispatch-sync [:set-in [:my-profile/seed :word] word1])
(rf/dispatch-sync [:my-profile/set-step :second-word]) (rf/dispatch-sync [:my-profile/set-step :second-word])
(rf/dispatch-sync [:set-in [:my-profile/seed :word] word2]) (rf/dispatch-sync [:set-in [:my-profile/seed :word] word2])
@ -188,42 +164,13 @@
[:my-profile/finish-success] [:my-profile/finish-success]
(is (nil? @(rf/subscribe [:mnemonic]))) ; assert seed phrase has been removed (is (nil? @(rf/subscribe [:mnemonic]))) ; assert seed phrase has been removed
(logout!) (logout!)
(rf-test/wait-for [::logout/logout-method] (rf-test/wait-for [::logout/logout-method]))))))))
(assert-logout)))))))))
(def multiaccount-name "Narrow Frail Lemming") (def multiaccount-name "Narrow Frail Lemming")
(def multiaccount-mnemonic (def multiaccount-mnemonic
"tattoo ramp health green tongue universe style vapor become tape lava reason") "tattoo ramp health green tongue universe style vapor become tape lava reason")
(def multiaccount-key-uid "0x694b8229524820a3a00a6e211141561d61b251ad99d6b65daf82a73c9a57697b") (def multiaccount-key-uid "0x694b8229524820a3a00a6e211141561d61b251ad99d6b65daf82a73c9a57697b")
(deftest recover-multiaccount-test
(log/info "========= recover-multiaccount-test ==================")
(rf-test/run-test-async
(initialize-app!)
(rf-test/wait-for
[:setup/initialize-view]
(rf/dispatch-sync [:init-root :onboarding])
(rf/dispatch-sync [:multiaccounts.recover.ui/recover-multiaccount-button-pressed])
(rf/dispatch-sync [:status-im.multiaccounts.recover.core/enter-phrase-pressed])
(rf/dispatch-sync [:multiaccounts.recover/enter-phrase-input-changed
(security/mask-data multiaccount-mnemonic)])
(rf/dispatch [:multiaccounts.recover/enter-phrase-next-pressed])
(rf-test/wait-for
[:status-im.multiaccounts.recover.core/import-multiaccount-success]
(rf/dispatch-sync [:multiaccounts.recover/re-encrypt-pressed])
(rf/dispatch [:multiaccounts.recover/enter-password-next-pressed password])
(rf-test/wait-for
[:status-im.multiaccounts.recover.core/store-multiaccount-success]
(let [multiaccount @(rf/subscribe [:multiaccount])] ; assert multiaccount is recovered
(is (= multiaccount-key-uid (:key-uid multiaccount)))
(is (= multiaccount-name (:name multiaccount))))
(rf-test/wait-for ; wait for login
[::transport/messenger-started]
(assert-messenger-started)
(logout!)
(rf-test/wait-for [::logout/logout-method]
(assert-logout))))))))
(def chat-id (def chat-id
"0x0402905bed83f0bbf993cee8239012ccb1a8bc86907ead834c1e38476a0eda71414eed0e25f525f270592a2eebb01c9119a4ed6429ba114e51f5cb0a28dae1adfd") "0x0402905bed83f0bbf993cee8239012ccb1a8bc86907ead834c1e38476a0eda71414eed0e25f525f270592a2eebb01c9119a4ed6429ba114e51f5cb0a28dae1adfd")
@ -232,11 +179,10 @@
(rf-test/run-test-async (rf-test/run-test-async
(initialize-app!) (initialize-app!)
(rf-test/wait-for (rf-test/wait-for
[:setup/initialize-view] [:profile/get-profiles-overview-success]
(generate-and-derive-addresses!) (generate-and-derive-addresses!)
(rf-test/wait-for (rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] ; wait for the keys [:multiaccount-generate-and-derive-addresses-success] ; wait for the keys
(assert-multiaccount-loaded)
(create-multiaccount!) (create-multiaccount!)
(rf-test/wait-for (rf-test/wait-for
[::transport/messenger-started] [::transport/messenger-started]
@ -247,19 +193,17 @@
(rf/dispatch-sync [:chat/navigate-to-chat chat-id]) (rf/dispatch-sync [:chat/navigate-to-chat chat-id])
(is (= chat-id @(rf/subscribe [:chats/current-chat-id]))) (is (= chat-id @(rf/subscribe [:chats/current-chat-id])))
(logout!) (logout!)
(rf-test/wait-for [::logout/logout-method] (rf-test/wait-for [::logout/logout-method])))))))
(assert-logout))))))))
(deftest delete-chat-test (deftest delete-chat-test
(log/info "========= delete-chat-test ==================") (log/info "========= delete-chat-test ==================")
(rf-test/run-test-async (rf-test/run-test-async
(initialize-app!) (initialize-app!)
(rf-test/wait-for (rf-test/wait-for
[:setup/initialize-view] [:profile/get-profiles-overview-success]
(generate-and-derive-addresses!) (generate-and-derive-addresses!)
(rf-test/wait-for (rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] ; wait for the keys [:multiaccount-generate-and-derive-addresses-success] ; wait for the keys
(assert-multiaccount-loaded)
(create-multiaccount!) (create-multiaccount!)
(rf-test/wait-for (rf-test/wait-for
[::transport/messenger-started] [::transport/messenger-started]
@ -273,19 +217,17 @@
(rf/dispatch-sync [:chat.ui/show-remove-confirmation chat-id]) (rf/dispatch-sync [:chat.ui/show-remove-confirmation chat-id])
(rf/dispatch-sync [:chat.ui/remove-chat chat-id]) (rf/dispatch-sync [:chat.ui/remove-chat chat-id])
(logout!) (logout!)
(rf-test/wait-for [::logout/logout-method] (rf-test/wait-for [::logout/logout-method])))))))
(assert-logout))))))))
(deftest mute-chat-test (deftest mute-chat-test
(log/info "========= mute-chat-test ==================") (log/info "========= mute-chat-test ==================")
(rf-test/run-test-async (rf-test/run-test-async
(initialize-app!) (initialize-app!)
(rf-test/wait-for (rf-test/wait-for
[:setup/initialize-view] [:profile/get-profiles-overview-success]
(generate-and-derive-addresses!) (generate-and-derive-addresses!)
(rf-test/wait-for (rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] ; wait for the keys [:multiaccount-generate-and-derive-addresses-success] ; wait for the keys
(assert-multiaccount-loaded)
(create-multiaccount!) (create-multiaccount!)
(rf-test/wait-for (rf-test/wait-for
[::transport/messenger-started] [::transport/messenger-started]
@ -305,8 +247,7 @@
[:chat/mute-successfully] [:chat/mute-successfully]
(is (not @(rf/subscribe [:chats/muted chat-id]))) (is (not @(rf/subscribe [:chats/muted chat-id])))
(logout!) (logout!)
(rf-test/wait-for [::logout/logout-method] (rf-test/wait-for [::logout/logout-method])))))))))
(assert-logout))))))))))
(deftest add-contact-test (deftest add-contact-test
(log/info "========= add-contact-test ==================") (log/info "========= add-contact-test ==================")
@ -318,11 +259,10 @@
(rf-test/run-test-async (rf-test/run-test-async
(initialize-app!) (initialize-app!)
(rf-test/wait-for (rf-test/wait-for
[:setup/initialize-view] [:profile/get-profiles-overview-success]
(generate-and-derive-addresses!) (generate-and-derive-addresses!)
(rf-test/wait-for (rf-test/wait-for
[:multiaccount-generate-and-derive-addresses-success] [:multiaccount-generate-and-derive-addresses-success]
(assert-multiaccount-loaded)
(create-multiaccount!) (create-multiaccount!)
(rf-test/wait-for (rf-test/wait-for
[::transport/messenger-started] [::transport/messenger-started]
@ -343,5 +283,4 @@
(let [contact @(rf/subscribe [:contacts/current-contact])] (let [contact @(rf/subscribe [:contacts/current-contact])]
(is (= three-words-name (:primary-name contact)))) (is (= three-words-name (:primary-name contact))))
(logout!) (logout!)
(rf-test/wait-for [::logout/logout-method] (rf-test/wait-for [::logout/logout-method]))))))))))
(assert-logout)))))))))))

View File

@ -17,7 +17,7 @@
(rf/merge cofx (rf/merge cofx
{:db (-> db {:db (-> db
(assoc-in [:keycard :creating-backup?] backup-type))} (assoc-in [:keycard :creating-backup?] backup-type))}
(when (:multiaccount db) (when (:profile/profile db)
(navigation/navigate-to :my-profile nil)) (navigation/navigate-to :my-profile nil))
(navigation/navigate-to :seed-phrase nil))) (navigation/navigate-to :seed-phrase nil)))

View File

@ -152,7 +152,7 @@
(if puk-restore? (if puk-restore?
(navigation/navigate-to :multiaccounts nil) (navigation/navigate-to :multiaccounts nil)
(navigation/set-stack-root :profile-stack [:my-profile :keycard-settings])) (navigation/set-stack-root :profile-stack [:my-profile :keycard-settings]))
(when (:multiaccounts/login db) (when (:profile/login db)
(common/get-keys-from-keycard))))) (common/get-keys-from-keycard)))))
(rf/defn on-change-puk-success (rf/defn on-change-puk-success

View File

@ -52,7 +52,7 @@
:init :init
has-master-key? has-master-key?
:multiaccount :profile/profile
(and (not paired?) (and (not paired?)
(zero? free-pairing-slots)) (zero? free-pairing-slots))
@ -68,7 +68,7 @@
(defn find-multiaccount-by-keycard-instance-uid (defn find-multiaccount-by-keycard-instance-uid
[db keycard-instance-uid] [db keycard-instance-uid]
(when keycard-instance-uid (when keycard-instance-uid
(->> (:multiaccounts/multiaccounts db) (->> (:profile/profiles-overview db)
vals vals
(filter #(= keycard-instance-uid (:keycard-instance-uid %))) (filter #(= keycard-instance-uid (:keycard-instance-uid %)))
first))) first)))
@ -76,7 +76,7 @@
(defn find-multiaccount-by-key-uid (defn find-multiaccount-by-key-uid
[db key-uid] [db key-uid]
(when key-uid (when key-uid
(->> (:multiaccounts/multiaccounts db) (->> (:profile/profiles-overview db)
vals vals
(filter #(= (ethereum/normalized-hex key-uid) (:key-uid %))) (filter #(= (ethereum/normalized-hex key-uid) (:key-uid %)))
first))) first)))
@ -86,7 +86,7 @@
(get-pairing db (get-in db [:keycard :application-info :key-uid]))) (get-pairing db (get-in db [:keycard :application-info :key-uid])))
([db key-uid] ([db key-uid]
(or (or
(get-in db [:multiaccount :keycard-pairing]) (get-in db [:profile/profile :keycard-pairing])
(get-in db [:keycard :secrets :pairing]) (get-in db [:keycard :secrets :pairing])
(when key-uid (when key-uid
(:keycard-pairing (:keycard-pairing
@ -324,7 +324,7 @@
(rf/defn get-keys-from-keycard (rf/defn get-keys-from-keycard
[{:keys [db]}] [{:keys [db]}]
(let [key-uid (get-in db [:multiaccounts/login :key-uid]) (let [key-uid (get-in db [:profile/login :key-uid])
pin (string/join (get-in db [:keycard :pin :login]))] pin (string/join (get-in db [:keycard :pin :login]))]
(log/debug "[keycard] get-keys-from-keycard" (log/debug "[keycard] get-keys-from-keycard"
", not empty pin:" ", not empty pin:"
@ -339,11 +339,11 @@
(let [{:keys [key-uid encryption-public-key whisper-private-key] (let [{:keys [key-uid encryption-public-key whisper-private-key]
:as account-data} :as account-data}
(js->clj data :keywordize-keys true) (js->clj data :keywordize-keys true)
{:keys [name]} (get-in db [:multiaccounts/multiaccounts key-uid]) {:keys [name]} (get-in db [:profile/profiles-overview key-uid])
key-uid (get-in db [:keycard :application-info :key-uid]) key-uid (get-in db [:keycard :application-info :key-uid])
multiaccount-data (types/clj->json {:name name multiaccount-data (types/clj->json {:name name
:key-uid key-uid}) :key-uid key-uid})
save-keys? (get-in db [:multiaccounts/login :save-password?])] save-keys? (get-in db [:profile/login :save-password?])]
(rf/merge cofx (rf/merge cofx
{:db {:db
(-> db (-> db
@ -353,13 +353,13 @@
assoc assoc
:puk-retry-counter 5 :puk-retry-counter 5
:pin-retry-counter 3) :pin-retry-counter 3)
(assoc-in [:keycard :multiaccount] (assoc-in [:keycard :profile/profile]
(update account-data :whisper-public-key ethereum/normalized-hex)) (update account-data :whisper-public-key ethereum/normalized-hex))
(assoc-in [:keycard :flow] nil) (assoc-in [:keycard :flow] nil)
(update :multiaccounts/login assoc (update :profile/login assoc
:password encryption-public-key :password encryption-public-key
:key-uid key-uid :key-uid key-uid
:name name)) :name name))
:keycard/login-with-keycard {:multiaccount-data multiaccount-data :keycard/login-with-keycard {:multiaccount-data multiaccount-data
:password encryption-public-key :password encryption-public-key
@ -379,7 +379,7 @@
(hide-connection-sheet) (hide-connection-sheet)
; do not try to display the popover if it is already open or ; do not try to display the popover if it is already open or
; we are in the login interface (which has a different handling) ; we are in the login interface (which has a different handling)
(when-not (or (:multiaccounts/login db) (:popover/popover db)) (when-not (or (:profile/login db) (:popover/popover db))
(popover/show-popover {:view card-status})))) (popover/show-popover {:view card-status}))))
(rf/defn blocked-keycard-popup (rf/defn blocked-keycard-popup
@ -536,7 +536,7 @@
(defn keycard-multiaccount? (defn keycard-multiaccount?
[db] [db]
(boolean (get-in db [:multiaccount :keycard-pairing]))) (boolean (get-in db [:profile/profile :keycard-pairing])))
(rf/defn verify-pin (rf/defn verify-pin
{:events [:keycard/verify-pin]} {:events [:keycard/verify-pin]}

View File

@ -543,7 +543,7 @@
:not-paired :pair :not-paired :pair
:no-pairing-slots :no-slots :no-pairing-slots :no-slots
:init :card-ready :init :card-ready
:multiaccount :import-multiaccount :profile/profile :import-multiaccount
:begin))}) :begin))})
(rf/defn show-no-keycard-applet-alert (rf/defn show-no-keycard-applet-alert
@ -586,7 +586,7 @@
(common/clear-on-card-read) (common/clear-on-card-read)
(load-pin-screen))))) (load-pin-screen)))))
(when (and (= card-state :multiaccount) (when (and (= card-state :profile/profile)
(= flow :import)) (= flow :import))
(if (common/find-multiaccount-by-key-uid db key-uid) (if (common/find-multiaccount-by-key-uid db key-uid)
(multiaccounts.recover/show-existing-multiaccount-alert key-uid) (multiaccounts.recover/show-existing-multiaccount-alert key-uid)
@ -599,7 +599,7 @@
(navigation/navigate-to :keycard-recovery-no-key nil) (navigation/navigate-to :keycard-recovery-no-key nil)
(show-no-keycard-applet-alert))) (show-no-keycard-applet-alert)))
(when (and (= card-state :multiaccount) (when (and (= card-state :profile/profile)
(#{:create :recovery} flow)) (#{:create :recovery} flow))
(show-keycard-has-multiaccount-alert))))) (show-keycard-has-multiaccount-alert)))))

View File

@ -62,7 +62,7 @@
"04f2a432677a1b7c4f1bb22078135821d1d10fce23422297b5c808a545f2b61cdba38ee7394762172fc6ff5e9e28db7535e555efe2812905ffd4e0c25e82a98ae8" "04f2a432677a1b7c4f1bb22078135821d1d10fce23422297b5c808a545f2b61cdba38ee7394762172fc6ff5e9e28db7535e555efe2812905ffd4e0c25e82a98ae8"
"whisper-address" "87df2285f90b71221fab6267b7cb37532fedbb1f" "whisper-address" "87df2285f90b71221fab6267b7cb37532fedbb1f"
"wallet-address" "7e92236392a850980d00d0cd2a4b92886bd7fe7b"}) "wallet-address" "7e92236392a850980d00d0cd2a4b92886bd7fe7b"})
[:db :keycard :multiaccount]) [:db :keycard :profile/profile])
[:whisper-private-key [:whisper-private-key
:whisper-public-key :whisper-public-key
:encryption-public-key :encryption-public-key

View File

@ -11,7 +11,7 @@
(rf/defn delete-card (rf/defn delete-card
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [key-uid (get-in db [:keycard :application-info :key-uid]) (let [key-uid (get-in db [:keycard :application-info :key-uid])
multiaccount-key-uid (get-in db [:multiaccount :key-uid])] multiaccount-key-uid (get-in db [:profile/profile :key-uid])]
(if (and key-uid (if (and key-uid
(= key-uid multiaccount-key-uid)) (= key-uid multiaccount-key-uid))
{:keycard/delete nil} {:keycard/delete nil}

View File

@ -69,9 +69,9 @@
:error nil :error nil
:status nil)) :status nil))
:hide-popover nil}) :hide-popover nil})
(when (:multiaccount db) (when (:profile/profile db)
(navigation/navigate-to :my-profile nil)) (navigation/navigate-to :my-profile nil))
(when-not (:multiaccounts/login db) (when-not (:profile/login db)
(if (:popover/popover db) (if (:popover/popover db)
(navigation/navigate-replace :keycard-pin nil) (navigation/navigate-replace :keycard-pin nil)
(navigation/navigate-to :keycard-pin nil))))) (navigation/navigate-to :keycard-pin nil)))))
@ -94,7 +94,7 @@
key-uid (get-in db [:keycard :application-info :key-uid]) key-uid (get-in db [:keycard :application-info :key-uid])
paired? (get-in db [:keycard :application-info :paired?]) paired? (get-in db [:keycard :application-info :paired?])
multiaccount (get-in db multiaccount (get-in db
[:multiaccounts/multiaccounts (get-in db [:multiaccounts/login :key-uid])]) [:profile/profiles-overview (get-in db [:profile/login :key-uid])])
multiaccount-key-uid (get multiaccount :key-uid) multiaccount-key-uid (get multiaccount :key-uid)
multiaccount-mismatch? (or (nil? multiaccount) multiaccount-mismatch? (or (nil? multiaccount)
(not= multiaccount-key-uid key-uid))] (not= multiaccount-key-uid key-uid))]
@ -151,7 +151,7 @@
:multiaccounts-stack :multiaccounts-stack
[:multiaccounts [:multiaccounts
:keycard-login-pin]) :keycard-login-pin])
(let [{:keys [name]} (get-in db [:multiaccounts/multiaccounts key-uid]) (let [{:keys [name]} (get-in db [:profile/profiles-overview key-uid])
multiaccount-data (types/clj->json {:name name multiaccount-data (types/clj->json {:name name
:key-uid key-uid}) :key-uid key-uid})
account-data {:key-uid key-uid account-data {:key-uid key-uid
@ -161,14 +161,14 @@
(-> db (-> db
(assoc-in [:keycard :pin :status] nil) (assoc-in [:keycard :pin :status] nil)
(assoc-in [:keycard :pin :login] []) (assoc-in [:keycard :pin :login] [])
(assoc-in [:keycard :multiaccount] (assoc-in [:keycard :profile/profile]
(update account-data :whisper-public-key ethereum/normalized-hex)) (update account-data :whisper-public-key ethereum/normalized-hex))
(assoc-in [:keycard :flow] nil) (assoc-in [:keycard :flow] nil)
(update :multiaccounts/login assoc (update :profile/login assoc
:password encryption-public-key :password encryption-public-key
:key-uid key-uid :key-uid key-uid
:name name :name name
:save-password? true)) :save-password? true))
:keycard/login-with-keycard :keycard/login-with-keycard
{:multiaccount-data multiaccount-data {:multiaccount-data multiaccount-data
:key-uid key-uid :key-uid key-uid

View File

@ -134,7 +134,7 @@
(rf/defn intro-wizard (rf/defn intro-wizard
{:events [:multiaccounts.create.ui/intro-wizard]} {:events [:multiaccounts.create.ui/intro-wizard]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [accs (get db :multiaccounts/multiaccounts)] (let [accs (get db :profile/profiles-overview)]
(rf/merge cofx (rf/merge cofx
{:db (-> db {:db (-> db
(update :keycard dissoc :flow) (update :keycard dissoc :flow)
@ -157,7 +157,7 @@
:interceptors [(re-frame/inject-cofx :random-guid-generator) :interceptors [(re-frame/inject-cofx :random-guid-generator)
(re-frame/inject-cofx ::multiaccounts.create/get-signing-phrase)]} (re-frame/inject-cofx ::multiaccounts.create/get-signing-phrase)]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [{{:keys [multiaccount secrets flow]} :keycard} db (let [{{:keys [secrets flow] :profile/keys [profile]} :keycard} db
{:keys [address {:keys [address
name name
public-key public-key
@ -172,7 +172,7 @@
instance-uid instance-uid
key-uid key-uid
recovered]} recovered]}
multiaccount profile
{:keys [pairing paired-on]} secrets {:keys [pairing paired-on]} secrets
{:keys [name]} {:keys [name]}
(if (nil? name) (if (nil? name)
@ -238,7 +238,7 @@
(multiaccounts.model/logged-in? db) (multiaccounts.model/logged-in? db)
(navigation/set-stack-root :profile-stack [:my-profile :keycard-settings]) (navigation/set-stack-root :profile-stack [:my-profile :keycard-settings])
(:multiaccounts/login db) (:profile/login db)
(return-to-keycard-login) (return-to-keycard-login)
:else :else
@ -263,9 +263,9 @@
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [pairing (get-in db [:keycard :secrets :pairing]) (let [pairing (get-in db [:keycard :secrets :pairing])
paired-on (get-in db [:keycard :secrets :paired-on]) paired-on (get-in db [:keycard :secrets :paired-on])
instance-uid (get-in db [:keycard :multiaccount :instance-uid]) instance-uid (get-in db [:keycard :profile/profile :instance-uid])
account (-> db account (-> db
:multiaccounts/login :profile/login
(assoc :keycard-pairing pairing) (assoc :keycard-pairing pairing)
(assoc :save-password? false)) (assoc :save-password? false))
key-uid (-> account :key-uid) key-uid (-> account :key-uid)
@ -275,14 +275,15 @@
password (ethereum/sha3 (security/safe-unmask-data (get-in db password (ethereum/sha3 (security/safe-unmask-data (get-in db
[:keycard [:keycard
:migration-password]))) :migration-password])))
encryption-pass (get-in db [:keycard :multiaccount :encryption-public-key]) encryption-pass (get-in db [:keycard :profile/profile :encryption-public-key])
login-params {:key-uid key-uid login-params {:key-uid key-uid
:multiaccount-data (types/clj->json account) :multiaccount-data (types/clj->json account)
:password encryption-pass :password encryption-pass
:chat-key (get-in db [:keycard :multiaccount :whisper-private-key])}] :chat-key (get-in db
[:keycard :profile/profile :whisper-private-key])}]
{:db (-> db {:db (-> db
(assoc-in [:multiaccounts/multiaccounts key-uid :keycard-pairing] pairing) (assoc-in [:profile/profiles-overview key-uid :keycard-pairing] pairing)
(assoc :multiaccounts/login account) (assoc :profile/login account)
(assoc :auth-method keychain/auth-method-none) (assoc :auth-method keychain/auth-method-none)
(update :keycard dissoc :flow :migration-password) (update :keycard dissoc :flow :migration-password)
(dissoc :recovered-account?)) (dissoc :recovered-account?))
@ -290,7 +291,7 @@
(rf/defn delete-multiaccount (rf/defn delete-multiaccount
[{:keys [db]}] [{:keys [db]}]
(let [key-uid (get-in db [:multiaccounts/login :key-uid])] (let [key-uid (get-in db [:profile/login :key-uid])]
{:keycard/delete-multiaccount-before-migration {:keycard/delete-multiaccount-before-migration
{:key-uid key-uid {:key-uid key-uid
:on-error #(re-frame/dispatch [::delete-multiaccount-error %]) :on-error #(re-frame/dispatch [::delete-multiaccount-error %])
@ -313,7 +314,7 @@
cofx cofx
{:db (-> db {:db (-> db
(assoc-in (assoc-in
[:keycard :multiaccount] [:keycard :profile/profile]
(-> account-data (-> account-data
(update :address ethereum/normalized-hex) (update :address ethereum/normalized-hex)
(update :whisper-address ethereum/normalized-hex) (update :whisper-address ethereum/normalized-hex)
@ -323,7 +324,7 @@
(update :whisper-public-key ethereum/normalized-hex) (update :whisper-public-key ethereum/normalized-hex)
(update :wallet-public-key ethereum/normalized-hex) (update :wallet-public-key ethereum/normalized-hex)
(update :wallet-root-public-key ethereum/normalized-hex) (update :wallet-root-public-key ethereum/normalized-hex)
(update :instance-uid #(get-in db [:keycard :multiaccount :instance-uid] %)))) (update :instance-uid #(get-in db [:keycard :profile/profile :instance-uid] %))))
(assoc-in [:keycard :multiaccount-wallet-address] (:wallet-address account-data)) (assoc-in [:keycard :multiaccount-wallet-address] (:wallet-address account-data))
(assoc-in [:keycard :multiaccount-whisper-public-key] (:whisper-public-key account-data)) (assoc-in [:keycard :multiaccount-whisper-public-key] (:whisper-public-key account-data))
(assoc-in [:keycard :pin :status] nil) (assoc-in [:keycard :pin :status] nil)
@ -362,7 +363,7 @@
pin (common/vector->string (get-in db [:keycard :pin :import-multiaccount]))] pin (common/vector->string (get-in db [:keycard :pin :import-multiaccount]))]
(rf/merge cofx (rf/merge cofx
{:db (-> db {:db (-> db
(assoc-in [:keycard :multiaccount :instance-uid] instance-uid) (assoc-in [:keycard :profile/profile :instance-uid] instance-uid)
(assoc-in [:keycard :pin :status] :verifying) (assoc-in [:keycard :pin :status] :verifying)
(assoc-in [:keycard :secrets] (assoc-in [:keycard :secrets]
{:pairing pairing' {:pairing pairing'
@ -387,7 +388,7 @@
(rf/merge (rf/merge
cofx cofx
{:db (update-in db {:db (update-in db
[:keycard :multiaccount] [:keycard :profile/profile]
(fn [multiacc] (fn [multiacc]
(assoc multiacc (assoc multiacc
:recovered (get db :recovered-account?) :recovered (get db :recovered-account?)

View File

@ -12,7 +12,7 @@
{:events [:keycard/sign]} {:events [:keycard/sign]}
[{:keys [db] :as cofx} hash on-success] [{:keys [db] :as cofx} hash on-success]
(let [card-connected? (get-in db [:keycard :card-connected?]) (let [card-connected? (get-in db [:keycard :card-connected?])
key-uid (get-in db [:multiaccount :key-uid]) key-uid (get-in db [:profile/profile :key-uid])
keycard-key-uid (get-in db [:keycard :application-info :key-uid]) keycard-key-uid (get-in db [:keycard :application-info :key-uid])
keycard-pin-retries (get-in db [:keycard :application-info :pin-retry-counter]) keycard-pin-retries (get-in db [:keycard :application-info :pin-retry-counter])
keycard-match? (= key-uid keycard-key-uid) keycard-match? (= key-uid keycard-key-uid)
@ -28,7 +28,7 @@
(when (ethereum/address= from address) (when (ethereum/address= from address)
(reduced path))) (reduced path)))
nil nil
(:multiaccount/accounts db))] (:profile/wallet-accounts db))]
(cond (cond
(not keycard-match?) (not keycard-match?)
(common/show-wrong-keycard-alert cofx) (common/show-wrong-keycard-alert cofx)

View File

@ -44,7 +44,7 @@
:initialized? true :initialized? true
:pin-retry-counter 3 :pin-retry-counter 3
:puk-retry-counter 5 :puk-retry-counter 5
:key-uid (get-in @re-frame.db/app-db [:multiaccounts/login :key-uid])}) :key-uid (get-in @re-frame.db/app-db [:profile/login :key-uid])})
(swap! state assoc :pin default-pin :puk default-puk :password kk1-password) (swap! state assoc :pin default-pin :puk default-puk :password kk1-password)
(connect-card)) (connect-card))
@ -389,11 +389,11 @@
pin pin
on-failure on-failure
#(let [{:keys [key-uid wallet-root-address]} #(let [{:keys [key-uid wallet-root-address]}
(get @re-frame.db/app-db :multiaccount) (get @re-frame.db/app-db :profile/profile)
accounts (get @re-frame.db/app-db :multiaccount/accounts) accounts (get @re-frame.db/app-db :profile/wallet-accounts)
hashed-password account-password hashed-password account-password
path-num (inc (get-in @re-frame.db/app-db path-num (inc (get-in @re-frame.db/app-db
[:multiaccount :latest-derived-path])) [:profile/profile :latest-derived-path]))
path (str "m/" path-num)] path (str "m/" path-num)]
(native-module/multiaccount-load-account (native-module/multiaccount-load-account
wallet-root-address wallet-root-address
@ -460,8 +460,8 @@
(when (= path (:path acc)) (when (= path (:path acc))
(reduced address))) (reduced address)))
nil nil
(:multiaccount/accounts @re-frame.db/app-db)) (:profile/wallet-accounts @re-frame.db/app-db))
(-> (:multiaccount/accounts @re-frame.db/app-db) (-> (:profile/wallet-accounts @re-frame.db/app-db)
first first
:address)) :address))
password account-password] password account-password]

View File

@ -119,13 +119,13 @@
(defn handle-account-removal (defn handle-account-removal
[{:keys [db] :as cofx} keys-removed-from-card?] [{:keys [db] :as cofx} keys-removed-from-card?]
(let [key-uid (get-in db [:multiaccount :key-uid]) (let [key-uid (get-in db [:profile/profile :key-uid])
instance-uid (get-in db [:keycard :application-info :instance-uid]) instance-uid (get-in db [:keycard :application-info :instance-uid])
pairings (get-in db [:keycard :pairings])] pairings (get-in db [:keycard :pairings])]
(rf/merge (rf/merge
cofx cofx
{:db (-> db {:db (-> db
(update :multiaccounts/multiaccounts dissoc key-uid) (update :profile/profiles-overview dissoc key-uid)
(assoc-in [:keycard :secrets] nil) (assoc-in [:keycard :secrets] nil)
(update-in [:keycard :pairings] (update-in [:keycard :pairings]
dissoc dissoc

View File

@ -34,7 +34,7 @@
(rf/defn generate-new-keycard-account (rf/defn generate-new-keycard-account
{:events [:wallet.accounts/generate-new-keycard-account]} {:events [:wallet.accounts/generate-new-keycard-account]}
[{:keys [db]}] [{:keys [db]}]
(let [path-num (inc (get-in db [:multiaccount :latest-derived-path])) (let [path-num (inc (get-in db [:profile/profile :latest-derived-path]))
path (str constants/path-wallet-root "/" path-num) path (str constants/path-wallet-root "/" path-num)
pin (common/vector->string (get-in db [:keycard :pin :export-key]))] pin (common/vector->string (get-in db [:keycard :pin :export-key]))]
{:db {:db

View File

@ -8,7 +8,7 @@
(rf/defn save-log-level (rf/defn save-log-level
{:events [:log-level.ui/change-log-level-confirmed]} {:events [:log-level.ui/change-log-level-confirmed]}
[{:keys [db now] :as cofx} log-level] [{:keys [db now] :as cofx} log-level]
(let [old-log-level (get-in db [:multiaccount :log-level])] (let [old-log-level (get-in db [:profile/profile :log-level])]
(when (not= old-log-level log-level) (when (not= old-log-level log-level)
(rf/merge cofx (rf/merge cofx
(multiaccounts.update/multiaccount-update (multiaccounts.update/multiaccount-update

View File

@ -36,7 +36,7 @@
(defn preferred-mailserver-id (defn preferred-mailserver-id
[db] [db]
(get-in db [:multiaccount :pinned-mailservers (node/current-fleet-key db)])) (get-in db [:profile/profile :pinned-mailservers (node/current-fleet-key db)]))
(defn connection-error-dismissed (defn connection-error-dismissed
[db] [db]
@ -61,7 +61,7 @@
(defn fetch-use-mailservers? (defn fetch-use-mailservers?
[{:keys [db]}] [{:keys [db]}]
(get-in db [:multiaccount :use-mailservers?])) (get-in db [:profile/profile :use-mailservers?]))
(defonce showing-connection-error-popup? (atom false)) (defonce showing-connection-error-popup? (atom false))
@ -105,7 +105,7 @@
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [current-fleet (node/current-fleet-key db) (let [current-fleet (node/current-fleet-key db)
error-dismissed? (connection-error-dismissed db) error-dismissed? (connection-error-dismissed db)
pinned-mailserver (get-in db [:multiaccount :pinned-mailservers current-fleet])] pinned-mailserver (get-in db [:profile/profile :pinned-mailservers current-fleet])]
(when (and pinned-mailserver (when (and pinned-mailserver
(not error-dismissed?) (not error-dismissed?)
(not @showing-connection-error-popup?)) (not @showing-connection-error-popup?))
@ -266,9 +266,9 @@
(rf/defn upsert (rf/defn upsert
{:events [:mailserver.ui/save-pressed] {:events [:mailserver.ui/save-pressed]
:interceptors [(re-frame/inject-cofx :random-id-generator)]} :interceptors [(re-frame/inject-cofx :random-id-generator)]}
[{{:mailserver.edit/keys [mailserver] :keys [multiaccount] :as db} :db [{{:mailserver.edit/keys [mailserver] :profile/keys [profile] :as db} :db
random-id-generator :random-id-generator random-id-generator :random-id-generator
:as cofx}] :as cofx}]
(let [{:keys [name url id]} mailserver (let [{:keys [name url id]} mailserver
current-fleet (node/current-fleet-key db)] current-fleet (node/current-fleet-key db)]
@ -364,7 +364,7 @@
{:events [:mailserver.ui/connect-confirmed]} {:events [:mailserver.ui/connect-confirmed]}
[{:keys [db] :as cofx} current-fleet mailserver-id] [{:keys [db] :as cofx} current-fleet mailserver-id]
(let [pinned-mailservers (-> db (let [pinned-mailservers (-> db
(get-in [:multiaccount :pinned-mailservers]) (get-in [:profile/profile :pinned-mailservers])
(assoc current-fleet mailserver-id))] (assoc current-fleet mailserver-id))]
(rf/merge cofx (rf/merge cofx
{:db (assoc db :mailserver/current-id mailserver-id) {:db (assoc db :mailserver/current-id mailserver-id)
@ -379,7 +379,7 @@
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [current-fleet (node/current-fleet-key db) (let [current-fleet (node/current-fleet-key db)
pinned-mailservers (-> db pinned-mailservers (-> db
(get-in [:multiaccount :pinned-mailservers]) (get-in [:profile/profile :pinned-mailservers])
(dissoc current-fleet))] (dissoc current-fleet))]
(rf/merge cofx (rf/merge cofx
{:json-rpc/call [{:method "wakuext_setPinnedMailservers" {:json-rpc/call [{:method "wakuext_setPinnedMailservers"
@ -396,7 +396,7 @@
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [current-fleet (node/current-fleet-key db) (let [current-fleet (node/current-fleet-key db)
mailserver-id (:mailserver/current-id db) mailserver-id (:mailserver/current-id db)
pinned-mailservers (get-in db [:multiaccount :pinned-mailservers])] pinned-mailservers (get-in db [:profile/profile :pinned-mailservers])]
(rf/merge cofx (rf/merge cofx
(multiaccounts.update/multiaccount-update (multiaccounts.update/multiaccount-update
:pinned-mailservers :pinned-mailservers

View File

@ -12,7 +12,7 @@
(rf/defn sheet-defaults (rf/defn sheet-defaults
[{:keys [db]}] [{:keys [db]}]
(let [remember-choice? (get-in db [:multiaccount :remember-syncing-choice?])] (let [remember-choice? (get-in db [:profile/profile :remember-syncing-choice?])]
{:db (assoc db {:db (assoc db
:mobile-network/remember-choice? :mobile-network/remember-choice?
(or (nil? remember-choice?) (or (nil? remember-choice?)
@ -22,7 +22,7 @@
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [initialized? (get db :network-status/initialized?) (let [initialized? (get db :network-status/initialized?)
logged-in? (multiaccounts.model/logged-in? db) logged-in? (multiaccounts.model/logged-in? db)
{:keys [remember-syncing-choice?]} (:multiaccount db)] {:keys [remember-syncing-choice?]} (:profile/profile db)]
(apply (apply
rf/merge rf/merge
cofx cofx
@ -91,13 +91,13 @@
(rf/defn mobile-network-set-syncing (rf/defn mobile-network-set-syncing
{:events [:mobile-network/set-syncing]} {:events [:mobile-network/set-syncing]}
[{:keys [db] :as cofx} syncing?] [{:keys [db] :as cofx} syncing?]
(let [{:keys [remember-syncing-choice?]} (:multiaccount db)] (let [{:keys [remember-syncing-choice?]} (:profile/profile db)]
((apply-settings syncing? remember-syncing-choice?) cofx))) ((apply-settings syncing? remember-syncing-choice?) cofx)))
(rf/defn mobile-network-ask-on-mobile-network? (rf/defn mobile-network-ask-on-mobile-network?
{:events [:mobile-network/ask-on-mobile-network?]} {:events [:mobile-network/ask-on-mobile-network?]}
[{:keys [db] :as cofx} ask?] [{:keys [db] :as cofx} ask?]
(let [{:keys [syncing-on-mobile-network?]} (:multiaccount db)] (let [{:keys [syncing-on-mobile-network?]} (:profile/profile db)]
((apply-settings syncing-on-mobile-network? (not ask?)) cofx))) ((apply-settings syncing-on-mobile-network? (not ask?)) cofx)))
(rf/defn mobile-network-restore-defaults (rf/defn mobile-network-restore-defaults

View File

@ -101,7 +101,7 @@
(.catch #(cb (generate-error-result %)))))) (.catch #(cb (generate-error-result %))))))
(re-frame/reg-fx (re-frame/reg-fx
:get-supported-biometric-auth :biometric/get-supported-biometric-auth
(fn [] (fn []
(let [callback #(re-frame/dispatch [:init.callback/get-supported-biometric-auth-success %])] (let [callback #(re-frame/dispatch [:init.callback/get-supported-biometric-auth-success %])]
;;NOTE: if we can't save user password, we can't support biometrics ;;NOTE: if we can't save user password, we can't support biometrics
@ -149,8 +149,8 @@
(rf/defn update-biometric (rf/defn update-biometric
[{db :db :as cofx} biometric-auth?] [{db :db :as cofx} biometric-auth?]
(let [key-uid (or (get-in db [:multiaccount :key-uid]) (let [key-uid (or (get-in db [:profile/profile :key-uid])
(get-in db [:multiaccounts/login :key-uid]))] (get-in db [:profile/login :key-uid]))]
(rf/merge cofx (rf/merge cofx
(keychain/save-auth-method (keychain/save-auth-method
key-uid key-uid
@ -214,7 +214,7 @@
cofx cofx
{:db (-> db {:db (-> db
(assoc :auth-method keychain/auth-method-none) (assoc :auth-method keychain/auth-method-none)
(assoc-in [:multiaccounts/login :save-password?] false))} (assoc-in [:profile/login :save-password?] false))}
(popover/hide-popover))) (popover/hide-popover)))
(rf/defn setup-done (rf/defn setup-done

View File

@ -120,7 +120,7 @@
(rf/defn switch-preview-privacy-mode-flag (rf/defn switch-preview-privacy-mode-flag
[{:keys [db]}] [{:keys [db]}]
(let [private? (get-in db [:multiaccount :preview-privacy?])] (let [private? (get-in db [:profile/profile :preview-privacy?])]
{::blank-preview-flag-changed private?})) {::blank-preview-flag-changed private?}))
(re-frame/reg-fx (re-frame/reg-fx
@ -153,7 +153,7 @@
{:events [:multiaccounts.ui/switch-theme]} {:events [:multiaccounts.ui/switch-theme]}
[cofx theme view-id] [cofx theme view-id]
(let [theme (or theme (let [theme (or theme
(get-in cofx [:db :multiaccount :appearance]) (get-in cofx [:db :profile/profile :appearance])
constants/theme-type-dark)] constants/theme-type-dark)]
{:multiaccounts.ui/switch-theme-fx [theme view-id false]})) {:multiaccounts.ui/switch-theme-fx [theme view-id false]}))
@ -180,7 +180,7 @@
(rf/defn save-profile-picture (rf/defn save-profile-picture
{:events [::save-profile-picture]} {:events [::save-profile-picture]}
[cofx path ax ay bx by] [cofx path ax ay bx by]
(let [key-uid (get-in cofx [:db :multiaccount :key-uid])] (let [key-uid (get-in cofx [:db :profile/profile :key-uid])]
(rf/merge cofx (rf/merge cofx
{:json-rpc/call [{:method "multiaccounts_storeIdentityImage" {:json-rpc/call [{:method "multiaccounts_storeIdentityImage"
:params [key-uid (clean-path path) ax ay bx by] :params [key-uid (clean-path path) ax ay bx by]
@ -191,7 +191,7 @@
(rf/defn save-profile-picture-from-url (rf/defn save-profile-picture-from-url
{:events [::save-profile-picture-from-url]} {:events [::save-profile-picture-from-url]}
[cofx url] [cofx url]
(let [key-uid (get-in cofx [:db :multiaccount :key-uid])] (let [key-uid (get-in cofx [:db :profile/profile :key-uid])]
(rf/merge cofx (rf/merge cofx
{:json-rpc/call [{:method "multiaccounts_storeIdentityImageFromURL" {:json-rpc/call [{:method "multiaccounts_storeIdentityImageFromURL"
:params [key-uid url] :params [key-uid url]
@ -207,7 +207,7 @@
(rf/defn delete-profile-picture (rf/defn delete-profile-picture
{:events [::delete-profile-picture]} {:events [::delete-profile-picture]}
[cofx name] [cofx name]
(let [key-uid (get-in cofx [:db :multiaccount :key-uid])] (let [key-uid (get-in cofx [:db :profile/profile :key-uid])]
(rf/merge cofx (rf/merge cofx
{:json-rpc/call [{:method "multiaccounts_deleteIdentityImage" {:json-rpc/call [{:method "multiaccounts_deleteIdentityImage"
:params [key-uid] :params [key-uid]
@ -219,7 +219,7 @@
(rf/defn get-profile-picture (rf/defn get-profile-picture
[cofx] [cofx]
(let [key-uid (get-in cofx [:db :multiaccount :key-uid])] (let [key-uid (get-in cofx [:db :profile/profile :key-uid])]
{:json-rpc/call [{:method "multiaccounts_getIdentityImages" {:json-rpc/call [{:method "multiaccounts_getIdentityImages"
:params [key-uid] :params [key-uid]
:on-success #(re-frame/dispatch [::update-local-picture %])}]})) :on-success #(re-frame/dispatch [::update-local-picture %])}]}))

View File

@ -225,13 +225,13 @@
:keycard-pairing keycard-pairing :keycard-pairing keycard-pairing
:keycard-paired-on keycard-paired-on)) :keycard-paired-on keycard-paired-on))
db (assoc db db (assoc db
:multiaccounts/login {:key-uid key-uid :profile/login {:key-uid key-uid
:name name :name name
:password password :password password
:creating? true :creating? true
:processing true} :processing true}
:multiaccount new-multiaccount :profile/profile new-multiaccount
:multiaccount/accounts [wallet-account] :profile/wallet-accounts [wallet-account]
:networks/current-network config/default-network :networks/current-network config/default-network
:networks/networks (data-store.settings/rpc->networks config/default-networks)) :networks/networks (data-store.settings/rpc->networks config/default-networks))
settings (assoc new-multiaccount settings (assoc new-multiaccount

View File

@ -7,7 +7,6 @@
[utils.i18n :as i18n] [utils.i18n :as i18n]
[status-im.keycard.backup-key :as keycard.backup] [status-im.keycard.backup-key :as keycard.backup]
[status-im.keycard.common :as common] [status-im.keycard.common :as common]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.multiaccounts.logout.core :as multiaccounts.logout] [status-im.multiaccounts.logout.core :as multiaccounts.logout]
[status-im.multiaccounts.model :as multiaccounts.model] [status-im.multiaccounts.model :as multiaccounts.model]
[status-im.multiaccounts.recover.core :as multiaccounts.recover] [status-im.multiaccounts.recover.core :as multiaccounts.recover]
@ -29,16 +28,6 @@
:actions-not-logged-in) :actions-not-logged-in)
nil)) nil))
(rf/defn move-keystore-checked
{:events [::move-keystore-checked]}
[{:keys [db] :as cofx} checked?]
{:db (assoc-in db [:multiaccounts/key-storage :move-keystore-checked?] checked?)})
(rf/defn reset-db-checked
{:events [::reset-db-checked]}
[{:keys [db] :as cofx} checked?]
{:db (assoc-in db [:multiaccounts/key-storage :reset-db-checked?] checked?)})
(rf/defn navigate-back (rf/defn navigate-back
{:events [::navigate-back]} {:events [::navigate-back]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
@ -62,18 +51,6 @@
{:db (assoc db :recovered-account? true)} {:db (assoc db :recovered-account? true)}
(navigation/navigate-to :seed-phrase nil))) (navigation/navigate-to :seed-phrase nil)))
(rf/defn seed-phrase-input-changed
{:events [::seed-phrase-input-changed]}
[{:keys [db] :as cofx} masked-seed-phrase]
(let [seed-phrase (security/safe-unmask-data masked-seed-phrase)]
{:db (update db
:multiaccounts/key-storage assoc
:seed-phrase (when seed-phrase
(string/lower-case seed-phrase))
:seed-shape-invalid? (or (empty? seed-phrase)
(not (mnemonic/valid-length? seed-phrase)))
:seed-word-count (mnemonic/words-count seed-phrase))}))
(rf/defn key-uid-seed-mismatch (rf/defn key-uid-seed-mismatch
{:events [::show-seed-key-uid-mismatch-error-popup]} {:events [::show-seed-key-uid-mismatch-error-popup]}
[cofx _] [cofx _]
@ -116,28 +93,20 @@
:error :error
string/blank? string/blank?
not) not)
onboarding? (not (or (:multiaccounts/login db) (:multiaccount db)))] onboarding? (not (or (:profile/login db) (:profile/profile db)))]
(if error? (if error?
(popover/show-popover cofx {:view :custom-seed-phrase}) (popover/show-popover cofx {:view :custom-seed-phrase})
{::validate-seed-against-key-uid {:seed-phrase (-> db :multiaccounts/key-storage :seed-phrase) {::validate-seed-against-key-uid {:seed-phrase (-> db :multiaccounts/key-storage :seed-phrase)
;; Unique key-uid of the account for which we are going to move ;; Unique key-uid of the account for which we are going to move
;; keys ;; keys
:key-uid (or (-> db :multiaccounts/login :key-uid) :key-uid (or (-> db :profile/login :key-uid)
(-> db :multiaccount :key-uid) (-> db :profile/profile :key-uid)
(and onboarding? (and onboarding?
(-> db (-> db
:keycard :keycard
:application-info :application-info
:key-uid)))}}))) :key-uid)))}})))
(rf/defn choose-storage-pressed
{:events [::choose-storage-pressed]}
[{:keys [db] :as cofx}]
(let [{:keys [seed-phrase]} (:multiaccounts/key-storage db)]
{::multiaccounts/validate-mnemonic
[(mnemonic/sanitize-passphrase seed-phrase)
#(re-frame/dispatch [::seed-phrase-validated %])]}))
(rf/defn keycard-storage-pressed (rf/defn keycard-storage-pressed
{:events [::keycard-storage-pressed]} {:events [::keycard-storage-pressed]}
[{:keys [db]} selected?] [{:keys [db]} selected?]
@ -224,7 +193,7 @@ We don't need to take the exact steps, just set the required state and redirect
{:events [::verify-password]} {:events [::verify-password]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(native-module/verify-database-password (native-module/verify-database-password
(get-in db [:multiaccounts/login :key-uid]) (get-in db [:profile/login :key-uid])
(ethereum/sha3 (security/safe-unmask-data (get-in db [:keycard :migration-password]))) (ethereum/sha3 (security/safe-unmask-data (get-in db [:keycard :migration-password])))
#(re-frame/dispatch [::verify-password-result %]))) #(re-frame/dispatch [::verify-password-result %])))

View File

@ -1,31 +1,8 @@
(ns status-im.multiaccounts.key-storage.core-test (ns status-im.multiaccounts.key-storage.core-test
(:require [cljs.test :refer-macros [deftest is testing]] (:require [cljs.test :refer-macros [deftest is testing]]
[clojure.string :as string]
[status-im.multiaccounts.key-storage.core :as models] [status-im.multiaccounts.key-storage.core :as models]
[utils.security.core :as security])) [utils.security.core :as security]))
(deftest move-keystore-checked
(testing "Checks checkbox on-press"
(let [res (models/move-keystore-checked {:db {}} true)]
(is (= true (get-in res [:db :multiaccounts/key-storage :move-keystore-checked?]))))))
(deftest seed-phrase-input-changed
(testing "nil seed phrase shape is invalid"
(let [res (models/seed-phrase-input-changed {:db {}} (security/mask-data nil))]
(is (get-in res [:db :multiaccounts/key-storage :seed-shape-invalid?]))))
(let [sample-phrase "h h h h h h h h h h h H" ;; 12 characters
res (models/seed-phrase-input-changed {:db {}} (security/mask-data sample-phrase))]
(testing "Seed shape for 12 letter seed phrase is valid"
(is (false? (get-in res [:db :multiaccounts/key-storage :seed-shape-invalid?]))))
(testing "Seed words counted correctly"
(is (= 12 (get-in res [:db :multiaccounts/key-storage :seed-word-count]))))
(testing "Seed phrase is lowercased"
(is (= (get-in res [:db :multiaccounts/key-storage :seed-phrase])
(string/lower-case sample-phrase))))))
(def seed-key-uid-pair (def seed-key-uid-pair
{:seed-phrase "rocket mixed rebel affair umbrella legal resemble scene virus park deposit cargo" {:seed-phrase "rocket mixed rebel affair umbrella legal resemble scene virus park deposit cargo"
:key-uid "0x3831d0f22996a65970a214f0a94bfa9a63a21dac235d8dadb91be8e32e7d3ab7"}) :key-uid "0x3831d0f22996a65970a214f0a94bfa9a63a21dac235d8dadb91be8e32e7d3ab7"})

View File

@ -16,7 +16,6 @@
[status-im.ethereum.transactions.core :as transactions] [status-im.ethereum.transactions.core :as transactions]
[status-im.fleet.core :as fleet] [status-im.fleet.core :as fleet]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[status-im.keycard.common :as keycard.common]
[status-im.mobile-sync-settings.core :as mobile-network] [status-im.mobile-sync-settings.core :as mobile-network]
[status-im.multiaccounts.biometric.core :as biometric] [status-im.multiaccounts.biometric.core :as biometric]
[status-im.multiaccounts.core :as multiaccounts] [status-im.multiaccounts.core :as multiaccounts]
@ -46,7 +45,8 @@
[status-im2.common.log :as logging] [status-im2.common.log :as logging]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[status-im2.contexts.shell.jump-to.utils :as shell.utils] [status-im2.contexts.shell.jump-to.utils :as shell.utils]
[utils.security.core :as security])) [utils.security.core :as security]
[status-im.keycard.common :as keycard.common]))
(re-frame/reg-fx (re-frame/reg-fx
::initialize-transactions-management-enabled ::initialize-transactions-management-enabled
@ -146,7 +146,7 @@
(rf/merge (rf/merge
cofx cofx
{:db (assoc db {:db (assoc db
:multiaccount/accounts :profile/wallet-accounts
(rpc->accounts accounts)) (rpc->accounts accounts))
;; NOTE: Local notifications should be enabled only after wallet was started ;; NOTE: Local notifications should be enabled only after wallet was started
::enable-local-notifications nil} ::enable-local-notifications nil}
@ -179,7 +179,7 @@
(rf/defn login-local-paired-user (rf/defn login-local-paired-user
{:events [:multiaccounts.login/local-paired-user]} {:events [:multiaccounts.login/local-paired-user]}
[{:keys [db]}] [{:keys [db]}]
(let [{:keys [key-uid name password]} (get-in db [:syncing :multiaccount])] (let [{:keys [key-uid name password]} (get-in db [:syncing :profile/profile])]
{::login [key-uid {::login [key-uid
(types/clj->json {:name name (types/clj->json {:name name
:key-uid key-uid}) :key-uid key-uid})
@ -188,9 +188,9 @@
(rf/defn login (rf/defn login
{:events [:multiaccounts.login.ui/password-input-submitted]} {:events [:multiaccounts.login.ui/password-input-submitted]}
[{:keys [db]}] [{:keys [db]}]
(let [{:keys [key-uid password name]} (:multiaccounts/login db)] (let [{:keys [key-uid password name]} (:profile/login db)]
{:db (-> db {:db (-> db
(assoc-in [:multiaccounts/login :processing] true) (assoc-in [:profile/login :processing] true)
(dissoc :intro-wizard :recovered-account?) (dissoc :intro-wizard :recovered-account?)
(update :keycard dissoc :flow)) (update :keycard dissoc :flow))
::login [key-uid ::login [key-uid
@ -201,7 +201,7 @@
(rf/defn export-db-submitted (rf/defn export-db-submitted
{:events [:multiaccounts.login.ui/export-db-submitted]} {:events [:multiaccounts.login.ui/export-db-submitted]}
[{:keys [db]}] [{:keys [db]}]
(let [{:keys [key-uid password name]} (:multiaccounts/login db)] (let [{:keys [key-uid password name]} (:profile/login db)]
{::export-db [key-uid {::export-db [key-uid
(types/clj->json {:name name (types/clj->json {:name name
:key-uid key-uid}) :key-uid key-uid})
@ -216,7 +216,7 @@
(rf/defn import-db-submitted (rf/defn import-db-submitted
{:events [:multiaccounts.login.ui/import-db-submitted]} {:events [:multiaccounts.login.ui/import-db-submitted]}
[{:keys [db]}] [{:keys [db]}]
(let [{:keys [key-uid password name]} (:multiaccounts/login db)] (let [{:keys [key-uid password name]} (:profile/login db)]
{::import-db [key-uid {::import-db [key-uid
(types/clj->json {:name name (types/clj->json {:name name
:key-uid key-uid}) :key-uid key-uid})
@ -394,7 +394,7 @@
[{:keys [db] :as cofx} node-config-json] [{:keys [db] :as cofx} node-config-json]
(let [node-config (types/json->clj node-config-json)] (let [node-config (types/json->clj node-config-json)]
{:db (assoc-in db {:db (assoc-in db
[:multiaccount :wakuv2-config] [:profile/profile :wakuv2-config]
(get node-config :WakuV2Config))})) (get node-config :WakuV2Config))}))
(rf/defn get-node-config (rf/defn get-node-config
@ -438,10 +438,10 @@
merged-networks (merge networks config/default-networks-by-id)] merged-networks (merge networks config/default-networks-by-id)]
(rf/merge cofx (rf/merge cofx
{:db (-> db {:db (-> db
(dissoc :multiaccounts/login) (dissoc :profile/login)
(assoc :networks/current-network current-network (assoc :networks/current-network current-network
:networks/networks merged-networks :networks/networks merged-networks
:multiaccount multiaccount))} :profile/profile multiaccount))}
(data-store.chats/fetch-chats-rpc (data-store.chats/fetch-chats-rpc
{:on-success {:on-success
#(do (re-frame/dispatch [:chats-list/load-success %]) #(do (re-frame/dispatch [:chats-list/load-success %])
@ -476,29 +476,29 @@
(rf/defn check-last-chat (rf/defn check-last-chat
{:events [::check-last-chat]} {:events [::check-last-chat]}
[{:keys [db]}] [{:keys [db]}]
{::open-last-chat (get-in db [:multiaccount :key-uid])}) {::open-last-chat (get-in db [:profile/profile :key-uid])})
(rf/defn update-wallet-accounts (rf/defn update-wallet-accounts
[{:keys [db]} accounts] [{:keys [db]} accounts]
(let [existing-accounts (into {} (map #(vector (:address %1) %1) (:multiaccount/accounts db))) (let [existing-accounts (into {} (map #(vector (:address %1) %1) (:profile/wallet-accounts db)))
reduce-fn (fn [existing-accs new-acc] reduce-fn (fn [existing-accs new-acc]
(let [address (:address new-acc)] (let [address (:address new-acc)]
(if (:removed new-acc) (if (:removed new-acc)
(dissoc existing-accs address) (dissoc existing-accs address)
(assoc existing-accs address new-acc)))) (assoc existing-accs address new-acc))))
new-accounts (reduce reduce-fn existing-accounts (rpc->accounts accounts))] new-accounts (reduce reduce-fn existing-accounts (rpc->accounts accounts))]
{:db (assoc db :multiaccount/accounts (vals new-accounts))})) {:db (assoc db :profile/wallet-accounts (vals new-accounts))}))
(rf/defn get-chats-callback (rf/defn get-chats-callback
{:events [::get-chats-callback]} {:events [::get-chats-callback]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [{:networks/keys [current-network networks]} db (let [{:networks/keys [current-network networks]} db
notifications-enabled? (get-in db [:multiaccount :notifications-enabled?]) notifications-enabled? (get-in db [:profile/profile :notifications-enabled?])
current-network-config (get networks current-network) current-network-config (get networks current-network)
network-id (str (get-in networks network-id (str (get-in networks
[current-network :config :NetworkId])) [current-network :config :NetworkId]))
remote-push-notifications-enabled? remote-push-notifications-enabled?
(get-in db [:multiaccount :remote-push-notifications-enabled?])] (get-in db [:profile/profile :remote-push-notifications-enabled?])]
(rf/merge cofx (rf/merge cofx
(cond-> {::eip1559/check-eip1559-activation (cond-> {::eip1559/check-eip1559-activation
{:network-id network-id {:network-id network-id
@ -510,7 +510,7 @@
(fn [accounts tokens custom-tokens favourites] (fn [accounts tokens custom-tokens favourites]
(re-frame/dispatch [::initialize-wallet (re-frame/dispatch [::initialize-wallet
accounts tokens custom-tokens favourites]))] accounts tokens custom-tokens favourites]))]
::open-last-chat (get-in db [:multiaccount :key-uid])} ::open-last-chat (get-in db [:profile/profile :key-uid])}
(or notifications-enabled? remote-push-notifications-enabled?) (or notifications-enabled? remote-push-notifications-enabled?)
(assoc ::notifications/enable remote-push-notifications-enabled?)) (assoc ::notifications/enable remote-push-notifications-enabled?))
(transport/start-messenger) (transport/start-messenger)
@ -555,23 +555,21 @@
(rf/defn create-only-events (rf/defn create-only-events
[{:keys [db] :as cofx} recovered-account?] [{:keys [db] :as cofx} recovered-account?]
(let [{:keys [multiaccount (let [{:profile/keys [profile profiles-overview wallet-accounts]}
:multiaccounts/multiaccounts
:multiaccount/accounts]}
db db
{:keys [creating?]} (:multiaccounts/login db) {:keys [creating?]} (:profile/login db)
first-account? (and creating? first-account? (and creating? (empty? profiles-overview))
(empty? multiaccounts))
tos-accepted? (get db :tos/accepted?) tos-accepted? (get db :tos/accepted?)
{:networks/keys [current-network networks]} db {:networks/keys [current-network networks]} db
network-id (str (get-in networks [current-network :config :NetworkId]))] network-id (str (get-in networks [current-network :config :NetworkId]))]
(shell.utils/change-selected-stack-id :communities-stack true nil) (shell.utils/change-selected-stack-id :communities-stack true nil)
(rf/merge cofx (rf/merge cofx
{:db (-> db {:db (-> db
(dissoc :multiaccounts/login) (dissoc :profile/login)
(assoc :tos/next-root :enable-notifications :chats/loading? false) (assoc :tos/next-root :enable-notifications :chats/loading? false)
(assoc-in [:multiaccount :multiaccounts/first-account] first-account?)) (assoc-in [:profile/profile :multiaccounts/first-account]
::get-tokens [network-id accounts recovered-account?]} first-account?))
::get-tokens [network-id wallet-accounts recovered-account?]}
(finish-keycard-setup) (finish-keycard-setup)
(transport/start-messenger) (transport/start-messenger)
(communities/fetch) (communities/fetch)
@ -579,7 +577,7 @@
{:on-success #(re-frame/dispatch [:chats-list/load-success %])}) {:on-success #(re-frame/dispatch [:chats-list/load-success %])})
(multiaccounts/switch-preview-privacy-mode-flag) (multiaccounts/switch-preview-privacy-mode-flag)
(link-preview/request-link-preview-whitelist) (link-preview/request-link-preview-whitelist)
(logging/set-log-level (:log-level multiaccount)) (logging/set-log-level (:log-level profile))
(navigation/init-root :enable-notifications)))) (navigation/init-root :enable-notifications))))
(defn- keycard-setup? (defn- keycard-setup?
@ -595,7 +593,7 @@
:on-card-read :on-card-read
:card-read-in-progress? :card-read-in-progress?
:pin :pin
:multiaccount) :profile/profile)
(assoc :tos-accept-next-root (assoc :tos-accept-next-root
(if login-only? (if login-only?
:shell-stack :shell-stack
@ -606,9 +604,9 @@
(rf/defn multiaccount-login-success (rf/defn multiaccount-login-success
[{:keys [db now] :as cofx}] [{:keys [db now] :as cofx}]
(let [{:keys [key-uid password save-password? creating?]} (let [{:keys [key-uid password save-password? creating?]}
(:multiaccounts/login db) (:profile/login db)
multiaccounts (:multiaccounts/multiaccounts db) multiaccounts (:profile/profiles-overview db)
recovered-account? (get db :recovered-account?) recovered-account? (get db :recovered-account?)
login-only? (not (or creating? login-only? (not (or creating?
recovered-account? recovered-account?
@ -638,29 +636,12 @@
(login-only-events key-uid password save-password?) (login-only-events key-uid password save-password?)
(create-only-events recovered-account?))))) (create-only-events recovered-account?)))))
;; FIXME(Ferossgp): We should not copy keys as we denormalize the database,
;; this create desync between actual accounts and the one on login causing broken state
;; UPDATE(cammellos): This code is copying over some fields explicitly as some values
;; are alreayd in `multiaccounts/login` and should not be overriden, as they come from
;; the keychain (save-password), this is not very explicit and we should probably
;; make it clearer
(rf/defn open-login
[{:keys [db]} override-multiaccount]
{:db (-> db
(update :multiaccounts/login
merge
override-multiaccount)
(update :multiaccounts/login
dissoc
:error
:password))})
(rf/defn open-login-callback (rf/defn open-login-callback
{:events [:multiaccounts.login.callback/get-user-password-success]} {:events [:multiaccounts.login.callback/get-user-password-success]}
[{:keys [db] :as cofx} password] [{:keys [db] :as cofx} password]
(let [key-uid (get-in db [:multiaccounts/login :key-uid]) (let [key-uid (get-in db [:profile/login :key-uid])
keycard-account? (boolean (get-in db keycard-account? (boolean (get-in db
[:multiaccounts/multiaccounts [:profile/profiles-overview
key-uid key-uid
:keycard-pairing])) :keycard-pairing]))
goto-key-storage? (:goto-key-storage? db)] goto-key-storage? (:goto-key-storage? db)]
@ -668,7 +649,7 @@
(rf/merge (rf/merge
cofx cofx
{:db (update-in db {:db (update-in db
[:multiaccounts/login] [:profile/login]
assoc assoc
:password password :password password
:save-password? true) :save-password? true)
@ -690,7 +671,7 @@
(rf/defn get-credentials (rf/defn get-credentials
[{:keys [db] :as cofx} key-uid] [{:keys [db] :as cofx} key-uid]
(let [keycard-multiaccount? (boolean (get-in db (let [keycard-multiaccount? (boolean (get-in db
[:multiaccounts/multiaccounts key-uid :keycard-pairing]))] [:profile/profiles-overview key-uid :keycard-pairing]))]
(log/debug "[login] get-credentials" (log/debug "[login] get-credentials"
"keycard-multiacc?" "keycard-multiacc?"
keycard-multiaccount?) keycard-multiaccount?)
@ -702,12 +683,8 @@
"Auth method: nil - not supported, \"none\" - not selected, \"password\", \"biometric\", \"biometric-prepare\"" "Auth method: nil - not supported, \"none\" - not selected, \"password\", \"biometric\", \"biometric-prepare\""
{:events [:multiaccounts.login/get-auth-method-success]} {:events [:multiaccounts.login/get-auth-method-success]}
[{:keys [db] :as cofx} auth-method] [{:keys [db] :as cofx} auth-method]
(let [key-uid (get-in db [:multiaccounts/login :key-uid]) (let [key-uid (get-in db [:profile/login :key-uid])
keycard-multiaccount? (boolean (get-in db keycard-profile? (boolean (get-in db [:profile/profiles-overview key-uid :keycard-pairing]))]
[:multiaccounts/multiaccounts key-uid :keycard-pairing]))]
(log/debug "[login] get-auth-method-success"
"auth-method" auth-method
"keycard-multiacc?" keycard-multiaccount?)
(rf/merge (rf/merge
cofx cofx
{:db (assoc db :auth-method auth-method)} {:db (assoc db :auth-method auth-method)}
@ -716,15 +693,14 @@
(biometric/biometric-auth %) (biometric/biometric-auth %)
(= auth-method keychain/auth-method-password) (= auth-method keychain/auth-method-password)
(get-credentials % key-uid) (get-credentials % key-uid)
(and keycard-multiaccount? (and keycard-profile? (get-in db [:keycard :card-connected?]))
(get-in db [:keycard :card-connected?]))
(keycard.common/get-application-info % nil)) (keycard.common/get-application-info % nil))
(open-login-callback nil)))) (open-login-callback nil))))
(rf/defn biometric-auth-done (rf/defn biometric-auth-done
{:events [:biometric-auth-done]} {:events [:biometric-auth-done]}
[{:keys [db] :as cofx} {:keys [bioauth-success bioauth-message bioauth-code]}] [{:keys [db] :as cofx} {:keys [bioauth-success bioauth-message bioauth-code]}]
(let [key-uid (get-in db [:multiaccounts/login :key-uid]) (let [key-uid (get-in db [:profile/login :key-uid])
auth-method (get db :auth-method)] auth-method (get db :auth-method)]
(log/debug "[biometric] biometric-auth-done" (log/debug "[biometric] biometric-auth-done"
"bioauth-success" bioauth-success "bioauth-success" bioauth-success
@ -734,7 +710,7 @@
(get-credentials cofx key-uid) (get-credentials cofx key-uid)
(rf/merge cofx (rf/merge cofx
{:db (assoc-in db {:db (assoc-in db
[:multiaccounts/login :save-password?] [:profile/login :save-password?]
(= auth-method keychain/auth-method-biometric))} (= auth-method keychain/auth-method-biometric))}
(when-not (= auth-method keychain/auth-method-biometric) (when-not (= auth-method keychain/auth-method-biometric)
(keychain/save-auth-method key-uid keychain/auth-method-none)) (keychain/save-auth-method key-uid keychain/auth-method-none))
@ -761,7 +737,7 @@
(and (not save-password?) (and (not save-password?)
bioauth-supported? bioauth-supported?
(= previous-auth-method keychain/auth-method-none))) (= previous-auth-method keychain/auth-method-none)))
(assoc-in [:multiaccounts/login :save-password?] save-password?))} (assoc-in [:profile/login :save-password?] save-password?))}
(when bioauth-supported? (when bioauth-supported?
(if save-password? (if save-password?
(popover/show-popover {:view :secure-with-biometric}) (popover/show-popover {:view :secure-with-biometric})
@ -773,21 +749,6 @@
[_] [_]
{:set-root :shell-stack}) {:set-root :shell-stack})
(rf/defn multiaccount-selected
{:events [:multiaccounts.login.ui/multiaccount-selected]}
[{:keys [db] :as cofx} key-uid]
;; We specifically pass a bunch of fields instead of the whole multiaccount
;; as we want store some fields in multiaccount that are not here
(let [multiaccount (get-in db [:multiaccounts/multiaccounts key-uid])
keycard-multiaccount? (boolean (:keycard-pairing multiaccount))]
(rf/merge
cofx
(merge
{:db (update db :keycard dissoc :application-info)}
(when keycard-multiaccount? {:navigate-to :keycard-login-pin}))
(open-login (select-keys multiaccount
[:key-uid :name :public-key :images :customization-color])))))
(rf/defn hide-keycard-banner (rf/defn hide-keycard-banner
{:events [:hide-keycard-banner]} {:events [:hide-keycard-banner]}
[{:keys [db]}] [{:keys [db]}]

View File

@ -11,16 +11,16 @@
:supported-biometric-auth false}} :supported-biometric-auth false}}
{:keys [db]} (login/save-password initial-cofx true)] {:keys [db]} (login/save-password initial-cofx true)]
(test/is (= false (contains? db :popover/popover))) (test/is (= false (contains? db :popover/popover)))
(test/is (= true (get-in db [:multiaccounts/login :save-password?]))) (test/is (= true (get-in db [:profile/login :save-password?])))
(test/testing "uncheck save password" (test/testing "uncheck save password"
(let [{:keys [db]} (login/save-password {:db db} false)] (let [{:keys [db]} (login/save-password {:db db} false)]
(test/is (= false (contains? db :popover/popover))) (test/is (= false (contains? db :popover/popover)))
(test/is (= false (get-in db [:multiaccounts/login :save-password?]))))))) (test/is (= false (get-in db [:profile/login :save-password?])))))))
(test/testing "check save password, biometric available" (test/testing "check save password, biometric available"
(let [initial-cofx {:db {:auth-method keychain/auth-method-none (let [initial-cofx {:db {:auth-method keychain/auth-method-none
:supported-biometric-auth true}} :supported-biometric-auth true}}
{:keys [db]} (login/save-password initial-cofx true)] {:keys [db]} (login/save-password initial-cofx true)]
(test/is (= true (get-in db [:multiaccounts/login :save-password?]))) (test/is (= true (get-in db [:profile/login :save-password?])))
(test/testing "enable biometric auth" (test/testing "enable biometric auth"
(let [{:keys [db] :as res} (biometric/enable {:db db})] (let [{:keys [db] :as res} (biometric/enable {:db db})]
(test/is (contains? res :biometric-auth/authenticate)) (test/is (contains? res :biometric-auth/authenticate))
@ -53,10 +53,10 @@
:bioauth-message nil :bioauth-message nil
:bioauth-code nil})) :bioauth-code nil}))
false)] false)]
(test/is (= true (get-in db [:multiaccounts/login :save-password?]))) (test/is (= true (get-in db [:profile/login :save-password?])))
;; case 2 from https://github.com/status-im/status-mobile/issues/9573 ;; case 2 from https://github.com/status-im/status-mobile/issues/9573
(test/is (= keychain/auth-method-biometric-prepare (:auth-method db))) (test/is (= keychain/auth-method-biometric-prepare (:auth-method db)))
(test/testing "disable biometric" (test/testing "disable biometric"
(let [{:keys [db]} (biometric/disable {:db db})] (let [{:keys [db]} (biometric/disable {:db db})]
(test/is (= false (get-in db [:multiaccounts/login :save-password?]))) (test/is (= false (get-in db [:profile/login :save-password?])))
(test/is (= keychain/auth-method-none (:auth-method db)))))))) (test/is (= keychain/auth-method-none (:auth-method db))))))))

View File

@ -10,28 +10,28 @@
(deftest on-password-input-submitted (deftest on-password-input-submitted
(testing (testing
"handling :multiaccounts.login.ui/password-input-submitted event" "handling :multiaccounts.login.ui/password-input-submitted event"
(let [cofx {:db {:multiaccounts/login {:key-uid "key-uid" (let [cofx {:db {:profile/login {:key-uid "key-uid"
:password "password" :password "password"
:name "user"}}} :name "user"}}}
efx (login.core/login cofx)] efx (login.core/login cofx)]
(testing "Change multiaccount." (testing "Change multiaccount."
(is (= (::login.core/login efx) (is (= (::login.core/login efx)
["key-uid" "{\"name\":\"user\",\"key-uid\":\"key-uid\"}" ["key-uid" "{\"name\":\"user\",\"key-uid\":\"key-uid\"}"
(ethereum/sha3 "password")]))) (ethereum/sha3 "password")])))
(testing "start activity indicator" (testing "start activity indicator"
(is (= (get-in efx [:db :multiaccounts/login :processing]) true)))))) (is (= (get-in efx [:db :profile/login :processing]) true))))))
(deftest login-success (deftest login-success
(testing ":accounts.login.callback/login-success event received." (testing ":accounts.login.callback/login-success event received."
(let [db {:multiaccounts/login {:address "address" (let [db {:profile/login {:address "address"
:password "password"} :password "password"}
:multiaccount data/multiaccount} :profile/profile data/multiaccount}
cofx {:db db} cofx {:db db}
efx (login.core/multiaccount-login-success cofx) efx (login.core/multiaccount-login-success cofx)
json-rpc (into #{} (map :method (:json-rpc/call efx)))] json-rpc (into #{} (map :method (:json-rpc/call efx)))]
;; TODO: Account is now cleared only after all sign in fx are executed. ;; TODO: Account is now cleared only after all sign in fx are executed.
;; (testing ":accounts/login cleared." ;; (testing ":accounts/login cleared."
;; (is (not (contains? new-db :multiaccounts/login)))) ;; (is (not (contains? new-db :profile/login))))
(testing "Check the rest of effects." (testing "Check the rest of effects."
(is (json-rpc "web3_clientVersion")))))) (is (json-rpc "web3_clientVersion"))))))
@ -44,7 +44,7 @@
"04f43da85ff1c333f3e7277b9ac4df92c9120fbb251f1dede7d41286e8c055acfeb845f6d2654821afca25da119daff9043530b296ee0e28e202ba92ec5842d617" "04f43da85ff1c333f3e7277b9ac4df92c9120fbb251f1dede7d41286e8c055acfeb845f6d2654821afca25da119daff9043530b296ee0e28e202ba92ec5842d617"
db db
{:keycard {:keycard
{:multiaccount {:profile/profile
{:encryption-public-key epk {:encryption-public-key epk
:whisper-private-key wpk :whisper-private-key wpk
:wallet-address "83278851e290d2488b6add2a257259f5741a3b7d" :wallet-address "83278851e290d2488b6add2a257259f5741a3b7d"

View File

@ -12,7 +12,7 @@
(rf/defn logout-method (rf/defn logout-method
{:events [::logout-method]} {:events [::logout-method]}
[{:keys [db] :as cofx} {:keys [auth-method logout?]}] [{:keys [db] :as cofx} {:keys [auth-method logout?]}]
(let [key-uid (get-in db [:multiaccount :key-uid])] (let [key-uid (get-in db [:profile/profile :key-uid])]
(rf/merge cofx (rf/merge cofx
{:set-root :progress {:set-root :progress
:chat.ui/clear-inputs nil :chat.ui/clear-inputs nil
@ -21,8 +21,9 @@
::logout nil ::logout nil
::multiaccounts/webview-debug-changed false ::multiaccounts/webview-debug-changed false
:keychain/clear-user-password key-uid :keychain/clear-user-password key-uid
:setup/open-multiaccounts #(re-frame/dispatch [:setup/initialize-multiaccounts :profile/get-profiles-overview #(re-frame/dispatch
% {:logout? logout?}])} [:profile/get-profiles-overview-success
%])}
(keychain/save-auth-method key-uid auth-method) (keychain/save-auth-method key-uid auth-method)
(wallet/clear-timeouts) (wallet/clear-timeouts)
(init/initialize-app-db)))) (init/initialize-app-db))))
@ -56,7 +57,7 @@
(logout-method {:auth-method keychain/auth-method-biometric-prepare (logout-method {:auth-method keychain/auth-method-biometric-prepare
:logout? false}) :logout? false})
(fn [{:keys [db]}] (fn [{:keys [db]}]
{:db (assoc-in db [:multiaccounts/login :save-password?] true)}))) {:db (assoc-in db [:profile/login :save-password?] true)})))
(re-frame/reg-fx (re-frame/reg-fx
::logout ::logout

View File

@ -1,13 +1,5 @@
(ns status-im.multiaccounts.model) (ns status-im.multiaccounts.model)
(defn logged-in? (defn logged-in?
[{:keys [multiaccount]}] [{:keys [profile/profile]}]
(boolean multiaccount)) (boolean profile))
(defn credentials
[cofx]
(select-keys (get-in cofx [:db :multiaccounts/login]) [:key-uid :password :save-password?]))
(defn current-public-key
[cofx]
(get-in cofx [:db :multiaccount :public-key]))

View File

@ -4,6 +4,6 @@
(deftest logged-in-test (deftest logged-in-test
(testing "multiaccount is defined" (testing "multiaccount is defined"
(is (multiaccounts.model/logged-in? {:multiaccount {}}))) (is (multiaccounts.model/logged-in? {:profile/profile {}})))
(testing "multiaccount is not there" (testing "multiaccount is not there"
(is (not (multiaccounts.model/logged-in? {}))))) (is (not (multiaccounts.model/logged-in? {})))))

View File

@ -6,14 +6,12 @@
[status-im.ethereum.core :as ethereum] [status-im.ethereum.core :as ethereum]
[status-im.ethereum.mnemonic :as mnemonic] [status-im.ethereum.mnemonic :as mnemonic]
[utils.i18n :as i18n] [utils.i18n :as i18n]
[status-im.keycard.nfc :as nfc]
[status-im.multiaccounts.core :as multiaccounts] [status-im.multiaccounts.core :as multiaccounts]
[status-im.multiaccounts.create.core :as multiaccounts.create] [status-im.multiaccounts.create.core :as multiaccounts.create]
[native-module.core :as native-module] [native-module.core :as native-module]
[status-im.popover.core :as popover] [status-im.popover.core :as popover]
[utils.re-frame :as rf] [utils.re-frame :as rf]
[status-im.utils.types :as types] [status-im.utils.types :as types]
[status-im.utils.utils :as utils]
[status-im2.navigation.events :as navigation] [status-im2.navigation.events :as navigation]
[taoensso.timbre :as log] [taoensso.timbre :as log]
[utils.security.core :as security])) [utils.security.core :as security]))
@ -31,13 +29,12 @@
{:events [:multiaccounts.recover/passphrase-input-changed]} {:events [:multiaccounts.recover/passphrase-input-changed]}
[{:keys [db]} masked-recovery-phrase] [{:keys [db]} masked-recovery-phrase]
(let [recovery-phrase (security/safe-unmask-data masked-recovery-phrase)] (let [recovery-phrase (security/safe-unmask-data masked-recovery-phrase)]
(rf/merge {:db (update db
{:db (update db :intro-wizard assoc
:intro-wizard assoc :passphrase (string/lower-case recovery-phrase)
:passphrase (string/lower-case recovery-phrase) :passphrase-error nil
:passphrase-error nil :next-button-disabled? (or (empty? recovery-phrase)
:next-button-disabled? (or (empty? recovery-phrase) (not (mnemonic/valid-length? recovery-phrase))))}))
(not (mnemonic/valid-length? recovery-phrase))))})))
(rf/defn validate-phrase-for-warnings (rf/defn validate-phrase-for-warnings
[{:keys [db]}] [{:keys [db]}]
@ -58,7 +55,7 @@
:on-dismiss #(re-frame/dispatch [:pop-to-root :multiaccounts])}} :on-dismiss #(re-frame/dispatch [:pop-to-root :multiaccounts])}}
(let [{:keys [key-uid] :as multiaccount} (get-in db [:intro-wizard :root-key]) (let [{:keys [key-uid] :as multiaccount} (get-in db [:intro-wizard :root-key])
keycard-multiaccount? (boolean (get-in db keycard-multiaccount? (boolean (get-in db
[:multiaccounts/multiaccounts key-uid [:profile/profiles-overview key-uid
:keycard-pairing]))] :keycard-pairing]))]
(if keycard-multiaccount? (if keycard-multiaccount?
;; trying to recover multiaccount created with keycard ;; trying to recover multiaccount created with keycard
@ -122,13 +119,13 @@
:on-accept #(do :on-accept #(do
(re-frame/dispatch [:pop-to-root :multiaccounts]) (re-frame/dispatch [:pop-to-root :multiaccounts])
(re-frame/dispatch (re-frame/dispatch
[:multiaccounts.login.ui/multiaccount-selected key-uid])) [:profile/profile-selected key-uid]))
:on-cancel #(re-frame/dispatch [:pop-to-root :multiaccounts])}}) :on-cancel #(re-frame/dispatch [:pop-to-root :multiaccounts])}})
(rf/defn on-import-multiaccount-success (rf/defn on-import-multiaccount-success
{:events [::import-multiaccount-success]} {:events [::import-multiaccount-success]}
[{:keys [db] :as cofx} {:keys [key-uid] :as root-data} derived-data] [{:keys [db] :as cofx} {:keys [key-uid] :as root-data} derived-data]
(let [multiaccounts (:multiaccounts/multiaccounts db)] (let [multiaccounts (:profile/profiles-overview db)]
(rf/merge (rf/merge
cofx cofx
{:db (update db {:db (update db
@ -178,106 +175,3 @@
{::multiaccounts/validate-mnemonic [passphrase {::multiaccounts/validate-mnemonic [passphrase
#(re-frame/dispatch [:multiaccounts.recover/phrase-validated #(re-frame/dispatch [:multiaccounts.recover/phrase-validated
%])]})) %])]}))
(rf/defn continue-to-import-mnemonic
{:events [::continue-pressed]}
[{:keys [db] :as cofx}]
(let [{:keys [password passphrase]} (:multiaccounts/recover db)]
(rf/merge cofx
{::import-multiaccount {:passphrase passphrase
:password password
:success-event ::import-multiaccount-success}}
(popover/hide-popover))))
(rf/defn dec-step
{:events [:multiaccounts.recover/dec-step]}
[{:keys [db] :as cofx}]
(let [step (get-in db [:intro-wizard :step])]
(if (= step :enter-phrase)
{:db (dissoc db :intro-wizard)}
{:db (update db
:intro-wizard assoc
:step
(case step
:recovery-success :enter-phrase
:select-key-storage :recovery-success
:create-code :select-key-storage)
:confirm-failure? false
:key-code nil)})))
(rf/defn cancel-pressed
{:events [:multiaccounts.recover/cancel-pressed]}
[{:keys [db] :as cofx} skip-alert?]
;; Workaround for multiple Cancel button clicks
;; that can break navigation tree
(let [step (get-in db [:intro-wizard :step])]
(when-not (#{:multiaccounts :login} (:view-id db))
(if (and (= step :select-key-storage) (not skip-alert?))
(utils/show-question
(i18n/label :t/are-you-sure-to-cancel)
(i18n/label :t/you-will-start-from-scratch)
#(re-frame/dispatch [:multiaccounts.recover/cancel-pressed true]))
(rf/merge cofx
dec-step
navigation/navigate-back)))))
(rf/defn select-storage-next-pressed
{:events [:multiaccounts.recover/select-storage-next-pressed]
:interceptors [(re-frame/inject-cofx :random-guid-generator)]}
[{:keys [db] :as cofx}]
(let [storage-type (get-in db [:intro-wizard :selected-storage-type])]
(if (= storage-type :advanced)
;;TODO: fix circular dependency to remove dispatch here
{:dispatch [:recovery.ui/keycard-option-pressed]}
(rf/merge cofx
{:db (update db :intro-wizard assoc :step :create-code)}
(navigation/navigate-to :create-password nil)))))
(rf/defn re-encrypt-pressed
{:events [:multiaccounts.recover/re-encrypt-pressed]}
[{:keys [db] :as cofx}]
(rf/merge cofx
{:db (update db
:intro-wizard
assoc
:step :select-key-storage
:selected-storage-type :default)}
(if (nfc/nfc-supported?)
(navigation/navigate-to :select-key-storage nil)
(select-storage-next-pressed))))
(rf/defn confirm-password-next-button-pressed
{:events [:multiaccounts.recover/enter-password-next-pressed]
:interceptors [(re-frame/inject-cofx :random-guid-generator)]}
[cofx key-code]
(store-multiaccount cofx key-code))
(rf/defn count-words
[{:keys [db]}]
(let [passphrase (get-in db [:intro-wizard :passphrase])]
{:db (assoc-in db
[:intro-wizard :passphrase-word-count]
(mnemonic/words-count passphrase))}))
(rf/defn run-validation
[{:keys [db] :as cofx}]
(let [passphrase (get-in db [:intro-wizard :passphrase])]
(when (= (last passphrase) " ")
(rf/merge cofx
(validate-phrase-for-warnings)))))
(rf/defn enter-phrase-input-changed
{:events [:multiaccounts.recover/enter-phrase-input-changed]}
[cofx input]
(rf/merge cofx
(set-phrase input)
(count-words)
(run-validation)))
(rf/defn enter-passphrase-input-changed
{:events [:multiaccounts.recover/enter-passphrase-input-changed]}
[{:keys [db]} masked-passphrase]
{:db (update db
:intro-wizard assoc
:password masked-passphrase
:password-error nil)})

View File

@ -73,13 +73,13 @@
(deftest on-import-multiaccount-success (deftest on-import-multiaccount-success
(testing "importing a new multiaccount" (testing "importing a new multiaccount"
(let [res (models/on-import-multiaccount-success (let [res (models/on-import-multiaccount-success
{:db {:multiaccounts/multiaccounts {:acc1 {}}}} {:db {:profile/profiles-overview {:acc1 {}}}}
{:key-uid :acc2} {:key-uid :acc2}
nil)] nil)]
(is (nil? (:utils/show-confirmation res))))) (is (nil? (:utils/show-confirmation res)))))
(testing "importing an existing multiaccount" (testing "importing an existing multiaccount"
(let [res (models/on-import-multiaccount-success (let [res (models/on-import-multiaccount-success
{:db {:multiaccounts/multiaccounts {:acc1 {}}}} {:db {:profile/profiles-overview {:acc1 {}}}}
{:key-uid :acc1} {:key-uid :acc1}
nil)] nil)]
(is (contains? res :utils/show-confirmation))))) (is (contains? res :utils/show-confirmation)))))

View File

@ -35,7 +35,7 @@
(rf/defn password-reset-success (rf/defn password-reset-success
{:events [::password-reset-success]} {:events [::password-reset-success]}
[{:keys [db] :as cofx}] [{:keys [db] :as cofx}]
(let [{:keys [key-uid]} (:multiaccount db) (let [{:keys [key-uid]} (:profile/profile db)
auth-method (get db :auth-method keychain/auth-method-none) auth-method (get db :auth-method keychain/auth-method-none)
new-password (get-in db [:multiaccount/reset-password-form-vals :new-password])] new-password (get-in db [:multiaccount/reset-password-form-vals :new-password])]
(rf/merge cofx (rf/merge cofx
@ -68,7 +68,7 @@
(rf/defn handle-verification-success (rf/defn handle-verification-success
{:events [::handle-verification-success]} {:events [::handle-verification-success]}
[{:keys [db] :as cofx} form-vals] [{:keys [db] :as cofx} form-vals]
(let [{:keys [key-uid name]} (:multiaccount db)] (let [{:keys [key-uid name]} (:profile/profile db)]
(rf/merge cofx (rf/merge cofx
{::change-db-password [key-uid form-vals] {::change-db-password [key-uid form-vals]
:db (assoc db :db (assoc db
@ -98,4 +98,4 @@
{::validate-current-password-and-reset {::validate-current-password-and-reset
(assoc form-vals (assoc form-vals
:address :address
(get-in db [:multiaccount :wallet-root-address]))}) (get-in db [:profile/profile :wallet-root-address]))})

View File

@ -6,7 +6,7 @@
(rf/defn send-contact-update (rf/defn send-contact-update
[{:keys [db]}] [{:keys [db]}]
(let [{:keys [name preferred-name display-name address]} (:multiaccount db)] (let [{:keys [name preferred-name display-name address]} (:profile/profile db)]
{:json-rpc/call [{:method "wakuext_sendContactUpdates" {:json-rpc/call [{:method "wakuext_sendContactUpdates"
:params [(or preferred-name display-name name) ""] :params [(or preferred-name display-name name) ""]
:on-success #(log/debug "sent contact update")}]})) :on-success #(log/debug "sent contact update")}]}))
@ -16,7 +16,7 @@
{:events [:multiaccounts.ui/update-name]} {:events [:multiaccounts.ui/update-name]}
[{:keys [db] :as cofx} raw-multiaccounts-from-status-go] [{:keys [db] :as cofx} raw-multiaccounts-from-status-go]
(let [{:keys [key-uid name preferred-name (let [{:keys [key-uid name preferred-name
display-name]} (:multiaccount db) display-name]} (:profile/profile db)
account (some #(and (= (:key-uid %) key-uid) %) raw-multiaccounts-from-status-go)] account (some #(and (= (:key-uid %) key-uid) %) raw-multiaccounts-from-status-go)]
(when-let [new-name (and account (or preferred-name display-name name))] (when-let [new-name (and account (or preferred-name display-name name))]
(rf/merge cofx (rf/merge cofx
@ -30,7 +30,7 @@
[{:keys [db] :as cofx} [{:keys [db] :as cofx}
setting setting-value setting setting-value
{:keys [dont-sync? on-success] :or {on-success #()}}] {:keys [dont-sync? on-success] :or {on-success #()}}]
(let [current-multiaccount (:multiaccount db)] (let [current-multiaccount (:profile/profile db)]
(if (empty? current-multiaccount) (if (empty? current-multiaccount)
;; NOTE: this should never happen, but if it does this is a critical error ;; NOTE: this should never happen, but if it does this is a critical error
;; and it is better to crash than risk having an unstable state ;; and it is better to crash than risk having an unstable state
@ -40,15 +40,15 @@
(rf/merge (rf/merge
cofx cofx
{:db (if setting-value {:db (if setting-value
(assoc-in db [:multiaccount setting] setting-value) (assoc-in db [:profile/profile setting] setting-value)
(update db :multiaccount dissoc setting)) (update db :profile/profile dissoc setting))
:json-rpc/call :json-rpc/call
[{:method "settings_saveSetting" [{:method "settings_saveSetting"
:params [setting setting-value] :params [setting setting-value]
:on-success on-success}]} :on-success on-success}]}
(when (#{:name :preferred-name} setting) (when (#{:name :preferred-name} setting)
(constantly {:setup/open-multiaccounts #(rf/dispatch [:multiaccounts.ui/update-name %])})) (constantly {:profile/get-profiles-overview #(rf/dispatch [:multiaccounts.ui/update-name %])}))
(when (and (not dont-sync?) (#{:name :preferred-name} setting)) (when (and (not dont-sync?) (#{:name :preferred-name} setting))
(send-contact-update)))))) (send-contact-update))))))
@ -73,7 +73,7 @@
(rf/defn optimistic (rf/defn optimistic
[{:keys [db] :as cofx} setting setting-value] [{:keys [db] :as cofx} setting setting-value]
(let [current-multiaccount (:multiaccount db) (let [current-multiaccount (:profile/profile db)
setting-value (if (= :currency setting) setting-value (if (= :currency setting)
(keyword setting-value) (keyword setting-value)
setting-value) setting-value)
@ -97,8 +97,8 @@
(assoc db :stickers/recent-stickers recent-stickers-from-remote)) (assoc db :stickers/recent-stickers recent-stickers-from-remote))
db)] db)]
{:db (if setting-value {:db (if setting-value
(assoc-in db [:multiaccount setting] setting-value) (assoc-in db [:profile/profile setting] setting-value)
(update db :multiaccount dissoc setting))})) (update db :profile/profile dissoc setting))}))
(rf/defn set-many-js (rf/defn set-many-js
[cofx settings-js] [cofx settings-js]
@ -119,7 +119,7 @@
{:events [::toggle-opensea-nfts-visiblity]} {:events [::toggle-opensea-nfts-visiblity]}
[cofx visible?] [cofx visible?]
(rf/merge cofx (rf/merge cofx
{:db (assoc-in (:db cofx) [:multiaccount :opensea-enabled?] visible?) {:db (assoc-in (:db cofx) [:profile/profile :opensea-enabled?] visible?)
;; need to add fully qualified namespace to counter circular deps ;; need to add fully qualified namespace to counter circular deps
:dispatch [:status-im.wallet.core/fetch-collectibles-collection]} :dispatch [:status-im.wallet.core/fetch-collectibles-collection]}
(multiaccount-update :opensea-enabled? visible? {}))) (multiaccount-update :opensea-enabled? visible? {})))

View File

@ -6,27 +6,27 @@
;;TODO this test case actually shows that we are doing a needless rpc call when ;;TODO this test case actually shows that we are doing a needless rpc call when
;;there is no changes, but it is an edge case that shouldn't really happen ;;there is no changes, but it is an edge case that shouldn't really happen
(let [efx (multiaccounts.update/multiaccount-update (let [efx (multiaccounts.update/multiaccount-update
{:db {:multiaccount {:not-empty "would throw an error if was empty"}}} {:db {:profile/profile {:not-empty "would throw an error if was empty"}}}
nil nil
nil nil
{}) {})
json-rpc (into #{} (map :method (:json-rpc/call efx)))] json-rpc (into #{} (map :method (:json-rpc/call efx)))]
(is (json-rpc "settings_saveSetting")) (is (json-rpc "settings_saveSetting"))
(is (= (get-in efx [:db :multiaccount]) {:not-empty "would throw an error if was empty"})))) (is (= (get-in efx [:db :profile/profile]) {:not-empty "would throw an error if was empty"}))))
(deftest test-clean-seed-phrase (deftest test-clean-seed-phrase
(let [efx (multiaccounts.update/clean-seed-phrase (let [efx (multiaccounts.update/clean-seed-phrase
{:db {:multiaccount {:mnemonic "lalalala"}}} {:db {:profile/profile {:mnemonic "lalalala"}}}
{}) {})
json-rpc (into #{} (map :method (:json-rpc/call efx)))] json-rpc (into #{} (map :method (:json-rpc/call efx)))]
(is (json-rpc "settings_saveSetting")) (is (json-rpc "settings_saveSetting"))
(is (nil? (get-in efx [:db :multiaccount :mnemonic]))))) (is (nil? (get-in efx [:db :profile/profile :mnemonic])))))
(deftest test-update-multiaccount-account-name (deftest test-update-multiaccount-account-name
(let [cofx {:db {:multiaccount {:key-uid 1 (let [cofx {:db {:profile/profile {:key-uid 1
:name "name" :name "name"
:preferred-name "preferred-name" :preferred-name "preferred-name"
:display-name "display-name"}}} :display-name "display-name"}}}
raw-multiaccounts-from-status-go [{:key-uid 1 :name "old-name"}]] raw-multiaccounts-from-status-go [{:key-uid 1 :name "old-name"}]]
(testing "wrong account" (testing "wrong account"
(is (nil? (multiaccounts.update/update-multiaccount-account-name cofx [])))) (is (nil? (multiaccounts.update/update-multiaccount-account-name cofx []))))
@ -46,11 +46,11 @@
"preferred-name")) "preferred-name"))
(is (new-account-name= (is (new-account-name=
(multiaccounts.update/update-multiaccount-account-name (multiaccounts.update/update-multiaccount-account-name
(update-in cofx [:db :multiaccount] dissoc :preferred-name) (update-in cofx [:db :profile/profile] dissoc :preferred-name)
raw-multiaccounts-from-status-go) raw-multiaccounts-from-status-go)
"display-name")) "display-name"))
(is (new-account-name= (is (new-account-name=
(multiaccounts.update/update-multiaccount-account-name (multiaccounts.update/update-multiaccount-account-name
(update-in cofx [:db :multiaccount] dissoc :preferred-name :display-name) (update-in cofx [:db :profile/profile] dissoc :preferred-name :display-name)
raw-multiaccounts-from-status-go) raw-multiaccounts-from-status-go)
"name")))))) "name"))))))

View File

@ -123,7 +123,7 @@
:db {:networks/manage {:url {:value "wrong"} :db {:networks/manage {:url {:value "wrong"}
:chain {:value "1"} :chain {:value "1"}
:name {:value "empty"}} :name {:value "empty"}}
:multiaccount {}}}))))) :profile/profile {}}})))))
(deftest save-valid-network (deftest save-valid-network
(testing "save a valid network" (testing "save a valid network"
@ -133,7 +133,7 @@
:chain {:value :mainnet} :chain {:value :mainnet}
:symbol {:value "symbol"} :symbol {:value "symbol"}
:name {:value "valid"}} :name {:value "valid"}}
:multiaccount {} :profile/profile {}
:networks/networks {"random2" :networks/networks {"random2"
{:id "random2" {:id "random2"
:name "network-name" :name "network-name"
@ -156,7 +156,7 @@
:chain {:value :custom} :chain {:value :custom}
:name {:value "valid"} :name {:value "valid"}
:network-id {:value 1}} :network-id {:value 1}}
:multiaccount {} :profile/profile {}
:networks/networks {"random" :networks/networks {"random"
{:id "random" {:id "random"
:name "network-name" :name "network-name"
@ -176,7 +176,7 @@
:name {:value "valid"} :name {:value "valid"}
:symbol {:value "symbol"} :symbol {:value "symbol"}
:network-id {:value 5}} :network-id {:value 5}}
:multiaccount {} :profile/profile {}
:networks/networks {"randomid" :networks/networks {"randomid"
{:id "randomid" {:id "randomid"
:name "network-name" :name "network-name"

View File

@ -13,7 +13,7 @@
{:db (assoc db :network-status (if is-connected? :online :offline))} {:db (assoc db :network-status (if is-connected? :online :offline))}
(when (and is-connected? (when (and is-connected?
(or (not= (count (get-in db [:wallet :accounts])) (or (not= (count (get-in db [:wallet :accounts]))
(count (get db :multiaccount/accounts))) (count (get db :profile/wallet-accounts)))
(wallet/has-empty-balances? db))) (wallet/has-empty-balances? db)))
(wallet/update-balances nil nil)))) (wallet/update-balances nil nil))))

View File

@ -102,7 +102,7 @@
(defn current-fleet-key (defn current-fleet-key
[db] [db]
(keyword (get-in db (keyword (get-in db
[:multiaccount :fleet] [:profile/profile :fleet]
config/fleet))) config/fleet)))
(defn get-current-fleet (defn get-current-fleet
@ -116,9 +116,9 @@
(some #(string/includes? (str %) "waku") ks))) (some #(string/includes? (str %) "waku") ks)))
(defn get-multiaccount-node-config (defn get-multiaccount-node-config
[{:keys [multiaccount :networks/networks :networks/current-network] [{:keys [profile/profile :networks/networks :networks/current-network]
:as db}] :as db}]
(let [wakuv2-config (get multiaccount :wakuv2-config {}) (let [wakuv2-config (get profile :wakuv2-config {})
current-fleet-key (current-fleet-key db) current-fleet-key (current-fleet-key db)
current-fleet (get-current-fleet db) current-fleet (get-current-fleet db)
wakuv2-enabled (wakuv2-enabled? current-fleet) wakuv2-enabled (wakuv2-enabled? current-fleet)
@ -127,7 +127,7 @@
{:keys [installation-id log-level {:keys [installation-id log-level
waku-bloom-filter-mode waku-bloom-filter-mode
custom-bootnodes custom-bootnodes-enabled?]} custom-bootnodes custom-bootnodes-enabled?]}
multiaccount profile
use-custom-bootnodes (get custom-bootnodes-enabled? current-network)] use-custom-bootnodes (get custom-bootnodes-enabled? current-network)]
(cond-> (get-in networks [current-network :config]) (cond-> (get-in networks [current-network :config])
:always :always
@ -212,7 +212,7 @@ app-db"
(rf/defn prepare-new-config (rf/defn prepare-new-config
"Use this function to apply settings to the current account node config" "Use this function to apply settings to the current account node config"
[{:keys [db]} {:keys [on-success]}] [{:keys [db]} {:keys [on-success]}]
(let [key-uid (get-in db [:multiaccount :key-uid])] (let [key-uid (get-in db [:profile/profile :key-uid])]
{::prepare-new-config [key-uid {::prepare-new-config [key-uid
(get-new-config db) (get-new-config db)
#(re-frame/dispatch #(re-frame/dispatch

View File

@ -110,12 +110,12 @@
(= view-id :chat))) (= view-id :chat)))
(defn show-message-pn? (defn show-message-pn?
[{{:keys [app-state multiaccount]} :db :as cofx} [{{:keys [app-state profile/profile]} :db :as cofx}
notification] notification]
(let [chat-id (get-in notification [:body :chat :id]) (let [chat-id (get-in notification [:body :chat :id])
notification-author (get-in notification [:notificationAuthor :id])] notification-author (get-in notification [:notificationAuthor :id])]
(and (and
(not= notification-author (:public-key multiaccount)) (not= notification-author (:public-key profile))
(or (= app-state "background") (or (= app-state "background")
(not (foreground-chat? cofx chat-id)))))) (not (foreground-chat? cofx chat-id))))))

View File

@ -91,7 +91,7 @@
"Set the name of the device" "Set the name of the device"
{:events [:pairing.ui/set-name-pressed]} {:events [:pairing.ui/set-name-pressed]}
[{:keys [db]} installation-name] [{:keys [db]} installation-name]
(let [our-installation-id (get-in db [:multiaccount :installation-id])] (let [our-installation-id (get-in db [:profile/profile :installation-id])]
{:pairing/set-installation-metadata [our-installation-id {:pairing/set-installation-metadata [our-installation-id
{:name installation-name {:name installation-name
:deviceType utils.platform/os}]})) :deviceType utils.platform/os}]}))
@ -195,7 +195,7 @@
(rf/defn send-installation-messages (rf/defn send-installation-messages
{:events [:pairing.ui/synchronize-installation-pressed]} {:events [:pairing.ui/synchronize-installation-pressed]}
[{:keys [db]}] [{:keys [db]}]
(let [multiaccount (:multiaccount db) (let [multiaccount (:profile/profile db)
{:keys [name preferred-name]} multiaccount] {:keys [name preferred-name]} multiaccount]
{:json-rpc/call [{:method "wakuext_syncDevices" {:json-rpc/call [{:method "wakuext_syncDevices"
:params [(or preferred-name name)] :params [(or preferred-name name)]

View File

@ -57,7 +57,7 @@
(rf/defn enter-two-random-words (rf/defn enter-two-random-words
{:events [:my-profile/enter-two-random-words]} {:events [:my-profile/enter-two-random-words]}
[{:keys [db]}] [{:keys [db]}]
(let [{:keys [mnemonic]} (:multiaccount db) (let [{:keys [mnemonic]} (:profile/profile db)
shuffled-mnemonic (shuffle (map-indexed vector (string/split mnemonic #" ")))] shuffled-mnemonic (shuffle (map-indexed vector (string/split mnemonic #" ")))]
{:db (assoc db {:db (assoc db
:my-profile/seed :my-profile/seed
@ -88,7 +88,7 @@
(rf/defn show-profile (rf/defn show-profile
{:events [:chat.ui/show-profile]} {:events [:chat.ui/show-profile]}
[{:keys [db]} identity ens-name] [{:keys [db]} identity ens-name]
(let [my-public-key (get-in db [:multiaccount :public-key])] (let [my-public-key (get-in db [:profile/profile :public-key])]
(if (not= my-public-key identity) (if (not= my-public-key identity)
{:db (-> db {:db (-> db
(assoc :contacts/identity identity) (assoc :contacts/identity identity)

View File

@ -42,8 +42,8 @@
(navigation/navigate-back))) (navigation/navigate-back)))
(defn own-public-key? (defn own-public-key?
[{:keys [multiaccount]} public-key] [{:keys [profile/profile]} public-key]
(= (:public-key multiaccount) public-key)) (= (:public-key profile) public-key))
(rf/defn handle-private-chat (rf/defn handle-private-chat
[{:keys [db] :as cofx} {:keys [chat-id]}] [{:keys [db] :as cofx} {:keys [chat-id]}]

View File

@ -21,8 +21,8 @@
(if error (if error
(cond-> (cond->
{:db (-> db {:db (-> db
(update :multiaccounts/login dissoc :processing) (update :profile/login dissoc :processing)
(assoc-in [:multiaccounts/login :error] (assoc-in [:profile/login :error]
;; NOTE: the only currently known error is ;; NOTE: the only currently known error is
;; "file is not a database" which occurs ;; "file is not a database" which occurs
;; when the user inputs the wrong password ;; when the user inputs the wrong password
@ -86,7 +86,7 @@
(assoc-in [:syncing :pairing-status] :connected) (assoc-in [:syncing :pairing-status] :connected)
received-account? received-account?
(assoc-in [:syncing :multiaccount] multiaccount-data) (assoc-in [:syncing :profile/profile] multiaccount-data)
error-on-pairing? error-on-pairing?
(assoc-in [:syncing :pairing-status] :error) (assoc-in [:syncing :pairing-status] :error)
@ -120,7 +120,9 @@
type (.-type data)] type (.-type data)]
(case type (case type
"node.login" (status-node-started cofx (js->clj event-js :keywordize-keys true)) "node.login" (status-node-started cofx (js->clj event-js :keywordize-keys true))
"backup.performed" {:db (assoc-in db [:multiaccount :last-backup] (.-lastBackup event-js))} "backup.performed" {:db (assoc-in db
[:profile/profile :last-backup]
(.-lastBackup event-js))}
"envelope.sent" (transport.message/update-envelopes-status cofx "envelope.sent" (transport.message/update-envelopes-status cofx
(:ids (:ids
(js->clj event-js (js->clj event-js

View File

@ -245,8 +245,8 @@
{:keys [data typed? pinless?] :as message} :message {:keys [data typed? pinless?] :as message} :message
:as tx} :as tx}
(last queue) (last queue)
keycard-multiaccount? (boolean (get-in db [:multiaccount :keycard-pairing])) keycard-multiaccount? (boolean (get-in db [:profile/profile :keycard-pairing]))
wallet-set-up-passed? (get-in db [:multiaccount :wallet-set-up-passed?])] wallet-set-up-passed? (get-in db [:profile/profile :wallet-set-up-passed?])]
(if message (if message
(rf/merge (rf/merge
cofx cofx
@ -349,7 +349,7 @@
[{:keys [db] :as cofx} transaction-hash hashed-password [{:keys [db] :as cofx} transaction-hash hashed-password
{:keys [message-id chat-id from] :as tx-obj}] {:keys [message-id chat-id from] :as tx-obj}]
(let [{:keys [on-result symbol amount contract value]} (get db :signing/tx) (let [{:keys [on-result symbol amount contract value]} (get db :signing/tx)
data (str (get-in db [:multiaccount :public-key]) data (str (get-in db [:profile/profile :public-key])
(subs transaction-hash 2))] (subs transaction-hash 2))]
(rf/merge (rf/merge
cofx cofx

View File

@ -14,7 +14,6 @@
[status-im.data-store.reactions :as data-store.reactions] [status-im.data-store.reactions :as data-store.reactions]
[status-im.group-chats.core :as models.group] [status-im.group-chats.core :as models.group]
[status-im.multiaccounts.login.core :as multiaccounts.login] [status-im.multiaccounts.login.core :as multiaccounts.login]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.multiaccounts.update.core :as update.core] [status-im.multiaccounts.update.core :as update.core]
[status-im.pairing.core :as models.pairing] [status-im.pairing.core :as models.pairing]
[utils.re-frame :as rf] [utils.re-frame :as rf]
@ -209,7 +208,7 @@
new new
(not (= message-type (not (= message-type
constants/message-type-private-group-system-message)) constants/message-type-private-group-system-message))
(not (= from (multiaccounts.model/current-public-key {:db db})))) (not (= from (get-in db [:profile/profile :public-key]))))
tx-hash (and (.-commandParameters message-js) tx-hash (and (.-commandParameters message-js)
(.-commandParameters.transactionHash message-js))] (.-commandParameters.transactionHash message-js))]
(cond-> acc (cond-> acc

View File

@ -88,7 +88,7 @@
(letsubs [{:keys [peers node mobile sync]} [:connectivity/state] (letsubs [{:keys [peers node mobile sync]} [:connectivity/state]
current-mailserver-name [:mailserver/current-name] current-mailserver-name [:mailserver/current-name]
peers-count [:peers-count] peers-count [:peers-count]
{:keys [syncing-on-mobile-network?]} [:multiaccount]] {:keys [syncing-on-mobile-network?]} [:profile/profile]]
[:<> [:<>
[quo/header {:title (i18n/label :t/connection-status) :border-bottom false}] [quo/header {:title (i18n/label :t/connection-status) :border-bottom false}]
[quo/list-header (i18n/label :t/peer-to-peer)] [quo/list-header (i18n/label :t/peer-to-peer)]

View File

@ -13,7 +13,7 @@
(rf/defn share-link (rf/defn share-link
{:events [:invite.events/share-link]} {:events [:invite.events/share-link]}
[{:keys [db]}] [{:keys [db]}]
(let [{:keys [public-key preferred-name]} (get db :multiaccount) (let [{:keys [public-key preferred-name]} (get db :profile/profile)
profile-link (universal-links/generate-link :user profile-link (universal-links/generate-link :user
:external :external
(or preferred-name (or preferred-name

View File

@ -115,7 +115,7 @@
(views/defview advanced-settings (views/defview advanced-settings
[] []
(views/letsubs [{:keys [webview-debug]} [:multiaccount] (views/letsubs [{:keys [webview-debug]} [:profile/profile]
network-name [:network-name] network-name [:network-name]
waku-bloom-filter-mode [:waku/bloom-filter-mode] waku-bloom-filter-mode [:waku/bloom-filter-mode]
wakuv2-flag [:waku/v2-flag] wakuv2-flag [:waku/v2-flag]

View File

@ -21,7 +21,7 @@
(views/defview appearance (views/defview appearance
[] []
(views/letsubs [{:keys [appearance]} [:multiaccount]] (views/letsubs [{:keys [appearance]} [:profile/profile]]
[:<> [:<>
[quo/list-header (i18n/label :t/preference)] [quo/list-header (i18n/label :t/preference)]
[react/view [react/view

View File

@ -32,7 +32,7 @@
[] []
(views/letsubs (views/letsubs
[{:keys [last-backup backup-enabled?]} [{:keys [last-backup backup-enabled?]}
[:multiaccount] [:profile/profile]
performing-backup? [:backup/performing-backup]] performing-backup? [:backup/performing-backup]]
[:<> [:<>
[react/scroll-view [react/scroll-view

View File

@ -251,7 +251,7 @@
[:browser/options] [:browser/options]
dapps-account [:dapps-account] dapps-account [:dapps-account]
network-id [:chain-id] network-id [:chain-id]
{:keys [webview-allow-permission-requests?]} [:multiaccount]] {:keys [webview-allow-permission-requests?]} [:profile/profile]]
(let [can-go-back? (browser/can-go-back? browser) (let [can-go-back? (browser/can-go-back? browser)
can-go-forward? (browser/can-go-forward? browser) can-go-forward? (browser/can-go-forward? browser)
url-original (browser/get-current-url browser)] url-original (browser/get-current-url browser)]

View File

@ -26,7 +26,7 @@
[] []
(views/letsubs [{:keys [default-sync-period] (views/letsubs [{:keys [default-sync-period]
:or {default-sync-period constants/one-day}} :or {default-sync-period constants/one-day}}
[:multiaccount]] [:profile/profile]]
[react/view {:margin-top 8} [react/view {:margin-top 8}
(when config/two-minutes-syncing? (when config/two-minutes-syncing?
[radio-item constants/two-mins default-sync-period]) [radio-item constants/two-mins default-sync-period])

View File

@ -611,7 +611,7 @@
(defn- welcome (defn- welcome
[] []
(let [name (:name @(re-frame/subscribe [:multiaccount]))] (let [name (:name @(re-frame/subscribe [:profile/profile]))]
[react/view {:style {:flex 1}} [react/view {:style {:flex 1}}
[react/scroll-view {:content-container-style {:align-items :center}} [react/scroll-view {:content-container-style {:align-items :center}}
[react/image [react/image
@ -761,8 +761,8 @@
(views/defview main (views/defview main
[] []
(views/letsubs [{:keys [names multiaccount show? registrations]} [:ens.main/screen]] (views/letsubs [{:keys [names profile/profile show? registrations]} [:ens.main/screen]]
[react/keyboard-avoiding-view {:style {:flex 1}} [react/keyboard-avoiding-view {:style {:flex 1}}
(if (or (seq names) registrations) (if (or (seq names) registrations)
[registered names multiaccount show? registrations] [registered names profile show? registrations]
[welcome])])) [welcome])]))

View File

@ -88,7 +88,7 @@
(defn save-password (defn save-password
[] []
(let [{:keys [save-password?]} @(re-frame/subscribe [:multiaccounts/login]) (let [{:keys [save-password?]} @(re-frame/subscribe [:profile/login])
auth-method @(re-frame/subscribe [:auth-method])] auth-method @(re-frame/subscribe [:auth-method])]
(when-not (and platform/android? (not auth-method)) (when-not (and platform/android? (not auth-method))
[react/view [react/view

View File

@ -316,8 +316,8 @@
enter-step [:keycard/pin-enter-step] enter-step [:keycard/pin-enter-step]
status [:keycard/pin-status] status [:keycard/pin-status]
error-label [:keycard/pin-error-label] error-label [:keycard/pin-error-label]
login-multiaccount [:multiaccounts/login] login-multiaccount [:profile/login]
multiaccount [:multiaccount] multiaccount [:profile/profile]
small-screen? [:dimensions/small-screen?] small-screen? [:dimensions/small-screen?]
retry-counter [:keycard/retry-counter]] retry-counter [:keycard/retry-counter]]
(let [{:keys [name] :as account} (or login-multiaccount multiaccount) (let [{:keys [name] :as account} (or login-multiaccount multiaccount)

View File

@ -24,7 +24,7 @@
(views/letsubs (views/letsubs
[{:keys [syncing-on-mobile-network? [{:keys [syncing-on-mobile-network?
remember-syncing-choice?]} remember-syncing-choice?]}
[:multiaccount]] [:profile/profile]]
[:<> [:<>
[react/view [react/view
{:style styles/switch-container {:style styles/switch-container

View File

@ -33,7 +33,7 @@
(let [{:keys [remote-push-notifications-enabled? (let [{:keys [remote-push-notifications-enabled?
push-notifications-block-mentions? push-notifications-block-mentions?
push-notifications-from-contacts-only?]} push-notifications-from-contacts-only?]}
@(re-frame/subscribe [:multiaccount])] @(re-frame/subscribe [:profile/profile])]
[:<> [:<>
[quo/list-item [quo/list-item
{:size :small {:size :small
@ -71,7 +71,7 @@
(defn notifications-settings-android (defn notifications-settings-android
[] []
(let [{:keys [notifications-enabled?]} @(re-frame/subscribe [:multiaccount])] (let [{:keys [notifications-enabled?]} @(re-frame/subscribe [:profile/profile])]
[:<> [:<>
[quo/list-item [quo/list-item
{:title (i18n/label :t/local-notifications) {:title (i18n/label :t/local-notifications)
@ -97,7 +97,7 @@
(let [{:keys [remote-push-notifications-enabled? (let [{:keys [remote-push-notifications-enabled?
send-push-notifications? send-push-notifications?
push-notifications-server-enabled?]} push-notifications-server-enabled?]}
@(re-frame/subscribe [:multiaccount])] @(re-frame/subscribe [:profile/profile])]
[react/scroll-view [react/scroll-view
{:style {:flex 1} {:style {:flex 1}
:content-container-style {:padding-vertical 8}} :content-container-style {:padding-vertical 8}}

View File

@ -53,7 +53,7 @@
(views/letsubs [current-mailserver-id [:mailserver/current-id] (views/letsubs [current-mailserver-id [:mailserver/current-id]
preferred-mailserver-id [:mailserver/preferred-id] preferred-mailserver-id [:mailserver/preferred-id]
mailservers [:mailserver/fleet-mailservers] mailservers [:mailserver/fleet-mailservers]
{:keys [use-mailservers?]} [:multiaccount]] {:keys [use-mailservers?]} [:profile/profile]]
[react/view {:style styles/wrapper} [react/view {:style styles/wrapper}
[topbar/topbar [topbar/topbar
{:title (i18n/label :t/history-nodes) {:title (i18n/label :t/history-nodes)

View File

@ -32,7 +32,7 @@
text-input-ref (atom nil)] text-input-ref (atom nil)]
(fn [] (fn []
(let [keycard? @(re-frame/subscribe [:keycard-multiaccount?]) (let [keycard? @(re-frame/subscribe [:keycard-multiaccount?])
multiaccount @(re-frame/subscribe [:multiaccount]) multiaccount @(re-frame/subscribe [:profile/profile])
error @(re-frame/subscribe [:delete-profile/error]) error @(re-frame/subscribe [:delete-profile/error])
keep-keys-on-keycard? @(re-frame/subscribe [:delete-profile/keep-keys-on-keycard?])] keep-keys-on-keycard? @(re-frame/subscribe [:delete-profile/keep-keys-on-keycard?])]
(when (and @text-input-ref error (not @password)) (when (and @text-input-ref error (not @password))

View File

@ -39,7 +39,7 @@
{:events [::delete-profile]} {:events [::delete-profile]}
[{:keys [db] :as cofx} masked-password] [{:keys [db] :as cofx} masked-password]
(log/info "[delete-profile] delete") (log/info "[delete-profile] delete")
(let [{:keys [key-uid wallet-root-address]} (:multiaccount db)] (let [{:keys [key-uid wallet-root-address]} (:profile/profile db)]
{:db (dissoc db :delete-profile/error) {:db (dissoc db :delete-profile/error)
::delete-profile ::delete-profile
{:masked-password masked-password {:masked-password masked-password

View File

@ -17,7 +17,7 @@
(views/defview messages-from-contacts-only (views/defview messages-from-contacts-only
[] []
(views/letsubs [{:keys [messages-from-contacts-only]} [:multiaccount]] (views/letsubs [{:keys [messages-from-contacts-only]} [:profile/profile]]
[react/view {:margin-top 8} [react/view {:margin-top 8}
[quo/list-item [quo/list-item
{:active (not messages-from-contacts-only) {:active (not messages-from-contacts-only)

View File

@ -33,7 +33,7 @@
webview-allow-permission-requests? webview-allow-permission-requests?
opensea-enabled? opensea-enabled?
profile-pictures-visibility]} profile-pictures-visibility]}
[:multiaccount] [:profile/profile]
has-picture [:profile/has-picture] has-picture [:profile/has-picture]
supported-biometric-auth [:supported-biometric-auth] supported-biometric-auth [:supported-biometric-auth]
keycard? [:keycard-multiaccount?] keycard? [:keycard-multiaccount?]
@ -174,7 +174,7 @@
(views/defview profile-pic-show-to (views/defview profile-pic-show-to
[] []
(views/letsubs [{:keys [profile-pictures-show-to]} [:multiaccount]] (views/letsubs [{:keys [profile-pictures-show-to]} [:profile/profile]]
[react/view {:margin-top 8} [react/view {:margin-top 8}
[ppst-radio-item constants/profile-pictures-show-to-everyone profile-pictures-show-to] [ppst-radio-item constants/profile-pictures-show-to-everyone profile-pictures-show-to]
[ppst-radio-item constants/profile-pictures-show-to-contacts-only profile-pictures-show-to] [ppst-radio-item constants/profile-pictures-show-to-contacts-only profile-pictures-show-to]
@ -194,7 +194,7 @@
(views/defview profile-pic (views/defview profile-pic
[] []
(views/letsubs [{:keys [profile-pictures-visibility]} [:multiaccount]] (views/letsubs [{:keys [profile-pictures-visibility]} [:profile/profile]]
[react/view {:margin-top 8} [react/view {:margin-top 8}
[ppvf-radio-item constants/profile-pictures-visibility-everyone profile-pictures-visibility] [ppvf-radio-item constants/profile-pictures-visibility-everyone profile-pictures-visibility]
[ppvf-radio-item constants/profile-pictures-visibility-contacts-only profile-pictures-visibility] [ppvf-radio-item constants/profile-pictures-visibility-contacts-only profile-pictures-visibility]

View File

@ -153,7 +153,7 @@
(defview backup-seed (defview backup-seed
[] []
(letsubs [current-multiaccount [:multiaccount] (letsubs [current-multiaccount [:profile/profile]
{:keys [step first-word second-word error word]} [:my-profile/recovery]] {:keys [step first-word second-word error word]} [:my-profile/recovery]]
[react/keyboard-avoiding-view [react/keyboard-avoiding-view
{:style {:flex 1} {:style {:flex 1}

View File

@ -71,7 +71,7 @@
(let [{:keys [preferred-name (let [{:keys [preferred-name
mnemonic mnemonic
keycard-pairing]} keycard-pairing]}
@(re-frame/subscribe [:multiaccount]) @(re-frame/subscribe [:profile/profile])
active-contacts-count @(re-frame/subscribe [:contacts/active-count]) active-contacts-count @(re-frame/subscribe [:contacts/active-count])
chain @(re-frame/subscribe [:chain-keyword]) chain @(re-frame/subscribe [:chain-keyword])
registrar (stateofus/get-cached-registrar chain) registrar (stateofus/get-cached-registrar chain)

View File

@ -13,7 +13,7 @@
backup-enabled? backup-enabled?
default-sync-period default-sync-period
use-mailservers?]} use-mailservers?]}
[:multiaccount] [:profile/profile]
current-mailserver-name [:mailserver/current-name]] current-mailserver-name [:mailserver/current-name]]
[react/scroll-view [react/scroll-view
[quo/list-header (i18n/label :t/data-syncing)] [quo/list-header (i18n/label :t/data-syncing)]

View File

@ -146,7 +146,7 @@
portfolio-value [:portfolio-value] portfolio-value [:portfolio-value]
empty-balances? [:empty-balances?] empty-balances? [:empty-balances?]
frozen-card? [:keycard/frozen-card?] frozen-card? [:keycard/frozen-card?]
{:keys [mnemonic]} [:multiaccount]] {:keys [mnemonic]} [:profile/profile]]
[reanimated/view {:style (styles/container {:minimized minimized})} [reanimated/view {:style (styles/container {:minimized minimized})}
(when (or (when (or
(and frozen-card? minimized) (and frozen-card? minimized)

View File

@ -30,7 +30,7 @@
(defn manage (defn manage
[] []
(let [accounts (rf/sub [:multiaccount/accounts])] (let [accounts (rf/sub [:profile/wallet-accounts])]
[list/flat-list [list/flat-list
{:key-fn :address {:key-fn :address
:data accounts :data accounts

View File

@ -10,7 +10,7 @@
(views/defview signing-phrase (views/defview signing-phrase
[] []
(views/letsubs [phrase [:signing/phrase] (views/letsubs [phrase [:signing/phrase]
{:keys [wallet-set-up-passed?]} [:multiaccount]] {:keys [wallet-set-up-passed?]} [:profile/profile]]
[react/view [react/view
[react/view {:margin-top 24 :margin-horizontal 24 :align-items :center} [react/view {:margin-top 24 :margin-horizontal 24 :align-items :center}
[react/view [react/view

View File

@ -221,11 +221,6 @@
(-> (.resetInternetCredentials react-native-keychain (string/lower-case key-uid)) (-> (.resetInternetCredentials react-native-keychain (string/lower-case key-uid))
(.then #(when-not % (log/error (str "Error while clearing saved password."))))))) (.then #(when-not % (log/error (str "Error while clearing saved password.")))))))
(rf/defn get-auth-method
[_ key-uid]
{:keychain/get-auth-method
[key-uid #(re-frame/dispatch [:multiaccounts.login/get-auth-method-success % key-uid])]})
(rf/defn get-user-password (rf/defn get-user-password
[_ key-uid] [_ key-uid]
{:keychain/get-user-password {:keychain/get-user-password

View File

@ -97,9 +97,9 @@
(re-frame/dispatch [:show-client-error])))))) (re-frame/dispatch [:show-client-error]))))))
(defn logs-enabled? (defn logs-enabled?
[{:keys [multiaccount]}] [{:profile/keys [profile]}]
(let [log-level (if multiaccount ;; already login (let [log-level (if profile ;; already login
(get multiaccount :log-level) (get profile :log-level)
config/log-level)] config/log-level)]
(not (string/blank? log-level)))) (not (string/blank? log-level))))

View File

@ -7,7 +7,7 @@
(defn syncing-allowed? (defn syncing-allowed?
[{:keys [db]}] [{:keys [db]}]
(let [network (:network/type db) (let [network (:network/type db)
{:keys [syncing-on-mobile-network?]} (:multiaccount db)] {:keys [syncing-on-mobile-network?]} (:profile/profile db)]
(or (= network "wifi") (or (= network "wifi")
(and syncing-on-mobile-network? (and syncing-on-mobile-network?
(= network "cellular"))))) (= network "cellular")))))

View File

@ -2,7 +2,7 @@
(defn has-paired-installations? (defn has-paired-installations?
[cofx] [cofx]
(let [our-installation-id (get-in cofx [:db :multiaccount :installation-id])] (let [our-installation-id (get-in cofx [:db :profile/profile :installation-id])]
(->> (->>
(get-in cofx [:db :pairing/installations]) (get-in cofx [:db :pairing/installations])
vals vals

View File

@ -59,8 +59,8 @@
(group-chats/create-from-link cofx params)) (group-chats/create-from-link cofx params))
(defn own-public-key? (defn own-public-key?
[{:keys [multiaccount]} public-key] [{:keys [profile/profile]} public-key]
(= (:public-key multiaccount) public-key)) (= (:public-key profile) public-key))
(rf/defn handle-private-chat (rf/defn handle-private-chat
[{:keys [db] :as cofx} {:keys [chat-id]}] [{:keys [db] :as cofx} {:keys [chat-id]}]
@ -123,7 +123,7 @@
(some #(when (= (string/lower-case (:address %)) (some #(when (= (string/lower-case (:address %))
(string/lower-case address)) (string/lower-case address))
%) %)
(:multiaccount/accounts db)))) (:profile/wallet-accounts db))))
(rf/defn handle-wallet-account (rf/defn handle-wallet-account
[cofx {address :account}] [cofx {address :account}]

View File

@ -12,7 +12,7 @@
(is (= {:db {:universal-links/url "some-url"}} (is (= {:db {:universal-links/url "some-url"}}
(links/handle-url {:db {}} "some-url"))))) (links/handle-url {:db {}} "some-url")))))
(testing "the user is logged in" (testing "the user is logged in"
(let [db {:multiaccount {:public-key "pk"} (let [db {:profile/profile {:public-key "pk"}
:app-state "active" :app-state "active"
:universal-links/url "some-url"}] :universal-links/url "some-url"}]
(testing "it clears the url" (testing "it clears the url"

View File

@ -66,10 +66,10 @@
(let [visibility-status-updates-old (get db :visibility-status-updates {}) (let [visibility-status-updates-old (get db :visibility-status-updates {})
my-public-key (get-in my-public-key (get-in
db db
[:multiaccount :public-key]) [:profile/profile :public-key])
my-current-status (get-in my-current-status (get-in
db db
[:multiaccount :current-user-visibility-status]) [:profile/profile :current-user-visibility-status])
{:keys [visibility-status-updates current-user-visibility-status dispatch]} {:keys [visibility-status-updates current-user-visibility-status dispatch]}
(reduce (fn [acc visibility-status-update-received] (reduce (fn [acc visibility-status-update-received]
(let [{:keys [public-key clock] :as visibility-status-update} (let [{:keys [public-key clock] :as visibility-status-update}
@ -93,7 +93,7 @@
(update-in [:visibility-status-updates] (update-in [:visibility-status-updates]
merge merge
visibility-status-updates) visibility-status-updates)
(update-in [:multiaccount :current-user-visibility-status] (update-in [:profile/profile :current-user-visibility-status]
merge merge
current-user-visibility-status))} current-user-visibility-status))}
(when dispatch {:dispatch dispatch})))) (when dispatch {:dispatch dispatch}))))
@ -102,7 +102,7 @@
{:events [:visibility-status-updates/update-visibility-status]} {:events [:visibility-status-updates/update-visibility-status]}
[{:keys [db] :as cofx} status-type] [{:keys [db] :as cofx} status-type]
{:db (update-in db {:db (update-in db
[:multiaccount :current-user-visibility-status] [:profile/profile :current-user-visibility-status]
merge merge
{:status-type status-type {:status-type status-type
:clock (datetime/timestamp-sec)}) :clock (datetime/timestamp-sec)})
@ -150,9 +150,9 @@
(rf/defn peers-summary-change (rf/defn peers-summary-change
[{:keys [db] :as cofx} peers-count] [{:keys [db] :as cofx} peers-count]
(let [send-visibility-status-updates? (let [send-visibility-status-updates?
(get-in db [:multiaccount :send-status-updates?]) (get-in db [:profile/profile :send-status-updates?])
status-type status-type
(get-in db [:multiaccount :current-user-visibility-status :status-type])] (get-in db [:profile/profile :current-user-visibility-status :status-type])]
(when (and (when (and
(> peers-count 0) (> peers-count 0)
send-visibility-status-updates? send-visibility-status-updates?
@ -161,12 +161,12 @@
{:dispatch-later [{:ms 1000 {:dispatch-later [{:ms 1000
:dispatch :dispatch
[:visibility-status-updates/send-visibility-status-updates? false]}] [:visibility-status-updates/send-visibility-status-updates? false]}]
:db (assoc-in db [:multiaccount :send-status-updates?] false)} :db (assoc-in db [:profile/profile :send-status-updates?] false)}
(update-visibility-status status-type))))) (update-visibility-status status-type)))))
(rf/defn sync-visibility-status-update (rf/defn sync-visibility-status-update
[{:keys [db] :as cofx} visibility-status-update-received] [{:keys [db] :as cofx} visibility-status-update-received]
(let [my-current-status (get-in db [:multiaccount :current-user-visibility-status]) (let [my-current-status (get-in db [:profile/profile :current-user-visibility-status])
{:keys [status-type clock]} (visibility-status-updates-store/<-rpc {:keys [status-type clock]} (visibility-status-updates-store/<-rpc
visibility-status-update-received)] visibility-status-update-received)]
(when (and (valid-status-type? status-type) (when (and (valid-status-type? status-type)
@ -175,7 +175,7 @@
(> clock (:clock my-current-status)))) (> clock (:clock my-current-status))))
(rf/merge cofx (rf/merge cofx
{:db (update-in db {:db (update-in db
[:multiaccount :current-user-visibility-status] [:profile/profile :current-user-visibility-status]
merge merge
{:clock clock :status-type status-type})} {:clock clock :status-type status-type})}
(send-visibility-status-updates? (send-visibility-status-updates?

View File

@ -41,7 +41,7 @@
(let [custom-nodes (into {} (let [custom-nodes (into {}
(map #(vector (random-guid-generator) (map #(vector (random-guid-generator)
{:name (name (first %1)) :address (second %1)}) {:name (name (first %1)) :address (second %1)})
(get-in db [:multiaccount :wakuv2-config :CustomNodes])))] (get-in db [:profile/profile :wakuv2-config :CustomNodes])))]
(rf/merge cofx (rf/merge cofx
{:db (assoc db :wakuv2-nodes/list custom-nodes) {:db (assoc db :wakuv2-nodes/list custom-nodes)
:dispatch [:navigate-to :wakuv2-settings]}))) :dispatch [:navigate-to :wakuv2-settings]})))
@ -109,7 +109,7 @@
(into {}))] (into {}))]
(rf/merge cofx (rf/merge cofx
{:db (-> db {:db (-> db
(assoc-in [:multiaccount :wakuv2-config :CustomNodes] new-nodes) (assoc-in [:profile/profile :wakuv2-config :CustomNodes] new-nodes)
(dissoc :wakuv2-nodes/manage :wakuv2-nodes/list)) (dissoc :wakuv2-nodes/manage :wakuv2-nodes/list))
:dispatch [:navigate-back]} :dispatch [:navigate-back]}
(node/prepare-new-config (node/prepare-new-config

View File

@ -29,7 +29,7 @@
(rf/defn start-adding-new-account (rf/defn start-adding-new-account
{:events [:wallet.accounts/start-adding-new-account]} {:events [:wallet.accounts/start-adding-new-account]}
[{:keys [db] :as cofx} {:keys [type] :as add-account}] [{:keys [db] :as cofx} {:keys [type] :as add-account}]
(let [{:keys [latest-derived-path]} (:multiaccount db) (let [{:keys [latest-derived-path]} (:profile/profile db)
path-num (inc latest-derived-path) path-num (inc latest-derived-path)
account (merge account (merge
{:color (rand-nth colors/account-colors)} {:color (rand-nth colors/account-colors)}
@ -152,9 +152,9 @@
(rf/defn generate-new-account (rf/defn generate-new-account
[{:keys [db]} hashed-password] [{:keys [db]} hashed-password]
(let [{:keys [key-uid wallet-root-address]} (let [{:keys [key-uid wallet-root-address]}
(get db :multiaccount) (get db :profile/profile)
path-num (inc (get-in db [:multiaccount :latest-derived-path])) path-num (inc (get-in db [:profile/profile :latest-derived-path]))
accounts (:multiaccount/accounts db)] accounts (:profile/wallet-accounts db)]
{:db (assoc-in db [:add-account :step] :generating) {:db (assoc-in db [:add-account :step] :generating)
::generate-account {:derivation-info {:path (str "m/" path-num) ::generate-account {:derivation-info {:path (str "m/" path-num)
:address wallet-root-address} :address wallet-root-address}
@ -173,10 +173,10 @@
{:events [:wallet.accounts/seed-validated]} {:events [:wallet.accounts/seed-validated]}
[{:keys [db] :as cofx} phrase-warnings passphrase hashed-password] [{:keys [db] :as cofx} phrase-warnings passphrase hashed-password]
(let [error (:error (types/json->clj phrase-warnings)) (let [error (:error (types/json->clj phrase-warnings))
{:keys [key-uid]} (:multiaccount db)] {:keys [key-uid]} (:profile/profile db)]
(if-not (string/blank? error) (if-not (string/blank? error)
(new-account-error cofx :account-error error) (new-account-error cofx :account-error error)
(let [accounts (:multiaccount/accounts db)] (let [accounts (:profile/wallet-accounts db)]
{::import-account-seed {:passphrase passphrase {::import-account-seed {:passphrase passphrase
:hashed-password hashed-password :hashed-password hashed-password
:accounts accounts :accounts accounts
@ -184,7 +184,7 @@
(rf/defn import-new-account-private-key (rf/defn import-new-account-private-key
[{:keys [db]} private-key hashed-password] [{:keys [db]} private-key hashed-password]
(let [{:keys [key-uid]} (:multiaccount db)] (let [{:keys [key-uid]} (:profile/profile db)]
{:db (assoc-in db [:add-account :step] :generating) {:db (assoc-in db [:add-account :step] :generating)
::import-account-private-key {:private-key private-key ::import-account-private-key {:private-key private-key
:hashed-password hashed-password :hashed-password hashed-password
@ -192,11 +192,11 @@
(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]} (:profile/profile db)
{:keys [account type]} (:add-account db) {:keys [account type]} (:add-account db)
{:keys [address name key-uid]} account {:keys [address name key-uid]} account
main-key-uid (or key-uid (get-in db [:multiaccount :key-uid])) main-key-uid (or key-uid (get-in db [:profile/profile :key-uid]))
accounts (:multiaccount/accounts db) accounts (:profile/wallet-accounts db)
new-accounts (conj accounts account) new-accounts (conj accounts account)
;; Note(rasom): in case if a new account is created using a mnemonic or ;; 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 ;; a private key we add a new keypair to the database, otherwise we just
@ -222,7 +222,7 @@
:params params :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 :profile/wallet-accounts new-accounts)
(dissoc :add-account))} (dissoc :add-account))}
(when (= type :generate) (when (= type :generate)
(multiaccounts.update/multiaccount-update (multiaccounts.update/multiaccount-update
@ -233,7 +233,7 @@
(rf/defn account-generated (rf/defn account-generated
{:events [:wallet.accounts/account-stored]} {:events [:wallet.accounts/account-stored]}
[{:keys [db] :as cofx} {:keys [address] :as account}] [{:keys [db] :as cofx} {:keys [address] :as account}]
(let [accounts (:multiaccount/accounts db)] (let [accounts (:profile/wallet-accounts db)]
(if (some #(when (= (:address %) address) %) accounts) (if (some #(when (= (:address %) address) %) accounts)
(new-account-error cofx :account-error (i18n/label :t/account-exists-title)) (new-account-error cofx :account-error (i18n/label :t/account-exists-title))
(rf/merge cofx (rf/merge cofx
@ -270,7 +270,7 @@
(rf/defn add-new-account-verify-password (rf/defn add-new-account-verify-password
[{:keys [db]} hashed-password] [{:keys [db]} hashed-password]
{:db (assoc-in db [:add-account :step] :generating) {:db (assoc-in db [:add-account :step] :generating)
::verify-password {:address (get-in db [:multiaccount :wallet-root-address]) ::verify-password {:address (get-in db [:profile/profile :wallet-root-address])
:hashed-password hashed-password}}) :hashed-password hashed-password}})
(rf/defn set-account-to-watch (rf/defn set-account-to-watch
@ -308,7 +308,7 @@
(rf/defn save-account (rf/defn save-account
{:events [:wallet.accounts/save-account]} {:events [:wallet.accounts/save-account]}
[{:keys [db]} account {:keys [name color hidden]}] [{:keys [db]} account {:keys [name color hidden]}]
(let [accounts (:multiaccount/accounts db) (let [accounts (:profile/wallet-accounts db)
new-account (cond-> account new-account (cond-> account
name (assoc :name name) name (assoc :name name)
color (assoc :color color) color (assoc :color color)
@ -317,12 +317,12 @@
{:json-rpc/call [{:method "accounts_saveAccount" {:json-rpc/call [{:method "accounts_saveAccount"
:params [new-account] :params [new-account]
:on-success #()}] :on-success #()}]
:db (assoc db :multiaccount/accounts new-accounts)})) :db (assoc db :profile/wallet-accounts new-accounts)}))
(rf/defn delete-account (rf/defn delete-account
{:events [:wallet.accounts/delete-account]} {:events [:wallet.accounts/delete-account]}
[{:keys [db] :as cofx} account] [{:keys [db] :as cofx} account]
(let [accounts (:multiaccount/accounts db) (let [accounts (:profile/wallet-accounts db)
new-accounts (vec (remove #(= account %) accounts)) new-accounts (vec (remove #(= account %) accounts))
deleted-address (:address account)] deleted-address (:address account)]
(rf/merge cofx (rf/merge cofx
@ -330,7 +330,7 @@
:params [(:address account)] :params [(:address account)]
:on-success #()}] :on-success #()}]
:db (-> db :db (-> db
(assoc :multiaccount/accounts new-accounts) (assoc :profile/wallet-accounts new-accounts)
(update-in [:wallet :accounts] dissoc deleted-address))} (update-in [:wallet :accounts] dissoc deleted-address))}
(navigation/pop-to-root :shell-stack)))) (navigation/pop-to-root :shell-stack))))
@ -338,12 +338,12 @@
{:events [:wallet.accounts/delete-key]} {:events [:wallet.accounts/delete-key]}
[{:keys [db] :as cofx} account password on-error] [{:keys [db] :as cofx} account password on-error]
(let [deleted-address (:address account) (let [deleted-address (:address account)
dapps-address (get-in cofx [:db :multiaccount :dapps-address])] dapps-address (get-in cofx [:db :profile/profile :dapps-address])]
(if (= (string/lower-case dapps-address) (string/lower-case deleted-address)) (if (= (string/lower-case dapps-address) (string/lower-case deleted-address))
{:utils/show-popup {:title (i18n/label :t/warning) {:utils/show-popup {:title (i18n/label :t/warning)
:content (i18n/label :t/account-is-used)}} :content (i18n/label :t/account-is-used)}}
{::key-storage/delete-imported-key {::key-storage/delete-imported-key
{:key-uid (get-in db [:multiaccount :key-uid]) {:key-uid (get-in db [:profile/profile :key-uid])
:address (:address account) :address (:address account)
:password password :password password
:on-success #(do :on-success #(do

View File

@ -61,7 +61,7 @@
(cond-> {:to address (cond-> {:to address
:to-name (or name (find-address-name db address)) :to-name (or name (find-address-name db address))
:from (ethereum/get-default-account :from (ethereum/get-default-account
(get db :multiaccount/accounts))} (get db :profile/wallet-accounts))}
gas (assoc :gas (money/bignumber gas)) gas (assoc :gas (money/bignumber gas))
gasLimit (assoc :gas (money/bignumber gasLimit)) gasLimit (assoc :gas (money/bignumber gasLimit))
gasPrice (assoc :gasPrice (money/bignumber gasPrice)) gasPrice (assoc :gasPrice (money/bignumber gasPrice))

View File

@ -66,7 +66,7 @@
(rf/defn get-cached-balances (rf/defn get-cached-balances
[{:keys [db]} scan-all-tokens?] [{:keys [db]} scan-all-tokens?]
(let [addresses (map (comp string/lower-case :address) (let [addresses (map (comp string/lower-case :address)
(get db :multiaccount/accounts))] (get db :profile/wallet-accounts))]
{:wallet/get-cached-balances {:wallet/get-cached-balances
{:addresses addresses {:addresses addresses
:on-success #(re-frame/dispatch [::set-cached-balances addresses % scan-all-tokens?]) :on-success #(re-frame/dispatch [::set-cached-balances addresses % scan-all-tokens?])
@ -155,11 +155,11 @@
{:events [::fetch-collectibles-collection]} {:events [::fetch-collectibles-collection]}
[{:keys [db]}] [{:keys [db]}]
(let [addresses (map (comp string/lower-case :address) (let [addresses (map (comp string/lower-case :address)
(get db :multiaccount/accounts)) (get db :profile/wallet-accounts))
chain-id (-> db chain-id (-> db
ethereum/current-network ethereum/current-network
ethereum/network->chain-id)] ethereum/network->chain-id)]
(when (get-in db [:multiaccount :opensea-enabled?]) (when (get-in db [:profile/profile :opensea-enabled?])
{:json-rpc/call (map {:json-rpc/call (map
(fn [address] (fn [address]
{:method "wallet_getOpenseaCollectionsByOwner" {:method "wallet_getOpenseaCollectionsByOwner"
@ -230,16 +230,18 @@
(rf/defn update-balances (rf/defn update-balances
{:events [:wallet/update-balances]} {:events [:wallet/update-balances]}
[{{:keys [network-status :wallet/all-tokens [{{:keys [network-status]
multiaccount :multiaccount/accounts] :wallet/keys [all-tokens]
:as db} :profile/keys [profile wallet-accounts]
:as db}
:db :db
:as cofx} addresses scan-all-tokens?] :as cofx} addresses scan-all-tokens?]
(log/debug "update-balances" (log/debug "update-balances"
"accounts" addresses "accounts" addresses
"scan-all-tokens?" scan-all-tokens?) "scan-all-tokens?" scan-all-tokens?)
(let [addresses (or addresses (map (comp string/lower-case :address) accounts)) (let [addresses (or addresses
{:keys [:wallet/visible-tokens]} multiaccount (map (comp string/lower-case :address) wallet-accounts))
{:keys [:wallet/visible-tokens]} profile
chain (ethereum/chain-keyword db) chain (ethereum/chain-keyword db)
assets (get visible-tokens chain) assets (get visible-tokens chain)
tokens (->> (vals all-tokens) tokens (->> (vals all-tokens)
@ -306,9 +308,9 @@
(get-in db [:wallet :accounts]))) (get-in db [:wallet :accounts])))
(rf/defn update-toggle-in-settings (rf/defn update-toggle-in-settings
[{{:keys [multiaccount] :as db} :db :as cofx} symbol checked?] [{{:profile/keys [profile] :as db} :db :as cofx} symbol checked?]
(let [chain (ethereum/chain-keyword db) (let [chain (ethereum/chain-keyword db)
visible-tokens (get multiaccount :wallet/visible-tokens)] visible-tokens (get profile :wallet/visible-tokens)]
(rf/merge cofx (rf/merge cofx
(multiaccounts.update/multiaccount-update (multiaccounts.update/multiaccount-update
:wallet/visible-tokens :wallet/visible-tokens
@ -353,7 +355,7 @@
{:events [::tokens-found]} {:events [::tokens-found]}
[{:keys [db] :as cofx} balances] [{:keys [db] :as cofx} balances]
(let [chain (ethereum/chain-keyword db) (let [chain (ethereum/chain-keyword db)
visible-tokens (get-in db [:multiaccount :wallet/visible-tokens]) visible-tokens (get-in db [:profile/profile :wallet/visible-tokens])
chain-visible-tokens (into (or (config/default-visible-tokens chain) chain-visible-tokens (into (or (config/default-visible-tokens chain)
#{}) #{})
(flatten (map keys (vals balances))))] (flatten (map keys (vals balances))))]
@ -460,7 +462,7 @@
amount-text (str (money/internal->formatted value symbol decimals))] amount-text (str (money/internal->formatted value symbol decimals))]
{:db (assoc db {:db (assoc db
:wallet/prepare-transaction :wallet/prepare-transaction
{:from (ethereum/get-default-account (:multiaccount/accounts db)) {:from (ethereum/get-default-account (:profile/wallet-accounts db))
:to (or (get-in db [:contacts/contacts identity]) :to (or (get-in db [:contacts/contacts identity])
(-> identity (-> identity
contact.db/public-key->new-contact contact.db/public-key->new-contact
@ -515,7 +517,7 @@
(cond-> {:db (assoc db (cond-> {:db (assoc db
:wallet/prepare-transaction :wallet/prepare-transaction
{:from (ethereum/get-default-account {:from (ethereum/get-default-account
(:multiaccount/accounts db)) (:profile/wallet-accounts db))
:to contact :to contact
:symbol :ETH :symbol :ETH
:from-chat? true}) :from-chat? true})
@ -535,7 +537,7 @@
(let [identity (:current-chat-id db)] (let [identity (:current-chat-id db)]
{:db (assoc db {:db (assoc db
:wallet/prepare-transaction :wallet/prepare-transaction
{:from (ethereum/get-default-account (:multiaccount/accounts db)) {:from (ethereum/get-default-account (:profile/wallet-accounts db))
:to (or (get-in db [:contacts/contacts identity]) :to (or (get-in db [:contacts/contacts identity])
(-> identity (-> identity
contact.db/public-key->new-contact contact.db/public-key->new-contact
@ -709,7 +711,7 @@
(rf/defn check-recent-history (rf/defn check-recent-history
[{:keys [db] :as cofx} [{:keys [db] :as cofx}
{:keys [on-recent-history-fetching force-restart?]}] {:keys [on-recent-history-fetching force-restart?]}]
(let [addresses (map :address (get db :multiaccount/accounts)) (let [addresses (map :address (get db :profile/wallet-accounts))
old-timeout (get db :wallet-service/restart-timeout) old-timeout (get db :wallet-service/restart-timeout)
timeout (if force-restart? timeout (if force-restart?
old-timeout old-timeout
@ -729,7 +731,7 @@
[{:keys [db] :as cofx} [{:keys [db] :as cofx}
{:keys [force-restart? on-recent-history-fetching] {:keys [force-restart? on-recent-history-fetching]
:as params}] :as params}]
(when (:multiaccount db) (when (:profile/profile db)
(let [syncing-allowed? (mobile-network-utils/syncing-allowed? cofx) (let [syncing-allowed? (mobile-network-utils/syncing-allowed? cofx)
binance-chain? (ethereum/binance-chain? db)] binance-chain? (ethereum/binance-chain? db)]
(log/info "restart-wallet-service" (log/info "restart-wallet-service"
@ -832,7 +834,7 @@
(rf/defn wallet-will-focus (rf/defn wallet-will-focus
{:events [::wallet-stack]} {:events [::wallet-stack]}
[{:keys [db]}] [{:keys [db]}]
(let [wallet-set-up-passed? (get-in db [:multiaccount :wallet-set-up-passed?]) (let [wallet-set-up-passed? (get-in db [:profile/profile :wallet-set-up-passed?])
sign-phrase-showed? (get db :wallet/sign-phrase-showed?)] sign-phrase-showed? (get db :wallet/sign-phrase-showed?)]
{:dispatch-n [[:wallet.ui/pull-to-refresh]] ;TODO temporary simple fix for v1 {:dispatch-n [[:wallet.ui/pull-to-refresh]] ;TODO temporary simple fix for v1
;;[:show-popover {:view [signing-phrase/signing-phrase]}]] ;;[:show-popover {:view [signing-phrase/signing-phrase]}]]

View File

@ -51,7 +51,7 @@
[{{:keys [network-status :wallet/all-tokens] [{{:keys [network-status :wallet/all-tokens]
{:keys [currency :wallet/visible-tokens] {:keys [currency :wallet/visible-tokens]
:or {currency :usd}} :or {currency :usd}}
:multiaccount :profile/profile
:as db} :as db}
:db}] :db}]
(let [chain (ethereum/chain-keyword db) (let [chain (ethereum/chain-keyword db)

View File

@ -238,7 +238,7 @@
(rf/defn wallet-connect-send-async (rf/defn wallet-connect-send-async
[cofx {:keys [method params id] :as payload} message-id topic] [cofx {:keys [method params id] :as payload} message-id topic]
(let [message? (browser/web3-sign-message? method) (let [message? (browser/web3-sign-message? method)
dapps-address (get-in cofx [:db :multiaccount :dapps-address]) dapps-address (get-in cofx [:db :profile/profile :dapps-address])
accounts (get-in cofx [:db :multiaccount/visible-accounts]) accounts (get-in cofx [:db :multiaccount/visible-accounts])
typed? (and (not= constants/web3-personal-sign method) typed? (and (not= constants/web3-personal-sign method)
(not= constants/web3-eth-sign method))] (not= constants/web3-eth-sign method))]

View File

@ -51,7 +51,7 @@
(defn- left-section (defn- left-section
[{:keys [avatar]}] [{:keys [avatar]}]
(let [{:keys [public-key]} (rf/sub [:multiaccount]) (let [{:keys [public-key]} (rf/sub [:profile/profile])
online? (rf/sub [:visibility-status-updates/online? public-key])] online? (rf/sub [:visibility-status-updates/online? public-key])]
[rn/touchable-without-feedback {:on-press #(rf/dispatch [:navigate-to :my-profile])} [rn/touchable-without-feedback {:on-press #(rf/dispatch [:navigate-to :my-profile])}
[rn/view [rn/view

View File

@ -49,5 +49,5 @@
(rf/defn set-log-level (rf/defn set-log-level
[{:keys [db]} log-level] [{:keys [db]} log-level]
(let [log-level (or log-level config/log-level)] (let [log-level (or log-level config/log-level)]
{:db (assoc-in db [:multiaccount :log-level] log-level) {:db (assoc-in db [:profile/profile :log-level] log-level)
:logs/set-level log-level})) :logs/set-level log-level}))

View File

@ -0,0 +1,8 @@
(ns status-im2.common.theme.events
(:require [re-frame.core :as re-frame]
[status-im2.common.theme.core :as theme]))
(re-frame/reg-fx
:theme/init-theme
(fn []
(theme/add-device-theme-change-listener)))

View File

@ -95,7 +95,7 @@
(rf/defn set-new-identity (rf/defn set-new-identity
{:events [:contacts/set-new-identity]} {:events [:contacts/set-new-identity]}
[{:keys [db]} input scanned] [{:keys [db]} input scanned]
(let [user-public-key (get-in db [:multiaccount :public-key]) (let [user-public-key (get-in db [:profile/profile :public-key])
{:keys [input id ens state] {:keys [input id ens state]
:as contact} (-> {:user-public-key user-public-key :as contact} (-> {:user-public-key user-public-key
:input input :input input

View File

@ -75,7 +75,7 @@
;;; event handler tests (no callbacks) ;;; event handler tests (no callbacks)
(def db (def db
{:multiaccount {:public-key user-ukey} {:profile/profile {:public-key user-ukey}
:networks/current-network "mainnet_rpc" :networks/current-network "mainnet_rpc"
:networks/networks {"mainnet_rpc" :networks/networks {"mainnet_rpc"
{:id "mainnet_rpc" {:id "mainnet_rpc"

Some files were not shown because too many files have changed in this diff Show More