Skip to content

Commit

Permalink
handle network error during fetching chain id
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSulpiride committed Sep 21, 2023
1 parent e416c6e commit e17ab9d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions packages/cli/src/cmds/node/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ export async function nodeHandler(args: IGlobalArgs): Promise<void> {
redirectRpc: params.redirectRpc,
});
} catch (err) {
if (err instanceof Error && err.message.indexOf("chain id") > -1) {
logger.error(err.message);
return;
}
logger.info("Config file not found. Proceeding with env vars...");
config = await Config.init({
networks: {},
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/cmds/standalone/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ export async function bundlerHandler(
redirectRpc,
});
} catch (err) {
if (err instanceof Error && err.message.indexOf("chain id") > -1) {
logger.error(err.message);
return;
}
logger.debug("Config file not found. Proceeding with env vars...");
config = await Config.init({
networks: {},
Expand Down
8 changes: 6 additions & 2 deletions packages/executor/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,12 @@ export class Config {
if (!provider) {
throw new Error(`No provider for ${networkName}`);
}
const network = await provider.getNetwork();
this.supportedNetworks[networkName] = network.chainId;
try {
const network = await provider.getNetwork();
this.supportedNetworks[networkName] = network.chainId;
} catch (err) {
throw new Error(`Could not fetch chain id for ${networkName}`);
}
}
}

Expand Down

0 comments on commit e17ab9d

Please sign in to comment.