This commit is contained in:
AlexK 2022-03-07 10:41:08 +04:00
parent 061695a2ab
commit 3e314638c3
3 changed files with 11 additions and 6 deletions

View File

@ -67,10 +67,14 @@ impl CompilerInput {
solidity_sources.insert(path, source); solidity_sources.insert(path, source);
} }
} }
vec![ let mut res = Vec::new();
Self { language: "Solidity".to_string(), sources: solidity_sources, settings: Default::default() }, if !solidity_sources.is_empty() {
Self { language: "Yul".to_string(), sources: yul_sources, settings: Default::default() } res.push(Self { language: "Solidity".to_string(), sources: solidity_sources, settings: Default::default() });
] }
if !yul_sources.is_empty() {
res.push(Self { language: "Yul".to_string(), sources: yul_sources, settings: Default::default() });
}
res
} }
/// Sets the settings for compilation /// Sets the settings for compilation

View File

@ -571,8 +571,8 @@ impl Solc {
/// use ethers_solc::{CompilerInput, Solc}; /// use ethers_solc::{CompilerInput, Solc};
/// let solc1 = Solc::default(); /// let solc1 = Solc::default();
/// let solc2 = Solc::default(); /// let solc2 = Solc::default();
/// let input1 = CompilerInput::new("contracts").unwrap(); /// let input1 = CompilerInput::new("contracts").unwrap()[0].clone();
/// let input2 = CompilerInput::new("src").unwrap(); /// let input2 = CompilerInput::new("src").unwrap()[0].clone();
/// ///
/// let outputs = Solc::compile_many([(solc1, input1), (solc2, input2)], 2).await.flattened().unwrap(); /// let outputs = Solc::compile_many([(solc1, input1), (solc2, input2)], 2).await.flattened().unwrap();
/// # } /// # }

View File

@ -740,6 +740,7 @@ mod tests {
.build() .build()
.unwrap(); .unwrap();
let compiled = project.compile().unwrap(); let compiled = project.compile().unwrap();
dbg!(compiled.clone());
assert!(!compiled.has_compiler_errors()); assert!(!compiled.has_compiler_errors());
let contracts = compiled.output().contracts; let contracts = compiled.output().contracts;
assert_eq!(contracts.contracts().count(), 3); assert_eq!(contracts.contracts().count(), 3);