Skip to content

Commit

Permalink
feat(config): add allow paths setting (#1751)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse authored May 28, 2022
1 parent 03fd04a commit 2127ecd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ test = 'test'
out = 'out'
libs = ['lib']
remappings = []
# additional solc allow paths
allow_paths = []
# list of libraries to link in the form of `<path to lib>:<lib name>:<address>`: `"src/MyLib.sol:MyLib:0x8De6DDbCd5053d32292AAA0D2105A32d108484a6"`
# the <path to lib> supports remappings
libraries = []
Expand Down
8 changes: 8 additions & 0 deletions config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ pub struct Config {
pub cache: bool,
/// where the cache is stored if enabled
pub cache_path: PathBuf,
/// additional solc allow paths
pub allow_paths: Vec<PathBuf>,
/// whether to force a `project.clean()`
pub force: bool,
/// evm version to use
Expand Down Expand Up @@ -414,6 +416,8 @@ impl Config {

self.cache_path = p(&root, &self.cache_path);

self.allow_paths = self.allow_paths.into_iter().map(|allow| p(&root, &allow)).collect();

if let Some(ref mut model_checker) = self.model_checker {
model_checker.contracts = std::mem::take(&mut model_checker.contracts)
.into_iter()
Expand Down Expand Up @@ -473,6 +477,7 @@ impl Config {
.paths(self.project_paths())
.allowed_path(&self.__root.0)
.allowed_paths(&self.libs)
.allowed_paths(&self.allow_paths)
.solc_config(SolcConfig::builder().settings(self.solc_settings()?).build())
.ignore_error_codes(self.ignored_error_codes.iter().copied().map(Into::into))
.set_auto_detect(self.is_auto_detect())
Expand Down Expand Up @@ -1229,6 +1234,7 @@ impl Default for Config {
libs: vec!["lib".into()],
cache: true,
cache_path: "cache".into(),
allow_paths: vec![],
force: false,
evm_version: Default::default(),
gas_reports: vec!["*".to_string()],
Expand Down Expand Up @@ -2209,6 +2215,7 @@ mod tests {
rpc_storage_caching = { chains = [1, "optimism", 999999], endpoints = "all"}
bytecode_hash = "ipfs"
revert_strings = "strip"
allow_paths = ["allow", "paths"]
"#,
)?;

Expand All @@ -2233,6 +2240,7 @@ mod tests {
},
bytecode_hash: BytecodeHash::Ipfs,
revert_strings: Some(RevertStrings::Strip),
allow_paths: vec![PathBuf::from("allow"), PathBuf::from("paths")],
..Config::default()
}
);
Expand Down

0 comments on commit 2127ecd

Please sign in to comment.