@@ -28,17 +28,31 @@ BLOCK_FROM=18421105 sqd process:oeth # Start processing at block 18421105
28
28
BLOCK_TO=18421105 sqd process:oeth # Process up to block 18421105
29
29
```
30
30
31
- ## Frequent Commands
31
+ ## Useful Commands
32
32
33
33
``` shell
34
- yarn codegen # Generate Schema code
35
- sqd typegen # Generate ABI code
36
- sqd down # Bring down squid container
37
- sqd up # Bring up squid container
38
- sqd process:oeth # Run OETH processor
39
- sqd process:ousd # Run OUSD processor
40
- sqd process:mainnet # Run misc processor
41
- sqd migration:generate # Generate migration (sqd down && sqd up first)
34
+ # Code Generation
35
+ yarn generate # Generate new migration
36
+ yarn typegen # Generate ABI code
37
+
38
+ yarn setup # Reset database - run prior to starting processing for a fresh start
39
+
40
+ # Processing Commands
41
+ yarn process:arbitrum # Run Arbitrum processor
42
+ yarn process:base # Run Base processor
43
+ yarn process:sonic # Run Sonic processor
44
+ yarn process:oeth # Run OETH processor
45
+ yarn process:ousd # Run OUSD processor
46
+ yarn process:ogv # Run OGV processor
47
+ yarn process:mainnet # Run misc mainnet processor
48
+ yarn process:test # Run test processor
49
+ yarn process # Run combined processor
50
+
51
+ # Local GraphQL Server
52
+ yarn serve # You'll have to rebuild and rerun to see updates here.
53
+
54
+ # Deployment Tools
55
+ yarn postdeploy v81 # Run post-deployment tasks (processing times log and validations)
42
56
```
43
57
44
58
## Quickstart
@@ -47,99 +61,107 @@ sqd migration:generate # Generate migration (sqd down && sqd up first)
47
61
# 0. Install @subsquid/cli a.k.a. the sqd command globally
48
62
npm i -g @subsquid/cli
49
63
50
- # 1. Retrieve the template
51
- sqd init my_squid_name -t evm
52
- cd my_squid_name
53
-
54
- # 2. Install dependencies
64
+ # 1. Install dependencies
55
65
npm ci
56
66
57
- # 3 . Start a Postgres database container and detach
58
- sqd up
67
+ # 2 . Start a Postgres database container and setup
68
+ yarn setup
59
69
60
- # 4. Build and start the processor
61
- sqd process:oeth
70
+ # 3. Build and start the processor (choose one)
71
+ yarn process:oeth
72
+ yarn process:ousd
73
+ yarn process:mainnet
74
+ # ... or other available processors
62
75
63
- # 5. The command above will block the terminal
64
- # being busy with fetching the chain data,
65
- # transforming and storing it in the target database.
66
- #
67
- # To start the graphql server open the separate terminal
68
- # and run
69
- sqd serve
76
+ # 4. In a separate terminal, start the GraphQL server
77
+ yarn serve
70
78
```
71
79
72
80
A GraphiQL playground will be available at [ localhost:4350/graphql] ( http://localhost:4350/graphql ) .
73
81
74
- ## Dev flow
75
-
76
- ### 1. Define database schema
82
+ ## Dev Flow
77
83
78
- Start development by defining the schema of the target database via ` schema.graphql ` .
79
- Schema definition consists of regular graphql type declarations annotated with custom directives.
80
- Full description of ` schema.graphql ` dialect is available [ here] ( https://docs.subsquid.io/basics/schema-file ) .
84
+ ### 1. Make Schema Changes
81
85
82
- ### 2. Generate TypeORM classes
86
+ - Add or modify GraphQL schema files in ` src/**/*.graphql `
87
+ - Run ` yarn generate ` to:
88
+ - Combine GraphQL files into schema.graphql
89
+ - Generate TypeORM entities
90
+ - Create new database migration
91
+ - Add new files to git
83
92
84
- Mapping developers use TypeORM [ EntityManager] ( https://typeorm.io/#/working-with-entity-manager )
85
- to interact with target database during data processing. All necessary entity classes are
86
- generated by the squid framework from ` schema.graphql ` . This is done by running ` yarn codegen `
87
- command.
93
+ ### 2. Add New Events/Contracts
88
94
89
- NOTE: We don't directly use the ` sqd codegen ` command because we generate our schema.graphql file first in
90
- the ` yarn codegen ` script.
95
+ - Add ABI JSON files to ` ./abi/ `
96
+ - Run ` yarn typegen ` to generate TypeScript interfaces
97
+ - Create new processor in ` src/processors/ ` or add to existing one
98
+ - Update ` squid.yaml ` if adding new processor
91
99
92
- ### 3. Generate database migrations
93
-
94
- All database changes are applied through migration files located at ` db/migrations ` .
95
- ` squid-typeorm-migration(1) ` tool provides several commands to drive the process.
100
+ ### 3. Local Development
96
101
97
102
``` bash
98
- # # drop create the database
99
- sqd down
100
- sqd up
103
+ # Start fresh
104
+ yarn setup
105
+
106
+ # Run processor (choose one)
107
+ yarn process:oeth
108
+ yarn process:ousd
109
+ # ... etc
101
110
102
- # # replace any old schemas with a new one made from the entities
103
- sqd migration:generate
111
+ # In another terminal
112
+ yarn serve
104
113
```
105
114
106
- See [ docs on database migrations ] ( https://docs.subsquid.io/basics/db-migrations ) for more details.
115
+ ### 4. Testing Changes
107
116
108
- ### 4. Import ABI contract and generate interfaces to decode events
117
+ - Use GraphiQL playground at [ localhost:4350/graphql] ( http://localhost:4350/graphql )
118
+ - Check processing times with ` yarn log:processing-times `
119
+ - Validate data integrity with generated validation queries
109
120
110
- It is necessary to import the respective ABI definition to decode EVM logs. One way to generate a type-safe facade class
111
- to decode EVM logs is by placing the relevant JSON ABIs to ` ./abi ` , then using ` squid-evm-typegen(1) ` via an ` sqd `
112
- script:
121
+ ### 5. Deployment
122
+
123
+ #### Development (v999)
113
124
114
125
``` bash
115
- sqd typegen
126
+ # Reset dev environment (v999)
127
+ # Only use when you need to reset schema or reload data
128
+ sqd deploy . --update --hard-reset
116
129
```
117
130
118
- See more details on the [ ` squid-evm-typegen ` doc page ] ( https://docs.subsquid.io/evm-indexing/squid-evm-typegen ) .
131
+ #### Production Deployment
119
132
120
- ## Project conventions
133
+ 1 . Create and push a new version branch
121
134
122
- Squid tools assume a certain [ project layout] ( https://docs.subsquid.io/basics/squid-structure ) :
135
+ ``` bash
136
+ git checkout -b v80 # Replace 80 with your version number
137
+ # Make any final changes if needed
138
+ git push origin v80
139
+ ```
140
+
141
+ 2 . Wait for the deployment to complete and validate the data
142
+
143
+ 3 . Tag for production
144
+
145
+ ``` bash
146
+ # Once validated, tag the latest commit for production
147
+ git tag prod-v80 # Replace 80 with your version number
148
+ git push origin prod-v80
149
+ ```
123
150
124
- - All compiled js files must reside in ` lib ` and all TypeScript sources in ` src ` .
125
- The layout of ` lib ` must reflect ` src ` .
126
- - All TypeORM classes must be exported by ` src/model/index.ts ` (` lib/model ` module).
127
- - Database schema must be defined in ` schema.graphql ` .
128
- - Database migrations must reside in ` db/migrations ` and must be plain js files.
129
- - ` sqd(1) ` and ` squid-*(1) ` executables consult ` .env ` file for environment variables.
151
+ 4 . Monitor deployment
130
152
131
- ## Deploy a new version
153
+ - Check processing at https://app.subsquid.io/squids
154
+ - Follow release checklist at the top of this README
155
+ - Keep the version branch for reference, DO NOT DELETE
132
156
133
- - Visit [ Squid deploy dashboard] ( https://app.subsquid.io/squids/deploy )
134
- - Auth with ` sqd auth -k sqd_XXX ` (key is on squid deploy page)
135
- - Update ` squid.yaml ` to set the correct version
136
- - Run ` sqd deploy . `
137
- - Make branch for new version (eg v9) and push to origin
138
- - Switch back to main branch
157
+ Note: Local deployment via ` sqd deploy . ` is possible but not recommended for production releases.
139
158
140
- ## Reset cloud dev version (v999)
159
+ ## Project conventions
141
160
142
- Useful if you made a schema change or need to reload data.
161
+ Squid tools assume a certain [ project layout ] ( https://docs.subsquid.io/basics/squid-structure ) :
143
162
144
- - Check ` squid.yaml ` to make sure you're on v999
145
- - ` sqd deploy . --update --hard-reset `
163
+ - All compiled js files must reside in ` lib ` and all TypeScript sources in ` src `
164
+ - The layout of ` lib ` must reflect ` src `
165
+ - All TypeORM classes must be exported by ` src/model/index.ts `
166
+ - Database schema is generated from GraphQL files in ` src `
167
+ - Database migrations must reside in ` db/migrations ` and must be plain js files
0 commit comments