MCPcopy Create free account
hub / github.com/subquery/subql / normalizeNetworkEndpoints

Function normalizeNetworkEndpoints

packages/common/src/project/utils.ts:282–303  ·  view source on GitHub ↗
(
  input: string | string[] | Record<string, T> | undefined,
  defaultConfig: T
)

Source from the content-addressed store, hash-verified

280 defaultConfig?: T
281): Record<string, T>;
282export function normalizeNetworkEndpoints<T extends IEndpointConfig = IEndpointConfig>(
283 input: string | string[] | Record<string, T> | undefined,
284 defaultConfig: T
285): Record<string, T> | undefined {
286 if (typeof input === 'string') {
287 return {[input]: defaultConfig ?? {}};
288 } else if (Array.isArray(input)) {
289 return input.reduce(
290 (acc, endpoint) => {
291 acc[endpoint] = defaultConfig ?? {};
292 return acc;
293 },
294 {} as Record<string, T>
295 );
296 }
297
298 for (const key in input) {
299 // Yaml can make this null so we ensure it exists
300 input[key] = input[key] ?? {};
301 }
302 return input;
303}
304/* eslint-enable no-redeclare */
305
306export function notifyUpdates(pjson: Package, logger: Pino.Logger): void {

Callers 3

createConnectionsFunction · 0.90
createMethod · 0.90
networkEndpointsMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected