Struct ethers_solc::Solc [−][src]
Expand description
Abstraction over solc
command line utility
Supports sync and async functions.
By default the solc path is configured as follows, with descending priority:
SOLC_PATH
environment variable- svm’s
global_version
(set viasvm use <version>
), stored at<svm_home>/.global_version
solc
otherwise
Fields
solc: PathBuf
Path to the solc
executable
args: Vec<String>
Additional arguments passed to the solc
exectuable
Implementations
Adds multiple arguments to pass to the solc
.
Returns the directory in which svm stores all versions
This will be ~/.svm
on unix
Returns the semver::Version
svm’s .global_version
is currently set to.
global_version
is configured with (svm use <version>
)
This will read the version string (eg: “0.8.9”) that the ~/.svm/.global_version
file
contains
pub fn find_matching_installation(
versions: &[Version],
required_version: &VersionReq
) -> Option<Version>
pub fn find_matching_installation(
versions: &[Version],
required_version: &VersionReq
) -> Option<Version>
Assuming the versions
array is sorted, it returns the first element which satisfies
the provided VersionReq
Given a Solidity source, it detects the latest compiler version which can be used to build it, and returns it.
If the required compiler version is not installed, it also proceeds to install it.
Given a Solidity version requirement, it detects the latest compiler version which can be used to build it, and returns it.
If the required compiler version is not installed, it also proceeds to install it.
Parses the given source looking for the pragma
definition and
returns the corresponding SemVer version requirement.
Installs the provided version of Solc in the machine under the svm dir
Example
use ethers_solc::{Solc, ISTANBUL_SOLC};
Solc::install(&ISTANBUL_SOLC).await.unwrap();
let solc = Solc::find_svm_installed_version(&ISTANBUL_SOLC.to_string());
Blocking version of Self::install
Verify that the checksum for this version of solc is correct. We check against the SHA256 checksum from the build information published by binaries.soliditylang
Convenience function for compiling all sources under the given path
Run solc --stand-json
and return the solc
’s output as
CompilerOutput
Example
use ethers_solc::{CompilerInput, Solc};
let solc = Solc::default();
let input = CompilerInput::new("./contracts")?;
let output = solc.compile(&input)?;
Run solc --stand-json
and return the solc
’s output as the given json
output
pub async fn async_compile_source<T: Serialize>(
&self,
path: impl AsRef<Path>
) -> Result<CompilerOutput>
pub async fn async_compile_source<T: Serialize>(
&self,
path: impl AsRef<Path>
) -> Result<CompilerOutput>
Convenience function for compiling all sources under the given path
Run solc --stand-json
and return the solc
’s output as
CompilerOutput
pub async fn async_compile_as<T: Serialize, D: DeserializeOwned>(
&self,
input: &T
) -> Result<D>
pub async fn async_compile_as<T: Serialize, D: DeserializeOwned>(
&self,
input: &T
) -> Result<D>
Run solc --stand-json
and return the solc
’s output as the given json
output
pub async fn compile_many<I>(jobs: I, n: usize) -> CompiledMany where
I: IntoIterator<Item = (Solc, CompilerInput)>,
pub async fn compile_many<I>(jobs: I, n: usize) -> CompiledMany where
I: IntoIterator<Item = (Solc, CompilerInput)>,
Compiles all CompilerInput
s with their associated Solc
.
This will buffer up to n
solc
processes and then return the CompilerOutput
s in the
order in which they complete. No more than n
futures will be buffered at any point in
time, and less than n
may also be buffered depending on the state of each future.
Example
Compile 2 CompilerInput
s at once
use ethers_solc::{CompilerInput, Solc};
let solc1 = Solc::default();
let solc2 = Solc::default();
let input1 = CompilerInput::new("contracts").unwrap();
let input2 = CompilerInput::new("src").unwrap();
let outputs = Solc::compile_many([(solc1, input1), (solc2, input2)], 2).await.flattened().unwrap();
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for Solc
impl UnwindSafe for Solc
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more