Fix issues with :confirm-payout re-frame handler

This commit is contained in:
Teemu Patja 2017-08-31 11:32:45 +03:00
parent 9885014235
commit 5ab68f3b18
No known key found for this signature in database
GPG Key ID: F5B7035E6580FD4C
1 changed files with 8 additions and 7 deletions

View File

@ -344,6 +344,7 @@
(defn send-transaction-callback (defn send-transaction-callback
[issue-id] [issue-id]
(fn [error payout-hash] (fn [error payout-hash]
(println "send-transaction-callback" error payout-hash)
(when error (when error
(dispatch [:set-flash-message (dispatch [:set-flash-message
:error :error
@ -354,7 +355,7 @@
(defn sig->method-id [w3 sig] (defn sig->method-id [w3 sig]
(println "sig->method-id" w3 sig) (println "sig->method-id" w3 sig)
(let [sha3 (fn [x] (web3/sha3 w3 x))] (let [sha3 (fn [x] (web3/sha3 x w3))]
(apply str (take 10 (sha3 sig))))) (apply str (take 10 (sha3 sig)))))
(defn strip-0x [x] (defn strip-0x [x]
@ -374,8 +375,8 @@
confirm-id) confirm-id)
payload {:from owner-address payload {:from owner-address
:to contract-address :to contract-address
:gas 200000 :gas 180000
:gas-price 8000000000 :gas-price 20000000000
:value 0 :value 0
:data data}] :data data}]
(println "data:" data) (println "data:" data)
@ -385,7 +386,7 @@
{:db (assoc-in db [:owner-bounties issue-id :confirming?] true)} {:db (assoc-in db [:owner-bounties issue-id :confirming?] true)}
(catch js/Error e (catch js/Error e
{:db (assoc-in db [:owner-bounties issue-id :confirm-failed?] true) {:db (assoc-in db [:owner-bounties issue-id :confirm-failed?] true)
:dispatch-n [[:payout-confirm-failed issue-id] :dispatch-n [[:payout-confirm-failed issue-id e]
[:set-flash-message [:set-flash-message
:error :error
(str "Failed to send transaction" e)]]}))))) (str "Failed to send transaction" e)]]})))))
@ -400,8 +401,8 @@
(reg-event-db (reg-event-db
:payout-confirm-failed :payout-confirm-failed
(fn [db [_ issue-id]] (fn [db [_ issue-id e]]
(println "payout-confirm-failed" issue-id) (println "payout-confirm-failed" issue-id e)
(-> db (-> db
(dissoc-in [:owner-bounties issue-id :confirming?]) (dissoc-in [:owner-bounties issue-id :confirming?])
(assoc-in [:owner-bounties issue-id :confirm-failed?] true)))) (assoc-in [:owner-bounties issue-id :confirm-failed?] true))))