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

Commit

Permalink
feat: add customize fn
Browse files Browse the repository at this point in the history
  • Loading branch information
kratico committed May 5, 2023
1 parent a8d7b97 commit c1cdf03
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 21 deletions.
1 change: 0 additions & 1 deletion deps/std/collections/deep_merge.ts

This file was deleted.

6 changes: 3 additions & 3 deletions nets/DevNetSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@ export interface DevNetProps {
bin: BinaryResolver
chain: string
nodeCount?: number
genesis?: Record<string, unknown>
customize?: (chainSpec: Record<string, unknown>) => void
}

export abstract class DevNetSpec extends NetSpec {
readonly binary
readonly chain
readonly nodeCount
readonly genesis
readonly customize
constructor(props: DevNetProps) {
super()
this.binary = props.bin
this.chain = props.chain
this.nodeCount = props.nodeCount
this.genesis = props.genesis
this.customize = props.customize
}

abstract relay: DevRelaySpec
Expand Down
4 changes: 1 addition & 3 deletions nets/DevParachainSpec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { deepMerge } from "../deps/std/collections/deep_merge.ts"
import {
addDevUsers,
createCustomChainSpec,
exportParachainGenesis,
getGenesisConfig,
setGenesisConfig,
} from "./chain_spec/mod.ts"
import { DevNetProps, DevNetSpec } from "./DevNetSpec.ts"
import { DevRelaySpec } from "./DevRelaySpec.ts"
Expand Down Expand Up @@ -37,7 +35,7 @@ export class DevParachainSpec extends DevNetSpec {
const genesisConfig = getGenesisConfig(chainSpec)
genesisConfig.parachainInfo && (genesisConfig.parachainInfo.parachainId = this.id)
addDevUsers(genesisConfig)
setGenesisConfig(chainSpec, deepMerge(genesisConfig, this.genesis ?? {}))
this.customize?.(chainSpec)
},
)
const genesis = await exportParachainGenesis(binary, chainSpecPath, signal)
Expand Down
4 changes: 1 addition & 3 deletions nets/DevRelaySpec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { deepMerge } from "../deps/std/collections/deep_merge.ts"
import {
addAuthorities,
addDevUsers,
addXcmHrmpChannels,
createCustomChainSpec,
GenesisConfig,
getGenesisConfig,
setGenesisConfig,
} from "./chain_spec/mod.ts"
import { DevNet, DevNetSpec, spawnDevNet } from "./DevNetSpec.ts"
import { DevParachainProps, DevParachainSpec } from "./DevParachainSpec.ts"
Expand Down Expand Up @@ -50,7 +48,7 @@ export class DevRelaySpec extends DevNetSpec {
}
addAuthorities(genesisConfig, minValidators)
addDevUsers(genesisConfig)
setGenesisConfig(chainSpec, deepMerge(genesisConfig, this.genesis ?? {}))
this.customize?.(chainSpec)
})
}

Expand Down
2 changes: 1 addition & 1 deletion nets/chain_spec/ChainSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface ChainSpec {
genesis: {
runtime: GenesisConfig | { runtime_genesis_config: GenesisConfig }
}
[key: string]: unknown
}

export interface GenesisConfig {
Expand Down Expand Up @@ -37,7 +38,6 @@ export interface GenesisConfig {
maxMessageSize: number,
][]
}
[key: string]: unknown
}

export interface SessionKey {
Expand Down
1 change: 0 additions & 1 deletion nets/chain_spec/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ export * from "./createCustomChainSpec.ts"
export * from "./createRawChainSpec.ts"
export * from "./exportParachainGenesis.ts"
export * from "./getGenesisConfig.ts"
export * from "./setGenesisConfig.ts"
9 changes: 0 additions & 9 deletions nets/chain_spec/setGenesisConfig.ts

This file was deleted.

0 comments on commit c1cdf03

Please sign in to comment.