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
0xbBC5eE8be95683983dF67260B0AB033c237Bde60 |
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 |
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-db | |
:contract/settings-loaded | |
interceptors | |
(fn [db [[max-name-length max-tweet-length]]] | |
(assoc db :settings {:max-name-length (.toNumber max-name-length) | |
:max-tweet-length (.toNumber max-tweet-length)}))) |
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-db | |
:contract/on-tweet-loaded | |
interceptors | |
(fn [db [tweet]] | |
(update db :tweets conj (merge (select-keys tweet [:author-address :text :name]) | |
{:date (u/big-number->date-time (:date tweet)) | |
:tweet-key (.toNumber (:tweet-key tweet))})))) |
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/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 |
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 | |
:blockchain/my-addresses-loaded | |
interceptors | |
(fn [{:keys [db]} [addresses]] | |
{:db (-> db | |
(assoc :my-addresses addresses) | |
(assoc-in [:new-tweet :address] (first addresses))) | |
:web3-fx.blockchain/balances | |
{:web3 (:web3 db/default-db) | |
:addresses addresses |
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 | |
:initialize | |
(fn [_ _] | |
(merge | |
{:db db/default-db | |
:http-xhrio {:method :get | |
:uri (gstring/format "/contracts/build/%s.abi" | |
(get-in db/default-db [:contract :name])) | |
:timeout 6000 | |
:response-format (ajax/json-response-format {:keywords? true}) |
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 | |
:initialize | |
(fn [_ _] | |
(merge | |
{:db db/default-db | |
:dispatch [:contract/fetch-compiled-code [:contract/compiled-code-loaded]]} | |
(when (:provides-web3? db/default-db) | |
{:web3-fx.blockchain/fns | |
{:web3 (:web3 db/default-db) | |
:fns [[web3-eth/accounts :blockchain/my-addresses-loaded :log-error]]}})))) |
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 | |
:initialize | |
(fn [_ _] | |
(merge | |
{:db db/default-db | |
:dispatch [:contract/fetch-compiled-code [:contract/compiled-code-loaded]]} | |
(when (:provides-web3? db/default-db) | |
{:web3-fx.blockchain/fns | |
{:web3 (:web3 db/default-db) | |
:fns [[web3-eth/accounts :blockchain/my-addresses-loaded :log-error]]}})))) |
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 |
NewerOlder