Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create in upstream merge #462

Merged
merged 17 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we move zk related helpers to a respective module/crate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can refactor this once we have a better picture.
In general it's easier to have everything in one place, but we need to plan it properly as most times the "zk" functions are a copy-paste of the original ones with a few modifications. So when a upstream merge comes, we want to include those updates to the original function.

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
Loading