2023-01-10 13:31:58 +00:00
## Watcher CLI commands
2023-01-09 18:57:40 +00:00
2023-01-10 13:31:58 +00:00
Non-exhaustive list of (yarn) CLI commands available for watchers. Assumes you have an environment setup either [by hand ](./README.md ) or using [Stack Orchestrator ](https://github.com/cerc-io/stack-orchestrator ), and have built `yarn && yarn build` a specific watcher.
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
If the watcher is an `active` watcher, run the job-runner:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn job-runner
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```
# For development.
yarn server:dev
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
# For specifying config file.
yarn server -f environments/local.toml
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
If the watcher is `lazy` omit the above step, then run the server:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn server
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
This will enable the GraphQL playground at: `http://localhost:<port>/graphql`
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
where `<port>` is set in the `environments/local.toml` of each watcher.
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
To watch a contract:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn watch:contract --address < contract-address > --kind < contract-kind > --checkpoint < true | false > --starting-block < block-number >
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
* `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` ).
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
Example:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
Watch a contract with its address and checkpointing on:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn watch:contract --address 0x1F78641644feB8b64642e833cE4AFE93DD6e7833 --kind ERC20 --checkpoint true
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
To fill a block range:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn fill --start-block < from-block > --end-block < to-block >
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
* `start-block` : Block number to start filling from.
* `end-block` : Block number till which to fill.
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
To create a checkpoint for a contract:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn checkpoint create --address < contract-address > --block-hash < block-hash >
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
* `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).
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
To verify a checkpoint:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn checkpoint verify --cid < checkpoint-cid >
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
* `cid` : CID of the checkpoint for which to verify.
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
To reset the watcher to a previous block number:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn reset watcher --block-number < previous-block-number >
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
* `block-number` : Block number to which to reset the watcher.
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
To reset the job-queue:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn reset job-queue
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
To reset the state:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn reset state --block-number < previous-block-number >
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
## Import/Export State
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
To export and import the watcher state:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
In the source watcher, export watcher state:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn export-state --export-file [export-file-path] --block-number [snapshot-block-height]
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
* `export-file` : Path of file to which to export the watcher data.
* `block-number` : Block height at which to take snapshot for export.
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
In the target watcher, run the job-runner:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn job-runner
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
Import watcher state:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn import-state --import-file < import-file-path >
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
* `import-file` : Path of file from which to import the watcher data.
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
To inspect a CID:
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
```bash
yarn inspect-cid --cid < cid >
```
2023-01-10 12:39:29 +00:00
2023-01-10 13:31:58 +00:00
* `cid` : CID to be inspected.