Skip to content

Commit 2be543f

Browse files
authored
fix(explorer): switch to fetchBlockLogs (#3352)
1 parent 722f4b4 commit 2be543f

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@latticexyz/explorer": patch
3+
---
4+
5+
Fixed world ABI fetching in Rhodolite.

packages/explorer/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
},
3737
"dependencies": {
3838
"@hookform/resolvers": "^3.9.0",
39+
"@latticexyz/block-logs-stream": "workspace:*",
3940
"@latticexyz/common": "workspace:*",
4041
"@latticexyz/config": "workspace:*",
4142
"@latticexyz/protocol-parser": "workspace:*",

packages/explorer/src/app/(explorer)/api/world-abi/route.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Address, Hex, createWalletClient, http, parseAbi } from "viem";
2-
import { getBlockNumber, getLogs } from "viem/actions";
2+
import { getBlockNumber } from "viem/actions";
3+
import { fetchBlockLogs } from "@latticexyz/block-logs-stream";
34
import { helloStoreEvent } from "@latticexyz/store";
45
import { helloWorldEvent } from "@latticexyz/world";
56
import { getWorldAbi } from "@latticexyz/world/internal";
@@ -20,16 +21,18 @@ async function getClient(chainId: supportedChainId) {
2021
async function getParameters(chainId: supportedChainId, worldAddress: Address) {
2122
const client = await getClient(chainId);
2223
const toBlock = await getBlockNumber(client);
23-
const logs = await getLogs(client, {
24-
strict: true,
24+
const logs = await fetchBlockLogs({
25+
fromBlock: 0n,
26+
toBlock,
27+
maxBlockRange: 100_000n,
28+
publicClient: client,
2529
address: worldAddress,
2630
events: parseAbi([helloStoreEvent, helloWorldEvent] as const),
27-
fromBlock: "earliest",
28-
toBlock,
2931
});
32+
3033
const fromBlock = logs[0]?.blockNumber ?? 0n;
3134
// world is considered loaded when both events are emitted
32-
const isWorldDeployed = logs.length === 2;
35+
const isWorldDeployed = logs[0]?.logs.length === 2;
3336

3437
return { fromBlock, toBlock, isWorldDeployed };
3538
}

pnpm-lock.yaml

Lines changed: 6 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)