cljs-web3 related fixes, pt 2

This commit is contained in:
Teemu Patja 2017-08-29 00:02:34 +03:00
parent 071fffbe4d
commit 3daf6482bf
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C

View File

@ -45,13 +45,13 @@
(fn [{:keys [db store]} [_]] (fn [{:keys [db store]} [_]]
(println (boolean (-> js/window .-web3))) (println (boolean (-> js/window .-web3)))
(let [injected-web3 (-> js/window .-web3) (let [injected-web3 (-> js/window .-web3)
web3 (if (boolean injected-web3) Web3 (if (boolean injected-web3)
(new (-> js/window .-Web3) (web3/current-provider injected-web3)) (new (-> js/window .-Web3) (web3/current-provider injected-web3))
;; TODO: put RPC URL in db ;; TODO: put RPC URL in db
(web3/create-web3 "http://localhost:8545"))] (web3/create-web3 "http://localhost:8545"))]
{:db (-> db/default-db {:db (-> db/default-db
(merge {:web3 web3}) (merge store)
(merge store))}))) (merge {:web3 Web3}))})))
(reg-event-db (reg-event-db
:assoc-in :assoc-in
@ -364,13 +364,12 @@
(let [Web3 (:web3 db) (let [Web3 (:web3 db)
confirm-method-id (sig->method-id "confirmTransaction(uint256)") confirm-method-id (sig->method-id "confirmTransaction(uint256)")
confirm-id (strip-0x confirm-hash) confirm-id (strip-0x confirm-hash)
bignum (fn [x] (web3/to-big-number Web3 x))
data (str confirm-method-id data (str confirm-method-id
confirm-id) confirm-id)
payload {:from owner-address payload {:from owner-address
:to contract-address :to contract-address
:gas (bignum "200000") :gas 200000
:gas-price (bignum "20000000000") :gas-price 8000000000
:value 0 :value 0
:data data}] :data data}]
(println "data:" data) (println "data:" data)