import { Artifacts } from "./artifacts"; import { HardhatConfig, HardhatUserConfig, NetworkConfig } from "./config"; import { EthereumProvider } from "./provider"; /** * This class is used to dynamically validate task's argument types. */ export interface ArgumentType { /** * The type's name. */ name: string; /** * Check if argument value is of type . * * @param argName {string} argument's name - used for context in case of error. * @param argumentValue - value to be validated * * @throws HH301 if value is not of type */ validate(argName: string, argumentValue: any): void; } /** * This is a special case of ArgumentType. * * These types must have a human-friendly string representation, so that they * can be used as command line arguments. */ export interface CLIArgumentType extends ArgumentType { /** * Parses strValue into T. This function MUST throw HH301 if it * can parse the given value. * * @param argName argument's name - used for context in case of error. * @param strValue argument's string value to be parsed. */ parse(argName: string, strValue: string): T; } export interface ConfigurableTaskDefinition { setDescription(description: string): this; setAction(action: ActionType): this; addParam(name: string, description?: string, defaultValue?: T, type?: ArgumentType, isOptional?: boolean): this; addOptionalParam(name: string, description?: string, defaultValue?: T, type?: ArgumentType): this; addPositionalParam(name: string, description?: string, defaultValue?: T, type?: ArgumentType, isOptional?: boolean): this; addOptionalPositionalParam(name: string, description?: string, defaultValue?: T, type?: ArgumentType): this; addVariadicPositionalParam(name: string, description?: string, defaultValue?: T[], type?: ArgumentType, isOptional?: boolean): this; addOptionalVariadicPositionalParam(name: string, description?: string, defaultValue?: T[], type?: ArgumentType): this; addFlag(name: string, description?: string): this; } export interface ParamDefinition { name: string; defaultValue?: T; type: ArgumentType; description?: string; isOptional: boolean; isFlag: boolean; isVariadic: boolean; } export interface OptionalParamDefinition extends ParamDefinition { defaultValue: T; isOptional: true; } export interface CLIOptionalParamDefinition extends OptionalParamDefinition { type: CLIArgumentType; } export interface ParamDefinitionsMap { [paramName: string]: ParamDefinition; } export interface TaskDefinition extends ConfigurableTaskDefinition { readonly name: string; readonly description?: string; readonly action: ActionType; readonly isSubtask: boolean; readonly paramDefinitions: ParamDefinitionsMap; readonly positionalParamDefinitions: Array>; } /** * @type TaskArguments {object-like} - the input arguments for a task. * * TaskArguments type is set to 'any' because it's interface is dynamic. * It's impossible in TypeScript to statically specify a variadic * number of fields and at the same time define specific types for\ * the argument values. * * For example, we could define: * type TaskArguments = Record; * * ...but then, we couldn't narrow the actual argument value's type in compile time, * thus we have no other option than forcing it to be just 'any'. */ export declare type TaskArguments = any; export interface RunSuperFunction { (taskArguments?: ArgT): Promise; isDefined: boolean; } export declare type ActionType = (taskArgs: ArgsT, env: HardhatRuntimeEnvironment, runSuper: RunSuperFunction) => Promise; export interface HardhatArguments { network?: string; showStackTraces: boolean; version: boolean; help: boolean; emoji: boolean; config?: string; verbose: boolean; maxMemory?: number; tsconfig?: string; } export declare type HardhatParamDefinitions = { [param in keyof Required]: CLIOptionalParamDefinition; }; export interface TasksMap { [name: string]: TaskDefinition; } export declare type RunTaskFunction = (name: string, taskArguments?: TaskArguments) => Promise; export interface HardhatRuntimeEnvironment { readonly config: HardhatConfig; readonly userConfig: HardhatUserConfig; readonly hardhatArguments: HardhatArguments; readonly tasks: TasksMap; readonly run: RunTaskFunction; readonly network: Network; readonly artifacts: Artifacts; } export interface Network { name: string; config: NetworkConfig; provider: EthereumProvider; } /** * A function that receives a HardhatRuntimeEnvironment and * modify its properties or add new ones. */ export declare type EnvironmentExtender = (env: HardhatRuntimeEnvironment) => void; //# sourceMappingURL=runtime.d.ts.map