revive_solc_json_interface/standard_json/output/contract/evm/
mod.rs

1//! The `solc --standard-json` output contract EVM data.
2
3pub mod bytecode;
4
5use std::collections::BTreeMap;
6
7use serde::Deserialize;
8use serde::Serialize;
9
10use self::bytecode::Bytecode;
11use self::bytecode::DeployedBytecode;
12
13/// The `solc --standard-json` output contract EVM data.
14/// It is replaced by PolkaVM data after compiling.
15#[derive(Debug, Serialize, Deserialize, Clone)]
16#[serde(rename_all = "camelCase")]
17pub struct EVM {
18    /// The contract PolkaVM assembly code.
19    #[serde(rename = "assembly", skip_serializing_if = "Option::is_none")]
20    pub assembly_text: Option<String>,
21    /// The contract bytecode.
22    /// Is reset by that of PolkaVM before yielding the compiled project artifacts.
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub bytecode: Option<Bytecode>,
25    /// The deployed bytecode of the contract.
26    /// It is overwritten with the PolkaVM blob before yielding the compiled project artifacts.
27    /// Hence it will be the same as the runtime code but we keep both for compatibility reasons.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub deployed_bytecode: Option<DeployedBytecode>,
30    /// The contract function signatures.
31    #[serde(default, skip_serializing_if = "Option::is_none")]
32    pub method_identifiers: Option<BTreeMap<String, String>>,
33}
34
35impl EVM {
36    /// Sets the PolkaVM assembly and bytecode.
37    pub fn modify(&mut self, assembly_text: String, bytecode: String) {
38        self.assembly_text = Some(assembly_text);
39        self.bytecode = Some(Bytecode::new(bytecode.clone()));
40        self.deployed_bytecode = Some(DeployedBytecode::new(bytecode));
41    }
42}