From 85a572c9f6a4b865565364b014eb8251eb793f2c Mon Sep 17 00:00:00 2001 From: Matthias Seitz Date: Sat, 4 Jun 2022 20:38:21 +0200 Subject: [PATCH] fix(solc): emit empty vec for empty artifacts (#1345) --- ethers-solc/src/artifact_output/configurable.rs | 1 + ethers-solc/src/artifacts/mod.rs | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ethers-solc/src/artifact_output/configurable.rs b/ethers-solc/src/artifact_output/configurable.rs index 90736eb3..28120d7a 100644 --- a/ethers-solc/src/artifact_output/configurable.rs +++ b/ethers-solc/src/artifact_output/configurable.rs @@ -337,6 +337,7 @@ impl ArtifactOutput for ConfigurableArtifacts { file: &VersionedSourceFile, ) -> Option { file.source_file.ast.clone().map(|ast| ConfigurableContractArtifact { + abi: Some(LosslessAbi::default()), id: Some(file.source_file.id), ast: Some(ast), bytecode: Some(CompactBytecode::empty()), diff --git a/ethers-solc/src/artifacts/mod.rs b/ethers-solc/src/artifacts/mod.rs index 34efb27c..24e0247e 100644 --- a/ethers-solc/src/artifacts/mod.rs +++ b/ethers-solc/src/artifacts/mod.rs @@ -1318,7 +1318,7 @@ impl OutputContracts { /// ethabi as it would require a redesign of the overall `Param` and `ParamType` types. Instead, /// this type keeps a copy of the [`serde_json::Value`] when deserialized from the `solc` json /// compiler output and uses it to serialize the `abi` without loss. -#[derive(Clone, Debug, PartialEq, Default)] +#[derive(Clone, Debug, PartialEq)] pub struct LosslessAbi { /// The complete abi as json value pub abi_value: serde_json::Value, @@ -1326,6 +1326,12 @@ pub struct LosslessAbi { pub abi: Abi, } +impl Default for LosslessAbi { + fn default() -> Self { + LosslessAbi { abi_value: serde_json::json!([]), abi: Default::default() } + } +} + impl From for Abi { fn from(abi: LosslessAbi) -> Self { abi.abi