mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 05:38:00 +00:00
497dae2494
The differential testing framework will make a second consumer. There seems to be no re-usable Rust crate for this. But we already have everything here, just needs a small refactor to make it fully re-usable. - Mostly decouple the solc JSON-input-output interface types from the `solidity` frontend crate - Expose the JSON-input-output interface types in a dedicated crate --------- Signed-off-by: Cyrill Leutwiler <bigcyrill@hotmail.com>
43 lines
1.6 KiB
Rust
43 lines
1.6 KiB
Rust
//! The `solc --standard-json` output contract EVM data.
|
|
|
|
pub mod bytecode;
|
|
|
|
use std::collections::BTreeMap;
|
|
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
use self::bytecode::Bytecode;
|
|
use self::bytecode::DeployedBytecode;
|
|
|
|
/// The `solc --standard-json` output contract EVM data.
|
|
/// It is replaced by PolkaVM data after compiling.
|
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
|
#[serde(rename_all = "camelCase")]
|
|
pub struct EVM {
|
|
/// The contract PolkaVM assembly code.
|
|
#[serde(rename = "assembly", skip_serializing_if = "Option::is_none")]
|
|
pub assembly_text: Option<String>,
|
|
/// The contract bytecode.
|
|
/// Is reset by that of PolkaVM before yielding the compiled project artifacts.
|
|
#[serde(skip_serializing_if = "Option::is_none")]
|
|
pub bytecode: Option<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<DeployedBytecode>,
|
|
/// The contract function signatures.
|
|
#[serde(default, skip_serializing_if = "Option::is_none")]
|
|
pub method_identifiers: Option<BTreeMap<String, String>>,
|
|
}
|
|
|
|
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.clone()));
|
|
self.deployed_bytecode = Some(DeployedBytecode::new(bytecode));
|
|
}
|
|
}
|