fix(solc): emit empty bytecode objects for standalone sol files (#1327)

This commit is contained in:
Matthias Seitz 2022-05-31 18:29:25 +02:00 committed by GitHub
parent ac0560c252
commit 8e3529e9b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -339,6 +339,8 @@ impl ArtifactOutput for ConfigurableArtifacts {
file.source_file.ast.clone().map(|ast| ConfigurableContractArtifact { file.source_file.ast.clone().map(|ast| ConfigurableContractArtifact {
id: Some(file.source_file.id), id: Some(file.source_file.id),
ast: Some(ast), ast: Some(ast),
bytecode: Some(CompactBytecode::empty()),
deployed_bytecode: Some(CompactDeployedBytecode::empty()),
..Default::default() ..Default::default()
}) })
} }

View File

@ -46,6 +46,11 @@ pub struct CompactBytecode {
} }
impl 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 /// Returns the parsed source map
/// ///
/// See also <https://docs.soliditylang.org/en/v0.8.10/internals/source_mappings.html> /// See also <https://docs.soliditylang.org/en/v0.8.10/internals/source_mappings.html>
@ -400,6 +405,14 @@ pub struct CompactDeployedBytecode {
pub immutable_references: BTreeMap<String, Vec<Offsets>>, pub immutable_references: BTreeMap<String, Vec<Offsets>>,
} }
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<DeployedBytecode> for CompactDeployedBytecode { impl From<DeployedBytecode> for CompactDeployedBytecode {
fn from(bcode: DeployedBytecode) -> CompactDeployedBytecode { fn from(bcode: DeployedBytecode) -> CompactDeployedBytecode {
CompactDeployedBytecode { CompactDeployedBytecode {