fix ens contenthash resolution
Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
parent
430a8fb27c
commit
b344322475
|
@ -97,14 +97,7 @@
|
|||
(fn [[name]]
|
||||
(cb name))}))
|
||||
|
||||
(defn contenthash
|
||||
[resolver ens-name cb]
|
||||
(json-rpc/eth-call
|
||||
{:contract resolver
|
||||
:method "contenthash(bytes32)"
|
||||
:params [(namehash ens-name)]
|
||||
:on-success
|
||||
(fn [raw-hash]
|
||||
(defn cleanup-hash [raw-hash]
|
||||
;; NOTE: it would be better if our abi-spec/decode was able to do that
|
||||
(let [;; ignore hex prefix
|
||||
[_ raw-hash-rest] (split-at 2 raw-hash)
|
||||
|
@ -120,7 +113,18 @@
|
|||
hash-field-length (* ^number (abi-spec/hex-to-number (string/join hash-field-length-hex)) 2)
|
||||
;; we get the hash
|
||||
[hash _] (split-at hash-field-length raw-hash-rest)]
|
||||
(cb (string/join "0x" hash))))}))
|
||||
(str "0x" (string/join hash))))
|
||||
|
||||
(defn contenthash
|
||||
[resolver ens-name cb]
|
||||
(json-rpc/eth-call
|
||||
{:contract resolver
|
||||
:method "contenthash(bytes32)"
|
||||
:params [(namehash ens-name)]
|
||||
:on-success
|
||||
(fn [raw-hash]
|
||||
;; NOTE: it would be better if our abi-spec/decode was able to do that
|
||||
(cb (cleanup-hash raw-hash)))}))
|
||||
|
||||
(defn content
|
||||
[resolver ens-name cb]
|
||||
|
|
|
@ -9,3 +9,11 @@
|
|||
(ens/namehash "eth")))
|
||||
(is (= "0xde9b09fd7c5f901e23a3f19fecc54828e9c848539801e86591bd9801b019f84f"
|
||||
(ens/namehash "foo.eth"))))
|
||||
|
||||
(deftest cleanup-hash
|
||||
;; simpledapp.eth
|
||||
(is (= "0xe30101701220795c1ea0ceaf4ceedc9896f14b73bb30e978e4855ee221b9a57f5a934268280e"
|
||||
(ens/cleanup-hash "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026e30101701220795c1ea0ceaf4ceedc9896f14b73bb30e978e4855ee221b9a57f5a934268280e0000000000000000000000000000000000000000000000000000")))
|
||||
;; ethereum.eth
|
||||
(is (= "0xe301017012206e70f0f72e2bcd0ad69bb2b15ee9e0f4f88693f6b2f485e48699e7d6f8dbd62a"
|
||||
(ens/cleanup-hash "0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000026e301017012206e70f0f72e2bcd0ad69bb2b15ee9e0f4f88693f6b2f485e48699e7d6f8dbd62a0000000000000000000000000000000000000000000000000000"))))
|
||||
|
|
Loading…
Reference in New Issue