Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
feat: add startNetworkForMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
kratico committed Apr 18, 2023
1 parent 0f16b8c commit e33ae91
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 2 deletions.
53 changes: 53 additions & 0 deletions devnets/startNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,59 @@ export interface NetworkChain {
ports: number[]
}

export async function startNetworkForMetadata(
tempDir: string,
config: NetworkConfig,
signal: AbortSignal,
): Promise<Network> {
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,
Expand Down
4 changes: 2 additions & 2 deletions devnets/syncConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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,
Expand Down

0 comments on commit e33ae91

Please sign in to comment.