Set evm.deployedBytecode to the value of evm.bytecode (#95)

This commit is contained in:
Sebastian Miasojed
2024-10-24 14:59:50 +02:00
committed by GitHub
parent e56feb95be
commit c36f650636
2 changed files with 9 additions and 2 deletions
@@ -41,6 +41,9 @@ pub enum Flag {
EVMBC, EVMBC,
#[serde(rename = "evm.deployedBytecode")] #[serde(rename = "evm.deployedBytecode")]
EVMDBC, EVMDBC,
/// The assembly code
#[serde(rename = "evm.assembly")]
Assembly,
} }
impl From<SolcPipeline> for Flag { impl From<SolcPipeline> for Flag {
@@ -66,6 +69,7 @@ impl std::fmt::Display for Flag {
Self::EVMLA => write!(f, "evm.legacyAssembly"), Self::EVMLA => write!(f, "evm.legacyAssembly"),
Self::EVMBC => write!(f, "evm.bytecode"), Self::EVMBC => write!(f, "evm.bytecode"),
Self::EVMDBC => write!(f, "evm.deployedBytecode"), Self::EVMDBC => write!(f, "evm.deployedBytecode"),
Self::Assembly => write!(f, "evm.assembly"),
} }
} }
} }
@@ -29,7 +29,9 @@ pub struct EVM {
/// Is reset by that of PolkaVM before yielding the compiled project artifacts. /// Is reset by that of PolkaVM before yielding the compiled project artifacts.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub bytecode: Option<Bytecode>, pub bytecode: Option<Bytecode>,
/// The contract deployed bytecode. /// The deployed bytecode of the contract.
/// It is overwritten with the PolkaVM blob before yielding the compiled project artifacts.
/// Hence it will be the same as the runtime code but we keep both for compatibility reasons.
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub deployed_bytecode: Option<DeployedBytecode>, pub deployed_bytecode: Option<DeployedBytecode>,
/// The contract function signatures. /// The contract function signatures.
@@ -44,6 +46,7 @@ impl EVM {
/// Sets the PolkaVM assembly and bytecode. /// Sets the PolkaVM assembly and bytecode.
pub fn modify(&mut self, assembly_text: String, bytecode: String) { pub fn modify(&mut self, assembly_text: String, bytecode: String) {
self.assembly_text = Some(assembly_text); self.assembly_text = Some(assembly_text);
self.bytecode = Some(Bytecode::new(bytecode)); self.bytecode = Some(Bytecode::new(bytecode.clone()));
self.deployed_bytecode = Some(DeployedBytecode::new(bytecode));
} }
} }