Skip to content

Commit

Permalink
feat(forge): Debugger (gakonst#356)
Browse files Browse the repository at this point in the history
* hook into step

* debug steps

* mvp

* better fmting

* fixes

* fmt

* clippy

* updates

* refactor

* fmt

* inner call support

* source mapping :)

* clippy and fmt

* traces for a run cmd

* source improvements

* some cleanup

* fix coloring

* add constructor bytecode debugger

* import fix

* working sourcemap parsing

* fixes

* cargo lock

* styling

* comments

* comments mostly

* better structure + comments

* dont compile when no project

* nits + documentation

* chore: update latest ethers utils (gakonst#394)

* chore: update latest ethers utils

* rustmft

* updates primarily to run cmd

* correct documentation

* fix solang version -.-

* refactor

* fmt

* fixes

* better formatting

* force recompile

* ui update + gas tracking + known contracts fix

Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
brockelmore and mattsse authored Jan 9, 2022
1 parent 18a0c27 commit a2287d9
Show file tree
Hide file tree
Showing 19 changed files with 2,136 additions and 120 deletions.
156 changes: 134 additions & 22 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ opt-level = "z"
lto = true
codegen-units = 1
panic = "abort"
debug = true
debug = true
1 change: 1 addition & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ foundry-utils = { path = "../utils" }
forge = { path = "../forge" }
cast = { path = "../cast" }
evm-adapters = { path = "../evm-adapters" }
ui = { path = "../ui" }
dunce = "1.0.2"
# ethers = "0.5"
ethers = { git = "https://github.com/gakonst/ethers-rs", default-features = false }
Expand Down
33 changes: 33 additions & 0 deletions cli/src/cmd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pub mod verify;
use crate::opts::forge::ContractInfo;
use ethers::{
abi::Abi,
prelude::Graph,
solc::{
artifacts::{Source, Sources},
cache::SolFilesCache,
Expand Down Expand Up @@ -54,6 +55,38 @@ If you are in a subdirectory in a Git repository, try adding `--root .`"#,
Ok(output)
}

/// Manually compile a project with added sources
pub fn manual_compile(
project: &Project<MinimalCombinedArtifacts>,
added_sources: Vec<PathBuf>,
) -> eyre::Result<ProjectCompileOutput<MinimalCombinedArtifacts>> {
let mut sources = project.paths.read_input_files()?;
sources.extend(Source::read_all_files(added_sources)?);
println!("compiling...");
if project.auto_detect {
tracing::trace!("using solc auto detection to compile sources");
let output = project.svm_compile(sources)?;
if output.has_compiler_errors() {
// return the diagnostics error back to the user.
eyre::bail!(output.to_string())
}
return Ok(output)
}

let mut solc = project.solc.clone();
if !project.allowed_lib_paths.is_empty() {
solc = solc.arg("--allow-paths").arg(project.allowed_lib_paths.to_string());
}

let sources = Graph::resolve_sources(&project.paths, sources)?.into_sources();
let output = project.compile_with_version(&solc, sources)?;
if output.has_compiler_errors() {
// return the diagnostics error back to the user.
eyre::bail!(output.to_string())
}
Ok(output)
}

/// Given a project and its compiled artifacts, proceeds to return the ABI, Bytecode and
/// Runtime Bytecode of the given contract.
pub fn read_artifact(
Expand Down
Loading

0 comments on commit a2287d9

Please sign in to comment.