@@ -98,7 +98,7 @@ The `mapping` field may be one of the following supported mapping manifests:
98
98
99
99
### 1.5.3 Declaring calls
100
100
101
- _ Available from spec version 1.2.0_
101
+ _ Available from spec version 1.2.0. Struct field access available from spec version 1.4. 0_
102
102
103
103
Declared calls are performed in parallel before the handler is run and can
104
104
greatly speed up syncing. Mappings access the call results simply by using
@@ -122,76 +122,12 @@ Each call is of the form `<ABI>[<address>].<function>(<args>)`:
122
122
123
123
The ` Expr ` can be one of the following:
124
124
125
- | Expression | Description | Example |
126
- | --- | --- | --- |
127
- | ** event.address** | The address of the contract that emitted the event | ` event.address ` |
128
- | ** event.params.< ; name> ; ** | A simple parameter from the event | ` event.params.token ` |
129
- | ** event.params.< ; name> ; .< ; index> ; ** | A field from a struct parameter by numeric index | ` event.params.asset.0 ` |
130
- | ** event.params.< ; name> ; .< ; fieldName> ; ** | A field from a struct parameter by field name | ` event.params.asset.addr ` |
131
- | ** Nested struct access** | Arbitrary nesting depth with mixed access patterns | ` event.params.data.1.user.id ` |
132
-
133
- #### Struct Field Access
134
-
135
- When event parameters contain struct types (tuples in ABI), you can access individual fields using either numeric indices or field names:
136
-
137
- ** Numeric Access (Traditional):**
138
- ``` yaml
139
- calls :
140
- tokenAddress : ERC20[event.params.asset.0].name() # First field
141
- tokenAmount : ERC20[event.params.asset.1].decimals() # Second field
142
- ` ` `
143
-
144
- **Named Access (Recommended):**
145
- ` ` ` yaml
146
- calls :
147
- tokenAddress : ERC20[event.params.asset.addr].name() # By field name
148
- tokenAmount : ERC20[event.params.asset.amount].decimals() # By field name
149
- ` ` `
150
-
151
- **Mixed Access Patterns:**
152
- ` ` ` yaml
153
- calls :
154
- # Access first transfer, then recipient field by name
155
- recipient : Token[event.params.transfers.0.recipient].balanceOf()
156
-
157
- # Deep nesting with mixed numeric and named access
158
- innerValue : Contract[event.params.data.1.user.addr].someFunction()
159
- ` ` `
160
-
161
- #### Struct Field Access Examples
162
-
163
- Given an event with this ABI structure:
164
- ` ` ` json
165
- {
166
- " name " : " AssetTransfer" ,
167
- " type " : " event" ,
168
- " inputs " : [
169
- {
170
- " name " : " asset" ,
171
- " type " : " tuple" ,
172
- " components " : [
173
- {"name": "addr", "type": "address"},
174
- {"name": "amount", "type": "uint256"},
175
- {"name": "active", "type": "bool"}
176
- ]
177
- }
178
- ]
179
- }
180
- ```
181
-
182
- You can access fields in multiple ways:
183
- ``` yaml
184
- calls :
185
- # Named field access (clearest and recommended)
186
- tokenContract : ERC20[event.params.asset.addr].name()
187
- tokenDecimals : ERC20[event.params.asset.addr].decimals()
188
-
189
- # Numeric field access (backward compatible)
190
- tokenContract : ERC20[event.params.asset.0].name()
191
-
192
- # Mixed access for complex nested structures
193
- nestedField : Contract[event.params.data.0.inner.fieldName].process()
194
- ` ` `
125
+ | Expression | Description |
126
+ | --- | --- |
127
+ | ** event.address** | The address of the contract that emitted the event |
128
+ | ** event.params.< ; name> ; ** | A simple parameter from the event |
129
+ | ** event.params.< ; name> ; .< ; index> ; ** | A field from a struct parameter by numeric index |
130
+ | ** event.params.< ; name> ; .< ; fieldName> ; ** | A field from a struct parameter by field name (spec version 1.4.0+) |
195
131
196
132
197
133
## 1.6 Path
0 commit comments