[#12750] Show warning when adding ENS name for wallet account
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
9a2987da60
commit
c6f041f0c5
|
@ -76,15 +76,17 @@
|
||||||
|
|
||||||
(fx/defn set-state
|
(fx/defn set-state
|
||||||
{:events [::name-resolved]}
|
{:events [::name-resolved]}
|
||||||
[{:keys [db]} username state]
|
[{:keys [db]} username state address]
|
||||||
(when (= username
|
(when (= username
|
||||||
(get-in db [:ens/registration :username]))
|
(get-in db [:ens/registration :username]))
|
||||||
{:db (assoc-in db [:ens/registration :state] state)}))
|
{:db (-> db
|
||||||
|
(assoc-in [:ens/registration :state] state)
|
||||||
|
(assoc-in [:ens/registration :address] address))}))
|
||||||
|
|
||||||
(fx/defn on-resolver-found
|
(fx/defn on-resolver-found
|
||||||
{:events [::resolver-found]}
|
{:events [::resolver-found]}
|
||||||
[{:keys [db] :as cofx} resolver-contract]
|
[{:keys [db] :as cofx} resolver-contract address]
|
||||||
(let [{:keys [state username custom-domain?]} (:ens/registration db)
|
(let [{:keys [username custom-domain?]} (:ens/registration db)
|
||||||
{:keys [public-key]} (:multiaccount db)
|
{:keys [public-key]} (:multiaccount db)
|
||||||
{:keys [x y]} (ethereum/coordinates public-key)
|
{:keys [x y]} (ethereum/coordinates public-key)
|
||||||
namehash (ens/namehash (str username (when-not custom-domain?
|
namehash (ens/namehash (str username (when-not custom-domain?
|
||||||
|
@ -92,6 +94,7 @@
|
||||||
(signing/eth-transaction-call
|
(signing/eth-transaction-call
|
||||||
cofx
|
cofx
|
||||||
{:contract resolver-contract
|
{:contract resolver-contract
|
||||||
|
:from address
|
||||||
:method "setPubkey(bytes32,bytes32,bytes32)"
|
:method "setPubkey(bytes32,bytes32,bytes32)"
|
||||||
:params [namehash x y]
|
:params [namehash x y]
|
||||||
:on-result [::save-username custom-domain? username true]
|
:on-result [::save-username custom-domain? username true]
|
||||||
|
@ -115,7 +118,7 @@
|
||||||
(fx/defn on-input-submitted
|
(fx/defn on-input-submitted
|
||||||
{:events [::input-submitted ::input-icon-pressed]}
|
{:events [::input-submitted ::input-icon-pressed]}
|
||||||
[{:keys [db] :as cofx}]
|
[{:keys [db] :as cofx}]
|
||||||
(let [{:keys [state username custom-domain?]} (:ens/registration db)
|
(let [{:keys [state username custom-domain? address]} (:ens/registration db)
|
||||||
registry-contract (get ens/ens-registries (ethereum/chain-keyword db))
|
registry-contract (get ens/ens-registries (ethereum/chain-keyword db))
|
||||||
ens-name (str username (when-not custom-domain?
|
ens-name (str username (when-not custom-domain?
|
||||||
".stateofus.eth"))]
|
".stateofus.eth"))]
|
||||||
|
@ -124,14 +127,14 @@
|
||||||
(navigation/navigate-to-cofx cofx :ens-checkout {})
|
(navigation/navigate-to-cofx cofx :ens-checkout {})
|
||||||
:connected-with-different-key
|
:connected-with-different-key
|
||||||
(ens/resolver registry-contract ens-name
|
(ens/resolver registry-contract ens-name
|
||||||
#(re-frame/dispatch [::resolver-found %]))
|
#(re-frame/dispatch [::resolver-found % address]))
|
||||||
:connected
|
:connected
|
||||||
(save-username cofx custom-domain? username true)
|
(save-username cofx custom-domain? username true)
|
||||||
;; for other states, we do nothing
|
;; for other states, we do nothing
|
||||||
nil)))
|
nil)))
|
||||||
|
|
||||||
(defn- on-resolve-owner
|
(defn- on-resolve-owner
|
||||||
[registry custom-domain? username address public-key response resolve-last-id* resolve-last-id]
|
[registry custom-domain? username addresses public-key response resolve-last-id* resolve-last-id]
|
||||||
(when (= @resolve-last-id* resolve-last-id)
|
(when (= @resolve-last-id* resolve-last-id)
|
||||||
(cond
|
(cond
|
||||||
|
|
||||||
|
@ -141,14 +144,14 @@
|
||||||
|
|
||||||
;; if we get an address back, we try to get the public key associated
|
;; if we get an address back, we try to get the public key associated
|
||||||
;; with the username as well
|
;; with the username as well
|
||||||
(= (eip55/address->checksum address)
|
(get addresses (eip55/address->checksum response))
|
||||||
(eip55/address->checksum response))
|
|
||||||
(resolver/pubkey registry (fullname custom-domain? username)
|
(resolver/pubkey registry (fullname custom-domain? username)
|
||||||
#(re-frame/dispatch [::name-resolved username
|
#(re-frame/dispatch [::name-resolved username
|
||||||
(cond
|
(cond
|
||||||
(not public-key) :owned
|
(not public-key) :owned
|
||||||
(= % public-key) :connected
|
(= % public-key) :connected
|
||||||
:else :connected-with-different-key)]))
|
:else :connected-with-different-key)
|
||||||
|
(eip55/address->checksum response)]))
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(re-frame/dispatch [::name-resolved username :taken]))))
|
(re-frame/dispatch [::name-resolved username :taken]))))
|
||||||
|
@ -220,12 +223,12 @@
|
||||||
(when (= state :searching)
|
(when (= state :searching)
|
||||||
(let [{:keys [multiaccount]} db
|
(let [{:keys [multiaccount]} db
|
||||||
{:keys [public-key]} multiaccount
|
{:keys [public-key]} multiaccount
|
||||||
address (ethereum/default-address db)
|
addresses (ethereum/addresses-without-watch db)
|
||||||
registry (get ens/ens-registries (ethereum/chain-keyword db))]
|
registry (get ens/ens-registries (ethereum/chain-keyword db))]
|
||||||
{::resolve-owner [registry
|
{::resolve-owner [registry
|
||||||
(fullname custom-domain? username)
|
(fullname custom-domain? username)
|
||||||
#(on-resolve-owner
|
#(on-resolve-owner
|
||||||
registry custom-domain? username address public-key %
|
registry custom-domain? username addresses public-key %
|
||||||
resolve-last-id @resolve-last-id)]})))))
|
resolve-last-id @resolve-last-id)]})))))
|
||||||
|
|
||||||
(fx/defn return-to-ens-main-screen
|
(fx/defn return-to-ens-main-screen
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
(ns status-im.ethereum.core
|
(ns status-im.ethereum.core
|
||||||
(:require [clojure.string :as string]
|
(:require [clojure.string :as string]
|
||||||
["web3-utils" :as utils]))
|
["web3-utils" :as utils]
|
||||||
|
[status-im.ethereum.eip55 :as eip55]))
|
||||||
|
|
||||||
(defn sha3 [s]
|
(defn sha3 [s]
|
||||||
(when s
|
(when s
|
||||||
|
@ -74,6 +75,11 @@
|
||||||
get-default-account
|
get-default-account
|
||||||
:address))
|
:address))
|
||||||
|
|
||||||
|
(defn addresses-without-watch [db]
|
||||||
|
(into #{}
|
||||||
|
(remove #(= (:type %) :watch)
|
||||||
|
(map #(eip55/address->checksum (:address %)) (get db :multiaccount/accounts)))))
|
||||||
|
|
||||||
(defn naked-address [s]
|
(defn naked-address [s]
|
||||||
(when s
|
(when s
|
||||||
(string/replace s hex-prefix "")))
|
(string/replace s hex-prefix "")))
|
||||||
|
|
|
@ -439,9 +439,10 @@
|
||||||
|
|
||||||
(fx/defn eth-transaction-call
|
(fx/defn eth-transaction-call
|
||||||
"Prepares tx-obj for contract call and show signing sheet"
|
"Prepares tx-obj for contract call and show signing sheet"
|
||||||
[cofx {:keys [contract method params on-result on-error]}]
|
[cofx {:keys [contract method params on-result on-error from]}]
|
||||||
(sign cofx {:tx-obj {:to contract
|
(sign cofx {:tx-obj {:to contract
|
||||||
:data (abi-spec/encode method params)}
|
:data (abi-spec/encode method params)
|
||||||
|
:from from}
|
||||||
:on-result on-result
|
:on-result on-result
|
||||||
:on-error on-error}))
|
:on-error on-error}))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue