diff --git a/packages/build-lz-options/src/utilities/prompts.ts b/packages/build-lz-options/src/utilities/prompts.ts index 05b82592b..fd8b2bd5e 100644 --- a/packages/build-lz-options/src/utilities/prompts.ts +++ b/packages/build-lz-options/src/utilities/prompts.ts @@ -35,13 +35,13 @@ const isValidBigInt = (str: string, max: bigint, min: bigint = BigInt(0)): boole * @param {bigint} max defaults to MAX_UINT_128 * @param {bigint} min defaults to BigInt(0) */ -const promptForBigInt = ( - name: string, +const promptForBigInt = ( + name: T, message: string, initial: bigint = DEFAULT_INITIAL_TEXT_NUMBER, max: bigint = MAX_UINT_128, min: bigint = BigInt(0) -): PromptObject => { +): PromptObject => { // wrapper around prompts to handle bigint using string serialization return { onState: handlePromptState, @@ -67,9 +67,9 @@ export const promptForOptionType = () => }, ]) -const promptForGasLimit: PromptObject = promptForBigInt('gasLimit', 'What gas limit do you want to set?') +const promptForGasLimit: PromptObject<'gasLimit'> = promptForBigInt('gasLimit', 'What gas limit do you want to set?') -const promptForNativeDropAmount: PromptObject = promptForBigInt( +const promptForNativeDropAmount: PromptObject<'nativeDropAmount'> = promptForBigInt( 'nativeDropAmount', 'What native gas drop do you want to set?' ) @@ -77,7 +77,7 @@ const promptForNativeDropAmount: PromptObject = promptForBigInt( /** * Prompt for verifier / executor index. */ -const promptForIndex: PromptObject = { +const promptForIndex: PromptObject<'index'> = { onState: handlePromptState, type: 'number', name: 'index', @@ -87,7 +87,7 @@ const promptForIndex: PromptObject = { max: MAX_UINT_8, } -const promptForNativeDropAddress: PromptObject = { +const promptForNativeDropAddress: PromptObject<'nativeDropAddress'> = { onState: handlePromptState, type: 'text', name: 'nativeDropAddress', @@ -136,6 +136,7 @@ const promptExecutorComposeOption = async (options: Options): Promise = promptForGasLimit, promptForNativeDropAmount, ]) + return options.addExecutorComposeOption(index, gasLimit, nativeDropAmount) } @@ -169,17 +170,13 @@ const promptVerifierPrecrimeOption = async (options: Options): Promise /** * Helper function to prompt for OptionType.TYPE_1. */ -export const promptForOptionType1 = () => prompts([promptForGasLimit]) as never as Promise +export const promptForOptionType1 = (): Promise => prompts(promptForGasLimit) /** * Helper function to prompt for OptionType.TYPE_2. */ export const promptForOptionType2 = (): Promise => - prompts([ - promptForGasLimit, - promptForNativeDropAmount, - promptForNativeDropAddress, - ]) as never as Promise + prompts([promptForGasLimit, promptForNativeDropAmount, promptForNativeDropAddress]) const determineWorkerType = async (options: Options): Promise => { const workerType = await promptForWorkerType()