mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-19 20:36:19 +00:00
4f8f1d8cd7
* 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> |
||
---|---|---|
.. | ||
environments | ||
src | ||
tasks | ||
test/contracts | ||
.eslintignore | ||
.eslintrc.json | ||
.gitignore | ||
.mocharc.yml | ||
hardhat.config.ts | ||
package.json | ||
README.md | ||
tsconfig.json |
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