@nomicfoundation/edr 0.5.2 → 0.6.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
@@ -7,9 +7,13 @@ edition = "2021"
7
7
  crate-type = ["cdylib"]
8
8
 
9
9
  [dependencies]
10
+ alloy-dyn-abi = { version = "0.7.6", default-features = false }
11
+ alloy-json-abi = { version = "0.7.4", default-features = false }
12
+ alloy-sol-types = { version = "0.5.1", default-features = false, features = ["std"] }
10
13
  ansi_term = { version = "0.12.1", default-features = false }
11
14
  crossbeam-channel = { version = "0.5.6", default-features = false }
12
15
  itertools = { version = "0.12.0", default-features = false }
16
+ indexmap = { version = "2" }
13
17
  k256 = { version = "0.13.1", default-features = false, features = ["arithmetic", "ecdsa", "pkcs8", "precomputed-tables", "std"] }
14
18
  log = { version = "0.4.20", default-features = false }
15
19
  # when napi is pinned, be sure to pin napi-derive to the same version
@@ -21,6 +25,7 @@ edr_evm = { version = "0.3.5", path = "../edr_evm", features = ["tracing"]}
21
25
  edr_eth = { version = "0.3.5", path = "../edr_eth" }
22
26
  edr_provider = { version = "0.3.5", path = "../edr_provider" }
23
27
  edr_rpc_eth = { version = "0.3.5", path = "../edr_rpc_eth" }
28
+ edr_solidity ={ version = "0.3.5", path = "../edr_solidity" }
24
29
  serde_json = { version = "1.0.85", default-features = false, features = ["alloc"] }
25
30
  thiserror = { version = "1.0.37", default-features = false }
26
31
  tracing = { version = "0.1.37", default-features = false, features = ["std"] }
@@ -29,7 +34,9 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
29
34
  parking_lot = { version = "0.12.1", default-features = false }
30
35
  lazy_static = { version = "1.4.0", features = [] }
31
36
  rand = { version = "0.8.4", optional = true }
37
+ semver = "1.0.22"
32
38
  serde = { version = "1.0.189", features = ["derive"] }
39
+ strum = { version = "0.26.0", features = ["derive"] }
33
40
  mimalloc = { version = "0.1.39", default-features = false, features = ["local_dynamic_tls"] }
34
41
 
35
42
  [target.x86_64-unknown-linux-gnu.dependencies]
package/index.d.ts CHANGED
@@ -149,6 +149,7 @@ export interface LoggerConfig {
149
149
  /** Whether to enable the logger. */
150
150
  enable: boolean
151
151
  decodeConsoleLogInputsCallback: (inputs: Buffer[]) => string[]
152
+ /** Used to resolve the contract and function name when logging. */
152
153
  getContractAndFunctionNameCallback: (code: Buffer, calldata?: Buffer) => ContractAndFunctionName
153
154
  printLineCallback: (message: string, replace: boolean) => void
154
155
  }
@@ -345,6 +346,243 @@ export interface SubscriptionEvent {
345
346
  filterId: bigint
346
347
  result: any
347
348
  }
