add support for pubkey method on ens contract

Signed-off-by: Eric Dvorsak <eric@dvorsak.fr>
This commit is contained in:
Eric Dvorsak 2018-08-23 13:33:38 +02:00
parent 60b343ef16
commit bca9ae25af
No known key found for this signature in database
GPG Key ID: 932AC1CE5F05DE0C
3 changed files with 16 additions and 13 deletions

View File

@ -10,7 +10,7 @@
(re-frame/reg-fx (re-frame/reg-fx
:resolve-whisper-identity :resolve-whisper-identity
(fn [{:keys [web3 registry ens-name cb]}] (fn [{:keys [web3 registry ens-name cb]}]
(stateofus/text web3 registry ens-name cb))) (stateofus/pubkey web3 registry ens-name cb)))
(handlers/register-handler-fx (handlers/register-handler-fx
:new-chat/set-new-identity :new-chat/set-new-identity

View File

@ -73,4 +73,15 @@
(def ABI-hash "0x2203ab56") (def ABI-hash "0x2203ab56")
(def pubkey-hash "0xc8690233") (def pubkey-hash "0xc8690233")
(defn add-uncompressed-public-key-prefix [key]
(when key
(str "0x04" (subs key 2))))
(defn pubkey [web3 resolver ens-name cb]
(ethereum/call web3
(ethereum/call-params resolver
"pubkey(bytes32)"
(namehash ens-name))
(fn [_ key] (cb (add-uncompressed-public-key-prefix key)))))
;; TODO ABI, pubkey ;; TODO ABI, pubkey

View File

@ -14,21 +14,13 @@
ens-name ens-name
#(ens/addr web3 % ens-name cb))) #(ens/addr web3 % ens-name cb)))
(defn text (defn pubkey
"calls the text function on the stateofus resolver contract for `statusAccount` key
TODO: https://solidity.readthedocs.io/en/develop/abi-spec.html needs to be implemented
to replace this by dynamic parameters"
[web3 registry ens-name cb] [web3 registry ens-name cb]
{:pre [(is-valid-name? ens-name)]} {:pre [(is-valid-name? ens-name)]}
(ens/resolver web3 (ens/resolver web3
registry registry
ens-name ens-name
#(ethereum/call web3 #(ens/pubkey web3 % ens-name cb)))
{:to %
:data (str "0x59d1d43c"
(subs (ens/namehash ens-name) 2)
"0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000d7374617475734163636f756e7400000000000000000000000000000000000000")}
(fn [_ text] (cb (ethereum/hex->string (subs text 130 394)))))))
#_(addr (:web3 @re-frame.db/app-db) "0x112234455c3a32fd11230c42e7bccd4a84e02010" "erictest.stateofus.eth" println) #_(addr (:web3 @re-frame.db/app-db) "0x112234455c3a32fd11230c42e7bccd4a84e02010" "qweqwe.stateofus.eth" println)
#_(text (:web3 @re-frame.db/app-db) "0x112234455c3a32fd11230c42e7bccd4a84e02010" "erictest.stateofus.eth" println) #_(pubkey (:web3 @re-frame.db/app-db) "0x112234455c3a32fd11230c42e7bccd4a84e02010" "qweqwe.stateofus.eth" println)