MCPcopy Index your code
hub / github.com/subquery/subql / findNetwork

Function findNetwork

packages/cli/src/commands/init.ts:73–94  ·  view source on GitHub ↗
(
  templates: Template[],
  network: string,
  family?: string
)

Source from the content-addressed store, hash-verified

71
72// Family needs to be provided because there can be the same network name in different families. eg Bittensor (Substrate and EVM)
73function findNetwork(
74 templates: Template[],
75 network: string,
76 family?: string
77): [Template, Template['networks'][number]] {
78 const selectedFamily = templates.find((f) => {
79 if (family) {
80 return f.name.toLowerCase() === family.toLowerCase();
81 }
82 return !!f.networks.find((n) => n.name.toLowerCase() === network.toLowerCase());
83 });
84 if (!selectedFamily) {
85 throw new Error(`Network ${network} not found in the available templates`);
86 }
87
88 const selectedNetwork = selectedFamily.networks.find((v) => network.toLowerCase() === v.name.toLowerCase());
89 if (!selectedNetwork) {
90 throw new Error(`Network ${network} not found in the available templates`);
91 }
92
93 return [selectedFamily, selectedNetwork];
94}
95
96export async function initAdapter(
97 workingDir: string,

Callers 1

initAdapterFunction · 0.85

Calls 1

findMethod · 0.65

Tested by

no test coverage detected