diff --git a/ethers-solc/src/artifacts.rs b/ethers-solc/src/artifacts.rs index cc92aaea..2feb5534 100644 --- a/ethers-solc/src/artifacts.rs +++ b/ethers-solc/src/artifacts.rs @@ -635,7 +635,7 @@ impl From 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, #[serde(default, skip_serializing_if = "Option::is_none")] pub legacy_assembly: Option, - pub bytecode: Bytecode, + pub bytecode: Option, #[serde(default, skip_serializing_if = "Option::is_none")] pub deployed_bytecode: Option, /// The list of function hashes diff --git a/ethers-solc/src/hh.rs b/ethers-solc/src/hh.rs index 5f4a47bd..dd79f75a 100644 --- a/ethers-solc/src/hh.rs +++ b/ethers-solc/src/hh.rs @@ -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, /// 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, @@ -43,7 +43,7 @@ impl From 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()) };