-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtypes.go
More file actions
278 lines (238 loc) · 10.2 KB
/
types.go
File metadata and controls
278 lines (238 loc) · 10.2 KB
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
package sourcify
// ABIParameter represents a parameter in an ABI function or event
type ABIParameter struct {
InternalType string `json:"internalType"`
Name string `json:"name"`
Type string `json:"type"`
}
// ABIEntry represents a function, event, or error in an ABI
type ABIEntry struct {
Inputs []ABIParameter `json:"inputs"`
Name string `json:"name"`
Outputs []OutputDetail `json:"outputs"`
StateMutability string `json:"stateMutability"`
Type string `json:"type"`
Constant bool `json:"constant"`
Payable bool `json:"payable"`
Anonymous bool `json:"anonymous,omitempty"`
}
// BytecodeHash represents the bytecode hash settings in metadata
type BytecodeHash struct {
BytecodeHash string `json:"bytecodeHash"`
}
// Optimizer represents compiler optimizer settings
type Optimizer struct {
Enabled bool `json:"enabled"`
Runs int64 `json:"runs"`
}
// EVMVersion represents EVM version settings used in compiler settings
type EVMVersion struct {
EvmVersion string `json:"evmVersion"`
Libraries struct{} `json:"libraries"`
Metadata BytecodeHash `json:"metadata"`
Optimizer Optimizer `json:"optimizer"`
Remappings []interface{} `json:"remappings"`
}
// CborAuxData represents CBOR auxiliary data
type CborAuxData struct {
Offset int64 `json:"offset"`
Value string `json:"value"`
}
// Transformation represents a bytecode transformation operation
type Transformation struct {
ID string `json:"id,omitempty"`
Type string `json:"type"`
Offset int64 `json:"offset"`
Reason string `json:"reason"`
}
// TransformationValues represents the values used in bytecode transformations
type TransformationValues struct {
CborAuxdata map[string]string `json:"cborAuxdata,omitempty"`
ConstructorArguments string `json:"constructorArguments,omitempty"`
}
// Libraries defines contract libraries mapping
type Libraries map[string]string
// Bytecode represents a contract's bytecode information
type Bytecode struct {
CborAuxdata map[string]CborAuxData `json:"cborAuxdata"`
LinkReferences map[string]interface{} `json:"linkReferences"`
OnchainBytecode string `json:"onchainBytecode"`
RecompiledBytecode string `json:"recompiledBytecode"`
SourceMap string `json:"sourceMap"`
TransformationValues TransformationValues `json:"transformationValues"`
Transformations []Transformation `json:"transformations"`
ImmutableReferences map[string]interface{} `json:"immutableReferences,omitempty"`
}
// UintType represents a uint type definition
type UintType struct {
Encoding string `json:"encoding"`
Label string `json:"label"`
NumberOfBytes string `json:"numberOfBytes"`
}
// StorageLayout represents the storage layout of a contract
type StorageLayout struct {
Storage []StorageEntry `json:"storage"`
Types map[string]StorageType `json:"types"`
}
// StorageType represents a type definition in the storage layout
type StorageType struct {
Label string `json:"label"`
Encoding string `json:"encoding"`
NumberOfBytes string `json:"numberOfBytes"`
}
// StorageEntry represents a storage variable in the contract
type StorageEntry struct {
Slot string `json:"slot"`
Type string `json:"type"`
AstId int `json:"astId"`
Label string `json:"label"`
Offset int `json:"offset"`
Contract string `json:"contract"`
}
// ContractReference represents a reference to a contract file
type ContractReference struct {
ID int64 `json:"id"`
}
// ContentReference represents a reference to a contract's content
type ContentReference struct {
Content string `json:"content"`
}
// SourceURLs represents source URLs information
type SourceURLs struct {
Keccak256 string `json:"keccak256"`
License string `json:"license"`
Urls []string `json:"urls"`
}
// DevDoc represents developer documentation
type DevDoc struct {
Details string `json:"details"`
Kind string `json:"kind"`
Methods map[string]any `json:"methods"`
Title string `json:"title"`
Version int64 `json:"version"`
}
// UserDoc represents user documentation
type UserDoc struct {
Kind string `json:"kind"`
Methods map[string]any `json:"methods"`
Version int64 `json:"version"`
}
// EVMBytecode represents the EVM bytecode information
type EVMBytecode struct {
LinkReferences map[string]interface{} `json:"linkReferences"`
Object string `json:"object"`
SourceMap string `json:"sourceMap"`
}
// EVMDeployedBytecode represents the EVM deployed bytecode information
type EVMDeployedBytecode struct {
ImmutableReferences map[string]interface{} `json:"immutableReferences"`
LinkReferences map[string]interface{} `json:"linkReferences"`
Object string `json:"object"`
SourceMap string `json:"sourceMap"`
}
// EVM represents EVM-related information
type EVM struct {
Bytecode EVMBytecode `json:"bytecode"`
DeployedBytecode EVMDeployedBytecode `json:"deployedBytecode"`
}
// MetadataDetail provides additional metadata.
type MetadataDetail struct {
BytecodeHash string `json:"bytecodeHash"` // Hash of the bytecode
}
// Settings includes details about the compiler settings used.
type Settings struct {
CompilationTarget CompilationTarget `json:"compilationTarget"` // CompilationTarget represents the compilation target details.
EvmVersion string `json:"evmVersion"` // EVM version used
Libraries Libraries `json:"libraries"` // Libraries used in the source code
Metadata MetadataDetail `json:"metadata"` // MetadataDetail represents additional metadata.
Optimizer Optimizer `json:"optimizer"` // Optimizer represents the compiler optimization details.
Remappings []string `json:"remappings"` // Remappings used in the source code
}
// CompilationTarget holds the details of the compilation target.
type CompilationTarget map[string]string
// Deployment contains information about the contract deployment transaction
type Deployment struct {
TransactionHash string `json:"transactionHash"` // The hash of the transaction that deployed the contract
BlockNumber string `json:"blockNumber"` // The block number in which the contract was deployed
TransactionIndex string `json:"transactionIndex"` // The index of the transaction in the block
Deployer string `json:"deployer"` // The address that deployed the contract
}
// Compiler contains information about the compiler used to compile the smart contract.
type Compiler struct {
Version string `json:"version"` // Version of the compiler
}
// Output represents details of the compiled code in the metadata.
type Output struct {
Abi []ABIEntry `json:"abi,omitempty"`
Devdoc DevDoc `json:"devdoc,omitempty"`
Userdoc UserDoc `json:"userdoc,omitempty"`
}
// MetadataSource represents a source file in the metadata.
type MetadataSource struct {
Keccak256 string `json:"keccak256,omitempty"`
Urls []string `json:"urls,omitempty"`
License string `json:"license,omitempty"`
}
// Metadata represents the top-level structure for compiler metadata
// for Ethereum smart contracts.
type Metadata struct {
Compiler Compiler `json:"compiler"` // Compiler contains information about the compiler used.
Language string `json:"language"` // Language of the source code
Output Output `json:"output"` // Output represents details of the compiled code.
Settings Settings `json:"settings"` // Settings represent the compiler settings used.
Sources map[string]MetadataSource `json:"sources"` // Sources represents the details of the source code.
Version int `json:"version"` // Version of the metadata.
}
// Compilation contains information about the contract compilation process
type Compilation struct {
Compiler string `json:"compiler"`
CompilerSettings EVMVersion `json:"compilerSettings"`
CompilerVersion string `json:"compilerVersion"`
FullyQualifiedName string `json:"fullyQualifiedName"`
Language string `json:"language"`
Name string `json:"name"`
}
// ProxyResolution contains information about proxy contract resolution
type ProxyResolution struct {
Implementations []string `json:"implementations"`
IsProxy bool `json:"isProxy"`
ProxyType string `json:"proxyType,omitempty"`
}
// StdJSONInput represents the standard JSON input format for the compiler
type StdJSONInput struct {
Language string `json:"language"`
Settings Settings `json:"settings"`
Sources map[string]ContentReference `json:"sources"`
}
// SourceIdReference represents the ID reference for a source file
type SourceIdReference struct {
ID int `json:"id"`
}
// SourceIds maps file paths to their corresponding source IDs
type SourceIds map[string]SourceIdReference
// StdJSONOutput represents the standard JSON output format from the compiler
type StdJSONOutput struct {
Contracts map[string]map[string]ContractOutput `json:"contracts"`
Sources SourceIds `json:"sources"`
}
// ContractOutput contains the compiled information of a contract
type ContractOutput struct {
Abi []ABIEntry `json:"abi"`
Devdoc DevDoc `json:"devdoc"`
Evm EVM `json:"evm"`
Metadata string `json:"metadata"`
StorageLayout StorageLayout `json:"storageLayout"`
Userdoc UserDoc `json:"userdoc"`
}
// SourceContent represents the content of a source file
type SourceContent struct {
Content string `json:"content"`
}
// Sources maps file names to their content
type Sources map[string]SourceContent
// OutputDetail holds information about the output parameters of the functions.
type OutputDetail struct {
InternalType string `json:"internalType"` // Internal type of the parameter
Name string `json:"name"` // Name of the parameter
Type string `json:"type"` // Type of the parameter
}