diff --git a/src/utils/ProviderUtils.ts b/src/utils/ProviderUtils.ts index 4808790e8..fe71750cf 100644 --- a/src/utils/ProviderUtils.ts +++ b/src/utils/ProviderUtils.ts @@ -569,12 +569,13 @@ export async function getProvider(chainId: number, logger?: winston.Logger, useC return provider; } -export function getNodeUrlList(chainId: number, quorum: number): string[] { +export function getNodeUrlList(chainId: number, quorum = 1): string[] { const resolveUrls = (): string[] => { const providers = process.env[`RPC_PROVIDERS_${chainId}`] ?? process.env["RPC_PROVIDERS"]; if (providers === undefined) { throw new Error(`No RPC providers defined for chainId ${chainId}`); } + const nodeUrls = providers.split(",").map((provider) => { const envVar = `RPC_PROVIDER_${provider}_${chainId}`; const url = process.env[envVar]; @@ -591,29 +592,8 @@ export function getNodeUrlList(chainId: number, quorum: number): string[] { return nodeUrls; }; - const retryConfigKey = `NODE_URLS_${chainId}`; - const nodeUrlKey = `NODE_URL_${chainId}`; - let nodeUrls: string[] = []; - - try { - nodeUrls = resolveUrls(); - } catch { - // Fallback to existing config scheme. - if (process.env[retryConfigKey]) { - nodeUrls = JSON.parse(process.env[retryConfigKey]) || []; - if (nodeUrls?.length === 0) { - throw new Error(`Provided ${retryConfigKey}, but parsing it as json did not result in an array of urls.`); - } - } else { - if (process.env[nodeUrlKey]) { - nodeUrls = [process.env[nodeUrlKey]]; - } - } - } - - if (nodeUrls.length === 0) { - throw new Error(`Can't get ${chainId} node url(s) because neither ${retryConfigKey} or ${nodeUrlKey} are defined.`); - } else if (nodeUrls.length < quorum) { + const nodeUrls = resolveUrls(); + if (nodeUrls.length < quorum) { throw new Error(`Insufficient RPC providers for chainId ${chainId} to meet quorum (minimum ${quorum} required)`); } diff --git a/src/utils/SignerUtils.ts b/src/utils/SignerUtils.ts index 8ff77d1ed..530b84841 100644 --- a/src/utils/SignerUtils.ts +++ b/src/utils/SignerUtils.ts @@ -8,7 +8,7 @@ export type SignerOptions = { * The type of wallet to use. * @note If using a GCKMS wallet, the gckmsKeys parameter must be set. */ - keyType: "mnemonic" | "privateKey" | "gckms"; + keyType: string; /** * Whether or not to clear the mnemonic/private key from the env after retrieving the signer. * @note Not including this parameter or setting it to false will not clear the mnemonic/private key from the env. @@ -42,7 +42,7 @@ export async function getSigner({ keyType, gckmsKeys, cleanEnv }: SignerOptions) wallet = await getGckmsSigner(gckmsKeys); break; default: - throw new Error("Must define mnemonic, privatekey or gckms for wallet"); + throw new Error(`getSigner: Unsupported key type (${keyType})`); } if (!wallet) { throw new Error("Must define mnemonic, privatekey or gckms for wallet");