enforce lowercase for namehash
Signed-off-by: Eric Dvorsak <eric@dvorsak.fr>
This commit is contained in:
parent
1769bfb695
commit
3a982e5d6b
|
@ -17,7 +17,7 @@
|
||||||
:new-chat/set-new-identity
|
:new-chat/set-new-identity
|
||||||
(fn [{{:keys [web3 network network-status] :as db} :db} [_ new-identity]]
|
(fn [{{:keys [web3 network network-status] :as db} :db} [_ new-identity]]
|
||||||
(let [new-identity-error (db/validate-pub-key new-identity (:account/account db))]
|
(let [new-identity-error (db/validate-pub-key new-identity (:account/account db))]
|
||||||
(if (stateofus/is-stateofus-name? new-identity)
|
(if (stateofus/is-valid-name? new-identity)
|
||||||
(let [network (get-in db [:account/account :networks network])
|
(let [network (get-in db [:account/account :networks network])
|
||||||
chain (ethereum/network->chain-keyword network)]
|
chain (ethereum/network->chain-keyword network)]
|
||||||
{:resolve-whisper-identity {:web3 web3
|
{:resolve-whisper-identity {:web3 web3
|
||||||
|
|
|
@ -97,7 +97,11 @@
|
||||||
(defn hex->bignumber [s]
|
(defn hex->bignumber [s]
|
||||||
(money/bignumber (if (= s hex-prefix) 0 s)))
|
(money/bignumber (if (= s hex-prefix) 0 s)))
|
||||||
|
|
||||||
(defn hex->address [s]
|
(defn hex->address
|
||||||
|
"When hex value is 66 char in length (2 for 0x, 64 for
|
||||||
|
the 32 bytes used by abi-spec for an address), only keep
|
||||||
|
the part that constitute the address and normalize it,"
|
||||||
|
[s]
|
||||||
(when (= 66 (count s))
|
(when (= 66 (count s))
|
||||||
(normalized-address (subs s 26))))
|
(normalized-address (subs s 26))))
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,9 @@
|
||||||
(defn namehash [s]
|
(defn namehash [s]
|
||||||
(ethereum/normalized-address (if (string/blank? s)
|
(ethereum/normalized-address (if (string/blank? s)
|
||||||
default-namehash
|
default-namehash
|
||||||
(let [[label remainder] (string/split s #"\." 2)]
|
(let [[label remainder] (-> s
|
||||||
|
string/lower-case
|
||||||
|
(string/split #"\." 2))]
|
||||||
(ethereum/sha3 (+ (namehash remainder)
|
(ethereum/sha3 (+ (namehash remainder)
|
||||||
(subs (ethereum/sha3 label) 2))
|
(subs (ethereum/sha3 label) 2))
|
||||||
{:encoding "hex"})))))
|
{:encoding "hex"})))))
|
||||||
|
|
|
@ -4,11 +4,11 @@
|
||||||
[status-im.utils.ethereum.core :as ethereum]
|
[status-im.utils.ethereum.core :as ethereum]
|
||||||
[status-im.utils.ethereum.ens :as ens]))
|
[status-im.utils.ethereum.ens :as ens]))
|
||||||
|
|
||||||
(defn is-stateofus-name? [ens-name]
|
(defn is-valid-name? [ens-name]
|
||||||
(string/ends-with? ens-name ".stateofus.eth"))
|
(string/ends-with? ens-name ".stateofus.eth"))
|
||||||
|
|
||||||
(defn addr [web3 registry ens-name cb]
|
(defn addr [web3 registry ens-name cb]
|
||||||
{:pre [(is-stateofus-name? ens-name)]}
|
{:pre [(is-valid-name? ens-name)]}
|
||||||
(ens/resolver web3
|
(ens/resolver web3
|
||||||
registry
|
registry
|
||||||
ens-name
|
ens-name
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
TODO: https://solidity.readthedocs.io/en/develop/abi-spec.html needs to be implemented
|
TODO: https://solidity.readthedocs.io/en/develop/abi-spec.html needs to be implemented
|
||||||
to replace this by dynamic parameters"
|
to replace this by dynamic parameters"
|
||||||
[web3 registry ens-name cb]
|
[web3 registry ens-name cb]
|
||||||
{:pre [(is-stateofus-name? ens-name)]}
|
{:pre [(is-valid-name? ens-name)]}
|
||||||
(ens/resolver web3
|
(ens/resolver web3
|
||||||
registry
|
registry
|
||||||
ens-name
|
ens-name
|
||||||
|
|
Loading…
Reference in New Issue