@nomicfoundation/edr 0.11.3 → 0.12.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.toml +61 -27
- package/LICENSE +5 -1
- package/index.d.ts +875 -137
- package/index.js +61 -3
- package/package.json +20 -16
- package/src/account.rs +109 -32
- package/src/block.rs +2 -103
- package/src/call_override.rs +7 -7
- package/src/cast.rs +47 -17
- package/src/chains/generic.rs +51 -0
- package/src/chains/l1.rs +262 -0
- package/src/chains/op.rs +425 -0
- package/src/chains.rs +7 -0
- package/src/config.rs +537 -67
- package/src/context.rs +374 -17
- package/src/debug_trace.rs +2 -2
- package/src/instrument.rs +109 -0
- package/src/lib.rs +38 -14
- package/src/log.rs +12 -14
- package/src/logger.rs +77 -1177
- package/src/mock.rs +68 -0
- package/src/precompile.rs +50 -0
- package/src/provider/factory.rs +22 -0
- package/src/provider/response.rs +73 -0
- package/src/provider.rs +64 -325
- package/src/result.rs +60 -69
- package/src/scenarios.rs +11 -17
- package/src/serde.rs +57 -0
- package/src/solidity_tests/artifact.rs +184 -0
- package/src/solidity_tests/config.rs +725 -0
- package/src/solidity_tests/factory.rs +22 -0
- package/src/solidity_tests/l1.rs +68 -0
- package/src/solidity_tests/op.rs +69 -0
- package/src/solidity_tests/runner.rs +51 -0
- package/src/solidity_tests/test_results.rs +668 -0
- package/src/solidity_tests.rs +56 -0
- package/src/subscription.rs +32 -0
- package/src/trace/debug.rs +1 -1
- package/src/trace/exit.rs +12 -13
- package/src/trace/library_utils.rs +1 -1
- package/src/trace/return_data.rs +11 -11
- package/src/trace/solidity_stack_trace.rs +11 -8
- package/src/trace.rs +37 -44
- package/src/withdrawal.rs +4 -4
- package/src/provider/config.rs +0 -291
- package/src/subscribe.rs +0 -63
package/index.d.ts
CHANGED
|
@@ -3,51 +3,29 @@
|
|
|
3
3
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
export interface
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
balance
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/** The state's root hash */
|
|
19
|
-
stateRoot?: Buffer
|
|
20
|
-
/** The block's difficulty */
|
|
21
|
-
difficulty?: bigint
|
|
22
|
-
/** The block's number */
|
|
23
|
-
number?: bigint
|
|
24
|
-
/** The block's gas limit */
|
|
25
|
-
gasLimit?: bigint
|
|
26
|
-
/** The block's timestamp */
|
|
27
|
-
timestamp?: bigint
|
|
28
|
-
/** The block's extra data */
|
|
29
|
-
extraData?: Buffer
|
|
30
|
-
/** The block's mix hash (or prevrandao) */
|
|
31
|
-
mixHash?: Buffer
|
|
32
|
-
/** The block's nonce */
|
|
33
|
-
nonce?: Buffer
|
|
34
|
-
/** The block's base gas fee */
|
|
35
|
-
baseFee?: bigint
|
|
36
|
-
/** The block's withdrawals */
|
|
37
|
-
withdrawals?: Array<Withdrawal>
|
|
38
|
-
/** Blob gas was added by EIP-4844 and is ignored in older headers. */
|
|
39
|
-
blobGas?: BlobGas
|
|
40
|
-
/**
|
|
41
|
-
* The hash tree root of the parent beacon block for the given execution
|
|
42
|
-
* block (EIP-4788).
|
|
43
|
-
*/
|
|
44
|
-
parentBeaconBlockRoot?: Buffer
|
|
45
|
-
/**
|
|
46
|
-
* The commitment hash calculated for a list of [EIP-7685] data requests.
|
|
6
|
+
/** Specification of overrides for an account and its storage. */
|
|
7
|
+
export interface AccountOverride {
|
|
8
|
+
/** The account's address */
|
|
9
|
+
address: Uint8Array
|
|
10
|
+
/** If present, the overwriting balance. */
|
|
11
|
+
balance?: bigint
|
|
12
|
+
/** If present, the overwriting nonce. */
|
|
13
|
+
nonce?: bigint
|
|
14
|
+
/** If present, the overwriting code. */
|
|
15
|
+
code?: Uint8Array
|
|
16
|
+
/**
|
|
17
|
+
* BEWARE: This field is not supported yet. See <https://github.com/NomicFoundation/edr/issues/911>
|
|
47
18
|
*
|
|
48
|
-
*
|
|
19
|
+
* If present, the overwriting storage.
|
|
49
20
|
*/
|
|
50
|
-
|
|
21
|
+
storage?: Array<StorageSlot>
|
|
22
|
+
}
|
|
23
|
+
/** A description of a storage slot's state. */
|
|
24
|
+
export interface StorageSlot {
|
|
25
|
+
/** The storage slot's index */
|
|
26
|
+
index: bigint
|
|
27
|
+
/** The storage slot's value */
|
|
28
|
+
value: bigint
|
|
51
29
|
}
|
|
52
30
|
/** Information about the blob gas used in a block. */
|
|
53
31
|
export interface BlobGas {
|
|
@@ -66,9 +44,14 @@ export interface BlobGas {
|
|
|
66
44
|
}
|
|
67
45
|
/** The result of executing a call override. */
|
|
68
46
|
export interface CallOverrideResult {
|
|
69
|
-
result:
|
|
47
|
+
result: Uint8Array
|
|
70
48
|
shouldRevert: boolean
|
|
71
49
|
}
|
|
50
|
+
export const GENERIC_CHAIN_TYPE: string
|
|
51
|
+
export declare function genericChainProviderFactory(): ProviderFactory
|
|
52
|
+
export const L1_CHAIN_TYPE: string
|
|
53
|
+
export declare function l1GenesisState(hardfork: SpecId): Array<AccountOverride>
|
|
54
|
+
export declare function l1ProviderFactory(): ProviderFactory
|
|
72
55
|
/** Identifier for the Ethereum spec. */
|
|
73
56
|
export enum SpecId {
|
|
74
57
|
/** Frontier */
|
|
@@ -108,75 +91,114 @@ export enum SpecId {
|
|
|
108
91
|
/** Cancun */
|
|
109
92
|
Cancun = 17,
|
|
110
93
|
/** Prague */
|
|
111
|
-
Prague = 18
|
|
112
|
-
/** Latest */
|
|
113
|
-
Latest = 19
|
|
114
|
-
}
|
|
115
|
-
export interface DebugTraceResult {
|
|
116
|
-
pass: boolean
|
|
117
|
-
gasUsed: bigint
|
|
118
|
-
output?: Buffer
|
|
119
|
-
structLogs: Array<DebugTraceLogItem>
|
|
120
|
-
}
|
|
121
|
-
export interface DebugTraceLogItem {
|
|
122
|
-
/** Program Counter */
|
|
123
|
-
pc: bigint
|
|
124
|
-
op: number
|
|
125
|
-
/** Gas left before executing this operation as hex number. */
|
|
126
|
-
gas: string
|
|
127
|
-
/** Gas cost of this operation as hex number. */
|
|
128
|
-
gasCost: string
|
|
129
|
-
/** Array of all values (hex numbers) on the stack */
|
|
130
|
-
stack?: Array<string>
|
|
131
|
-
/** Depth of the call stack */
|
|
132
|
-
depth: bigint
|
|
133
|
-
/** Size of memory array */
|
|
134
|
-
memSize: bigint
|
|
135
|
-
/** Name of the operation */
|
|
136
|
-
opName: string
|
|
137
|
-
/** Description of an error as a hex string. */
|
|
138
|
-
error?: string
|
|
139
|
-
/** Array of all allocated values as hex strings. */
|
|
140
|
-
memory?: Array<string>
|
|
141
|
-
/** Map of all stored values with keys and values encoded as hex strings. */
|
|
142
|
-
storage?: Record<string, string>
|
|
143
|
-
}
|
|
144
|
-
/** Ethereum execution log. */
|
|
145
|
-
export interface ExecutionLog {
|
|
146
|
-
address: Buffer
|
|
147
|
-
topics: Array<Buffer>
|
|
148
|
-
data: Buffer
|
|
149
|
-
}
|
|
150
|
-
export interface ContractAndFunctionName {
|
|
151
|
-
/** The contract name. */
|
|
152
|
-
contractName: string
|
|
153
|
-
/** The function name. Only present for calls. */
|
|
154
|
-
functionName?: string
|
|
94
|
+
Prague = 18
|
|
155
95
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
96
|
+
/**
|
|
97
|
+
* Tries to parse the provided string to create a [`SpecId`] instance.
|
|
98
|
+
*
|
|
99
|
+
* Returns an error if the string does not match any known hardfork.
|
|
100
|
+
*/
|
|
101
|
+
export declare function l1HardforkFromString(hardfork: string): SpecId
|
|
102
|
+
export declare function l1HardforkToString(harfork: SpecId): string
|
|
103
|
+
/**
|
|
104
|
+
* Returns the latest supported OP hardfork.
|
|
105
|
+
*
|
|
106
|
+
* The returned value will be updated after each network upgrade.
|
|
107
|
+
*/
|
|
108
|
+
export declare function l1HardforkLatest(): SpecId
|
|
109
|
+
export const FRONTIER: string
|
|
110
|
+
export const FRONTIER_THAWING: string
|
|
111
|
+
export const HOMESTEAD: string
|
|
112
|
+
export const DAO_FORK: string
|
|
113
|
+
export const TANGERINE: string
|
|
114
|
+
export const SPURIOUS_DRAGON: string
|
|
115
|
+
export const BYZANTIUM: string
|
|
116
|
+
export const CONSTANTINOPLE: string
|
|
117
|
+
export const PETERSBURG: string
|
|
118
|
+
export const ISTANBUL: string
|
|
119
|
+
export const MUIR_GLACIER: string
|
|
120
|
+
export const BERLIN: string
|
|
121
|
+
export const LONDON: string
|
|
122
|
+
export const ARROW_GLACIER: string
|
|
123
|
+
export const GRAY_GLACIER: string
|
|
124
|
+
export const MERGE: string
|
|
125
|
+
export const SHANGHAI: string
|
|
126
|
+
export const CANCUN: string
|
|
127
|
+
export const PRAGUE: string
|
|
128
|
+
/** Enumeration of supported OP hardforks. */
|
|
129
|
+
export enum OpHardfork {
|
|
130
|
+
Bedrock = 100,
|
|
131
|
+
Regolith = 101,
|
|
132
|
+
Canyon = 102,
|
|
133
|
+
Ecotone = 103,
|
|
134
|
+
Fjord = 104,
|
|
135
|
+
Granite = 105,
|
|
136
|
+
Holocene = 106,
|
|
137
|
+
Isthmus = 107
|
|
161
138
|
}
|
|
162
|
-
/**
|
|
163
|
-
|
|
139
|
+
/**
|
|
140
|
+
* Tries to parse the provided string to create an [`OpHardfork`]
|
|
141
|
+
* instance.
|
|
142
|
+
*
|
|
143
|
+
* Returns an error if the string does not match any known hardfork.
|
|
144
|
+
*/
|
|
145
|
+
export declare function opHardforkFromString(hardfork: string): OpHardfork
|
|
146
|
+
/** Returns the string representation of the provided OP hardfork. */
|
|
147
|
+
export declare function opHardforkToString(hardfork: OpHardfork): string
|
|
148
|
+
/**
|
|
149
|
+
* Returns the latest supported OP hardfork.
|
|
150
|
+
*
|
|
151
|
+
* The returned value will be updated after each network upgrade.
|
|
152
|
+
*/
|
|
153
|
+
export declare function opLatestHardfork(): OpHardfork
|
|
154
|
+
export const OP_CHAIN_TYPE: string
|
|
155
|
+
export declare function opGenesisState(hardfork: OpHardfork): Array<AccountOverride>
|
|
156
|
+
export declare function opProviderFactory(): ProviderFactory
|
|
157
|
+
export const BEDROCK: string
|
|
158
|
+
export const REGOLITH: string
|
|
159
|
+
export const CANYON: string
|
|
160
|
+
export const ECOTONE: string
|
|
161
|
+
export const FJORD: string
|
|
162
|
+
export const GRANITE: string
|
|
163
|
+
export const HOLOCENE: string
|
|
164
|
+
export const ISTHMUS: string
|
|
165
|
+
/** Specification of a chain with possible overrides. */
|
|
166
|
+
export interface ChainOverride {
|
|
164
167
|
/** The chain ID */
|
|
165
168
|
chainId: bigint
|
|
166
|
-
/** The chain's
|
|
167
|
-
|
|
169
|
+
/** The chain's name */
|
|
170
|
+
name: string
|
|
171
|
+
/** If present, overrides for the chain's supported hardforks */
|
|
172
|
+
hardforkActivationOverrides?: Array<HardforkActivation>
|
|
173
|
+
}
|
|
174
|
+
/** Configuration for a code coverage reporter. */
|
|
175
|
+
export interface CodeCoverageConfig {
|
|
176
|
+
/**
|
|
177
|
+
* The callback to be called when coverage has been collected.
|
|
178
|
+
*
|
|
179
|
+
* The callback receives an array of unique coverage hit markers (i.e. no
|
|
180
|
+
* repetition) per transaction.
|
|
181
|
+
*
|
|
182
|
+
* Exceptions thrown in the callback will be propagated to the original
|
|
183
|
+
* caller.
|
|
184
|
+
*/
|
|
185
|
+
onCollectedCoverageCallback: (coverageHits: Uint8Array[]) => Promise<void>
|
|
168
186
|
}
|
|
169
187
|
/** Configuration for forking a blockchain */
|
|
170
188
|
export interface ForkConfig {
|
|
171
|
-
/** The URL of the JSON-RPC endpoint to fork from */
|
|
172
|
-
jsonRpcUrl: string
|
|
173
189
|
/**
|
|
174
190
|
* The block number to fork from. If not provided, the latest safe block is
|
|
175
191
|
* used.
|
|
176
192
|
*/
|
|
177
193
|
blockNumber?: bigint
|
|
194
|
+
/** The directory to cache remote JSON-RPC responses */
|
|
195
|
+
cacheDir?: string
|
|
196
|
+
/** Overrides for the configuration of chains. */
|
|
197
|
+
chainOverrides?: Array<ChainOverride>
|
|
178
198
|
/** The HTTP headers to use when making requests to the JSON-RPC endpoint */
|
|
179
199
|
httpHeaders?: Array<HttpHeader>
|
|
200
|
+
/** The URL of the JSON-RPC endpoint to fork from */
|
|
201
|
+
url: string
|
|
180
202
|
}
|
|
181
203
|
export interface HttpHeader {
|
|
182
204
|
name: string
|
|
@@ -184,10 +206,18 @@ export interface HttpHeader {
|
|
|
184
206
|
}
|
|
185
207
|
/** Configuration for a hardfork activation */
|
|
186
208
|
export interface HardforkActivation {
|
|
209
|
+
/** The condition for the hardfork activation */
|
|
210
|
+
condition: HardforkActivationByBlockNumber | HardforkActivationByTimestamp
|
|
211
|
+
/** The activated hardfork */
|
|
212
|
+
hardfork: string
|
|
213
|
+
}
|
|
214
|
+
export interface HardforkActivationByBlockNumber {
|
|
187
215
|
/** The block number at which the hardfork is activated */
|
|
188
216
|
blockNumber: bigint
|
|
189
|
-
|
|
190
|
-
|
|
217
|
+
}
|
|
218
|
+
export interface HardforkActivationByTimestamp {
|
|
219
|
+
/** The timestamp at which the hardfork is activated */
|
|
220
|
+
timestamp: bigint
|
|
191
221
|
}
|
|
192
222
|
/**The type of ordering to use when selecting blocks to mine. */
|
|
193
223
|
export enum MineOrdering {
|
|
@@ -210,6 +240,11 @@ export interface MiningConfig {
|
|
|
210
240
|
interval?: bigint | IntervalRange
|
|
211
241
|
memPool: MemPoolConfig
|
|
212
242
|
}
|
|
243
|
+
/** Configuration for runtime observability. */
|
|
244
|
+
export interface ObservabilityConfig {
|
|
245
|
+
/** If present, configures runtime observability to collect code coverage. */
|
|
246
|
+
codeCoverage?: CodeCoverageConfig
|
|
247
|
+
}
|
|
213
248
|
/** Configuration for a provider */
|
|
214
249
|
export interface ProviderConfig {
|
|
215
250
|
/** Whether to allow blocks with the same timestamp */
|
|
@@ -222,25 +257,19 @@ export interface ProviderConfig {
|
|
|
222
257
|
bailOnTransactionFailure: boolean
|
|
223
258
|
/** The gas limit of each block */
|
|
224
259
|
blockGasLimit: bigint
|
|
225
|
-
/** The directory to cache remote JSON-RPC responses */
|
|
226
|
-
cacheDir?: string
|
|
227
260
|
/** The chain ID of the blockchain */
|
|
228
261
|
chainId: bigint
|
|
229
|
-
/** The configuration for chains */
|
|
230
|
-
chains: Array<ChainConfig>
|
|
231
262
|
/** The address of the coinbase */
|
|
232
|
-
coinbase:
|
|
233
|
-
/** Enables RIP-7212 */
|
|
234
|
-
enableRip7212: boolean
|
|
263
|
+
coinbase: Uint8Array
|
|
235
264
|
/**
|
|
236
265
|
* The configuration for forking a blockchain. If not provided, a local
|
|
237
266
|
* blockchain will be created
|
|
238
267
|
*/
|
|
239
268
|
fork?: ForkConfig
|
|
240
|
-
/** The genesis
|
|
241
|
-
|
|
269
|
+
/** The genesis state of the blockchain */
|
|
270
|
+
genesisState: Array<AccountOverride>
|
|
242
271
|
/** The hardfork of the blockchain */
|
|
243
|
-
hardfork:
|
|
272
|
+
hardfork: string
|
|
244
273
|
/**
|
|
245
274
|
* The initial base fee per gas of the blockchain. Required for EIP-1559
|
|
246
275
|
* transactions and later
|
|
@@ -254,13 +283,19 @@ export interface ProviderConfig {
|
|
|
254
283
|
* The initial parent beacon block root of the blockchain. Required for
|
|
255
284
|
* EIP-4788
|
|
256
285
|
*/
|
|
257
|
-
initialParentBeaconBlockRoot?:
|
|
286
|
+
initialParentBeaconBlockRoot?: Uint8Array
|
|
258
287
|
/** The minimum gas price of the next block. */
|
|
259
288
|
minGasPrice: bigint
|
|
260
289
|
/** The configuration for the miner */
|
|
261
290
|
mining: MiningConfig
|
|
262
291
|
/** The network ID of the blockchain */
|
|
263
292
|
networkId: bigint
|
|
293
|
+
/** The configuration for the provider's observability */
|
|
294
|
+
observability: ObservabilityConfig
|
|
295
|
+
/** Secret keys of owned accounts */
|
|
296
|
+
ownedAccounts: Array<string>
|
|
297
|
+
/** Overrides for precompiles */
|
|
298
|
+
precompileOverrides: Array<Precompile>
|
|
264
299
|
}
|
|
265
300
|
/** Tracing config for Solidity stack trace generation. */
|
|
266
301
|
export interface TracingConfigWithBuffers {
|
|
@@ -283,6 +318,86 @@ export interface BuildInfoAndOutput {
|
|
|
283
318
|
/** The build info output file */
|
|
284
319
|
output: Uint8Array
|
|
285
320
|
}
|
|
321
|
+
export interface DebugTraceResult {
|
|
322
|
+
pass: boolean
|
|
323
|
+
gasUsed: bigint
|
|
324
|
+
output?: Uint8Array
|
|
325
|
+
structLogs: Array<DebugTraceLogItem>
|
|
326
|
+
}
|
|
327
|
+
export interface DebugTraceLogItem {
|
|
328
|
+
/** Program Counter */
|
|
329
|
+
pc: bigint
|
|
330
|
+
op: number
|
|
331
|
+
/** Gas left before executing this operation as hex number. */
|
|
332
|
+
gas: string
|
|
333
|
+
/** Gas cost of this operation as hex number. */
|
|
334
|
+
gasCost: string
|
|
335
|
+
/** Array of all values (hex numbers) on the stack */
|
|
336
|
+
stack?: Array<string>
|
|
337
|
+
/** Depth of the call stack */
|
|
338
|
+
depth: bigint
|
|
339
|
+
/** Size of memory array */
|
|
340
|
+
memSize: bigint
|
|
341
|
+
/** Name of the operation */
|
|
342
|
+
opName: string
|
|
343
|
+
/** Description of an error as a hex string. */
|
|
344
|
+
error?: string
|
|
345
|
+
/** Array of all allocated values as hex strings. */
|
|
346
|
+
memory?: Array<string>
|
|
347
|
+
/** Map of all stored values with keys and values encoded as hex strings. */
|
|
348
|
+
storage?: Record<string, string>
|
|
349
|
+
}
|
|
350
|
+
export interface InstrumentationResult {
|
|
351
|
+
/** The generated source code with coverage instrumentation. */
|
|
352
|
+
readonly source: string
|
|
353
|
+
/** The metadata for each instrumented code segment. */
|
|
354
|
+
readonly metadata: Array<InstrumentationMetadata>
|
|
355
|
+
}
|
|
356
|
+
export interface InstrumentationMetadata {
|
|
357
|
+
/**
|
|
358
|
+
* The tag that identifies the instrumented code. Tags are
|
|
359
|
+
* deterministically generated from the source code, source id, and
|
|
360
|
+
* Solidity version.
|
|
361
|
+
*/
|
|
362
|
+
readonly tag: Uint8Array
|
|
363
|
+
/**
|
|
364
|
+
* The kind of instrumented code. Currently, the only supported kind
|
|
365
|
+
* is "statement".
|
|
366
|
+
*/
|
|
367
|
+
readonly kind: string
|
|
368
|
+
/**
|
|
369
|
+
* The starting position of the instrumented code - including trivia such
|
|
370
|
+
* as whitespace - in the source code, in UTF-16 code units.
|
|
371
|
+
*/
|
|
372
|
+
readonly startUtf16: number
|
|
373
|
+
/**
|
|
374
|
+
* The ending position of the instrumented code - including trivia such as
|
|
375
|
+
* whitespace - in the source code, in UTF-16 code units.
|
|
376
|
+
*/
|
|
377
|
+
readonly endUtf16: number
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Adds per-statement coverage instrumentation to the given Solidity source
|
|
381
|
+
* code.
|
|
382
|
+
*/
|
|
383
|
+
export declare function addStatementCoverageInstrumentation(sourceCode: string, sourceId: string, solidityVersion: string, coverageLibraryPath: string): InstrumentationResult
|
|
384
|
+
/** Ethereum execution log. */
|
|
385
|
+
export interface ExecutionLog {
|
|
386
|
+
address: Uint8Array
|
|
387
|
+
topics: Array<Uint8Array>
|
|
388
|
+
data: Uint8Array
|
|
389
|
+
}
|
|
390
|
+
export interface LoggerConfig {
|
|
391
|
+
/** Whether to enable the logger. */
|
|
392
|
+
enable: boolean
|
|
393
|
+
decodeConsoleLogInputsCallback: (inputs: ArrayBuffer[]) => string[]
|
|
394
|
+
printLineCallback: (message: string, replace: boolean) => void
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* [RIP-7212](https://github.com/ethereum/RIPs/blob/master/RIPS/rip-7212.md#specification)
|
|
398
|
+
* secp256r1 precompile.
|
|
399
|
+
*/
|
|
400
|
+
export declare function precompileP256Verify(): Precompile
|
|
286
401
|
/** The possible reasons for successful termination of the EVM. */
|
|
287
402
|
export enum SuccessReason {
|
|
288
403
|
/** The opcode `STOP` was called */
|
|
@@ -295,13 +410,13 @@ export enum SuccessReason {
|
|
|
295
410
|
}
|
|
296
411
|
export interface CallOutput {
|
|
297
412
|
/** Return value */
|
|
298
|
-
returnValue:
|
|
413
|
+
returnValue: Uint8Array
|
|
299
414
|
}
|
|
300
415
|
export interface CreateOutput {
|
|
301
416
|
/** Return value */
|
|
302
|
-
returnValue:
|
|
417
|
+
returnValue: Uint8Array
|
|
303
418
|
/** Optionally, a 160-bit address */
|
|
304
|
-
address?:
|
|
419
|
+
address?: Uint8Array
|
|
305
420
|
}
|
|
306
421
|
/** The result when the EVM terminates successfully. */
|
|
307
422
|
export interface SuccessResult {
|
|
@@ -321,7 +436,7 @@ export interface RevertResult {
|
|
|
321
436
|
/** The amount of gas used */
|
|
322
437
|
gasUsed: bigint
|
|
323
438
|
/** The transaction output */
|
|
324
|
-
output:
|
|
439
|
+
output: Uint8Array
|
|
325
440
|
}
|
|
326
441
|
/**
|
|
327
442
|
* Indicates that the EVM has experienced an exceptional halt. This causes
|
|
@@ -350,7 +465,7 @@ export enum ExceptionalHalt {
|
|
|
350
465
|
/** Aud data is smaller then already present data size. */
|
|
351
466
|
EofAuxDataTooSmall = 15,
|
|
352
467
|
/** EOF Subroutine stack overflow */
|
|
353
|
-
|
|
468
|
+
SubRoutineStackOverflow = 16,
|
|
354
469
|
/** Check for target address validity is only done inside subcall. */
|
|
355
470
|
InvalidEXTCALLTarget = 17
|
|
356
471
|
}
|
|
@@ -369,7 +484,563 @@ export interface ExecutionResult {
|
|
|
369
484
|
/** The transaction result */
|
|
370
485
|
result: SuccessResult | RevertResult | HaltResult
|
|
371
486
|
/** Optional contract address if the transaction created a new contract. */
|
|
372
|
-
contractAddress?:
|
|
487
|
+
contractAddress?: Uint8Array
|
|
488
|
+
}
|
|
489
|
+
/** A compilation artifact. */
|
|
490
|
+
export interface Artifact {
|
|
491
|
+
/** The identifier of the artifact. */
|
|
492
|
+
id: ArtifactId
|
|
493
|
+
/** The test contract. */
|
|
494
|
+
contract: ContractData
|
|
495
|
+
}
|
|
496
|
+
/** The identifier of a Solidity contract. */
|
|
497
|
+
export interface ArtifactId {
|
|
498
|
+
/** The name of the contract. */
|
|
499
|
+
name: string
|
|
500
|
+
/** Original source file path. */
|
|
501
|
+
source: string
|
|
502
|
+
/** The solc semver string. */
|
|
503
|
+
solcVersion: string
|
|
504
|
+
}
|
|
505
|
+
/** A test contract to execute. */
|
|
506
|
+
export interface ContractData {
|
|
507
|
+
/** Contract ABI as json string. */
|
|
508
|
+
abi: string
|
|
509
|
+
/**
|
|
510
|
+
* Contract creation code as hex string. It can be missing if the contract
|
|
511
|
+
* is ABI only.
|
|
512
|
+
*/
|
|
513
|
+
bytecode?: string
|
|
514
|
+
/** The link references of the deployment bytecode. */
|
|
515
|
+
linkReferences?: Record<string, Record<string, Array<LinkReference>>>
|
|
516
|
+
/**
|
|
517
|
+
* Contract runtime code as hex string. It can be missing if the contract
|
|
518
|
+
* is ABI only.
|
|
519
|
+
*/
|
|
520
|
+
deployedBytecode?: string
|
|
521
|
+
/** The link references of the deployed bytecode. */
|
|
522
|
+
deployedLinkReferences?: Record<string, Record<string, Array<LinkReference>>>
|
|
523
|
+
}
|
|
524
|
+
export interface LinkReference {
|
|
525
|
+
start: number
|
|
526
|
+
length: number
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* Solidity test runner configuration arguments exposed through the ffi.
|
|
530
|
+
* Docs based on <https://book.getfoundry.sh/reference/config/testing>.
|
|
531
|
+
*/
|
|
532
|
+
export interface SolidityTestRunnerConfigArgs {
|
|
533
|
+
/**
|
|
534
|
+
* The absolute path to the project root directory.
|
|
535
|
+
* Relative paths in cheat codes are resolved against this path.
|
|
536
|
+
*/
|
|
537
|
+
projectRoot: string
|
|
538
|
+
/** Configures the permissions of cheat codes that access the file system. */
|
|
539
|
+
fsPermissions?: Array<PathPermission>
|
|
540
|
+
/** Whether to support the `testFail` prefix. Defaults to false. */
|
|
541
|
+
testFail?: boolean
|
|
542
|
+
/** Address labels for traces. Defaults to none. */
|
|
543
|
+
labels?: Array<AddressLabel>
|
|
544
|
+
/**
|
|
545
|
+
* Whether to enable isolation of calls. In isolation mode all top-level
|
|
546
|
+
* calls are executed as a separate transaction in a separate EVM
|
|
547
|
+
* context, enabling more precise gas accounting and transaction state
|
|
548
|
+
* changes.
|
|
549
|
+
* Defaults to false.
|
|
550
|
+
*/
|
|
551
|
+
isolate?: boolean
|
|
552
|
+
/**
|
|
553
|
+
* Whether or not to enable the ffi cheatcode.
|
|
554
|
+
* Warning: Enabling this cheatcode has security implications, as it allows
|
|
555
|
+
* tests to execute arbitrary programs on your computer.
|
|
556
|
+
* Defaults to false.
|
|
557
|
+
*/
|
|
558
|
+
ffi?: boolean
|
|
559
|
+
/**
|
|
560
|
+
* Allow expecting reverts with `expectRevert` at the same callstack depth
|
|
561
|
+
* as the test. Defaults to false.
|
|
562
|
+
*/
|
|
563
|
+
allowInternalExpectRevert?: boolean
|
|
564
|
+
/**
|
|
565
|
+
* The value of `msg.sender` in tests as hex string.
|
|
566
|
+
* Defaults to `0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38`.
|
|
567
|
+
*/
|
|
568
|
+
sender?: Uint8Array
|
|
569
|
+
/**
|
|
570
|
+
* The value of `tx.origin` in tests as hex string.
|
|
571
|
+
* Defaults to `0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38`.
|
|
572
|
+
*/
|
|
573
|
+
txOrigin?: Uint8Array
|
|
574
|
+
/**
|
|
575
|
+
* The initial balance of the sender in tests.
|
|
576
|
+
* Defaults to `0xffffffffffffffffffffffff`.
|
|
577
|
+
*/
|
|
578
|
+
initialBalance?: bigint
|
|
579
|
+
/**
|
|
580
|
+
* The value of `block.number` in tests.
|
|
581
|
+
* Defaults to `1`.
|
|
582
|
+
*/
|
|
583
|
+
blockNumber?: bigint
|
|
584
|
+
/**
|
|
585
|
+
* The value of the `chainid` opcode in tests.
|
|
586
|
+
* Defaults to `31337`.
|
|
587
|
+
*/
|
|
588
|
+
chainId?: bigint
|
|
589
|
+
/**
|
|
590
|
+
* The gas limit for each test case.
|
|
591
|
+
* Defaults to `9_223_372_036_854_775_807` (`i64::MAX`).
|
|
592
|
+
*/
|
|
593
|
+
gasLimit?: bigint
|
|
594
|
+
/**
|
|
595
|
+
* The price of gas (in wei) in tests.
|
|
596
|
+
* Defaults to `0`.
|
|
597
|
+
*/
|
|
598
|
+
gasPrice?: bigint
|
|
599
|
+
/**
|
|
600
|
+
* The base fee per gas (in wei) in tests.
|
|
601
|
+
* Defaults to `0`.
|
|
602
|
+
*/
|
|
603
|
+
blockBaseFeePerGas?: bigint
|
|
604
|
+
/**
|
|
605
|
+
* The value of `block.coinbase` in tests.
|
|
606
|
+
* Defaults to `0x0000000000000000000000000000000000000000`.
|
|
607
|
+
*/
|
|
608
|
+
blockCoinbase?: Uint8Array
|
|
609
|
+
/**
|
|
610
|
+
* The value of `block.timestamp` in tests.
|
|
611
|
+
* Defaults to 1.
|
|
612
|
+
*/
|
|
613
|
+
blockTimestamp?: bigint
|
|
614
|
+
/**
|
|
615
|
+
* The value of `block.difficulty` in tests.
|
|
616
|
+
* Defaults to 0.
|
|
617
|
+
*/
|
|
618
|
+
blockDifficulty?: bigint
|
|
619
|
+
/**
|
|
620
|
+
* The `block.gaslimit` value during EVM execution.
|
|
621
|
+
* Defaults to none.
|
|
622
|
+
*/
|
|
623
|
+
blockGasLimit?: bigint
|
|
624
|
+
/**
|
|
625
|
+
* Whether to disable the block gas limit.
|
|
626
|
+
* Defaults to false.
|
|
627
|
+
*/
|
|
628
|
+
disableBlockGasLimit?: boolean
|
|
629
|
+
/**
|
|
630
|
+
* The memory limit of the EVM in bytes.
|
|
631
|
+
* Defaults to 33_554_432 (2^25 = 32MiB).
|
|
632
|
+
*/
|
|
633
|
+
memoryLimit?: bigint
|
|
634
|
+
/**
|
|
635
|
+
* The predeploys applied in local mode. Defaults to no predeploys.
|
|
636
|
+
* These should match the predeploys of the network in fork mode, so they
|
|
637
|
+
* aren't set in fork mode.
|
|
638
|
+
* The code must be set and non-empty. The nonce and the balance default to
|
|
639
|
+
* zero and storage defaults to empty.
|
|
640
|
+
*/
|
|
641
|
+
localPredeploys?: Array<AccountOverride>
|
|
642
|
+
/**
|
|
643
|
+
* If set, all tests are run in fork mode using this url or remote name.
|
|
644
|
+
* Defaults to none.
|
|
645
|
+
*/
|
|
646
|
+
ethRpcUrl?: string
|
|
647
|
+
/** Pins the block number for the global state fork. */
|
|
648
|
+
forkBlockNumber?: bigint
|
|
649
|
+
/**
|
|
650
|
+
* Map of RPC endpoints from chain name to RPC urls for fork cheat codes,
|
|
651
|
+
* e.g. `{ "optimism": "https://optimism.alchemyapi.io/v2/..." }`
|
|
652
|
+
*/
|
|
653
|
+
rpcEndpoints?: Record<string, string>
|
|
654
|
+
/**
|
|
655
|
+
* Optional RPC cache path. If this is none, then no RPC calls will be
|
|
656
|
+
* cached, otherwise data is cached to `<rpc_cache_path>/<chain
|
|
657
|
+
* id>/<block number>`. Caching can be disabled for specific chains
|
|
658
|
+
* with `rpc_storage_caching`.
|
|
659
|
+
*/
|
|
660
|
+
rpcCachePath?: string
|
|
661
|
+
/** What RPC endpoints are cached. Defaults to all. */
|
|
662
|
+
rpcStorageCaching?: StorageCachingConfig
|
|
663
|
+
/**
|
|
664
|
+
* The number of seconds to wait before `vm.prompt` reverts with a timeout.
|
|
665
|
+
* Defaults to 120.
|
|
666
|
+
*/
|
|
667
|
+
promptTimeout?: number
|
|
668
|
+
/** Fuzz testing configuration. */
|
|
669
|
+
fuzz?: FuzzConfigArgs
|
|
670
|
+
/**
|
|
671
|
+
* Invariant testing configuration.
|
|
672
|
+
* If an invariant config setting is not set, but a corresponding fuzz
|
|
673
|
+
* config value is set, then the fuzz config value will be used.
|
|
674
|
+
*/
|
|
675
|
+
invariant?: InvariantConfigArgs
|
|
676
|
+
/**
|
|
677
|
+
* Controls which test results should include execution traces. Defaults to
|
|
678
|
+
* None.
|
|
679
|
+
*/
|
|
680
|
+
includeTraces?: IncludeTraces
|
|
681
|
+
/** The configuration for the Solidity test runner's observability */
|
|
682
|
+
observability?: ObservabilityConfig
|
|
683
|
+
/**
|
|
684
|
+
* A regex pattern to filter tests. If provided, only test methods that
|
|
685
|
+
* match the pattern will be executed and reported as a test result.
|
|
686
|
+
*/
|
|
687
|
+
testPattern?: string
|
|
688
|
+
}
|
|
689
|
+
/** Fuzz testing configuration */
|
|
690
|
+
export interface FuzzConfigArgs {
|
|
691
|
+
/** Path where fuzz failures are recorded and replayed if set. */
|
|
692
|
+
failurePersistDir?: string
|
|
693
|
+
/** Name of the file to record fuzz failures, defaults to `failures`. */
|
|
694
|
+
failurePersistFile?: string
|
|
695
|
+
/**
|
|
696
|
+
* The amount of fuzz runs to perform for each fuzz test case. Higher
|
|
697
|
+
* values gives more confidence in results at the cost of testing
|
|
698
|
+
* speed.
|
|
699
|
+
* Defaults to 256.
|
|
700
|
+
*/
|
|
701
|
+
runs?: number
|
|
702
|
+
/**
|
|
703
|
+
* The maximum number of combined inputs that may be rejected before the
|
|
704
|
+
* test as a whole aborts. “Global” filters apply to the whole test
|
|
705
|
+
* case. If the test case is rejected, the whole thing is regenerated.
|
|
706
|
+
* Defaults to 65536.
|
|
707
|
+
*/
|
|
708
|
+
maxTestRejects?: number
|
|
709
|
+
/**
|
|
710
|
+
* Hexadecimal string.
|
|
711
|
+
* Optional seed for the fuzzing RNG algorithm.
|
|
712
|
+
* Defaults to None.
|
|
713
|
+
*/
|
|
714
|
+
seed?: string
|
|
715
|
+
/**
|
|
716
|
+
* Integer between 0 and 100.
|
|
717
|
+
* The weight of the dictionary. A higher dictionary weight will bias the
|
|
718
|
+
* fuzz inputs towards “interesting” values, e.g. boundary values like
|
|
719
|
+
* type(uint256).max or contract addresses from your environment.
|
|
720
|
+
* Defaults to 40.
|
|
721
|
+
*/
|
|
722
|
+
dictionaryWeight?: number
|
|
723
|
+
/**
|
|
724
|
+
* The flag indicating whether to include values from storage.
|
|
725
|
+
* Defaults to true.
|
|
726
|
+
*/
|
|
727
|
+
includeStorage?: boolean
|
|
728
|
+
/**
|
|
729
|
+
* The flag indicating whether to include push bytes values.
|
|
730
|
+
* Defaults to true.
|
|
731
|
+
*/
|
|
732
|
+
includePushBytes?: boolean
|
|
733
|
+
}
|
|
734
|
+
/** Invariant testing configuration. */
|
|
735
|
+
export interface InvariantConfigArgs {
|
|
736
|
+
/** Path where invariant failures are recorded and replayed if set. */
|
|
737
|
+
failurePersistDir?: string
|
|
738
|
+
/**
|
|
739
|
+
* The number of runs that must execute for each invariant test group.
|
|
740
|
+
* Defaults to 256.
|
|
741
|
+
*/
|
|
742
|
+
runs?: number
|
|
743
|
+
/**
|
|
744
|
+
* The number of calls executed to attempt to break invariants in one run.
|
|
745
|
+
* Defaults to 500.
|
|
746
|
+
*/
|
|
747
|
+
depth?: number
|
|
748
|
+
/**
|
|
749
|
+
* Fails the invariant fuzzing if a revert occurs.
|
|
750
|
+
* Defaults to false.
|
|
751
|
+
*/
|
|
752
|
+
failOnRevert?: boolean
|
|
753
|
+
/**
|
|
754
|
+
* Overrides unsafe external calls when running invariant tests, useful for
|
|
755
|
+
* e.g. performing reentrancy checks.
|
|
756
|
+
* Defaults to false.
|
|
757
|
+
*/
|
|
758
|
+
callOverride?: boolean
|
|
759
|
+
/**
|
|
760
|
+
* Integer between 0 and 100.
|
|
761
|
+
* The weight of the dictionary. A higher dictionary weight will bias the
|
|
762
|
+
* fuzz inputs towards “interesting” values, e.g. boundary values like
|
|
763
|
+
* type(uint256).max or contract addresses from your environment.
|
|
764
|
+
* Defaults to 40.
|
|
765
|
+
*/
|
|
766
|
+
dictionaryWeight?: number
|
|
767
|
+
/**
|
|
768
|
+
* The flag indicating whether to include values from storage.
|
|
769
|
+
* Defaults to true.
|
|
770
|
+
*/
|
|
771
|
+
includeStorage?: boolean
|
|
772
|
+
/**
|
|
773
|
+
* The flag indicating whether to include push bytes values.
|
|
774
|
+
* Defaults to true.
|
|
775
|
+
*/
|
|
776
|
+
includePushBytes?: boolean
|
|
777
|
+
/**
|
|
778
|
+
* The maximum number of attempts to shrink a failed the sequence. Shrink
|
|
779
|
+
* process is disabled if set to 0.
|
|
780
|
+
* Defaults to 5000.
|
|
781
|
+
*/
|
|
782
|
+
shrinkRunLimit?: number
|
|
783
|
+
}
|
|
784
|
+
/** Settings to configure caching of remote RPC endpoints. */
|
|
785
|
+
export interface StorageCachingConfig {
|
|
786
|
+
/**
|
|
787
|
+
* Chains to cache. Either all or none or a list of chain names, e.g.
|
|
788
|
+
* ["optimism", "mainnet"].
|
|
789
|
+
*/
|
|
790
|
+
chains: CachedChains | Array<string>
|
|
791
|
+
/** Endpoints to cache. Either all or remote or a regex. */
|
|
792
|
+
endpoints: CachedEndpoints | string
|
|
793
|
+
}
|
|
794
|
+
/** What chains to cache */
|
|
795
|
+
export enum CachedChains {
|
|
796
|
+
/** Cache all chains */
|
|
797
|
+
All = 0,
|
|
798
|
+
/** Don't cache anything */
|
|
799
|
+
None = 1
|
|
800
|
+
}
|
|
801
|
+
/** What endpoints to enable caching for */
|
|
802
|
+
export enum CachedEndpoints {
|
|
803
|
+
/** Cache all endpoints */
|
|
804
|
+
All = 0,
|
|
805
|
+
/** Only cache non-local host endpoints */
|
|
806
|
+
Remote = 1
|
|
807
|
+
}
|
|
808
|
+
/** Represents an access permission to a single path */
|
|
809
|
+
export interface PathPermission {
|
|
810
|
+
/** Permission level to access the `path` */
|
|
811
|
+
access: FsAccessPermission
|
|
812
|
+
/** The targeted path guarded by the permission */
|
|
813
|
+
path: string
|
|
814
|
+
}
|
|
815
|
+
/** Determines the status of file system access */
|
|
816
|
+
export enum FsAccessPermission {
|
|
817
|
+
/** FS access is allowed with `read` + `write` permission */
|
|
818
|
+
ReadWrite = 0,
|
|
819
|
+
/** Only reading is allowed */
|
|
820
|
+
Read = 1,
|
|
821
|
+
/** Only writing is allowed */
|
|
822
|
+
Write = 2
|
|
823
|
+
}
|
|
824
|
+
export interface AddressLabel {
|
|
825
|
+
/** The address to label */
|
|
826
|
+
address: Uint8Array
|
|
827
|
+
/** The label to assign to the address */
|
|
828
|
+
label: string
|
|
829
|
+
}
|
|
830
|
+
/**
|
|
831
|
+
* Configuration for [`SolidityTestRunnerConfigArgs::include_traces`] that
|
|
832
|
+
* controls execution trace decoding and inclusion in test results.
|
|
833
|
+
*/
|
|
834
|
+
export enum IncludeTraces {
|
|
835
|
+
/** No traces will be included in any test result. */
|
|
836
|
+
None = 0,
|
|
837
|
+
/** Traces will be included only on the results of failed tests. */
|
|
838
|
+
Failing = 1,
|
|
839
|
+
/** Traces will be included in all test results. */
|
|
840
|
+
All = 2
|
|
841
|
+
}
|
|
842
|
+
export declare function l1SolidityTestRunnerFactory(): SolidityTestRunnerFactory
|
|
843
|
+
export declare function opSolidityTestRunnerFactory(): SolidityTestRunnerFactory
|
|
844
|
+
/** The stack trace result */
|
|
845
|
+
export interface StackTrace {
|
|
846
|
+
/** Enum tag for JS. */
|
|
847
|
+
kind: "StackTrace"
|
|
848
|
+
/** The stack trace entries */
|
|
849
|
+
entries: Array<SolidityStackTraceEntry>
|
|
850
|
+
}
|
|
851
|
+
/** We couldn't generate stack traces, because an unexpected error occurred. */
|
|
852
|
+
export interface UnexpectedError {
|
|
853
|
+
/** Enum tag for JS. */
|
|
854
|
+
kind: "UnexpectedError"
|
|
855
|
+
/** The error message from the unexpected error. */
|
|
856
|
+
errorMessage: string
|
|
857
|
+
}
|
|
858
|
+
/**
|
|
859
|
+
* We couldn't generate stack traces, because the stack trace generation
|
|
860
|
+
* heuristics failed due to an unknown reason.
|
|
861
|
+
*/
|
|
862
|
+
export interface HeuristicFailed {
|
|
863
|
+
/** Enum tag for JS. */
|
|
864
|
+
kind: "HeuristicFailed"
|
|
865
|
+
}
|
|
866
|
+
/**
|
|
867
|
+
* We couldn't generate stack traces, because the test execution is unsafe to
|
|
868
|
+
* replay due to indeterminism. This can be caused by either specifying a fork
|
|
869
|
+
* url without a fork block number in the test runner config or using impure
|
|
870
|
+
* cheatcodes.
|
|
871
|
+
*/
|
|
872
|
+
export interface UnsafeToReplay {
|
|
873
|
+
/** Enum tag for JS. */
|
|
874
|
+
kind: "UnsafeToReplay"
|
|
875
|
+
/**
|
|
876
|
+
* Indeterminism due to specifying a fork url without a fork block number
|
|
877
|
+
* in the test runner config.
|
|
878
|
+
*/
|
|
879
|
+
globalForkLatest: boolean
|
|
880
|
+
/**
|
|
881
|
+
* The list of executed impure cheatcode signatures. We collect function
|
|
882
|
+
* signatures instead of function names as whether a cheatcode is impure
|
|
883
|
+
* can depend on the arguments it takes (e.g. `createFork` without a second
|
|
884
|
+
* argument means implicitly fork from “latest”). Example signature:
|
|
885
|
+
* `function createSelectFork(string calldata urlOrAlias) external returns
|
|
886
|
+
* (uint256 forkId);`.
|
|
887
|
+
*/
|
|
888
|
+
impureCheatcodes: Array<string>
|
|
889
|
+
}
|
|
890
|
+
/**The result of a test execution. */
|
|
891
|
+
export enum TestStatus {
|
|
892
|
+
/**Test success */
|
|
893
|
+
Success = 'Success',
|
|
894
|
+
/**Test failure */
|
|
895
|
+
Failure = 'Failure',
|
|
896
|
+
/**Test skipped */
|
|
897
|
+
Skipped = 'Skipped'
|
|
898
|
+
}
|
|
899
|
+
/** See [edr_solidity_tests::result::TestKind::Standard] */
|
|
900
|
+
export interface StandardTestKind {
|
|
901
|
+
/** The gas consumed by the test. */
|
|
902
|
+
readonly consumedGas: bigint
|
|
903
|
+
}
|
|
904
|
+
/** See [edr_solidity_tests::result::TestKind::Fuzz] */
|
|
905
|
+
export interface FuzzTestKind {
|
|
906
|
+
/** See [edr_solidity_tests::result::TestKind::Fuzz] */
|
|
907
|
+
readonly runs: bigint
|
|
908
|
+
/** See [edr_solidity_tests::result::TestKind::Fuzz] */
|
|
909
|
+
readonly meanGas: bigint
|
|
910
|
+
/** See [edr_solidity_tests::result::TestKind::Fuzz] */
|
|
911
|
+
readonly medianGas: bigint
|
|
912
|
+
}
|
|
913
|
+
/** See [edr_solidity_tests::fuzz::FuzzCase] */
|
|
914
|
+
export interface FuzzCase {
|
|
915
|
+
/** The calldata used for this fuzz test */
|
|
916
|
+
readonly calldata: Uint8Array
|
|
917
|
+
/** Consumed gas */
|
|
918
|
+
readonly gas: bigint
|
|
919
|
+
/** The initial gas stipend for the transaction */
|
|
920
|
+
readonly stipend: bigint
|
|
921
|
+
}
|
|
922
|
+
/** See [edr_solidity_tests::result::TestKind::Invariant] */
|
|
923
|
+
export interface InvariantTestKind {
|
|
924
|
+
/** See [edr_solidity_tests::result::TestKind::Invariant] */
|
|
925
|
+
readonly runs: bigint
|
|
926
|
+
/** See [edr_solidity_tests::result::TestKind::Invariant] */
|
|
927
|
+
readonly calls: bigint
|
|
928
|
+
/** See [edr_solidity_tests::result::TestKind::Invariant] */
|
|
929
|
+
readonly reverts: bigint
|
|
930
|
+
}
|
|
931
|
+
/**
|
|
932
|
+
* Original sequence size and sequence of calls used as a counter example
|
|
933
|
+
* for invariant tests.
|
|
934
|
+
*/
|
|
935
|
+
export interface CounterExampleSequence {
|
|
936
|
+
/** The original sequence size before shrinking. */
|
|
937
|
+
originalSequenceSize: bigint
|
|
938
|
+
/** The shrunk counterexample sequence. */
|
|
939
|
+
sequence: Array<BaseCounterExample>
|
|
940
|
+
}
|
|
941
|
+
/** See [edr_solidity_tests::fuzz::BaseCounterExample] */
|
|
942
|
+
export interface BaseCounterExample {
|
|
943
|
+
/** See [edr_solidity_tests::fuzz::BaseCounterExample::sender] */
|
|
944
|
+
readonly sender?: Uint8Array
|
|
945
|
+
/** See [edr_solidity_tests::fuzz::BaseCounterExample::addr] */
|
|
946
|
+
readonly address?: Uint8Array
|
|
947
|
+
/** See [edr_solidity_tests::fuzz::BaseCounterExample::calldata] */
|
|
948
|
+
readonly calldata: Uint8Array
|
|
949
|
+
/** See [edr_solidity_tests::fuzz::BaseCounterExample::contract_name] */
|
|
950
|
+
readonly contractName?: string
|
|
951
|
+
/** See [edr_solidity_tests::fuzz::BaseCounterExample::signature] */
|
|
952
|
+
readonly signature?: string
|
|
953
|
+
/** See [edr_solidity_tests::fuzz::BaseCounterExample::args] */
|
|
954
|
+
readonly args?: string
|
|
955
|
+
}
|
|
956
|
+
/**
|
|
957
|
+
* Object representing a call in an execution trace, including contract
|
|
958
|
+
* creation.
|
|
959
|
+
*/
|
|
960
|
+
export interface CallTrace {
|
|
961
|
+
/** The kind of call or contract creation this represents. */
|
|
962
|
+
kind: CallKind
|
|
963
|
+
/** Whether the call succeeded or reverted. */
|
|
964
|
+
success: boolean
|
|
965
|
+
/** Whether the call is a cheatcode. */
|
|
966
|
+
isCheatcode: boolean
|
|
967
|
+
/** The amount of gas that was consumed. */
|
|
968
|
+
gasUsed: bigint
|
|
969
|
+
/** The amount of native token that was included with the call. */
|
|
970
|
+
value: bigint
|
|
971
|
+
/**
|
|
972
|
+
* The target of the call. Provided as a contract name if known, otherwise
|
|
973
|
+
* a checksum address.
|
|
974
|
+
*/
|
|
975
|
+
contract: string
|
|
976
|
+
/**
|
|
977
|
+
* The input (calldata) to the call. If it encodes a known function call,
|
|
978
|
+
* it will be decoded into the function name and a list of arguments.
|
|
979
|
+
* For example, `{ name: "ownerOf", arguments: ["1"] }`. Note that the
|
|
980
|
+
* function name may also be any of the special `fallback` and `receive`
|
|
981
|
+
* functions. Otherwise, it will be provided as a raw byte array.
|
|
982
|
+
*/
|
|
983
|
+
inputs: DecodedTraceParameters | Uint8Array
|
|
984
|
+
/**
|
|
985
|
+
* The output of the call. This will be a decoded human-readable
|
|
986
|
+
* representation of the value if the function is known, otherwise a
|
|
987
|
+
* raw byte array.
|
|
988
|
+
*/
|
|
989
|
+
outputs: string | Uint8Array
|
|
990
|
+
/**
|
|
991
|
+
* Interleaved subcalls and event logs. Use `kind` to check if each member
|
|
992
|
+
* of the array is a call or log trace.
|
|
993
|
+
*/
|
|
994
|
+
children: Array<CallTrace | LogTrace>
|
|
995
|
+
}
|
|
996
|
+
/** Object representing an event log in an execution trace. */
|
|
997
|
+
export interface LogTrace {
|
|
998
|
+
/** A constant to help discriminate the union `CallTrace | LogTrace`. */
|
|
999
|
+
kind: LogKind
|
|
1000
|
+
/**
|
|
1001
|
+
* If the log is a known event (based on its first topic), it will be
|
|
1002
|
+
* decoded into the event name and list of named parameters. For
|
|
1003
|
+
* example, `{ name: "Log", arguments: ["value: 1"] }`. Otherwise, it
|
|
1004
|
+
* will be provided as an array where all but the last element are the
|
|
1005
|
+
* log topics, and the last element is the log data.
|
|
1006
|
+
*/
|
|
1007
|
+
parameters: DecodedTraceParameters | Array<Uint8Array>
|
|
1008
|
+
}
|
|
1009
|
+
/** The various kinds of call frames possible in the EVM. */
|
|
1010
|
+
export enum CallKind {
|
|
1011
|
+
/** Regular call that may change state. */
|
|
1012
|
+
Call = 0,
|
|
1013
|
+
/**
|
|
1014
|
+
* Variant of `DelegateCall` that doesn't preserve sender or value in the
|
|
1015
|
+
* frame.
|
|
1016
|
+
*/
|
|
1017
|
+
CallCode = 1,
|
|
1018
|
+
/** Call that executes the code of the target in the context of the caller. */
|
|
1019
|
+
DelegateCall = 2,
|
|
1020
|
+
/** Regular call that may not change state. */
|
|
1021
|
+
StaticCall = 3,
|
|
1022
|
+
/** Contract creation. */
|
|
1023
|
+
Create = 4
|
|
1024
|
+
}
|
|
1025
|
+
/** Kind marker for log traces. */
|
|
1026
|
+
export enum LogKind {
|
|
1027
|
+
/** Single kind of log. */
|
|
1028
|
+
Log = 5
|
|
1029
|
+
}
|
|
1030
|
+
/** Decoded function call or event. */
|
|
1031
|
+
export interface DecodedTraceParameters {
|
|
1032
|
+
/** The name of a function or an event. */
|
|
1033
|
+
name: string
|
|
1034
|
+
/**
|
|
1035
|
+
* The arguments of the function call or the event, in their human-readable
|
|
1036
|
+
* representations.
|
|
1037
|
+
*/
|
|
1038
|
+
arguments: Array<string>
|
|
1039
|
+
}
|
|
1040
|
+
/** Configuration for subscriptions. */
|
|
1041
|
+
export interface SubscriptionConfig {
|
|
1042
|
+
/** Callback to be called when a new event is received. */
|
|
1043
|
+
subscriptionCallback: (event: SubscriptionEvent) => void
|
|
373
1044
|
}
|
|
374
1045
|
export interface SubscriptionEvent {
|
|
375
1046
|
filterId: bigint
|
|
@@ -563,9 +1234,9 @@ export interface ContractCallRunOutOfGasError {
|
|
|
563
1234
|
}
|
|
564
1235
|
export interface TracingMessage {
|
|
565
1236
|
/** Sender address */
|
|
566
|
-
readonly caller:
|
|
1237
|
+
readonly caller: Uint8Array
|
|
567
1238
|
/** Recipient address. None if it is a Create message. */
|
|
568
|
-
readonly to?:
|
|
1239
|
+
readonly to?: Uint8Array
|
|
569
1240
|
/** Whether it's a static call */
|
|
570
1241
|
readonly isStaticCall: boolean
|
|
571
1242
|
/** Transaction gas limit */
|
|
@@ -573,16 +1244,16 @@ export interface TracingMessage {
|
|
|
573
1244
|
/** Depth of the message */
|
|
574
1245
|
readonly depth: number
|
|
575
1246
|
/** Input data of the message */
|
|
576
|
-
readonly data:
|
|
1247
|
+
readonly data: Uint8Array
|
|
577
1248
|
/** Value sent in the message */
|
|
578
1249
|
readonly value: bigint
|
|
579
1250
|
/**
|
|
580
1251
|
* Address of the code that is being executed. Can be different from `to`
|
|
581
1252
|
* if a delegate call is being done.
|
|
582
1253
|
*/
|
|
583
|
-
readonly codeAddress?:
|
|
1254
|
+
readonly codeAddress?: Uint8Array
|
|
584
1255
|
/** Code of the contract that is being executed. */
|
|
585
|
-
readonly code?:
|
|
1256
|
+
readonly code?: Uint8Array
|
|
586
1257
|
}
|
|
587
1258
|
export interface TracingStep {
|
|
588
1259
|
/** Call depth */
|
|
@@ -598,7 +1269,7 @@ export interface TracingStep {
|
|
|
598
1269
|
*/
|
|
599
1270
|
readonly stack: Array<bigint>
|
|
600
1271
|
/** The memory at the step. None if verbose tracing is disabled. */
|
|
601
|
-
readonly memory?:
|
|
1272
|
+
readonly memory?: Uint8Array
|
|
602
1273
|
}
|
|
603
1274
|
export interface TracingMessageResult {
|
|
604
1275
|
/** Execution result */
|
|
@@ -615,35 +1286,102 @@ export interface Withdrawal {
|
|
|
615
1286
|
/** The index of the validator that generated the withdrawal */
|
|
616
1287
|
validatorIndex: bigint
|
|
617
1288
|
/** The recipient address for withdrawal value */
|
|
618
|
-
address:
|
|
1289
|
+
address: Uint8Array
|
|
619
1290
|
/** The value contained in withdrawal */
|
|
620
1291
|
amount: bigint
|
|
621
1292
|
}
|
|
622
1293
|
export declare class EdrContext {
|
|
623
1294
|
/**Creates a new [`EdrContext`] instance. Should only be called once! */
|
|
624
1295
|
constructor()
|
|
1296
|
+
/**Constructs a new provider with the provided configuration. */
|
|
1297
|
+
createProvider(chainType: string, providerConfig: ProviderConfig, loggerConfig: LoggerConfig, subscriptionConfig: SubscriptionConfig, tracingConfig: TracingConfigWithBuffers): Promise<Provider>
|
|
1298
|
+
/**Registers a new provider factory for the provided chain type. */
|
|
1299
|
+
registerProviderFactory(chainType: string, factory: ProviderFactory): Promise<void>
|
|
1300
|
+
registerSolidityTestRunnerFactory(chainType: string, factory: SolidityTestRunnerFactory): Promise<void>
|
|
1301
|
+
/**
|
|
1302
|
+
*Executes Solidity tests.
|
|
1303
|
+
*
|
|
1304
|
+
*The function will return as soon as test execution is started.
|
|
1305
|
+
*The progress callback will be called with the results of each test
|
|
1306
|
+
*suite. It is up to the caller to track how many times the callback
|
|
1307
|
+
*is called to know when all tests are done.
|
|
1308
|
+
*/
|
|
1309
|
+
runSolidityTests(chainType: string, artifacts: Array<Artifact>, testSuites: Array<ArtifactId>, configArgs: SolidityTestRunnerConfigArgs, tracingConfig: TracingConfigWithBuffers, onTestSuiteCompletedCallback: (result: SuiteResult) => void): Promise<void>
|
|
1310
|
+
}
|
|
1311
|
+
export declare class Precompile {
|
|
1312
|
+
/** Returns the address of the precompile. */
|
|
1313
|
+
get address(): Uint8Array
|
|
1314
|
+
}
|
|
1315
|
+
export declare class ProviderFactory { }
|
|
1316
|
+
export declare class Response {
|
|
1317
|
+
/**Returns the response data as a JSON string or a JSON object. */
|
|
1318
|
+
get data(): string | any
|
|
1319
|
+
/**Compute the error stack trace. Return the stack trace if it can be decoded, otherwise returns none. Throws if there was an error computing the stack trace. */
|
|
1320
|
+
stackTrace(): SolidityStackTrace | null
|
|
1321
|
+
/**Returns the raw traces of executed contracts. This maybe contain zero or more traces. */
|
|
1322
|
+
get traces(): Array<RawTrace>
|
|
625
1323
|
}
|
|
626
1324
|
/** A JSON-RPC provider for Ethereum. */
|
|
627
1325
|
export declare class Provider {
|
|
628
|
-
/**Constructs a new provider with the provided configuration. */
|
|
629
|
-
static withConfig(context: EdrContext, config: ProviderConfig, loggerConfig: LoggerConfig, tracingConfig: TracingConfigWithBuffers, subscriberCallback: (event: SubscriptionEvent) => void): Promise<Provider>
|
|
630
1326
|
/**Handles a JSON-RPC request and returns a JSON-RPC response. */
|
|
631
|
-
handleRequest(
|
|
632
|
-
setCallOverrideCallback(callOverrideCallback: (contract_address:
|
|
1327
|
+
handleRequest(request: string): Promise<Response>
|
|
1328
|
+
setCallOverrideCallback(callOverrideCallback: (contract_address: ArrayBuffer, data: ArrayBuffer) => Promise<CallOverrideResult | undefined>): Promise<void>
|
|
633
1329
|
/**
|
|
634
1330
|
* Set to `true` to make the traces returned with `eth_call`,
|
|
635
1331
|
* `eth_estimateGas`, `eth_sendRawTransaction`, `eth_sendTransaction`,
|
|
636
1332
|
* `evm_mine`, `hardhat_mine` include the full stack and memory. Set to
|
|
637
1333
|
* `false` to disable this.
|
|
638
1334
|
*/
|
|
639
|
-
setVerboseTracing(verboseTracing: boolean): void
|
|
1335
|
+
setVerboseTracing(verboseTracing: boolean): Promise<void>
|
|
640
1336
|
}
|
|
641
|
-
export declare class
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
1337
|
+
export declare class SolidityTestRunnerFactory { }
|
|
1338
|
+
/** See [edr_solidity_tests::result::SuiteResult] */
|
|
1339
|
+
export declare class SuiteResult {
|
|
1340
|
+
/**
|
|
1341
|
+
* The artifact id can be used to match input to result in the progress
|
|
1342
|
+
* callback
|
|
1343
|
+
*/
|
|
1344
|
+
readonly id: ArtifactId
|
|
1345
|
+
/** See [edr_solidity_tests::result::SuiteResult::duration] */
|
|
1346
|
+
readonly durationNs: bigint
|
|
1347
|
+
/** See [edr_solidity_tests::result::SuiteResult::test_results] */
|
|
1348
|
+
readonly testResults: Array<TestResult>
|
|
1349
|
+
/** See [edr_solidity_tests::result::SuiteResult::warnings] */
|
|
1350
|
+
readonly warnings: Array<string>
|
|
1351
|
+
}
|
|
1352
|
+
/** See [edr_solidity_tests::result::TestResult] */
|
|
1353
|
+
export declare class TestResult {
|
|
1354
|
+
/** The name of the test. */
|
|
1355
|
+
readonly name: string
|
|
1356
|
+
/** See [edr_solidity_tests::result::TestResult::status] */
|
|
1357
|
+
readonly status: TestStatus
|
|
1358
|
+
/** See [edr_solidity_tests::result::TestResult::reason] */
|
|
1359
|
+
readonly reason?: string
|
|
1360
|
+
/** See [edr_solidity_tests::result::TestResult::counterexample] */
|
|
1361
|
+
readonly counterexample?: BaseCounterExample | CounterExampleSequence
|
|
1362
|
+
/** See [edr_solidity_tests::result::TestResult::decoded_logs] */
|
|
1363
|
+
readonly decodedLogs: Array<string>
|
|
1364
|
+
/** See [edr_solidity_tests::result::TestResult::kind] */
|
|
1365
|
+
readonly kind: StandardTestKind | FuzzTestKind | InvariantTestKind
|
|
1366
|
+
/** See [edr_solidity_tests::result::TestResult::duration] */
|
|
1367
|
+
readonly durationNs: bigint
|
|
1368
|
+
/**
|
|
1369
|
+
* Compute the error stack trace.
|
|
1370
|
+
* The result is either the stack trace or the reason why we couldn't
|
|
1371
|
+
* generate the stack trace.
|
|
1372
|
+
* Returns null if the test status is succeeded or skipped.
|
|
1373
|
+
* Cannot throw.
|
|
1374
|
+
*/
|
|
1375
|
+
stackTrace(): StackTrace | UnexpectedError | HeuristicFailed | UnsafeToReplay | null
|
|
1376
|
+
/**
|
|
1377
|
+
* Constructs the execution traces for the test. Returns an empty array if
|
|
1378
|
+
* traces for this test were not requested according to
|
|
1379
|
+
* [`crate::solidity_tests::config::SolidityTestRunnerConfigArgs::include_traces`]. Otherwise, returns
|
|
1380
|
+
* an array of the root calls of the trace, which always includes the test
|
|
1381
|
+
* call itself and may also include the setup call if there is one
|
|
1382
|
+
* (identified by the function name `setUp`).
|
|
1383
|
+
*/
|
|
1384
|
+
callTraces(): Array<CallTrace>
|
|
647
1385
|
}
|
|
648
1386
|
export declare class Exit {
|
|
649
1387
|
get kind(): ExitCode
|
|
@@ -665,5 +1403,5 @@ export declare class ReturnData {
|
|
|
665
1403
|
decodePanic(): bigint
|
|
666
1404
|
}
|
|
667
1405
|
export declare class RawTrace {
|
|
668
|
-
trace(): Array<TracingMessage | TracingStep | TracingMessageResult>
|
|
1406
|
+
get trace(): Array<TracingMessage | TracingStep | TracingMessageResult>
|
|
669
1407
|
}
|