Created
October 3, 2016 15:17
-
-
Save madvas/cf591bcba89ff758d311b2ecdf0630e8 to your computer and use it in GitHub Desktop.
:contract/fetch-compiled-code
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 | |
:contract/fetch-compiled-code | |
interceptors | |
(fn [{:keys [db]} [on-success]] | |
{:http-xhrio {:method :get | |
:uri (gstring/format "/contracts/build/%s.json" | |
(get-in db [:contract :name])) | |
:timeout 6000 | |
:response-format (ajax/json-response-format {:keywords? true}) | |
:on-success on-success | |
:on-failure [:log-error]}})) | |
(reg-event-fx | |
:contract/deploy-compiled-code | |
interceptors | |
(fn [{:keys [db]} [contracts]] | |
(let [{:keys [abi bin]} (get-in contracts [:contracts (keyword (:name (:contract db)))])] | |
{:web3-fx.blockchain/fns | |
{:web3 (:web3 db) | |
:fns [[web3-eth/contract-new | |
(js/JSON.parse abi) | |
{:gas 4500000 | |
:data bin | |
:from (first (:my-addresses db))} | |
:contract/deployed | |
:log-error]]}}))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment