Skip to content

Commit c1a5b94

Browse files
committed
fix: weird InstanceManager.configureGlobal backport
1 parent e615d6f commit c1a5b94

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

src/permissionless/bindings/instance-manager.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
type Address,
33
type Chain,
44
type DecodeFunctionDataReturnType,
5+
decodeFunctionData,
56
type Hex,
67
hexToString,
78
type PublicClient,
@@ -156,20 +157,35 @@ export class InstanceManagerContract extends BaseContract<typeof abi> {
156157
}
157158
}
158159

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+
160185
protected override parseFunctionParams(
161186
params: DecodeFunctionDataReturnType<typeof abi>,
162187
): ParsedCallArgs {
163188
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-
}
173189
case "configureLocal": {
174190
const [target, data] = params.args;
175191

0 commit comments

Comments
 (0)