Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
:new-tweet/send
(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