From cc38c374810f37a6d0a89b46681e944050a8d4d0 Mon Sep 17 00:00:00 2001 From: Sebastian Miasojed Date: Thu, 24 Oct 2024 14:59:50 +0200 Subject: [PATCH] Set evm.deployedBytecode to the value of evm.bytecode (#95) --- .../standard_json/input/settings/selection/file/flag.rs | 4 ++++ .../src/solc/standard_json/output/contract/evm/mod.rs | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/solidity/src/solc/standard_json/input/settings/selection/file/flag.rs b/crates/solidity/src/solc/standard_json/input/settings/selection/file/flag.rs index d3cedff4..ad6efc66 100644 --- a/crates/solidity/src/solc/standard_json/input/settings/selection/file/flag.rs +++ b/crates/solidity/src/solc/standard_json/input/settings/selection/file/flag.rs @@ -41,6 +41,9 @@ pub enum Flag { EVMBC, #[serde(rename = "evm.deployedBytecode")] EVMDBC, + /// The assembly code + #[serde(rename = "evm.assembly")] + Assembly, } impl From for Flag { @@ -66,6 +69,7 @@ impl std::fmt::Display for Flag { Self::EVMLA => write!(f, "evm.legacyAssembly"), Self::EVMBC => write!(f, "evm.bytecode"), Self::EVMDBC => write!(f, "evm.deployedBytecode"), + Self::Assembly => write!(f, "evm.assembly"), } } } diff --git a/crates/solidity/src/solc/standard_json/output/contract/evm/mod.rs b/crates/solidity/src/solc/standard_json/output/contract/evm/mod.rs index 26897d81..c5613cf9 100644 --- a/crates/solidity/src/solc/standard_json/output/contract/evm/mod.rs +++ b/crates/solidity/src/solc/standard_json/output/contract/evm/mod.rs @@ -29,7 +29,9 @@ pub struct EVM { /// Is reset by that of PolkaVM before yielding the compiled project artifacts. #[serde(skip_serializing_if = "Option::is_none")] pub bytecode: Option, - /// 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")] pub deployed_bytecode: Option, /// The contract function signatures. @@ -44,6 +46,7 @@ impl EVM { /// Sets the PolkaVM assembly and bytecode. pub fn modify(&mut self, assembly_text: String, bytecode: String) { 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)); } }