mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-06-13 05:01:00 +00:00
use normal style for comments
Signed-off-by: xermicus <cyrill@parity.io>
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --combined-json` contract.
|
||||
//!
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashSet;
|
||||
@@ -8,9 +6,7 @@ use std::collections::HashSet;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The contract.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub struct Contract {
|
||||
@@ -53,12 +49,9 @@ pub struct Contract {
|
||||
}
|
||||
|
||||
impl Contract {
|
||||
///
|
||||
/// Returns the signature hash of the specified contract entry.
|
||||
///
|
||||
/// # Panics
|
||||
/// If the hashes have not been requested in the `solc` call.
|
||||
///
|
||||
pub fn entry(&self, entry: &str) -> u32 {
|
||||
self.hashes
|
||||
.as_ref()
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --combined-json` output.
|
||||
//!
|
||||
|
||||
pub mod contract;
|
||||
|
||||
@@ -14,9 +12,7 @@ use serde::Serialize;
|
||||
|
||||
use self::contract::Contract;
|
||||
|
||||
///
|
||||
/// The `solc --combined-json` output.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct CombinedJson {
|
||||
/// The contract entries.
|
||||
@@ -36,9 +32,7 @@ pub struct CombinedJson {
|
||||
}
|
||||
|
||||
impl CombinedJson {
|
||||
///
|
||||
/// Returns the signature hash of the specified contract and entry.
|
||||
///
|
||||
pub fn entry(&self, path: &str, entry: &str) -> u32 {
|
||||
self.contracts
|
||||
.iter()
|
||||
@@ -53,9 +47,7 @@ impl CombinedJson {
|
||||
.entry(entry)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the full contract path which can be found in `combined-json` output.
|
||||
///
|
||||
pub fn get_full_path(&self, name: &str) -> Option<String> {
|
||||
self.contracts.iter().find_map(|(path, _value)| {
|
||||
if let Some(last_slash_position) = path.rfind('/') {
|
||||
@@ -70,9 +62,7 @@ impl CombinedJson {
|
||||
})
|
||||
}
|
||||
|
||||
///
|
||||
/// Removes EVM artifacts to prevent their accidental usage.
|
||||
///
|
||||
pub fn remove_evm(&mut self) {
|
||||
for (_, contract) in self.contracts.iter_mut() {
|
||||
contract.bin = None;
|
||||
@@ -80,9 +70,7 @@ impl CombinedJson {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Writes the JSON to the specified directory.
|
||||
///
|
||||
pub fn write_to_directory(
|
||||
self,
|
||||
output_directory: &Path,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The Solidity compiler.
|
||||
//!
|
||||
|
||||
pub mod combined_json;
|
||||
pub mod pipeline;
|
||||
@@ -17,9 +15,7 @@ use self::standard_json::input::Input as StandardJsonInput;
|
||||
use self::standard_json::output::Output as StandardJsonOutput;
|
||||
use self::version::Version;
|
||||
|
||||
///
|
||||
/// The Solidity compiler.
|
||||
///
|
||||
pub struct Compiler {
|
||||
/// The binary executable name.
|
||||
pub executable: String,
|
||||
@@ -43,12 +39,9 @@ impl Compiler {
|
||||
/// The last supported version of `solc`.
|
||||
pub const LAST_SUPPORTED_VERSION: semver::Version = semver::Version::new(0, 8, 25);
|
||||
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
/// Different tools may use different `executable` names. For example, the integration tester
|
||||
/// uses `solc-<version>` format.
|
||||
///
|
||||
pub fn new(executable: String) -> anyhow::Result<Self> {
|
||||
if let Err(error) = which::which(executable.as_str()) {
|
||||
anyhow::bail!(
|
||||
@@ -62,9 +55,7 @@ impl Compiler {
|
||||
})
|
||||
}
|
||||
|
||||
///
|
||||
/// Compiles the Solidity `--standard-json` input into Yul IR.
|
||||
///
|
||||
pub fn standard_json(
|
||||
&mut self,
|
||||
mut input: StandardJsonInput,
|
||||
@@ -143,9 +134,7 @@ impl Compiler {
|
||||
Ok(output)
|
||||
}
|
||||
|
||||
///
|
||||
/// The `solc --combined-json abi,hashes...` mirror.
|
||||
///
|
||||
pub fn combined_json(
|
||||
&self,
|
||||
paths: &[PathBuf],
|
||||
@@ -217,9 +206,7 @@ impl Compiler {
|
||||
Ok(combined_json)
|
||||
}
|
||||
|
||||
///
|
||||
/// The `solc` Yul validator.
|
||||
///
|
||||
pub fn validate_yul(&self, path: &Path) -> anyhow::Result<()> {
|
||||
let mut command = std::process::Command::new(self.executable.as_str());
|
||||
command.arg("--strict-assembly");
|
||||
@@ -239,9 +226,7 @@ impl Compiler {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// The `solc --version` mini-parser.
|
||||
///
|
||||
pub fn version(&mut self) -> anyhow::Result<Version> {
|
||||
if let Some(version) = self.version.as_ref() {
|
||||
return Ok(version.to_owned());
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The Solidity compiler pipeline type.
|
||||
//!
|
||||
|
||||
use crate::solc::version::Version as SolcVersion;
|
||||
use crate::solc::Compiler as SolcCompiler;
|
||||
|
||||
///
|
||||
/// The Solidity compiler pipeline type.
|
||||
///
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
@@ -19,9 +15,7 @@ pub enum Pipeline {
|
||||
}
|
||||
|
||||
impl Pipeline {
|
||||
///
|
||||
/// We always use EVMLA for Solidity <=0.7, or if the user does not want to compile via Yul.
|
||||
///
|
||||
pub fn new(solc_version: &SolcVersion, force_evmla: bool) -> Self {
|
||||
if solc_version.default < SolcCompiler::FIRST_YUL_VERSION || force_evmla {
|
||||
Self::EVMLA
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The `solc --standard-json` input language.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` input language.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum Language {
|
||||
/// The Solidity language.
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` input.
|
||||
//!
|
||||
|
||||
pub mod language;
|
||||
pub mod settings;
|
||||
@@ -25,9 +23,7 @@ use self::language::Language;
|
||||
use self::settings::Settings;
|
||||
use self::source::Source;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` input.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Input {
|
||||
@@ -43,9 +39,7 @@ pub struct Input {
|
||||
}
|
||||
|
||||
impl Input {
|
||||
///
|
||||
/// A shortcut constructor from stdin.
|
||||
///
|
||||
pub fn try_from_stdin(solc_pipeline: SolcPipeline) -> anyhow::Result<Self> {
|
||||
let mut input: Self = serde_json::from_reader(std::io::BufReader::new(std::io::stdin()))?;
|
||||
input
|
||||
@@ -56,9 +50,7 @@ impl Input {
|
||||
Ok(input)
|
||||
}
|
||||
|
||||
///
|
||||
/// A shortcut constructor from paths.
|
||||
///
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn try_from_paths(
|
||||
language: Language,
|
||||
@@ -100,11 +92,8 @@ impl Input {
|
||||
})
|
||||
}
|
||||
|
||||
///
|
||||
/// A shortcut constructor from source code.
|
||||
///
|
||||
/// Only for the integration test purposes.
|
||||
///
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn try_from_sources(
|
||||
evm_version: Option<revive_common::EVMVersion>,
|
||||
@@ -138,9 +127,7 @@ impl Input {
|
||||
})
|
||||
}
|
||||
|
||||
///
|
||||
/// Sets the necessary defaults.
|
||||
///
|
||||
pub fn normalize(&mut self, version: &semver::Version) {
|
||||
self.settings.normalize(version);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The `solc --standard-json` input settings metadata.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` input settings metadata.
|
||||
///
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Metadata {
|
||||
@@ -17,9 +13,7 @@ pub struct Metadata {
|
||||
}
|
||||
|
||||
impl Metadata {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(bytecode_hash: revive_llvm_context::EraVMMetadataHash) -> Self {
|
||||
Self {
|
||||
bytecode_hash: Some(bytecode_hash),
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` input settings.
|
||||
//!
|
||||
|
||||
pub mod metadata;
|
||||
pub mod optimizer;
|
||||
@@ -16,9 +14,7 @@ use self::metadata::Metadata;
|
||||
use self::optimizer::Optimizer;
|
||||
use self::selection::Selection;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` input settings.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Settings {
|
||||
@@ -49,9 +45,7 @@ pub struct Settings {
|
||||
}
|
||||
|
||||
impl Settings {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
evm_version: Option<revive_common::EVMVersion>,
|
||||
libraries: BTreeMap<String, BTreeMap<String, String>>,
|
||||
@@ -72,16 +66,12 @@ impl Settings {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Sets the necessary defaults.
|
||||
///
|
||||
pub fn normalize(&mut self, version: &semver::Version) {
|
||||
self.optimizer.normalize(version);
|
||||
}
|
||||
|
||||
///
|
||||
/// Parses the library list and returns their double hashmap with path and name as keys.
|
||||
///
|
||||
pub fn parse_libraries(
|
||||
input: Vec<String>,
|
||||
) -> anyhow::Result<BTreeMap<String, BTreeMap<String, String>>> {
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The `solc --standard-json` input settings optimizer details.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` input settings optimizer details.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Details {
|
||||
@@ -29,9 +25,7 @@ pub struct Details {
|
||||
}
|
||||
|
||||
impl Details {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
peephole: bool,
|
||||
inliner: Option<bool>,
|
||||
@@ -52,9 +46,7 @@ impl Details {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Creates a set of disabled optimizations.
|
||||
///
|
||||
pub fn disabled(version: &semver::Version) -> Self {
|
||||
let inliner = if version >= &semver::Version::new(0, 8, 5) {
|
||||
Some(false)
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` input settings optimizer.
|
||||
//!
|
||||
|
||||
pub mod details;
|
||||
|
||||
@@ -9,9 +7,7 @@ use serde::Serialize;
|
||||
|
||||
use self::details::Details;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` input settings optimizer.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Optimizer {
|
||||
@@ -32,9 +28,7 @@ pub struct Optimizer {
|
||||
}
|
||||
|
||||
impl Optimizer {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
enabled: bool,
|
||||
mode: Option<char>,
|
||||
@@ -51,9 +45,7 @@ impl Optimizer {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Sets the necessary defaults.
|
||||
///
|
||||
pub fn normalize(&mut self, version: &semver::Version) {
|
||||
self.details = if version >= &semver::Version::new(0, 5, 5) {
|
||||
Some(Details::disabled(version))
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
//!
|
||||
//! The `solc --standard-json` expected output selection flag.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::solc::pipeline::Pipeline as SolcPipeline;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` expected output selection flag.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output file selection.
|
||||
//!
|
||||
|
||||
pub mod flag;
|
||||
|
||||
@@ -13,9 +11,7 @@ use crate::solc::pipeline::Pipeline as SolcPipeline;
|
||||
|
||||
use self::flag::Flag as SelectionFlag;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output file selection.
|
||||
///
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
pub struct File {
|
||||
/// The per-file output selections.
|
||||
@@ -27,9 +23,7 @@ pub struct File {
|
||||
}
|
||||
|
||||
impl File {
|
||||
///
|
||||
/// Creates the selection required by our compilation process.
|
||||
///
|
||||
pub fn new_required(pipeline: SolcPipeline) -> Self {
|
||||
Self {
|
||||
per_file: Some(HashSet::from_iter([SelectionFlag::AST])),
|
||||
@@ -42,9 +36,7 @@ impl File {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Extends the user's output selection with flag required by our compilation process.
|
||||
///
|
||||
pub fn extend_with_required(&mut self, pipeline: SolcPipeline) -> &mut Self {
|
||||
let required = Self::new_required(pipeline);
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output selection.
|
||||
//!
|
||||
|
||||
pub mod file;
|
||||
|
||||
@@ -11,9 +9,7 @@ use crate::solc::pipeline::Pipeline as SolcPipeline;
|
||||
|
||||
use self::file::File as FileSelection;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output selection.
|
||||
///
|
||||
#[derive(Debug, Default, Serialize, Deserialize)]
|
||||
pub struct Selection {
|
||||
/// Only the 'all' wildcard is available for robustness reasons.
|
||||
@@ -22,18 +18,14 @@ pub struct Selection {
|
||||
}
|
||||
|
||||
impl Selection {
|
||||
///
|
||||
/// Creates the selection required by our compilation process.
|
||||
///
|
||||
pub fn new_required(pipeline: SolcPipeline) -> Self {
|
||||
Self {
|
||||
all: Some(FileSelection::new_required(pipeline)),
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Extends the user's output selection with flag required by our compilation process.
|
||||
///
|
||||
pub fn extend_with_required(&mut self, pipeline: SolcPipeline) -> &mut Self {
|
||||
self.all
|
||||
.get_or_insert_with(|| FileSelection::new_required(pipeline))
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` input source.
|
||||
//!
|
||||
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
@@ -8,9 +6,7 @@ use std::path::Path;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` input source.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Source {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc <input>.sol --standard-json`.
|
||||
//!
|
||||
|
||||
pub mod input;
|
||||
pub mod output;
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output contract EVM bytecode.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract EVM bytecode.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Bytecode {
|
||||
@@ -16,17 +12,13 @@ pub struct Bytecode {
|
||||
}
|
||||
|
||||
impl Bytecode {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(object: String) -> Self {
|
||||
Self { object }
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract EVM deployed bytecode.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DeployedBytecode {
|
||||
@@ -35,9 +27,7 @@ pub struct DeployedBytecode {
|
||||
}
|
||||
|
||||
impl DeployedBytecode {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(object: String) -> Self {
|
||||
Self { object }
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output contract EVM extra metadata.
|
||||
//!
|
||||
|
||||
pub mod recursive_function;
|
||||
|
||||
@@ -9,9 +7,7 @@ use serde::Serialize;
|
||||
|
||||
use self::recursive_function::RecursiveFunction;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract EVM extra metadata.
|
||||
///
|
||||
#[derive(Debug, Default, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct ExtraMetadata {
|
||||
@@ -21,9 +17,7 @@ pub struct ExtraMetadata {
|
||||
}
|
||||
|
||||
impl ExtraMetadata {
|
||||
///
|
||||
/// Returns the recursive function reference for the specified tag.
|
||||
///
|
||||
pub fn get(
|
||||
&self,
|
||||
block_key: &revive_llvm_context::EraVMFunctionBlockKey,
|
||||
|
||||
-4
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output contract EVM recursive function.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract EVM recursive function.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct RecursiveFunction {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output contract EVM data.
|
||||
//!
|
||||
|
||||
pub mod bytecode;
|
||||
pub mod extra_metadata;
|
||||
@@ -16,11 +14,8 @@ use self::bytecode::Bytecode;
|
||||
use self::bytecode::DeployedBytecode;
|
||||
use self::extra_metadata::ExtraMetadata;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract EVM data.
|
||||
///
|
||||
/// It is replaced by EraVM data after compiling.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EVM {
|
||||
@@ -44,9 +39,7 @@ pub struct EVM {
|
||||
}
|
||||
|
||||
impl EVM {
|
||||
///
|
||||
/// Sets the EraVM 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));
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output contract.
|
||||
//!
|
||||
|
||||
pub mod evm;
|
||||
|
||||
@@ -12,9 +10,7 @@ use serde::Serialize;
|
||||
|
||||
use self::evm::EVM;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output contract.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Contract {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output error.
|
||||
//!
|
||||
|
||||
pub mod source_location;
|
||||
|
||||
@@ -11,9 +9,7 @@ use serde::Serialize;
|
||||
|
||||
use self::source_location::SourceLocation;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output error.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Error {
|
||||
@@ -34,9 +30,7 @@ pub struct Error {
|
||||
}
|
||||
|
||||
impl Error {
|
||||
///
|
||||
/// Returns the `ecrecover` function usage warning.
|
||||
///
|
||||
pub fn message_ecrecover(src: Option<&str>) -> Self {
|
||||
let message = r#"
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -59,9 +53,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the `<address payable>`'s `send` and `transfer` methods usage error.
|
||||
///
|
||||
pub fn message_send_and_transfer(src: Option<&str>) -> Self {
|
||||
let message = r#"
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -87,9 +79,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the `extcodesize` instruction usage warning.
|
||||
///
|
||||
pub fn message_extcodesize(src: Option<&str>) -> Self {
|
||||
let message = r#"
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -114,9 +104,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the `origin` instruction usage warning.
|
||||
///
|
||||
pub fn message_tx_origin(src: Option<&str>) -> Self {
|
||||
let message = r#"
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -139,9 +127,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the internal function pointer usage error.
|
||||
///
|
||||
pub fn message_internal_function_pointer(src: Option<&str>) -> Self {
|
||||
let message = r#"
|
||||
┌──────────────────────────────────────────────────────────────────────────────────────────────────┐
|
||||
@@ -161,9 +147,7 @@ impl Error {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Appends the contract path to the message..
|
||||
///
|
||||
pub fn push_contract_path(&mut self, path: &str) {
|
||||
self.formatted_message
|
||||
.push_str(format!("\n--> {path}\n").as_str());
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output error source location.
|
||||
//!
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output error source location.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct SourceLocation {
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output.
|
||||
//!
|
||||
|
||||
pub mod contract;
|
||||
pub mod error;
|
||||
@@ -27,9 +25,7 @@ use self::contract::Contract;
|
||||
use self::error::Error as SolcStandardJsonOutputError;
|
||||
use self::source::Source;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Output {
|
||||
/// The file-contract hashmap.
|
||||
@@ -53,9 +49,7 @@ pub struct Output {
|
||||
}
|
||||
|
||||
impl Output {
|
||||
///
|
||||
/// Converts the `solc` JSON output into a convenient project.
|
||||
///
|
||||
pub fn try_to_project(
|
||||
&mut self,
|
||||
source_code_files: BTreeMap<String, String>,
|
||||
@@ -144,9 +138,7 @@ impl Output {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Removes EVM artifacts to prevent their accidental usage.
|
||||
///
|
||||
pub fn remove_evm(&mut self) {
|
||||
if let Some(files) = self.contracts.as_mut() {
|
||||
for (_, file) in files.iter_mut() {
|
||||
@@ -159,9 +151,7 @@ impl Output {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// Traverses the AST and returns the list of additional errors and warnings.
|
||||
///
|
||||
pub fn preprocess_ast(
|
||||
&mut self,
|
||||
version: &SolcVersion,
|
||||
@@ -196,9 +186,7 @@ impl Output {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// The pass, which replaces with dependency indexes with actual data.
|
||||
///
|
||||
fn preprocess_dependencies(&mut self) -> anyhow::Result<()> {
|
||||
let files = match self.contracts.as_mut() {
|
||||
Some(files) => files,
|
||||
@@ -242,9 +230,7 @@ impl Output {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
///
|
||||
/// Preprocesses an assembly JSON structure dependency data map.
|
||||
///
|
||||
fn preprocess_dependency_level(
|
||||
full_path: &str,
|
||||
assembly: &mut Assembly,
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
//!
|
||||
//! The `solc --standard-json` output source.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
@@ -10,9 +8,7 @@ use crate::solc::standard_json::output::error::Error as SolcStandardJsonOutputEr
|
||||
use crate::solc::version::Version as SolcVersion;
|
||||
use crate::warning::Warning;
|
||||
|
||||
///
|
||||
/// The `solc --standard-json` output source.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Source {
|
||||
@@ -23,9 +19,7 @@ pub struct Source {
|
||||
}
|
||||
|
||||
impl Source {
|
||||
///
|
||||
/// Checks the AST node for the `ecrecover` function usage.
|
||||
///
|
||||
pub fn check_ecrecover(ast: &serde_json::Value) -> Option<SolcStandardJsonOutputError> {
|
||||
let ast = ast.as_object()?;
|
||||
|
||||
@@ -46,9 +40,7 @@ impl Source {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the AST node for the `<address payable>`'s `send` and `transfer` methods usage.
|
||||
///
|
||||
pub fn check_send_and_transfer(ast: &serde_json::Value) -> Option<SolcStandardJsonOutputError> {
|
||||
let ast = ast.as_object()?;
|
||||
|
||||
@@ -70,9 +62,7 @@ impl Source {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the AST node for the `extcodesize` assembly instruction usage.
|
||||
///
|
||||
pub fn check_assembly_extcodesize(
|
||||
ast: &serde_json::Value,
|
||||
) -> Option<SolcStandardJsonOutputError> {
|
||||
@@ -96,9 +86,7 @@ impl Source {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the AST node for the `origin` assembly instruction usage.
|
||||
///
|
||||
pub fn check_assembly_origin(ast: &serde_json::Value) -> Option<SolcStandardJsonOutputError> {
|
||||
let ast = ast.as_object()?;
|
||||
|
||||
@@ -120,9 +108,7 @@ impl Source {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the AST node for the `tx.origin` value usage.
|
||||
///
|
||||
pub fn check_tx_origin(ast: &serde_json::Value) -> Option<SolcStandardJsonOutputError> {
|
||||
let ast = ast.as_object()?;
|
||||
|
||||
@@ -146,9 +132,7 @@ impl Source {
|
||||
))
|
||||
}
|
||||
|
||||
///
|
||||
/// Checks the AST node for the internal function pointers value usage.
|
||||
///
|
||||
pub fn check_internal_function_pointer(
|
||||
ast: &serde_json::Value,
|
||||
) -> Option<SolcStandardJsonOutputError> {
|
||||
@@ -174,9 +158,7 @@ impl Source {
|
||||
)
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the list of messages for some specific parts of the AST.
|
||||
///
|
||||
pub fn get_messages(
|
||||
ast: &serde_json::Value,
|
||||
version: &SolcVersion,
|
||||
@@ -240,9 +222,7 @@ impl Source {
|
||||
messages
|
||||
}
|
||||
|
||||
///
|
||||
/// Returns the name of the last contract.
|
||||
///
|
||||
pub fn last_contract_name(&self) -> anyhow::Result<String> {
|
||||
self.ast
|
||||
.as_ref()
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
//!
|
||||
//! The Solidity compiler version.
|
||||
//!
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
///
|
||||
/// The Solidity compiler version.
|
||||
///
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
pub struct Version {
|
||||
/// The long version string.
|
||||
@@ -19,9 +15,7 @@ pub struct Version {
|
||||
}
|
||||
|
||||
impl Version {
|
||||
///
|
||||
/// A shortcut constructor.
|
||||
///
|
||||
pub fn new(
|
||||
long: String,
|
||||
default: semver::Version,
|
||||
@@ -34,9 +28,7 @@ impl Version {
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
/// A shortcut constructor for a simple version.
|
||||
///
|
||||
pub fn new_simple(version: semver::Version) -> Self {
|
||||
Self {
|
||||
long: version.to_string(),
|
||||
|
||||
Reference in New Issue
Block a user