-
I'm migrating some code from I used import { PromptConfig, input } from "@inquirer/prompts";
import { Address, isAddress, getAddress } from "viem";
/**
* Prompt for an address value.
* @param config inquirer config
* @returns address
*/
export type AddressPromptConfig = PromptConfig<{ default?: Address }>;
export const addressInput = async (
config: AddressPromptConfig,
): Promise<Address> => {
const address = await input({
...config,
validate: (value) => isAddress(value) || "Enter a valid address",
});
return getAddress(address);
}; What is the recommended way of doing this kind of stuff now, without having to write a full blown custom prompt like the procedure described at the @inquirer/core documentation? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi, the To get the input config type, I would recommend going at it this way: type InputConfig = Parameters<typeof input>[0];
export type AddressPromptConfig = InputConfig & { default?: Address }; |
Beta Was this translation helpful? Give feedback.
Hi, the
PromptConfig
just disappeared - it's not used anymore.To get the input config type, I would recommend going at it this way: