Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding type so that we can desirialize #2

Merged
merged 1 commit into from
Oct 25, 2022
Merged
Show file tree
Hide file tree
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
27 changes: 27 additions & 0 deletions ethers-core/src/types/trace/geth.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use crate::types::{Bytes, H256, U256};
use ethabi::Address;
use serde::{Deserialize, Serialize, Serializer};
use std::collections::BTreeMap;

use super::Action;

// 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 {
Expand All @@ -13,6 +16,30 @@ pub struct GethTrace {
pub struct_logs: Vec<StructLog>,
}

// https://github.com/ethereum/go-ethereum/blob/a9ef135e2dd53682d106c6a2aede9187026cc1de/eth/tracers/logger/logger.go#L406-L411
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct GethCallTrace {
/// Action
#[serde(rename = "type")]
pub action: String,
pub from: Address,
//pub gas: u64,
//#[serde(rename = "gasUsed")]
//pub gas_used: u64,
#[serde(skip_serializing_if = "Option::is_none")]
pub to: Option<Address>,
#[serde(serialize_with = "serialize_bytes")]
pub input: Bytes,
#[serde(serialize_with = "serialize_bytes")]
pub output: Bytes,
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub revertal: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub calls: Option<Vec<GethCallTrace>>,
}

// https://github.com/ethereum/go-ethereum/blob/366d2169fbc0e0f803b68c042b77b6b480836dbc/eth/tracers/logger/logger.go#L413-L426
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct StructLog {
Expand Down
2 changes: 1 addition & 1 deletion ethers-providers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ pub trait Middleware: Sync + Send + Debug {
block: Option<BlockNumber>,
trace_options: GethDebugTracingOptions,
state_overrides: spoof::State,
) -> Result<BlockTrace, ProviderError> {
) -> Result<GethCallTrace, ProviderError> {

self.inner().debug_trace_call(tx, block, trace_options, state_overrides).await.map_err(FromErr::from)
}
Expand Down
4 changes: 2 additions & 2 deletions ethers-providers/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use ethers_core::{
Address, Block, BlockId, BlockNumber, BlockTrace, Bytes, EIP1186ProofResponse, FeeHistory,
Filter, FilterBlockOption, GethDebugTracingOptions, GethTrace, Log, NameOrAddress,
Selector, Signature, Trace, TraceFilter, TraceType, Transaction, TransactionReceipt,
TransactionRequest, TxHash, TxpoolContent, TxpoolInspect, TxpoolStatus, H256, U256, U64,
TransactionRequest, TxHash, TxpoolContent, TxpoolInspect, TxpoolStatus, H256, U256, U64, GethCallTrace,
},
utils,
};
Expand Down Expand Up @@ -990,7 +990,7 @@ impl<P: JsonRpcClient> Middleware for Provider<P> {
block: Option<BlockNumber>,
trace_options: GethDebugTracingOptions,
state_overrides: spoof::State,
) -> Result<BlockTrace, ProviderError> {
) -> Result<GethCallTrace, ProviderError> {
let tx = tx.into();
let tx = utils::serialize(&tx);

Expand Down
4 changes: 0 additions & 4 deletions ethers-providers/src/transports/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,12 @@ impl JsonRpcClient for Ws {
sender,
};

println!("payload: {:#?}", payload);

// send the data
self.send(payload)?;

// wait for the response (the request itself may have errors as well)
let res = receiver.await??;

println!("res: {:?}", res);

// parse it
Ok(serde_json::from_str(res.get())?)
}
Expand Down