diff --git a/ethers-solc/src/artifact_output/configurable.rs b/ethers-solc/src/artifact_output/configurable.rs index c3dea9ea..90736eb3 100644 --- a/ethers-solc/src/artifact_output/configurable.rs +++ b/ethers-solc/src/artifact_output/configurable.rs @@ -339,6 +339,8 @@ impl ArtifactOutput for ConfigurableArtifacts { file.source_file.ast.clone().map(|ast| ConfigurableContractArtifact { id: Some(file.source_file.id), ast: Some(ast), + bytecode: Some(CompactBytecode::empty()), + deployed_bytecode: Some(CompactDeployedBytecode::empty()), ..Default::default() }) } diff --git a/ethers-solc/src/artifacts/bytecode.rs b/ethers-solc/src/artifacts/bytecode.rs index 8f6837ce..eae27f1a 100644 --- a/ethers-solc/src/artifacts/bytecode.rs +++ b/ethers-solc/src/artifacts/bytecode.rs @@ -46,6 +46,11 @@ pub struct CompactBytecode { } impl CompactBytecode { + /// Returns a new `CompactBytecode` object that contains nothing, as it's the case for + /// interfaces and standalone solidity files that don't contain any contract definitions + pub fn empty() -> Self { + Self { object: Default::default(), source_map: None, link_references: Default::default() } + } /// Returns the parsed source map /// /// See also @@ -400,6 +405,14 @@ pub struct CompactDeployedBytecode { pub immutable_references: BTreeMap>, } +impl CompactDeployedBytecode { + /// Returns a new `CompactDeployedBytecode` object that contains nothing, as it's the case for + /// interfaces and standalone solidity files that don't contain any contract definitions + pub fn empty() -> Self { + Self { bytecode: Some(CompactBytecode::empty()), immutable_references: Default::default() } + } +} + impl From for CompactDeployedBytecode { fn from(bcode: DeployedBytecode) -> CompactDeployedBytecode { CompactDeployedBytecode {