@nomicfoundation/edr 0.12.0-next.23 → 0.12.0-next.24

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/index.d.ts CHANGED
@@ -587,6 +587,20 @@ export interface LinkReference {
587
587
  start: number
588
588
  length: number
589
589
  }
590
+ /**Error codes that can be returned by cheatcodes in Solidity tests. */
591
+ export enum CheatcodeErrorCode {
592
+ /**The specified cheatcode is not supported. */
593
+ UnsupportedCheatcode = 'UnsupportedCheatcode',
594
+ /**The specified cheatcode is missing. */
595
+ MissingCheatcode = 'MissingCheatcode'
596
+ }
597
+ /**Error returned by a cheatcode in Solidity tests. */
598
+ export interface CheatcodeErrorDetails {
599
+ /**The error code representing the type of cheatcode error. */
600
+ code: CheatcodeErrorCode
601
+ /**The name of the cheatcode that caused the error. */
602
+ cheatcode: string
603
+ }
590
604
  /**
591
605
  * Solidity test runner configuration arguments exposed through the ffi.
592
606
  * Docs based on <https://book.getfoundry.sh/reference/config/testing>.
@@ -646,6 +660,8 @@ export interface SolidityTestRunnerConfigArgs {
646
660
  * Defaults to `31337`.
647
661
  */
648
662
  chainId?: bigint
663
+ /** The hardfork to use for EVM execution. */
664
+ hardfork: string
649
665
  /**
650
666
  * The gas limit for each test case.
651
667
  * Defaults to `9_223_372_036_854_775_807` (`i64::MAX`).
@@ -686,6 +702,11 @@ export interface SolidityTestRunnerConfigArgs {
686
702
  * Defaults to false.
687
703
  */
688
704
  disableBlockGasLimit?: boolean
