Clojurescript re-mount module, that provides core logic for transaction log components. This module does not provide reagent UI component for a transaction log, only logic to build the component upon. This way many different reagent components can be build on top of this module.
This module automatically listens to district-ui-web3-tx events and based on that performs 2 things:
-
Builds up chronological list of transactions. Also stores it in localstorage, but only if district-ui-web3-tx uses localstorage as well.
-
Extends send-tx, so you can pass it key
:tx-log
with any data you want associate together with a transaction. Then these data can be displayed in transaction log UI component.
Add [district0x/district-ui-web3-tx-log-core "1.0.3"]
into your project.clj
Include [district.ui.web3-tx-log-core]
in your CLJS file, where you use mount/start
Warning: district0x modules are still in early stages, therefore API can change in a future.
- district.ui.web3-tx-log-core
- district.ui.web3-tx-log-core.subs
- district.ui.web3-tx-log-core.events
- district.ui.web3-tx-log-core.queries
This namespace contains web3-tx-log-core mount module.
This module does not have any configuration options.
(ns my-district.core
(:require [mount.core :as mount]
[district.ui.web3-tx-log-core]))
(-> (mount/with-args
{:web3 {:url "https://mainnet.infura.io/"}})
(mount/start))
(ns my-district.events
(:require [district.ui.web3-tx.events :as tx-events]))
(dispatch [::tx-events/send-tx {:instance MyContract
:fn :my-function
:args [1]
:tx-opts {:from my-account :gas 4500000}
;; Any data can be passed to :tx-log, depending on what your tx-log component
;; is displaying for each transaction
:tx-log {:name "Nice Transaction"}}])
re-frame subscriptions provided by this module:
Returns list of transactions as stored by district-ui-web3-tx, ordered chronologically with newest being first. Optionally, you can pass filter opts same way as you'd pass to district-ui-web3-tx ::txs
(ns my-district.core
(:require [mount.core :as mount]
[district.ui.web3-tx-log-core :as subs]))
(defn transaction-log []
(let [txs (subscribe [::subs/txs])]
(fn []
[:div "Transaction Log: "]
(for [{:keys [:transaction-hash :created-on :gas-used]} @txs]
[:div
{:key transaction-hash}
transaction-hash " - " created-on " - " gas-used]))))
Returns only list of transaction hashes ordered chronologically with newest transactions being first.
re-frame events provided by this module:
Adds transaction hash into transaction log list.
Removes transaction hash from transaction log list.
DB queries provided by this module:
You should use them in your events, instead of trying to get this module's
data directly with get-in
into re-frame db.
Works the same way as sub ::txs
Works the same way as sub ::tx-hashes
Adds transaction hash into transaction log list and returns new re-frame db.
Removes transaction hash from transaction log list and returns new re-frame db.
Associates list of tx-hashes into this module's state.
- Build:
npx shadow-cljs watch test-browser
- Tests: http://d0x-vm:6502
- Build:
npx shadow-cljs compile test-ci
- Tests:
CHROME_BIN=`which chromium-browser` npx karma start karma.conf.js --single-run
- Build:
clj -T:build jar
- Release:
clj -T:build deploy