349
+ export function createModelsAndDecodeBytecodes(solcVersion: string, compilerInput: any, compilerOutput: any): Array<BytecodeWrapper>
350
+ export function linkHexStringBytecode(code: string, address: string, position: number): string
351
+ export const enum ContractFunctionType {
352
+ CONSTRUCTOR = 0,
353
+ FUNCTION = 1,
354
+ FALLBACK = 2,
355
+ RECEIVE = 3,
356
+ GETTER = 4,
357
+ MODIFIER = 5,
358
+ FREE_FUNCTION = 6
359
+ }
360
+ export function printMessageTrace(trace: PrecompileMessageTrace | CallMessageTrace | CreateMessageTrace, depth?: number | undefined | null): void
361
+ export function printStackTrace(trace: SolidityStackTrace): void
362
+ /** Represents the exit code of the EVM. */
363
+ export const enum ExitCode {
364
+ /** Execution was successful. */
365
+ SUCCESS = 0,
366
+ /** Execution was reverted. */
367
+ REVERT = 1,
368
+ /** Execution ran out of gas. */
369
+ OUT_OF_GAS = 2,
370
+ /** Execution encountered an internal error. */
371
+ INTERNAL_ERROR = 3,
372
+ /** Execution encountered an invalid opcode. */
373
+ INVALID_OPCODE = 4,
374
+ /** Execution encountered a stack underflow. */
375
+ STACK_UNDERFLOW = 5,
376
+ /** Create init code size exceeds limit (runtime). */
377
+ CODESIZE_EXCEEDS_MAXIMUM = 6,
378
+ /** Create collision. */
379
+ CREATE_COLLISION = 7
380
+ }
381
+ export interface EvmStep {
382
+ pc: number
383
+ }
384
+ export interface PrecompileMessageTrace {
385
+ value: bigint
386
+ returnData: Uint8Array
387
+ exit: Exit
388
+ gasUsed: bigint
389
+ depth: number
390
+ precompile: number
391
+ calldata: Uint8Array
392
+ }
393
+ export interface CreateMessageTrace {
394
+ value: bigint
395
+ returnData: Uint8Array
396
+ exit: Exit
397
+ gasUsed: bigint
398
+ depth: number
399
+ code: Uint8Array
400
+ steps: Array<EvmStep | PrecompileMessageTrace | CallMessageTrace | CreateMessageTrace>
401
+ /**
402
+ * Reference to the resolved `Bytecode` EDR data.
403
+ * Only used on the JS side by the `VmTraceDecoder` class.
404
+ */
405
+ bytecode?: BytecodeWrapper
406
+ numberOfSubtraces: number
407
+ deployedContract?: Uint8Array | undefined
408
+ }
409
+ export interface CallMessageTrace {
410
+ value: bigint
411
+ returnData: Uint8Array
412
+ exit: Exit
413
+ gasUsed: bigint
414
+ depth: number
415
+ code: Uint8Array
416
+ steps: Array<EvmStep | PrecompileMessageTrace | CallMessageTrace | CreateMessageTrace>
417
+ /**
418
+ * Reference to the resolved `Bytecode` EDR data.
419
+ * Only used on the JS side by the `VmTraceDecoder` class.
420
+ */
421
+ bytecode?: BytecodeWrapper
422
+ numberOfSubtraces: number
423
+ calldata: Uint8Array
424
+ address: Uint8Array
425
+ codeAddress: Uint8Array
426
+ }
427
+ export const enum StackTraceEntryType {
428
+ CALLSTACK_ENTRY = 0,
429
+ UNRECOGNIZED_CREATE_CALLSTACK_ENTRY = 1,
430
+ UNRECOGNIZED_CONTRACT_CALLSTACK_ENTRY = 2,
431
+ PRECOMPILE_ERROR = 3,
432
+ REVERT_ERROR = 4,
433
+ PANIC_ERROR = 5,
434
+ CUSTOM_ERROR = 6,
435
+ FUNCTION_NOT_PAYABLE_ERROR = 7,
436
+ INVALID_PARAMS_ERROR = 8,
437
+ FALLBACK_NOT_PAYABLE_ERROR = 9,
438
+ FALLBACK_NOT_PAYABLE_AND_NO_RECEIVE_ERROR = 10,
439
+ UNRECOGNIZED_FUNCTION_WITHOUT_FALLBACK_ERROR = 11,
440
+ MISSING_FALLBACK_OR_RECEIVE_ERROR = 12,
441
+ RETURNDATA_SIZE_ERROR = 13,
442
+ NONCONTRACT_ACCOUNT_CALLED_ERROR = 14,
443
+ CALL_FAILED_ERROR = 15,
444
+ DIRECT_LIBRARY_CALL_ERROR = 16,
445
+ UNRECOGNIZED_CREATE_ERROR = 17,
446
+ UNRECOGNIZED_CONTRACT_ERROR = 18,
447
+ OTHER_EXECUTION_ERROR = 19,
448
+ UNMAPPED_SOLC_0_6_3_REVERT_ERROR = 20,
449
+ CONTRACT_TOO_LARGE_ERROR = 21,
450
+ INTERNAL_FUNCTION_CALLSTACK_ENTRY = 22,
451
+ CONTRACT_CALL_RUN_OUT_OF_GAS_ERROR = 23
452
+ }
453
+ export function stackTraceEntryTypeToString(val: StackTraceEntryType): string
454
+ export const FALLBACK_FUNCTION_NAME: string
455
+ export const RECEIVE_FUNCTION_NAME: string
456
+ export const CONSTRUCTOR_FUNCTION_NAME: string
457
+ export const UNRECOGNIZED_FUNCTION_NAME: string
458
+ export const UNKNOWN_FUNCTION_NAME: string
459
+ export const PRECOMPILE_FUNCTION_NAME: string
460
+ export const UNRECOGNIZED_CONTRACT_NAME: string
461
+ export interface SourceReference {
462
+ sourceName: string
463
+ sourceContent: string
464
+ contract?: string
465
+ function?: string
466
+ line: number
467
+ range: Array<number>
468
+ }
469
+ export interface CallstackEntryStackTraceEntry {
470
+ type: StackTraceEntryType.CALLSTACK_ENTRY
471
+ sourceReference: SourceReference
472
+ functionType: ContractFunctionType
473
+ }
474
+ export interface UnrecognizedCreateCallstackEntryStackTraceEntry {
475
+ type: StackTraceEntryType.UNRECOGNIZED_CREATE_CALLSTACK_ENTRY
476
+ sourceReference?: undefined
477
+ }
478
+ export interface UnrecognizedContractCallstackEntryStackTraceEntry {
479
+ type: StackTraceEntryType.UNRECOGNIZED_CONTRACT_CALLSTACK_ENTRY
480
+ address: Uint8Array
481
+ sourceReference?: undefined
482
+ }
483
+ export interface PrecompileErrorStackTraceEntry {
484
+ type: StackTraceEntryType.PRECOMPILE_ERROR
485
+ precompile: number
486
+ sourceReference?: undefined
487
+ }
488
+ export interface RevertErrorStackTraceEntry {
489
+ type: StackTraceEntryType.REVERT_ERROR
490
+ returnData: Uint8Array
491
+ sourceReference: SourceReference
492
+ isInvalidOpcodeError: boolean
493
+ }
494
+ export interface PanicErrorStackTraceEntry {
495
+ type: StackTraceEntryType.PANIC_ERROR
496
+ errorCode: bigint
497
+ sourceReference?: SourceReference
498
+ }
499
+ export interface CustomErrorStackTraceEntry {
500
+ type: StackTraceEntryType.CUSTOM_ERROR
501
+ message: string
502
+ sourceReference: SourceReference
503
+ }
504
+ export interface FunctionNotPayableErrorStackTraceEntry {
505
+ type: StackTraceEntryType.FUNCTION_NOT_PAYABLE_ERROR
506
+ value: bigint
507
+ sourceReference: SourceReference
508
+ }
509
+ export interface InvalidParamsErrorStackTraceEntry {
510
+ type: StackTraceEntryType.INVALID_PARAMS_ERROR
511
+ sourceReference: SourceReference
512
+ }
513
+ export interface FallbackNotPayableErrorStackTraceEntry {
514
+ type: StackTraceEntryType.FALLBACK_NOT_PAYABLE_ERROR
515
+ value: bigint
516
+ sourceReference: SourceReference
517
+ }
518
+ export interface FallbackNotPayableAndNoReceiveErrorStackTraceEntry {
519
+ type: StackTraceEntryType.FALLBACK_NOT_PAYABLE_AND_NO_RECEIVE_ERROR
520
+ value: bigint
521
+ sourceReference: SourceReference
522
+ }
523
+ export interface UnrecognizedFunctionWithoutFallbackErrorStackTraceEntry {
524
+ type: StackTraceEntryType.UNRECOGNIZED_FUNCTION_WITHOUT_FALLBACK_ERROR
525
+ sourceReference: SourceReference
526
+ }
527
+ export interface MissingFallbackOrReceiveErrorStackTraceEntry {
528
+ type: StackTraceEntryType.MISSING_FALLBACK_OR_RECEIVE_ERROR
529
+ sourceReference: SourceReference
530
+ }
531
+ export interface ReturndataSizeErrorStackTraceEntry {
532
+ type: StackTraceEntryType.RETURNDATA_SIZE_ERROR
533
+ sourceReference: SourceReference
534
+ }
535
+ export interface NonContractAccountCalledErrorStackTraceEntry {
536
+ type: StackTraceEntryType.NONCONTRACT_ACCOUNT_CALLED_ERROR
537
+ sourceReference: SourceReference
538
+ }
539
+ export interface CallFailedErrorStackTraceEntry {
540
+ type: StackTraceEntryType.CALL_FAILED_ERROR
541
+ sourceReference: SourceReference
542
+ }
543
+ export interface DirectLibraryCallErrorStackTraceEntry {
544
+ type: StackTraceEntryType.DIRECT_LIBRARY_CALL_ERROR
545
+ sourceReference: SourceReference
546
+ }
547
+ export interface UnrecognizedCreateErrorStackTraceEntry {
548
+ type: StackTraceEntryType.UNRECOGNIZED_CREATE_ERROR
549
+ returnData: Uint8Array
550
+ sourceReference?: undefined
551
+ isInvalidOpcodeError: boolean
552
+ }
553
+ export interface UnrecognizedContractErrorStackTraceEntry {
554
+ type: StackTraceEntryType.UNRECOGNIZED_CONTRACT_ERROR
555
+ address: Uint8Array
556
+ returnData: Uint8Array
557
+ sourceReference?: undefined
558
+ isInvalidOpcodeError: boolean
559
+ }
560
+ export interface OtherExecutionErrorStackTraceEntry {
561
+ type: StackTraceEntryType.OTHER_EXECUTION_ERROR
562
+ sourceReference?: SourceReference
563
+ }
564
+ export interface UnmappedSolc063RevertErrorStackTraceEntry {
565
+ type: StackTraceEntryType.UNMAPPED_SOLC_0_6_3_REVERT_ERROR
566
+ sourceReference?: SourceReference
567
+ }
568
+ export interface ContractTooLargeErrorStackTraceEntry {
569
+ type: StackTraceEntryType.CONTRACT_TOO_LARGE_ERROR
570
+ sourceReference?: SourceReference
571
+ }
572
+ export interface InternalFunctionCallStackEntry {
573
+ type: StackTraceEntryType.INTERNAL_FUNCTION_CALLSTACK_ENTRY
574
+ pc: number
575
+ sourceReference: SourceReference
576
+ }
577
+ export interface ContractCallRunOutOfGasError {
578
+ type: StackTraceEntryType.CONTRACT_CALL_RUN_OUT_OF_GAS_ERROR
579
+ sourceReference?: SourceReference
580
+ }
581
+ export interface ContractAndFunctionName {
582
+ contractName: string
583
+ functionName: string | undefined
584
+ }
585
+ export function initializeVmTraceDecoder(vmTraceDecoder: VmTraceDecoder, tracingConfig: any): void
348
586
  export interface TracingMessage {
349
587
  /** Sender address */
350
588
  readonly caller: Buffer
@@ -420,10 +658,48 @@ export class Provider {
420
658
  export class Response {
421
659
  /** Returns the response data as a JSON string or a JSON object. */
422
660
  get data(): string | any
423
- get json(): string | any
424
661
  get solidityTrace(): RawTrace | null
425
662
  get traces(): Array<RawTrace>
426
663
  }
664
+ /**
665
+ * Opaque handle to the `Bytecode` struct.
666
+ * Only used on the JS side by the `VmTraceDecoder` class.
667
+ */
668
+ export class BytecodeWrapper { }
669
+ export class Exit {
670
+ get kind(): ExitCode
671
+ isError(): boolean
672
+ getReason(): string
673
+ }
674
+ export class ReturnData {
675
+ readonly value: Uint8Array
676
+ constructor(value: Uint8Array)
677
+ isEmpty(): boolean
678
+ isErrorReturnData(): boolean
679
+ isPanicReturnData(): boolean
680
+ decodeError(): string
681
+ decodePanic(): bigint
682
+ }
683
+ export class SolidityTracer {
684
+
685
+ constructor()
686
+ getStackTrace(trace: PrecompileMessageTrace | CallMessageTrace | CreateMessageTrace): SolidityStackTrace
687
+ }
688
+ export class VmTraceDecoder {
689
+ constructor()
690
+ addBytecode(bytecode: BytecodeWrapper): void
691
+ tryToDecodeMessageTrace(messageTrace: PrecompileMessageTrace | CallMessageTrace | CreateMessageTrace): PrecompileMessageTrace | CallMessageTrace | CreateMessageTrace
692
+ getContractAndFunctionNamesForCall(code: Uint8Array, calldata: Uint8Array | undefined): ContractAndFunctionName
693
+ }
694
+ export type VMTracer = VmTracer
695
+ /** N-API bindings for the Rust port of `VMTracer` from Hardhat. */
696
+ export class VmTracer {
697
+ constructor()
698
+ /** Observes a trace, collecting information about the execution of the EVM. */
699
+ observe(trace: RawTrace): void
700
+ getLastTopLevelMessageTrace(): PrecompileMessageTrace | CallMessageTrace | CreateMessageTrace | undefined
701
+ getLastError(): Error | undefined
702
+ }
427
703
  export class RawTrace {
428
704
  trace(): Array<TracingMessage | TracingStep | TracingMessageResult>
429
705
  }
package/index.js CHANGED
@@ -310,7 +310,7 @@ 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, RawTrace } = nativeBinding
313
+ const { SpecId, EdrContext, MineOrdering, Provider, Response, SuccessReason, ExceptionalHalt, createModelsAndDecodeBytecodes, linkHexStringBytecode, BytecodeWrapper, ContractFunctionType, printMessageTrace, printStackTrace, Exit, ExitCode, ReturnData, StackTraceEntryType, stackTraceEntryTypeToString, FALLBACK_FUNCTION_NAME, RECEIVE_FUNCTION_NAME, CONSTRUCTOR_FUNCTION_NAME, UNRECOGNIZED_FUNCTION_NAME, UNKNOWN_FUNCTION_NAME, PRECOMPILE_FUNCTION_NAME, UNRECOGNIZED_CONTRACT_NAME, SolidityTracer, VmTraceDecoder, initializeVmTraceDecoder, VmTracer, RawTrace } = nativeBinding
314
314
 
315
315
  module.exports.SpecId = SpecId
316
316
  module.exports.EdrContext = EdrContext
@@ -319,4 +319,26 @@ module.exports.Provider = Provider
319
319
  module.exports.Response = Response
320
320
  module.exports.SuccessReason = SuccessReason
321
321
  module.exports.ExceptionalHalt = ExceptionalHalt
322
+ module.exports.createModelsAndDecodeBytecodes = createModelsAndDecodeBytecodes
323
+ module.exports.linkHexStringBytecode = linkHexStringBytecode
324
+ module.exports.BytecodeWrapper = BytecodeWrapper
325
+ module.exports.ContractFunctionType = ContractFunctionType
326
+ module.exports.printMessageTrace = printMessageTrace
327
+ module.exports.printStackTrace = printStackTrace
328
+ module.exports.Exit = Exit
329
+ module.exports.ExitCode = ExitCode
330
+ module.exports.ReturnData = ReturnData
331
+ module.exports.StackTraceEntryType = StackTraceEntryType
332
+ module.exports.stackTraceEntryTypeToString = stackTraceEntryTypeToString
333
+ module.exports.FALLBACK_FUNCTION_NAME = FALLBACK_FUNCTION_NAME
334
+ module.exports.RECEIVE_FUNCTION_NAME = RECEIVE_FUNCTION_NAME
335
+ module.exports.CONSTRUCTOR_FUNCTION_NAME = CONSTRUCTOR_FUNCTION_NAME
336
+ module.exports.UNRECOGNIZED_FUNCTION_NAME = UNRECOGNIZED_FUNCTION_NAME
337
+ module.exports.UNKNOWN_FUNCTION_NAME = UNKNOWN_FUNCTION_NAME
338
+ module.exports.PRECOMPILE_FUNCTION_NAME = PRECOMPILE_FUNCTION_NAME
339
+ module.exports.UNRECOGNIZED_CONTRACT_NAME = UNRECOGNIZED_CONTRACT_NAME
340
+ module.exports.SolidityTracer = SolidityTracer
341
+ module.exports.VmTraceDecoder = VmTraceDecoder
342
+ module.exports.initializeVmTraceDecoder = initializeVmTraceDecoder
343
+ module.exports.VmTracer = VmTracer
322
344
  module.exports.RawTrace = RawTrace
package/package.json CHANGED
@@ -1,8 +1,30 @@
1
1
  {
2
2
  "name": "@nomicfoundation/edr",
3
- "version": "0.5.2",
4
- "main": "index.js",
5
- "types": "index.d.ts",
3
+ "version": "0.6.0",
4
+ "devDependencies": {
5
+ "@napi-rs/cli": "^2.18.3",
6
+ "@types/chai": "^4.2.0",
7
+ "@types/chai-as-promised": "^7.1.8",
8
+ "@types/mocha": ">=9.1.0",
9
+ "@types/node": "^20.0.0",
10
+ "@typescript-eslint/eslint-plugin": "5.61.0",
11
+ "@typescript-eslint/parser": "5.61.0",
12
+ "chai": "^4.3.6",
13
+ "chai-as-promised": "^7.1.1",
14
+ "eslint": "^8.44.0",
15
+ "eslint-config-prettier": "9.1.0",
16
+ "eslint-plugin-import": "2.27.5",
17
+ "eslint-plugin-mocha": "10.4.1",
18
+ "eslint-plugin-prettier": "5.2.1",
19
+ "json-stream-stringify": "^3.1.4",
20
+ "mocha": "^10.0.0",
21
+ "prettier": "^3.2.5",
22
+ "ts-node": "^10.8.0",
23
+ "typescript": "~5.0.0"
24
+ },
25
+ "engines": {
26
+ "node": ">= 18"
27
+ },
6
28
  "files": [
7
29
  "index.js",
8
30
  "index.d.ts",
@@ -10,10 +32,8 @@
10
32
  "build.rs",
11
33
  "src/"
12
34
  ],
13
- "repository": {
14
- "url": "https://github.com/NomicFoundation/edr.git",
15
- "type": "git"
16
- },
35
+ "license": "MIT",
36
+ "main": "index.js",
17
37
  "napi": {
18
38
  "name": "edr",
19
39
  "triples": {
@@ -29,43 +49,32 @@
29
49
  ]
30
50
  }
31
51
  },
32
- "license": "MIT",
33
- "devDependencies": {
34
- "@napi-rs/cli": "^2.18.1",
35
- "@types/chai": "^4.2.0",
36
- "@types/chai-as-promised": "^7.1.8",
37
- "@types/mocha": ">=9.1.0",
38
- "@types/node": "^18.0.0",
39
- "chai": "^4.3.6",
40
- "chai-as-promised": "^7.1.1",
41
- "json-stream-stringify": "^3.1.4",
42
- "mocha": "^10.0.0",
43
- "ts-node": "^10.8.0",
44
- "typescript": "~4.5.2"
45
- },
46
- "engines": {
47
- "node": ">= 18"
48
- },
52
+ "repository": "NomicFoundation/edr.git",
53
+ "types": "index.d.ts",
49
54
  "dependencies": {
50
- "@nomicfoundation/edr-darwin-arm64": "0.5.2",
51
- "@nomicfoundation/edr-darwin-x64": "0.5.2",
52
- "@nomicfoundation/edr-linux-arm64-gnu": "0.5.2",
53
- "@nomicfoundation/edr-linux-arm64-musl": "0.5.2",
54
- "@nomicfoundation/edr-linux-x64-gnu": "0.5.2",
55
- "@nomicfoundation/edr-linux-x64-musl": "0.5.2",
56
- "@nomicfoundation/edr-win32-x64-msvc": "0.5.2"
55
+ "@nomicfoundation/edr-darwin-arm64": "0.6.0",
56
+ "@nomicfoundation/edr-darwin-x64": "0.6.0",
57
+ "@nomicfoundation/edr-linux-arm64-gnu": "0.6.0",
58
+ "@nomicfoundation/edr-linux-arm64-musl": "0.6.0",
59
+ "@nomicfoundation/edr-linux-x64-gnu": "0.6.0",
60
+ "@nomicfoundation/edr-linux-x64-musl": "0.6.0",
61
+ "@nomicfoundation/edr-win32-x64-msvc": "0.6.0"
57
62
  },
58
63
  "scripts": {
59
64
  "artifacts": "napi artifacts",
60
65
  "build": "napi build --platform --release",
61
66
  "build:debug": "napi build --platform",
62
- "build:tracing": "napi build --platform --release --features tracing",
63
67
  "build:scenarios": "napi build --platform --release --features scenarios",
64
- "universal": "napi universal",
65
- "version": "napi version",
68
+ "build:tracing": "napi build --platform --release --features tracing",
69
+ "clean": "rm -rf @nomicfoundation/edr.node",
70
+ "eslint": "eslint 'test/**/*.ts'",
71
+ "lint": "pnpm run prettier && pnpm run eslint",
72
+ "lint:fix": "pnpm run prettier --write",
66
73
  "pretest": "pnpm build",
74
+ "prettier": "prettier --check \"test/**.ts\"",
67
75
  "test": "pnpm tsc && node --max-old-space-size=8192 node_modules/mocha/bin/_mocha --recursive \"test/**/*.ts\"",
68
76
  "testNoBuild": "pnpm tsc && node --max-old-space-size=8192 node_modules/mocha/bin/_mocha --recursive \"test/**/*.ts\"",
69
- "clean": "rm -rf @nomicfoundation/edr.node"
77
+ "universal": "napi universal",
78
+ "version": "napi version"
70
79
  }
71
80
  }
