diff --git a/src/status_im2/contexts/profile/create/events.cljs b/src/status_im2/contexts/profile/create/events.cljs index d4f57dec0c1d..355b744334b4 100644 --- a/src/status_im2/contexts/profile/create/events.cljs +++ b/src/status_im2/contexts/profile/create/events.cljs @@ -1,32 +1,19 @@ (ns status-im2.contexts.profile.create.events (:require [native-module.core :as native-module] -<<<<<<< HEAD -======= - [re-frame.core :as re-frame] [status-im2.contexts.emoji-picker.utils :as emoji-picker.utils] ->>>>>>> 3e7d48f12 (review) [status-im2.contexts.profile.config :as profile.config] status-im2.contexts.profile.create.effects [utils.re-frame :as rf] [utils.security.core :as security])) (rf/defn create-profile-and-login - {:events [:profile.create/create-and-login]} -<<<<<<< HEAD -<<<<<<< HEAD - [_ {:keys [display-name password image-path color]}] - {:effects.profile/create-and-login -======= - [_ {:keys [display-name password image-path color emoji]}] -======= - [_ {:keys [display-name password image-path color]}] ->>>>>>> d46724bcf (qa) - {::create-profile-and-login ->>>>>>> c1d06ad1d (wallet: add color and emoji) - (assoc (profile.config/create) - :displayName display-name - :password (native-module/sha3 (security/safe-unmask-data password)) - :imagePath (profile.config/strip-file-prefix image-path) - :customizationColor color - :emoji (emoji-picker.utils/random-emoji))}) + {:events [:profile.create/create-and-login]} + [_ {:keys [display-name password image-path color]}] + {:effects.profile/create-and-login + (assoc (profile.config/create) + :displayName display-name + :password (native-module/sha3 (security/safe-unmask-data password)) + :imagePath (profile.config/strip-file-prefix image-path) + :customizationColor color + :emoji (emoji-picker.utils/random-emoji))}) diff --git a/src/status_im2/contexts/profile/recover/events.cljs b/src/status_im2/contexts/profile/recover/events.cljs index 84fb64623de3..f136da5ac938 100644 --- a/src/status_im2/contexts/profile/recover/events.cljs +++ b/src/status_im2/contexts/profile/recover/events.cljs @@ -1,37 +1,19 @@ (ns status-im2.contexts.profile.recover.events (:require [native-module.core :as native-module] -<<<<<<< HEAD -======= - [re-frame.core :as re-frame] [status-im2.contexts.emoji-picker.utils :as emoji-picker.utils] ->>>>>>> d46724bcf (qa) [status-im2.contexts.profile.config :as profile.config] status-im2.contexts.profile.recover.effects [utils.re-frame :as rf] [utils.security.core :as security])) (rf/defn recover-profile-and-login -<<<<<<< HEAD - {:events [:profile.recover/recover-and-login]} - [{:keys [db]} {:keys [display-name password image-path color seed-phrase]}] - {:db - (assoc db :onboarding/recovered-account? true) - - :effects.profile/restore-and-login - (merge (profile.config/create) - {:displayName display-name - :mnemonic (security/safe-unmask-data seed-phrase) - :password (native-module/sha3 (security/safe-unmask-data password)) - :imagePath (profile.config/strip-file-prefix image-path) - :customizationColor color})}) -======= {:events [:profile.recover/recover-and-login]} [{:keys [db]} {:keys [display-name password image-path color seed-phrase]}] {:db - (assoc db :onboarding-2/recovered-account? true) + (assoc db :onboarding/recovered-account? true) - ::restore-profile-and-login + :effects.profile/restore-and-login (merge (profile.config/create) {:displayName display-name :mnemonic (security/safe-unmask-data seed-phrase) @@ -39,4 +21,3 @@ :imagePath (profile.config/strip-file-prefix image-path) :customizationColor color :emoji (emoji-picker.utils/random-emoji)})}) ->>>>>>> d46724bcf (qa) diff --git a/src/status_im2/contexts/wallet/account/view.cljs b/src/status_im2/contexts/wallet/account/view.cljs index 608aba9a198d..f65512c70bee 100644 --- a/src/status_im2/contexts/wallet/account/view.cljs +++ b/src/status_im2/contexts/wallet/account/view.cljs @@ -28,41 +28,15 @@ (cond-> [{:id :assets :label (i18n/label :t/assets) :accessibility-label :assets-tab} {:id :collectibles :label (i18n/label :t/collectibles) :accessibility-label :collectibles-tab} {:id :activity :label (i18n/label :t/activity) :accessibility-label :activity-tab}] - (not watch-only?) (conj {:id :dapps :label (i18n/label :t/dapps) :accessibility-label :dapps}) - true (conj {:id :about :label (i18n/label :t/about) :accessibility-label :about}))) + (not watch-only?) (conj {:id :dapps :label (i18n/label :t/dapps) :accessibility-label :dapps}) + true (conj {:id :about :label (i18n/label :t/about) :accessibility-label :about}))) (defn view [] (let [selected-tab (reagent/atom first-tab-id)] (fn [] -<<<<<<< HEAD -<<<<<<< HEAD (let [{:keys [name color balance type]} (rf/sub [:wallet/current-viewing-account]) watch-only? (= type :watch)] -======= -<<<<<<< HEAD - (let [{:keys [name color balance]} (rf/sub [:wallet/current-viewing-account]) - ] -======= - (let [{:keys [name color emoji balance]} (rf/sub [:wallet/current-viewing-account]) -<<<<<<< HEAD - networks (rf/sub [:wallet/network-details]) - profile1 (rf/sub [:profile/wallet-accounts]) - profile2 (rf/sub [:wallet/accounts])] - ;(println "profile1: " profile1) - ;(println "profile2: " profile2) ->>>>>>> 8bcb90b41 (wallet: add color and emoji) -<<<<<<< HEAD ->>>>>>> c1d06ad1d (wallet: add color and emoji) -======= -======= - networks (rf/sub [:wallet/network-details])] ->>>>>>> aa35edaf6 (lint) ->>>>>>> 9c3ec27ba (lint) -======= - (let [{:keys [name color balance]} (rf/sub [:wallet/current-viewing-account]) - ] ->>>>>>> 0ae3804f1 (rebase) [rn/view {:style {:flex 1}} [account-switcher/view {:on-press #(rf/dispatch [:wallet/close-account-page])}] [quo/account-overview diff --git a/src/status_im2/contexts/wallet/events.cljs b/src/status_im2/contexts/wallet/events.cljs index ff80f91e1ba6..fb78def94f62 100644 --- a/src/status_im2/contexts/wallet/events.cljs +++ b/src/status_im2/contexts/wallet/events.cljs @@ -17,208 +17,200 @@ [utils.transforms :as types])) (rf/reg-event-fx :wallet/show-account-created-toast - (fn [{:keys [db]} [address]] - (let [account (get-in db [:wallet :accounts address])] - {:db (update db :wallet dissoc :navigate-to-account :new-account?) - :fx [[:dispatch - [:toasts/upsert - {:id :new-wallet-account-created - :icon :i/correct - :icon-color colors/success-50 - :text (i18n/label :t/account-created {:name (:name account)})}]]]}))) + (fn [{:keys [db]} [address]] + (let [account (get-in db [:wallet :accounts address])] + {:db (update db :wallet dissoc :navigate-to-account :new-account?) + :fx [[:dispatch + [:toasts/upsert + {:id :new-wallet-account-created + :icon :i/correct + :icon-color colors/success-50 + :text (i18n/label :t/account-created {:name (:name account)})}]]]}))) (rf/reg-event-fx :wallet/navigate-to-account - (fn [{:keys [db]} [address]] - {:db (assoc-in db [:wallet :current-viewing-account-address] address) - :fx [[:dispatch [:navigate-to :wallet-accounts address]]]})) + (fn [{:keys [db]} [address]] + {:db (assoc-in db [:wallet :current-viewing-account-address] address) + :fx [[:dispatch [:navigate-to :wallet-accounts address]]]})) (rf/reg-event-fx :wallet/navigate-to-new-account - (fn [{:keys [db]} [address]] - {:db (assoc-in db [:wallet :current-viewing-account-address] address) - :fx [[:dispatch [:hide-bottom-sheet]] - [:dispatch-later - [{:dispatch [:navigate-back] - :ms 100} - {:dispatch [:navigate-back] - :ms 100} - {:dispatch [:navigate-to :wallet-accounts address] - :ms 300}]] - [:dispatch [:wallet/show-account-created-toast address]]]})) + (fn [{:keys [db]} [address]] + {:db (assoc-in db [:wallet :current-viewing-account-address] address) + :fx [[:dispatch [:hide-bottom-sheet]] + [:dispatch-later + [{:dispatch [:navigate-back] + :ms 100} + {:dispatch [:navigate-back] + :ms 100} + {:dispatch [:navigate-to :wallet-accounts address] + :ms 300}]] + [:dispatch [:wallet/show-account-created-toast address]]]})) (rf/reg-event-fx :wallet/switch-current-viewing-account - (fn [{:keys [db]} [address]] - {:db (assoc-in db [:wallet :current-viewing-account-address] address)})) + (fn [{:keys [db]} [address]] + {:db (assoc-in db [:wallet :current-viewing-account-address] address)})) (rf/reg-event-fx :wallet/close-account-page - (fn [{:keys [db]}] - {:db (update db :wallet dissoc :current-viewing-account-address) - :fx [[:dispatch [:navigate-back]]]})) + (fn [{:keys [db]}] + {:db (update db :wallet dissoc :current-viewing-account-address) + :fx [[:dispatch [:navigate-back]]]})) (rf/reg-event-fx - :wallet/get-accounts-success - (fn [{:keys [db]} [accounts]] -<<<<<<< HEAD -<<<<<<< HEAD - (let [wallet-accounts (filter #(not (:chat %)) accounts) - wallet-db (get db :wallet) -======= - (println "aaaa" accounts) -======= ->>>>>>> 9c3ec27ba (lint) - (let [wallet-db (get db :wallet) ->>>>>>> c1d06ad1d (wallet: add color and emoji) - new-account? (:new-account? wallet-db) - navigate-to-account (:navigate-to-account wallet-db)] - {:db (reduce (fn [db {:keys [address] :as account}] - (assoc-in db [:wallet :accounts address] account)) - db - (data-store/rpc->accounts wallet-accounts)) - :fx [[:dispatch [:wallet/get-wallet-token]] - (when new-account? - [:dispatch [:wallet/navigate-to-new-account navigate-to-account]])]}))) + :wallet/get-accounts-success + (fn [{:keys [db]} [accounts]] + (let [wallet-accounts (filter #(not (:chat %)) accounts) + wallet-db (get db :wallet) + new-account? (:new-account? wallet-db) + navigate-to-account (:navigate-to-account wallet-db)] + {:db (reduce (fn [db {:keys [address] :as account}] + (assoc-in db [:wallet :accounts address] account)) + db + (data-store/rpc->accounts wallet-accounts)) + :fx [[:dispatch [:wallet/get-wallet-token]] + (when new-account? + [:dispatch [:wallet/navigate-to-new-account navigate-to-account]])]}))) (rf/reg-event-fx - :wallet/get-accounts - (fn [_] - {:fx [[:json-rpc/call - [{:method "accounts_getAccounts" - :on-success [:wallet/get-accounts-success] - :on-error #(log/info "failed to get accounts " - {:error % - :event :wallet/get-accounts})}]]]})) + :wallet/get-accounts + (fn [_] + {:fx [[:json-rpc/call + [{:method "accounts_getAccounts" + :on-success [:wallet/get-accounts-success] + :on-error #(log/info "failed to get accounts " + {:error % + :event :wallet/get-accounts})}]]]})) (rf/reg-event-fx - :wallet/save-account - (fn [_ [{:keys [account on-success]}]] - {:fx [[:json-rpc/call - [{:method "accounts_saveAccount" - :params [(data-store/<-account account)] - :on-success (fn [] - (rf/dispatch [:wallet/get-accounts]) - (when (fn? on-success) - (on-success))) - :on-error #(log/info "failed to save account " - {:error % - :event :wallet/save-account})}]]]})) + :wallet/save-account + (fn [_ [{:keys [account on-success]}]] + {:fx [[:json-rpc/call + [{:method "accounts_saveAccount" + :params [(data-store/<-account account)] + :on-success (fn [] + (rf/dispatch [:wallet/get-accounts]) + (when (fn? on-success) + (on-success))) + :on-error #(log/info "failed to save account " + {:error % + :event :wallet/save-account})}]]]})) (rf/reg-event-fx - :wallet/get-wallet-token - (fn [{:keys [db]}] - (let [addresses (->> (get-in db [:wallet :accounts]) - vals - (map :address))] - {:fx [[:json-rpc/call - [{:method "wallet_getWalletToken" - :params [addresses] - :on-success [:wallet/store-wallet-token] - :on-error #(log/info "failed to get wallet token " - {:error % - :event :wallet/get-wallet-token - :params addresses})}]]]}))) + :wallet/get-wallet-token + (fn [{:keys [db]}] + (let [addresses (->> (get-in db [:wallet :accounts]) + vals + (map :address))] + {:fx [[:json-rpc/call + [{:method "wallet_getWalletToken" + :params [addresses] + :on-success [:wallet/store-wallet-token] + :on-error #(log/info "failed to get wallet token " + {:error % + :event :wallet/get-wallet-token + :params addresses})}]]]}))) (defn- fix-chain-id-keys [token] (update token :balances-per-chain update-keys (comp utils.number/parse-int name))) (rf/reg-event-fx - :wallet/store-wallet-token - (fn [{:keys [db]} [raw-tokens-data]] - (let [tokens (-> raw-tokens-data - (update-keys name) - (update-vals #(cske/transform-keys csk/->kebab-case %)) - (update-vals #(mapv fix-chain-id-keys %))) - add-tokens (fn [stored-accounts tokens-per-account] - (reduce-kv (fn [accounts address tokens-data] - (if (accounts address) - (update accounts address assoc :tokens tokens-data) - accounts)) - stored-accounts - tokens-per-account))] - {:db (-> db - (update-in [:wallet :accounts] add-tokens tokens) - (assoc-in [:wallet :ui :tokens-loading?] false))}))) + :wallet/store-wallet-token + (fn [{:keys [db]} [raw-tokens-data]] + (let [tokens (-> raw-tokens-data + (update-keys name) + (update-vals #(cske/transform-keys csk/->kebab-case %)) + (update-vals #(mapv fix-chain-id-keys %))) + add-tokens (fn [stored-accounts tokens-per-account] + (reduce-kv (fn [accounts address tokens-data] + (if (accounts address) + (update accounts address assoc :tokens tokens-data) + accounts)) + stored-accounts + tokens-per-account))] + {:db (-> db + (update-in [:wallet :accounts] add-tokens tokens) + (assoc-in [:wallet :ui :tokens-loading?] false))}))) (rf/defn scan-address-success - {:events [:wallet/scan-address-success]} - [{:keys [db]} address] - {:db (assoc db :wallet/scanned-address address)}) + {:events [:wallet/scan-address-success]} + [{:keys [db]} address] + {:db (assoc db :wallet/scanned-address address)}) (rf/defn clean-scanned-address - {:events [:wallet/clean-scanned-address]} - [{:keys [db]}] - {:db (dissoc db :wallet/scanned-address :wallet/send-address)}) + {:events [:wallet/clean-scanned-address]} + [{:keys [db]}] + {:db (dissoc db :wallet/scanned-address :wallet/send-address)}) (rf/reg-event-fx :wallet/create-derived-addresses - (fn [{:keys [db]} [password {:keys [path]} on-success]] - (let [{:keys [wallet-root-address]} (:profile/profile db) - sha3-pwd (native-module/sha3 (str (security/safe-unmask-data password)))] - {:fx [[:json-rpc/call - [{:method "wallet_getDerivedAddresses" - :params [sha3-pwd wallet-root-address [path]] - :on-success on-success - :on-error #(log/info "failed to derive address " %)}]]]}))) + (fn [{:keys [db]} [password {:keys [path]} on-success]] + (let [{:keys [wallet-root-address]} (:profile/profile db) + sha3-pwd (native-module/sha3 (str (security/safe-unmask-data password)))] + {:fx [[:json-rpc/call + [{:method "wallet_getDerivedAddresses" + :params [sha3-pwd wallet-root-address [path]] + :on-success on-success + :on-error #(log/info "failed to derive address " %)}]]]}))) (rf/reg-event-fx :wallet/add-account-success - (fn [{:keys [db]} [address]] - {:db (update db - :wallet assoc - :navigate-to-account address - :new-account? true) - :fx [[:dispatch [:wallet/get-accounts]]]})) + (fn [{:keys [db]} [address]] + {:db (update db + :wallet assoc + :navigate-to-account address + :new-account? true) + :fx [[:dispatch [:wallet/get-accounts]]]})) (rf/reg-event-fx :wallet/add-account - (fn [{:keys [db]} - [password {:keys [emoji account-name color type] :or {type :generated}} - {:keys [public-key address path]}]] - (let [lowercase-address (if address (string/lower-case address) address) - key-uid (get-in db [:profile/profile :key-uid]) - sha3-pwd (native-module/sha3 (security/safe-unmask-data password)) - account-config {:key-uid (when (= type :generated) key-uid) - :wallet false - :chat false - :type type - :name account-name - :emoji emoji - :path path - :address lowercase-address - :public-key public-key - :colorID color}] - {:fx [[:json-rpc/call - [{:method "accounts_addAccount" - :params [(when (= type :generated) sha3-pwd) account-config] - :on-success [:wallet/add-account-success lowercase-address] - :on-error #(log/info "failed to create account " %)}]]]}))) + (fn [{:keys [db]} + [password {:keys [emoji account-name color type] :or {type :generated}} + {:keys [public-key address path]}]] + (let [lowercase-address (if address (string/lower-case address) address) + key-uid (get-in db [:profile/profile :key-uid]) + sha3-pwd (native-module/sha3 (security/safe-unmask-data password)) + account-config {:key-uid (when (= type :generated) key-uid) + :wallet false + :chat false + :type type + :name account-name + :emoji emoji + :path path + :address lowercase-address + :public-key public-key + :colorID color}] + {:fx [[:json-rpc/call + [{:method "accounts_addAccount" + :params [(when (= type :generated) sha3-pwd) account-config] + :on-success [:wallet/add-account-success lowercase-address] + :on-error #(log/info "failed to create account " %)}]]]}))) (rf/reg-event-fx - :wallet/derive-address-and-add-account - (fn [_ [password account-details]] - (let [on-success (fn [derived-address-details] - (rf/dispatch [:wallet/add-account password account-details - (first derived-address-details)]))] - {:fx [[:dispatch [:wallet/create-derived-addresses password account-details on-success]]]}))) + :wallet/derive-address-and-add-account + (fn [_ [password account-details]] + (let [on-success (fn [derived-address-details] + (rf/dispatch [:wallet/add-account password account-details + (first derived-address-details)]))] + {:fx [[:dispatch [:wallet/create-derived-addresses password account-details on-success]]]}))) (rf/defn get-ethereum-chains - {:events [:wallet/get-ethereum-chains]} - [{:keys [db]}] - {:fx [[:json-rpc/call - [{:method "wallet_getEthereumChains" - :params [] - :on-success [:wallet/get-ethereum-chains-success] - :on-error #(log/info "failed to get networks " %)}]]]}) + {:events [:wallet/get-ethereum-chains]} + [{:keys [db]}] + {:fx [[:json-rpc/call + [{:method "wallet_getEthereumChains" + :params [] + :on-success [:wallet/get-ethereum-chains-success] + :on-error #(log/info "failed to get networks " %)}]]]}) (rf/reg-event-fx - :wallet/get-ethereum-chains-success - (fn [{:keys [db]} [data]] - (let [network-data - {:test (map #(->> % - :Test - data-store/<-rpc) - data) - :prod (map #(->> % - :Prod - data-store/<-rpc) - data)}] - {:db (assoc db :wallet/networks network-data)}))) + :wallet/get-ethereum-chains-success + (fn [{:keys [db]} [data]] + (let [network-data + {:test (map #(->> % + :Test + data-store/<-rpc) + data) + :prod (map #(->> % + :Prod + data-store/<-rpc) + data)}] + {:db (assoc db :wallet/networks network-data)}))) (def collectibles-request-batch-size 1000) @@ -233,8 +225,8 @@ (let [stored-collectibles (get-in db [:wallet :collectibles]) displayable-collectibles (filter displayable-collectible? collectibles)] {:db (assoc-in db - [:wallet :collectibles] - (reduce conj displayable-collectibles stored-collectibles))})) + [:wallet :collectibles] + (reduce conj displayable-collectibles stored-collectibles))})) (rf/reg-event-fx :wallet/store-collectibles store-collectibles) @@ -247,8 +239,8 @@ (defn store-last-collectible-details [{:keys [db]} [collectible]] {:db (assoc-in db - [:wallet :last-collectible-details] - collectible)}) + [:wallet :last-collectible-details] + collectible)}) (rf/reg-event-fx :wallet/store-last-collectible-details store-last-collectible-details) @@ -267,165 +259,154 @@ (def max-cache-age-seconds 3600) (rf/reg-event-fx - :wallet/request-collectibles - (fn [{:keys [db]} [{:keys [start-at-index new-request?]}]] - (let [request-id 0 - collectibles-filter nil - data-type (collectible-data-types :header) - fetch-criteria {:fetch-type (fetch-type :fetch-if-not-cached) - :max-cache-age-seconds max-cache-age-seconds} - request-params [request-id - [(chain/chain-id db)] - (map :address (:profile/wallet-accounts db)) - collectibles-filter - start-at-index - collectibles-request-batch-size - data-type - fetch-criteria]] - {:fx [[:json-rpc/call - [{:method "wallet_getOwnedCollectiblesAsync" - :params request-params - :on-success #() - :on-error (fn [error] - (log/error "failed to request collectibles" - {:event :wallet/request-collectibles - :error error - :params request-params}))}]] - (when new-request? - [:dispatch [:wallet/clear-stored-collectibles]])]}))) + :wallet/request-collectibles + (fn [{:keys [db]} [{:keys [start-at-index new-request?]}]] + (let [request-id 0 + collectibles-filter nil + data-type (collectible-data-types :header) + fetch-criteria {:fetch-type (fetch-type :fetch-if-not-cached) + :max-cache-age-seconds max-cache-age-seconds} + request-params [request-id + [(chain/chain-id db)] + (map :address (:profile/wallet-accounts db)) + collectibles-filter + start-at-index + collectibles-request-batch-size + data-type + fetch-criteria]] + {:fx [[:json-rpc/call + [{:method "wallet_getOwnedCollectiblesAsync" + :params request-params + :on-success #() + :on-error (fn [error] + (log/error "failed to request collectibles" + {:event :wallet/request-collectibles + :error error + :params request-params}))}]] + (when new-request? + [:dispatch [:wallet/clear-stored-collectibles]])]}))) (rf/reg-event-fx :wallet/owned-collectibles-filtering-done - (fn [_ [{:keys [message]}]] - (let [response (cske/transform-keys csk/->kebab-case-keyword - (types/json->clj message)) - {:keys [collectibles has-more offset]} response - start-at-index (+ offset (count collectibles))] - {:fx - [[:dispatch [:wallet/store-collectibles collectibles]] - (when has-more - [:dispatch - [:wallet/request-collectibles - {:start-at-index start-at-index}]])]}))) + (fn [_ [{:keys [message]}]] + (let [response (cske/transform-keys csk/->kebab-case-keyword + (types/json->clj message)) + {:keys [collectibles has-more offset]} response + start-at-index (+ offset (count collectibles))] + {:fx + [[:dispatch [:wallet/store-collectibles collectibles]] + (when has-more + [:dispatch + [:wallet/request-collectibles + {:start-at-index start-at-index}]])]}))) (rf/reg-event-fx :wallet/get-collectible-details - (fn [_ [collectible-id]] - (let [request-id 0 - collectible-id-converted (cske/transform-keys csk/->PascalCaseKeyword collectible-id) - data-type (collectible-data-types :details) - request-params [request-id [collectible-id-converted] data-type]] - {:fx [[:json-rpc/call - [{:method "wallet_getCollectiblesByUniqueIDAsync" - :params request-params - :on-error (fn [error] - (log/error "failed to request collectible" - {:event :wallet/get-collectible-details - :error error - :params request-params}))}]]]}))) + (fn [_ [collectible-id]] + (let [request-id 0 + collectible-id-converted (cske/transform-keys csk/->PascalCaseKeyword collectible-id) + data-type (collectible-data-types :details) + request-params [request-id [collectible-id-converted] data-type]] + {:fx [[:json-rpc/call + [{:method "wallet_getCollectiblesByUniqueIDAsync" + :params request-params + :on-error (fn [error] + (log/error "failed to request collectible" + {:event :wallet/get-collectible-details + :error error + :params request-params}))}]]]}))) (rf/reg-event-fx :wallet/get-collectible-details-done - (fn [_ [{:keys [message]}]] - (let [response (cske/transform-keys csk/->kebab-case-keyword - (types/json->clj message)) - {:keys [collectibles]} response - collectible (first collectibles)] - (if collectible - {:fx - [[:dispatch [:wallet/store-last-collectible-details collectible]]]} - (log/error "failed to get collectible details" - {:event :wallet/get-collectible-details-done - :response response}))))) + (fn [_ [{:keys [message]}]] + (let [response (cske/transform-keys csk/->kebab-case-keyword + (types/json->clj message)) + {:keys [collectibles]} response + collectible (first collectibles)] + (if collectible + {:fx + [[:dispatch [:wallet/store-last-collectible-details collectible]]]} + (log/error "failed to get collectible details" + {:event :wallet/get-collectible-details-done + :response response}))))) (rf/reg-event-fx :wallet/fetch-address-suggestions - (fn [{:keys [db]} [address]] - {:db (assoc db - :wallet/local-suggestions - (cond - (= address - (get-in - temp/address-local-suggestion-saved-contact-address-mock - [:accounts 0 :address])) - [temp/address-local-suggestion-saved-contact-address-mock] - (= address - (get temp/address-local-suggestion-saved-address-mock - :address)) - [temp/address-local-suggestion-saved-address-mock] - :else (temp/find-matching-addresses address)) - :wallet/valid-ens-or-address? - false)})) + (fn [{:keys [db]} [address]] + {:db (assoc db + :wallet/local-suggestions + (cond + (= address + (get-in + temp/address-local-suggestion-saved-contact-address-mock + [:accounts 0 :address])) + [temp/address-local-suggestion-saved-contact-address-mock] + (= address + (get temp/address-local-suggestion-saved-address-mock + :address)) + [temp/address-local-suggestion-saved-address-mock] + :else (temp/find-matching-addresses address)) + :wallet/valid-ens-or-address? + false)})) (rf/reg-event-fx :wallet/ens-validation-success - (fn [{:keys [db]} [ens]] - {:db (assoc db - :wallet/local-suggestions (if (= ens - (:ens temp/ens-local-suggestion-saved-address-mock)) - [temp/ens-local-suggestion-saved-address-mock] - [temp/ens-local-suggestion-mock]) - :wallet/valid-ens-or-address? true)})) + (fn [{:keys [db]} [ens]] + {:db (assoc db + :wallet/local-suggestions (if (= ens + (:ens temp/ens-local-suggestion-saved-address-mock)) + [temp/ens-local-suggestion-saved-address-mock] + [temp/ens-local-suggestion-mock]) + :wallet/valid-ens-or-address? true)})) (rf/reg-event-fx :wallet/address-validation-success - (fn [{:keys [db]} [_]] - {:db (assoc db :wallet/valid-ens-or-address? true)})) + (fn [{:keys [db]} [_]] + {:db (assoc db :wallet/valid-ens-or-address? true)})) (rf/reg-event-fx :wallet/validate-address - (fn [{:keys [db]} [address]] - (let [current-timeout (get db :wallet/search-timeout) - timeout (background-timer/set-timeout - #(rf/dispatch [:wallet/address-validation-success address]) - 2000)] - (background-timer/clear-timeout current-timeout) - {:db (assoc db - :wallet/valid-ens-or-address? false - :wallet/search-timeout timeout)}))) + (fn [{:keys [db]} [address]] + (let [current-timeout (get db :wallet/search-timeout) + timeout (background-timer/set-timeout + #(rf/dispatch [:wallet/address-validation-success address]) + 2000)] + (background-timer/clear-timeout current-timeout) + {:db (assoc db + :wallet/valid-ens-or-address? false + :wallet/search-timeout timeout)}))) (rf/reg-event-fx :wallet/validate-ens - (fn [{:keys [db]} [ens]] - (let [current-timeout (get db :wallet/search-timeout) - timeout (background-timer/set-timeout - #(rf/dispatch [:wallet/ens-validation-success ens]) - 2000)] - (background-timer/clear-timeout current-timeout) - {:db (assoc db - :wallet/valid-ens-or-address? false - :wallet/search-timeout timeout)}))) + (fn [{:keys [db]} [ens]] + (let [current-timeout (get db :wallet/search-timeout) + timeout (background-timer/set-timeout + #(rf/dispatch [:wallet/ens-validation-success ens]) + 2000)] + (background-timer/clear-timeout current-timeout) + {:db (assoc db + :wallet/valid-ens-or-address? false + :wallet/search-timeout timeout)}))) (rf/reg-event-fx :wallet/clean-local-suggestions - (fn [{:keys [db]}] - (let [current-timeout (get db :wallet/search-timeout)] - (background-timer/clear-timeout current-timeout) - {:db (assoc db :wallet/local-suggestions [] :wallet/valid-ens-or-address? false)}))) + (fn [{:keys [db]}] + (let [current-timeout (get db :wallet/search-timeout)] + (background-timer/clear-timeout current-timeout) + {:db (assoc db :wallet/local-suggestions [] :wallet/valid-ens-or-address? false)}))) (rf/reg-event-fx :wallet/select-send-address - (fn [{:keys [db]} [address]] - {:db (assoc db :wallet/send-address address)})) -<<<<<<< HEAD + (fn [{:keys [db]} [address]] + {:db (assoc db :wallet/send-address address)})) -<<<<<<< HEAD (rf/reg-event-fx :wallet/get-address-details-success - (fn [{:keys [db]} [{:keys [hasActivity]}]] - {:db (assoc-in db - [:wallet :ui :watch-address-activity-state] - (if hasActivity :has-activity :no-activity))})) + (fn [{:keys [db]} [{:keys [hasActivity]}]] + {:db (assoc-in db + [:wallet :ui :watch-address-activity-state] + (if hasActivity :has-activity :no-activity))})) (rf/reg-event-fx :wallet/clear-address-activity-check - (fn [{:keys [db]}] - {:db (update-in db [:wallet :ui] dissoc :watch-address-activity-state)})) + (fn [{:keys [db]}] + {:db (update-in db [:wallet :ui] dissoc :watch-address-activity-state)})) (rf/reg-event-fx :wallet/get-address-details - (fn [{:keys [db]} [address]] - {:db (assoc-in db [:wallet :ui :watch-address-activity-state] :scanning) - :fx [[:json-rpc/call - [{:method "wallet_getAddressDetails" - :params [(chain/chain-id db) address] - :on-success [:wallet/get-address-details-success] - :on-error #(log/info "failed to get address details" - {:error % - :event :wallet/get-address-details})}]]]})) -======= -(rf/reg-event-fx - :wallet/initialize - (fn [{:keys [db]}] - (println "WALLET INIT") - {:db db})) ->>>>>>> c1d06ad1d (wallet: add color and emoji) -======= ->>>>>>> 9c3ec27ba (lint) + (fn [{:keys [db]} [address]] + {:db (assoc-in db [:wallet :ui :watch-address-activity-state] :scanning) + :fx [[:json-rpc/call + [{:method "wallet_getAddressDetails" + :params [(chain/chain-id db) address] + :on-success [:wallet/get-address-details-success] + :on-error #(log/info "failed to get address details" + {:error % + :event :wallet/get-address-details})}]]]})) diff --git a/src/status_im2/subs/wallet/wallet.cljs b/src/status_im2/subs/wallet/wallet.cljs index a27e04339f08..646bd2bdb5e0 100644 --- a/src/status_im2/subs/wallet/wallet.cljs +++ b/src/status_im2/subs/wallet/wallet.cljs @@ -5,105 +5,97 @@ [utils.number])) (rf/reg-sub - :wallet/ui - :<- [:wallet] - :-> :ui) + :wallet/ui + :<- [:wallet] + :-> :ui) (rf/reg-sub - :wallet/tokens-loading? - :<- [:wallet/ui] - :-> :tokens-loading?) + :wallet/tokens-loading? + :<- [:wallet/ui] + :-> :tokens-loading?) (rf/reg-sub - :wallet/watch-address-activity-state - :<- [:wallet/ui] - :-> :watch-address-activity-state) + :wallet/watch-address-activity-state + :<- [:wallet/ui] + :-> :watch-address-activity-state) (rf/reg-sub - :wallet/accounts - :<- [:wallet] - :-> #(->> % - :accounts - vals - (sort-by :position))) + :wallet/accounts + :<- [:wallet] + :-> #(->> % + :accounts + vals + (sort-by :position))) (rf/reg-sub - :wallet/addresses - :<- [:wallet] - :-> #(->> % - :accounts - keys - set)) + :wallet/addresses + :<- [:wallet] + :-> #(->> % + :accounts + keys + set)) (rf/reg-sub - :wallet/balances - :<- [:wallet/accounts] - (fn [accounts] - (zipmap (map :address accounts) - (map #(-> % :tokens utils/calculate-balance) accounts)))) + :wallet/balances + :<- [:wallet/accounts] + (fn [accounts] + (zipmap (map :address accounts) + (map #(-> % :tokens utils/calculate-balance) accounts)))) (rf/reg-sub - :wallet/account-cards-data - :<- [:wallet/accounts] - :<- [:wallet/balances] - :<- [:wallet/tokens-loading?] - (fn [[accounts balances tokens-loading?]] -<<<<<<< HEAD -<<<<<<< HEAD - (mapv (fn [{:keys [color address type] :as account}] -======= - (println "accountsx" accounts) -======= ->>>>>>> 19a423fc3 (lint) - (mapv (fn [{:keys [color address] :as account}] ->>>>>>> c1d06ad1d (wallet: add color and emoji) - (assoc account - :customization-color color - :type (if (= type :watch) :watch-only :empty) - :on-press #(rf/dispatch [:wallet/navigate-to-account address]) - :loading? tokens-loading? - :balance (utils/prettify-balance (get balances address)))) - accounts))) + :wallet/account-cards-data + :<- [:wallet/accounts] + :<- [:wallet/balances] + :<- [:wallet/tokens-loading?] + (fn [[accounts balances tokens-loading?]] + (mapv (fn [{:keys [color address type] :as account}] + (assoc account + :customization-color color + :type (if (= type :watch) :watch-only :empty) + :on-press #(rf/dispatch [:wallet/navigate-to-account address]) + :loading? tokens-loading? + :balance (utils/prettify-balance (get balances address)))) + accounts))) (rf/reg-sub - :wallet/current-viewing-account - :<- [:wallet] - :<- [:wallet/balances] - (fn [[{:keys [current-viewing-account-address] :as wallet} balances]] - (-> wallet - (get-in [:accounts current-viewing-account-address]) - (assoc :balance (get balances current-viewing-account-address))))) + :wallet/current-viewing-account + :<- [:wallet] + :<- [:wallet/balances] + (fn [[{:keys [current-viewing-account-address] :as wallet} balances]] + (-> wallet + (get-in [:accounts current-viewing-account-address]) + (assoc :balance (get balances current-viewing-account-address))))) (rf/reg-sub - :wallet/tokens-filtered - :<- [:wallet/current-viewing-account] - :<- [:wallet/network-details] - (fn [[account networks] [_ query]] - (let [tokens (map (fn [token] - (assoc token - :networks (utils/network-list token networks) - :total-balance (utils/total-token-value-in-all-chains token) - :total-balance-fiat (utils/calculate-balance token))) - (:tokens account)) + :wallet/tokens-filtered + :<- [:wallet/current-viewing-account] + :<- [:wallet/network-details] + (fn [[account networks] [_ query]] + (let [tokens (map (fn [token] + (assoc token + :networks (utils/network-list token networks) + :total-balance (utils/total-token-value-in-all-chains token) + :total-balance-fiat (utils/calculate-balance token))) + (:tokens account)) - sorted-tokens - (sort-by :name compare tokens) - filtered-tokens - (filter #(or (string/starts-with? (string/lower-case (:name %)) - (string/lower-case query)) - (string/starts-with? (string/lower-case (:symbol %)) - (string/lower-case query))) - sorted-tokens)] - filtered-tokens))) + sorted-tokens + (sort-by :name compare tokens) + filtered-tokens + (filter #(or (string/starts-with? (string/lower-case (:name %)) + (string/lower-case query)) + (string/starts-with? (string/lower-case (:symbol %)) + (string/lower-case query))) + sorted-tokens)] + filtered-tokens))) (rf/reg-sub - :wallet/current-viewing-account-address - :<- [:wallet] - :-> :current-viewing-account-address) + :wallet/current-viewing-account-address + :<- [:wallet] + :-> :current-viewing-account-address) (rf/reg-sub - :wallet/accounts-without-current-viewing-account - :<- [:wallet/accounts] - :<- [:wallet/current-viewing-account-address] - (fn [[accounts current-viewing-account-address]] - (remove #(= (:address %) current-viewing-account-address) accounts))) + :wallet/accounts-without-current-viewing-account + :<- [:wallet/accounts] + :<- [:wallet/current-viewing-account-address] + (fn [[accounts current-viewing-account-address]] + (remove #(= (:address %) current-viewing-account-address) accounts))) diff --git a/status-go-version.json b/status-go-version.json index 240d6d5e5a25..bae7120e0e05 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,19 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", -<<<<<<< HEAD -<<<<<<< HEAD - "version": "v0.171.27", - "commit-sha1": "76b6745666b945f8d6336e2a5fc6e5705985273d", - "src-sha256": "1amak99bpsx6j8grzm2kzwd3si34gg4r8kbxqmnkfsrkm2nzvbx1" -======= - "version": "c7278b9322cca78a648b151e53534702ed4b7166", - "commit-sha1": "c7278b9322cca78a648b151e53534702ed4b7166", - "src-sha256": "13h2wc5gcay196bjvcgcixzvncdw372yrabsx6gnr82phbw9py6l" ->>>>>>> c1d06ad1d (wallet: add color and emoji) -======= - "version": "08d32d39c0d7b0550f1110df8cebfd5da5691ac7", - "commit-sha1": "08d32d39c0d7b0550f1110df8cebfd5da5691ac7", - "src-sha256": "10vzgyq3sspylxyxffig34l8sd8ryvghkkmagjrr06azsqsyp1mf" ->>>>>>> 5c9afe65b (update status-go) + "version": "1174e1e43c0fbffaa21c9401c29e98cbdc37557c", + "commit-sha1": "1174e1e43c0fbffaa21c9401c29e98cbdc37557c", + "src-sha256": "1q5l9aimdiyryzvbd10djvz5ghg6ccaghwmqp2456skbvflpbyr2" }