Skip to content

Commit b4fb0b8

Browse files
authored
Merge pull request #61 from EOSIO/develop
Release 4.0.1
2 parents 50d9ec6 + 3d89ed2 commit b4fb0b8

File tree

13 files changed

+1045
-738
lines changed

13 files changed

+1045
-738
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# See https://help.github.com/ignore-files/ for more about ignoring files.
2-
31
# dependencies
42
node_modules/
53

.travis.yml

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
sudo: false
22
language: node_js
33
node_js:
4-
- '10.0.0'
4+
- 10.0.0
55
before_install:
6-
- npm i -g npm@6.4.1
7-
- npm install -g typescript
6+
- npm i -g npm@6.4.1
7+
- npm install -g typescript
88
stages:
9-
- test
10-
- name: publish-edge
11-
if: (NOT type IN (pull_request)) AND (branch = develop)
12-
- name: publish-latest
13-
# Travis assigns the tag to branch for some reason. This matches any valid semver version.
14-
if: branch =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$
9+
- test
10+
- name: publish-edge
11+
if: "(NOT type IN (pull_request)) AND (branch = develop)"
12+
- name: publish-latest
13+
if: branch =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$
1514
jobs:
1615
include:
17-
- stage: test
18-
name: "Lint and Test"
19-
script:
20-
- npm run lint
21-
- npm run test
22-
- stage: publish-edge
23-
name: "Publish @edge to NPM"
24-
script:
25-
- npm run build
26-
deploy:
27-
provider: script
28-
skip_cleanup: true
29-
script: ./scripts/publish-edge.sh
30-
on:
31-
branch: develop
32-
- stage: publish-latest
33-
name: "Publish @latest to NPM"
34-
script:
35-
- npm run build
36-
deploy:
37-
provider: script
38-
skip_cleanup: true
39-
script: ./scripts/publish-latest.sh
40-
on:
41-
all_branches: true
42-
condition: $TRAVIS_TAG =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$
16+
- stage: test
17+
name: Lint and Test
18+
script:
19+
- npm run lint
20+
- npm run test
21+
- stage: publish-edge
22+
name: Publish @edge to NPM
23+
script:
24+
- npm run build
25+
deploy:
26+
provider: script
27+
skip_cleanup: true
28+
script: "./scripts/publish-edge.sh"
29+
on:
30+
branch: develop
31+
- stage: publish-latest
32+
name: Publish @latest to NPM
33+
script:
34+
- npm run build
35+
deploy:
36+
provider: script
37+
skip_cleanup: true
38+
script: "./scripts/publish-latest.sh"
39+
on:
40+
all_branches: true
41+
condition: "$TRAVIS_TAG =~ ^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$"
42+
notifications:
43+
webhooks:
44+
secure: ji2Jmd5PZb0/4hTxcCPQDTaVVNWvY09VFN/q2jXxBlYd/h6QyXB4pDfEm+gm6O3kLMZrL/k+75HzlVf9UYRrHd1CO85Rj5nrqImgCwdxYbmPRnehdwgoAknz6+A8+CZRIphcxXyFKOw4Q5Fvs4WXlCu4vWeE/vbv1rY3bH22Iv8lmeddaAk5i61ReppZK+JiYXhSQwhpNWWWRpCFDw87jawujuXe3ToppSkJ0C3v/oaKg9+ngIbZ0skDqe2cD/Ia7AvSynyyemHRY3AJ/t+ekXAY3rnP4wvdMZ0A0mfRGOq2yzkZBtUa3vG4WrseoNz3K8z1uDDqQLEUEb14SitNd4NXIdYXEUG1suM0AoEszAjcDt7r3ddv7J6f3cJ8qxTLLXj6Qf7Ceee/AEU54CsJkIamG9PL2HQky4GnXsqNCOgpwivedYcFoEPiUmbz3Pcz8aR8LvnE7RH/IImUiMODhIwR0nMH6etARk+j3D5XyFeHzVkjYyg0P9gEo54vl/4T9Op4lQQJ63mqhPGvELNij5nrTLxIGSWsiz3LFn/ranDLUN1sSoCl8X3yXOWAfRxr/Q3Tg7/gvqLDov0HNfTXQ45cDuAVxP0SlZwwsqMYFAU0+rPd8alLEMVxhGztezfZNA2mYhs5bxofy83UpnkvR6t7gNuarW+UTJXQZRZtVzU=

