diff --git a/.changeset/nice-wombats-destroy.md b/.changeset/nice-wombats-destroy.md new file mode 100644 index 0000000000..dc4d2c2538 --- /dev/null +++ b/.changeset/nice-wombats-destroy.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/explorer": patch +--- + +Fixed calls to system view functions. diff --git a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/interact/content/FunctionField.tsx b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/interact/content/FunctionField.tsx index e3968ea7c9..62873280a4 100644 --- a/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/interact/content/FunctionField.tsx +++ b/packages/explorer/src/app/(explorer)/[chainName]/worlds/[worldAddress]/interact/content/FunctionField.tsx @@ -148,15 +148,37 @@ export function FunctionField({ systemId, worldAbi, functionAbi, useSearchParams try { if (operationType === FunctionType.READ) { - const { data: result } = await publicClient.call({ - account: account.address, - data: encodeFunctionData({ - abi: [...worldAbi, functionAbi], + let result; + if (systemId) { + const encoded = encodeSystemCall({ + abi: [functionAbi], functionName: functionAbi.name, args: encodeFunctionArgs(resolvedInputs, functionAbi), - }), - to: worldAddress as Address, - }); + systemId, + }); + + const { data } = await publicClient.call({ + account: account.address, + data: encodeFunctionData({ + abi: [...worldAbi, functionAbi], + functionName: "call", + args: encoded, + }), + to: worldAddress as Address, + }); + result = data; + } else { + const { data } = await publicClient.call({ + account: account.address, + data: encodeFunctionData({ + abi: [...worldAbi, functionAbi], + functionName: functionAbi.name, + args: encodeFunctionArgs(resolvedInputs, functionAbi), + }), + to: worldAddress as Address, + }); + result = data; + } setResult(stringify(result, null, 2).replace(/^"|"$/g, "")); } else {