Created
October 3, 2016 17:34
-
-
Save madvas/92ff50799e7d7fff8a01998c034e263a to your computer and use it in GitHub Desktop.
:new-tweet/send
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(reg-event-fx | |
:new-tweet/send | |
interceptors | |
(fn [{:keys [db]} []] | |
(let [{:keys [name text address]} (:new-tweet db)] | |
{:web3-fx.contract/state-fn | |
{:instance (:instance (:contract db)) | |
:web3 (:web3 db) | |
:db-path [:contract :send-tweet] | |
:fn [:add-tweet name text | |
{:from address | |
:gas tweet-gas-limit} | |
:new-tweet/confirmed | |
:log-error | |
:new-tweet/transaction-receipt-loaded]}}))) | |
(reg-event-db | |
:new-tweet/confirmed | |
interceptors | |
(fn [db [transaction-hash]] | |
(assoc-in db [:new-tweet :sending?] true))) | |
(reg-event-db | |
:new-tweet/transaction-receipt-loaded | |
interceptors | |
(fn [db [{:keys [gas-used] :as transaction-receipt}]] | |
(console :log transaction-receipt) | |
(when (= gas-used tweet-gas-limit) | |
(console :error "All gas used")) | |
(assoc-in db [:new-tweet :sending?] false))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment