Skip to content

Commit

Permalink
warn on missing chain
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Aug 3, 2023
1 parent 19e74b7 commit 027c4f1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/store-indexer/bin/sqlite-indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { isNotNull } from "@latticexyz/common/utils";

const possibleChains = Object.values({ ...mudChains, ...chains }) as Chain[];

// TODO: refine zod type to be either CHAIN_ID or RPC_HTTP_URL/RPC_WS_URL
const env = z
.object({
CHAIN_ID: z.coerce.number().positive().optional(),
Expand All @@ -33,7 +34,10 @@ const env = z
}),
});

const chain = env.CHAIN_ID ? possibleChains.find((c) => c.id === env.CHAIN_ID) : undefined;
const chain = env.CHAIN_ID != null ? possibleChains.find((c) => c.id === env.CHAIN_ID) : undefined;
if (env.CHAIN_ID != null && !chain) {
console.warn(`No chain found for chain ID ${env.CHAIN_ID}`);
}

const transports: Transport[] = [
env.RPC_WS_URL ? webSocket(env.RPC_WS_URL) : null,
Expand Down

0 comments on commit 027c4f1

Please sign in to comment.