1650723420
Clojurescript re-mount module, that provides mobile integration.
Add [district0x/district-ui-mobile "1.0.0"]
into your project.clj
district.ui.mobile
first needs to be initialized, as defined in the re-mount pattern.
Include district.ui.mobile
within the main file where you call mount/start
;; core.cljs, or main.cljs, etc...
(require '[mount.core :as mount])
(require '[district.ui.mobile])
;; optional initialization options
(def district-ui-options
{:mobile {:force-mobile-device false}})
(mount/start (with-args district-ui-options))
Subscriptions can then be made to determine if the web application is being viewed from mobile devices, specifically Android or iOS devices.
;; re-frame view file
(require '[re-frame :refer [subscribe]])
(require '[district.ui.mobile.subs :as mobile-subs])
(defn show-device []
(let [android? (subscribe [::mobile-subs/android?])
ios? (subscribe [::mobile-subs/ios?])]
(fn []
[:div
(cond
@android? [:span "You are on an Android device."]
@ios? [:span "You are on an iOS (iPhone, iPad) device."]
:else [:span "We don't know if you're on a mobile device."])])))
Another use-case is determining if the device is coinbase-compatible.
;; re-frame view file
(require '[re-frame :refer [subscribe]])
(require '[district.ui.mobile.subs :as mobile-subs])
(defn coinbase-dialog []
(let [coinbase-compatible? (subscribe [::mobile-subs/coinbase-compatible?])]
(fn []
[:div
(if @coinbase-compatible?
[:span "Mobile device is coinbase compatible."]
[:span "Device is not coinbase compatible."])])))
This namespace contains the mobile
mount module.
You can pass the following args while initiating this module:
:force-mobile-device
Used to imitate a mobile browser. Accepts one of the values: true
(android), :android
, :ios
, or false
. By default, this value is set to false
.For example, if I wanted to imitate an iOS device:
(ns my-district.core
(:require [mount.core :as mount]
[district.ui.mobile]
;;...
))
(-> (mount/with-args
{:mobile {:force-mobile-device :ios}
;; Additional mount options...
})
(mount/start))
re-frame subscriptions provided by this module:
::android? []
Returns true
if an Android mobile device is viewing the web application, otherwise false
::ios? []
Returns true
if an iOS mobile device (iPhone, iPad) is viewing the web application, otherwise false
.
::coinbase-compatible? []
Returns true
if an coinbase-compatible mobile device is viewing the web application, otherwise false
.
$ lein doo
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district-ui-mobile
License: EPL-1.0 License
1650716040
Clojurescript re-mount module, that synchronises UI time with the blockchain time.
Add [district0x/district-ui-web3-sync-now "1.0.3-2"]
into your project.clj. Include [district.ui.web3-sync-now]
in your CLJS file, where you use mount/start
.
Warning: district0x modules are still in early stages, therefore API can change in a future.
This namespace contains now mount module. This module has no configuration parameters.
(ns my-district.core
(:require [mount.core :as mount]
[district.ui.now]
[district.ui.web3]
[district.ui.web3-sync-now]
[district.ui.logging]))
(-> (mount/with-args {:logging {:level :info}
:web3 {:url "http://127.0.0.1:8549"}})
(mount/start))
After the :start
lifecycle method gets called this module waits for the :district.ui.web3.events/web3-created
event and sets :district.ui.now.subs/now
time to the last block time on the blockchain. Set the logging level to get notified of errors and/or successfull events.
re-frame events provided by this module:
::increment-now
Event to increment now time in a re-frame db and the (testrpc) blockchain time by a number of seconds.
(ns my-district.core
(:require [district.ui.web3-sync-now.events :as sync-now-events]
[re-frame.core :as re-frame]))
(re-frame/dispatch [::sync-now-events/increment-now 300])
Errors and successfully handled events will be logged to the JS console.
::block-number
This is an utility event called by the :start
lifecycle method of the module. It wraps the re-frame-web3-fx web3/call
effect and chains the returned last block number to the ::get-block
event. In a typical application you will never need to call this event yourself.
::get-block
This is an utility event which wraps the re-frame-web3-fx web3/call
effect and chains the returned last block object to the ::set-now
. In a typical application you will never need to call this event yourself.
::set-now
This is an utility event which sets the :district.ui.now.subs/now
time from the last block time. Upon success it will log to the JS console. In a typical application you will never need to call this event yourself.
Run test suite:
lein deps
# To run tests and rerun on changes
lein doo chrome tests
Install into local repo:
lein install
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district-ui-web3-sync-now
License: EPL-1.0 License
1650708720
Clojurescript mount + re-frame component for a district UI, that provides reagent UI component for adding calendar reminders. Works with Google Calendar and Apple Calendar.
Add [district0x/district-ui-add-to-calendar "1.0.0"]
into your project.clj.
Include [district.ui.component.add-to-calendar]
in your CLJS file.
district.ui.component.add-to-calendar
This namespace contains reagent UI component.
Basic usage example:
(ns my-district
(:require [cljs-time.core :as t]
[reagent.core :as r]
[district.ui.component.add-to-calendar :as add-to-calendar]))
(defn main-panel []
[:div#page1 [add-to-calendar/add-to-calendar {:title "Test"
:url "https://district0x.io"
:description "description"
:start-time (t/now)
:end-time (t/now)}]])
(defn ^:export init []
(r/render [main-panel] (.getElementById js/document "app")))
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district-ui-component-add-to-calendar
License:
1650701400
First time run
lein deps
Compile contracts (assumes you have solc
installed):
lein solc
Auto compile contracts on changes:
lein solc auto
Start server:
ganache-cli -d -p 8545 -m district0x
lein repl
(start-server!)
node dev-server/district0x-tasks.js
Start UI:
lein garden once
lein repl
(start-ui!)
# go to http://localhost:4598/
How to do tests:
ganache-cli -d -p 8545 -m district0x
lein test-doo
If change contracts code:
; auto compile Solidity code in project when files changed
lein solc auto
Remember this doesn't trigger cljs tests. So you have to change cljs tests files to trigger. For example add new line.
QA env and Dockerfiles
See docker-compose file in https://github.com/district0x/pipelines
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district0x-tasks
License: EPL-1.0 License
1650694080
A Leiningen plugin for compiling Solidity smart contracts.
lein-solc is available from Clojars. The latest released version is: Here
Add it to the :plugins
vector of your project.clj.
Plugin assumes solc compiler is installed and on your $PATH
.
You can specify the contracts to compile by adding an :solc
map to your project.clj. It takes the following key value pairs:
:src-path
string with the path where the .sol source files are residing, relative to the projects root path.:build-path
string with the path where the compiled output is written to, relative to the projects root directory.:abi?
(optional) boolean, if true
(default) output includes contract's abi interfaces.:bin?
(optional) boolean, if true
(default) output includes contract's bytecode.:truffle-artifacts?
(optional) boolean, if true
contracts are compiled into truffle artifacts, that can be required and deployed with truffle.:contracts
vector of files with the Solidity contracts source code, relative to the src-path directory (you can also specify sub-directories), or :all
to compile all of the contracts in the root of the src-path.:solc-err-only
(optional) boolean, if true
(default value) only compilation errors will be reported to the STDOUT.:verbose
(optional) boolean, if false
(default value) the STDOUT output is limited to the most important information.:byte-count
boolean, if true
after succesfull compilation the number of bytes in the compiled .bin
file will be printed to the STDOUT. Only valid if :bin?
is set to true
.:optimize-runs
(optional) map of contract filenames and parameter n
values, where 0 <= n < inf
is an estimated number of contract runs for optimizer tuning. It represents a trade-off between a smaller bytecode (low values) and cheaper transaction costs (high values).Example:
:solc {:src-path "resources/contracts/src"
:build-path "resources/contracts/build/"
:contracts ["MyContract.sol" "sub/MySecondContract.sol"]
:byte-count true
:optimize-runs {"MyContract.sol" 1}}
The contracts in :contracts
will be compiled when you do:
$ lein solc once
which is equivalent to lein solc
. You can also watch the :contracts
files and re-compile them on changes if you do:
$ lein solc auto
Download Details:
Author: district0x
Source Code: https://github.com/district0x/lein-solc
License:
#blockchain #cryptocurrency #district0x #web3 #clojure #smartcontract
1650686700
This repository contains MemeFactory smart contracts packaged as a reusable EVM Package. You can deploy them as-is, or extend to suit your needs to build custom contracts and more complex decentralized systems.
npm install memefactory-contracts
You need ZeppelinOS comand-line interface installed:
npm install --global zos
Create a new ZeppelinOS project, and add the memefactory-contracts
EVM package:
zos init MyProject
zos link memefactory-contracts
Start session with a network called local
(defined in truffle-config), using an address different from the default:
zos session --network local --from <address> --expires 3600
Deploy all the added logic contracts to the network (note that this step is only needed on local networks, when working on public networks ZeppelinOS will automatically used the pre-deployed implementation contracts):
zos push --deploy-dependencies
Initialize project:
zos init memefactory-contracts
Add contracts:
zos add DSAuth:ds-auth
zos add DSGuard:ds-guard
zos add EternalDb:meme-registry-db
zos add Registry:meme-registry
zos add App:token-factory
zos add DankToken:DANK
zos add MemeToken:meme-token
zos add MemeFactory:meme-factory
Start session with a testrpc network called ganache
(defined in truffle-config):
zos session --network ganache --from <address> --expires 3600
Deploy all the added logic contracts to the network:
zos push --force
Publish the contracts:
zos publish --network ganache --from <address>
Update to a new version of the package and deploy changes to the logic contracts:
zos link memefactory-contracts@new-version
zos push --deploy-dependencies
Deploy updated instances of the contracts to interact with:
zos update meme-factory
OWNER=<address>
DB=$(zos create meme-registry-db --init initialize)
REGISTRY=$(zos create meme-registry --init --args $DB,$OWNER)
TOKEN_FACTORY=$(zos create token-factory)
DANK_TOKEN=$(zos create DANK --init --args $TOKEN_FACTORY,1000000000000000000000000000,$OWNER)
MEME_TOKEN=$(zos create meme-token --init --args $REGISTRY)
MEME_FACTORY=$(zos create meme-factory --init --args $REGISTRY,$DANK_TOKEN,$MEME_TOKEN,1)
NOTE
When interacting with deployed contracts use a different address than that of the owner (admin) addressed used when creating it. The transparent proxy pattern posits that the calls from the admin address will not be delegated to the proxy contract holding the logic.
npx truffle console --network ganache
var address='contract-instance-address';
memeFactory=MemeFactory.at(address)
var opts = {from: 'address'};
memeFactory.version(opts)
Download Details:
Author: district0x
Source Code: https://github.com/district0x/memefactory-contracts
License: https://github.com/district0x/memefactory-contracts
#blockchain #evm #cryptocurrency #district0x #web3 #clojure #javascript #smartcontract
1650679320
Set of functions helpful for data encryption on blockchain based on public/private key. This library utilises eccjs. Suitable for both nodejs and browser.
Add: Here
into your project.clj
Include [district.encryption]
in your CLJS file.
district.encryption
generate-keypair []
Generates and returns public/private keypair.
encrypt [public-key content]
Encrypts content with public key.
decrypt [private-key content]
Decrypts content with private key.
encode-base64 [string]
Base64 encodes string.
decode-base64 [string]
Base64 decodes string.
encrypt-encode [public-key content]
Encrypts with public key and then base64 encodes.
decode-decrypt [private-key content]
Base64 decodes and then decrypts with private key.
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district-encryption
License: EPL-1.0 License
1650671940
district0x-error-handling
Clojurescript library with functions aiding in error handling. This library currently utilises timbre as a logging library. You shoud use it in conjunction with the district-server-logging and district-ui-logging modules which setup various logging appenders.
Add into your project.clj: Here
Include [district.shared.error-handling]
in your CLJS file.
try-catch
try-catch-throw
(ns my-district
(:require [district.shared.error-handling :refer [try-catch try-catch-throw]]))
(defn function-that-can-fail [n]
(try-catch
(/ 7 n)))
error-handling
requires a configured district-server-logging
and/or district-ui-logging
modules to function correctly. Depending on where the code is run and how the logging is configured your errors will be reported to the browser, node.js console, log file, sentry etc.
For possible configuration options please see district-server-logging and district-ui-logging.
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district0x-error-handling
License: EPL-1.0 License
1650664620
Clojurescript reagent UI component for displaying user's active web3 account. If user has multiple accounts, select field will be presented, otherwise just plain element with the address. This component uses React Semantic UI.
Add [district0x/district-ui-component-active-account "1.0.0"]
into your project.clj
Include [district.ui.component.active-account]
in your CLJS file
This UI component assumes you have following UI modules installed in your app:
You can pass following props to the active-account
component:
:select-props
Props passed into Select with multiple accounts.:single-account-props
Props passed into single account element (ns my-district.core
(:require [district.ui.component.active-account :refer [active-account]]))
(defn home-page []
[active-account])
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district-ui-component-active-account
License: EPL-1.0 License
1650657240
Clojurescript mount + re-frame component for a district UI, that provides reagent UI component for serving html meta-tags for SEO.
Add: Here
into your project.clj.
Include [district.ui.component.meta-tags]
in your CLJS file.
district.ui.component.meta-tags
This namespace contains reagent UI component to add meta tags.
Basic usage:
(ns my-district
(:require [reagent.core :as r]
[district.ui.component.meta-tags :as meta-tags]))
(defn main-panel []
[:div#page1 [meta-tags/meta-tags {:title "My District" :description "A long and complete description of my district"}]])
(defn ^:export init []
(r/render [main-panel] (.getElementById js/document "app")))
This will set the page title to "My District" and the content of the description meta tag. You can also pass additional custom meta-tags by adding more maps with and :id
, :name
and :content
keys, after the :title
and :description
map:
[meta-tags/meta-tags {:title "title" :description "description"}
{:id "id0" :name "foo" :content "foo"}
{:id "id1" :name "bar" :content "bar"}]
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district-ui-component-meta-tags
License:
1650649920
Set of extra functions helpful for working with web3.js.
Add [district0x/district-web3-utils "1.0.3"]
into your project.clj
Include [district.web3-utils]
in your CLJS file
wei->eth [x]
Safely Converts wei into ether.
(web3-utils/wei->eth 1000000000000000000)
;; => "1"
(web3-utils/wei->eth (web3/to-big-number 1000000000000000000))
;; => #object[BigNumber 1]
(web3-utils/wei->eth "abc")
;; => nil
wei->eth-number [x]
Safely Converts wei into ether and coerces into number.
(web3-utils/wei->eth-number "1000000000000000000")
;; => 1
(web3-utils/wei->eth-number (web3/to-big-number 1000000000000000000))
;; => 1
eth->wei [x]
Safely Converts ether into wei.
(web3-utils/eth->wei 1.1)
;; => "1100000000000000000"
;; handles comma as fraction decimals separator as well
(web3-utils/eth->wei "1,1")
;; => "1100000000000000000"
eth->wei-number [x]
Safely Converts ether into wei and coerces into number.
(web3-utils/eth->wei-number "1.1")
;; => 1100000000000000000
zero-address? [address]
True if address is zero address
(web3-utils/zero-address? "0x")
;; => true
(web3-utils/zero-address? "0x0000000000000000000000000000000000000000")
;; => true
empty-address? [address]
True if address is zero address, empty string or nil
(web3-utils/empty-address? "0x")
;; => true
(web3-utils/empty-address? nil)
;; => true
remove-0x [address]
Removes initial "0x" from an address
(web3-utils/remove-0x "0x0000000000000000000000000000000000000000")
;; => "0000000000000000000000000000000000000000"
web3-time->date-time [x]
Converts time returned by smart-contracts (usually as BigNumber UNIX epoch) into cljs-time.
(web3-utils/web3-time->date-time (web3/to-big-number 1516223428))
;; => #object[Object 20180117T211028]
(web3-utils/web3-time->date-time 1516223428)
;; => #object[Object 20180117T211028]
(web3-utils/web3-time->date-time (web3/to-big-number 0))
;; => nil
web3-time->local-date-time [x]
Converts time returned by smart-contracts (usually as BigNumber UNIX epoch) into local cljs-time.
(web3-utils/web3-time->local-date-time (web3/to-big-number 1516223428))
;; => #object[Object 20180117T211028]
(web3-utils/web3-time->local-date-time 1516223428)
;; => #object[Object 20180117T211028]
prepend-address-zeros [address]
If given address is shorter than it should be, it prepends missing places with zeros.
(web3-utils/prepend-address-zeros "0x123")
;; => "0x0000000000000000000000000000000000000123"
bytes32->str [x]
Converts web3 bytes32 encoded string into normal string.
(web3-utils/bytes32->str "0x636f6e7374727563746564000000000000000000000000000000000000000000")
;; => "constructed"
uint->address [x]
Converts Solidity's uint into web3 address
(web3-utils/uint->address (web3/to-big-number 1234))
;; => "0x00000000000000000000000000000000000004d2"
lein deps
# To run tests and rerun on changes
lein doo chrome tests
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district-web3-utils
License: EPL-1.0 License
1650642600
Set of functions helpful for working with time.
Add [district0x/district-time "1.0.1"]
into your project.clj
Include [district.time]
in your CLJS file
time-units [milis]
Divides given miliseconds into seconds, minutes, hours, days.
(time/time-units 400000000)
;; => {:seconds 40 :minutes 6 :hours 15 :days 4}
biggest-time-unit [{:keys [:seconds :minutes :hours :days]}]
Returns biggest positive time unit from given parameters.
(time/biggest-time-unit (time/time-units 400000000))
;; => [:days 4]
time-remaining [from-time to-time]
Time remaining from from-time
to to-time
. Passed times are from cljs-time format.
(time/time-remaining (t/now) (t/plus (t/now) (t/hours 3)))
;; => {:seconds 0 :minutes 0 :hours 3 :days 0}
time-remaining-biggest-unit [from-time to-time]
Returns biggest time unit from remaining time. Passed times are from cljs-time format.
(time/time-remaining-biggest-unit (t/now) (t/plus (t/now) (t/hours 3)))
;; => [:hours 3]
epoch->long [x]
Converts epoch to long time format.
(time/epoch->long 1516314507)
;; => 1516314507000
long->epoch [x]
Converts long to epoch time format.
(time/long->epoch 1516314507000)
;; => 1516314507
days->seconds [x]
Converts days to seconds.
(time/days->seconds 3)
;; => 259200
seconds->days [x]
Converts seconds to days.
(time/seconds->days 345600)
;; => 259200
lein deps
# To run tests and rerun on changes
lein doo chrome tests
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district-time
License: EPL-1.0 License
1650635100
Set of helper functions for working with vanilla Clojurescript, requiring no other 3rd party libraries. This is not meant to be replacement of similar libraries like medley, rather should be complementary.
Add [district0x/district-cljs-utils "1.0.4"]
into your project.clj
Include [district.cljs-utils]
in your CLJS file
merge-in [& args]
Deep merge of multiple maps
(cljs-utils/merge-in {:a {:b 1}} {:a {:c 2}} {:a {:d 3}})
;; => {:a {:b 1 :c 2 :d 3}}
collify [x]
Ensures a collection.
(first (cljs-utils/collify 1))
;; => 1
(first (cljs-utils/collify [1]))
;; => 1
not-nil? [x]
Returns true if not nil
(cljs-utils/not-nil? 1)
;; => true
sort-desc [coll]
Descending sort
(cljs-utils/sort-desc [2 1 3])
;; => [3 2 1]
sort-by-desc [key-fn coll]
Descending sort by key-fn
(cljs-utils/sort-by-desc :a [{:a 2} {:a 1} {:a 3}])
;; => ({:a 3} {:a 2} {:a 1})
map-kv-at-keys [f keyseq m]
Maps a function over the key/value pairs of an associate collection, but only on given keys.
(cljs-utils/map-kv-at-keys #(vec [(dec %1) (inc %2)]) [8 7] {9 1, 8 2, 7 3})
;; => {9 1, 7 3, 6 4}
map-vals-at-keys [f keyseq m]
Maps a function over the values pairs of an associate collection, but only on given keys.
(cljs-utils/map-vals-at-keys inc [:b :c] {:a 1 :b 2 :c 3})
;; => {:a 1 :b 3 :c 4}
rand-str [n & [{:keys [:lowercase-only? :exclude-numbers?]}]]
Generates random alphanumeric string with n
characters.
(cljs-utils/rand-str 10)
;; => "LpvMscagIw"
(cljs-utils/rand-str 10 {:lowercase-only? true})
;; => "frtkeahqus"
safe-assoc-in [m ks v]
Invariant version of assoc-in. Returns unchanged map if ks
path is empty.
(cljs-utils/safe-assoc-in {:a 1} [:b :c] 2)
;; => {:a 1}
(cljs-utils/safe-assoc-in {:b {}} [:b :c] 2)
;; => {:b {:c 2}}
js-obj->clj [obj]
Converts JS object (instance of a class) into Clojure map
(:protocol (cljs-utils/js-obj->clj (aget js/window "location")))
;; => http:
kw->str [kw]
Stringifies keyword. In contrary to name
, preserves namespace as well
(cljs-utils/kw->str :some.long/name)
;; => "some.long/name"
transform-keys [t coll]
Recursively transforms all map keys in coll with t.
(cljs-utils/transform-keys inc {1 "a" 2 "a" 3 {4 "a"}})
;; => {2 "a" 3 "a" 4 {5 "a"}}
transform-vals [t coll]
Recursively transforms all map values in coll with t.
(cljs-utils/transform-vals (fn [v]
(if (number? v)
(inc v)
v))
{:a 1 :b 2 :c {:z 3}})
;; => {:a 2 :b 3 :c {:z 4}}
lein deps
# To run tests and rerun on changes
lein doo chrome tests
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district-cljs-utils
License: EPL-1.0 License
1650627780
Contribution 0xf8094e15c897518b5ac5287d7070ca5850efc6ff:
[{"constant":true,"inputs":[],"name":"totalContributed","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_minContribAmount","type":"uint256"}],"name":"setMinContribAmount","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"advisers","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"founder1","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"EARLY_CONTRIBUTOR_STAKE","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"tokenAddr","type":"address"}],"name":"reclaimToken","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"contributors","outputs":[{"name":"amount","type":"uint256"},{"name":"isCompensated","type":"bool"},{"name":"amountCompensated","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"COMMUNITY_ADVISERS_STAKE","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_softCapAmount","type":"uint256"},{"name":"_afterSoftCapDuration","type":"uint256"},{"name":"_hardCapAmount","type":"uint256"},{"name":"_startTime","type":"uint256"},{"name":"_endTime","type":"uint256"}],"name":"setContribPeriod","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"ADVISER_STAKE","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"softCapReached","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"endTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"}],"name":"claimTokensFromTokenDistrict0xNetworkToken","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"contributorAddress","type":"address"}],"name":"getContributor","outputs":[{"name":"","type":"uint256"},{"name":"","type":"bool"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"maxGasPrice","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"ADVISER_STAKE2","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"contributorsKeys","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"onTransfer","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"TEAM_VESTING_CLIFF","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"EARLY_CONTRIBUTOR_VESTING_CLIFF","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"enableContribPeriod","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"minContribAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"afterSoftCapDuration","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"emergencyStop","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"isEnabled","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getConfiguration","outputs":[{"name":"","type":"bool"},{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"address"},{"name":"","type":"address"},{"name":"_advisers","type":"address[]"},{"name":"","type":"bool"},{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"FOUNDER2_STAKE","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"CONTRIB_PERIOD2_STAKE","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"stopped","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"startTime","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"acceptOwnership","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"contributor","type":"address"}],"name":"contributeWithAddress","outputs":[],"payable":true,"type":"function"},{"constant":true,"inputs":[],"name":"founder2","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"earlySponsor","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"CONTRIB_PERIOD3_STAKE","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"release","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"multisigWallet","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"hardCapReached","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newOwner","type":"address"}],"name":"changeOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"enableDistrict0xNetworkTokenTransfers","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"tokenTransfersEnabled","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"offset","type":"uint256"},{"name":"limit","type":"uint256"}],"name":"getUncompensatedContributors","outputs":[{"name":"contributorIndexes","type":"uint256[]"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getNow","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"from_","type":"address"},{"name":"value_","type":"uint256"},{"name":"data_","type":"bytes"}],"name":"tokenFallback","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"}],"name":"kill","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"hardCapAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"isContribPeriodRunning","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_maxGasPrice","type":"uint256"}],"name":"setMaxGasPrice","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"newOwner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[],"name":"contribute","outputs":[],"payable":true,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"onApprove","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_district0xNetworkToken","type":"address"}],"name":"setDistrict0xNetworkToken","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"TEAM_VESTING_PERIOD","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"district0xNetworkToken","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getContribPeriod","outputs":[{"name":"boolValues","type":"bool[3]"},{"name":"uintValues","type":"uint256[8]"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"tokenAddr","type":"address"}],"name":"isTokenSaleToken","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"CONTRIB_PERIOD1_STAKE","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"EARLY_CONTRIBUTOR_VESTING_PERIOD","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"}],"name":"proxyPayment","outputs":[{"name":"","type":"bool"}],"payable":true,"type":"function"},{"constant":true,"inputs":[],"name":"softCapAmount","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"FOUNDER1_STAKE","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"offset","type":"uint256"},{"name":"limit","type":"uint256"}],"name":"compensateContributors","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"_multisigWallet","type":"address"},{"name":"_founder1","type":"address"},{"name":"_founder2","type":"address"},{"name":"_earlySponsor","type":"address"},{"name":"_advisers","type":"address[]"}],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":false,"name":"totalContributed","type":"uint256"},{"indexed":true,"name":"contributor","type":"address"},{"indexed":false,"name":"amount","type":"uint256"},{"indexed":false,"name":"contributorsCount","type":"uint256"}],"name":"onContribution","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"endTime","type":"uint256"}],"name":"onSoftCapReached","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"endTime","type":"uint256"}],"name":"onHardCapReached","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"contributor","type":"address"},{"indexed":false,"name":"amount","type":"uint256"}],"name":"onCompensated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"isStopped","type":"bool"}],"name":"onEmergencyChanged","type":"event"}]
DNT 0x0abdace70d3790235af448c88547603b945604ea:
[{"constant":true,"inputs":[{"name":"_holder","type":"address"}],"name":"tokenGrantsCount","outputs":[{"name":"index","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"creationBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"uint256"}],"name":"grants","outputs":[{"name":"granter","type":"address"},{"name":"value","type":"uint256"},{"name":"cliff","type":"uint64"},{"name":"vesting","type":"uint64"},{"name":"start","type":"uint64"},{"name":"revokable","type":"bool"},{"name":"burnsOnRevoke","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newController","type":"address"}],"name":"changeController","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_blockNumber","type":"uint256"}],"name":"balanceOfAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_holder","type":"address"},{"name":"_grantId","type":"uint256"}],"name":"tokenGrant","outputs":[{"name":"granter","type":"address"},{"name":"value","type":"uint256"},{"name":"vested","type":"uint256"},{"name":"start","type":"uint64"},{"name":"cliff","type":"uint64"},{"name":"vesting","type":"uint64"},{"name":"revokable","type":"bool"},{"name":"burnsOnRevoke","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_cloneTokenName","type":"string"},{"name":"_cloneDecimalUnits","type":"uint8"},{"name":"_cloneTokenSymbol","type":"string"},{"name":"_snapshotBlock","type":"uint256"},{"name":"_transfersEnabled","type":"bool"}],"name":"createCloneToken","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_token","type":"address"},{"name":"_claimer","type":"address"}],"name":"claimTokens","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"holder","type":"address"}],"name":"lastTokenIsTransferableDate","outputs":[{"name":"date","type":"uint64"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"parentToken","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"}],"name":"generateTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"grantsController","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"},{"name":"_start","type":"uint64"},{"name":"_cliff","type":"uint64"},{"name":"_vesting","type":"uint64"},{"name":"_revokable","type":"bool"},{"name":"_burnsOnRevoke","type":"bool"}],"name":"grantVestedTokens","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_blockNumber","type":"uint256"}],"name":"totalSupplyAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_value","type":"uint256"}],"name":"transfer","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"transfersEnabled","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"parentSnapShotBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_holder","type":"address"}],"name":"revokeAllTokenGrants","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"holder","type":"address"},{"name":"time","type":"uint64"}],"name":"transferableTokens","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"}],"name":"destroyTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"tokens","type":"uint256"},{"name":"time","type":"uint256"},{"name":"start","type":"uint256"},{"name":"cliff","type":"uint256"},{"name":"vesting","type":"uint256"}],"name":"calculateVestedTokens","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newController","type":"address"}],"name":"changeGrantsController","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"tokenFactory","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_holder","type":"address"},{"name":"_grantId","type":"uint256"}],"name":"revokeTokenGrant","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_transfersEnabled","type":"bool"}],"name":"enableTransfers","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"inputs":[{"name":"_controller","type":"address"},{"name":"_tokenFactory","type":"address"}],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"from","type":"address"},{"indexed":true,"name":"to","type":"address"},{"indexed":false,"name":"value","type":"uint256"},{"indexed":false,"name":"grantId","type":"uint256"}],"name":"NewTokenGrant","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_token","type":"address"},{"indexed":true,"name":"_claimer","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"ClaimedTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_cloneToken","type":"address"},{"indexed":false,"name":"_snapshotBlock","type":"uint256"}],"name":"NewCloneToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Approval","type":"event"}]
Multisig 0xd20e4d854c71de2428e1268167753e4c7070ae68:
[{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"owners","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"}],"name":"removeOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"revokeConfirmation","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isOwner","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"},{"name":"","type":"address"}],"name":"confirmations","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"pending","type":"bool"},{"name":"executed","type":"bool"}],"name":"getTransactionCount","outputs":[{"name":"count","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"}],"name":"addOwner","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"isConfirmed","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"getConfirmationCount","outputs":[{"name":"count","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"uint256"}],"name":"transactions","outputs":[{"name":"destination","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"},{"name":"executed","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"getOwners","outputs":[{"name":"","type":"address[]"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"from","type":"uint256"},{"name":"to","type":"uint256"},{"name":"pending","type":"bool"},{"name":"executed","type":"bool"}],"name":"getTransactionIds","outputs":[{"name":"_transactionIds","type":"uint256[]"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"getConfirmations","outputs":[{"name":"_confirmations","type":"address[]"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"transactionCount","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_required","type":"uint256"}],"name":"changeRequirement","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"confirmTransaction","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"destination","type":"address"},{"name":"value","type":"uint256"},{"name":"data","type":"bytes"}],"name":"submitTransaction","outputs":[{"name":"transactionId","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"MAX_OWNER_COUNT","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"required","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"owner","type":"address"},{"name":"newOwner","type":"address"}],"name":"replaceOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"transactionId","type":"uint256"}],"name":"executeTransaction","outputs":[],"payable":false,"type":"function"},{"inputs":[{"name":"_owners","type":"address[]"},{"name":"_required","type":"uint256"}],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":true,"name":"transactionId","type":"uint256"}],"name":"Confirmation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":true,"name":"transactionId","type":"uint256"}],"name":"Revocation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"transactionId","type":"uint256"}],"name":"Submission","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"transactionId","type":"uint256"}],"name":"Execution","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"transactionId","type":"uint256"}],"name":"ExecutionFailure","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"sender","type":"address"},{"indexed":false,"name":"value","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"OwnerAddition","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"owner","type":"address"}],"name":"OwnerRemoval","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"name":"required","type":"uint256"}],"name":"RequirementChange","type":"event"}]
At the technical level DNT is a ERC20-compliant token, derived from the MiniMeToken that allows for token cloning (forking), which will be useful for many future usecases.
Vesting functionality derived from VestedToken is also built-in into our token. Founders, advisors and early contributor have their tokens vested.
Token:
Contribution:
To run our smart-contract tests you need to have node installed on your machine. Our tests are written in Clojurescript here tests.cljs, but they are compiled into Javascript here contribution-tests.js, so you don't need to do that. You can just run tests with following commands:
npm install
node contribution-tests.js
Read More:
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district0x-network-token
License: EPL-1.0 License
#blockchain #cryptocurrency #district0x #web3 #clojure #smartcontract
1650620355
Clojurescript-node.js mount module for a district server, that watches server connection to a blockchain.
Add [district0x/district-server-web3-watcher "1.0.3"]
into your project.clj
Include [district.server.web3-watcher]
in your CLJS file, where you use mount/start
Warning: district0x modules are still in early stages, therefore API can change in a future.
To see how district server modules play together in real-world app, you can take a look at NameBazaar server folder, where this is deployed in production.
You can pass following args to web3-watcher module:
:interval
Interval at which it should check the connection. Default: 3s:confirmations
How many offline responses module needs to get before triggers :on-offline
. Default: 3:on-online
Callback that is run when connection goes from offline to online:on-offline
Callback that is run when connection goes from online to offline(ns my-district
(:require [mount.core :as mount]
[district.server.web3-watcher]))
(-> (mount/with-args
{:web3 {:port 8545}
:web3-watcher {:on-offline #(println "Node went offline")
:on-online #(println "Node is online again")}})
(mount/start))
district-server-web3-watcher
gets initial args from config provided by district-server-config/config
under the key :web3-watcher
. These args are then merged together with ones passed to mount/with-args
.
district-server-web3-watcher
relies on getting web3 instance from district-server-web3/web3
. That's why, in example, you need to set up :web3
in mount/with-args
as well.
If you wish to use custom modules instead of dependencies above while still using district-server-web3-watcher
, you can easily do so by mount's states swapping.
# To start REPL and run tests
lein deps
lein repl
(start-tests!)
# In other terminal
node tests-compiled/run-tests.js
# To run tests without REPL
lein doo node "tests" once
Download Details:
Author: district0x
Source Code: https://github.com/district0x/district-server-web3-watcher
License: EPL-1.0 License