Skip to content

Commit

Permalink
chore: trace output utils (alloy-rs#1027)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored and ben186 committed Jul 27, 2024
1 parent 1f79997 commit 9664d9f
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions crates/rpc-types-trace/src/parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,28 @@ pub enum TraceOutput {
Create(CreateOutput),
}

// === impl TraceOutput ===

impl TraceOutput {
/// Returns the output of this trace.
pub const fn output(&self) -> &Bytes {
match self {
Self::Call(call) => &call.output,
Self::Create(create) => &create.code,
}
}

/// Consumes the output of this trace.
pub fn into_output(self) -> Bytes {
match self {
Self::Call(call) => call.output,
Self::Create(create) => create.code,
}
}

/// Returns the gas used by this trace.
pub const fn gas_used(&self) -> U64 {
pub fn gas_used(&self) -> u64 {
match self {
Self::Call(call) => call.gas_used,
Self::Create(create) => create.gas_used,
Self::Call(call) => call.gas_used.to(),
Self::Create(create) => create.gas_used.to(),
}
}

Expand Down

0 comments on commit 9664d9f

Please sign in to comment.