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