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 {
|
fn from(c: Contract) -> Self {
|
||||||
let (bin, bin_runtime) = if let Some(evm) = c.evm {
|
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)),
|
evm.deployed_bytecode.and_then(|deployed| deployed.bytecode.map(|evm| evm.object)),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -688,7 +688,7 @@ impl<'a> From<&'a Contract> for CompactContractRef<'a> {
|
||||||
fn from(c: &'a Contract) -> Self {
|
fn from(c: &'a Contract) -> Self {
|
||||||
let (bin, bin_runtime) = if let Some(ref evm) = c.evm {
|
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
|
evm.deployed_bytecode
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|deployed| deployed.bytecode.as_ref().map(|evm| &evm.object)),
|
.and_then(|deployed| deployed.bytecode.as_ref().map(|evm| &evm.object)),
|
||||||
|
@ -738,7 +738,7 @@ pub struct Evm {
|
||||||
pub assembly: Option<String>,
|
pub assembly: Option<String>,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub legacy_assembly: Option<serde_json::Value>,
|
pub legacy_assembly: Option<serde_json::Value>,
|
||||||
pub bytecode: Bytecode,
|
pub bytecode: Option<Bytecode>,
|
||||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||||
pub deployed_bytecode: Option<DeployedBytecode>,
|
pub deployed_bytecode: Option<DeployedBytecode>,
|
||||||
/// The list of function hashes
|
/// The list of function hashes
|
||||||
|
|
|
@ -25,7 +25,7 @@ pub struct HardhatArtifact {
|
||||||
pub abi: Abi,
|
pub abi: Abi,
|
||||||
/// A "0x"-prefixed hex string of the unlinked deployment bytecode. If the contract is not
|
/// A "0x"-prefixed hex string of the unlinked deployment bytecode. If the contract is not
|
||||||
/// deployable, this has the string "0x"
|
/// 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
|
/// A "0x"-prefixed hex string of the unlinked runtime/deployed bytecode. If the contract is
|
||||||
/// not deployable, this has the string "0x"
|
/// not deployable, this has the string "0x"
|
||||||
pub deployed_bytecode: Option<BytecodeObject>,
|
pub deployed_bytecode: Option<BytecodeObject>,
|
||||||
|
@ -43,7 +43,7 @@ impl From<HardhatArtifact> for CompactContract {
|
||||||
fn from(artifact: HardhatArtifact) -> Self {
|
fn from(artifact: HardhatArtifact) -> Self {
|
||||||
CompactContract {
|
CompactContract {
|
||||||
abi: Some(artifact.abi),
|
abi: Some(artifact.abi),
|
||||||
bin: Some(artifact.bytecode),
|
bin: artifact.bytecode,
|
||||||
bin_runtime: artifact.deployed_bytecode,
|
bin_runtime: artifact.deployed_bytecode,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,12 +90,13 @@ impl ArtifactOutput for HardhatArtifacts {
|
||||||
(None, Default::default())
|
(None, Default::default())
|
||||||
};
|
};
|
||||||
|
|
||||||
(
|
let (bytecode, link_ref) = if let Some(bc) = evm.bytecode {
|
||||||
evm.bytecode.object,
|
(Some(bc.object), bc.link_references)
|
||||||
evm.bytecode.link_references,
|
} else {
|
||||||
deployed_bytecode,
|
(None, Default::default())
|
||||||
deployed_link_references,
|
};
|
||||||
)
|
|
||||||
|
(bytecode, link_ref, deployed_bytecode, deployed_link_references)
|
||||||
} else {
|
} else {
|
||||||
(Default::default(), Default::default(), None, Default::default())
|
(Default::default(), Default::default(), None, Default::default())
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue