From 3e314638c377b1288e400eb31cc822cc93cbac71 Mon Sep 17 00:00:00 2001 From: AlexK Date: Mon, 7 Mar 2022 10:41:08 +0400 Subject: [PATCH] fixes --- ethers-solc/src/artifacts/mod.rs | 12 ++++++++---- ethers-solc/src/compile/mod.rs | 4 ++-- ethers-solc/src/lib.rs | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ethers-solc/src/artifacts/mod.rs b/ethers-solc/src/artifacts/mod.rs index 39f54b0e..f332a6cb 100644 --- a/ethers-solc/src/artifacts/mod.rs +++ b/ethers-solc/src/artifacts/mod.rs @@ -67,10 +67,14 @@ impl CompilerInput { solidity_sources.insert(path, source); } } - vec![ - Self { language: "Solidity".to_string(), sources: solidity_sources, settings: Default::default() }, - Self { language: "Yul".to_string(), sources: yul_sources, settings: Default::default() } - ] + let mut res = Vec::new(); + if !solidity_sources.is_empty() { + 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 diff --git a/ethers-solc/src/compile/mod.rs b/ethers-solc/src/compile/mod.rs index ce57610d..af34c54f 100644 --- a/ethers-solc/src/compile/mod.rs +++ b/ethers-solc/src/compile/mod.rs @@ -571,8 +571,8 @@ impl Solc { /// use ethers_solc::{CompilerInput, Solc}; /// let solc1 = Solc::default(); /// let solc2 = Solc::default(); - /// let input1 = CompilerInput::new("contracts").unwrap(); - /// let input2 = CompilerInput::new("src").unwrap(); + /// let input1 = CompilerInput::new("contracts").unwrap()[0].clone(); + /// let input2 = CompilerInput::new("src").unwrap()[0].clone(); /// /// let outputs = Solc::compile_many([(solc1, input1), (solc2, input2)], 2).await.flattened().unwrap(); /// # } diff --git a/ethers-solc/src/lib.rs b/ethers-solc/src/lib.rs index afc6821b..cce80f56 100644 --- a/ethers-solc/src/lib.rs +++ b/ethers-solc/src/lib.rs @@ -740,6 +740,7 @@ mod tests { .build() .unwrap(); let compiled = project.compile().unwrap(); + dbg!(compiled.clone()); assert!(!compiled.has_compiler_errors()); let contracts = compiled.output().contracts; assert_eq!(contracts.contracts().count(), 3);