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