@nomicfoundation/edr 0.12.0-next.8 → 0.12.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/coverage.sol +38 -0
- package/dist/src/ts/coverage.d.ts +6 -0
- package/dist/src/ts/coverage.d.ts.map +1 -0
- package/dist/src/ts/coverage.js +51 -0
- package/dist/src/ts/coverage.js.map +1 -0
- package/index.d.ts +267 -27
- package/index.js +5 -2
- package/package.json +23 -12
- package/src/account.rs +0 -124
- package/src/block.rs +0 -28
- package/src/call_override.rs +0 -116
- package/src/cast.rs +0 -165
- package/src/chains/generic.rs +0 -58
- package/src/chains/l1.rs +0 -268
- package/src/chains/op.rs +0 -424
- package/src/chains.rs +0 -7
- package/src/config.rs +0 -700
- package/src/context.rs +0 -447
- package/src/contract_decoder.rs +0 -57
- package/src/debug_trace.rs +0 -40
- package/src/gas_report.rs +0 -92
- package/src/instrument.rs +0 -109
- package/src/lib.rs +0 -50
- package/src/log.rs +0 -28
- package/src/logger.rs +0 -120
- package/src/mock/time.rs +0 -134
- package/src/mock.rs +0 -71
- package/src/precompile.rs +0 -50
- package/src/provider/factory.rs +0 -22
- package/src/provider/response.rs +0 -73
- package/src/provider.rs +0 -162
- package/src/result.rs +0 -212
- package/src/scenarios.rs +0 -53
- package/src/serde.rs +0 -57
- package/src/solidity_tests/artifact.rs +0 -184
- package/src/solidity_tests/config.rs +0 -793
- package/src/solidity_tests/factory.rs +0 -22
- package/src/solidity_tests/l1.rs +0 -68
- package/src/solidity_tests/op.rs +0 -69
- package/src/solidity_tests/runner.rs +0 -51
- package/src/solidity_tests/test_results.rs +0 -736
- package/src/solidity_tests.rs +0 -56
- package/src/subscription.rs +0 -32
- package/src/trace/debug.rs +0 -61
- package/src/trace/exit.rs +0 -89
- package/src/trace/library_utils.rs +0 -11
- package/src/trace/model.rs +0 -59
- package/src/trace/return_data.rs +0 -96
- package/src/trace/solidity_stack_trace.rs +0 -869
- package/src/trace.rs +0 -199
- package/src/ts/solidity_tests.ts +0 -46
- package/src/withdrawal.rs +0 -49
package/src/solidity_tests.rs
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
pub mod artifact;
|
|
2
|
-
pub mod config;
|
|
3
|
-
pub mod factory;
|
|
4
|
-
pub mod l1;
|
|
5
|
-
#[cfg(feature = "op")]
|
|
6
|
-
pub mod op;
|
|
7
|
-
pub mod runner;
|
|
8
|
-
pub mod test_results;
|
|
9
|
-
|
|
10
|
-
use std::path::Path;
|
|
11
|
-
|
|
12
|
-
use edr_primitives::Bytes;
|
|
13
|
-
use edr_solidity::linker::{LinkOutput, Linker};
|
|
14
|
-
use edr_solidity_tests::{constants::LIBRARY_DEPLOYER, contracts::ContractsByArtifact};
|
|
15
|
-
use foundry_compilers::artifacts::Libraries;
|
|
16
|
-
|
|
17
|
-
use crate::solidity_tests::artifact::Artifact;
|
|
18
|
-
|
|
19
|
-
pub(crate) struct LinkingOutput {
|
|
20
|
-
pub libs_to_deploy: Vec<Bytes>,
|
|
21
|
-
pub known_contracts: ContractsByArtifact,
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
impl LinkingOutput {
|
|
25
|
-
pub fn link(project_root: &Path, artifacts: Vec<Artifact>) -> napi::Result<Self> {
|
|
26
|
-
let artifact_contracts = artifacts
|
|
27
|
-
.into_iter()
|
|
28
|
-
.map(|artifact| Ok((artifact.id.try_into()?, artifact.contract.try_into()?)))
|
|
29
|
-
.collect::<napi::Result<Vec<_>>>()?;
|
|
30
|
-
|
|
31
|
-
let linker = Linker::new(project_root, artifact_contracts);
|
|
32
|
-
|
|
33
|
-
let LinkOutput {
|
|
34
|
-
libraries,
|
|
35
|
-
libs_to_deploy,
|
|
36
|
-
} = linker
|
|
37
|
-
.link_with_nonce_or_address(
|
|
38
|
-
Libraries::default(),
|
|
39
|
-
LIBRARY_DEPLOYER,
|
|
40
|
-
0,
|
|
41
|
-
linker.contracts.keys(),
|
|
42
|
-
)
|
|
43
|
-
.map_err(|error| napi::Error::from_reason(error.to_string()))?;
|
|
44
|
-
|
|
45
|
-
let linked_contracts = linker
|
|
46
|
-
.get_linked_artifacts(&libraries)
|
|
47
|
-
.map_err(|error| napi::Error::from_reason(error.to_string()))?;
|
|
48
|
-
|
|
49
|
-
let known_contracts = ContractsByArtifact::new(linked_contracts);
|
|
50
|
-
|
|
51
|
-
Ok(LinkingOutput {
|
|
52
|
-
libs_to_deploy,
|
|
53
|
-
known_contracts,
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
}
|
package/src/subscription.rs
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
use napi::{bindgen_prelude::BigInt, JsFunction};
|
|
2
|
-
use napi_derive::napi;
|
|
3
|
-
|
|
4
|
-
/// Configuration for subscriptions.
|
|
5
|
-
#[napi(object)]
|
|
6
|
-
pub struct SubscriptionConfig {
|
|
7
|
-
/// Callback to be called when a new event is received.
|
|
8
|
-
#[napi(ts_type = "(event: SubscriptionEvent) => void")]
|
|
9
|
-
pub subscription_callback: JsFunction,
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
impl From<edr_napi_core::subscription::Config> for SubscriptionConfig {
|
|
13
|
-
fn from(config: edr_napi_core::subscription::Config) -> Self {
|
|
14
|
-
Self {
|
|
15
|
-
subscription_callback: config.subscription_callback,
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
impl From<SubscriptionConfig> for edr_napi_core::subscription::Config {
|
|
21
|
-
fn from(config: SubscriptionConfig) -> Self {
|
|
22
|
-
Self {
|
|
23
|
-
subscription_callback: config.subscription_callback,
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
#[napi(object)]
|
|
29
|
-
pub struct SubscriptionEvent {
|
|
30
|
-
pub filter_id: BigInt,
|
|
31
|
-
pub result: serde_json::Value,
|
|
32
|
-
}
|
package/src/trace/debug.rs
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
//! Port of `hardhat-network/stack-traces/debug.ts` from Hardhat.
|
|
2
|
-
|
|
3
|
-
use napi::bindgen_prelude::Either25;
|
|
4
|
-
use napi_derive::napi;
|
|
5
|
-
|
|
6
|
-
use super::solidity_stack_trace::{RevertErrorStackTraceEntry, SolidityStackTrace};
|
|
7
|
-
use crate::trace::return_data::ReturnData;
|
|
8
|
-
|
|
9
|
-
#[napi(catch_unwind)]
|
|
10
|
-
fn print_stack_trace(trace: SolidityStackTrace) -> napi::Result<()> {
|
|
11
|
-
let entry_values = trace
|
|
12
|
-
.into_iter()
|
|
13
|
-
.map(|entry| match entry {
|
|
14
|
-
Either25::A(entry) => serde_json::to_value(entry),
|
|
15
|
-
Either25::B(entry) => serde_json::to_value(entry),
|
|
16
|
-
Either25::C(entry) => serde_json::to_value(entry),
|
|
17
|
-
Either25::D(entry) => serde_json::to_value(entry),
|
|
18
|
-
Either25::F(entry) => serde_json::to_value(entry),
|
|
19
|
-
Either25::G(entry) => serde_json::to_value(entry),
|
|
20
|
-
Either25::H(entry) => serde_json::to_value(entry),
|
|
21
|
-
Either25::I(entry) => serde_json::to_value(entry),
|
|
22
|
-
Either25::J(entry) => serde_json::to_value(entry),
|
|
23
|
-
Either25::K(entry) => serde_json::to_value(entry),
|
|
24
|
-
Either25::L(entry) => serde_json::to_value(entry),
|
|
25
|
-
Either25::M(entry) => serde_json::to_value(entry),
|
|
26
|
-
Either25::N(entry) => serde_json::to_value(entry),
|
|
27
|
-
Either25::O(entry) => serde_json::to_value(entry),
|
|
28
|
-
Either25::P(entry) => serde_json::to_value(entry),
|
|
29
|
-
Either25::Q(entry) => serde_json::to_value(entry),
|
|
30
|
-
Either25::R(entry) => serde_json::to_value(entry),
|
|
31
|
-
Either25::S(entry) => serde_json::to_value(entry),
|
|
32
|
-
Either25::T(entry) => serde_json::to_value(entry),
|
|
33
|
-
Either25::U(entry) => serde_json::to_value(entry),
|
|
34
|
-
Either25::V(entry) => serde_json::to_value(entry),
|
|
35
|
-
Either25::W(entry) => serde_json::to_value(entry),
|
|
36
|
-
Either25::X(entry) => serde_json::to_value(entry),
|
|
37
|
-
Either25::Y(entry) => serde_json::to_value(entry),
|
|
38
|
-
// Decode the error message from the return data
|
|
39
|
-
Either25::E(entry @ RevertErrorStackTraceEntry { .. }) => {
|
|
40
|
-
use serde::de::Error;
|
|
41
|
-
|
|
42
|
-
let decoded_error_msg = ReturnData::new(entry.return_data.clone())
|
|
43
|
-
.decode_error()
|
|
44
|
-
.map_err(|e| {
|
|
45
|
-
serde_json::Error::custom(format_args!("Error decoding return data: {e}"))
|
|
46
|
-
})?;
|
|
47
|
-
|
|
48
|
-
let mut value = serde_json::to_value(entry)?;
|
|
49
|
-
if let Some(obj) = value.as_object_mut() {
|
|
50
|
-
obj.insert("message".to_string(), decoded_error_msg.into());
|
|
51
|
-
}
|
|
52
|
-
Ok(value)
|
|
53
|
-
}
|
|
54
|
-
})
|
|
55
|
-
.collect::<Result<Vec<_>, _>>()
|
|
56
|
-
.map_err(|e| napi::Error::from_reason(format!("Error converting to JSON: {e}")))?;
|
|
57
|
-
|
|
58
|
-
println!("{}", serde_json::to_string_pretty(&entry_values)?);
|
|
59
|
-
|
|
60
|
-
Ok(())
|
|
61
|
-
}
|
package/src/trace/exit.rs
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
//! Naive rewrite of `hardhat-network/provider/vm/exit.ts` from Hardhat.
|
|
2
|
-
//! Used together with `VmTracer`.
|
|
3
|
-
|
|
4
|
-
use std::fmt;
|
|
5
|
-
|
|
6
|
-
use edr_evm_spec::EvmHaltReason;
|
|
7
|
-
use napi_derive::napi;
|
|
8
|
-
|
|
9
|
-
#[napi]
|
|
10
|
-
pub struct Exit(pub(crate) ExitCode);
|
|
11
|
-
|
|
12
|
-
#[napi]
|
|
13
|
-
/// Represents the exit code of the EVM.
|
|
14
|
-
#[derive(Debug, PartialEq, Eq)]
|
|
15
|
-
#[allow(clippy::upper_case_acronyms, non_camel_case_types)] // These are exported and mapped 1:1 to existing JS enum
|
|
16
|
-
pub enum ExitCode {
|
|
17
|
-
/// Execution was successful.
|
|
18
|
-
SUCCESS = 0,
|
|
19
|
-
/// Execution was reverted.
|
|
20
|
-
REVERT,
|
|
21
|
-
/// Execution ran out of gas.
|
|
22
|
-
OUT_OF_GAS,
|
|
23
|
-
/// Execution encountered an internal error.
|
|
24
|
-
INTERNAL_ERROR,
|
|
25
|
-
/// Execution encountered an invalid opcode.
|
|
26
|
-
INVALID_OPCODE,
|
|
27
|
-
/// Execution encountered a stack underflow.
|
|
28
|
-
STACK_UNDERFLOW,
|
|
29
|
-
/// Create init code size exceeds limit (runtime).
|
|
30
|
-
CODESIZE_EXCEEDS_MAXIMUM,
|
|
31
|
-
/// Create collision.
|
|
32
|
-
CREATE_COLLISION,
|
|
33
|
-
/// Unknown halt reason.
|
|
34
|
-
UNKNOWN_HALT_REASON,
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
impl fmt::Display for ExitCode {
|
|
38
|
-
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
39
|
-
match self {
|
|
40
|
-
ExitCode::SUCCESS => write!(f, "Success"),
|
|
41
|
-
ExitCode::REVERT => write!(f, "Reverted"),
|
|
42
|
-
ExitCode::OUT_OF_GAS => write!(f, "Out of gas"),
|
|
43
|
-
ExitCode::INTERNAL_ERROR => write!(f, "Internal error"),
|
|
44
|
-
ExitCode::INVALID_OPCODE => write!(f, "Invalid opcode"),
|
|
45
|
-
ExitCode::STACK_UNDERFLOW => write!(f, "Stack underflow"),
|
|
46
|
-
ExitCode::CODESIZE_EXCEEDS_MAXIMUM => write!(f, "Codesize exceeds maximum"),
|
|
47
|
-
ExitCode::CREATE_COLLISION => write!(f, "Create collision"),
|
|
48
|
-
ExitCode::UNKNOWN_HALT_REASON => write!(f, "Unknown halt reason"),
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
#[allow(clippy::fallible_impl_from)] // naively ported for now
|
|
54
|
-
impl From<edr_solidity::exit_code::ExitCode<EvmHaltReason>> for ExitCode {
|
|
55
|
-
fn from(code: edr_solidity::exit_code::ExitCode<EvmHaltReason>) -> Self {
|
|
56
|
-
use edr_solidity::exit_code::ExitCode;
|
|
57
|
-
|
|
58
|
-
match code {
|
|
59
|
-
ExitCode::Success => Self::SUCCESS,
|
|
60
|
-
ExitCode::Revert => Self::REVERT,
|
|
61
|
-
ExitCode::Halt(EvmHaltReason::OutOfGas(_)) => Self::OUT_OF_GAS,
|
|
62
|
-
ExitCode::Halt(EvmHaltReason::OpcodeNotFound | EvmHaltReason::InvalidFEOpcode
|
|
63
|
-
// Returned when an opcode is not implemented for the hardfork
|
|
64
|
-
| EvmHaltReason::NotActivated) => Self::INVALID_OPCODE,
|
|
65
|
-
ExitCode::Halt(EvmHaltReason::StackUnderflow) => Self::STACK_UNDERFLOW,
|
|
66
|
-
ExitCode::Halt(EvmHaltReason::CreateContractSizeLimit) => Self::CODESIZE_EXCEEDS_MAXIMUM,
|
|
67
|
-
ExitCode::Halt(EvmHaltReason::CreateCollision) => Self::CREATE_COLLISION,
|
|
68
|
-
_ => Self::UNKNOWN_HALT_REASON,
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
#[napi]
|
|
74
|
-
impl Exit {
|
|
75
|
-
#[napi(catch_unwind, getter)]
|
|
76
|
-
pub fn kind(&self) -> ExitCode {
|
|
77
|
-
self.0
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
#[napi(catch_unwind)]
|
|
81
|
-
pub fn is_error(&self) -> bool {
|
|
82
|
-
!matches!(self.0, ExitCode::SUCCESS)
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
#[napi(catch_unwind)]
|
|
86
|
-
pub fn get_reason(&self) -> String {
|
|
87
|
-
self.0.to_string()
|
|
88
|
-
}
|
|
89
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
use napi_derive::napi;
|
|
2
|
-
|
|
3
|
-
#[napi(catch_unwind)]
|
|
4
|
-
pub fn link_hex_string_bytecode(
|
|
5
|
-
code: String,
|
|
6
|
-
address: String,
|
|
7
|
-
position: u32,
|
|
8
|
-
) -> napi::Result<String> {
|
|
9
|
-
edr_solidity::library_utils::link_hex_string_bytecode(code, &address, position)
|
|
10
|
-
.map_err(|err| napi::Error::from_reason(err.to_string()))
|
|
11
|
-
}
|
package/src/trace/model.rs
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
use std::rc::Rc;
|
|
2
|
-
|
|
3
|
-
use edr_solidity::build_model::ContractMetadata;
|
|
4
|
-
use napi_derive::napi;
|
|
5
|
-
use serde::Serialize;
|
|
6
|
-
|
|
7
|
-
/// Opaque handle to the `Bytecode` struct.
|
|
8
|
-
/// Only used on the JS side by the `VmTraceDecoder` class.
|
|
9
|
-
// NOTE: Needed, because we store the resolved `Bytecode` in the MessageTrace
|
|
10
|
-
// JS plain objects and those need a dedicated (class) type.
|
|
11
|
-
#[napi]
|
|
12
|
-
pub struct BytecodeWrapper(pub(crate) Rc<ContractMetadata>);
|
|
13
|
-
|
|
14
|
-
impl BytecodeWrapper {
|
|
15
|
-
pub fn new(bytecode: Rc<ContractMetadata>) -> Self {
|
|
16
|
-
Self(bytecode)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
pub fn inner(&self) -> &Rc<ContractMetadata> {
|
|
20
|
-
&self.0
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
impl std::ops::Deref for BytecodeWrapper {
|
|
25
|
-
type Target = ContractMetadata;
|
|
26
|
-
|
|
27
|
-
fn deref(&self) -> &Self::Target {
|
|
28
|
-
&self.0
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
#[derive(Debug, PartialEq, Eq, Serialize)]
|
|
33
|
-
#[allow(non_camel_case_types)] // intentionally mimicks the original case in TS
|
|
34
|
-
#[allow(clippy::upper_case_acronyms)]
|
|
35
|
-
#[napi]
|
|
36
|
-
// Mimicks [`edr_solidity::build_model::ContractFunctionType`].
|
|
37
|
-
pub enum ContractFunctionType {
|
|
38
|
-
CONSTRUCTOR,
|
|
39
|
-
FUNCTION,
|
|
40
|
-
FALLBACK,
|
|
41
|
-
RECEIVE,
|
|
42
|
-
GETTER,
|
|
43
|
-
MODIFIER,
|
|
44
|
-
FREE_FUNCTION,
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
impl From<edr_solidity::build_model::ContractFunctionType> for ContractFunctionType {
|
|
48
|
-
fn from(value: edr_solidity::build_model::ContractFunctionType) -> Self {
|
|
49
|
-
match value {
|
|
50
|
-
edr_solidity::build_model::ContractFunctionType::Constructor => Self::CONSTRUCTOR,
|
|
51
|
-
edr_solidity::build_model::ContractFunctionType::Function => Self::FUNCTION,
|
|
52
|
-
edr_solidity::build_model::ContractFunctionType::Fallback => Self::FALLBACK,
|
|
53
|
-
edr_solidity::build_model::ContractFunctionType::Receive => Self::RECEIVE,
|
|
54
|
-
edr_solidity::build_model::ContractFunctionType::Getter => Self::GETTER,
|
|
55
|
-
edr_solidity::build_model::ContractFunctionType::Modifier => Self::MODIFIER,
|
|
56
|
-
edr_solidity::build_model::ContractFunctionType::FreeFunction => Self::FREE_FUNCTION,
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
package/src/trace/return_data.rs
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
//! Rewrite of `hardhat-network/provider/return-data.ts` from Hardhat.
|
|
2
|
-
|
|
3
|
-
use alloy_sol_types::SolError;
|
|
4
|
-
use napi::bindgen_prelude::{BigInt, Uint8Array};
|
|
5
|
-
use napi_derive::napi;
|
|
6
|
-
|
|
7
|
-
// Built-in error types
|
|
8
|
-
// See <https://docs.soliditylang.org/en/v0.8.26/control-structures.html#error-handling-assert-require-revert-and-exceptions>
|
|
9
|
-
alloy_sol_types::sol! {
|
|
10
|
-
error Error(string);
|
|
11
|
-
error Panic(uint256);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
#[napi]
|
|
15
|
-
pub struct ReturnData {
|
|
16
|
-
#[napi(readonly)]
|
|
17
|
-
pub value: Uint8Array,
|
|
18
|
-
selector: Option<[u8; 4]>,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
#[napi]
|
|
22
|
-
impl ReturnData {
|
|
23
|
-
#[napi(catch_unwind, constructor)]
|
|
24
|
-
pub fn new(value: Uint8Array) -> Self {
|
|
25
|
-
let selector = value
|
|
26
|
-
.get(0..4)
|
|
27
|
-
.map(|selector| selector.try_into().expect("selector is 4 bytes"));
|
|
28
|
-
|
|
29
|
-
Self { value, selector }
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
#[napi(catch_unwind)]
|
|
33
|
-
pub fn is_empty(&self) -> bool {
|
|
34
|
-
self.value.is_empty()
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
pub fn matches_selector(&self, selector: impl AsRef<[u8]>) -> bool {
|
|
38
|
-
self.selector
|
|
39
|
-
.is_some_and(|value| value == selector.as_ref())
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
#[napi(catch_unwind)]
|
|
43
|
-
pub fn is_error_return_data(&self) -> bool {
|
|
44
|
-
self.selector == Some(Error::SELECTOR)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
#[napi(catch_unwind)]
|
|
48
|
-
pub fn is_panic_return_data(&self) -> bool {
|
|
49
|
-
self.selector == Some(Panic::SELECTOR)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
#[napi(catch_unwind)]
|
|
53
|
-
pub fn decode_error(&self) -> napi::Result<String> {
|
|
54
|
-
if self.is_empty() {
|
|
55
|
-
return Ok(String::new());
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if !self.is_error_return_data() {
|
|
59
|
-
return Err(napi::Error::new(
|
|
60
|
-
napi::Status::InvalidArg,
|
|
61
|
-
"VM Exception while processing transaction: Expected return data to be a Error(string)",
|
|
62
|
-
));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
let result = Error::abi_decode(&self.value[..]).map_err(|_err| {
|
|
66
|
-
napi::Error::new(
|
|
67
|
-
napi::Status::InvalidArg,
|
|
68
|
-
"VM Exception while processing transaction: Expected return data to contain a valid string",
|
|
69
|
-
)
|
|
70
|
-
})?;
|
|
71
|
-
|
|
72
|
-
Ok(result.0)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
#[napi(catch_unwind)]
|
|
76
|
-
pub fn decode_panic(&self) -> napi::Result<BigInt> {
|
|
77
|
-
if !self.is_panic_return_data() {
|
|
78
|
-
return Err(napi::Error::new(
|
|
79
|
-
napi::Status::InvalidArg,
|
|
80
|
-
"VM Exception while processing transaction: Expected return data to be a Panic(uint256)",
|
|
81
|
-
));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
let result = Panic::abi_decode(&self.value[..]).map_err(|_err| {
|
|
85
|
-
napi::Error::new(
|
|
86
|
-
napi::Status::InvalidArg,
|
|
87
|
-
"VM Exception while processing transaction: Expected return data to contain a valid uint256",
|
|
88
|
-
)
|
|
89
|
-
})?;
|
|
90
|
-
|
|
91
|
-
Ok(BigInt {
|
|
92
|
-
sign_bit: false,
|
|
93
|
-
words: result.0.as_limbs().to_vec(),
|
|
94
|
-
})
|
|
95
|
-
}
|
|
96
|
-
}
|