[#7188] undefined is not an object (evaluating 'e.substring') when dapps / stickers offline

Signed-off-by: Andrey Shovkoplyas <motor4ik@gmail.com>
This commit is contained in:
Andrey Shovkoplyas 2019-03-19 14:55:37 +01:00
parent c61ce1892f
commit d0de1c5c24
No known key found for this signature in database
GPG Key ID: EAAB7C8622D860A4
2 changed files with 4 additions and 6 deletions

View File

@ -81,11 +81,9 @@
(re-frame/dispatch [:browser.callback/resolve-ens-contenthash]))))
(defn resolve-ens-contenthash-callback [hex]
(let [proto-code (subs hex 2 4)
(let [proto-code (when hex (subs hex 2 4))
hash (when hex (multihash/base58 (multihash/create :sha2-256 (subs hex 12))))]
;; We only support IPFS and SWARM
;; TODO Once more implementations / providers are published this will have to be improved
(if (and ((#{constants/swarm-proto-code constants/ipfs-proto-code} proto-code) hash (not= hash resolver/default-hash)))
(if (and proto-code (#{constants/swarm-proto-code constants/ipfs-proto-code} proto-code) hash (not= hash resolver/default-hash))
(re-frame/dispatch [:browser.callback/resolve-ens-multihash-success proto-code hash])
(re-frame/dispatch [:browser.callback/resolve-ens-multihash-error]))))

View File

@ -18,14 +18,14 @@
(ethereum/call web3
(ethereum/call-params contract "getPackData(uint256)" (ethereum/int->hex pack-id))
(fn [_ data]
(cb (abi-spec/decode (subs data 2) ["bytes4[]" "address" "bool" "uint256" "uint256" "bytes"])))))
(cb (when data (abi-spec/decode (subs data 2) ["bytes4[]" "address" "bool" "uint256" "uint256" "bytes"]))))))
(defn owned-tokens [web3 contract address cb]
"Returns vector of owned tokens ids in the contract by address"
(ethereum/call web3
(ethereum/call-params contract "tokensOwnedBy(address)" (ethereum/normalized-address address))
(fn [_ data]
(cb (first (abi-spec/decode (subs data 2) ["uint256[]"]))))))
(cb (when data (first (abi-spec/decode (subs data 2) ["uint256[]"])))))))
(defn token-pack-id [web3 contract token cb]
"Returns pack id in the contract by token id"