From d09a6ff897daefae434b3b19b6d11cd0f07112c2 Mon Sep 17 00:00:00 2001 From: Xiliang Chen Date: Sat, 23 Dec 2023 20:11:04 +1300 Subject: [PATCH] fix run block (#603) * fix run block * fix * fmt --- packages/chopsticks/src/schema/index.ts | 4 ++-- packages/chopsticks/src/schema/options.test.ts | 4 ++-- packages/core/src/logger.ts | 4 +++- packages/core/src/setup.ts | 2 ++ 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/chopsticks/src/schema/index.ts b/packages/chopsticks/src/schema/index.ts index d6436128..4e52fa4f 100644 --- a/packages/chopsticks/src/schema/index.ts +++ b/packages/chopsticks/src/schema/index.ts @@ -61,8 +61,8 @@ const getZodType = (option: ZodTypeAny) => { default: break } - if (option._def.innerType) { - return getZodType(option._def.innerType) + if (option._def.innerType ?? option._def.left) { + return getZodType(option._def.innerType ?? option._def.left) } return undefined } diff --git a/packages/chopsticks/src/schema/options.test.ts b/packages/chopsticks/src/schema/options.test.ts index 016faa01..0f47fe5a 100644 --- a/packages/chopsticks/src/schema/options.test.ts +++ b/packages/chopsticks/src/schema/options.test.ts @@ -14,7 +14,7 @@ it('get yargs options from zod schema', () => { "choices": undefined, "demandOption": false, "description": "Block hash or block number. Default to latest block", - "type": "number", + "type": "string", }, "build-block-mode": { "choices": [ @@ -84,7 +84,7 @@ it('get yargs options from zod schema', () => { "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": "number", + "type": "string", }, "runtime-log-level": { "choices": undefined, diff --git a/packages/core/src/logger.ts b/packages/core/src/logger.ts index b8a1f0c4..0f852902 100644 --- a/packages/core/src/logger.ts +++ b/packages/core/src/logger.ts @@ -1,12 +1,14 @@ import { pino } from 'pino' -export const defaultLogger = pino({ +export const pinoLogger = pino({ level: (typeof process === 'object' && process.env.LOG_LEVEL) || 'info', transport: { target: 'pino-pretty', }, }) +export const defaultLogger = pinoLogger.child({ app: 'chopsticks' }) + const innerTruncate = (level = 0) => (val: any) => { diff --git a/packages/core/src/setup.ts b/packages/core/src/setup.ts index b24ffb45..7ed8be56 100644 --- a/packages/core/src/setup.ts +++ b/packages/core/src/setup.ts @@ -34,6 +34,8 @@ export type SetupOptions = { } export const setup = async (options: SetupOptions) => { + defaultLogger.debug(options, 'Setup options') + let provider: ProviderInterface if (options.genesis) { provider = options.genesis