Skip to content

Commit

Permalink
add fallback for web3 json-rpc...
Browse files Browse the repository at this point in the history
  • Loading branch information
Jagden committed Dec 16, 2024
1 parent ac4ab46 commit 61d7b15
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cli-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import * as Logger from './logger';

import { setConfigEnvVars } from './env-var-args';

function ensureEthereumEndpointIsArray(obj: ServiceConfiguration): void {
if (!obj.EthereumEndpoint) {
obj.EthereumEndpoint = []; // Initialize as an empty array if the field is undefined or null
} else if (!Array.isArray(obj.EthereumEndpoint)) {
obj.EthereumEndpoint = [obj.EthereumEndpoint]; // Convert to array if it's not already one
}
}

export function parseArgs(argv: string[]): ServiceConfiguration {
const options = yargs(argv)
.option('config', {
Expand All @@ -28,6 +36,8 @@ export function parseArgs(argv: string[]): ServiceConfiguration {
// Support passing required config values via environment variables
setConfigEnvVars(config);

ensureEthereumEndpointIsArray(config);

const validationErrors = validateServiceConfiguration(config);
if (validationErrors) {
Logger.error(`Invalid JSON config: '${JSON.stringify(config)}'.`);
Expand Down

0 comments on commit 61d7b15

Please sign in to comment.