UNPKG

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