Commit 7ca3203
committed
Generate named struct types for Solidity tuples with named components
When a Solidity struct is ABI-encoded, it becomes a tuple. Previously,
the codegen always generated unnamed TypeScript tuple types (arrays)
for these, making it hard for developers to access fields by name.
Now, when a tuple has all named components (indicating a Solidity struct),
the codegen generates a named record type with proper field names. This
applies to the ReScript types (with @genType for TypeScript generation),
the rescript-schema declarations, and the HyperSync decoder conversion.
Key changes:
- abi_compat.rs: Preserve component names from alloy's EventParam
- event_parsing.rs: Add AuxTypeDecl and abi_to_rescript_type_with_structs
that generates named record types for structs, with schemas that read
from arrays but produce records, and fromArray converters for HyperSync
- codegen_templates.rs: Use struct-aware type conversion, generate aux
type declarations in event modules, update HyperSync converter to
construct records from decoded arrays for struct params
Unnamed tuples (without named components) remain as before.
https://claude.ai/code/session_01VDr9kuWFkdSN5dsCoD9K5P1 parent ff3e6e1 commit 7ca3203
File tree
4 files changed
+535
-32
lines changed- codegenerator/cli/src
- config_parsing
- hbs_templating
4 files changed
+535
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | | - | |
| 17 | + | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
24 | 32 | | |
25 | 33 | | |
26 | 34 | | |
27 | 35 | | |
28 | 36 | | |
29 | | - | |
| 37 | + | |
30 | 38 | | |
31 | 39 | | |
32 | 40 | | |
| |||
35 | 43 | | |
36 | 44 | | |
37 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
38 | 51 | | |
39 | 52 | | |
40 | 53 | | |
41 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
42 | 78 | | |
43 | 79 | | |
44 | 80 | | |
| |||
48 | 84 | | |
49 | 85 | | |
50 | 86 | | |
| 87 | + | |
51 | 88 | | |
52 | 89 | | |
53 | 90 | | |
| |||
125 | 162 | | |
126 | 163 | | |
127 | 164 | | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
128 | 206 | | |
129 | 207 | | |
130 | 208 | | |
| |||
0 commit comments