diff --git a/devnets/startNetwork.ts b/devnets/startNetwork.ts index 8051f5b06..281e4792b 100644 --- a/devnets/startNetwork.ts +++ b/devnets/startNetwork.ts @@ -17,6 +17,59 @@ export interface NetworkChain { ports: number[] } +export async function startNetworkForMetadata( + tempDir: string, + config: NetworkConfig, + signal: AbortSignal, +): Promise { + const relayBinary = await resolveBinary(config.binary, signal) + const relaySpec = await createCustomChainSpec( + path.join(tempDir, "relay"), + relayBinary, + config.chain, + () => {}, + ) + return { + relay: await spawnChain( + path.join(tempDir, "relay"), + relayBinary, + relaySpec, + 1, + [], + relayBinary, + signal, + ), + paras: Object.fromEntries( + await Promise.all( + Object.entries(config.parachains ?? {}).map(async ([name, config]) => { + const binary = await resolveBinary(config.binary, signal) + const chain = await spawnChain( + path.join(tempDir, name), + binary, + await createCustomChainSpec( + path.join(tempDir, name), + binary, + config.chain, + () => {}, + ), + 1, + [ + "--", + "--execution", + "wasm", + "--chain", + relaySpec, + ], + relayBinary, + signal, + ) + return [name, chain] satisfies Narrow + }), + ), + ), + } +} + export async function startNetwork( tempDir: string, config: NetworkConfig, diff --git a/devnets/syncConfig.ts b/devnets/syncConfig.ts index 728843a1f..212cc1f57 100644 --- a/devnets/syncConfig.ts +++ b/devnets/syncConfig.ts @@ -8,7 +8,7 @@ import { $codegenSpec, CodegenEntry, CodegenSpec } from "../server/codegenSpec.t import { normalizePackageName, withSignal } from "../util/mod.ts" import { normalizeTypeName } from "../util/normalize.ts" import { CapiConfig } from "./CapiConfig.ts" -import { startNetwork } from "./startNetwork.ts" +import { startNetworkForMetadata } from "./startNetwork.ts" export async function syncConfig(tempDir: string, config: CapiConfig) { return withSignal(async (signal) => { @@ -26,7 +26,7 @@ export async function syncConfig(tempDir: string, config: CapiConfig) { }) return } - const network = await startNetwork(path.join(tempDir, name), chain, signal) + const network = await startNetworkForMetadata(path.join(tempDir, name), chain, signal) await Promise.all( [ [undefined, network.relay] as const,