diff --git a/.env b/.env index 5b8f7d0b8d..e9cfd2e243 100644 --- a/.env +++ b/.env @@ -32,3 +32,4 @@ TWO_MINUTES_SYNCING=1 SWAP_ENABLED=1 STICKERS_TEST_ENABLED=1 LOCAL_PAIRING_ENABLED=1 +TEST_STATEOFUS=1 diff --git a/src/status_im/ens/core.cljs b/src/status_im/ens/core.cljs index ac720786db..86081f6480 100644 --- a/src/status_im/ens/core.cljs +++ b/src/status_im/ens/core.cljs @@ -1,17 +1,21 @@ (ns status-im.ens.core (:refer-clojure :exclude [name]) - (:require [clojure.string :as string] - [re-frame.core :as re-frame] - [status-im.bottom-sheet.events :as bottom-sheet] - [status-im.ethereum.core :as ethereum] - [status-im.ethereum.eip55 :as eip55] - [status-im.ethereum.ens :as ens] - [status-im.ethereum.stateofus :as stateofus] - [status-im.multiaccounts.update.core :as multiaccounts.update] - [utils.re-frame :as rf] - [utils.datetime :as datetime] - [status-im.utils.random :as random] - [status-im2.navigation.events :as navigation])) + (:require + [clojure.set :as set] + [clojure.string :as string] + [re-frame.core :as re-frame] + [status-im.bottom-sheet.events :as bottom-sheet] + [status-im.ethereum.core :as ethereum] + [status-im.ethereum.eip55 :as eip55] + [status-im.ethereum.ens :as ens] + [status-im.ethereum.stateofus :as stateofus] + [status-im.multiaccounts.update.core :as multiaccounts.update] + [utils.re-frame :as rf] + [utils.datetime :as datetime] + [status-im.utils.random :as random] + [status-im2.navigation.events :as navigation] + [status-im2.constants :as constants] + [taoensso.timbre :as log])) (defn fullname [custom-domain? username] @@ -40,7 +44,7 @@ (ens/expire-at chain-id name cb))) (rf/defn update-ens-tx-state - {:events [:update-ens-tx-state]} + {:events [:ens/update-ens-tx-state]} [{:keys [db]} new-state username custom-domain? tx-hash] {:db (assoc-in db [:ens/registrations tx-hash] @@ -53,20 +57,19 @@ [cofx] ;; we reset navigation so that navigate back doesn't return ;; into the registration flow - (navigation/set-stack-root cofx - :profile-stack - [:my-profile - :ens-confirmation])) + (rf/merge cofx + (navigation/navigate-back-to :my-profile) + (navigation/navigate-to :ens-confirmation {}))) (rf/defn update-ens-tx-state-and-redirect {:events [:update-ens-tx-state-and-redirect]} - [cofx new-state username custom-domain? tx-hash] + [{:keys [db] :as cofx} new-state username custom-domain? tx-hash] (rf/merge cofx (update-ens-tx-state new-state username custom-domain? tx-hash) (redirect-to-ens-summary))) (rf/defn clear-ens-registration - {:events [:clear-ens-registration]} + {:events [:ens/clear-registration]} [{:keys [db]} tx-hash] {:db (update db :ens/registrations dissoc tx-hash)}) @@ -79,23 +82,43 @@ (assoc-in [:ens/registration :state] state) (assoc-in [:ens/registration :address] address))})) +(rf/defn update-usernames + {:events [:ens/update-usernames]} + [{:keys [db]} name-details] + (let [name-details (map #(set/rename-keys % + {:chainId :chain-id + :removed :removed?}) + name-details)] + {:db (reduce (fn [db {:keys [username removed?] :as name-detail}] + (if removed? + (update-in db [:ens/names] dissoc username) + (let [old (get-in db [:ens/names username])] + (assoc-in db [:ens/names username] (merge old name-detail))))) + db + name-details)})) + (rf/defn save-username - {:events [::save-username]} - [{:keys [db] :as cofx} custom-domain? username redirectToSummary] - (let [name (fullname custom-domain? username) - names (get-in db [:profile/profile :usernames] []) - new-names (conj names name)] + {:events [:ens/save-username]} + [{:keys [db] :as cofx} custom-domain? username redirect-to-summary? connected?] + (let [name (fullname custom-domain? username) + names (get-in db [:ens/names] []) + chain-id (ethereum/chain-id db)] (rf/merge cofx - (multiaccounts.update/multiaccount-update - :usernames - new-names - (when redirectToSummary - {:on-success #(re-frame/dispatch [::redirect-to-ens-summary])})) - (when (empty? names) - (multiaccounts.update/multiaccount-update - :preferred-name - name - {}))))) + (cond-> {:dispatch-n [[:ens/update-usernames [{:username name :chain-id chain-id}]]]} + connected? (assoc :json-rpc/call + [{:method "ens_add" + :params [chain-id name] + :on-success #() + :on-error #(log/error + "Failed to add ens name" + {:chain-id chain-id :name name :error %})}]) + redirect-to-summary? (update-in [:dispatch-n] #(conj % [::redirect-to-ens-summary]))) + #(when (empty? names) + (multiaccounts.update/multiaccount-update + cofx + :preferred-name + name + {}))))) (rf/defn set-pub-key {:events [::set-pub-key]} @@ -105,15 +128,14 @@ {:keys [public-key]} (:profile/profile db) chain-id (ethereum/chain-id db) username (fullname custom-domain? username)] - (ens/set-pub-key-prepare-tx - chain-id - address - username - public-key - #(re-frame/dispatch [:signing.ui/sign - {:tx-obj % - :on-result [::save-username custom-domain? username true] - :on-error [::on-registration-failure]}])))) + {:db (assoc-in db [:ens/registration :action] constants/ens-action-type-set-pub-key) + :json-rpc/call [{:method "ens_setPubKeyPrepareTx" + :params [chain-id {:from address} username public-key] + :on-success #(re-frame/dispatch [:signing.ui/sign + {:tx-obj % + :on-result [:ens/save-username custom-domain? + username true] + :on-error [::on-registration-failure]}])}]})) (rf/defn on-input-submitted {:events [::input-submitted]} @@ -125,7 +147,7 @@ :connected-with-different-key (re-frame/dispatch [::set-pub-key]) :connected - (save-username cofx custom-domain? username true) + (save-username cofx custom-domain? username true true) ;; for other states, we do nothing nil))) @@ -171,15 +193,14 @@ (:ens/registration db) {:keys [public-key]} (:profile/profile db) chain-id (ethereum/chain-id db)] - (ens/register-prepare-tx - chain-id - address - username - public-key - #(re-frame/dispatch [:signing.ui/sign - {:tx-obj % - :on-result [:update-ens-tx-state-and-redirect :submitted username false] - :on-error [::on-registration-failure]}])))) + {:db (assoc-in db [:ens/registration :action] constants/ens-action-type-register) + :json-rpc/call [{:method "ens_registerPrepareTx" + :params [chain-id {:from address} username public-key] + :on-success #(re-frame/dispatch [:signing.ui/sign + {:tx-obj % + :on-result [:update-ens-tx-state-and-redirect + :submitted username false] + :on-error [::on-registration-failure]}])}]})) (defn- valid-custom-domain? [username] @@ -211,7 +232,7 @@ {:events [::set-username-candidate]} [{:keys [db]} username] (let [{:keys [custom-domain?]} (:ens/registration db) - usernames (into #{} (get-in db [:profile/profile :usernames])) + usernames (into #{} (keys (get-in db [:ens/names]))) state (state custom-domain? username usernames)] (reset! resolve-last-id (random/id)) (merge @@ -244,9 +265,9 @@ {:db (dissoc db :ens/registration)} ;; we reset navigation so that navigate back doesn't return ;; into the registration flow - (navigation/set-stack-root :profile-stack - [:my-profile - :ens-main]))) + (navigation/navigate-back-to :my-profile) + (navigation/navigate-to :ens-main {}) + )) (rf/defn switch-domain-type {:events [::switch-domain-type]} @@ -323,14 +344,18 @@ (rf/defn remove-username {:events [::remove-username]} [{:keys [db] :as cofx} name] - (let [names (get-in db [:profile/profile :usernames] []) - preferred-name (get-in db [:profile/profile :preferred-name]) - new-names (remove #(= name %) names)] + (let [names (get-in db [:ens/names] []) + preferred-name (get-in db [:profile/profile :preferred-name]) + new-names (remove #(= name %) (keys names)) + {:keys [chain-id username]} (get-in names [name])] (rf/merge cofx - (multiaccounts.update/multiaccount-update - :usernames - new-names - {}) + {:json-rpc/call [{:method "ens_remove" + :params [chain-id username] + :on-success #() + :on-error #(log/error "Failed to remove ENS name" + {:name name :error %})}] + :dispatch [:ens/update-usernames + [{:username username :chain-id chain-id :removed? true}]]} (when (= name preferred-name) (multiaccounts.update/multiaccount-update :preferred-name diff --git a/src/status_im/ethereum/ens.cljs b/src/status_im/ethereum/ens.cljs index 185bad91ca..59c557fc8a 100644 --- a/src/status_im/ethereum/ens.cljs +++ b/src/status_im/ethereum/ens.cljs @@ -67,15 +67,3 @@ :on-success ;;NOTE: returns a timestamp in s and we want ms #(cb (* (js/Number (native-module/hex-to-number %)) 1000))})) - -(defn register-prepare-tx - [chain-id from ens-name public-key cb] - (json-rpc/call {:method "ens_registerPrepareTx" - :params [chain-id {:from from} ens-name public-key] - :on-success cb})) - -(defn set-pub-key-prepare-tx - [chain-id from ens-name public-key cb] - (json-rpc/call {:method "ens_setPubKeyPrepareTx" - :params [chain-id {:from from} ens-name public-key] - :on-success cb})) diff --git a/src/status_im/ethereum/transactions/core.cljs b/src/status_im/ethereum/transactions/core.cljs index 83fbe27637..a4b9b958ac 100644 --- a/src/status_im/ethereum/transactions/core.cljs +++ b/src/status_im/ethereum/transactions/core.cljs @@ -1,7 +1,6 @@ (ns status-im.ethereum.transactions.core (:require [cljs.spec.alpha :as spec] [re-frame.core :as re-frame] - [status-im.ens.core :as ens] [status-im.ethereum.core :as ethereum] [status-im.ethereum.decode :as decode] [status-im.ethereum.eip55 :as eip55] @@ -111,6 +110,7 @@ `trigger-fn` is a function that returns true if the watch has been triggered `on-trigger` is a function that returns the effects to apply when the transaction has been triggered" + {:events [:transactions/watch-transaction]} [{:keys [db]} transaction-id {:keys [trigger-fn on-trigger] :as watch-params}] (when (and (fn? trigger-fn) (fn? on-trigger)) @@ -246,19 +246,6 @@ :all :all-preloaded))})) -(rf/defn delete-pending-transactions - [{:keys [db]} address transactions] - (let [all-transactions - (get-in db [:wallet :accounts (eip55/address->checksum address) :transactions]) - pending-tx-hashes (keep (fn [{:keys [hash]}] - (let [{:keys [type] :as old-tx} - (get all-transactions hash)] - (when (and (get all-transactions hash) - (= type :pending)) - hash))) - transactions)] - {:wallet/delete-pending-transactions pending-tx-hashes})) - (rf/defn handle-new-transfer [{:keys [db] :as cofx} transfers {:keys [address limit]}] (log/debug "[transfers] new-transfers" @@ -273,7 +260,7 @@ (seq transfers) (concat - [(delete-pending-transactions address transfers)] + [] (mapv add-transfer transfers)) (and max-known-block @@ -290,44 +277,12 @@ (conj (tx-history-end-reached checksum)))] (apply rf/merge cofx (tx-fetching-ended [checksum]) effects))) -(rf/defn check-ens-transactions - [{:keys [db] :as cofx} transfers] - (let [set-of-transactions-hash (reduce (fn [acc {:keys [hash]}] (conj acc hash)) #{} transfers) - registrations (filter - (fn [[hash {:keys [state]}]] - (and - (or (= state :dismissed) (= state :submitted)) - (contains? set-of-transactions-hash hash))) - (get db :ens/registrations)) - fxs (map - (fn [[hash {:keys [username custom-domain?]}]] - (let [transfer (first (filter (fn [transfer] - (let [transfer-hash - (get transfer - :hash)] - (= transfer-hash hash))) - transfers)) - type (get transfer :type) - transaction-success (get transfer :transfer)] - (cond - (= transaction-success true) - (rf/merge cofx - (ens/clear-ens-registration hash) - (ens/save-username custom-domain? username false)) - (= type :failed) - (ens/update-ens-tx-state :failure username custom-domain? hash) - :else - nil))) - registrations)] - (apply rf/merge cofx fxs))) - (rf/defn new-transfers {:events [::new-transfers]} [cofx transfers params] (rf/merge cofx (handle-new-transfer transfers params) - (wallet/stop-fetching-on-empty-tx-history transfers) - (check-ens-transactions transfers))) + (wallet/stop-fetching-on-empty-tx-history transfers))) (rf/defn tx-fetching-failed {:events [::tx-fetching-failed]} diff --git a/src/status_im/node/core.cljs b/src/status_im/node/core.cljs index 698bd9783a..7b6a1b6817 100644 --- a/src/status_im/node/core.cljs +++ b/src/status_im/node/core.cljs @@ -160,6 +160,7 @@ :always (assoc :LocalNotificationsConfig {:Enabled true} + :KeycardPairingDataFile "/ethereum/mainnet_rpc/keycard/pairings.json" :BrowsersConfig {:Enabled true} :PermissionsConfig {:Enabled true} :MailserversConfig {:Enabled true} diff --git a/src/status_im/signing/core.cljs b/src/status_im/signing/core.cljs index e79d31a29e..0b892c2fc4 100644 --- a/src/status_im/signing/core.cljs +++ b/src/status_im/signing/core.cljs @@ -1,27 +1,28 @@ (ns status-im.signing.core - (:require [clojure.set :as set] - [clojure.string :as string] - [re-frame.core :as re-frame] - [status-im2.constants :as constants] - [status-im.ethereum.core :as ethereum] - [status-im.ethereum.eip55 :as eip55] - [status-im.ethereum.tokens :as tokens] - [utils.i18n :as i18n] - [status-im.keycard.card :as keycard.card] - [status-im.keycard.common :as keycard.common] - [native-module.core :as native-module] - [status-im.signing.eip1559 :as eip1559] - [status-im.signing.keycard :as signing.keycard] - [utils.re-frame :as rf] - [status-im.utils.hex :as utils.hex] - [utils.money :as money] - [status-im.utils.types :as types] - [status-im.utils.utils :as utils] - [status-im.wallet.core :as wallet] - [status-im.wallet.prices :as prices] - [status-im2.common.json-rpc.events :as json-rpc] - [taoensso.timbre :as log] - [utils.security.core :as security])) + (:require + [clojure.set :as set] + [clojure.string :as string] + [re-frame.core :as re-frame] + [status-im2.constants :as constants] + [status-im.ethereum.core :as ethereum] + [status-im.ethereum.eip55 :as eip55] + [status-im.ethereum.tokens :as tokens] + [utils.i18n :as i18n] + [status-im.keycard.card :as keycard.card] + [status-im.keycard.common :as keycard.common] + [native-module.core :as native-module] + [status-im.signing.eip1559 :as eip1559] + [status-im.signing.keycard :as signing.keycard] + [utils.re-frame :as rf] + [status-im.utils.hex :as utils.hex] + [utils.money :as money] + [status-im.utils.types :as types] + [status-im.utils.utils :as utils] + [status-im.wallet.core :as wallet] + [status-im.wallet.prices :as prices] + [status-im2.common.json-rpc.events :as json-rpc] + [taoensso.timbre :as log] + [utils.security.core :as security])) (re-frame/reg-fx :signing/send-transaction-fx @@ -100,35 +101,81 @@ (rf/defn send-transaction {:events [:signing.ui/sign-is-pressed]} - [{{:signing/keys [sign tx] :as db} :db :as cofx}] - (let [{:keys [in-progress? password]} sign + [{{:signing/keys [sign tx] :ens/keys [registration] :as db} :db :as cofx}] + (let [{:keys [in-progress? password]} sign {:keys [tx-obj gas gasPrice maxPriorityFeePerGas - maxFeePerGas message nonce]} tx - hashed-password (ethereum/sha3 (security/safe-unmask-data password))] + maxFeePerGas message nonce]} tx + hashed-password (ethereum/sha3 (security/safe-unmask-data password)) + {:keys [action username custom-domain?]} registration + {:keys [public-key]} (:profile/profile db) + chain-id (ethereum/chain-id db)] (if message (sign-message cofx) - (let [tx-obj-to-send (merge tx-obj - (when gas - {:gas (str "0x" (native-module/number-to-hex gas))}) - (when gasPrice - {:gasPrice (str "0x" (native-module/number-to-hex gasPrice))}) - (when nonce - {:nonce (str "0x" (native-module/number-to-hex nonce))}) - (when maxPriorityFeePerGas - {:maxPriorityFeePerGas (str "0x" - (native-module/number-to-hex - (js/parseInt maxPriorityFeePerGas)))}) - (when maxFeePerGas - {:maxFeePerGas (str "0x" - (native-module/number-to-hex - (js/parseInt maxFeePerGas)))}))] + (let [tx-obj-to-send (merge tx-obj + (when gas + {:gas (str "0x" (native-module/number-to-hex gas))}) + (when gasPrice + {:gasPrice (str "0x" (native-module/number-to-hex gasPrice))}) + (when nonce + {:nonce (str "0x" (native-module/number-to-hex nonce))}) + (when maxPriorityFeePerGas + {:maxPriorityFeePerGas (str "0x" + (native-module/number-to-hex + (js/parseInt maxPriorityFeePerGas)))}) + (when maxFeePerGas + {:maxFeePerGas (str "0x" + (native-module/number-to-hex + (js/parseInt maxFeePerGas)))})) + cb #(re-frame/dispatch + [:signing/transaction-completed % + tx-obj-to-send hashed-password]) + watch-ens-tx-fn #(re-frame/dispatch + [:transactions/watch-transaction + % + {:trigger-fn + (fn [_ {:keys [hash type]}] + (and (= hash %) + (contains? #{:outbound :failed} type))) + :on-trigger + (fn [{:keys [type]}] + (case type + :outbound (do (rf/dispatch [:ens/clear-registration %]) + (rf/dispatch [:ens/save-username custom-domain? + username false])) + + :failed (rf/dispatch [:ens/update-ens-tx-state :failure username + custom-domain? %]) + nil))}])] (when-not in-progress? - {:db (update db :signing/sign assoc :error nil :in-progress? true) - :signing/send-transaction-fx {:tx-obj tx-obj-to-send - :hashed-password hashed-password - :cb #(re-frame/dispatch - [:signing/transaction-completed % - tx-obj-to-send hashed-password])}}))))) + (cond-> {:db (update db :signing/sign assoc :error nil :in-progress? true)} + (nil? action) (assoc :signing/send-transaction-fx + {:tx-obj tx-obj-to-send + :hashed-password hashed-password + :cb cb}) + (= action constants/ens-action-type-register) (assoc :json-rpc/call + [{:method "ens_register" + :params [chain-id tx-obj-to-send + hashed-password username + public-key] + :on-success + #(do + (cb (types/clj->json + {:result %})) + (watch-ens-tx-fn %)) + :on-error #(cb (types/clj->json + {:error %}))}]) + (= action + constants/ens-action-type-set-pub-key) (assoc :json-rpc/call + [{:method "ens_setPubKey" + :params [chain-id tx-obj-to-send + hashed-password username + public-key] + :on-success #(do (cb (types/clj->json + {:result %})) + (watch-ens-tx-fn %)) + :on-error #(cb (types/clj->json + {:error + %}))}]))))))) (rf/defn prepare-unconfirmed-transaction [{:keys [db now]} new-tx-hash @@ -155,19 +202,10 @@ :tip-cap maxPriorityFeePerGas :gas-limit gas-limit}] (log/info "[signing] prepare-unconfirmed-transaction" tx) - {:db (-> db - ;;remove old transaction, because we replace it with the new one - (update-in [:wallet :accounts from :transactions] dissoc old-tx-hash) - (assoc-in [:wallet :accounts from :transactions new-tx-hash] tx)) - :json-rpc/call [{:method "wallet_storePendingTransaction" - :params [(-> tx - (dissoc :gas-price :gas-limit) - (assoc :gasPrice - (money/to-fixed (money/bignumber gasPrice)) - :gasLimit (money/to-fixed (money/bignumber gas))) - clj->js)] - :on-success #(log/info "pending transfer is saved") - :on-error #(log/info "pending transfer was not saved" %)}]})) + {:db (-> db + ;;remove old transaction, because we replace it with the new one + (update-in [:wallet :accounts from :transactions] dissoc old-tx-hash) + (assoc-in [:wallet :accounts from :transactions new-tx-hash] tx))})) (defn get-method-type [data] @@ -431,6 +469,7 @@ {:events [:signing/transaction-completed] :interceptors [(re-frame/inject-cofx :random-id-generator)]} [cofx response tx-obj hashed-password] + (log/info "transaction-completed" "tx-obj" tx-obj "response" response) (let [cofx-in-progress-false (assoc-in cofx [:db :signing/sign :in-progress?] false) {:keys [result error]} (types/json->clj response)] (if error diff --git a/src/status_im/transport/message/core.cljs b/src/status_im/transport/message/core.cljs index e07c14ea27..e0fa66cb4c 100644 --- a/src/status_im/transport/message/core.cljs +++ b/src/status_im/transport/message/core.cljs @@ -51,6 +51,7 @@ ^js cleared-histories (.-clearedHistories response-js) ^js identity-images (.-identityImages response-js) ^js accounts (.-accounts response-js) + ^js ens-username-details-js (.-ensUsernameDetails response-js) sync-handler (when-not process-async process-response)] (cond @@ -193,7 +194,14 @@ (rf/merge cofx (process-next response-js sync-handler) (models.visibility-status-updates/sync-visibility-status-update - current-visibility-status-clj)))))) + current-visibility-status-clj))) + + (seq ens-username-details-js) + (let [ens-username-details-clj (types/js->clj ens-username-details-js)] + (js-delete response-js "ensUsernameDetails") + (rf/merge cofx + (process-next response-js sync-handler) + (rf/dispatch [:ens/update-usernames ens-username-details-clj])))))) (defn group-by-and-update-unviewed-counts "group messages by current chat, profile updates, transactions and update unviewed counters in db for not curent chats" diff --git a/src/status_im/ui/screens/ens/views.cljs b/src/status_im/ui/screens/ens/views.cljs index 38485f49cb..f3fc72bb78 100644 --- a/src/status_im/ui/screens/ens/views.cljs +++ b/src/status_im/ui/screens/ens/views.cljs @@ -702,7 +702,7 @@ [name-item {:name username :action (when-not (= state :submitted) - #(re-frame/dispatch [:clear-ens-registration tx-hash])) + #(re-frame/dispatch [:ens/clear-registration tx-hash])) :subtitle (case state :submitted (i18n/label :t/ens-registration-in-progress) :failure (i18n/label :t/ens-registration-failure) diff --git a/src/status_im/wallet/core.cljs b/src/status_im/wallet/core.cljs index fcb633c57b..92f701fb6c 100644 --- a/src/status_im/wallet/core.cljs +++ b/src/status_im/wallet/core.cljs @@ -803,21 +803,18 @@ ::start-watching (fn [hashes] (log/info "[wallet] watch transactions" hashes) - (doseq [[address tx-hash] hashes] + (doseq [[address tx-hash chain-id] hashes] (json-rpc/call - {:method "wallet_watchTransaction" - :params [tx-hash] + {:method "wallet_watchTransactionByChainID" + :params [chain-id tx-hash] :on-success #(re-frame.core/dispatch [::transaction-included address tx-hash]) :on-error #(log/info "[wallet] watch transaction error" % "hash" tx-hash)})))) (rf/defn watch-tx {:events [:watch-tx]} [{:keys [db] :as cofx} address tx-id] - {::start-watching [[address tx-id]]}) - -(rf/defn watch-transsactions - [_ hashes] - {::start-watching hashes}) + (let [chain-id (ethereum/chain-id db)] + {::start-watching [[address tx-id chain-id]]})) (rf/defn clear-timeouts [{:keys [db]}] @@ -1013,7 +1010,7 @@ db))) db (map (partial normalize-transaction db) raw-transactions)) - ::start-watching (map (juxt :from :hash) raw-transactions)}) + ::start-watching (map (juxt :from :hash :network_id) raw-transactions)}) (re-frame/reg-fx :wallet/delete-pending-transactions diff --git a/src/status_im2/constants.cljs b/src/status_im2/constants.cljs index 65dc0d2f76..eba3baafad 100644 --- a/src/status_im2/constants.cljs +++ b/src/status_im2/constants.cljs @@ -354,3 +354,6 @@ {:ios "Inter-Medium.otf" :android "Inter-Medium.ttf" :uppercase-ratio 0.603861228044709}) + +(def ^:const ens-action-type-register 1) +(def ^:const ens-action-type-set-pub-key 2) diff --git a/src/status_im2/contexts/profile/login/events.cljs b/src/status_im2/contexts/profile/login/events.cljs index 46c788b77c..1383d04949 100644 --- a/src/status_im2/contexts/profile/login/events.cljs +++ b/src/status_im2/contexts/profile/login/events.cljs @@ -130,7 +130,7 @@ (rf/defn login-node-signal [{{:onboarding-2/keys [recovered-account? new-account?] :as db} :db :as cofx} - {:keys [settings account error]}] + {:keys [settings account ensUsernames error]}] (log/debug "[signals] node.login" "error" error) (if error {:db (update db :profile/login #(-> % (dissoc :processing) (assoc :error error)))} @@ -138,7 +138,8 @@ {:db (dissoc db :profile/login) :dispatch-n [[:logging/initialize-web3-client-version] (when (and new-account? (not recovered-account?)) - [:wallet/set-initial-blocks-range])]} + [:wallet/set-initial-blocks-range]) + [:ens/update-usernames ensUsernames]]} (login-existing-profile settings account)))) (rf/defn login-with-biometric-if-available diff --git a/src/status_im2/subs/ens.cljs b/src/status_im2/subs/ens.cljs index d853bae035..70cff94c08 100644 --- a/src/status_im2/subs/ens.cljs +++ b/src/status_im2/subs/ens.cljs @@ -5,12 +5,6 @@ [status-im.ethereum.core :as ethereum] [utils.money :as money])) -(re-frame/reg-sub - :multiaccount/usernames - :<- [:profile/profile] - (fn [multiaccount] - (:usernames multiaccount))) - (re-frame/reg-sub :ens/preferred-name :<- [:profile/profile] @@ -83,12 +77,17 @@ (re-frame/reg-sub :ens.main/screen - :<- [:multiaccount/usernames] + :<- [:ens/names] :<- [:profile/profile] :<- [:ens/preferred-name] :<- [:ens/registrations] (fn [[names multiaccount preferred-name registrations]] - {:names names - :profile/profile multiaccount - :preferred-name preferred-name - :registrations registrations})) + (let [not-in-progress-names (reduce (fn [acc {:keys [username custom-domain?]}] + (let [full-name (ens/fullname custom-domain? username)] + (remove #(= % full-name) acc))) + (keys names) + (vals registrations))] + {:names not-in-progress-names + :profile/profile multiaccount + :preferred-name preferred-name + :registrations registrations}))) diff --git a/status-go-version.json b/status-go-version.json index 88775a2970..f4130adb4a 100644 --- a/status-go-version.json +++ b/status-go-version.json @@ -3,7 +3,7 @@ "_comment": "Instead use: scripts/update-status-go.sh ", "owner": "status-im", "repo": "status-go", - "version": "v0.166.9", - "commit-sha1": "e72a033930872c909cb7cc61aadefb34341e9bd7", - "src-sha256": "0ldji1pk9a45lpwcdzrkmnfhvz311v92nfkwk16gv65cv54705fv" + "version": "v0.166.11", + "commit-sha1": "6bcf5f1289f9160168574290cbd6f90dede3f8f6", + "src-sha256": "0g56pawjpxgjp93slvpbkajz73ajrjfi0n0js3hvqh8x4ciwa43p" }