@nomicfoundation/edr 0.10.0 → 0.12.0-alpha.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 CHANGED
@@ -1,36 +1,38 @@
1
1
  [package]
2
2
  name = "edr_napi"
3
3
  version = "0.3.5"
4
- edition = "2021"
4
+ edition.workspace = true
5
5
 
6
6
  [lib]
7
7
  crate-type = ["cdylib"]
8
8
 
9
9
  [dependencies]
10
- alloy-sol-types = { version = "0.5.1", default-features = false, features = ["std"] }
11
- ansi_term = { version = "0.12.1", default-features = false }
12
- itertools = { version = "0.12.0", default-features = false }
13
- k256 = { version = "0.13.1", default-features = false, features = ["arithmetic", "ecdsa", "pkcs8", "precomputed-tables", "std"] }
14
- # The `async` feature ensures that a tokio runtime is available
15
- napi = { version = "2.16.11", default-features = false, features = ["async", "error_anyhow", "napi8", "serde-json"] }
16
- napi-derive = "2.16.11"
17
- edr_defaults = { version = "0.3.5", path = "../edr_defaults" }
18
- edr_evm = { version = "0.3.5", path = "../edr_evm", features = ["tracing"] }
19
- edr_eth = { version = "0.3.5", path = "../edr_eth" }
20
- edr_provider = { version = "0.3.5", path = "../edr_provider" }
21
- edr_rpc_eth = { version = "0.3.5", path = "../edr_rpc_eth" }
22
- edr_solidity = { version = "0.3.5", path = "../edr_solidity" }
10
+ alloy-dyn-abi = { version = "0.8.22", default-features = false, features = ["eip712", "std"] }
11
+ alloy-json-abi = { version = "0.8.22", default-features = false }
12
+ alloy-sol-types = { version = "0.8.22", default-features = false, features = ["std"] }
13
+ derive-where = { version = "1.2.7", default-features = false }
14
+ edr_eth = { path = "../edr_eth" }
15
+ edr_evm = { path = "../edr_evm" }
16
+ edr_generic = { path = "../edr_generic" }
17
+ edr_napi_core = { path = "../edr_napi_core" }
18
+ edr_op = { path = "../edr_op", optional = true }
19
+ edr_provider = { path = "../edr_provider" }
20
+ edr_rpc_client = { path = "../edr_rpc_client" }
23
21
  edr_scenarios = { version = "0.3.5", path = "../edr_scenarios", optional = true }
