This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 796
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(solc): consider case sensitive conflicting artifact paths (#1625)
* fix(solc): consider case sensitive conflicting artifact paths * chore: fmt Co-authored-by: Georgios Konstantopoulos <[email protected]>
- Loading branch information
Showing
4 changed files
with
186 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
use crate::contracts::VersionedContract; | ||
use std::{ | ||
collections::HashMap, | ||
hash::Hash, | ||
ops::{Deref, DerefMut}, | ||
path::{Path, PathBuf}, | ||
}; | ||
|
||
/// Container type for all contracts mapped to their output file | ||
pub struct MappedArtifactFiles<'a> { | ||
/// Represents the determined output artifact file and the contract(s) that target it | ||
/// | ||
/// This is guaranteed to be `len >= 1` | ||
/// | ||
/// If there is more than 1 contract in the map, this means we have a naming conflict where | ||
/// different contracts target the same output file. This happens if the solidity file and | ||
/// contract name match, but they are in different folders. | ||
pub files: HashMap<MappedArtifactFile, Vec<MappedContract<'a>>>, | ||
} | ||
|
||
impl<'a> MappedArtifactFiles<'a> { | ||
pub fn with_capacity(len: usize) -> Self { | ||
Self { files: HashMap::with_capacity(len) } | ||
} | ||
} | ||
|
||
impl<'a> Deref for MappedArtifactFiles<'a> { | ||
type Target = HashMap<MappedArtifactFile, Vec<MappedContract<'a>>>; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.files | ||
} | ||
} | ||
|
||
impl<'a> DerefMut for MappedArtifactFiles<'a> { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.files | ||
} | ||
} | ||
|
||
/// Represents the targeted path of a contract or multiple contracts | ||
/// | ||
/// To account for case-sensitivity we identify it via lowercase path | ||
#[derive(Debug, Hash, PartialEq, Eq)] | ||
pub struct MappedArtifactFile { | ||
lower_case_path: String, | ||
} | ||
|
||
impl MappedArtifactFile { | ||
pub fn new(path: &Path) -> Self { | ||
Self { lower_case_path: path.to_string_lossy().to_lowercase() } | ||
} | ||
} | ||
|
||
pub struct MappedContract<'a> { | ||
pub file: &'a str, | ||
pub name: &'a str, | ||
pub contract: &'a VersionedContract, | ||
pub artifact_path: PathBuf, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters