|
1 | 1 | use alloy_json_abi::JsonAbi;
|
2 |
| -use alloy_primitives::{Address, Bytes, map::HashMap}; |
3 | 2 | use eyre::{Result, WrapErr};
|
4 |
| -use foundry_common::{ |
5 |
| - ContractsByArtifact, TestFunctionExt, compile::ProjectCompiler, fs, selectors::SelectorKind, |
6 |
| - shell, |
7 |
| -}; |
| 3 | +use foundry_common::{TestFunctionExt, fs, selectors::SelectorKind, shell}; |
8 | 4 | use foundry_compilers::{
|
9 | 5 | Artifact, ArtifactId, ProjectCompileOutput,
|
10 | 6 | artifacts::{CompactBytecode, Settings},
|
11 | 7 | cache::{CacheEntry, CompilerCache},
|
12 | 8 | utils::read_json_file,
|
13 | 9 | };
|
14 | 10 | use foundry_config::{Chain, Config, NamedChain, error::ExtractConfigError, figment::Figment};
|
15 |
| -use foundry_debugger::Debugger; |
16 | 11 | use foundry_evm::{
|
17 | 12 | executors::{DeployResult, EvmError, RawCallResult},
|
18 | 13 | opts::EvmOpts,
|
19 | 14 | traces::{
|
20 |
| - CallTraceDecoder, CallTraceDecoderBuilder, TraceKind, Traces, |
21 |
| - debug::{ContractSources, DebugTraceIdentifier}, |
22 |
| - decode_trace_arena, |
23 |
| - identifier::{SignaturesCache, SignaturesIdentifier, TraceIdentifiers}, |
| 15 | + CallTraceDecoder, TraceKind, Traces, decode_trace_arena, identifier::SignaturesCache, |
24 | 16 | render_trace_arena_inner,
|
25 | 17 | },
|
26 | 18 | };
|
27 | 19 | use std::{
|
28 | 20 | fmt::Write,
|
29 | 21 | path::{Path, PathBuf},
|
30 |
| - str::FromStr, |
31 | 22 | };
|
32 | 23 | use yansi::Paint;
|
33 | 24 |
|
@@ -331,85 +322,6 @@ impl TryFrom<Result<RawCallResult>> for TraceResult {
|
331 | 322 | }
|
332 | 323 | }
|
333 | 324 |
|
334 |
| -/// labels the traces, conditionally prints them or opens the debugger |
335 |
| -#[expect(clippy::too_many_arguments)] |
336 |
| -pub async fn handle_traces( |
337 |
| - mut result: TraceResult, |
338 |
| - config: &Config, |
339 |
| - chain: Option<Chain>, |
340 |
| - contracts_bytecode: &HashMap<Address, Bytes>, |
341 |
| - labels: Vec<String>, |
342 |
| - with_local_artifacts: bool, |
343 |
| - debug: bool, |
344 |
| - decode_internal: bool, |
345 |
| - disable_label: bool, |
346 |
| -) -> Result<()> { |
347 |
| - let (known_contracts, mut sources) = if with_local_artifacts { |
348 |
| - let _ = sh_println!("Compiling project to generate artifacts"); |
349 |
| - let project = config.project()?; |
350 |
| - let compiler = ProjectCompiler::new(); |
351 |
| - let output = compiler.compile(&project)?; |
352 |
| - ( |
353 |
| - Some(ContractsByArtifact::new( |
354 |
| - output.artifact_ids().map(|(id, artifact)| (id, artifact.clone().into())), |
355 |
| - )), |
356 |
| - ContractSources::from_project_output(&output, project.root(), None)?, |
357 |
| - ) |
358 |
| - } else { |
359 |
| - (None, ContractSources::default()) |
360 |
| - }; |
361 |
| - |
362 |
| - let labels = labels.iter().filter_map(|label_str| { |
363 |
| - let mut iter = label_str.split(':'); |
364 |
| - |
365 |
| - if let Some(addr) = iter.next() |
366 |
| - && let (Ok(address), Some(label)) = (Address::from_str(addr), iter.next()) |
367 |
| - { |
368 |
| - return Some((address, label.to_string())); |
369 |
| - } |
370 |
| - None |
371 |
| - }); |
372 |
| - let config_labels = config.labels.clone().into_iter(); |
373 |
| - |
374 |
| - let mut builder = CallTraceDecoderBuilder::new() |
375 |
| - .with_labels(labels.chain(config_labels)) |
376 |
| - .with_signature_identifier(SignaturesIdentifier::from_config(config)?) |
377 |
| - .with_label_disabled(disable_label); |
378 |
| - let mut identifier = TraceIdentifiers::new().with_etherscan(config, chain)?; |
379 |
| - if let Some(contracts) = &known_contracts { |
380 |
| - builder = builder.with_known_contracts(contracts); |
381 |
| - identifier = identifier.with_local_and_bytecodes(contracts, contracts_bytecode); |
382 |
| - } |
383 |
| - |
384 |
| - let mut decoder = builder.build(); |
385 |
| - |
386 |
| - for (_, trace) in result.traces.as_deref_mut().unwrap_or_default() { |
387 |
| - decoder.identify(trace, &mut identifier); |
388 |
| - } |
389 |
| - |
390 |
| - if decode_internal || debug { |
391 |
| - if let Some(ref etherscan_identifier) = identifier.etherscan { |
392 |
| - sources.merge(etherscan_identifier.get_compiled_contracts().await?); |
393 |
| - } |
394 |
| - |
395 |
| - if debug { |
396 |
| - let mut debugger = Debugger::builder() |
397 |
| - .traces(result.traces.expect("missing traces")) |
398 |
| - .decoder(&decoder) |
399 |
| - .sources(sources) |
400 |
| - .build(); |
401 |
| - debugger.try_run_tui()?; |
402 |
| - return Ok(()); |
403 |
| - } |
404 |
| - |
405 |
| - decoder.debug_identifier = Some(DebugTraceIdentifier::new(sources)); |
406 |
| - } |
407 |
| - |
408 |
| - print_traces(&mut result, &decoder, shell::verbosity() > 0, shell::verbosity() > 4).await?; |
409 |
| - |
410 |
| - Ok(()) |
411 |
| -} |
412 |
| - |
413 | 325 | pub async fn print_traces(
|
414 | 326 | result: &mut TraceResult,
|
415 | 327 | decoder: &CallTraceDecoder,
|
|
0 commit comments