fix: make evm bytecode optional (#735)
This commit is contained in:
parent
183c0d21c4
commit
4b4ebd74ba
|
@ -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
|
||||
|
|
|
@ -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())
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue