mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-01-06 19:38:05 +00:00
deduplicate the Customize section
This commit is contained in:
parent
dd9f85f268
commit
67dd22e761
20
packages/README.md
Normal file
20
packages/README.md
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Watchers Directory
|
||||||
|
|
||||||
|
Here contains all the publicly available watchers for your experimenting purposes. For general information on setting up the stack and the CLI commands used to interact with watchers, see the [docs](/docs) directory.
|
||||||
|
|
||||||
|
## Customizing Watchers
|
||||||
|
|
||||||
|
* Indexing on an event:
|
||||||
|
|
||||||
|
* Edit the custom hook function `handleEvent` (triggered on an event) in [hooks.ts](./src/hooks.ts) to perform corresponding indexing using the `Indexer` object.
|
||||||
|
|
||||||
|
* While using the indexer storage methods for indexing, pass `diff` as true if default state is desired to be generated using the state variables being indexed.
|
||||||
|
|
||||||
|
* Generating state:
|
||||||
|
|
||||||
|
* Edit the custom hook function `createInitialState` (triggered if the watcher passes the start block, checkpoint: `true`) in [hooks.ts](./src/hooks.ts) to save an initial `State` using the `Indexer` object.
|
||||||
|
|
||||||
|
* Edit the custom hook function `createStateDiff` (triggered on a block) in [hooks.ts](./src/hooks.ts) to save the state in a `diff` `State` using the `Indexer` object. The default state (if exists) is updated.
|
||||||
|
|
||||||
|
* Edit the custom hook function `createStateCheckpoint` (triggered just before default and CLI checkpoint) in [hooks.ts](./src/hooks.ts) to save the state in a `checkpoint` `State` using the `Indexer` object.
|
||||||
|
|
@ -4,158 +4,13 @@
|
|||||||
|
|
||||||
First try the [stack orchestrator](https://github.com/cerc-io/stack-orchestrator) to quickly get started. Advanced users can see [here](/docs/README.md) for instructions on setting up a local environment by hand.
|
First try the [stack orchestrator](https://github.com/cerc-io/stack-orchestrator) to quickly get started. Advanced users can see [here](/docs/README.md) for instructions on setting up a local environment by hand.
|
||||||
|
|
||||||
## Customize
|
|
||||||
|
|
||||||
* Indexing on an event:
|
|
||||||
|
|
||||||
* Edit the custom hook function `handleEvent` (triggered on an event) in [hooks.ts](./src/hooks.ts) to perform corresponding indexing using the `Indexer` object.
|
|
||||||
|
|
||||||
* While using the indexer storage methods for indexing, pass `diff` as true if default state is desired to be generated using the state variables being indexed.
|
|
||||||
|
|
||||||
* Generating state:
|
|
||||||
|
|
||||||
* Edit the custom hook function `createInitialState` (triggered if the watcher passes the start block, checkpoint: `true`) in [hooks.ts](./src/hooks.ts) to save an initial `State` using the `Indexer` object.
|
|
||||||
|
|
||||||
* Edit the custom hook function `createStateDiff` (triggered on a block) in [hooks.ts](./src/hooks.ts) to save the state in a `diff` `State` using the `Indexer` object. The default state (if exists) is updated.
|
|
||||||
|
|
||||||
* Edit the custom hook function `createStateCheckpoint` (triggered just before default and CLI checkpoint) in [hooks.ts](./src/hooks.ts) to save the state in a `checkpoint` `State` using the `Indexer` object.
|
|
||||||
|
|
||||||
## Run
|
## Run
|
||||||
|
|
||||||
* If the watcher is a `lazy` watcher:
|
Setup with:
|
||||||
|
|
||||||
* Run the server:
|
```bash
|
||||||
|
yarn && yarn build
|
||||||
|
```
|
||||||
|
|
||||||
```bash
|
then checkout the [CLI guide](/docs/cli.md) for examples of commands that can be run on this watcher.
|
||||||
yarn server
|
|
||||||
```
|
|
||||||
|
|
||||||
GQL console: http://localhost:3012/graphql
|
|
||||||
|
|
||||||
* If the watcher is an `active` watcher:
|
|
||||||
|
|
||||||
* Run the job-runner:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn job-runner
|
|
||||||
```
|
|
||||||
|
|
||||||
* Run the server:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn server
|
|
||||||
```
|
|
||||||
|
|
||||||
GQL console: http://localhost:3012/graphql
|
|
||||||
|
|
||||||
* To watch a contract:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn watch:contract --address <contract-address> --kind <contract-kind> --checkpoint <true | false> --starting-block [block-number]
|
|
||||||
```
|
|
||||||
|
|
||||||
* `address`: Address or identifier of the contract to be watched.
|
|
||||||
* `kind`: Kind of the contract.
|
|
||||||
* `checkpoint`: Turn checkpointing on (`true` | `false`).
|
|
||||||
* `starting-block`: Starting block for the contract (default: `1`).
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
Watch a contract with its address and checkpointing on:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn watch:contract --address 0x1F78641644feB8b64642e833cE4AFE93DD6e7833 --kind ERC20 --checkpoint true
|
|
||||||
```
|
|
||||||
|
|
||||||
Watch a contract with its identifier and checkpointing on:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn watch:contract --address MyProtocol --kind protocol --checkpoint true
|
|
||||||
```
|
|
||||||
|
|
||||||
* To fill a block range:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn fill --start-block <from-block> --end-block <to-block>
|
|
||||||
```
|
|
||||||
|
|
||||||
* `start-block`: Block number to start filling from.
|
|
||||||
* `end-block`: Block number till which to fill.
|
|
||||||
|
|
||||||
* To create a checkpoint for a contract:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn checkpoint create --address <contract-address> --block-hash [block-hash]
|
|
||||||
```
|
|
||||||
|
|
||||||
* `address`: Address or identifier of the contract for which to create a checkpoint.
|
|
||||||
* `block-hash`: Hash of a block (in the pruned region) at which to create the checkpoint (default: latest canonical block hash).
|
|
||||||
|
|
||||||
* To verify a checkpoint:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn checkpoint verify --cid <checkpoint-cid>
|
|
||||||
```
|
|
||||||
|
|
||||||
`cid`: CID of the checkpoint for which to verify.
|
|
||||||
|
|
||||||
* To reset the watcher to a previous block number:
|
|
||||||
|
|
||||||
* Reset watcher:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn reset watcher --block-number <previous-block-number>
|
|
||||||
```
|
|
||||||
|
|
||||||
* Reset job-queue:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn reset job-queue
|
|
||||||
```
|
|
||||||
|
|
||||||
* Reset state:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn reset state --block-number <previous-block-number>
|
|
||||||
```
|
|
||||||
|
|
||||||
* `block-number`: Block number to which to reset the watcher.
|
|
||||||
|
|
||||||
* To export and import the watcher state:
|
|
||||||
|
|
||||||
* In source watcher, export watcher state:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn export-state --export-file [export-file-path] --block-number [snapshot-block-height]
|
|
||||||
```
|
|
||||||
|
|
||||||
* `export-file`: Path of file to which to export the watcher data.
|
|
||||||
* `block-number`: Block height at which to take snapshot for export.
|
|
||||||
|
|
||||||
* In target watcher, run job-runner:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn job-runner
|
|
||||||
```
|
|
||||||
|
|
||||||
* Import watcher state:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn import-state --import-file <import-file-path>
|
|
||||||
```
|
|
||||||
|
|
||||||
* `import-file`: Path of file from which to import the watcher data.
|
|
||||||
|
|
||||||
* Run server:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn server
|
|
||||||
```
|
|
||||||
|
|
||||||
* To inspect a CID:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn inspect-cid --cid <cid>
|
|
||||||
```
|
|
||||||
|
|
||||||
* `cid`: CID to be inspected.
|
|
||||||
|
@ -302,125 +302,4 @@ yarn checkpoint create --address $NFT_ADDRESS
|
|||||||
|
|
||||||
- The state should have auto indexed data and also custom property `transferCount` according to code in [hooks](./src/hooks.ts) file `handleEvent` method.
|
- The state should have auto indexed data and also custom property `transferCount` according to code in [hooks](./src/hooks.ts) file `handleEvent` method.
|
||||||
|
|
||||||
## Watch
|
For more `yarn` sub-commands available, see the [CLI guide](/docs/cli.md)
|
||||||
|
|
||||||
To watch a contract:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn watch:contract --address <contract-address> --kind <contract-kind> --checkpoint <true | false> --starting-block [block-number]
|
|
||||||
```
|
|
||||||
|
|
||||||
* `address`: Address or identifier of the contract to be watched.
|
|
||||||
* `kind`: Kind of the contract.
|
|
||||||
* `checkpoint`: Turn checkpointing on (`true` | `false`).
|
|
||||||
* `starting-block`: Starting block for the contract (default: `1`).
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
|
|
||||||
Watch a contract with its address and checkpointing on:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn watch:contract --address 0x1F78641644feB8b64642e833cE4AFE93DD6e7833 --kind ERC721 --checkpoint true
|
|
||||||
```
|
|
||||||
|
|
||||||
Watch a contract with its identifier and checkpointing on:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn watch:contract --address MyProtocol --kind protocol --checkpoint true
|
|
||||||
```
|
|
||||||
|
|
||||||
* To fill a block range:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn fill --start-block <from-block> --end-block <to-block>
|
|
||||||
```
|
|
||||||
|
|
||||||
* `start-block`: Block number to start filling from.
|
|
||||||
* `end-block`: Block number till which to fill.
|
|
||||||
|
|
||||||
* To create a checkpoint for a contract:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn checkpoint create --address <contract-address> --block-hash [block-hash]
|
|
||||||
```
|
|
||||||
|
|
||||||
* `address`: Address or identifier of the contract for which to create a checkpoint.
|
|
||||||
* `block-hash`: Hash of a block (in the pruned region) at which to create the checkpoint (default: latest canonical block hash).
|
|
||||||
|
|
||||||
* To reset the watcher to a previous block number:
|
|
||||||
|
|
||||||
* Reset watcher:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn reset watcher --block-number <previous-block-number>
|
|
||||||
```
|
|
||||||
|
|
||||||
* Reset job-queue:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn reset job-queue
|
|
||||||
```
|
|
||||||
|
|
||||||
* Reset state:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn reset state --block-number <previous-block-number>
|
|
||||||
```
|
|
||||||
|
|
||||||
* `block-number`: Block number to which to reset the watcher.
|
|
||||||
|
|
||||||
* To export and import the watcher state:
|
|
||||||
|
|
||||||
* In source watcher, export watcher state:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn export-state --export-file [export-file-path] --block-number [snapshot-block-height]
|
|
||||||
```
|
|
||||||
|
|
||||||
* `export-file`: Path of file to which to export the watcher data.
|
|
||||||
* `block-number`: Block height at which to take snapshot for export.
|
|
||||||
|
|
||||||
* In target watcher, run job-runner:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn job-runner
|
|
||||||
```
|
|
||||||
|
|
||||||
* Import watcher state:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn import-state --import-file <import-file-path>
|
|
||||||
```
|
|
||||||
|
|
||||||
* `import-file`: Path of file from which to import the watcher data.
|
|
||||||
|
|
||||||
* Run server:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn server
|
|
||||||
```
|
|
||||||
|
|
||||||
* To inspect a CID:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn inspect-cid --cid <cid>
|
|
||||||
```
|
|
||||||
|
|
||||||
* `cid`: CID to be inspected.
|
|
||||||
|
|
||||||
|
|
||||||
## Customize
|
|
||||||
|
|
||||||
* Indexing on an event:
|
|
||||||
|
|
||||||
* Edit the custom hook function `handleEvent` (triggered on an event) in [hooks.ts](./src/hooks.ts) to perform corresponding indexing using the `Indexer` object.
|
|
||||||
|
|
||||||
* While using the indexer storage methods for indexing, pass `diff` as true if default state is desired to be generated using the state variables being indexed.
|
|
||||||
|
|
||||||
* Generating state:
|
|
||||||
|
|
||||||
* Edit the custom hook function `createInitialState` (triggered if the watcher passes the start block, checkpoint: `true`) in [hooks.ts](./src/hooks.ts) to save an initial `State` using the `Indexer` object.
|
|
||||||
|
|
||||||
* Edit the custom hook function `createStateDiff` (triggered on a block) in [hooks.ts](./src/hooks.ts) to save the state in a `diff` `State` using the `Indexer` object. The default state (if exists) is updated.
|
|
||||||
|
|
||||||
* Edit the custom hook function `createStateCheckpoint` (triggered just before default and CLI checkpoint) in [hooks.ts](./src/hooks.ts) to save the state in a `checkpoint` `State` using the `Indexer` object.
|
|
||||||
|
@ -138,21 +138,4 @@ yarn
|
|||||||
|
|
||||||
* All the `State` entries can be seen in `pg-admin` in table `state`.
|
* All the `State` entries can be seen in `pg-admin` in table `state`.
|
||||||
|
|
||||||
|
|
||||||
## Customize
|
|
||||||
|
|
||||||
* Indexing on an event:
|
|
||||||
|
|
||||||
* Edit the custom hook function `handleEvent` (triggered on an event) in [hooks.ts](./src/hooks.ts) to perform corresponding indexing using the `Indexer` object.
|
|
||||||
|
|
||||||
* While using the indexer storage methods for indexing, pass `diff` as true if default state is desired to be generated using the state variables being indexed.
|
|
||||||
|
|
||||||
* Generating state:
|
|
||||||
|
|
||||||
* Edit the custom hook function `createInitialState` (triggered if the watcher passes the start block, checkpoint: `true`) in [hooks.ts](./src/hooks.ts) to save an initial `State` using the `Indexer` object.
|
|
||||||
|
|
||||||
* Edit the custom hook function `createStateDiff` (triggered on a block) in [hooks.ts](./src/hooks.ts) to save the state in a `diff` `State` using the `Indexer` object. The default state (if exists) is updated.
|
|
||||||
|
|
||||||
* Edit the custom hook function `createStateCheckpoint` (triggered just before default and CLI checkpoint) in [hooks.ts](./src/hooks.ts) to save the state in a `checkpoint` `State` using the `Indexer` object.
|
|
||||||
|
|
||||||
* The existing example hooks in [hooks.ts](./src/hooks.ts) are for an `ERC20` contract.
|
* The existing example hooks in [hooks.ts](./src/hooks.ts) are for an `ERC20` contract.
|
||||||
|
@ -279,20 +279,3 @@ yarn inspect-cid --cid <cid>
|
|||||||
```
|
```
|
||||||
|
|
||||||
* `cid`: CID to be inspected.
|
* `cid`: CID to be inspected.
|
||||||
|
|
||||||
## Customize
|
|
||||||
|
|
||||||
* Indexing on an event:
|
|
||||||
|
|
||||||
* Edit the custom hook function `handleEvent` (triggered on an event) in [hooks.ts](./src/hooks.ts) to perform corresponding indexing using the `Indexer` object.
|
|
||||||
|
|
||||||
* While using the indexer storage methods for indexing, pass `diff` as true if default state is desired to be generated using the state variables being indexed.
|
|
||||||
|
|
||||||
* Generating state:
|
|
||||||
|
|
||||||
* Edit the custom hook function `createInitialState` (triggered if the watcher passes the start block, checkpoint: `true`) in [hooks.ts](./src/hooks.ts) to save an initial `State` using the `Indexer` object.
|
|
||||||
|
|
||||||
* Edit the custom hook function `createStateDiff` (triggered on a block) in [hooks.ts](./src/hooks.ts) to save the state in a `diff` `State` using the `Indexer` object. The default state (if exists) is updated.
|
|
||||||
|
|
||||||
* Edit the custom hook function `createStateCheckpoint` (triggered just before default and CLI checkpoint) in [hooks.ts](./src/hooks.ts) to save the state in a `checkpoint` `State` using the `Indexer` object.
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user