|
2 | 2 | type Address, |
3 | 3 | type Chain, |
4 | 4 | type DecodeFunctionDataReturnType, |
| 5 | + decodeFunctionData, |
5 | 6 | type Hex, |
6 | 7 | hexToString, |
7 | 8 | type PublicClient, |
@@ -156,20 +157,35 @@ export class InstanceManagerContract extends BaseContract<typeof abi> { |
156 | 157 | } |
157 | 158 | } |
158 | 159 |
|
159 | | - // TODO: |
| 160 | + protected override mustParseFunctionData(calldata: Hex): ParsedCall { |
| 161 | + const { functionName, args } = decodeFunctionData({ |
| 162 | + abi: this.abi, |
| 163 | + data: calldata, |
| 164 | + }); |
| 165 | + // Previously bindings contract returned entire ParsedCall in parseFunctionParams |
| 166 | + // So configureGlobal returned flat call with label e.g. "PriceFeedStore via instanceManager" |
| 167 | + // if we keep configureGlobal in parseFunctionParams, it'll return nedsted call |
| 168 | + // interface is unabled to display nested calls nicely, so we have to make exception in mustParseFunctionData |
| 169 | + if (functionName === "configureGlobal") { |
| 170 | + const [target, data] = args; |
| 171 | + const nestedCall = this.register.parseFunctionData(target, data); |
| 172 | + const result = this.wrapParseCall( |
| 173 | + nestedCall.functionName, |
| 174 | + nestedCall.args, |
| 175 | + ); |
| 176 | + return { |
| 177 | + ...result, |
| 178 | + label: `${this.register.labelAddress(target, true)} via ${result.label}`, |
| 179 | + }; |
| 180 | + } |
| 181 | + |
| 182 | + return super.mustParseFunctionData(calldata); |
| 183 | + } |
| 184 | + |
160 | 185 | protected override parseFunctionParams( |
161 | 186 | params: DecodeFunctionDataReturnType<typeof abi>, |
162 | 187 | ): ParsedCallArgs { |
163 | 188 | switch (params.functionName) { |
164 | | - case "configureGlobal": { |
165 | | - const [target, data] = params.args; |
166 | | - const nestedCall = this.register.parseFunctionData(target, data); |
167 | | - return { |
168 | | - ...nestedCall.args, |
169 | | - label: `${nestedCall.label} via instanceManager`, |
170 | | - target: this.address, |
171 | | - }; |
172 | | - } |
173 | 189 | case "configureLocal": { |
174 | 190 | const [target, data] = params.args; |
175 | 191 |
|
|
0 commit comments