UNPKG

8.2 kBTypeScriptView Raw
1/// <reference types="mocha" />
2/// <reference types="node" />
3import { EventEmitter } from "events";
4import { DeepPartial, DeepReadonly, Omit } from "ts-essentials";
5import { MessageTrace } from "./internal/buidler-evm/stack-traces/message-trace";
6import * as types from "./internal/core/params/argumentTypes";
7export interface CommonNetworkConfig {
8 chainId?: number;
9 from?: string;
10 gas?: "auto" | number;
11 gasPrice?: "auto" | number;
12 gasMultiplier?: number;
13}
14export interface BuidlerNetworkAccount {
15 privateKey: string;
16 balance: string;
17}
18export interface BuidlerNetworkConfig extends CommonNetworkConfig {
19 accounts?: BuidlerNetworkAccount[];
20 blockGasLimit?: number;
21 hardfork?: string;
22 throwOnTransactionFailures?: boolean;
23 throwOnCallFailures?: boolean;
24 loggingEnabled?: boolean;
25 allowUnlimitedContractSize?: boolean;
26 initialDate?: string;
27}
28export interface HDAccountsConfig {
29 mnemonic: string;
30 initialIndex?: number;
31 count?: number;
32 path?: string;
33}
34export interface OtherAccountsConfig {
35 type: string;
36}
37export declare type NetworkConfigAccounts = "remote" | string[] | HDAccountsConfig | OtherAccountsConfig;
38export interface HttpNetworkConfig extends CommonNetworkConfig {
39 url?: string;
40 timeout?: number;
41 httpHeaders?: {
42 [name: string]: string;
43 };
44 accounts?: NetworkConfigAccounts;
45}
46export declare type NetworkConfig = BuidlerNetworkConfig | HttpNetworkConfig;
47export interface Networks {
48 [networkName: string]: NetworkConfig;
49}
50/**
51 * The project paths:
52 * * root: the project's root.
53 * * configFile: the buidler's config filepath.
54 * * cache: project's cache directory.
55 * * artifacts: artifact's directory.
56 * * sources: project's sources directory.
57 * * tests: project's tests directory.
58 */
59export interface ProjectPaths {
60 root: string;
61 configFile: string;
62 cache: string;
63 artifacts: string;
64 sources: string;
65 tests: string;
66}
67declare type EVMVersion = string;
68export interface SolcConfig {
69 version: string;
70 optimizer: SolcOptimizerConfig;
71 evmVersion?: EVMVersion;
72}
73export interface SolcOptimizerConfig {
74 enabled: boolean;
75 runs: number;
76}
77export interface AnalyticsConfig {
78 enabled: boolean;
79}
80export interface BuidlerConfig {
81 defaultNetwork?: string;
82 networks?: Networks;
83 paths?: Omit<Partial<ProjectPaths>, "configFile">;
84 solc?: DeepPartial<SolcConfig>;
85 mocha?: Mocha.MochaOptions;
86 analytics?: Partial<AnalyticsConfig>;
87}
88export interface ResolvedBuidlerConfig extends BuidlerConfig {
89 defaultNetwork: string;
90 paths: ProjectPaths;
91 networks: Networks;
92 solc: SolcConfig;
93 analytics: AnalyticsConfig;
94}
95export interface SolcInput {
96 settings: {
97 metadata: {
98 useLiteralContent: boolean;
99 };
100 optimizer: SolcOptimizerConfig;
101 outputSelection: {
102 "*": {
103 "": string[];
104 "*": string[];
105 };
106 };
107 evmVersion?: string;
108 };
109 sources: {
110 [p: string]: {
111 content: string;
112 };
113 };
114 language: string;
115}
116/**
117 * A function that receives a BuidlerRuntimeEnvironment and
118 * modify its properties or add new ones.
119 */
120export declare type EnvironmentExtender = (env: BuidlerRuntimeEnvironment) => void;
121export declare type ConfigExtender = (config: ResolvedBuidlerConfig, userConfig: DeepReadonly<BuidlerConfig>) => void;
122export declare type ExperimentalBuidlerEVMMessageTraceHook = (bre: BuidlerRuntimeEnvironment, trace: MessageTrace, isMessageTraceFromACall: boolean) => Promise<void>;
123export declare type BoundExperimentalBuidlerEVMMessageTraceHook = (trace: MessageTrace, isMessageTraceFromACall: boolean) => Promise<void>;
124export interface TasksMap {
125 [name: string]: TaskDefinition;
126}
127export interface ConfigurableTaskDefinition {
128 setDescription(description: string): this;
129 setAction(action: ActionType<TaskArguments>): this;
130 addParam<T>(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType<T>, isOptional?: boolean): this;
131 addOptionalParam<T>(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType<T>): this;
132 addPositionalParam<T>(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType<T>, isOptional?: boolean): this;
133 addOptionalPositionalParam<T>(name: string, description?: string, defaultValue?: T, type?: types.ArgumentType<T>): this;
134 addVariadicPositionalParam<T>(name: string, description?: string, defaultValue?: T[], type?: types.ArgumentType<T>, isOptional?: boolean): this;
135 addOptionalVariadicPositionalParam<T>(name: string, description?: string, defaultValue?: T[], type?: types.ArgumentType<T>): this;
136 addFlag(name: string, description?: string): this;
137}
138export interface ParamDefinition<T> {
139 name: string;
140 defaultValue?: T;
141 type: types.ArgumentType<T>;
142 description?: string;
143 isOptional: boolean;
144 isFlag: boolean;
145 isVariadic: boolean;
146}
147export interface OptionalParamDefinition<T> extends ParamDefinition<T> {
148 defaultValue: T;
149 isOptional: true;
150}
151export interface ParamDefinitionsMap {
152 [paramName: string]: ParamDefinition<any>;
153}
154/**
155 * Buidler arguments:
156 * * network: the network to be used.
157 * * showStackTraces: flag to show stack traces.
158 * * version: flag to show buidler's version.
159 * * help: flag to show buidler's help message.
160 * * emoji:
161 * * config: used to specify buidler's config file.
162 */
163export interface BuidlerArguments {
164 network?: string;
165 showStackTraces: boolean;
166 version: boolean;
167 help: boolean;
168 emoji: boolean;
169 config?: string;
170 verbose: boolean;
171 maxMemory?: number;
172}
173export declare type BuidlerParamDefinitions = {
174 [param in keyof Required<BuidlerArguments>]: OptionalParamDefinition<BuidlerArguments[param]>;
175};
176export interface TaskDefinition extends ConfigurableTaskDefinition {
177 readonly name: string;
178 readonly description?: string;
179 readonly action: ActionType<TaskArguments>;
180 readonly isInternal: boolean;
181 readonly paramDefinitions: ParamDefinitionsMap;
182 readonly positionalParamDefinitions: Array<ParamDefinition<any>>;
183}
184/**
185 * @type TaskArguments {object-like} - the input arguments for a task.
186 *
187 * TaskArguments type is set to 'any' because it's interface is dynamic.
188 * It's impossible in TypeScript to statically specify a variadic
189 * number of fields and at the same time define specific types for\
190 * the argument values.
191 *
192 * For example, we could define:
193 * type TaskArguments = Record<string, any>;
194 *
195 * ...but then, we couldn't narrow the actual argument value's type in compile time,
196 * thus we have no other option than forcing it to be just 'any'.
197 */
198export declare type TaskArguments = any;
199export declare type RunTaskFunction = (name: string, taskArguments?: TaskArguments) => Promise<any>;
200export interface RunSuperFunction<ArgT extends TaskArguments> {
201 (taskArguments?: ArgT): Promise<any>;
202 isDefined: boolean;
203}
204export declare type ActionType<ArgsT extends TaskArguments> = (taskArgs: ArgsT, env: BuidlerRuntimeEnvironment, runSuper: RunSuperFunction<ArgsT>) => Promise<any>;
205export interface EthereumProvider extends EventEmitter {
206 send(method: string, params?: any[]): Promise<any>;
207}
208export declare type IEthereumProvider = EthereumProvider;
209export interface Network {
210 name: string;
211 config: NetworkConfig;
212 provider: EthereumProvider;
213}
214export interface BuidlerRuntimeEnvironment {
215 readonly config: ResolvedBuidlerConfig;
216 readonly buidlerArguments: BuidlerArguments;
217 readonly tasks: TasksMap;
218 readonly run: RunTaskFunction;
219 readonly network: Network;
220 readonly ethereum: EthereumProvider;
221}
222export interface Artifact {
223 contractName: string;
224 abi: any;
225 bytecode: string;
226 deployedBytecode: string;
227 linkReferences: LinkReferences;
228 deployedLinkReferences: LinkReferences;
229}
230export interface LinkReferences {
231 [libraryFileName: string]: {
232 [libraryName: string]: Array<{
233 length: number;
234 start: number;
235 }>;
236 };
237}
238export {};
239//# sourceMappingURL=types.d.ts.map
\No newline at end of file