mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-06-23 18:51:05 +00:00
@@ -1,6 +1,7 @@
|
|||||||
//! This crate provides compiler helpers for all supported Solidity targets:
|
//! This crate provides compiler helpers for all supported Solidity targets:
|
||||||
//! - Ethereum solc compiler
|
//! - Ethereum solc compiler
|
||||||
//! - Polkadot revive compiler
|
//! - Polkadot revive resolc compiler
|
||||||
|
//! - Polkadot revive Wasm compiler
|
||||||
|
|
||||||
use std::{fs::read_to_string, path::Path};
|
use std::{fs::read_to_string, path::Path};
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ pub mod solc;
|
|||||||
/// A common interface for all supported Solidity compilers.
|
/// A common interface for all supported Solidity compilers.
|
||||||
pub trait SolidityCompiler {
|
pub trait SolidityCompiler {
|
||||||
/// Extra options specific to the compiler.
|
/// Extra options specific to the compiler.
|
||||||
type Options: Sized;
|
type Options;
|
||||||
|
|
||||||
fn build(
|
fn build(
|
||||||
&self,
|
&self,
|
||||||
@@ -34,7 +35,6 @@ pub trait SolidityCompiler {
|
|||||||
pub struct Compiler<T: SolidityCompiler> {
|
pub struct Compiler<T: SolidityCompiler> {
|
||||||
input: SolcStandardJsonInput,
|
input: SolcStandardJsonInput,
|
||||||
extra_options: Option<T::Options>,
|
extra_options: Option<T::Options>,
|
||||||
solc_version: Version,
|
|
||||||
allow_paths: Vec<String>,
|
allow_paths: Vec<String>,
|
||||||
base_path: Option<String>,
|
base_path: Option<String>,
|
||||||
}
|
}
|
||||||
@@ -43,7 +43,7 @@ impl<T> Compiler<T>
|
|||||||
where
|
where
|
||||||
T: SolidityCompiler,
|
T: SolidityCompiler,
|
||||||
{
|
{
|
||||||
pub fn new(solc_version: Version) -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
input: SolcStandardJsonInput {
|
input: SolcStandardJsonInput {
|
||||||
language: SolcStandardJsonInputLanguage::Solidity,
|
language: SolcStandardJsonInputLanguage::Solidity,
|
||||||
@@ -63,7 +63,6 @@ where
|
|||||||
),
|
),
|
||||||
},
|
},
|
||||||
extra_options: None,
|
extra_options: None,
|
||||||
solc_version,
|
|
||||||
allow_paths: Default::default(),
|
allow_paths: Default::default(),
|
||||||
base_path: None,
|
base_path: None,
|
||||||
}
|
}
|
||||||
@@ -86,11 +85,6 @@ where
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn solc_version(mut self, solc_version: Version) -> Self {
|
|
||||||
self.solc_version = solc_version;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn extra_options(mut self, extra_options: T::Options) -> Self {
|
pub fn extra_options(mut self, extra_options: T::Options) -> Self {
|
||||||
self.extra_options = Some(extra_options);
|
self.extra_options = Some(extra_options);
|
||||||
self
|
self
|
||||||
@@ -106,8 +100,7 @@ where
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn try_build(&self) -> anyhow::Result<SolcStandardJsonOutput> {
|
pub fn try_build(&self, solc_version: &Version) -> anyhow::Result<SolcStandardJsonOutput> {
|
||||||
let compiler = T::new(&self.solc_version);
|
T::new(solc_version).build(&self.input, &self.extra_options)
|
||||||
compiler.build(&self.input, &self.extra_options)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user