├── .babelrc
├── .circleci
└── config.yml
├── .editorconfig
├── .eslintignore
├── .eslintrc
├── .gitignore
├── LICENSE
├── README.md
├── package-lock.json
├── package.json
├── src
├── attestation.js
├── index.js
├── permissions.js
├── record.js
├── records.js
├── stow.js
└── util.js
├── stow-logo.jpg
├── test
├── .eslintrc
├── 1-util-test.js
├── 3-linnia-records-test.js
├── 4-linnia-permissions-test.js
├── 5-linnia-record-class-test.js
└── deployForTests.js
└── webpack.config.js
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["env"],
3 | "plugins": [
4 | "transform-runtime",
5 | "babel-plugin-add-module-exports"
6 | ]
7 | }
8 |
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | # Javascript Node CircleCI 2.0 configuration file
2 | #
3 | # Check https://circleci.com/docs/2.0/language-javascript/ for more details
4 | #
5 | version: 2
6 | jobs:
7 | build:
8 | docker:
9 | # specify the version you desire here
10 | - image: circleci/node:10.5
11 |
12 | # Specify service dependencies here if necessary
13 | # CircleCI maintains a library of pre-built images
14 | # documented at https://circleci.com/docs/2.0/circleci-images/
15 | # - image: circleci/mongo:3.4.4
16 |
17 | working_directory: ~/repo
18 |
19 | steps:
20 | - checkout
21 |
22 | # Download and cache dependencies
23 | - restore_cache:
24 | keys:
25 | - v1-dependencies-{{ checksum "package.json" }}
26 | # fallback to using the latest cache if no exact match is found
27 | - v1-dependencies-
28 |
29 | # start testrpc so that prepare runs without errors
30 |
31 | - run: npm ci
32 |
33 | - run:
34 | command: npm run testrpc
35 | background: true
36 | - run: sleep 5
37 |
38 | - save_cache:
39 | paths:
40 | - node_modules
41 | key: v1-dependencies-{{ checksum "package.json" }}
42 |
43 | # run tests!
44 | - run: npm test
45 | - run: npm run build
46 |
47 | - run: npm run lint
48 |
49 | # Teardown
50 | # If you break your build into multiple jobs with workflows, you will probably want to do the parts of this that are relevant in each
51 | # Save test results
52 | # - store_test_results:
53 | # path: coverage
54 | # # Save artifacts
55 | # - store_artifacts:
56 | # path: coverage
57 | - store_artifacts:
58 | path: dist
59 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | insert_final_newline = true
7 | trim_trailing_whitespace = true
8 |
9 | [*.js]
10 | indent_size = 2
11 | indent_style = space
12 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | /lib
2 | /dist
3 | /node_modules
4 | /src/contracts
5 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "env": {
3 | "browser": true,
4 | "node": true
5 | },
6 | "extends": "airbnb",
7 | "parserOptions": {
8 | "ecmaVersion": 2017
9 | },
10 | "rules": {
11 | "no-underscore-dangle": "off",
12 | "max-len": 1
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .idea
2 |
3 | # Logs
4 | logs
5 | *.log
6 | npm-debug.log*
7 | yarn-debug.log*
8 | yarn-error.log*
9 |
10 | # Runtime data
11 | pids
12 | *.pid
13 | *.seed
14 | *.pid.lock
15 |
16 | # Directory for instrumented libs generated by jscoverage/JSCover
17 | lib-cov
18 |
19 | # Coverage directory used by tools like istanbul
20 | coverage
21 |
22 | # nyc test coverage
23 | .nyc_output
24 |
25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
26 | .grunt
27 |
28 | # Bower dependency directory (https://bower.io/)
29 | bower_components
30 |
31 | # node-waf configuration
32 | .lock-wscript
33 |
34 | # Compiled binary addons (https://nodejs.org/api/addons.html)
35 | build/Release
36 |
37 | # Dependency directories
38 | node_modules/
39 | jspm_packages/
40 |
41 | # TypeScript v1 declaration files
42 | typings/
43 |
44 | # Optional npm cache directory
45 | .npm
46 |
47 | # Optional eslint cache
48 | .eslintcache
49 |
50 | # Optional REPL history
51 | .node_repl_history
52 |
53 | # Output of 'npm pack'
54 | *.tgz
55 |
56 | # Yarn Integrity file
57 | .yarn-integrity
58 |
59 | # dotenv environment variables file
60 | .env
61 |
62 | # next.js build output
63 | .next
64 |
65 | # Babel and Webpack output
66 | lib
67 | dist
68 |
69 | # vscode
70 | .vscode
71 |
72 | #.DS_Store
73 | .DS_Store
74 |
75 | #src/DS_Store
76 | src/.DS_Store
77 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 ConsenSys
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## [](https://www.npmjs.com/package/@stowprotocol/stow-js) 
4 |
5 | # StowJS
6 |
7 | ## Quickstart
8 |
9 | ```javascript
10 | const Web3 = require("web3");
11 | const Stow = require("@stowprotocol/stow-js");
12 |
13 | const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545"));
14 |
15 | const stow = new Stow(web3);
16 |
17 | // get the deployed contracts
18 | const { _, users, records, permissions } = await stow.getContractInstances();
19 | ```
20 |
21 | ## Installation
22 |
23 | You can install using npm:
24 |
25 | ```bash
26 | npm i @stowprotocol/stow-js
27 | ```
28 |
29 | or add inject the library onto the `window` using a script tag:
30 |
31 | ```html
32 |
33 | ```
34 |
35 | ## Building
36 |
37 | ```
38 | npm run build
39 | ```
40 |
41 | The compiled library is generated in `lib`, which you can require by typing `require('./lib')`
42 |
43 | ## Setting up a Dev Environment
44 |
45 | New to ethereum and/or Stow? Head over to our [resources page](https://github.com/ConsenSys/stow-resources) to learn more about the protocol and how to set up your ethereum development environment.
46 |
47 | ## API Documentation
48 |
49 | ### Constructor
50 |
51 | ```javascript
52 | new Stow(web3 [, options])
53 | ```
54 |
55 | ### Parameters
56 |
57 | 1. `Object` - An instantiated web3 API object
58 | 1. `Object` - (Optional) Constructor options
59 |
60 | - `hubAddress`: `String` - Address of the StowHub. If not specified, library will use the address of the latest version of the contract deployed on the network.
61 | - `tokenAddress`:`String` - Address of the StowToken. If not specified, library will use the address of the latest version of the contract deployed on the network.
62 | ### Example
63 |
64 | ```javascript
65 | const Web3 = require("web3");
66 | const Stow = require("@stowprotocol/stow-js");
67 | const web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545"));
68 | const stow = new Stow(web3);
69 | ```
70 |
71 | ## stow.getContractInstances
72 |
73 | ```javascript
74 | stow.getContractInstances();
75 | ```
76 |
77 | Gets Stow contract instances, wrapped in truffle contract.
78 |
79 | ### Returns
80 |
81 | `Promise