Skip to content

Commit

Permalink
fix after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
ermalkaleci committed Apr 18, 2024
1 parent f106758 commit f3fb9e4
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 112 deletions.
3 changes: 2 additions & 1 deletion packages/chopsticks/src/schema/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export const configSchema = z.object({
.object({
genesisBlockHash: zHash,
bootnodes: z.array(z.string()),
}).optional()
})
.optional(),
})

export type Config = z.infer<typeof configSchema>
Expand Down
224 changes: 115 additions & 109 deletions packages/chopsticks/src/schema/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,113 +3,119 @@ import { expect, it } from 'vitest'

it('get yargs options from zod schema', () => {
expect(getYargsOptions(configSchema.shape)).toMatchInlineSnapshot(`
{
"allow-unresolved-imports": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": "boolean",
},
"block": {
"choices": undefined,
"demandOption": false,
"description": "Block hash or block number. Default to latest block",
"type": "string",
},
"build-block-mode": {
"choices": [
"Batch",
"Instant",
"Manual",
],
"demandOption": false,
"description": undefined,
"type": undefined,
},
"db": {
"choices": undefined,
"demandOption": false,
"description": "Path to database",
"type": "string",
},
"endpoint": {
"choices": undefined,
"demandOption": false,
"description": "Endpoint to connect to",
"type": "string",
},
"genesis": {
"choices": undefined,
"demandOption": false,
"description": "URL to genesis config file. NOTE: Only parachains with AURA consensus are supported!",
"type": "string",
},
"import-storage": {
"choices": undefined,
"demandOption": false,
"description": "Pre-defined JSON/YAML storage file path",
"type": undefined,
},
"max-memory-block-count": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": "number",
},
"mock-signature-host": {
"choices": undefined,
"demandOption": false,
"description": "Mock signature host so any signature starts with 0xdeadbeef and filled by 0xcd is considered valid",
"type": "boolean",
},
"offchain-worker": {
"choices": undefined,
"demandOption": false,
"description": "Enable offchain worker",
"type": "boolean",
},
"p2p": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": undefined,
},
"port": {
"choices": undefined,
"demandOption": false,
"description": "Port to listen on",
"type": "number",
},
"registered-types": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": undefined,
},
"resume": {
"choices": undefined,
"demandOption": false,
"description": "Resume from the specified block hash or block number in db. If true, it will resume from the latest block in db. Note this will override the block option",
"type": "string",
},
"runtime-log-level": {
"choices": undefined,
"demandOption": false,
"description": "Runtime maximum log level [off = 0; error = 1; warn = 2; info = 3; debug = 4; trace = 5]",
"type": "number",
},
"timestamp": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": "number",
},
"wasm-override": {
"choices": undefined,
"demandOption": false,
"description": "Path to wasm override",
"type": "string",
},
}
`)
{
"allow-unresolved-imports": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": "boolean",
},
"block": {
"choices": undefined,
"demandOption": false,
"description": "Block hash or block number. Default to latest block",
"type": "string",
},
"build-block-mode": {
"choices": [
"Batch",
"Instant",
"Manual",
],
"demandOption": false,
"description": undefined,
"type": undefined,
},
"db": {
"choices": undefined,
"demandOption": false,
"description": "Path to database",
"type": "string",
},
"endpoint": {
"choices": undefined,
"demandOption": false,
"description": "Endpoint to connect to",
"type": "string",
},
"genesis": {
"choices": undefined,
"demandOption": false,
"description": "URL to genesis config file. NOTE: Only parachains with AURA consensus are supported!",
"type": "string",
},
"import-storage": {
"choices": undefined,
"demandOption": false,
"description": "Pre-defined JSON/YAML storage file path",
"type": undefined,
},
"max-memory-block-count": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": "number",
},
"mock-signature-host": {
"choices": undefined,
"demandOption": false,
"description": "Mock signature host so any signature starts with 0xdeadbeef and filled by 0xcd is considered valid",
"type": "boolean",
},
"offchain-worker": {
"choices": undefined,
"demandOption": false,
"description": "Enable offchain worker",
"type": "boolean",
},
"p2p": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": undefined,
},
"port": {
"choices": undefined,
"demandOption": false,
"description": "Port to listen on",
"type": "number",
},
"process-queued-messages": {
"choices": undefined,
"demandOption": false,
"description": "Produce extra block when queued messages are detected. Default to true. Set to false to disable it.",
"type": "boolean",
},
"registered-types": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": undefined,
},
"resume": {
"choices": undefined,
"demandOption": false,
"description": "Resume from the specified block hash or block number in db. If true, it will resume from the latest block in db. Note this will override the block option",
"type": "string",
},
"runtime-log-level": {
"choices": undefined,
"demandOption": false,
"description": "Runtime maximum log level [off = 0; error = 1; warn = 2; info = 3; debug = 4; trace = 5]",
"type": "number",
},
"timestamp": {
"choices": undefined,
"demandOption": false,
"description": undefined,
"type": "number",
},
"wasm-override": {
"choices": undefined,
"demandOption": false,
"description": "Path to wasm override",
"type": "string",
},
}
`)
})
4 changes: 2 additions & 2 deletions packages/core/src/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ export const processOptions = async (options: SetupOptions) => {
const api = new Api(provider)
await api.isReady

const lightClient = options.p2p && (await LightClient.create(options.p2p))

let blockHash: string
if (options.block == null) {
blockHash = await api.getBlockHash().then((hash) => {
Expand Down Expand Up @@ -122,6 +120,8 @@ export const setup = async (options: SetupOptions) => {
throw new Error(`Cannot find header for ${blockHash}`)
}

const lightClient = options.p2p && (await LightClient.create(options.p2p))

const chain = new Blockchain({
lightClient,
api,
Expand Down

0 comments on commit f3fb9e4

Please sign in to comment.