Skip to content

Commit e9e21c9

Browse files
authored
fix(explorer): handle invalid system abis (#3786)
1 parent ba07cf0 commit e9e21c9

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

.changeset/soft-bats-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/store-sync": patch
3+
---
4+
5+
Invalid registered system ABIs are now handled by displaying an empty ABI.

packages/store-sync/src/world/getSystemAbis.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Client, Abi, Address, Hex, hexToString, parseAbi, stringToHex, toFuncti
22
import metadataConfig from "@latticexyz/world-module-metadata/mud.config";
33
import { getRecords } from "../getRecords";
44
import { getFunctions } from "./getFunctions";
5-
import { groupBy } from "@latticexyz/common/utils";
5+
import { groupBy, isNotNull } from "@latticexyz/common/utils";
66
import { functionSignatureToAbiItem } from "./functionSignatureToAbiItem";
77
import { hexToResource } from "@latticexyz/common";
88
import { isAbiFunction } from "./common";
@@ -52,9 +52,15 @@ export async function getSystemAbis({
5252
return isAbiTag && matchesSystemId;
5353
})
5454
.map(({ resource, value }) => {
55-
const abi = value === "0x" ? [] : parseAbi(hexToString(value).split("\n"));
56-
return [resource, abi] as const;
57-
}),
55+
try {
56+
const abi = value === "0x" ? [] : parseAbi(hexToString(value).split("\n"));
57+
return [resource, abi] as const;
58+
} catch (error) {
59+
console.error("error parsing system abi", error);
60+
return [resource, []] as const;
61+
}
62+
})
63+
.filter(isNotNull),
5864
);
5965

6066
const systemFunctions = Object.fromEntries(

0 commit comments

Comments
 (0)