CONTRIBUTING.md

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# Contributing to demux-js-eos
2+
3+
Interested in contributing? That's awesome! Here are some guidelines to get started quickly and easily:
4+
5+
- [Contributing to demux-js-eos](#contributing-to-demux-js-eos)
6+
- [Reporting An Issue](#reporting-an-issue)
7+
- [Bug Reports](#bug-reports)
8+
- [Feature Requests](#feature-requests)
9+
- [Change Requests](#change-requests)
10+
- [Working on demux-js-eos](#working-on-demux-js-eos)
11+
- [Feature Branches](#feature-branches)
12+
- [Submitting Pull Requests](#submitting-pull-requests)
13+
- [Testing and Quality Assurance](#testing-and-quality-assurance)
14+
- [Conduct](#conduct)
15+
- [Contributor License & Acknowledgments](#contributor-license--acknowledgments)
16+
- [References](#references)
17+
18+
## Reporting An Issue
19+
20+
If you're about to raise an issue because you think you've found a problem with demux-js-eos, or you'd like to make a request for a new feature in the codebase, or any other reason… please read this first.
21+
22+
The GitHub issue tracker is the preferred channel for [bug reports](#bug-reports), [feature requests](#feature-requests), and [submitting pull requests](#submitting-pull-requests), but please respect the following restrictions:
23+
24+
* Please **search for existing issues**. Help us keep duplicate issues to a minimum by checking to see if someone has already reported your problem or requested your idea.
25+
26+
* Please **be civil**. Keep the discussion on topic and respect the opinions of others. See also our [Contributor Code of Conduct](#conduct).
27+
28+
### Bug Reports
29+
30+
A bug is a _demonstrable problem_ that is caused by the code in the repository. Good bug reports are extremely helpful - thank you!
31+
32+
Guidelines for bug reports:
33+
34+
1. **Use the GitHub issue search** — check if the issue has already been
35+
reported.
36+
37+
1. **Check if the issue has been fixed** — look for [closed issues](https://github.com/EOSIO/demux-js-eos/issues?q=is%3Aissue+is%3Aclosed) or try to reproduce it
38+
using the latest `develop` branch.
39+
40+
A good bug report shouldn't leave others needing to chase you up for more information. Be sure to include the details of your environment and relevant tests that demonstrate the failure.
41+
42+
[Report a bug](https://github.com/EOSIO/demux-js-eos/issues/new?title=Bug%3A)
43+
44+
### Feature Requests
45+
46+
Feature requests are welcome. Before you submit one be sure to have:
47+
48+
1. **Use the GitHub search** and check the feature hasn't already been requested.
49+
1. Take a moment to think about whether your idea fits with the scope and aims of the project.
50+
1. Remember, it's up to *you* to make a strong case to convince the project's leaders of the merits of this feature. Please provide as much detail and context as possible, this means explaining the use case and why it is likely to be common.
51+
52+
### Change Requests
53+
54+
Change requests cover both architectural and functional changes to how demux-js-eos works. If you have an idea for a new or different dependency, a refactor, or an improvement to a feature, etc - please be sure to:
55+
56+
1. **Use the GitHub search** and check someone else didn't get there first
57+
1. Take a moment to think about the best way to make a case for, and explain what you're thinking. Are you sure this shouldn't really be
58+
a [bug report](#bug-reports) or a [feature request](#feature-requests)? Is it really one idea or is it many? What's the context? What problem are you solving? Why is what you are suggesting better than what's already there?
59+
60+
## Working on demux-js-eos
61+
62+
Code contributions are welcome and encouraged! If you are looking for a good place to start, check out the [good first issue](https://github.com/EOSIO/demux-js-eos/labels/good%20first%20issue) label in GitHub issues.
63+
64+
Also, please follow these guidelines when submitting code:
65+
66+
### Feature Branches
67+
68+
To get it out of the way:
69+
70+
- **[develop](https://github.com/EOSIO/demux-js-eos/tree/develop)** is the development branch. All work on the next release happens here so you should generally branch off `develop`. Do **NOT** use this branch for a production site.
71+
- **[master](https://github.com/EOSIO/demux-js-eos/tree/master)** contains the latest release of demux-js-eos. This branch may be used in production. Do **NOT** use this branch to work on demux-js-eos's source.
72+
73+
### Submitting Pull Requests
74+
75+
Pull requests are awesome. If you're looking to raise a PR for something which doesn't have an open issue, please think carefully about [raising an issue](#reporting-an-issue) which your PR can close, especially if you're fixing a bug. This makes it more likely that there will be enough information available for your PR to be properly tested and merged.
76+
77+
### Testing and Quality Assurance
78+
79+
Never underestimate just how useful quality assurance is. If you're looking to get involved with the code base and don't know where to start, checking out and testing a pull request is one of the most useful things you could do.
80+
81+
Essentially, [check out the latest develop branch](#working-on-demux-js-eos), take it for a spin, and if you find anything odd, please follow the [bug report guidelines](#bug-reports) and let us know!
82+
83+
## Conduct
84+
85+
While contributing, please be respectful and constructive, so that participation in our project is a positive experience for everyone.
86+
87+
Examples of behavior that contributes to creating a positive environment include:
88+
- Using welcoming and inclusive language
89+
- Being respectful of differing viewpoints and experiences
90+
- Gracefully accepting constructive criticism
91+
- Focusing on what is best for the community
92+
- Showing empathy towards other community members
93+
94+
Examples of unacceptable behavior include:
95+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
96+
- Trolling, insulting/derogatory comments, and personal or political attacks
97+
- Public or private harassment
98+
- Publishing others’ private information, such as a physical or electronic address, without explicit permission
99+
- Other conduct which could reasonably be considered inappropriate in a professional setting
100+
101+
## Contributor License & Acknowledgments
102+
103+
This repository contains a notice of a license (MIT), and in accordance with [GitHub’s Terms of Service](https://help.github.com/articles/github-terms-of-service/), whenever you make a contribution to this project, you license your contribution under the same terms, and you agree that you have the right to license your contribution under those terms.
104+
105+
Whenever you make a contribution to this project, you also certify in the terms of the Developer’s Certificate of Origin set out below:
106+
107+
```
108+
Developer Certificate of Origin
109+
Version 1.1
110+
111+
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
112+
1 Letterman Drive
113+
Suite D4700
114+
San Francisco, CA, 94129
115+
116+
Everyone is permitted to copy and distribute verbatim copies of this
117+
license document, but changing it is not allowed.
118+
119+
120+
Developer's Certificate of Origin 1.1
121+
122+
By making a contribution to this project, I certify that:
123+
124+
(a) The contribution was created in whole or in part by me and I
125+
have the right to submit it under the open source license
126+
indicated in the file; or
127+
128+
(b) The contribution is based upon previous work that, to the best
129+
of my knowledge, is covered under an appropriate open source
130+
license and I have the right under that license to submit that
131+
work with modifications, whether created in whole or in part
132+
by me, under the same open source license (unless I am
133+
permitted to submit under a different license), as indicated
134+
in the file; or
135+
136+
(c) The contribution was provided directly to me by some other
137+
person who certified (a), (b) or (c) and I have not modified
138+
it.
139+
140+
(d) I understand and agree that this project and the contribution
141+
are public and that a record of the contribution (including all
142+
personal information I submit with it, including my sign-off) is
143+
maintained indefinitely and may be redistributed consistent with
144+
this project or the open source license(s) involved.
145+
```
146+
147+
## References
148+
149+
* Overall CONTRIB adapted from https://github.com/mathjax/MathJax/blob/master/CONTRIBUTING.md
150+
* Conduct section adapted from the Contributor Covenant, version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018-2019 block.one
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.

README.md

Lines changed: 76 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ npm install demux-eos --save
1515

1616
## Usage
1717

18-
This library provides two Action Reader implementations for reading from EOSIO blockchains: `NodeosActionReader` and `MongoActionReader`. **It is currently recomended to use the `MongoActionReader` due to performance and the ability to read inline and deferred actions.**
18+
This library provides three Action Reader implementations for reading from EOSIO blockchains: `NodeosActionReader`, `MongoActionReader`, and `StateHistoryPostgresActionReader`. **It is currently recomended to use the `MongoActionReader` due to performance and the ability to read inline and deferred actions.**
1919

2020
### MongoActionReader
2121

@@ -54,13 +54,75 @@ const { MongoActionReader } = require("demux-eos")
5454
// See supported Action Handlers here: https://github.com/EOSIO/demux-js#class-implementations
5555
const actionHandler = ...
5656

57-
const actionReader = new MongoActionReader(
58-
"mongo://...", // mongoEndpoint: the url of the mongodb instance
59-
1234, // startAtBlock: the first block relevant to our application
60-
false, // onlyIrreversible: whether or not to only process irreversible blocks
61-
600, // the maximum history length
62-
"EOS", // name of the database
57+
const actionReader = new MongoActionReader({
58+
startAtBlock: 1234, // startAtBlock: the first block relevant to our application
59+
onlyIrreversible: false, // onlyIrreversible: whether or not to only process irreversible blocks
60+
dbName: "EOS", // name of the database
61+
mongoEndpoint: "mongo://...", // mongoEndpoint: the url of the mongodb instance
62+
})
63+
64+
const actionWatcher = new BaseActionWatcher(actionReader, actionHander, 500)
65+
66+
// This must be done before calling watch so the MongoDB connection can be made
67+
actionReader.initialize().then(() =>
68+
actionWatcher.watch()
6369
)
70+
```
71+
72+
### StateHistoryPostgresActionReader
73+
74+
Reads from a Postgres instance when nodeos is configured to use the State History Plugin as well as the [fill-postgresql](https://github.com/EOSIO/fill-postgresql) tool.
75+
76+
#### Setup
77+
78+
To use the `StateHistoryPostgresActionReader`, you must first make sure that your environment is properly configured, as it otherwise may yield unpredictable or incorrect results. To set up a proper environment, make sure the following are true:
79+
80+
- You are running a producing node.
81+
82+
- You are running a second node with the state history plugin enabled.
83+
- Is not producing blocks
84+
- Is connected to the node(s) producing blocks via the `p2p-peer-address` configuration
85+
- `--disable-replay-opts` set via CLI.
86+
- `--plugin eosio::state_history_plugin` set via CLI.
87+
- `--trace-history` set via CLI.
88+
- `--chain-state-history` set via CLI.
89+
- `--state-history-endpoint \"0.0.0.0:<preferred_port>\"` set via CLI.
90+
91+
- You are running fill-postgresql.
92+
- `--endpoint=<ip_of_above_node:port_specified>` set via CLI.
93+
- `--schema=<preferred_schema>` set via CLI.
94+
- `--drop` set via CLI. This will cleanup any existing tables.
95+
- `--create` set via CLI. This will create the schema/tables as needed.
96+
97+
This means that in a development environment, you will need to set up at least two Nodeos instances: one to produce blocks, and a peer with the State History plugin activated to populate the Postgresql instance.
98+
99+
#### Inline and Deferred Actions
100+
101+
Unlike the `NodeosActionReader`, inline and deferred actions are able to be captured and passed on to the Action Handler. Additionally, each Action has a `notifiedAccounts` property that lists all accounts notified of the blockchain action (this information is also not available via the `NodeosActionReader`).
102+
103+
#### Example
104+
105+
```javascript
106+
const { BaseActionWatcher } = require("demux")
107+
const { StateHistoryPostgresActionReader } = require("demux-eos")
108+
109+
// See supported Action Handlers here: https://github.com/EOSIO/demux-js#class-implementations
110+
const actionHandler = ...
111+
112+
const massiveConfig = {
113+
host: 'localhost',
114+
port: 5432,
115+
database: 'chain',
116+
user: 'postgres',
117+
password: 'postgres'
118+
}
119+
120+
const actionReader = new StateHistoryPostgresActionReader({
121+
startAtBlock: 1234, // startAtBlock: the first block relevant to our application
122+
onlyIrreversible: false, // onlyIrreversible: whether or not to only process irreversible blocks
123+
dbSchema: "chain", // name of the database
124+
massiveConfig, // provides config to internal massivejs instance.
125+
})
64126

65127
const actionWatcher = new BaseActionWatcher(actionReader, actionHander, 500)
66128

@@ -70,6 +132,7 @@ actionReader.initialize().then(() =>
70132
)
71133
```
72134

135+
73136
### NodeosActionReader
74137

75138
Makes requests directly to a specified Nodeos API endpoint to obtain block data.
@@ -82,17 +145,16 @@ All that is required is a running Nodeos instance that has the `chain_api_plugin
82145

83146
```javascript
84147
const { BaseActionWatcher } = require("demux")
85-
const { MongoActionReader } = require("demux-eos")
148+
const { NodeosActionReader } = require("demux-eos")
86149

87150
// See supported Action Handlers here: https://github.com/EOSIO/demux-js#class-implementations
88151
const actionHandler = ...
89152

90-
const actionReader = new MongoActionReader(
91-
"http://...", // mongoEndpoint: the url of the Nodeos API
92-
1234, // startAtBlock: the first block relevant to our application
93-
false, // onlyIrreversible: whether or not to only process irreversible blocks
94-
600, // the maximum history length
95-
)
153+
const actionReader = new NodeosActionReader({
154+
startAtBlock: 1234, // startAtBlock: the first block relevant to our application
155+
onlyIrreversible: false, // onlyIrreversible: whether or not to only process irreversible blocks
156+
nodeosEndpoint: "http://...", // mongoEndpoint: the url of the Nodeos API
157+
})
96158

97159
const actionWatcher = new BaseActionWatcher(actionReader, actionHander, 500)
98160

0 commit comments

Comments
 (0)