diff --git a/.changeset/lemon-apples-march.md b/.changeset/lemon-apples-march.md new file mode 100644 index 0000000000..e694ed7ac5 --- /dev/null +++ b/.changeset/lemon-apples-march.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/store-sync": patch +--- + +Updated `createStoreSync` to default to the chain's indexer URL when no `indexerUrl` is passed in. To intentionally unset the value and not use the indexer at all, `indexerUrl` can now also be `false`. diff --git a/.changeset/rotten-rules-switch.md b/.changeset/rotten-rules-switch.md new file mode 100644 index 0000000000..c80e7d88bc --- /dev/null +++ b/.changeset/rotten-rules-switch.md @@ -0,0 +1,5 @@ +--- +"@latticexyz/common": patch +--- + +Added an optional `indexerUrl` property to `MUDChain`, and populated it in the Redstone and Garnet chain configs. diff --git a/packages/common/src/chains/garnet.ts b/packages/common/src/chains/garnet.ts index aaf958668f..1a09725a91 100644 --- a/packages/common/src/chains/garnet.ts +++ b/packages/common/src/chains/garnet.ts @@ -22,6 +22,7 @@ export const garnet = { url: "https://explorer.garnetchain.com", }, }, + indexerUrl: "https://indexer.mud.garnetchain.com", contracts: { multicall3: { address: "0xca11bde05977b3631167028862be2a173976ca11", diff --git a/packages/common/src/chains/redstone.ts b/packages/common/src/chains/redstone.ts index bc56719612..6581b0362a 100644 --- a/packages/common/src/chains/redstone.ts +++ b/packages/common/src/chains/redstone.ts @@ -21,6 +21,7 @@ export const redstone = { url: "https://explorer.redstone.xyz", }, }, + indexerUrl: "https://indexer.mud.redstonechain.com", contracts: { multicall3: { address: "0xca11bde05977b3631167028862be2a173976ca11", diff --git a/packages/common/src/chains/types.ts b/packages/common/src/chains/types.ts index e3e5376777..fcadfb423c 100644 --- a/packages/common/src/chains/types.ts +++ b/packages/common/src/chains/types.ts @@ -1,5 +1,6 @@ import type { Chain } from "viem/chains"; export type MUDChain = Chain & { + indexerUrl?: string; faucetUrl?: string; }; diff --git a/packages/store-sync/src/common.ts b/packages/store-sync/src/common.ts index 72ccd53248..6d9c2a0eb8 100644 --- a/packages/store-sync/src/common.ts +++ b/packages/store-sync/src/common.ts @@ -95,7 +95,7 @@ export type SyncOptions = { /** * Optional MUD tRPC indexer URL to fetch initial state from. */ - indexerUrl?: string; + indexerUrl?: string | false; /** * Optional initial state to hydrate from. Useful if you're hydrating from an indexer or cache. * @deprecated Use `initialLogs` option instead. diff --git a/packages/store-sync/src/createStoreSync.ts b/packages/store-sync/src/createStoreSync.ts index c14f6e68fa..a359d8d813 100644 --- a/packages/store-sync/src/createStoreSync.ts +++ b/packages/store-sync/src/createStoreSync.ts @@ -96,7 +96,15 @@ export async function createStoreSync( filters, initialState, initialBlockLogs, - indexerUrl, + indexerUrl: + indexerUrl !== false + ? indexerUrl ?? + (publicClient.chain && + "indexerUrl" in publicClient.chain && + typeof publicClient.chain.indexerUrl === "string" + ? publicClient.chain.indexerUrl + : undefined) + : undefined, }); onProgress?.({