-
Notifications
You must be signed in to change notification settings - Fork 796
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - small nits / questions
ethers-solc/src/project_util.rs
Outdated
} | ||
|
||
/// Copies a single file into the given dir | ||
pub fn copy_file(&self, source: impl AsRef<Path>, target_dir: impl AsRef<Path>) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think this shouldn't be needed?
pub fn copy_file(&self, source: impl AsRef<Path>, target_dir: impl AsRef<Path>) -> Result<()> { | |
pub fn copy_file(source: impl AsRef<Path>, target_dir: impl AsRef<Path>) -> Result<()> { |
ethers-solc/src/project_util.rs
Outdated
/// Returns the handle to the tempdir and the project | ||
/// | ||
/// NOTE: the `TempDir` object deletes its directory on drop, also removing all the project's | ||
/// content | ||
pub fn split(self) -> (Project<T>, TempDir) { | ||
(self.inner, self.root) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unused? Is it needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, used that before adding more utility functions, removed now
ethers-solc/src/project_util.rs
Outdated
} | ||
|
||
/// Copies all content of the source dir into the target dir | ||
pub fn copy_dir(&self, source: impl AsRef<Path>, target_dir: impl AsRef<Path>) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub fn copy_dir(&self, source: impl AsRef<Path>, target_dir: impl AsRef<Path>) -> Result<()> { | |
pub fn copy_dir(source: impl AsRef<Path>, target_dir: impl AsRef<Path>) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
moved to standalone function, same as copy_file
ethers-solc/src/project_util.rs
Outdated
let cache = tmp_dir.path().join("cache"); | ||
let cache = cache.join(SOLIDITY_FILES_CACHE_FILENAME); | ||
|
||
let paths = ProjectPathsConfig::builder() | ||
.cache(cache) | ||
.sources(root.join("contracts")) | ||
.artifacts(root.join("artifacts")) | ||
.lib(root.join("node_modules")) | ||
.root(root) | ||
.build()?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't you use ProjectPathsConfig::hardhat
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, this simplifies it quite a bit
.build() | ||
.unwrap(); | ||
let paths = ProjectPathsConfig::builder().sources(root.join("src")).lib(root.join("lib")); | ||
let project = TempProject::<MinimalCombinedArtifacts>::new(paths).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could be done with TempProject::<_>::dapptools()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm we're essentially setting the project root to ./test-data/..
instead of creating a totally new, empty temp project that TempProject::<_>::dapptools()
would do.
in these cases we'd need to use TempProject::new
and pass in the preconfigured ProjectPaths,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
* feat(config): support omptimizer details * bump ethers * chore: bump ethers Co-authored-by: Georgios Konstantopoulos <me@gakonst.com>
Motivation
Add utils for
ethers-solc
to easily create temp workspaces we can also use in foundry.Solution
PR Checklist