alloy_rpc_types_trace/
tracerequest.rsuse crate::parity::TraceType;
use alloy_primitives::map::HashSet;
use alloy_rpc_types_eth::{
request::TransactionRequest, state::StateOverride, BlockId, BlockOverrides,
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct TraceCallRequest {
pub call: TransactionRequest,
pub trace_types: HashSet<TraceType>,
pub block_id: Option<BlockId>,
pub state_overrides: Option<StateOverride>,
pub block_overrides: Option<Box<BlockOverrides>>,
}
impl TraceCallRequest {
pub fn new(call: TransactionRequest) -> Self {
Self {
call,
trace_types: HashSet::default(),
block_id: None,
state_overrides: None,
block_overrides: None,
}
}
pub const fn with_block_id(mut self, block_id: BlockId) -> Self {
self.block_id = Some(block_id);
self
}
pub fn with_state_override(mut self, state_overrides: StateOverride) -> Self {
self.state_overrides = Some(state_overrides);
self
}
pub fn with_block_overrides(mut self, block_overrides: Box<BlockOverrides>) -> Self {
self.block_overrides = Some(block_overrides);
self
}
pub fn with_trace_type(mut self, trace_type: TraceType) -> Self {
self.trace_types.insert(trace_type);
self
}
pub fn with_trace_types<I: IntoIterator<Item = TraceType>>(mut self, trace_types: I) -> Self {
self.trace_types.extend(trace_types);
self
}
pub fn with_trace(self) -> Self {
self.with_trace_type(TraceType::Trace)
}
pub fn with_vm_trace(self) -> Self {
self.with_trace_type(TraceType::VmTrace)
}
pub fn with_statediff(self) -> Self {
self.with_trace_type(TraceType::StateDiff)
}
}