You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tools/operations-gen/README.md
+69-2Lines changed: 69 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,6 +127,17 @@ contracts:
127
127
access: owner # Write op with MCMS support
128
128
- name: getTokenPrice
129
129
access: public # Read op (or public write op)
130
+
131
+
# Same ABI, multiple datastore labels — one Deploy handles all three.
132
+
- contract_name: ManyChainMultiSig
133
+
version: "1.0.0"
134
+
deploy_contract_types:
135
+
- ProposerManyChainMultiSig
136
+
- BypasserManyChainMultiSig
137
+
- CancellerManyChainMultiSig
138
+
functions:
139
+
- name: setConfig
140
+
access: owner
130
141
```
131
142
132
143
### Top-level fields
@@ -148,8 +159,9 @@ contracts:
148
159
| `gobindings_package` | No | Optional full Go import path or relative filesystem path override for this contract's abigen-generated bindings package. Required only when `input.gobindings_package` is not set. |
149
160
| `package_name` | No | Override the generated Go package name. Defaults to `snake_case(contract_name)`. |
150
161
| `version_path` | No | Override the directory path derived from the version. Defaults to `v{major}_{minor}_{patch}`. |
151
-
| `omit_deploy` | No | Skip generation of the `Deploy` operation and bytecode constant. Defaults to `false`. Cannot be combined with `zksync_bytecode`. |
152
-
| `zksync_bytecode` | No | zkSync VM deploy bytecode symbol, or `{package, symbol}`. Package defaults to `input.zksync_bindings_package`, then the contract's `gobindings_package`. |
162
+
| `omit_deploy` | No | Skip generation of the `Deploy` operation and bytecode constant. Defaults to `false`. Cannot be combined with `zksync_bytecode` or `deploy_contract_types`. |
163
+
| `deploy_contract_types` | No | List of `ContractType` labels (e.g. `ProposerManyChainMultiSig`) that share this contract's ABI and bytecode but need distinct datastore entries. Labels must be valid Go exported identifiers. When set, **only** these labels appear as keys in `BytecodeByTypeAndVersion` — the base `contract_name` type is excluded. Each label gets exported `var <Label>ContractType` and `var <Label>TypeAndVersion` vars. An empty list is rejected. Cannot be combined with `omit_deploy`. See [Deploy contract types](#deploy-contract-types). |
164
+
| `zksync_bytecode` | No | zkSync VM deploy bytecode symbol, or `{package, symbol}`. Package defaults to `input.zksync_bindings_package`, then the contract's `gobindings_package`. |
153
165
154
166
### Function access control
155
167
@@ -163,6 +175,61 @@ For `access: role`, `DEFAULT_ADMIN_ROLE` maps to the all-zero role and any other
163
175
human-readable role name is hashed as `keccak256("<ROLE_NAME>")`. Raw bytes32
164
176
role hashes are rejected so configs remain readable.
165
177
178
+
## Deploy contract types
179
+
180
+
Some contracts are deployed multiple times with different semantic roles, each requiring a distinct
181
+
`ContractType`label in the datastore (e.g. `ProposerManyChainMultiSig`, `BypasserManyChainMultiSig`,
182
+
`CancellerManyChainMultiSig`). Because all three share the same ABI and bytecode, using three
183
+
separate YAML contract entries would generate three near-identical files. `deploy_contract_types`
184
+
solves this: one entry, one generated package, one `Deploy` var — but the `BytecodeByTypeAndVersion`
185
+
map holds a key for every label so the caller can deploy under whichever type it needs.
186
+
187
+
```yaml
188
+
- contract_name: ManyChainMultiSig
189
+
version: "1.0.0"
190
+
deploy_contract_types:
191
+
- ProposerManyChainMultiSig
192
+
- BypasserManyChainMultiSig
193
+
- CancellerManyChainMultiSig
194
+
functions:
195
+
- name: setConfig
196
+
access: owner
197
+
```
198
+
199
+
This generates:
200
+
201
+
```go
202
+
var ContractType cldf_deployment.ContractType = "ManyChainMultiSig"
203
+
var ProposerManyChainMultiSigContractType cldf_deployment.ContractType = "ProposerManyChainMultiSig"
204
+
var ProposerManyChainMultiSigTypeAndVersion = cldf_deployment.NewTypeAndVersion(ProposerManyChainMultiSigContractType, *Version)
205
+
var BypasserManyChainMultiSigContractType cldf_deployment.ContractType = "BypasserManyChainMultiSig"
206
+
var BypasserManyChainMultiSigTypeAndVersion = cldf_deployment.NewTypeAndVersion(BypasserManyChainMultiSigContractType, *Version)
207
+
var CancellerManyChainMultiSigContractType cldf_deployment.ContractType = "CancellerManyChainMultiSig"
208
+
var CancellerManyChainMultiSigTypeAndVersion = cldf_deployment.NewTypeAndVersion(CancellerManyChainMultiSigContractType, *Version)
209
+
210
+
var Deploy = contract.NewDeploy(contract.DeployParams[ConstructorArgs]{
- Labels must be valid Go exported identifiers, non-empty, unique, and different from `contract_name`.
229
+
- The list must contain at least one entry; an empty list is rejected.
230
+
- Cannot be combined with `omit_deploy: true`.
231
+
- The base `contract_name` type is **not** included in `BytecodeByTypeAndVersion` when this field is set, and `TypeAndVersion` is not emitted (use the per-label `*TypeAndVersion` vars instead).
232
+
166
233
## Gobindings requirements
167
234
168
235
The generator expects an abigen-generated package that exports the standard metadata symbol:
GobindingsPackagestring`yaml:"gobindings_package"`// Optional: override the derived gobindings import path or relative filesystem path for this contract.
GobindingsPackagestring`yaml:"gobindings_package"`// Optional: override the derived gobindings import path or relative filesystem path for this contract.
0 commit comments