-
Notifications
You must be signed in to change notification settings - Fork 1
/
types.ts
209 lines (187 loc) Β· 5.26 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
import type { CoreBindings as Bindings, LibraryAddresses, Wrapper as SolcWrapper } from './deps.ts'
// Taken from https://stackoverflow.com/a/68404823/11889402
type DotPrefix<T extends string> = T extends '' ? '' : `.${T}`
type DotNestedKeys<T> =
(T extends object
? { [K in Exclude<keyof T, symbol>]: `${K}${DotPrefix<DotNestedKeys<T[K]>>}` }[Exclude<keyof T, symbol>]
: '') extends infer D ? Extract<D, string> : never
type OutputSelection = DotNestedKeys<Omit<CompiledContract, 'abi'>> | 'abi' | '*' | 'ast'
export type InputSettings = Partial<{
remappings: string[]
optimizer: Partial<{
enabled: boolean
runs: number
details: {
peephole: boolean
jumpdestRemover: boolean
deduplicate: boolean
orderLiterals: boolean
cse: boolean
constantOptimizer: boolean
yul: boolean
yulDetails: {
/**
* Improve allocation of stack slots for variables, can free up stack slots early. ctivated by default if the Yul optimizer is activated.
*/
stackAllocation: boolean
/**
* Select optimization steps to be applied.
* Optional, the optimizer will use the default sequence if omitted.
*/
optimizerSteps: string
}
}
}>
outputSelection: Record<string, Record<string, OutputSelection[]>>
libraries: LibraryAddresses
}>
export type Input = {
/**
* Source code language. Currently supported are "Solidity" and "Yul"
*/
language: 'Solidity' | 'Yul'
sources: Record<
string,
{ content: string; keccak256?: `0x${string}` } | { urls: string[]; keccak256?: `0x${string}` }
>
settings?: InputSettings
}
export type LegacyAssemblyCode = {
begin: number
end: number
name: string
source: number
value?: string
}
export type Assembly = string | null | undefined | {
'.code': LegacyAssemblyCode[]
'.data': {
'.auxdata': string
'.code': LegacyAssemblyCode[]
}
}
export type GeneratedSources = {
ast: YulAST
contents: string
id: number
language: string
name: string
}[]
export type FunctionDebugData = Record<
string,
{ entryPoint: number | null; id: number | null; parameterSlots: number; returnSlots: number }
>
export type CompilationError = {
component: 'general' | string
errorCode: string
formattedMessage: string
message: string
severity: 'error' | 'warning'
sourceLocation: { end: number; file: string; start: number }
type: 'Warning' | 'Parser' | string
}
export type ABI = {
inputs: {
internalType: string
name: string
type: string
}[]
name?: string
outputs?: { internalType: string; name: string; type: string }[]
stateMutability: string
type: string
payable?: boolean
constant?: boolean
}
type Statement = {
body: { nodeType: string; src: string; statements: Statement[] }
name: string
nodeType: string
parameters: { name: string; nodeType: string; src: string; type: string }[]
src: string
}
export type YulAST = {
nodeType: string
src: string
name?: string
statements: Statement[]
}
export type DocMethods = Record<
string,
{
details: string
params: Record<string, string>
}
>
export type GasEstimates = Partial<{
creation: { codeDepositCost: string; executionCost: string; totalCost: string }
internal: Record<string, string>
external: Record<string, string>
}>
export type LinkReferences = Record<string, Record<string, { length: number; start: number }[]>>
export type ContractEVM = {
assembly: string
bytecode: {
functionDebugData: FunctionDebugData
generatedSources: GeneratedSources
linkReferences: LinkReferences
object: string
opcodes: string
sourceMap: string
}
deployedBytecode: {
functionDebugData: FunctionDebugData
generatedSources: GeneratedSources
immutableReferences: Record<string, { length: number; start: number }[]>
linkReferences: LinkReferences
}
gasEstimates: GasEstimates
legacyAssembly: {
'.code': LegacyAssemblyCode[]
'.data': Record<
string,
{
'.auxdata': string
'.code': LegacyAssemblyCode[]
}
>
}
methodIdentifiers: Record<string, string>
}
export type CompiledContract = {
abi: ABI[]
devdoc: { kind: string; methods: DocMethods; version: 1; author: string }
evm: ContractEVM
ewasm: { wasm: string }
metadata: string
storageLayout: {
storage: {
astId: number
contract: string
label: string
offset: number
slot: string
type: string
}[]
types: Record<string, { encoding: string; key?: string; label: string; numberOfBytes: string; value?: string }>
}
userdoc: { kind: string; methods: DocMethods; version: number }
}
export type Output = {
error?: CompilationError
errors: CompilationError[]
contracts: Record<string, Record<string, CompiledContract>>
sourceList?: string[]
sources?: Record<string, { id: number; AST?: any }>
}
export type Wrapper = Pick<SolcWrapper, 'license' | 'compile' | 'version' | 'loadRemoteVersion'>
export type CoreBindings =
& Omit<Bindings, 'versionToSemver' | 'isVersion6OrNewer' | 'copyFromCString' | 'copyToCString'>
& {
copyFromCString: (ptr: number) => string
copyToCString: (input: string, ptr: number) => string
}
export type Callbacks = Partial<{
import: (data: unknown) => void
smtSolver: (data: string) => void
}>