Skip to content

Commit

Permalink
chore: try from eyre:Result for TraceResult (display chained error) (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy authored Oct 28, 2024
1 parent 00415bb commit 0191e17
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/cast/bin/cmd/run.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy_primitives::U256;
use alloy_provider::Provider;
use alloy_rpc_types::BlockTransactions;
use cast::{revm::primitives::EnvWithHandlerCfg, traces::TraceKind};
use cast::revm::primitives::EnvWithHandlerCfg;
use clap::Parser;
use eyre::{Result, WrapErr};
use foundry_cli::{
Expand Down Expand Up @@ -235,7 +235,7 @@ impl RunArgs {

if let Some(to) = tx.to {
trace!(tx=?tx.hash, to=?to, "executing call transaction");
TraceResult::from_raw(executor.transact_with_env(env)?, TraceKind::Execution)
TraceResult::try_from(executor.transact_with_env(env))?
} else {
trace!(tx=?tx.hash, "executing create transaction");
TraceResult::try_from(executor.deploy_with_env(env, None))?
Expand Down
17 changes: 17 additions & 0 deletions crates/cli/src/utils/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,23 @@ impl TryFrom<Result<DeployResult, EvmError>> for TraceResult {
}
}

impl From<RawCallResult> for TraceResult {
fn from(result: RawCallResult) -> Self {
Self::from_raw(result, TraceKind::Execution)
}
}

impl TryFrom<Result<RawCallResult>> for TraceResult {
type Error = EvmError;

fn try_from(value: Result<RawCallResult>) -> Result<Self, Self::Error> {
match value {
Ok(result) => Ok(Self::from(result)),
Err(err) => Err(EvmError::from(err)),
}
}
}

/// labels the traces, conditionally prints them or opens the debugger
pub async fn handle_traces(
mut result: TraceResult,
Expand Down

0 comments on commit 0191e17

Please sign in to comment.