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

View File

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

View File

@ -385,7 +385,7 @@
(rf/defn web3-send-async
[cofx dapp-name {:keys [method params id] :as payload} message-id]
(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)
(not= constants/web3-eth-sign method))]
(if (or message? (= constants/web3-send-transaction method))

View File

@ -42,7 +42,7 @@
(defn get-permission-data
[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)
constants/dapp-permission-web3 [(:dapps-address multiaccount)]}
allowed-permission)))

View File

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

View File

@ -148,7 +148,7 @@
(when-not (string/blank? input-text)
(let [{:keys [message-id]}
(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
:response-to message-id})]
{:chat-id current-chat-id

View File

@ -83,7 +83,7 @@
[{db :db} chat-id]
{:db (mark-chat-all-read db 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"
:params [chat-id]
:on-success #(re-frame/dispatch [::mark-all-read-successful])}]})
@ -94,7 +94,7 @@
(let [community-chat-ids (map #(str community-id %)
(keys (get-in db [:communities community-id :chats])))]
{: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"
:params [community-id]
:on-success #(re-frame/dispatch

View File

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

View File

@ -102,7 +102,7 @@
(rf/defn handle-requests-to-join
[{: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}]
(let [my-request? (= my-public-key public-key)]
(if my-request?
@ -278,7 +278,7 @@
(let [community-chat-ids (map #(str community-id %)
(keys (get-in db [:communities community-id :chats])))]
{: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]
:json-rpc/call [{:method "wakuext_leaveCommunity"
:params [community-id]
@ -795,14 +795,14 @@
(rf/defn store-category-state
{:events [::store-category-state]}
[{: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)]
{::async-storage/set! {hash state-open?}}))
(rf/defn update-category-states-in-db
{:events [::category-states-loaded]}
[{: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 (reduce (fn [acc [category-id category]]
(let [hash (get hashes category-id)
@ -816,7 +816,7 @@
(rf/defn load-category-states
{:events [:communities/load-category-states]}
[{: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])
{:keys [keys hashes]} (reduce (fn [acc category]
(let [category-id (get category 0)

View File

@ -49,7 +49,7 @@
(assoc-in [:contacts/contacts public-key :added?] false))
:dispatch [:shell/close-switcher-card public-key]
: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)
fxs)))

View File

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

View File

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

View File

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

View File

@ -82,7 +82,7 @@
(defn current-address
[db]
(-> (get-in db [:multiaccount :address])
(-> (get-in db [:profile/profile :address])
normalized-hex))
(defn get-default-account
@ -91,7 +91,7 @@
(defn default-address
[db]
(-> (get db :multiaccount/accounts)
(-> (get db :profile/wallet-accounts)
get-default-account
:address))
@ -99,7 +99,7 @@
[db]
(into #{}
(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
[s]

View File

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

View File

@ -117,11 +117,11 @@
(rf/defn system-theme-mode-changed
{:events [:system-theme-mode-changed]}
[{: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)
(= current-theme-type status-im2.constants/theme-type-system))
{:multiaccounts.ui/switch-theme-fx
[(get-in db [:multiaccount :appearance])
[(get-in db [:profile/profile :appearance])
(:view-id db) true]})))
(def authentication-options
@ -146,7 +146,7 @@
[{:keys [db now] :as cofx}]
(let [new-account? (get db :onboarding-2/new-account?)
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")
requires-bio-auth (and
signed-up?
@ -202,7 +202,7 @@
(cond
(= :chat view-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)}
(= :login view-id)
@ -291,7 +291,7 @@
(rf/defn close-information-box
{:events [:close-information-box]}
[{: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?)]
{::async-storage/set! {hash true}
:db (assoc-in db [:information-box-states id] true)}))
@ -310,7 +310,7 @@
(rf/defn load-information-box-states
{:events [:load-information-box-states]}
[{: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?]}]
(let [hash (information-box-id-hash
id

View File

@ -75,7 +75,7 @@
(rf/defn save
{:events [:fleet.ui/save-fleet-confirmed]}
[{: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)
(rf/merge
cofx

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,7 +11,7 @@
(rf/defn delete-card
[{:keys [db] :as cofx}]
(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
(= key-uid multiaccount-key-uid))
{:keycard/delete nil}

View File

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

View File

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

View File

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

View File

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

View File

@ -119,13 +119,13 @@
(defn handle-account-removal
[{: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])
pairings (get-in db [:keycard :pairings])]
(rf/merge
cofx
{:db (-> db
(update :multiaccounts/multiaccounts dissoc key-uid)
(update :profile/profiles-overview dissoc key-uid)
(assoc-in [:keycard :secrets] nil)
(update-in [:keycard :pairings]
dissoc

View File

@ -34,7 +34,7 @@
(rf/defn generate-new-keycard-account
{:events [:wallet.accounts/generate-new-keycard-account]}
[{: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)
pin (common/vector->string (get-in db [:keycard :pin :export-key]))]
{:db

View File

@ -8,7 +8,7 @@
(rf/defn save-log-level
{:events [:log-level.ui/change-log-level-confirmed]}
[{: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)
(rf/merge cofx
(multiaccounts.update/multiaccount-update

View File

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

View File

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

View File

@ -101,7 +101,7 @@
(.catch #(cb (generate-error-result %))))))
(re-frame/reg-fx
:get-supported-biometric-auth
:biometric/get-supported-biometric-auth
(fn []
(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
@ -149,8 +149,8 @@
(rf/defn update-biometric
[{db :db :as cofx} biometric-auth?]
(let [key-uid (or (get-in db [:multiaccount :key-uid])
(get-in db [:multiaccounts/login :key-uid]))]
(let [key-uid (or (get-in db [:profile/profile :key-uid])
(get-in db [:profile/login :key-uid]))]
(rf/merge cofx
(keychain/save-auth-method
key-uid
@ -214,7 +214,7 @@
cofx
{:db (-> db
(assoc :auth-method keychain/auth-method-none)
(assoc-in [:multiaccounts/login :save-password?] false))}
(assoc-in [:profile/login :save-password?] false))}
(popover/hide-popover)))
(rf/defn setup-done

View File

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

View File

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

View File

@ -7,7 +7,6 @@
[utils.i18n :as i18n]
[status-im.keycard.backup-key :as keycard.backup]
[status-im.keycard.common :as common]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.multiaccounts.logout.core :as multiaccounts.logout]
[status-im.multiaccounts.model :as multiaccounts.model]
[status-im.multiaccounts.recover.core :as multiaccounts.recover]
@ -29,16 +28,6 @@
:actions-not-logged-in)
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
{:events [::navigate-back]}
[{:keys [db] :as cofx}]
@ -62,18 +51,6 @@
{:db (assoc db :recovered-account? true)}
(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
{:events [::show-seed-key-uid-mismatch-error-popup]}
[cofx _]
@ -116,28 +93,20 @@
:error
string/blank?
not)
onboarding? (not (or (:multiaccounts/login db) (:multiaccount db)))]
onboarding? (not (or (:profile/login db) (:profile/profile db)))]
(if error?
(popover/show-popover cofx {:view :custom-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
;; keys
:key-uid (or (-> db :multiaccounts/login :key-uid)
(-> db :multiaccount :key-uid)
:key-uid (or (-> db :profile/login :key-uid)
(-> db :profile/profile :key-uid)
(and onboarding?
(-> db
:keycard
:application-info
: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
{:events [::keycard-storage-pressed]}
[{: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]}
[{:keys [db] :as cofx}]
(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])))
#(re-frame/dispatch [::verify-password-result %])))

View File

@ -1,31 +1,8 @@
(ns status-im.multiaccounts.key-storage.core-test
(:require [cljs.test :refer-macros [deftest is testing]]
[clojure.string :as string]
[status-im.multiaccounts.key-storage.core :as models]
[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
{:seed-phrase "rocket mixed rebel affair umbrella legal resemble scene virus park deposit cargo"
:key-uid "0x3831d0f22996a65970a214f0a94bfa9a63a21dac235d8dadb91be8e32e7d3ab7"})

View File

@ -16,7 +16,6 @@
[status-im.ethereum.transactions.core :as transactions]
[status-im.fleet.core :as fleet]
[utils.i18n :as i18n]
[status-im.keycard.common :as keycard.common]
[status-im.mobile-sync-settings.core :as mobile-network]
[status-im.multiaccounts.biometric.core :as biometric]
[status-im.multiaccounts.core :as multiaccounts]
@ -46,7 +45,8 @@
[status-im2.common.log :as logging]
[taoensso.timbre :as log]
[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
::initialize-transactions-management-enabled
@ -146,7 +146,7 @@
(rf/merge
cofx
{:db (assoc db
:multiaccount/accounts
:profile/wallet-accounts
(rpc->accounts accounts))
;; NOTE: Local notifications should be enabled only after wallet was started
::enable-local-notifications nil}
@ -179,7 +179,7 @@
(rf/defn login-local-paired-user
{:events [:multiaccounts.login/local-paired-user]}
[{: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
(types/clj->json {:name name
:key-uid key-uid})
@ -188,9 +188,9 @@
(rf/defn login
{:events [:multiaccounts.login.ui/password-input-submitted]}
[{:keys [db]}]
(let [{:keys [key-uid password name]} (:multiaccounts/login db)]
(let [{:keys [key-uid password name]} (:profile/login db)]
{:db (-> db
(assoc-in [:multiaccounts/login :processing] true)
(assoc-in [:profile/login :processing] true)
(dissoc :intro-wizard :recovered-account?)
(update :keycard dissoc :flow))
::login [key-uid
@ -201,7 +201,7 @@
(rf/defn export-db-submitted
{:events [:multiaccounts.login.ui/export-db-submitted]}
[{:keys [db]}]
(let [{:keys [key-uid password name]} (:multiaccounts/login db)]
(let [{:keys [key-uid password name]} (:profile/login db)]
{::export-db [key-uid
(types/clj->json {:name name
:key-uid key-uid})
@ -216,7 +216,7 @@
(rf/defn import-db-submitted
{:events [:multiaccounts.login.ui/import-db-submitted]}
[{:keys [db]}]
(let [{:keys [key-uid password name]} (:multiaccounts/login db)]
(let [{:keys [key-uid password name]} (:profile/login db)]
{::import-db [key-uid
(types/clj->json {:name name
:key-uid key-uid})
@ -394,7 +394,7 @@
[{:keys [db] :as cofx} node-config-json]
(let [node-config (types/json->clj node-config-json)]
{:db (assoc-in db
[:multiaccount :wakuv2-config]
[:profile/profile :wakuv2-config]
(get node-config :WakuV2Config))}))
(rf/defn get-node-config
@ -438,10 +438,10 @@
merged-networks (merge networks config/default-networks-by-id)]
(rf/merge cofx
{:db (-> db
(dissoc :multiaccounts/login)
(dissoc :profile/login)
(assoc :networks/current-network current-network
:networks/networks merged-networks
:multiaccount multiaccount))}
:profile/profile multiaccount))}
(data-store.chats/fetch-chats-rpc
{:on-success
#(do (re-frame/dispatch [:chats-list/load-success %])
@ -476,29 +476,29 @@
(rf/defn check-last-chat
{:events [::check-last-chat]}
[{: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
[{: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]
(let [address (:address new-acc)]
(if (:removed new-acc)
(dissoc existing-accs address)
(assoc existing-accs address new-acc))))
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
{:events [::get-chats-callback]}
[{:keys [db] :as cofx}]
(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)
network-id (str (get-in networks
[current-network :config :NetworkId]))
remote-push-notifications-enabled?
(get-in db [:multiaccount :remote-push-notifications-enabled?])]
(get-in db [:profile/profile :remote-push-notifications-enabled?])]
(rf/merge cofx
(cond-> {::eip1559/check-eip1559-activation
{:network-id network-id
@ -510,7 +510,7 @@
(fn [accounts tokens custom-tokens favourites]
(re-frame/dispatch [::initialize-wallet
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?)
(assoc ::notifications/enable remote-push-notifications-enabled?))
(transport/start-messenger)
@ -555,23 +555,21 @@
(rf/defn create-only-events
[{:keys [db] :as cofx} recovered-account?]
(let [{:keys [multiaccount
:multiaccounts/multiaccounts
:multiaccount/accounts]}
(let [{:profile/keys [profile profiles-overview wallet-accounts]}
db
{:keys [creating?]} (:multiaccounts/login db)
first-account? (and creating?
(empty? multiaccounts))
{:keys [creating?]} (:profile/login db)
first-account? (and creating? (empty? profiles-overview))
tos-accepted? (get db :tos/accepted?)
{:networks/keys [current-network networks]} db
network-id (str (get-in networks [current-network :config :NetworkId]))]
(shell.utils/change-selected-stack-id :communities-stack true nil)
(rf/merge cofx
{:db (-> db
(dissoc :multiaccounts/login)
(dissoc :profile/login)
(assoc :tos/next-root :enable-notifications :chats/loading? false)
(assoc-in [:multiaccount :multiaccounts/first-account] first-account?))
::get-tokens [network-id accounts recovered-account?]}
(assoc-in [:profile/profile :multiaccounts/first-account]
first-account?))
::get-tokens [network-id wallet-accounts recovered-account?]}
(finish-keycard-setup)
(transport/start-messenger)
(communities/fetch)
@ -579,7 +577,7 @@
{:on-success #(re-frame/dispatch [:chats-list/load-success %])})
(multiaccounts/switch-preview-privacy-mode-flag)
(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))))
(defn- keycard-setup?
@ -595,7 +593,7 @@
:on-card-read
:card-read-in-progress?
:pin
:multiaccount)
:profile/profile)
(assoc :tos-accept-next-root
(if login-only?
:shell-stack
@ -606,9 +604,9 @@
(rf/defn multiaccount-login-success
[{:keys [db now] :as cofx}]
(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?)
login-only? (not (or creating?
recovered-account?
@ -638,29 +636,12 @@
(login-only-events key-uid password save-password?)
(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
{:events [:multiaccounts.login.callback/get-user-password-success]}
[{: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
[:multiaccounts/multiaccounts
[:profile/profiles-overview
key-uid
:keycard-pairing]))
goto-key-storage? (:goto-key-storage? db)]
@ -668,7 +649,7 @@
(rf/merge
cofx
{:db (update-in db
[:multiaccounts/login]
[:profile/login]
assoc
:password password
:save-password? true)
@ -690,7 +671,7 @@
(rf/defn get-credentials
[{:keys [db] :as cofx} key-uid]
(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"
"keycard-multiacc?"
keycard-multiaccount?)
@ -702,12 +683,8 @@
"Auth method: nil - not supported, \"none\" - not selected, \"password\", \"biometric\", \"biometric-prepare\""
{:events [:multiaccounts.login/get-auth-method-success]}
[{:keys [db] :as cofx} auth-method]
(let [key-uid (get-in db [:multiaccounts/login :key-uid])
keycard-multiaccount? (boolean (get-in db
[:multiaccounts/multiaccounts key-uid :keycard-pairing]))]
(log/debug "[login] get-auth-method-success"
"auth-method" auth-method
"keycard-multiacc?" keycard-multiaccount?)
(let [key-uid (get-in db [:profile/login :key-uid])
keycard-profile? (boolean (get-in db [:profile/profiles-overview key-uid :keycard-pairing]))]
(rf/merge
cofx
{:db (assoc db :auth-method auth-method)}
@ -716,15 +693,14 @@
(biometric/biometric-auth %)
(= auth-method keychain/auth-method-password)
(get-credentials % key-uid)
(and keycard-multiaccount?
(get-in db [:keycard :card-connected?]))
(and keycard-profile? (get-in db [:keycard :card-connected?]))
(keycard.common/get-application-info % nil))
(open-login-callback nil))))
(rf/defn biometric-auth-done
{:events [:biometric-auth-done]}
[{: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)]
(log/debug "[biometric] biometric-auth-done"
"bioauth-success" bioauth-success
@ -734,7 +710,7 @@
(get-credentials cofx key-uid)
(rf/merge cofx
{:db (assoc-in db
[:multiaccounts/login :save-password?]
[:profile/login :save-password?]
(= auth-method keychain/auth-method-biometric))}
(when-not (= auth-method keychain/auth-method-biometric)
(keychain/save-auth-method key-uid keychain/auth-method-none))
@ -761,7 +737,7 @@
(and (not save-password?)
bioauth-supported?
(= 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?
(if save-password?
(popover/show-popover {:view :secure-with-biometric})
@ -773,21 +749,6 @@
[_]
{: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
{:events [:hide-keycard-banner]}
[{:keys [db]}]

View File

@ -11,16 +11,16 @@
:supported-biometric-auth false}}
{:keys [db]} (login/save-password initial-cofx true)]
(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"
(let [{:keys [db]} (login/save-password {:db db} false)]
(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"
(let [initial-cofx {:db {:auth-method keychain/auth-method-none
:supported-biometric-auth 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"
(let [{:keys [db] :as res} (biometric/enable {:db db})]
(test/is (contains? res :biometric-auth/authenticate))
@ -53,10 +53,10 @@
:bioauth-message nil
:bioauth-code nil}))
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
(test/is (= keychain/auth-method-biometric-prepare (:auth-method db)))
(test/testing "disable biometric"
(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))))))))

View File

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

View File

@ -12,7 +12,7 @@
(rf/defn logout-method
{:events [::logout-method]}
[{: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
{:set-root :progress
:chat.ui/clear-inputs nil
@ -21,8 +21,9 @@
::logout nil
::multiaccounts/webview-debug-changed false
:keychain/clear-user-password key-uid
:setup/open-multiaccounts #(re-frame/dispatch [:setup/initialize-multiaccounts
% {:logout? logout?}])}
:profile/get-profiles-overview #(re-frame/dispatch
[:profile/get-profiles-overview-success
%])}
(keychain/save-auth-method key-uid auth-method)
(wallet/clear-timeouts)
(init/initialize-app-db))))
@ -56,7 +57,7 @@
(logout-method {:auth-method keychain/auth-method-biometric-prepare
:logout? false})
(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
::logout

View File

@ -1,13 +1,5 @@
(ns status-im.multiaccounts.model)
(defn logged-in?
[{:keys [multiaccount]}]
(boolean multiaccount))
(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]))
[{:keys [profile/profile]}]
(boolean profile))

View File

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

View File

@ -6,14 +6,12 @@
[status-im.ethereum.core :as ethereum]
[status-im.ethereum.mnemonic :as mnemonic]
[utils.i18n :as i18n]
[status-im.keycard.nfc :as nfc]
[status-im.multiaccounts.core :as multiaccounts]
[status-im.multiaccounts.create.core :as multiaccounts.create]
[native-module.core :as native-module]
[status-im.popover.core :as popover]
[utils.re-frame :as rf]
[status-im.utils.types :as types]
[status-im.utils.utils :as utils]
[status-im2.navigation.events :as navigation]
[taoensso.timbre :as log]
[utils.security.core :as security]))
@ -31,13 +29,12 @@
{:events [:multiaccounts.recover/passphrase-input-changed]}
[{:keys [db]} masked-recovery-phrase]
(let [recovery-phrase (security/safe-unmask-data masked-recovery-phrase)]
(rf/merge
{:db (update db
:intro-wizard assoc
:passphrase (string/lower-case recovery-phrase)
:passphrase-error nil
:next-button-disabled? (or (empty? recovery-phrase)
(not (mnemonic/valid-length? recovery-phrase))))})))
{:db (update db
:intro-wizard assoc
:passphrase (string/lower-case recovery-phrase)
:passphrase-error nil
:next-button-disabled? (or (empty? recovery-phrase)
(not (mnemonic/valid-length? recovery-phrase))))}))
(rf/defn validate-phrase-for-warnings
[{:keys [db]}]
@ -58,7 +55,7 @@
:on-dismiss #(re-frame/dispatch [:pop-to-root :multiaccounts])}}
(let [{:keys [key-uid] :as multiaccount} (get-in db [:intro-wizard :root-key])
keycard-multiaccount? (boolean (get-in db
[:multiaccounts/multiaccounts key-uid
[:profile/profiles-overview key-uid
:keycard-pairing]))]
(if keycard-multiaccount?
;; trying to recover multiaccount created with keycard
@ -122,13 +119,13 @@
:on-accept #(do
(re-frame/dispatch [:pop-to-root :multiaccounts])
(re-frame/dispatch
[:multiaccounts.login.ui/multiaccount-selected key-uid]))
[:profile/profile-selected key-uid]))
:on-cancel #(re-frame/dispatch [:pop-to-root :multiaccounts])}})
(rf/defn on-import-multiaccount-success
{:events [::import-multiaccount-success]}
[{: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
cofx
{:db (update db
@ -178,106 +175,3 @@
{::multiaccounts/validate-mnemonic [passphrase
#(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
(testing "importing a new multiaccount"
(let [res (models/on-import-multiaccount-success
{:db {:multiaccounts/multiaccounts {:acc1 {}}}}
{:db {:profile/profiles-overview {:acc1 {}}}}
{:key-uid :acc2}
nil)]
(is (nil? (:utils/show-confirmation res)))))
(testing "importing an existing multiaccount"
(let [res (models/on-import-multiaccount-success
{:db {:multiaccounts/multiaccounts {:acc1 {}}}}
{:db {:profile/profiles-overview {:acc1 {}}}}
{:key-uid :acc1}
nil)]
(is (contains? res :utils/show-confirmation)))))

View File

@ -35,7 +35,7 @@
(rf/defn password-reset-success
{:events [::password-reset-success]}
[{: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)
new-password (get-in db [:multiaccount/reset-password-form-vals :new-password])]
(rf/merge cofx
@ -68,7 +68,7 @@
(rf/defn handle-verification-success
{:events [::handle-verification-success]}
[{:keys [db] :as cofx} form-vals]
(let [{:keys [key-uid name]} (:multiaccount db)]
(let [{:keys [key-uid name]} (:profile/profile db)]
(rf/merge cofx
{::change-db-password [key-uid form-vals]
:db (assoc db
@ -98,4 +98,4 @@
{::validate-current-password-and-reset
(assoc form-vals
: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
[{: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"
:params [(or preferred-name display-name name) ""]
:on-success #(log/debug "sent contact update")}]}))
@ -16,7 +16,7 @@
{:events [:multiaccounts.ui/update-name]}
[{:keys [db] :as cofx} raw-multiaccounts-from-status-go]
(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)]
(when-let [new-name (and account (or preferred-name display-name name))]
(rf/merge cofx
@ -30,7 +30,7 @@
[{:keys [db] :as cofx}
setting setting-value
{:keys [dont-sync? on-success] :or {on-success #()}}]
(let [current-multiaccount (:multiaccount db)]
(let [current-multiaccount (:profile/profile db)]
(if (empty? current-multiaccount)
;; 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
@ -40,15 +40,15 @@
(rf/merge
cofx
{:db (if setting-value
(assoc-in db [:multiaccount setting] setting-value)
(update db :multiaccount dissoc setting))
(assoc-in db [:profile/profile setting] setting-value)
(update db :profile/profile dissoc setting))
:json-rpc/call
[{:method "settings_saveSetting"
:params [setting setting-value]
:on-success on-success}]}
(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))
(send-contact-update))))))
@ -73,7 +73,7 @@
(rf/defn optimistic
[{:keys [db] :as cofx} setting setting-value]
(let [current-multiaccount (:multiaccount db)
(let [current-multiaccount (:profile/profile db)
setting-value (if (= :currency setting)
(keyword setting-value)
setting-value)
@ -97,8 +97,8 @@
(assoc db :stickers/recent-stickers recent-stickers-from-remote))
db)]
{:db (if setting-value
(assoc-in db [:multiaccount setting] setting-value)
(update db :multiaccount dissoc setting))}))
(assoc-in db [:profile/profile setting] setting-value)
(update db :profile/profile dissoc setting))}))
(rf/defn set-many-js
[cofx settings-js]
@ -119,7 +119,7 @@
{:events [::toggle-opensea-nfts-visiblity]}
[cofx visible?]
(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
:dispatch [:status-im.wallet.core/fetch-collectibles-collection]}
(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
;;there is no changes, but it is an edge case that shouldn't really happen
(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
{})
json-rpc (into #{} (map :method (:json-rpc/call efx)))]
(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
(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)))]
(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
(let [cofx {:db {:multiaccount {:key-uid 1
:name "name"
:preferred-name "preferred-name"
:display-name "display-name"}}}
(let [cofx {:db {:profile/profile {:key-uid 1
:name "name"
:preferred-name "preferred-name"
:display-name "display-name"}}}
raw-multiaccounts-from-status-go [{:key-uid 1 :name "old-name"}]]
(testing "wrong account"
(is (nil? (multiaccounts.update/update-multiaccount-account-name cofx []))))
@ -46,11 +46,11 @@
"preferred-name"))
(is (new-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)
"display-name"))
(is (new-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)
"name"))))))

View File

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

View File

@ -13,7 +13,7 @@
{:db (assoc db :network-status (if is-connected? :online :offline))}
(when (and is-connected?
(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/update-balances nil nil))))

View File

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

View File

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

View File

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

View File

@ -57,7 +57,7 @@
(rf/defn enter-two-random-words
{:events [:my-profile/enter-two-random-words]}
[{:keys [db]}]
(let [{:keys [mnemonic]} (:multiaccount db)
(let [{:keys [mnemonic]} (:profile/profile db)
shuffled-mnemonic (shuffle (map-indexed vector (string/split mnemonic #" ")))]
{:db (assoc db
:my-profile/seed
@ -88,7 +88,7 @@
(rf/defn show-profile
{:events [:chat.ui/show-profile]}
[{: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)
{:db (-> db
(assoc :contacts/identity identity)

View File

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

View File

@ -21,8 +21,8 @@
(if error
(cond->
{:db (-> db
(update :multiaccounts/login dissoc :processing)
(assoc-in [:multiaccounts/login :error]
(update :profile/login dissoc :processing)
(assoc-in [:profile/login :error]
;; NOTE: the only currently known error is
;; "file is not a database" which occurs
;; when the user inputs the wrong password
@ -86,7 +86,7 @@
(assoc-in [:syncing :pairing-status] :connected)
received-account?
(assoc-in [:syncing :multiaccount] multiaccount-data)
(assoc-in [:syncing :profile/profile] multiaccount-data)
error-on-pairing?
(assoc-in [:syncing :pairing-status] :error)
@ -120,7 +120,9 @@
type (.-type data)]
(case type
"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
(:ids
(js->clj event-js

View File

@ -245,8 +245,8 @@
{:keys [data typed? pinless?] :as message} :message
:as tx}
(last queue)
keycard-multiaccount? (boolean (get-in db [:multiaccount :keycard-pairing]))
wallet-set-up-passed? (get-in db [:multiaccount :wallet-set-up-passed?])]
keycard-multiaccount? (boolean (get-in db [:profile/profile :keycard-pairing]))
wallet-set-up-passed? (get-in db [:profile/profile :wallet-set-up-passed?])]
(if message
(rf/merge
cofx
@ -349,7 +349,7 @@
[{:keys [db] :as cofx} transaction-hash hashed-password
{:keys [message-id chat-id from] :as tx-obj}]
(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))]
(rf/merge
cofx

View File

@ -14,7 +14,6 @@
[status-im.data-store.reactions :as data-store.reactions]
[status-im.group-chats.core :as models.group]
[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.pairing.core :as models.pairing]
[utils.re-frame :as rf]
@ -209,7 +208,7 @@
new
(not (= message-type
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)
(.-commandParameters.transactionHash message-js))]
(cond-> acc

View File

@ -88,7 +88,7 @@
(letsubs [{:keys [peers node mobile sync]} [:connectivity/state]
current-mailserver-name [:mailserver/current-name]
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/list-header (i18n/label :t/peer-to-peer)]

View File

@ -13,7 +13,7 @@
(rf/defn share-link
{:events [:invite.events/share-link]}
[{: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
:external
(or preferred-name

View File

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

View File

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

View File

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

View File

@ -251,7 +251,7 @@
[:browser/options]
dapps-account [:dapps-account]
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)
can-go-forward? (browser/can-go-forward? browser)
url-original (browser/get-current-url browser)]

View File

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

View File

@ -611,7 +611,7 @@
(defn- welcome
[]
(let [name (:name @(re-frame/subscribe [:multiaccount]))]
(let [name (:name @(re-frame/subscribe [:profile/profile]))]
[react/view {:style {:flex 1}}
[react/scroll-view {:content-container-style {:align-items :center}}
[react/image
@ -761,8 +761,8 @@
(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}}
(if (or (seq names) registrations)
[registered names multiaccount show? registrations]
[registered names profile show? registrations]
[welcome])]))

View File

@ -88,7 +88,7 @@
(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])]
(when-not (and platform/android? (not auth-method))
[react/view

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,7 +39,7 @@
{:events [::delete-profile]}
[{:keys [db] :as cofx} masked-password]
(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)
::delete-profile
{:masked-password masked-password

View File

@ -17,7 +17,7 @@
(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}
[quo/list-item
{:active (not messages-from-contacts-only)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -221,11 +221,6 @@
(-> (.resetInternetCredentials react-native-keychain (string/lower-case key-uid))
(.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
[_ key-uid]
{:keychain/get-user-password

View File

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

View File

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

View File

@ -2,7 +2,7 @@
(defn has-paired-installations?
[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])
vals

View File

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

View File

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

View File

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

View File

@ -41,7 +41,7 @@
(let [custom-nodes (into {}
(map #(vector (random-guid-generator)
{: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
{:db (assoc db :wakuv2-nodes/list custom-nodes)
:dispatch [:navigate-to :wakuv2-settings]})))
@ -109,7 +109,7 @@
(into {}))]
(rf/merge cofx
{: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))
:dispatch [:navigate-back]}
(node/prepare-new-config

View File

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

View File

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

View File

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

View File

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

View File

@ -238,7 +238,7 @@
(rf/defn wallet-connect-send-async
[cofx {:keys [method params id] :as payload} message-id topic]
(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])
typed? (and (not= constants/web3-personal-sign method)
(not= constants/web3-eth-sign method))]

View File

@ -51,7 +51,7 @@
(defn- left-section
[{: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])]
[rn/touchable-without-feedback {:on-press #(rf/dispatch [:navigate-to :my-profile])}
[rn/view

View File

@ -49,5 +49,5 @@
(rf/defn set-log-level
[{:keys [db]} 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}))

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
{:events [:contacts/set-new-identity]}
[{: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]
:as contact} (-> {:user-public-key user-public-key
:input input

View File

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

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