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

change: Expose additional fields #16

Merged
merged 3 commits into from
Jan 30, 2024
Merged
Changes from 2 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
22 changes: 11 additions & 11 deletions src/tracing/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,30 +181,30 @@ impl CallTraceNode {

/// Returns true if this is a call to a precompile
#[inline]
pub(crate) fn is_precompile(&self) -> bool {
pub fn is_precompile(&self) -> bool {
self.trace.maybe_precompile.unwrap_or(false)
}

/// Returns the kind of call the trace belongs to
#[inline]
pub(crate) const fn kind(&self) -> CallKind {
pub const fn kind(&self) -> CallKind {
self.trace.kind
}

/// Returns the status of the call
#[inline]
pub(crate) const fn status(&self) -> InstructionResult {
pub const fn status(&self) -> InstructionResult {
self.trace.status
}

/// Returns true if the call was a selfdestruct
#[inline]
pub(crate) fn is_selfdestruct(&self) -> bool {
pub fn is_selfdestruct(&self) -> bool {
self.status() == InstructionResult::SelfDestruct
}

/// Converts this node into a parity `TransactionTrace`
pub(crate) fn parity_transaction_trace(&self, trace_address: Vec<usize>) -> TransactionTrace {
pub fn parity_transaction_trace(&self, trace_address: Vec<usize>) -> TransactionTrace {
let action = self.parity_action();
let result = if self.trace.is_error() && !self.trace.is_revert() {
// if the trace is a selfdestruct or an error that is not a revert, the result is None
Expand All @@ -217,7 +217,7 @@ impl CallTraceNode {
}

/// Returns the `Output` for a parity trace
pub(crate) fn parity_trace_output(&self) -> TraceOutput {
pub fn parity_trace_output(&self) -> TraceOutput {
match self.kind() {
CallKind::Call | CallKind::StaticCall | CallKind::CallCode | CallKind::DelegateCall => {
TraceOutput::Call(CallOutput {
Expand All @@ -234,7 +234,7 @@ impl CallTraceNode {
}

/// If the trace is a selfdestruct, returns the `Action` for a parity trace.
pub(crate) fn parity_selfdestruct_action(&self) -> Option<Action> {
pub fn parity_selfdestruct_action(&self) -> Option<Action> {
if self.is_selfdestruct() {
Some(Action::Selfdestruct(SelfdestructAction {
address: self.trace.address,
Expand All @@ -247,7 +247,7 @@ impl CallTraceNode {
}

/// If the trace is a selfdestruct, returns the `CallFrame` for a geth call trace
pub(crate) fn geth_selfdestruct_call_trace(&self) -> Option<CallFrame> {
pub fn geth_selfdestruct_call_trace(&self) -> Option<CallFrame> {
if self.is_selfdestruct() {
Some(CallFrame {
typ: "SELFDESTRUCT".to_string(),
Expand All @@ -262,7 +262,7 @@ impl CallTraceNode {
}

/// If the trace is a selfdestruct, returns the `TransactionTrace` for a parity trace.
pub(crate) fn parity_selfdestruct_trace(
pub fn parity_selfdestruct_trace(
&self,
trace_address: Vec<usize>,
) -> Option<TransactionTrace> {
Expand All @@ -280,7 +280,7 @@ impl CallTraceNode {
///
/// Caution: This does not include the selfdestruct action, if the trace is a selfdestruct,
/// since those are handled in addition to the call action.
pub(crate) fn parity_action(&self) -> Action {
pub fn parity_action(&self) -> Action {
match self.kind() {
CallKind::Call | CallKind::StaticCall | CallKind::CallCode | CallKind::DelegateCall => {
Action::Call(CallAction {
Expand All @@ -302,7 +302,7 @@ impl CallTraceNode {
}

/// Converts this call trace into an _empty_ geth [CallFrame]
pub(crate) fn geth_empty_call_frame(&self, include_logs: bool) -> CallFrame {
pub fn geth_empty_call_frame(&self, include_logs: bool) -> CallFrame {
let mut call_frame = CallFrame {
typ: self.trace.kind.to_string(),
from: self.trace.caller,
Expand Down
Loading