package/src/logger.rs CHANGED
@@ -54,6 +54,7 @@ pub struct LoggerConfig {
54
54
  #[napi(ts_type = "(inputs: Buffer[]) => string[]")]
55
55
  pub decode_console_log_inputs_callback: JsFunction,
56
56
  #[napi(ts_type = "(code: Buffer, calldata?: Buffer) => ContractAndFunctionName")]
57
+ /// Used to resolve the contract and function name when logging.
57
58
  pub get_contract_and_function_name_callback: JsFunction,
58
59
  #[napi(ts_type = "(message: string, replace: boolean) => void")]
59
60
  pub print_line_callback: JsFunction,
package/src/provider.rs CHANGED
@@ -243,12 +243,6 @@ impl Response {
243
243
  self.data.clone()
244
244
  }
245
245
 
246
- // Temporary alias for data to prevent breaking change
247
- #[napi(getter)]
248
- pub fn json(&self) -> Either<String, serde_json::Value> {
249
- self.data.clone()
250
- }
251
-
252
246
  #[napi(getter)]
253
247
  pub fn solidity_trace(&self) -> Option<RawTrace> {
254
248
  self.solidity_trace
@@ -0,0 +1,27 @@
1
+ use std::rc::Rc;
2
+
3
+ use edr_solidity::artifacts::{CompilerInput, CompilerOutput};
4
+ use napi::{bindgen_prelude::ClassInstance, Env};
5
+ use napi_derive::napi;
6
+
7
+ use crate::trace::model::BytecodeWrapper;
8
+
9
+ #[napi(catch_unwind)]
10
+ pub fn create_models_and_decode_bytecodes(
11
+ solc_version: String,
12
+ compiler_input: serde_json::Value,
13
+ compiler_output: serde_json::Value,
14
+ env: Env,
15
+ ) -> napi::Result<Vec<ClassInstance<BytecodeWrapper>>> {
16
+ let compiler_input: CompilerInput = serde_json::from_value(compiler_input)?;
17
+ let compiler_output: CompilerOutput = serde_json::from_value(compiler_output)?;
18
+
19
+ edr_solidity::compiler::create_models_and_decode_bytecodes(
20
+ solc_version,
21
+ &compiler_input,
22
+ &compiler_output,
23
+ )?
24
+ .into_iter()
25
+ .map(|bytecode| BytecodeWrapper::new(Rc::new(bytecode)).into_instance(env))
26
+ .collect()
27
+ }