@nomicfoundation/edr 0.7.0 → 0.8.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/index.d.ts CHANGED
@@ -254,6 +254,27 @@ export interface ProviderConfig {
254
254
  /** The network ID of the blockchain */
255
255
  networkId: bigint
256
256
  }
257
+ /** Tracing config for Solidity stack trace generation. */
258
+ export interface TracingConfigWithBuffers {
259
+ /**
260
+ * Build information to use for decoding contracts. Either a Hardhat v2
261
+ * build info file that contains both input and output or a Hardhat v3
262
+ * build info file that doesn't contain output and a separate output file.
263
+ */
264
+ buildInfos?: Array<Uint8Array> | Array<BuildInfoAndOutput>
265
+ /** Whether to ignore contracts whose name starts with "Ignored". */
266
+ ignoreContracts?: boolean
267
+ }
268
+ /**
269
+ * Hardhat V3 build info where the compiler output is not part of the build
270
+ * info file.
271
+ */
272
+ export interface BuildInfoAndOutput {
273
+ /** The build info input file */
274
+ buildInfo: Uint8Array
275
+ /** The build info output file */
276
+ output: Uint8Array
277
+ }
257
278
  /** The possible reasons for successful termination of the EVM. */
258
279
  export const enum SuccessReason {
259
280
  /** The opcode `STOP` was called */
@@ -595,7 +616,7 @@ export declare class EdrContext {
595
616
  /** A JSON-RPC provider for Ethereum. */
596
617
  export declare class Provider {
597
618
  /**Constructs a new provider with the provided configuration. */
598
- static withConfig(context: EdrContext, config: ProviderConfig, loggerConfig: LoggerConfig, tracingConfig: any, subscriberCallback: (event: SubscriptionEvent) => void): Promise<Provider>
619
+ static withConfig(context: EdrContext, config: ProviderConfig, loggerConfig: LoggerConfig, tracingConfig: TracingConfigWithBuffers, subscriberCallback: (event: SubscriptionEvent) => void): Promise<Provider>
599
620
  /**Handles a JSON-RPC request and returns a JSON-RPC response. */
600
621
  handleRequest(jsonRequest: string): Promise<Response>
601
622
  setCallOverrideCallback(callOverrideCallback: (contract_address: Buffer, data: Buffer) => Promise<CallOverrideResult | undefined>): void
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nomicfoundation/edr",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "devDependencies": {
5
5
  "@napi-rs/cli": "^2.18.4",
6
6
  "@types/chai": "^4.2.0",
@@ -52,13 +52,13 @@
52
52
  "repository": "NomicFoundation/edr.git",
53
53
  "types": "index.d.ts",
54
54
  "dependencies": {
55
- "@nomicfoundation/edr-darwin-arm64": "0.7.0",
56
- "@nomicfoundation/edr-darwin-x64": "0.7.0",
57
- "@nomicfoundation/edr-linux-arm64-gnu": "0.7.0",
58
- "@nomicfoundation/edr-linux-arm64-musl": "0.7.0",
59
- "@nomicfoundation/edr-linux-x64-gnu": "0.7.0",
60
- "@nomicfoundation/edr-linux-x64-musl": "0.7.0",
61
- "@nomicfoundation/edr-win32-x64-msvc": "0.7.0"
55
+ "@nomicfoundation/edr-darwin-arm64": "0.8.0",
56
+ "@nomicfoundation/edr-darwin-x64": "0.8.0",
57
+ "@nomicfoundation/edr-linux-arm64-gnu": "0.8.0",
58
+ "@nomicfoundation/edr-linux-arm64-musl": "0.8.0",
59
+ "@nomicfoundation/edr-linux-x64-gnu": "0.8.0",
60
+ "@nomicfoundation/edr-linux-x64-musl": "0.8.0",
61
+ "@nomicfoundation/edr-win32-x64-msvc": "0.8.0"
62
62
  },
63
63
  "scripts": {
64
64
  "artifacts": "napi artifacts",
package/src/provider.rs CHANGED
@@ -5,7 +5,9 @@ use std::sync::Arc;
5
5
  use edr_provider::{time::CurrentTime, InvalidRequestReason};
6
6
  use edr_rpc_eth::jsonrpc;
7
7
  use edr_solidity::contract_decoder::ContractDecoder;
8
- use napi::{tokio::runtime, Either, Env, JsFunction, JsObject, Status};
8
+ use napi::{
9
+ bindgen_prelude::Uint8Array, tokio::runtime, Either, Env, JsFunction, JsObject, Status,
10
+ };
9
11
  use napi_derive::napi;
10
12
 
11
13
  use self::config::ProviderConfig;
@@ -37,7 +39,7 @@ impl Provider {
37
39
  _context: &EdrContext,
38
40
  config: ProviderConfig,
39
41
  logger_config: LoggerConfig,
40
- tracing_config: serde_json::Value,
42
+ tracing_config: TracingConfigWithBuffers,
41
43
  #[napi(ts_arg_type = "(event: SubscriptionEvent) => void")] subscriber_callback: JsFunction,
42
44
  ) -> napi::Result<JsObject> {
43
45
  let runtime = runtime::Handle::current();
@@ -45,8 +47,9 @@ impl Provider {
45
47
  let config = edr_provider::ProviderConfig::try_from(config)?;
46
48
 
47
49
  // TODO https://github.com/NomicFoundation/edr/issues/760
48
- let build_info_config: edr_solidity::contract_decoder::BuildInfoConfig =
49
- serde_json::from_value(tracing_config)?;
50
+ let build_info_config =
51
+ edr_solidity::artifacts::BuildInfoConfig::parse_from_buffers((&tracing_config).into())
52
+ .map_err(|err| napi::Error::from_reason(err.to_string()))?;
50
53
  let contract_decoder = ContractDecoder::new(&build_info_config)
51
54
  .map_err(|error| napi::Error::from_reason(error.to_string()))?;
52
55
  let contract_decoder = Arc::new(contract_decoder);
@@ -245,6 +248,66 @@ impl Provider {
245
248
  }
246
249
  }
247
250
 
251
+ /// Tracing config for Solidity stack trace generation.
252
+ #[napi(object)]
253
+ pub struct TracingConfigWithBuffers {
254
+ /// Build information to use for decoding contracts. Either a Hardhat v2
255
+ /// build info file that contains both input and output or a Hardhat v3
256
+ /// build info file that doesn't contain output and a separate output file.
257
+ pub build_infos: Option<Either<Vec<Uint8Array>, Vec<BuildInfoAndOutput>>>,
258
+ /// Whether to ignore contracts whose name starts with "Ignored".
259
+ pub ignore_contracts: Option<bool>,
260
+ }
261
+
262
+ /// Hardhat V3 build info where the compiler output is not part of the build
263
+ /// info file.
264
+ #[napi(object)]
265
+ pub struct BuildInfoAndOutput {
266
+ /// The build info input file
267
+ pub build_info: Uint8Array,
268
+ /// The build info output file
269
+ pub output: Uint8Array,
270
+ }
271
+
272
+ impl<'a> From<&'a BuildInfoAndOutput>
273
+ for edr_solidity::artifacts::BuildInfoBufferSeparateOutput<'a>
274
+ {
275
+ fn from(value: &'a BuildInfoAndOutput) -> Self {
276
+ Self {
277
+ build_info: value.build_info.as_ref(),
278
+ output: value.output.as_ref(),
279
+ }
280
+ }
281
+ }
282
+
283
+ impl<'a> From<&'a TracingConfigWithBuffers>
284
+ for edr_solidity::artifacts::BuildInfoConfigWithBuffers<'a>
285
+ {
286
+ fn from(value: &'a TracingConfigWithBuffers) -> Self {
287
+ use edr_solidity::artifacts::{BuildInfoBufferSeparateOutput, BuildInfoBuffers};
288
+
289
+ let build_infos = value.build_infos.as_ref().map(|infos| match infos {
290
+ Either::A(with_output) => BuildInfoBuffers::WithOutput(
291
+ with_output
292
+ .iter()
293
+ .map(std::convert::AsRef::as_ref)
294
+ .collect(),
295
+ ),
296
+ Either::B(separate_output) => BuildInfoBuffers::SeparateInputOutput(
297
+ separate_output
298
+ .iter()
299
+ .map(BuildInfoBufferSeparateOutput::from)
300
+ .collect(),
301
+ ),
302
+ });
303
+
304
+ Self {
305
+ build_infos,
306
+ ignore_contracts: value.ignore_contracts,
307
+ }
308
+ }
309
+ }
310
+
248
311
  #[derive(Debug)]
249
312
  struct SolidityTraceData {
250
313
  trace: Arc<edr_evm::trace::Trace>,