watcher-ts/packages/lighthouse-watcher
Ashwin Phatak 4f8f1d8cd7
Update code for log_cids change in vdb core (#243)
* Remove fields no longer present in schema.

* Refactor code to work with log_cids change in eth-server.

* Refactor process event to save events from logs.

* Use constants for erc20 event names.

* Implement watch blocks in erc20-watcher similar to uni-watcher.

* Moved common methods to util.

* Implement eventsInRange query in erc20-watcher.

* Filter unknown event in database query.

* Change dependencies version to be same in all packages.

Co-authored-by: nabarun <nabarun@deepstacksoft.com>
2021-09-21 16:43:55 +05:30
..
environments Remove unused settings from lighthouse config. (#210) 2021-08-12 10:33:23 +05:30
src Update code for log_cids change in vdb core (#243) 2021-09-21 16:43:55 +05:30
tasks Add APGL license and copyright notices (#212) 2021-08-12 15:28:13 +05:30
test/contracts Link to original code/license for reused source (#214) 2021-08-13 15:23:42 +05:30
.eslintignore Lighthouse watcher (#205) 2021-08-11 17:27:49 +05:30
.eslintrc.json Lighthouse watcher (#205) 2021-08-11 17:27:49 +05:30
.gitignore Lighthouse watcher (#205) 2021-08-11 17:27:49 +05:30
.mocharc.yml Lighthouse watcher (#205) 2021-08-11 17:27:49 +05:30
hardhat.config.ts Lighthouse watcher (#205) 2021-08-11 17:27:49 +05:30
package.json Enable source maps for transpiled files (#242) 2021-09-07 16:01:15 +05:30
README.md Run services from transpiled ES5 (#239) 2021-09-02 10:27:56 +05:30
tsconfig.json Enable source maps for transpiled files (#242) 2021-09-07 16:01:15 +05:30

Lighthouse Watcher

Setup

Deploy a Lighthouse contract:

yarn lighthouse:deploy

Use the Lighthouse contract address and set environments/local.toml to watch the contract.

[watch]
  lighthouse = "0xLighthouseContractAddress"

Run

Build files:

$ yarn build

Run the server:

$ yarn server

# For development.
$ yarn server:dev

# For specifying config file.
$ yarn server -f environments/local.toml

Test

To test the watcher locally:

Open graphql playground at http://127.0.0.1:3005/graphql and set a subscription query

subscription {
  onEvent {
    block {
      hash
      number
      timestamp
    }
    tx {
      hash
    }
    contract
    eventIndex
    event {
      __typename
      ... on StorageRequestEvent {
        uploader
        cid
        config
        fileCost
      }
    }
    proof {
      data
    }
  }
}

To trigger StorageRequest event locally, run:

yarn lighthouse:store --lighthouse 0xLighthouseContractAddress --cid testCid --store-config testConfig --file-cost 10

Smoke test

To run a smoke test:

  • Start the server.

  • Run:

    $ yarn smoke-test