mirror of
https://github.com/cerc-io/watcher-ts
synced 2024-11-20 04:46:20 +00:00
6560639a68
Co-authored-by: prathamesh <prathamesh.musale0@gmail.com>
2.0 KiB
2.0 KiB
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 usingstdout
if 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_call
yarn 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.2
is being used to fetch from URLs asv3.0.0
is an ESM-only module andts-node
transpiles to import it usingrequire
.