Commit 63cc7e6
authored
feat: deploy method refactor 2 (#23033)
## Summary
Splits `DeployMethod` into an abstract umbrella type plus three concrete
flavors that encode the deployer-lock state at the type level instead of
branching on a nullable field.
- `DeployMethod<T>` — abstract base, the type consumers use generically
(`let d: DeployMethod<MyContract> = ...`).
- `BoundDeployMethod` — locked to a concrete `deployer`.
- `UniversalDeployMethod` — locked to `AztecAddress.ZERO` (any sender).
- `PendingDeployMethod` — promotes into a `Bound`/`Universal` sibling on
the first `send` / `simulate` / `profile` call.
The three flavor-specific decisions (`getDeployerAddress`,
`lockOrAssertDeployer`, `cloneInstantiation`) are now abstract methods
rather than `if (this.deployer === undefined / equals(ZERO) / else)`
branches in the base.
## Compile-time guarantees
Each subclass takes a narrowed instantiation type:
- `BoundInstantiationOptions` — `deployer` required, `universalDeploy:
never`.
- `UniversalInstantiationOptions` — `universalDeploy: true` required,
`deployer: never`.
- `PendingInstantiationOptions` — both `never`.
`new BoundDeployMethod(..., { universalDeploy: true })` is now a
TypeScript error. The runtime mutual-exclusion checks in subclass
constructors are gone; the only runtime guard left is
`BoundDeployMethod` rejecting `AztecAddress.ZERO` (a value-level
invariant the type system can't model).
## Constructor shape
Subclass constructors take named bundles instead of 9 positionals:
```ts
new BoundDeployMethod(wallet, contract, instantiation, payload?)
// ^ ^ ^
// { artifact, postDeployCtor, args, constructorNameOrArtifact }
// { salt, publicKeys, deployer }
// { authWitnesses, capsules, extraHashedArgs }
```
`DeployMethod.create` follows the same shape. `Contract.deploy(wallet,
artifact, args, constructorName, instantiation)` and
`MyContract.deploy(wallet, ...args, instantiation?)` (codegen) are
**unchanged** — the bundle reshape stops at the `create` boundary.
## Other changes
- `DeployAccountMethod` now extends `UniversalDeployMethod` (account
contracts are always universal).1 parent d8aa9fe commit 63cc7e6
8 files changed
Lines changed: 417 additions & 157 deletions
File tree
- playground/src/components/contract/components
- yarn-project
- aztec.js/src
- api
- contract
- deployment
- wallet
- builder/src/contract-interface-gen
Lines changed: 10 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
123 | 128 | | |
124 | 129 | | |
125 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | | - | |
31 | | - | |
32 | | - | |
| 29 | + | |
33 | 30 | | |
34 | 31 | | |
35 | | - | |
36 | | - | |
37 | | - | |
| 32 | + | |
38 | 33 | | |
39 | 34 | | |
40 | 35 | | |
| |||
43 | 38 | | |
44 | 39 | | |
45 | 40 | | |
46 | | - | |
47 | 41 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 42 | + | |
52 | 43 | | |
53 | | - | |
54 | 44 | | |
55 | | - | |
56 | 45 | | |
57 | 46 | | |
58 | | - | |
59 | 47 | | |
60 | 48 | | |
61 | 49 | | |
| |||
112 | 100 | | |
113 | 101 | | |
114 | 102 | | |
115 | | - | |
116 | 103 | | |
117 | | - | |
118 | 104 | | |
119 | 105 | | |
120 | | - | |
121 | 106 | | |
122 | 107 | | |
123 | | - | |
124 | 108 | | |
125 | 109 | | |
126 | 110 | | |
| |||
147 | 131 | | |
148 | 132 | | |
149 | 133 | | |
150 | | - | |
151 | 134 | | |
152 | 135 | | |
153 | 136 | | |
| |||
0 commit comments