| 71 | |
| 72 | // Family needs to be provided because there can be the same network name in different families. eg Bittensor (Substrate and EVM) |
| 73 | function 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 | |
| 96 | export async function initAdapter( |
| 97 | workingDir: string, |