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

This commit is contained in:
Alexey Shekhirin 2022-09-16 01:18:08 +01:00 committed by GitHub
parent 9773a76dd4
commit 78e406b261
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 2 deletions

View File

@ -1,5 +1,5 @@
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
@ -7,7 +7,7 @@ use std::collections::BTreeMap;
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>,
@ -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()))
}