Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

fix(solc): ensure std json sources are unique #1210

Merged
Merged
Changes from all 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
10 changes: 8 additions & 2 deletions ethers-solc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pub mod artifacts;
pub mod sourcemap;

pub use artifacts::{CompilerInput, CompilerOutput, EvmVersion};
use std::collections::BTreeMap;
use std::collections::{BTreeMap, HashSet};

mod artifact_output;
pub mod cache;
Expand Down Expand Up @@ -440,11 +440,17 @@ impl<T: ArtifactOutput> Project<T> {
let target_index = graph.files().get(target).ok_or_else(|| {
SolcError::msg(format!("cannot resolve file at {:?}", target.display()))
})?;

let mut sources = Vec::new();
let mut unique_paths = HashSet::new();
let (path, source) = graph.node(*target_index).unpack();
unique_paths.insert(path.clone());
sources.push((path, source));
sources.extend(
graph.all_imported_nodes(*target_index).map(|index| graph.node(index).unpack()),
graph
.all_imported_nodes(*target_index)
.map(|index| graph.node(index).unpack())
.filter(|(p, _)| unique_paths.insert(p.to_path_buf())),
);

let root = self.root();
Expand Down