705
+ /**
706
+ * Whether to enable the EIP-7825 (Osaka) transaction gas limit cap.
707
+ * Defaults to false.
708
+ */
709
+ enableTxGasLimitCap?: boolean
689
710
  /**
690
711
  * The memory limit of the EVM in bytes.
691
712
  * Defaults to `33_554_432` (2^25 = 32MiB).
@@ -1457,6 +1478,7 @@ export interface CheatcodeErrorStackTraceEntry {
1457
1478
  type: StackTraceEntryType.CHEATCODE_ERROR
1458
1479
  message: string
1459
1480
  sourceReference: SourceReference
1481
+ details?: CheatcodeErrorDetails
1460
1482
  }
1461
1483
  export interface TracingMessage {
1462
1484
  /** Sender address */
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 { 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, OSAKA, OpHardfork, opHardforkFromString, opHardforkToString, opLatestHardfork, OP_CHAIN_TYPE, opGenesisState, opProviderFactory, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, MineOrdering, EdrContext, ContractDecoder, GasReportExecutionStatus, addStatementCoverageInstrumentation, latestSupportedSolidityVersion, Precompile, precompileP256Verify, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, CachedChains, CachedEndpoints, FsAccessPermission, CollectStackTraces, IncludeTraces, SolidityTestRunnerFactory, l1SolidityTestRunnerFactory, opSolidityTestRunnerFactory, SuiteResult, TestResult, TestStatus, CallKind, LogKind, 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, OSAKA, OpHardfork, opHardforkFromString, opHardforkToString, opLatestHardfork, OP_CHAIN_TYPE, opGenesisState, opProviderFactory, BEDROCK, REGOLITH, CANYON, ECOTONE, FJORD, GRANITE, HOLOCENE, ISTHMUS, MineOrdering, EdrContext, ContractDecoder, GasReportExecutionStatus, addStatementCoverageInstrumentation, latestSupportedSolidityVersion, Precompile, precompileP256Verify, ProviderFactory, Response, Provider, SuccessReason, ExceptionalHalt, CheatcodeErrorCode, CachedChains, CachedEndpoints, FsAccessPermission, CollectStackTraces, IncludeTraces, SolidityTestRunnerFactory, l1SolidityTestRunnerFactory, opSolidityTestRunnerFactory, SuiteResult, TestResult, TestStatus, CallKind, LogKind, 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
315
  module.exports.GENERIC_CHAIN_TYPE = GENERIC_CHAIN_TYPE
316
316
  module.exports.genericChainProviderFactory = genericChainProviderFactory
@@ -369,6 +369,7 @@ module.exports.Response = Response
369
369
  module.exports.Provider = Provider
370
370
  module.exports.SuccessReason = SuccessReason
371
371
  module.exports.ExceptionalHalt = ExceptionalHalt
372
+ module.exports.CheatcodeErrorCode = CheatcodeErrorCode
372
373
  module.exports.CachedChains = CachedChains
373
374
  module.exports.CachedEndpoints = CachedEndpoints
374
375
  module.exports.FsAccessPermission = FsAccessPermission
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomicfoundation/edr",
3
- "version": "0.12.0-next.23",
3
+ "version": "0.12.0-next.24",
4
4
  "devDependencies": {
5
5
  "@napi-rs/cli": "^2.18.4",
6
6
  "@nomicfoundation/ethereumjs-util": "^9.0.4",
@@ -58,13 +58,13 @@
58
58
  "repository": "NomicFoundation/edr.git",
59
59
  "types": "index.d.ts",
60
60
  "dependencies": {
61
- "@nomicfoundation/edr-darwin-arm64": "0.12.0-next.23",
62
- "@nomicfoundation/edr-darwin-x64": "0.12.0-next.23",
63
- "@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.23",
64
- "@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.23",
65
- "@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.23",
66
- "@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.23",
67
- "@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.23"
61
+ "@nomicfoundation/edr-darwin-arm64": "0.12.0-next.24",
62
+ "@nomicfoundation/edr-darwin-x64": "0.12.0-next.24",
63
+ "@nomicfoundation/edr-linux-arm64-gnu": "0.12.0-next.24",
64
+ "@nomicfoundation/edr-linux-arm64-musl": "0.12.0-next.24",
65
+ "@nomicfoundation/edr-linux-x64-gnu": "0.12.0-next.24",
66
+ "@nomicfoundation/edr-linux-x64-musl": "0.12.0-next.24",
67
+ "@nomicfoundation/edr-win32-x64-msvc": "0.12.0-next.24"
68
68
  },
69
69
  "scripts": {
70
70
  "artifacts": "napi artifacts",
@@ -0,0 +1,37 @@
1
+ use napi_derive::napi;
2
+ use serde::Serialize;
3
+
4
+ #[napi(string_enum)]
5
+ #[derive(Serialize)]
6
+ #[doc = "Error codes that can be returned by cheatcodes in Solidity tests."]
7
+ pub enum CheatcodeErrorCode {
8
+ #[doc = "The specified cheatcode is not supported."]
9
+ UnsupportedCheatcode,
10
+ #[doc = "The specified cheatcode is missing."]
11
+ MissingCheatcode,
12
+ }
13
+
14
+ #[napi(object)]
15
+ #[derive(Clone, Serialize)]
16
+ #[doc = "Error returned by a cheatcode in Solidity tests."]
17
+ pub struct CheatcodeErrorDetails {
18
+ #[doc = "The error code representing the type of cheatcode error."]
19
+ pub code: CheatcodeErrorCode,
20
+ #[doc = "The name of the cheatcode that caused the error."]
21
+ pub cheatcode: String,
22
+ }
23
+
24
+ impl From<edr_solidity::return_data::CheatcodeErrorCode> for CheatcodeErrorCode {
25
+ fn from(value: edr_solidity::return_data::CheatcodeErrorCode) -> Self {
26
+ match value {
27
+ edr_solidity::return_data::CheatcodeErrorCode::UnsupportedCheatcode => {
28
+ CheatcodeErrorCode::UnsupportedCheatcode
29
+ }
30
+ // __Invalid is generated by alloy_sol_types for invalid encoded values.
31
+ edr_solidity::return_data::CheatcodeErrorCode::MissingCheatcode
32
+ | edr_solidity::return_data::CheatcodeErrorCode::__Invalid => {
33
+ CheatcodeErrorCode::MissingCheatcode
34
+ }
35
+ }
36
+ }
37
+ }
@@ -75,6 +75,8 @@ pub struct SolidityTestRunnerConfigArgs {
75
75
  /// Defaults to `31337`.
76
76
  #[serde(serialize_with = "serialize_optional_bigint_as_struct")]
77
77
  pub chain_id: Option<BigInt>,
78
+ /// The hardfork to use for EVM execution.
79
+ pub hardfork: String,
78
80
  /// The gas limit for each test case.
79
81
  /// Defaults to `9_223_372_036_854_775_807` (`i64::MAX`).
80
82
  #[serde(serialize_with = "serialize_optional_bigint_as_struct")]
@@ -107,6 +109,9 @@ pub struct SolidityTestRunnerConfigArgs {
107
109
  /// Whether to disable the block gas limit.
108
110
  /// Defaults to false.
109
111
  pub disable_block_gas_limit: Option<bool>,
112
+ /// Whether to enable the EIP-7825 (Osaka) transaction gas limit cap.
113
+ /// Defaults to false.
114
+ pub enable_tx_gas_limit_cap: Option<bool>,
110
115
  /// The memory limit of the EVM in bytes.
111
116
  /// Defaults to `33_554_432` (2^25 = 32MiB).
112
117
  #[serde(serialize_with = "serialize_optional_bigint_as_struct")]
@@ -184,6 +189,7 @@ impl SolidityTestRunnerConfigArgs {
184
189
  initial_balance,
185
190
  block_number,
186
191
  chain_id,
192
+ hardfork,
187
193
  gas_limit,
188
194
  gas_price,
189
195
  block_base_fee_per_gas,
@@ -192,6 +198,7 @@ impl SolidityTestRunnerConfigArgs {
192
198
  block_difficulty,
193
199
  block_gas_limit,
194
200
  disable_block_gas_limit,
201
+ enable_tx_gas_limit_cap,
195
202
  memory_limit,
196
203
  local_predeploys,
197
204
  eth_rpc_url,
@@ -308,6 +315,7 @@ impl SolidityTestRunnerConfigArgs {
308
315
  initial_balance: initial_balance.map(TryCast::try_cast).transpose()?,
309
316
  block_number: block_number.map(TryCast::try_cast).transpose()?,
310
317
  chain_id: chain_id.map(TryCast::try_cast).transpose()?,
318
+ hardfork,
311
319
  gas_limit: gas_limit.map(TryCast::try_cast).transpose()?,
312
320
  gas_price: gas_price.map(TryCast::try_cast).transpose()?,
313
321
  block_base_fee_per_gas: block_base_fee_per_gas.map(TryCast::try_cast).transpose()?,
@@ -316,6 +324,7 @@ impl SolidityTestRunnerConfigArgs {
316
324
  block_difficulty: block_difficulty.map(TryCast::try_cast).transpose()?,
317
325
  block_gas_limit: block_gas_limit.map(TryCast::try_cast).transpose()?,
318
326
  disable_block_gas_limit,
327
+ enable_tx_gas_limit_cap,
319
328
  memory_limit: memory_limit.map(TryCast::try_cast).transpose()?,
320
329
  local_predeploys,
321
330
  fork_url: eth_rpc_url,
@@ -1,4 +1,5 @@
1
1
  pub mod artifact;
2
+ pub mod cheatcode_errors;
2
3
  pub mod config;
3
4
  pub mod factory;
4
5
  pub mod l1;
@@ -9,7 +9,9 @@ use napi_derive::napi;
9
9
  use serde::{Serialize, Serializer};
10
10
 
11
11
  use super::model::ContractFunctionType;
12
- use crate::{cast::TryCast, trace::u256_to_bigint};
12
+ use crate::{
13
+ cast::TryCast, solidity_tests::cheatcode_errors::CheatcodeErrorDetails, trace::u256_to_bigint,
14
+ };
13
15
 
14
16
  #[napi]
15
17
  #[repr(u8)]
@@ -94,6 +96,15 @@ impl From<edr_solidity::solidity_stack_trace::SourceReference> for SourceReferen
94
96
  }
95
97
  }
96
98
 
99
+ impl From<edr_solidity::return_data::CheatcodeErrorDetails> for CheatcodeErrorDetails {
100
+ fn from(value: edr_solidity::return_data::CheatcodeErrorDetails) -> Self {
101
+ Self {
102
+ code: value.code.into(),
103
+ cheatcode: value.cheatcode,
104
+ }
105
+ }
106
+ }
107
+
97
108
  /// A [`StackTraceEntryType`] constant that is convertible to/from a
98
109
  /// `napi_value`.
99
110
  ///
@@ -579,6 +590,7 @@ pub struct CheatcodeErrorStackTraceEntry {
579
590
  // The parsed cheatcode error message that can be displayed to the user
580
591
  pub message: String,
581
592
  pub source_reference: SourceReference,
593
+ pub details: Option<CheatcodeErrorDetails>,
582
594
  }
583
595
 
584
596
  impl From<CheatcodeErrorStackTraceEntry> for SolidityStackTraceEntry {
@@ -684,10 +696,12 @@ impl TryCast<SolidityStackTraceEntry> for edr_solidity::solidity_stack_trace::St
684
696
  StackTraceEntry::CheatCodeError {
685
697
  message,
686
698
  source_reference,
699
+ details,
687
700
  } => CheatcodeErrorStackTraceEntry {
688
701
  type_: StackTraceEntryTypeConst,
689
702
  message,
690
703
  source_reference: source_reference.into(),
704
+ details: details.map(std::convert::Into::into),
691
705
  }
692
706
  .into(),
693
707
  StackTraceEntry::CustomError {