mirror of
https://github.com/cerc-io/watcher-ts
synced 2025-11-11 00:54:09 +00:00
|
|
||
|---|---|---|
| .. | ||
| src | ||
| .eslintignore | ||
| .eslintrc.json | ||
| package.json | ||
| README.md | ||
| tsconfig.json | ||
Code Generator
Setup
-
Run the following command to install required packages:
yarn
Run
-
Run the following command to generate schema from a contract file:
yarn codegen:gql --input-file <input-file-path> --output-file [output-file-path] --mode [eth_call | storage] --flatten [true | false]input-file(alias:i): Input contract file path or an URL (required).output-file(alias:o): Schema output file path (logs output usingstdoutif not provided).mode(alias:m): Code generation mode (default:storage).flatten(alias:f): Flatten the input contract file (default:true).
Note: When passed an URL as
input-file, it is assumed that it points to an already flattened contract file.Examples:
yarn codegen:gql --input-file ./test/examples/contracts/ERC20.sol --output-file ./ERC20-schema.gql --mode eth_callyarn codegen:gql --input-file https://git.io/Jupci --output-file ./ERC721-schema.gql --mode storage
Demo
-
Install required packages:
yarn -
Generate schema from a contract file:
yarn codegen:gql --input-file ../../node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol --output-file ./ERC20-schema.gql --mode storage -
Generate schema from a flattened contract file from an URL:
yarn codegen:gql --input-file https://git.io/Jupci --output-file ./ERC721-schema.gql --mode eth_call
References
- ERC20 schema generation (eth_call mode).
- ERC20 schema generation (storage mode).
- ERC721 schema generation (eth_call mode).
- ERC721 schema generation (storage mode).
Known Issues
- Currently,
node-fetch v2.6.2is being used to fetch from URLs asv3.0.0is an ESM-only module andts-nodetranspiles to import it usingrequire.