24
- serde_json = { version = "1.0.85", default-features = false, features = ["alloc"] }
25
- thiserror = { version = "1.0.37", default-features = false }
26
- tracing = { version = "0.1.37", default-features = false, features = ["std"] }
27
- tracing-flame = { version = "0.2.0", default-features = false, features = ["smallvec"] }
28
- tracing-subscriber = { version = "0.3.18", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec", "std"] }
22
+ edr_solidity ={ version = "0.3.5", path = "../edr_solidity" }
23
+ k256 = { version = "0.13.1", default-features = false, features = ["arithmetic", "ecdsa", "pkcs8" ] }
24
+ mimalloc = { version = "0.1.39", default-features = false, features = ["local_dynamic_tls"] }
25
+ # The `async` feature ensures that a tokio runtime is available
26
+ napi = { version = "2.16.17", default-features = false, features = ["async", "error_anyhow", "napi8", "serde-json"] }
27
+ napi-derive = "2.16.13"
29
28
  rand = { version = "0.8.4", optional = true }
30
- serde = { version = "1.0.189", features = ["derive"] }
29
+ serde = { version = "1.0.209", features = ["derive"] }
30
+ serde_json = { version = "1.0.127" }
31
31
  static_assertions = "1.1.0"
32
32
  strum = { version = "0.26.0", features = ["derive"] }
33
- mimalloc = { version = "0.1.39", default-features = false, features = ["local_dynamic_tls"] }
33
+ tracing = { version = "0.1.37", default-features = false, features = ["std"] }
34
+ tracing-flame = { version = "0.2.0", default-features = false, features = ["smallvec"] }
35
+ tracing-subscriber = { version = "0.3.18", default-features = false, features = ["ansi", "env-filter", "fmt", "parking_lot", "smallvec", "std"] }
34
36
 
35
37
  [target.x86_64-unknown-linux-gnu.dependencies]
36
38
  openssl-sys = { version = "0.9.93", features = ["vendored"] }
@@ -48,8 +50,9 @@ openssl-sys = { version = "0.9.93", features = ["vendored"] }
48
50
  napi-build = "2.0.1"
49
51
 
50
52
  [features]
51
- tracing = ["edr_evm/tracing", "edr_provider/tracing"]
52
- scenarios = ["rand", "edr_scenarios"]
53
+ op = ["dep:edr_op"]
54
+ scenarios = ["dep:edr_scenarios", "dep:rand"]
55
+ tracing = ["edr_evm/tracing", "edr_napi_core/tracing", "edr_provider/tracing"]
53
56
 
54
57
  [profile.release]
55
58
  lto = true
package/index.d.ts CHANGED
@@ -3,8 +3,31 @@
3
3
 
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
- /** An account that needs to be created during the genesis block. */
7
- export interface GenesisAccount {
6
+ /** A description of an account's state. */
7
+ export interface Account {
8
+ /** The account's address */
9
+ address: Uint8Array
10
+ /** The account's balance */
11
+ balance: bigint
12
+ /** The account's nonce */
13
+ nonce: bigint
14
+ /** The account's code */
15
+ code?: Uint8Array
16
+ /** The account's storage */
17
+ storage: Array<StorageSlot>
18
+ }
19
+ /** A description of a storage slot's state. */
20
+ export interface StorageSlot {
21
+ /** The storage slot's index */
22
+ index: bigint
23
+ /** The storage slot's value */
24
+ value: bigint
25
+ }
26
+ /**
27
+ * An owned account, for which the secret key is known, and its desired genesis
28
+ * balance.
29
+ */
30
+ export interface OwnedAccount {
8
31
  /** Account secret key */
9
32
  secretKey: string
10
33
  /** Account balance */
@@ -69,8 +92,13 @@ export interface CallOverrideResult {
69
92
  result: Buffer
70
93
  shouldRevert: boolean
71
94
  }
95
+ export const GENERIC_CHAIN_TYPE: string
96
+ export declare function genericChainProviderFactory(): ProviderFactory
97
+ export const L1_CHAIN_TYPE: string
98
+ export declare function l1GenesisState(hardfork: SpecId): Array<Account>
99
+ export declare function l1ProviderFactory(): ProviderFactory
72
100
  /** Identifier for the Ethereum spec. */
73
- export const enum SpecId {
101
+ export enum SpecId {
74
102
  /** Frontier */
75
103
  Frontier = 0,
76
104
  /** Frontier Thawing */
@@ -108,57 +136,40 @@ export const enum SpecId {
108
136
  /** Cancun */
109
137
  Cancun = 17,
110
138
  /** 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
155
- }
156
- export interface LoggerConfig {
157
- /** Whether to enable the logger. */
158
- enable: boolean
159
- decodeConsoleLogInputsCallback: (inputs: Buffer[]) => string[]
160
- printLineCallback: (message: string, replace: boolean) => void
139
+ Prague = 18
161
140
  }
141
+ /**
142
+ * Tries to parse the provided string to create a [`SpecId`] instance.
143
+ *
144
+ * Returns an error if the string does not match any known hardfork.
145
+ */
146
+ export declare function l1HardforkFromString(hardfork: string): SpecId
147
+ export declare function l1HardforkToString(harfork: SpecId): 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 l1HardforkLatest(): SpecId
154
+ export const FRONTIER: string
155
+ export const FRONTIER_THAWING: string
156
+ export const HOMESTEAD: string
157
+ export const DAO_FORK: string
158
+ export const TANGERINE: string
159
+ export const SPURIOUS_DRAGON: string
160
+ export const BYZANTIUM: string
161
+ export const CONSTANTINOPLE: string
162
+ export const PETERSBURG: string
163
+ export const ISTANBUL: string
164
+ export const MUIR_GLACIER: string
165
+ export const BERLIN: string
166
+ export const LONDON: string
167
+ export const ARROW_GLACIER: string
168
+ export const GRAY_GLACIER: string
169
+ export const MERGE: string
170
+ export const SHANGHAI: string
171
+ export const CANCUN: string
172
+ export const PRAGUE: string
162
173
  /** Configuration for a chain */
163
174
  export interface ChainConfig {
164
175
  /** The chain ID */
@@ -187,10 +198,10 @@ export interface HardforkActivation {
187
198
  /** The block number at which the hardfork is activated */
188
199
  blockNumber: bigint
189
200
  /** The activated hardfork */
190
- specId: SpecId
201
+ specId: string
191
202
  }
192
203
  /**The type of ordering to use when selecting blocks to mine. */
193
- export const enum MineOrdering {
204
+ export enum MineOrdering {
194
205
  /**Insertion order */
195
206
  Fifo = 'Fifo',
196
207
  /**Effective miner fee */
@@ -237,10 +248,10 @@ export interface ProviderConfig {
237
248
  * blockchain will be created
238
249
  */
239
250
  fork?: ForkConfig
240
- /** The genesis accounts of the blockchain */
241
- genesisAccounts: Array<GenesisAccount>
251
+ /** The genesis state of the blockchain */
252
+ genesisState: Array<Account>
242
253
  /** The hardfork of the blockchain */
243
- hardfork: SpecId
254
+ hardfork: string
244
255
  /**
245
256
  * The initial base fee per gas of the blockchain. Required for EIP-1559
246
257
  * transactions and later
@@ -261,6 +272,8 @@ export interface ProviderConfig {
261
272
  mining: MiningConfig
262
273
  /** The network ID of the blockchain */
263
274
  networkId: bigint
275
+ /** Owned accounts, for which the secret key is known */
276
+ ownedAccounts: Array<OwnedAccount>
264
277
  }
265
278
  /** Tracing config for Solidity stack trace generation. */
266
279
  export interface TracingConfigWithBuffers {
@@ -283,8 +296,55 @@ export interface BuildInfoAndOutput {
283
296
  /** The build info output file */
284
297
  output: Uint8Array
285
298
  }
299
+ export interface DebugTraceResult {
300
+ pass: boolean
301
+ gasUsed: bigint
302
+ output?: Buffer
303
+ structLogs: Array<DebugTraceLogItem>
304
+ }
305
+ export interface DebugTraceLogItem {
306
+ /** Program Counter */
307
+ pc: bigint
308
+ op: number
309
+ /** Gas left before executing this operation as hex number. */
310
+ gas: string
311
+ /** Gas cost of this operation as hex number. */
312
+ gasCost: string
313
+ /** Array of all values (hex numbers) on the stack */
314
+ stack?: Array<string>
315
+ /** Depth of the call stack */
316
+ depth: bigint
317
+ /** Size of memory array */
318
+ memSize: bigint
319
+ /** Name of the operation */
320
+ opName: string
321
+ /** Description of an error as a hex string. */
322
+ error?: string
323
+ /** Array of all allocated values as hex strings. */
324
+ memory?: Array<string>
325
+ /** Map of all stored values with keys and values encoded as hex strings. */
326
+ storage?: Record<string, string>
327
+ }
328
+ /** Ethereum execution log. */
329
+ export interface ExecutionLog {
330
+ address: Buffer
331
+ topics: Array<Buffer>
332
+ data: Buffer
333
+ }
334
+ export interface ContractAndFunctionName {
335
+ /** The contract name. */
336
+ contractName: string
337
+ /** The function name. Only present for calls. */
338
+ functionName?: string
339
+ }
340
+ export interface LoggerConfig {
341
+ /** Whether to enable the logger. */
342
+ enable: boolean
343
+ decodeConsoleLogInputsCallback: (inputs: Buffer[]) => string[]
344
+ printLineCallback: (message: string, replace: boolean) => void
345
+ }
286
346
  /** The possible reasons for successful termination of the EVM. */
287
- export const enum SuccessReason {
347
+ export enum SuccessReason {
288
348
  /** The opcode `STOP` was called */
289
349
  Stop = 0,
290
350
  /** The opcode `RETURN` was called */
@@ -327,7 +387,7 @@ export interface RevertResult {
327
387
  * Indicates that the EVM has experienced an exceptional halt. This causes
328
388
  * execution to immediately end with all gas being consumed.
329
389
  */
330
- export const enum ExceptionalHalt {
390
+ export enum ExceptionalHalt {
331
391
  OutOfGas = 0,
332
392
  OpcodeNotFound = 1,
333
393
  InvalidFEOpcode = 2,
@@ -350,7 +410,7 @@ export const enum ExceptionalHalt {
350
410
  /** Aud data is smaller then already present data size. */
351
411
  EofAuxDataTooSmall = 15,
352
412
  /** EOF Subroutine stack overflow */
353
- EOFFunctionStackOverflow = 16,
413
+ SubRoutineStackOverflow = 16,
354
414
  /** Check for target address validity is only done inside subcall. */
355
415
  InvalidEXTCALLTarget = 17
356
416
  }
@@ -371,6 +431,11 @@ export interface ExecutionResult {
371
431
  /** Optional contract address if the transaction created a new contract. */
372
432
  contractAddress?: Buffer
373
433
  }
434
+ /** Configuration for subscriptions. */
435
+ export interface SubscriptionConfig {
436
+ /** Callback to be called when a new event is received. */
437
+ subscriptionCallback: (event: SubscriptionEvent) => void
438
+ }
374
439
  export interface SubscriptionEvent {
375
440
  filterId: bigint
376
441
  result: any
@@ -378,7 +443,7 @@ export interface SubscriptionEvent {
378
443
  export declare function linkHexStringBytecode(code: string, address: string, position: number): string
379
444
  export declare function printStackTrace(trace: SolidityStackTrace): void
380
445
  /** Represents the exit code of the EVM. */
381
- export const enum ExitCode {
446
+ export enum ExitCode {
382
447
  /** Execution was successful. */
383
448
  SUCCESS = 0,
384
449
  /** Execution was reverted. */
@@ -398,7 +463,7 @@ export const enum ExitCode {
398
463
  /** Unknown halt reason. */
399
464
  UNKNOWN_HALT_REASON = 8
400
465
  }
401
- export const enum ContractFunctionType {
466
+ export enum ContractFunctionType {
402
467
  CONSTRUCTOR = 0,
403
468
  FUNCTION = 1,
404
469
  FALLBACK = 2,
@@ -407,7 +472,7 @@ export const enum ContractFunctionType {
407
472
  MODIFIER = 5,
408
473
  FREE_FUNCTION = 6
409
474
  }
410
- export const enum StackTraceEntryType {
475
+ export enum StackTraceEntryType {
411
476
  CALLSTACK_ENTRY = 0,
412
477
  UNRECOGNIZED_CREATE_CALLSTACK_ENTRY = 1,
413
478
  UNRECOGNIZED_CONTRACT_CALLSTACK_ENTRY = 2,
@@ -622,28 +687,32 @@ export interface Withdrawal {
622
687
  export declare class EdrContext {
623
688
  /**Creates a new [`EdrContext`] instance. Should only be called once! */
624
689
  constructor()
690
+ /**Constructs a new provider with the provided configuration. */
691
+ createProvider(chainType: string, providerConfig: ProviderConfig, loggerConfig: LoggerConfig, subscriptionConfig: SubscriptionConfig, tracingConfig: TracingConfigWithBuffers): Promise<Provider>
692
+ /**Registers a new provider factory for the provided chain type. */
693
+ registerProviderFactory(chainType: string, factory: ProviderFactory): Promise<void>
694
+ }
695
+ export declare class ProviderFactory { }
696
+ export declare class Response {
697
+ /**Returns the response data as a JSON string or a JSON object. */
698
+ get data(): string | any
699
+ /**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. */
700
+ stackTrace(): SolidityStackTrace | null
701
+ /**Returns the raw traces of executed contracts. This maybe contain zero or more traces. */
702
+ get traces(): Array<RawTrace>
625
703
  }
626
704
  /** A JSON-RPC provider for Ethereum. */
627
705
  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
706
  /**Handles a JSON-RPC request and returns a JSON-RPC response. */
631
- handleRequest(jsonRequest: string): Promise<Response>
632
- setCallOverrideCallback(callOverrideCallback: (contract_address: Buffer, data: Buffer) => Promise<CallOverrideResult | undefined>): void
707
+ handleRequest(request: string): Promise<Response>
708
+ setCallOverrideCallback(callOverrideCallback: (contract_address: Buffer, data: Buffer) => Promise<CallOverrideResult | undefined>): Promise<void>
633
709
  /**
634
710
  * Set to `true` to make the traces returned with `eth_call`,
635
711
  * `eth_estimateGas`, `eth_sendRawTransaction`, `eth_sendTransaction`,
636
712
  * `evm_mine`, `hardhat_mine` include the full stack and memory. Set to
637
713
  * `false` to disable this.
638
714
  */
639
- setVerboseTracing(verboseTracing: boolean): void
640
- }
641
- export declare class Response {
642
- /** Returns the response data as a JSON string or a JSON object. */
643
- get data(): string | any
644
- get traces(): Array<RawTrace>
645
- /**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. */
646
- stackTrace(): SolidityStackTrace | null
715
+ setVerboseTracing(verboseTracing: boolean): Promise<void>
647
716
  }
648
717
  export declare class Exit {
649
718
  get kind(): ExitCode
package/index.js CHANGED
@@ -310,13 +310,41 @@ if (!nativeBinding) {
310
310
  throw new Error(`Failed to load native binding`)
311
311
  }
312
312
 
313
- const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, linkHexStringBytecode, printStackTrace, Exit, ExitCode, BytecodeWrapper, ContractFunctionType, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, RawTrace, getLatestSupportedSolcVersion } = nativeBinding
313
+ const { GENERIC_CHAIN_TYPE, genericChainProviderFactory, L1_CHAIN_TYPE, l1GenesisState, l1ProviderFactory, SpecId, l1HardforkFromString, l1HardforkToString, l1HardforkLatest, FRONTIER, FRONTIER_THAWING, HOMESTEAD, DAO_FORK, TANGERINE, SPURIOUS_DRAGON, BYZANTIUM, CONSTANTINOPLE, PETERSBURG, ISTANBUL, MUIR_GLACIER, BERLIN, LONDON, ARROW_GLACIER, GRAY_GLACIER, MERGE, SHANGHAI, CANCUN, PRAGUE, MineOrdering, EdrContext, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, linkHexStringBytecode, printStackTrace, Exit, ExitCode, BytecodeWrapper, ContractFunctionType, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, RawTrace, getLatestSupportedSolcVersion } = nativeBinding
314
314
 
315
+ module.exports.GENERIC_CHAIN_TYPE = GENERIC_CHAIN_TYPE
316
+ module.exports.genericChainProviderFactory = genericChainProviderFactory
317
+ module.exports.L1_CHAIN_TYPE = L1_CHAIN_TYPE
318
+ module.exports.l1GenesisState = l1GenesisState
319
+ module.exports.l1ProviderFactory = l1ProviderFactory
315
320
  module.exports.SpecId = SpecId
316
- module.exports.EdrContext = EdrContext
321
+ module.exports.l1HardforkFromString = l1HardforkFromString
322
+ module.exports.l1HardforkToString = l1HardforkToString
323
+ module.exports.l1HardforkLatest = l1HardforkLatest
324
+ module.exports.FRONTIER = FRONTIER
325
+ module.exports.FRONTIER_THAWING = FRONTIER_THAWING
326
+ module.exports.HOMESTEAD = HOMESTEAD
327
+ module.exports.DAO_FORK = DAO_FORK
328
+ module.exports.TANGERINE = TANGERINE
329
+ module.exports.SPURIOUS_DRAGON = SPURIOUS_DRAGON
330
+ module.exports.BYZANTIUM = BYZANTIUM
331
+ module.exports.CONSTANTINOPLE = CONSTANTINOPLE
332
+ module.exports.PETERSBURG = PETERSBURG
333
+ module.exports.ISTANBUL = ISTANBUL
334
+ module.exports.MUIR_GLACIER = MUIR_GLACIER
335
+ module.exports.BERLIN = BERLIN
336
+ module.exports.LONDON = LONDON
337
+ module.exports.ARROW_GLACIER = ARROW_GLACIER
338
+ module.exports.GRAY_GLACIER = GRAY_GLACIER
339
+ module.exports.MERGE = MERGE
340
+ module.exports.SHANGHAI = SHANGHAI
341
+ module.exports.CANCUN = CANCUN
342
+ module.exports.PRAGUE = PRAGUE
317
343
  module.exports.MineOrdering = MineOrdering
318
- module.exports.Provider = Provider
344
+ module.exports.EdrContext = EdrContext
345
+ module.exports.ProviderFactory = ProviderFactory
319
346
  module.exports.Response = Response
347
+ module.exports.Provider = Provider
320
348
  module.exports.SuccessReason = SuccessReason
321
349
  module.exports.ExceptionalHalt = ExceptionalHalt
322
350
  module.exports.linkHexStringBytecode = linkHexStringBytecode
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@nomicfoundation/edr",
3
- "version": "0.10.0",
3
+ "version": "0.12.0-alpha.0",
4
4
  "devDependencies": {
5
5
  "@napi-rs/cli": "^2.18.4",
6
+ "@nomicfoundation/ethereumjs-util": "^9.0.4",
6
7
  "@types/chai": "^4.2.0",
7
8
  "@types/chai-as-promised": "^7.1.8",
8
9
  "@types/mocha": ">=9.1.0",
@@ -52,28 +53,29 @@
52
53
  "repository": "NomicFoundation/edr.git",
53
54
  "types": "index.d.ts",
54
55
  "dependencies": {
55
- "@nomicfoundation/edr-darwin-arm64": "0.10.0",
56
- "@nomicfoundation/edr-darwin-x64": "0.10.0",
57
- "@nomicfoundation/edr-linux-arm64-gnu": "0.10.0",
58
- "@nomicfoundation/edr-linux-arm64-musl": "0.10.0",
59
- "@nomicfoundation/edr-linux-x64-gnu": "0.10.0",
60
- "@nomicfoundation/edr-linux-x64-musl": "0.10.0",
61
- "@nomicfoundation/edr-win32-x64-msvc": "0.10.0"
56
+ "@nomicfoundation/edr-darwin-arm64": "0.12.0-alpha.0",
57
+ "@nomicfoundation/edr-darwin-x64": "0.12.0-alpha.0",
58
+ "@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-alpha.0",
59
+ "@nomicfoundation/edr-linux-arm64-musl": "0.12.0-alpha.0",
60
+ "@nomicfoundation/edr-linux-x64-gnu": "0.12.0-alpha.0",
61
+ "@nomicfoundation/edr-linux-x64-musl": "0.12.0-alpha.0",
62
+ "@nomicfoundation/edr-win32-x64-msvc": "0.12.0-alpha.0"
62
63
  },
63
64
  "scripts": {
64
65
  "artifacts": "napi artifacts",
65
- "build": "napi build --platform --release",
66
- "build:debug": "napi build --platform",
67
- "build:scenarios": "napi build --platform --release --features scenarios",
68
- "build:tracing": "napi build --platform --release --features tracing",
66
+ "build": "napi build --platform --release --no-const-enum",
67
+ "build:debug": "napi build --platform --no-const-enum",
68
+ "build:op": "napi build --platform --release --no-const-enum --features op",
69
+ "build:scenarios": "napi build --platform --release --no-const-enum --features scenarios",
70
+ "build:tracing": "napi build --platform --release --no-const-enum --features tracing",
69
71
  "clean": "rm -rf @nomicfoundation/edr.node",
70
72
  "eslint": "eslint 'test/**/*.ts'",
71
73
  "lint": "pnpm run prettier && pnpm run eslint",
72
74
  "lint:fix": "pnpm run prettier --write",
73
- "pretest": "pnpm build",
75
+ "pretest": "pnpm build:op",
74
76
  "prettier": "prettier --check \"test/**.ts\"",
75
77
  "test": "pnpm tsc && node --max-old-space-size=8192 node_modules/mocha/bin/_mocha --recursive \"test/**/*.ts\"",
76
- "testNoBuild": "pnpm tsc && node --max-old-space-size=8192 node_modules/mocha/bin/_mocha --recursive \"test/**/*.ts\"",
78
+ "testNoBuild": "pnpm tsc && node --max-old-space-size=8192 node_modules/mocha/bin/_mocha --recursive \"test/**/{,!(op)}.ts\"",
77
79
  "universal": "napi universal",
78
80
  "version": "napi version"
79
81
  }
package/src/account.rs CHANGED
@@ -1,18 +1,43 @@
1
- use std::fmt::{Debug, Display};
1
+ use core::fmt::{Debug, Display};
2
2
 
3
- #[allow(deprecated)]
4
- // This is the only source file in production code where it's allowed to create
5
- // `DangerousSecretKeyStr`.
6
- use edr_eth::signature::{secret_key_from_str, DangerousSecretKeyStr};
7
- use napi::{bindgen_prelude::BigInt, JsString, Status};
3
+ use edr_eth::signature::secret_key_from_str;
4
+ use napi::{
5
+ JsString, Status,
6
+ bindgen_prelude::{BigInt, Uint8Array},
7
+ };
8
8
  use napi_derive::napi;
9
9
  use serde::Serialize;
10
10
 
11
- use crate::cast::TryCast;
11
+ use crate::cast::TryCast as _;
12
12
 
13
- /// An account that needs to be created during the genesis block.
13
+ /// A description of an account's state.
14
14
  #[napi(object)]
15
- pub struct GenesisAccount {
15
+ pub struct Account {
16
+ /// The account's address
17
+ pub address: Uint8Array,
18
+ /// The account's balance
19
+ pub balance: BigInt,
20
+ /// The account's nonce
21
+ pub nonce: BigInt,
22
+ /// The account's code
23
+ pub code: Option<Uint8Array>,
24
+ /// The account's storage
25
+ pub storage: Vec<StorageSlot>,
26
+ }
27
+
28
+ /// A description of a storage slot's state.
29
+ #[napi(object)]
30
+ pub struct StorageSlot {
31
+ /// The storage slot's index
32
+ pub index: BigInt,
33
+ /// The storage slot's value
34
+ pub value: BigInt,
35
+ }
36
+
37
+ /// An owned account, for which the secret key is known, and its desired genesis
38
+ /// balance.
39
+ #[napi(object)]
40
+ pub struct OwnedAccount {
16
41
  // Using JsString here as it doesn't have `Debug`, `Display` and `Serialize` implementation
17
42
  // which prevents accidentally leaking the secret keys to error messages and logs.
18
43
  /// Account secret key
@@ -21,10 +46,15 @@ pub struct GenesisAccount {
21
46
  pub balance: BigInt,
22
47
  }
23
48
 
24
- impl TryFrom<GenesisAccount> for edr_provider::AccountConfig {
49
+ impl TryFrom<OwnedAccount> for edr_provider::config::OwnedAccount {
25
50
  type Error = napi::Error;
26
51
 
27
- fn try_from(value: GenesisAccount) -> Result<Self, Self::Error> {
52
+ fn try_from(value: OwnedAccount) -> Result<Self, Self::Error> {
53
+ // This is the only place in production code where it's allowed to use
54
+ // `DangerousSecretKeyStr`.
55
+ #[allow(deprecated)]
56
+ use edr_eth::signature::DangerousSecretKeyStr;
57
+
28
58
  static_assertions::assert_not_impl_all!(JsString: Debug, Display, Serialize);
29
59
  // `k256::SecretKey` has `Debug` implementation, but it's opaque (only shows the
30
60
  // type name)
package/src/block.rs CHANGED
@@ -1,4 +1,4 @@
1
- use edr_eth::{Address, Bytes, B256, B64};
1
+ use edr_eth::{Address, B64, B256, Bytes};
2
2
  use napi::bindgen_prelude::{BigInt, Buffer};
3
3
  use napi_derive::napi;
4
4
 
@@ -2,12 +2,12 @@ use std::sync::mpsc::channel;
2
2
 
3
3
  use edr_eth::{Address, Bytes};
4
4
  use napi::{
5
+ Env, JsFunction, Status,
5
6
  bindgen_prelude::{Buffer, Promise},
6
7
  threadsafe_function::{
7
8
  ErrorStrategy, ThreadSafeCallContext, ThreadsafeFunction, ThreadsafeFunctionCallMode,
8
9
  },
9
10
  tokio::runtime,
10
- Env, JsFunction, Status,
11
11
  };
12
12
  use napi_derive::napi;
13
13