fix(solc): emit empty vec for empty artifacts (#1345)

This commit is contained in:
Matthias Seitz 2022-06-04 20:38:21 +02:00 committed by GitHub
parent 1dfe6d0cd2
commit 85a572c9f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -337,6 +337,7 @@ impl ArtifactOutput for ConfigurableArtifacts {
file: &VersionedSourceFile, file: &VersionedSourceFile,
) -> Option<Self::Artifact> { ) -> Option<Self::Artifact> {
file.source_file.ast.clone().map(|ast| ConfigurableContractArtifact { file.source_file.ast.clone().map(|ast| ConfigurableContractArtifact {
abi: Some(LosslessAbi::default()),
id: Some(file.source_file.id), id: Some(file.source_file.id),
ast: Some(ast), ast: Some(ast),
bytecode: Some(CompactBytecode::empty()), bytecode: Some(CompactBytecode::empty()),

View File

@ -1318,7 +1318,7 @@ impl OutputContracts {
/// ethabi as it would require a redesign of the overall `Param` and `ParamType` types. Instead, /// 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 /// 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. /// compiler output and uses it to serialize the `abi` without loss.
#[derive(Clone, Debug, PartialEq, Default)] #[derive(Clone, Debug, PartialEq)]
pub struct LosslessAbi { pub struct LosslessAbi {
/// The complete abi as json value /// The complete abi as json value
pub abi_value: serde_json::Value, pub abi_value: serde_json::Value,
@ -1326,6 +1326,12 @@ pub struct LosslessAbi {
pub abi: Abi, pub abi: Abi,
} }
impl Default for LosslessAbi {
fn default() -> Self {
LosslessAbi { abi_value: serde_json::json!([]), abi: Default::default() }
}
}
impl From<LosslessAbi> for Abi { impl From<LosslessAbi> for Abi {
fn from(abi: LosslessAbi) -> Self { fn from(abi: LosslessAbi) -> Self {
abi.abi abi.abi