Skip to content

Commit

Permalink
fix: create in upstream merge (#462)
Browse files Browse the repository at this point in the history
Co-authored-by: Francesco Dainese <[email protected]>
Co-authored-by: Federico Rodríguez <[email protected]>
  • Loading branch information
3 people authored Jul 10, 2024
1 parent 1866ebd commit 233707f
Show file tree
Hide file tree
Showing 14 changed files with 522 additions and 84 deletions.
6 changes: 6 additions & 0 deletions Cargo.lock

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

8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,11 @@ revm-primitives = { git = "https://github.com/bluealloy/revm.git", rev = "41e2f7
# [patch."https://github.com/matter-labs/era-boojum"]
# cs_derive = { git = "https://github.com/nbaztec/era-boojum", branch = "foundry-fix" }
# boojum = { git = "https://github.com/nbaztec/era-boojum", branch = "foundry-fix" }

# [patch."https://github.com/moonsong-labs/compilers"]
# foundry-compilers = { path = "../msl-compilers/crates/compilers" }
# foundry-compilers-core = { path = "../msl-compilers/crates/core" }
# foundry-compilers-artifacts-vyper = { path = "../msl-compilers/crates/artifacts/vyper" }
# foundry-compilers-artifacts-solc = { path = "../msl-compilers/crates/artifacts/solc" }
# foundry-compilers-artifacts-zksolc = { path = "../msl-compilers/crates/artifacts/zksolc" }
# foundry-compilers-artifacts = { path = "../msl-compilers/crates/artifacts/artifacts" }
30 changes: 30 additions & 0 deletions crates/cli/src/utils/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use foundry_compilers::{
artifacts::{CompactBytecode, CompactDeployedBytecode, Settings},
cache::{CacheEntry, CompilerCache},
utils::read_json_file,
zksync::artifact_output::zk::ZkContractArtifact,
Artifact, ProjectCompileOutput,
};
use foundry_config::{error::ExtractConfigError, figment::Figment, Chain, Config, NamedChain};
Expand Down Expand Up @@ -70,6 +71,35 @@ pub fn remove_contract(
Ok((abi, bin, runtime))
}

/// Given a `Project`'s output, removes the matching ABI, Bytecode and
/// Runtime Bytecode of the given contract.
#[track_caller]
pub fn remove_zk_contract(
output: &mut foundry_compilers::zksync::compile::output::ProjectCompileOutput,
path: &Path,
name: &str,
) -> Result<ZkContractArtifact> {
let contract = if let Some(contract) = output.remove(path.to_string_lossy(), name) {
contract
} else {
let mut err = format!("could not find artifact: `{name}`");
if let Some(suggestion) =
super::did_you_mean(name, output.artifacts().map(|(name, _)| name)).pop()
{
if suggestion != name {
err = format!(
r#"{err}
Did you mean `{suggestion}`?"#
);
}
}
eyre::bail!(err)
};

Ok(contract)
}

/// Helper function for finding a contract by ContractName
// TODO: Is there a better / more ergonomic way to get the artifacts given a project and a
// contract name?
Expand Down
Loading

0 comments on commit 233707f

Please sign in to comment.