UNPKG

6.4 kBPlain TextView Raw
1/** sources object with name of the file and content **/
2export interface SrcIfc {
3 [key: string]: {
4 content: string
5 }
6}
7/** An object with final results of test **/
8export interface FinalResult {
9 totalPassing: number,
10 totalFailing: number,
11 totalTime: number,
12 errors: any[],
13}
14/** List of tests to run **/
15export interface RunListInterface {
16 name: string,
17 type: string,
18 constant: boolean,
19 payable: boolean,
20 signature?: any
21}
22export interface ResultsInterface {
23 passingNum: number,
24 failureNum: number,
25 timePassed: number
26}
27export interface TestResultInterface {
28 type: string,
29 value: any,
30 time?: number,
31 context?: string,
32 errMsg?: string
33 filename?: string
34}
35export interface TestCbInterface {
36 (error: Error | null | undefined, result: TestResultInterface) : void;
37}
38export interface ResultCbInterface {
39 (error: Error | null | undefined, result: ResultsInterface) : void;
40}
41
42export interface Options {
43 accounts?: string[] | null,
44 web3?: any
45}
46
47export interface CompilerConfiguration {
48 currentCompilerUrl: string,
49 evmVersion: string,
50 optimize: boolean,
51 usingWorker: boolean
52}
53
54/** sources object with name of the file and content **/
55
56////////////
57// SOURCE //
58////////////
59export interface CompilationSource {
60 /** Identifier of the source (used in source maps) */
61 id: number
62 /** The AST object */
63 ast: AstNode
64 /** The legacy AST object */
65 legacyAST: AstNodeLegacy
66}
67
68export interface AstNodeLegacy {
69 id: number
70 name: string
71 src: string
72 children?: Array<AstNodeLegacy>
73 attributes?: AstNodeAtt
74}
75
76export interface AstNodeAtt {
77 operator?: string
78 string?: null
79 type?: string
80 value?: string
81 constant?: boolean
82 name?: string
83 public?: boolean
84 exportedSymbols?: Object
85 argumentTypes?: null
86 absolutePath?: string
87 [x: string]: any
88}
89
90export interface AstNode {
91 absolutePath?: string
92 exportedSymbols?: Object
93 id: number
94 nodeType: string
95 nodes?: Array<AstNode>
96 src: string
97 literals?: Array<string>
98 file?: string
99 scope?: number
100 sourceUnit?: number
101 symbolAliases?: Array<string>
102 [x: string]: any
103}
104
105export interface compilationInterface {
106 [fileName: string]: {
107 [contract: string]: CompiledContract
108 }
109}
110
111export interface ASTInterface {
112 [contractName: string]: CompilationSource
113}
114
115export interface CompiledContract {
116 /** The Ethereum Contract ABI. If empty, it is represented as an empty array. */
117 abi: ABIDescription[]
118 // See the Metadata Output documentation (serialised JSON string)
119 metadata: string
120 /** User documentation (natural specification) */
121 userdoc: UserDocumentation
122 /** Developer documentation (natural specification) */
123 devdoc: DeveloperDocumentation
124 /** Intermediate representation (string) */
125 ir: string
126 /** EVM-related outputs */
127 evm: {
128 assembly: string
129 legacyAssembly: {}
130 /** Bytecode and related details. */
131 bytecode: BytecodeObject
132 deployedBytecode: BytecodeObject
133 /** The list of function hashes */
134 methodIdentifiers: {
135 [functionIdentifier: string]: string
136 }
137 // Function gas estimates
138 gasEstimates: {
139 creation: {
140 codeDepositCost: string
141 executionCost: 'infinite' | string
142 totalCost: 'infinite' | string
143 }
144 external: {
145 [functionIdentifier: string]: string
146 }
147 internal: {
148 [functionIdentifier: string]: 'infinite' | string
149 }
150 }
151 }
152}
153
154/////////
155// ABI //
156/////////
157export type ABIDescription = FunctionDescription | EventDescription
158
159export interface FunctionDescription {
160 /** Type of the method. default is 'function' */
161 type?: 'function' | 'constructor' | 'fallback' | 'receive'
162 /** The name of the function. Constructor and fallback function never have name */
163 name?: string
164 /** List of parameters of the method. Fallback function doesn’t have inputs. */
165 inputs?: ABIParameter[]
166 /** List of the outputs parameters for the method, if any */
167 outputs?: ABIParameter[]
168 /** State mutability of the method */
169 stateMutability: 'pure' | 'view' | 'nonpayable' | 'payable'
170 /** true if function accepts Ether, false otherwise. Default is false */
171 payable?: boolean
172 /** true if function is either pure or view, false otherwise. Default is false */
173 constant?: boolean
174 signature?: string
175}
176
177export interface EventDescription {
178 type: 'event'
179 name: string
180 inputs: ABIParameter &
181 {
182 /** true if the field is part of the log’s topics, false if it one of the log’s data segment. */
183 indexed: boolean
184 }[]
185 /** true if the event was declared as anonymous. */
186 anonymous: boolean
187}
188
189export interface ABIParameter {
190 /** The name of the parameter */
191 name: string
192 /** The canonical type of the parameter */
193 type: ABITypeParameter
194 /** Used for tuple types */
195 components?: ABIParameter[]
196}
197
198export type ABITypeParameter =
199 | 'uint'
200 | 'uint[]' // TODO : add <M>
201 | 'int'
202 | 'int[]' // TODO : add <M>
203 | 'address'
204 | 'address[]'
205 | 'bool'
206 | 'bool[]'
207 | 'fixed'
208 | 'fixed[]' // TODO : add <M>
209 | 'ufixed'
210 | 'ufixed[]' // TODO : add <M>
211 | 'bytes'
212 | 'bytes[]' // TODO : add <M>
213 | 'function'
214 | 'function[]'
215 | 'tuple'
216 | 'tuple[]'
217 | string // Fallback
218
219///////////////////////////
220// NATURAL SPECIFICATION //
221///////////////////////////
222
223// Userdoc
224export interface UserDocumentation {
225 methods: UserMethodList
226 notice: string
227}
228
229export type UserMethodList = {
230 [functionIdentifier: string]: UserMethodDoc
231} & {
232 'constructor'?: string
233}
234export interface UserMethodDoc {
235 notice: string
236}
237
238// Devdoc
239export interface DeveloperDocumentation {
240 author: string
241 title: string
242 details: string
243 methods: DevMethodList
244}
245
246export interface DevMethodList {
247 [functionIdentifier: string]: DevMethodDoc
248}
249
250export interface DevMethodDoc {
251 author: string
252 details: string
253 return: string
254 params: {
255 [param: string]: string
256 }
257}
258
259//////////////
260// BYTECODE //
261//////////////
262export interface BytecodeObject {
263 /** The bytecode as a hex string. */
264 object: string
265 /** Opcodes list */
266 opcodes: string
267 /** The source mapping as a string. See the source mapping definition. */
268 sourceMap: string
269 /** If given, this is an unlinked object. */
270 linkReferences?: {
271 [contractName: string]: {
272 /** Byte offsets into the bytecode. */
273 [library: string]: { start: number; length: number }[]
274 }
275 }
276}