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

fix(core): GethTrace shouldn't have 0x prefix for return_value #1705

Merged
merged 1 commit into from
Sep 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()))
}