Skip to content

Commit

Permalink
chore(deps): bump foundry-compilers (foundry-rs#8291)
Browse files Browse the repository at this point in the history
* chore(deps): bump foundry-compilers

* bumpies
  • Loading branch information
DaniPopes authored Jun 29, 2024
1 parent 844f3f5 commit 07b0ec3
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 42 deletions.
25 changes: 13 additions & 12 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ foundry-wallets = { path = "crates/wallets" }
foundry-linking = { path = "crates/linking" }

# solc & compilation utilities
foundry-block-explorers = { version = "0.4.1", default-features = false }
foundry-compilers = { version = "0.8.0", default-features = false }
foundry-block-explorers = { version = "0.5.0", default-features = false }
foundry-compilers = { version = "0.9.0", default-features = false }
solang-parser = "=0.3.3"

## revm
Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/utils/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub fn remove_contract(
path: &Path,
name: &str,
) -> Result<(JsonAbi, CompactBytecode, CompactDeployedBytecode)> {
let contract = if let Some(contract) = output.remove(path.to_string_lossy(), name) {
let contract = if let Some(contract) = output.remove(path, name) {
contract
} else {
let mut err = format!("could not find artifact: `{name}`");
Expand Down
1 change: 1 addition & 0 deletions crates/config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,6 +1313,7 @@ impl Config {
"evm.bytecode".to_string(),
"evm.deployedBytecode".to_string(),
]),
search_paths: None,
})
}

