GithubHelp home page GithubHelp logo

tokenstore / demux-js-dfuse Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dfuse-io/demux-js-dfuse

0.0 1.0 0.0 493 KB

A demux-js Action Reader Implementation for dfuse.io

Home Page: https://dfuse.io

License: MIT License

JavaScript 20.54% TypeScript 79.46%

demux-js-dfuse's Introduction

demux-js-dfuse

A demux-js Action Reader Implementation for dfuse.io


Status GitHub Issues GitHub Pull Requests License


๐Ÿ“ Table of Contents

๐Ÿง About

demux-js-dfuse implements an ActionReader for demux-js to allow for sourcing blockchain events to deterministically update queryable datastores and trigger side effects.

๐Ÿ Getting Started

To run a basic example, run this command:

yarn run:example

The code for the example can be found in the /example directory at the root of the project.

๐Ÿ›ซ Usage

To use dfuse as your data source, simply pass a DfuseActionReader instance to a Demux ActionWatcher.

You will need to create your own ActionHandler. For more information on this, visit the demux-js repository.

It is critical that you set the ActionHandler's option validateBlocks to false. Because the dfuse API only returns the blocks that match your query, it means the chain of blocks passed through demux will be missing blocks. Without this option set, demux will not work.

To generate a dfuse API key, visit the dfuse website.

The DfuseActionReader class supports the following parameters:

  • dfuseApiKey: string. Required. An API key that can be obtained from the dfuse.io website.
  • startAtBlock: number. Optional. Defaults to 1. For positive values, this sets the first block that this will start at. For negative values, this will start at (most recent block + startAtBlock), effectively tailing the chain. Be careful when using this feature, as this will make your starting block dynamic.
  • onlyIrreversible: boolean. Optional. Defaults to false. If set to true, only irreversible blocks will be fetched
  • query: string. Optional. Defaults to status:executed. A dfuse SQE query. For more informations, see the docs.
import { BaseActionWatcher } from "demux"
import { ObjectActionHandler } from "./ObjectActionHandler"
import { handlerVersion } from "./handlerVersions/v1"
import { DfuseActionReader } from "demux-js-dfuse"

const actionHandler = new ObjectActionHandler([handlerVersion], { validateBlocks: false })

const dfuseActionReader = new DfuseActionReader({
  dfuseApiKey: "YOUR DFUSE API KEY",
  startAtBlock: 1,
  onlyIrreversible: false,
  query: "account:eosknightsio",
  network: "mainnet"
})

const actionWatcher = new BaseActionWatcher(dfuseActionReader, actionHandler, 100)
actionWatcher.watch()

๐Ÿ”ง Running the tests

All tests are run using Jest. Use yarn test to run them.

๐ŸŽ‰ Acknowledgements

  • Thanks to @flux627 for the great work on demux-js!

demux-js-dfuse's People

Contributors

olivierbeaulieu avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.