0.0.1-alpha.0 • Published 4 years ago
@bosonprotocol/eventcapture v0.0.1-alpha.0
EventCapture library
This library wraps the blockchain event capture on-flight, so that it's possible:
- to listen to events, calling a specific handler for each of them when they occur (as ethers.js provides it)
- to look back to events a few blocks later (20 blocks by default) in order to detect some events that could have been missed by the on-flight (usually as a consequence of a chain reorganization)
- to look back to events again a few blocks later in order to detect some events that have been captured and then, been cancelled (usually as a consequence of a chain reorganization)
Use it
Instead of subscribing directly to the events of a contracts using the on method, create a new EventWrapper instance.
Installation
npm install @bosonprotocol/eventcaptureYOUR CODE BEFORE
contract.on(eventName, listener)YOUR CODE AFTER
new EventWrapper(
contract,
eventName,
listener,
onCancelledTransactionHandler,
new EventStore())Test it
Unit tests
npm run testIntegration tests
Be sure the .env file is defining the JSON_RPC_URL
JSON_RPC_PROVIDER=xxxxxxxThen run the example
npm run exampleBuild the library
npm run buildPublish the library
npm publish0.0.1-alpha.0
4 years ago