From a39415bd0025bf39e0a3ef2ea5d42efbb956fa97 Mon Sep 17 00:00:00 2001 From: DaniPopes <57450786+DaniPopes@users.noreply.github.com> Date: Tue, 9 Jul 2024 19:19:08 +0200 Subject: [PATCH] chore: trace output utils (#1027) --- crates/rpc-types-trace/src/parity.rs | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/crates/rpc-types-trace/src/parity.rs b/crates/rpc-types-trace/src/parity.rs index caadcd18cc9..e3c1ef4d539 100644 --- a/crates/rpc-types-trace/src/parity.rs +++ b/crates/rpc-types-trace/src/parity.rs @@ -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(), } }