Skip to content

Commit

Permalink
fix config initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
0xSulpiride committed Sep 19, 2023
1 parent bb9f371 commit 0ab20c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src/cmds/node/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ export async function nodeHandler(args: IGlobalArgs): Promise<void> {
let config: Config;
try {
const configOptions = readFile(params.configFile) as ConfigOptions;
config = new Config({
config = await Config.init({
networks: configOptions.networks,
testingMode: params.testingMode,
unsafeMode: params.unsafeMode,
redirectRpc: params.redirectRpc,
});
} catch (err) {
logger.info("Config file not found. Proceeding with env vars...");
config = new Config({
config = await Config.init({
networks: {},
testingMode: false,
unsafeMode: false,
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/cmds/standalone/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ export async function bundlerHandler(
let config: Config;
try {
const configOptions = readFile(configFile) as ConfigOptions;
config = new Config({
config = await Config.init({
networks: configOptions.networks,
testingMode,
unsafeMode,
redirectRpc,
});
} catch (err) {
logger.debug("Config file not found. Proceeding with env vars...");
config = new Config({
config = await Config.init({
networks: {},
testingMode,
unsafeMode,
Expand Down
6 changes: 6 additions & 0 deletions packages/executor/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export class Config {
this.networks = this.parseNetworkConfigs();
}

static async init(configOptions: ConfigOptions): Promise<Config> {
const config = new Config(configOptions);
await config.fetchChainIds();
return config;
}

getNetworkProvider(network: string): providers.JsonRpcProvider | null {
const conf = this.networks[network];
const endpoint = conf?.rpcEndpoint;
Expand Down

0 comments on commit 0ab20c8

Please sign in to comment.