Skip to content

Instantly share code, notes, and snippets.

@madvas
Last active October 3, 2016 17:00
Show Gist options
  • Save madvas/91b860de0aa03b04ebcb921965b1865e to your computer and use it in GitHub Desktop.
Save madvas/91b860de0aa03b04ebcb921965b1865e to your computer and use it in GitHub Desktop.
:contract/compiled-code-loaded
(reg-event-fx
:contract/abi-loaded
interceptors
(fn [{:keys [db]} [abi]]
(let [web3 (:web3 db)
contract-instance (web3-eth/contract-at web3 abi (:address (:contract db)))]
{:db (assoc-in db [:contract :instance] contract-instance)
:web3-fx.contract/events
{:instance contract-instance
:db db
:db-path [:contract :events]
:events [[:on-tweet-added {} {:from-block 0} :contract/on-tweet-loaded :log-error]]}
:web3-fx.contract/constant-fns
{:instance contract-instance
:fns [[:get-settings :contract/settings-loaded :log-error]]}})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment