@bosonprotocol/eventcapture
v0.0.1-alpha.0
Published
Wrap event capture to fix missed events after a chain reorganization
Downloads
4
Keywords
Readme
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/eventcapture
YOUR CODE BEFORE
contract.on(eventName, listener)
YOUR CODE AFTER
new EventWrapper(
contract,
eventName,
listener,
onCancelledTransactionHandler,
new EventStore())
Test it
Unit tests
npm run test
Integration tests
Be sure the .env file is defining the JSON_RPC_URL
JSON_RPC_PROVIDER=xxxxxxx
Then run the example
npm run example
Build the library
npm run build
Publish the library
npm publish