Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
fix(core): GethTrace shouldn't have 0x prefix for return_value (#1705)
Browse files Browse the repository at this point in the history
  • Loading branch information
shekhirin authored Sep 16, 2022
1 parent 9773a76 commit 78e406b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ethers-core/src/types/trace/geth.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::types::{Bytes, H256, U256};
use serde::{Deserialize, Serialize};
use serde::{Deserialize, Serialize, Serializer};
use std::collections::BTreeMap;

// https://github.com/ethereum/go-ethereum/blob/a9ef135e2dd53682d106c6a2aede9187026cc1de/eth/tracers/logger/logger.go#L406-L411
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct GethTrace {
pub failed: bool,
pub gas: u64,
#[serde(rename = "returnValue")]
#[serde(serialize_with = "serialize_bytes", rename = "returnValue")]
pub return_value: Bytes,
#[serde(rename = "structLogs")]
pub struct_logs: Vec<StructLog>,
Expand Down Expand Up @@ -54,3 +54,11 @@ pub struct GethDebugTracingOptions {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub timeout: Option<String>,
}

fn serialize_bytes<S, T>(x: T, s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
T: AsRef<[u8]>,
{
s.serialize_str(&hex::encode(x.as_ref()))
}

0 comments on commit 78e406b

Please sign in to comment.