[#13086] stateofus.eth ENS username is not connected with chat key after purchasing
Signed-off-by: andrey <motor4ik@gmail.com>
This commit is contained in:
parent
c59089c7d3
commit
aaf655abe4
|
@ -2,18 +2,14 @@
|
|||
(:refer-clojure :exclude [name])
|
||||
(:require [clojure.string :as string]
|
||||
[re-frame.core :as re-frame]
|
||||
[status-im.ethereum.abi-spec :as abi-spec]
|
||||
[status-im.ethereum.contracts :as contracts]
|
||||
[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]
|
||||
[status-im.signing.core :as signing]
|
||||
[status-im.navigation :as navigation]
|
||||
[status-im.utils.datetime :as datetime]
|
||||
[status-im.utils.fx :as fx]
|
||||
[status-im.utils.money :as money]
|
||||
[status-im.utils.random :as random]
|
||||
[status-im.bottom-sheet.core :as bottom-sheet]))
|
||||
|
||||
|
@ -80,23 +76,6 @@
|
|||
(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 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?
|
||||
".stateofus.eth")))]
|
||||
(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]
|
||||
:on-error [::on-registration-failure]})))
|
||||
|
||||
(fx/defn save-username
|
||||
{:events [::save-username]}
|
||||
[{:keys [db] :as cofx} custom-domain? username redirectToSummary]
|
||||
|
@ -112,19 +91,30 @@
|
|||
(multiaccounts.update/multiaccount-update
|
||||
:preferred-name name {})))))
|
||||
|
||||
(fx/defn set-pub-key
|
||||
{:events [::set-pub-key]}
|
||||
[{:keys [db]}]
|
||||
(let [{:keys [username address custom-domain?]} (:ens/registration db)
|
||||
address (or address (ethereum/default-address db))
|
||||
{:keys [public-key]} (:multiaccount 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]}]))))
|
||||
|
||||
(fx/defn on-input-submitted
|
||||
{:events [::input-submitted ::input-icon-pressed]}
|
||||
{:events [::input-submitted]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(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"))]
|
||||
(let [{:keys [state username custom-domain?]} (:ens/registration db)]
|
||||
(case state
|
||||
(:available :owned)
|
||||
(navigation/navigate-to-cofx cofx :ens-checkout {})
|
||||
:connected-with-different-key
|
||||
(ens/resolver registry-contract ens-name
|
||||
#(re-frame/dispatch [::resolver-found % address]))
|
||||
(re-frame/dispatch [::set-pub-key])
|
||||
:connected
|
||||
(save-username cofx custom-domain? username true)
|
||||
;; for other states, we do nothing
|
||||
|
@ -148,6 +138,8 @@
|
|||
#(re-frame/dispatch [::name-resolved username
|
||||
(cond
|
||||
(not public-key) :owned
|
||||
(string/ends-with? % "0000000000000000000000000000000000000000000000000000000000000000")
|
||||
:invalid
|
||||
(= % public-key) :connected
|
||||
:else :connected-with-different-key)
|
||||
(eip55/address->checksum response)]))
|
||||
|
@ -160,33 +152,19 @@
|
|||
3 50
|
||||
1 10))
|
||||
|
||||
;; (andrey) there is the method "register" in status-go, but im not sure how we could use it
|
||||
;; because we still need to prepare tx and show it to user, and then have a condition to do not sign tx but
|
||||
;; call register method instead, doesn't look like a good solution
|
||||
(fx/defn register-name
|
||||
{:events [::register-name-pressed]}
|
||||
[{:keys [db] :as cofx}]
|
||||
(let [{:keys [custom-domain? username address]}
|
||||
[{:keys [db]} address]
|
||||
(let [{:keys [username]}
|
||||
(:ens/registration db)
|
||||
{:keys [public-key]} (:multiaccount db)
|
||||
chain (ethereum/chain-keyword db)
|
||||
chain-id (ethereum/chain-id db)
|
||||
amount (registration-cost chain-id)
|
||||
{:keys [x y]} (ethereum/coordinates public-key)]
|
||||
(stateofus/get-registrar
|
||||
chain
|
||||
(fn [contract]
|
||||
(signing/eth-transaction-call
|
||||
cofx
|
||||
{:contract (contracts/get-address db :status/snt)
|
||||
:method "approveAndCall(address,uint256,bytes)"
|
||||
:from address
|
||||
:params [contract
|
||||
(money/unit->token amount 18)
|
||||
(abi-spec/encode "register(bytes32,address,bytes32,bytes32)"
|
||||
[(ethereum/sha3 username) address x y])]
|
||||
:on-result [:update-ens-tx-state-and-redirect :submitted username custom-domain?]
|
||||
:on-error [::on-registration-failure]})))))
|
||||
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]}]))))
|
||||
|
||||
(defn- valid-custom-domain? [username]
|
||||
(and (ens/is-valid-eth-name? username)
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
(ns status-im.ethereum.ens
|
||||
"
|
||||
https://docs.ens.domains/en/latest/index.html
|
||||
https://eips.ethereum.org/EIPS/eip-137
|
||||
https://eips.ethereum.org/EIPS/eip-181
|
||||
"
|
||||
(:refer-clojure :exclude [name])
|
||||
(:require [clojure.string :as string]
|
||||
[status-im.ethereum.core :as ethereum]
|
||||
[status-im.ethereum.json-rpc :as json-rpc]
|
||||
[status-im.ethereum.abi-spec :as abi-spec]))
|
||||
|
||||
|
@ -16,36 +9,10 @@
|
|||
:testnet "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"
|
||||
:rinkeby "0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"})
|
||||
|
||||
(def default-namehash "0000000000000000000000000000000000000000000000000000000000000000")
|
||||
(def default-address "0x0000000000000000000000000000000000000000")
|
||||
(def default-key "0x0400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
|
||||
(def default-hash "0x0000000000000000000000000000000000000000000000000000000000000000")
|
||||
|
||||
(defn namehash
|
||||
[s]
|
||||
(ethereum/normalized-hex
|
||||
(if (string/blank? s)
|
||||
default-namehash
|
||||
(let [[label remainder] (-> s
|
||||
string/lower-case
|
||||
(string/split #"\." 2))]
|
||||
(if-not (seq label)
|
||||
default-namehash
|
||||
(ethereum/sha3 (str (namehash remainder)
|
||||
(subs (ethereum/sha3 label) 2))))))))
|
||||
|
||||
(defn resolver
|
||||
[registry ens-name cb]
|
||||
(json-rpc/eth-call
|
||||
{:contract registry
|
||||
:method "resolver(bytes32)"
|
||||
:params [(namehash ens-name)]
|
||||
:outputs ["address"]
|
||||
:on-error #(cb "0x")
|
||||
:on-success
|
||||
(fn [[address]]
|
||||
(cb (when-not (= address default-address) address)))}))
|
||||
|
||||
(defn valid-eth-name-prefix?
|
||||
[prefix]
|
||||
(not
|
||||
|
@ -72,8 +39,7 @@
|
|||
{:pre [(is-valid-eth-name? ens-name)]}
|
||||
(json-rpc/call {:method "ens_publicKeyOf"
|
||||
:params [chain-id ens-name]
|
||||
:on-success (fn [result]
|
||||
(cb (str "0x04" (subs result 2))))
|
||||
:on-success cb
|
||||
;;at some point infura started to return execution reverted error instead of "0x" result
|
||||
;;our code expects "0x" result
|
||||
:on-error #(cb "0x")}))
|
||||
|
@ -98,4 +64,16 @@
|
|||
:params [chain-id ens-name]
|
||||
:on-success
|
||||
;;NOTE: returns a timestamp in s and we want ms
|
||||
#(cb (* (js/Number (abi-spec/hex-to-number %)) 1000))}))
|
||||
#(cb (* (js/Number (abi-spec/hex-to-number %)) 1000))}))
|
||||
|
||||
(defn register-prepare-tx
|
||||
[chain-id from ens-name pubkey cb]
|
||||
(json-rpc/call {:method "ens_registerPrepareTx"
|
||||
:params [chain-id {:from from} ens-name pubkey]
|
||||
:on-success cb}))
|
||||
|
||||
(defn set-pub-key-prepare-tx
|
||||
[chain-id from ens-name pubkey cb]
|
||||
(json-rpc/call {:method "ens_setPubKeyPrepareTx"
|
||||
:params [chain-id {:from from} ens-name pubkey]
|
||||
:on-success cb}))
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
(ns status-im.ethereum.ens-test
|
||||
(:require [cljs.test :refer-macros [deftest is]]
|
||||
[status-im.ethereum.ens :as ens]))
|
||||
|
||||
(deftest namehash
|
||||
(is (= (str "0x" ens/default-namehash) (ens/namehash nil)))
|
||||
(is (= (str "0x" ens/default-namehash) (ens/namehash "")))
|
||||
(is (= "0x93cdeb708b7545dc668eb9280176169d1c33cfd8ed6f04690a0bcc88a93fc4ae"
|
||||
(ens/namehash "eth")))
|
||||
(is (= "0xde9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f"
|
||||
(ens/namehash "foo.eth"))))
|
|
@ -35,6 +35,8 @@
|
|||
"ens_ownerOf" {}
|
||||
"ens_contentHash" {}
|
||||
"ens_resourceURL" {}
|
||||
"ens_registerPrepareTx" {}
|
||||
"ens_setPubKeyPrepareTx" {}
|
||||
"net_version" {}
|
||||
"web3_clientVersion" {}
|
||||
"shh_generateSymKeyFromPassword" {}
|
||||
|
|
|
@ -41,7 +41,8 @@
|
|||
[status-im.data-store.visibility-status-updates :as visibility-status-updates-store]
|
||||
[status-im.ui.components.react :as react]
|
||||
[status-im.utils.platform :as platform]
|
||||
[status-im.ethereum.tokens :as tokens]))
|
||||
[status-im.ethereum.tokens :as tokens]
|
||||
[clojure.string :as string]))
|
||||
|
||||
(re-frame/reg-fx
|
||||
::initialize-communities-enabled
|
||||
|
@ -97,10 +98,37 @@
|
|||
[]
|
||||
accounts))
|
||||
|
||||
;;TODO remove this code after all invalid names will be fixed (ask chu or flexsurfer)
|
||||
(def invalid-addrr
|
||||
#{"0x9575cf381f71368a54e09b8138ebe046a1ef31ce93e6c37661513b21faaf741e"
|
||||
"0x56fa5de8cd4f2a3cbc122e7c51ac8690c6fc739b7c3724add97d0c55cc783d45"
|
||||
"0xf0e49d178fa34ac3ade4625e144f51e5f982434f0912bcbe23b6467343f48305"
|
||||
"0x60d1bf67e9d0d34368a6422c55f034230cc0997b186dd921fd18e89b7f0df5f2"
|
||||
"0x5fe69d562990616a02f4a5f934aa973b27bf02c4fc774f9ad82f105379f16789"
|
||||
"0xf1cabf2d74576ef76dfcb1182fd59a734a26c95ea6e68fc8f91ca4bfa1ea0594"
|
||||
"0x21d8ce6c0e32481506f98218920bee88f03d9c1b45dab3546948ccc34b1aadea"
|
||||
"0xbf7a74b39090fb5b1366f61fb4ac3ecc4b7f99f0fd3cb326dc5c18c58d58d7b6"
|
||||
"0xeeb570494d442795235589284100812e4176e9c29d151a81df43b6286ef66c49"
|
||||
"0x86a12d91c813f69a53349ff640e32af97d5f5c1f8d42d54cf4c8aa8dea231955"
|
||||
"0x0011a30f5b2023bc228f6dd5608b3e7149646fa83f33350926ceb1925af78f08"})
|
||||
|
||||
(fx/defn check-invalid-ens [{:keys [db]}]
|
||||
(async-storage/get-item
|
||||
:invalid-ens-name-seen
|
||||
(fn [already-seen]
|
||||
(when (and (not already-seen)
|
||||
(boolean (get invalid-addrr (ethereum/sha3 (string/lower-case (ethereum/default-address db))))))
|
||||
(utils/show-popup
|
||||
(i18n/label :t/warning)
|
||||
(i18n/label :t/ens-username-invalid-name-warning)
|
||||
#(async-storage/set-item! :invalid-ens-name-seen true)))))
|
||||
nil)
|
||||
|
||||
(fx/defn initialize-wallet
|
||||
{:events [::initialize-wallet]}
|
||||
[{:keys [db] :as cofx} accounts tokens custom-tokens
|
||||
favourites scan-all-tokens? new-account?]
|
||||
(check-invalid-ens cofx)
|
||||
(fx/merge
|
||||
cofx
|
||||
{:db (assoc db :multiaccount/accounts
|
||||
|
|
|
@ -439,6 +439,7 @@
|
|||
:message {:address :data :typed? } - message data to sign
|
||||
:on-result - re-frame event vector
|
||||
:on-error - re-frame event vector}"
|
||||
{:events [:signing.ui/sign]}
|
||||
[{:keys [db] :as cofx} tx]
|
||||
(fx/merge cofx
|
||||
{:db (update db :signing/queue conj (normalize-tx-obj db tx))}
|
||||
|
|
|
@ -106,7 +106,7 @@
|
|||
|
||||
(:available :connected :connected-with-different-key :owned)
|
||||
[react/touchable-highlight
|
||||
{:on-press #(debounce/dispatch-and-chill [::ens/input-icon-pressed] 3000)}
|
||||
{:on-press #(debounce/dispatch-and-chill [::ens/input-submitted] 3000)}
|
||||
[icon-wrapper colors/blue
|
||||
[icons/icon :main-icons/arrow-right {:color colors/white-persist}]]]
|
||||
|
||||
|
@ -150,6 +150,10 @@
|
|||
[help-message-text-element
|
||||
:t/ens-username-owned
|
||||
:t/ens-username-connected-with-different-key]
|
||||
:invalid
|
||||
[help-message-text-element
|
||||
:t/ens-username-owned
|
||||
:t/ens-username-registration-invalid]
|
||||
(if custom-domain?
|
||||
(case state
|
||||
:too-short
|
||||
|
@ -330,7 +334,7 @@
|
|||
:right [react/view {:padding-horizontal 8}
|
||||
[quo/button
|
||||
{:disabled (or (not @checked?) (not sufficient-funds?))
|
||||
:on-press #(debounce/dispatch-and-chill [::ens/register-name-pressed] 2000)}
|
||||
:on-press #(debounce/dispatch-and-chill [::ens/register-name-pressed address] 2000)}
|
||||
(if sufficient-funds?
|
||||
(i18n/label :t/ens-register)
|
||||
(i18n/label :t/not-enough-snt))]]}]]))))
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"_comment": "Instead use: scripts/update-status-go.sh <rev>",
|
||||
"owner": "status-im",
|
||||
"repo": "status-go",
|
||||
"version": "v0.94.4",
|
||||
"commit-sha1": "4cc53630d5cbe10ce28103154bd4cfe926176ccc",
|
||||
"src-sha256": "082wrqwjk27cijfd4vl7ma5qpd6vg01kh3k80va9l9693vn3ljdh"
|
||||
"version": "v0.94.6",
|
||||
"commit-sha1": "3cc683587dabf16e17a987d1af7b2003faf09d60",
|
||||
"src-sha256": "1d8f2x7na3scvsgarmfqay5f6nb5x9sh2m6af7lh8d295ia70ha8"
|
||||
}
|
||||
|
|
|
@ -530,6 +530,8 @@
|
|||
"ens-username-owned-continue": "Continuing will connect this username with your chat key.",
|
||||
"ens-username-taken": "Username already taken :(",
|
||||
"ens-name-not-found": "Cannot resolve ENS name",
|
||||
"ens-username-registration-invalid": "Warning! Registration process has finished in invalid state. DO NOT USE the name for wallet transactions and reach out to our support at support@status.im",
|
||||
"ens-username-invalid-name-warning": "Registration process of one of your ens names has finished in invalid state. DO NOT USE the name for wallet transactions and reach out to our support at support@status.im",
|
||||
"enter-12-words": "Enter the 12 words of your seed phrase, separated by single spaces",
|
||||
"enter-a-private-key": "Enter a private key",
|
||||
"enter-a-seed-phrase": "Enter a seed phrase",
|
||||
|
|
Loading…
Reference in New Issue