fix: make evm bytecode optional (#735)

This commit is contained in:
Matthias Seitz 2021-12-25 05:45:53 +01:00 committed by GitHub
parent 183c0d21c4
commit 4b4ebd74ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 11 deletions

View File

@ -635,7 +635,7 @@ impl From<Contract> for CompactContract {
fn from(c: Contract) -> Self {
let (bin, bin_runtime) = if let Some(evm) = c.evm {
(
Some(evm.bytecode.object),
evm.bytecode.map(|c| c.object),
evm.deployed_bytecode.and_then(|deployed| deployed.bytecode.map(|evm| evm.object)),
)
} else {
@ -688,7 +688,7 @@ impl<'a> From<&'a Contract> for CompactContractRef<'a> {
fn from(c: &'a Contract) -> Self {
let (bin, bin_runtime) = if let Some(ref evm) = c.evm {
(
Some(&evm.bytecode.object),
evm.bytecode.as_ref().map(|c| &c.object),
evm.deployed_bytecode
.as_ref()
.and_then(|deployed| deployed.bytecode.as_ref().map(|evm| &evm.object)),
@ -738,7 +738,7 @@ pub struct Evm {
pub assembly: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub legacy_assembly: Option<serde_json::Value>,
pub bytecode: Bytecode,
pub bytecode: Option<Bytecode>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub deployed_bytecode: Option<DeployedBytecode>,
/// The list of function hashes

View File

@ -25,7 +25,7 @@ pub struct HardhatArtifact {
pub abi: Abi,
/// A "0x"-prefixed hex string of the unlinked deployment bytecode. If the contract is not
/// deployable, this has the string "0x"
pub bytecode: BytecodeObject,
pub bytecode: Option<BytecodeObject>,
/// A "0x"-prefixed hex string of the unlinked runtime/deployed bytecode. If the contract is
/// not deployable, this has the string "0x"
pub deployed_bytecode: Option<BytecodeObject>,
@ -43,7 +43,7 @@ impl From<HardhatArtifact> for CompactContract {
fn from(artifact: HardhatArtifact) -> Self {
CompactContract {
abi: Some(artifact.abi),
bin: Some(artifact.bytecode),
bin: artifact.bytecode,
bin_runtime: artifact.deployed_bytecode,
}
}
@ -90,12 +90,13 @@ impl ArtifactOutput for HardhatArtifacts {
(None, Default::default())
};
(
evm.bytecode.object,
evm.bytecode.link_references,
deployed_bytecode,
deployed_link_references,
)
let (bytecode, link_ref) = if let Some(bc) = evm.bytecode {
(Some(bc.object), bc.link_references)
} else {
(None, Default::default())
};
(bytecode, link_ref, deployed_bytecode, deployed_link_references)
} else {
(Default::default(), Default::default(), None, Default::default())
};