From 16e17078fdc9ab75a3a2c32d4a01baec95de5a73 Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Thu, 5 May 2022 16:31:52 +0200 Subject: [PATCH] fix(solc): respect auto detection in additional compile functions (#1226) --- ethers-solc/src/lib.rs | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/ethers-solc/src/lib.rs b/ethers-solc/src/lib.rs index 69ab0e6d..56ec5cbe 100644 --- a/ethers-solc/src/lib.rs +++ b/ethers-solc/src/lib.rs @@ -282,13 +282,20 @@ impl Project { /// ).unwrap(); /// # } /// ``` - #[cfg(all(feature = "svm-solc"))] pub fn compile_files(&self, files: I) -> Result> where I: IntoIterator, P: Into, { - project::ProjectCompiler::with_sources(self, Source::read_all(files)?)?.compile() + let sources = Source::read_all(files)?; + + #[cfg(all(feature = "svm-solc"))] + if self.auto_detect { + return project::ProjectCompiler::with_sources(self, sources)?.compile() + } + + let solc = self.configure_solc(self.solc.clone()); + self.compile_with_version(&solc, sources) } /// Convenience function to compile only (re)compile files that match the provided [FileFilter]. @@ -321,16 +328,28 @@ impl Project { /// ).unwrap(); /// # } /// ``` - #[cfg(all(feature = "svm-solc"))] pub fn compile_sparse( &self, filter: F, ) -> Result> { let sources = Source::read_all(self.paths.input_files().into_iter().filter(|p| filter.is_match(p)))?; - let filter: Box = Box::new(filter); - project::ProjectCompiler::with_sources(self, sources)?.with_sparse_output(filter).compile() + + #[cfg(all(feature = "svm-solc"))] + if self.auto_detect { + return project::ProjectCompiler::with_sources(self, sources)? + .with_sparse_output(filter) + .compile() + } + + project::ProjectCompiler::with_sources_and_solc( + self, + sources, + self.configure_solc(self.solc.clone()), + )? + .with_sparse_output(filter) + .compile() } /// Compiles the given source files with the exact `Solc` executable