Expand Down
6 changes: 2 additions & 4 deletions crates/config/src/providers/remappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,8 @@ impl<'a> RemappingsProvider<'a> {
.lib_paths
.iter()
.map(|lib| self.root.join(lib))
.inspect(|lib| {
trace!("find all remappings in lib path: {:?}", lib);
})
.flat_map(Remapping::find_many)
.inspect(|lib| trace!(?lib, "find all remappings"))
.flat_map(|lib| Remapping::find_many(&lib))
{
// this is an additional safety check for weird auto-detected remappings
if ["lib/", "src/", "contracts/"].contains(&r.name.as_str()) {
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/bin/cmd/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl BuildArgs {

// Collect sources to compile if build subdirectories specified.
let mut files = vec![];
if let Some(paths) = self.paths {
if let Some(paths) = &self.paths {
for path in paths {
files.extend(source_files_iter(path, MultiCompilerLanguage::FILE_EXTENSIONS));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/bin/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ fn init_git_repo(git: Git<'_>, no_commit: bool) -> Result<()> {
fn init_vscode(root: &Path) -> Result<()> {
let remappings_file = root.join("remappings.txt");
if !remappings_file.exists() {
let mut remappings = Remapping::find_many(root.join("lib"))
let mut remappings = Remapping::find_many(&root.join("lib"))
.into_iter()
.map(|r| r.into_relative(root).to_relative_remapping().to_string())
.collect::<Vec<_>>();
Expand Down
2 changes: 1 addition & 1 deletion crates/forge/bin/cmd/test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl TestArgs {

// Always recompile all sources to ensure that `getCode` cheatcode can use any artifact.
test_sources.extend(source_files_iter(
project.paths.sources,
&project.paths.sources,
MultiCompilerLanguage::FILE_EXTENSIONS,
));

Expand Down
8 changes: 1 addition & 7 deletions crates/forge/src/multi_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,7 @@ impl MultiContractRunnerBuilder {
) -> Result<MultiContractRunner> {
let contracts = output
.artifact_ids()
.map(|(mut id, v)| {
// TODO: Use ArtifactId::with_stripped_file_prefixes
if let Ok(stripped) = id.source.strip_prefix(root) {
id.source = stripped.to_path_buf();
}
(id, v)
})
.map(|(id, v)| (id.with_stripped_file_prefixes(root), v))
.collect();
let linker = Linker::new(root, contracts);

Expand Down
8 changes: 4 additions & 4 deletions crates/forge/tests/cli/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,15 +577,15 @@ forgetest_init!(can_emit_extra_output, |prj, cmd| {

let artifact_path = prj.paths().artifacts.join(TEMPLATE_CONTRACT_ARTIFACT_JSON);
let artifact: ConfigurableContractArtifact =
foundry_compilers::utils::read_json_file(artifact_path).unwrap();
foundry_compilers::utils::read_json_file(&artifact_path).unwrap();
assert!(artifact.metadata.is_some());

cmd.forge_fuse().args(["build", "--extra-output-files", "metadata", "--force"]).root_arg();
cmd.assert_non_empty_stdout();

let metadata_path =
prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.metadata.json"));
let _artifact: Metadata = foundry_compilers::utils::read_json_file(metadata_path).unwrap();
let _artifact: Metadata = foundry_compilers::utils::read_json_file(&metadata_path).unwrap();
});

// checks that extra output works
Expand All @@ -595,7 +595,7 @@ forgetest_init!(can_emit_multiple_extra_output, |prj, cmd| {

let artifact_path = prj.paths().artifacts.join(TEMPLATE_CONTRACT_ARTIFACT_JSON);
let artifact: ConfigurableContractArtifact =
foundry_compilers::utils::read_json_file(artifact_path).unwrap();
foundry_compilers::utils::read_json_file(&artifact_path).unwrap();
assert!(artifact.metadata.is_some());
assert!(artifact.ir.is_some());
assert!(artifact.ir_optimized.is_some());
Expand All @@ -614,7 +614,7 @@ forgetest_init!(can_emit_multiple_extra_output, |prj, cmd| {

let metadata_path =
prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.metadata.json"));
let _artifact: Metadata = foundry_compilers::utils::read_json_file(metadata_path).unwrap();
let _artifact: Metadata = foundry_compilers::utils::read_json_file(&metadata_path).unwrap();

let iropt = prj.paths().artifacts.join(format!("{TEMPLATE_CONTRACT_ARTIFACT_BASE}.iropt"));
std::fs::read_to_string(iropt).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions crates/linking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl<'a> Linker<'a> {
let (file, name) = self.convert_artifact_id_to_lib_path(id);

for (_, bytecode) in &mut needed_libraries {
bytecode.to_mut().link(file.to_string_lossy(), name.clone(), address);
bytecode.to_mut().link(&file.to_string_lossy(), &name, address);
}

libraries.libs.entry(file).or_default().insert(name, address.to_checksum(None));
Expand All @@ -253,12 +253,12 @@ impl<'a> Linker<'a> {
for (name, address) in libs {
let address = Address::from_str(address).map_err(LinkerError::InvalidAddress)?;
if let Some(bytecode) = contract.bytecode.as_mut() {
bytecode.to_mut().link(file.to_string_lossy(), name, address);
bytecode.to_mut().link(&file.to_string_lossy(), name, address);
}
if let Some(deployed_bytecode) =
contract.deployed_bytecode.as_mut().and_then(|b| b.to_mut().bytecode.as_mut())
{
deployed_bytecode.link(file.to_string_lossy(), name, address);
deployed_bytecode.link(&file.to_string_lossy(), name, address);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/verify/src/etherscan/flatten.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::provider::VerificationContext;
use eyre::{Context, Result};
use foundry_block_explorers::verify::CodeFormat;
use foundry_compilers::{
artifacts::{BytecodeHash, Source},
artifacts::{BytecodeHash, Source, Sources},
buildinfo::RawBuildInfo,
compilers::{
solc::{SolcCompiler, SolcLanguage, SolcVersionedInput},
Expand All @@ -13,7 +13,7 @@ use foundry_compilers::{
AggregatedCompilerOutput,
};
use semver::{BuildMetadata, Version};
use std::{collections::BTreeMap, path::Path};
use std::path::Path;

#[derive(Debug)]
pub struct EtherscanFlattenedSource;
Expand Down Expand Up @@ -81,7 +81,7 @@ impl EtherscanFlattenedSource {
let solc = Solc::find_or_install(&version)?;

let input = SolcVersionedInput::build(
BTreeMap::from([("contract.sol".into(), Source::new(content))]),
Sources::from([("contract.sol".into(), Source::new(content))]),
Default::default(),
SolcLanguage::Solidity,
version.clone(),
Expand Down
2 changes: 1 addition & 1 deletion crates/verify/src/etherscan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ impl EtherscanVerificationProvider {

let output = context.project.compile_file(&context.target_path)?;
let artifact = output
.find(context.target_path.to_string_lossy(), &context.target_name)
.find(&context.target_path, &context.target_name)
.ok_or_eyre("Contract artifact wasn't found locally")?;
let bytecode = artifact
.get_bytecode_object()
Expand Down
4 changes: 2 additions & 2 deletions crates/verify/src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl VerificationContext {
.compile(&project)?;

let artifact = output
.find(self.target_path.to_string_lossy(), &self.target_name)
.find(&self.target_path, &self.target_name)
.ok_or_eyre("failed to find target artifact when compiling for abi")?;

artifact.abi.clone().ok_or_eyre("target artifact does not have an ABI")
Expand All @@ -74,7 +74,7 @@ impl VerificationContext {
.compile(&project)?;

let artifact = output
.find(self.target_path.to_string_lossy(), &self.target_name)
.find(&self.target_path, &self.target_name)
.ok_or_eyre("failed to find target artifact when compiling for metadata")?;

artifact.metadata.clone().ok_or_eyre("target artifact does not have an ABI")
Expand Down

0 comments on commit 07b0ec3

Please sign in to comment.