Skip to content

Commit

Permalink
fix(solc): ensure std json sources are unique (gakonst#1210)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed May 3, 2022
1 parent f074f3d commit e7e5abc
Showing 1 changed file with 8 additions and 2 deletions.
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

0 comments on commit e7e5abc

Please sign in to comment.