Struct ethers_solc::Project [−][src]
pub struct Project<Artifacts: ArtifactOutput = MinimalCombinedArtifacts> {
pub paths: ProjectPathsConfig,
pub solc: Solc,
pub solc_config: SolcConfig,
pub cached: bool,
pub no_artifacts: bool,
pub auto_detect: bool,
pub artifacts: PhantomData<Artifacts>,
pub ignored_error_codes: Vec<u64>,
pub allowed_lib_paths: AllowedLibPaths,
// some fields omitted
}
Expand description
Represents a project workspace and handles solc
compiling of all contracts in that workspace.
Fields
paths: ProjectPathsConfig
The layout of the
solc: Solc
Where to find solc
solc_config: SolcConfig
How solc invocation should be configured.
cached: bool
Whether caching is enabled
no_artifacts: bool
Whether writing artifacts to disk is enabled
auto_detect: bool
Whether writing artifacts to disk is enabled
artifacts: PhantomData<Artifacts>
How to handle compiler output
ignored_error_codes: Vec<u64>
Errors/Warnings which match these error codes are not going to be logged
allowed_lib_paths: AllowedLibPaths
The paths which will be allowed for library inclusion
Implementations
Convenience function to call ProjectBuilder::default()
Example
Configure with MinimalCombinedArtifacts
artifacts output
use ethers_solc::Project;
let config = Project::builder().build().unwrap();
To configure any a project with any ArtifactOutput
use either
use ethers_solc::Project;
let config = Project::builder().build().unwrap();
or use the builder directly
use ethers_solc::{MinimalCombinedArtifacts, ProjectBuilder};
let config = ProjectBuilder::<MinimalCombinedArtifacts>::default().build().unwrap();
Returns the path to the artifacts directory
Returns the path to the sources directory
Returns the path to the cache file
Sets the maximum number of parallel solc
processes to run simultaneously.
Returns all sources found under the project’s configured sources path
This emits the cargo rerun-if-changed
instruction.
Which tells Cargo to re-run the build script if a file inside the project’s sources
directory has changed.
Use this if you compile a project in a build.rs
file.
Example build.rs
file
use ethers_solc::{Project, ProjectPathsConfig};
// configure the project with all its paths, solc, cache etc. where the root dir is the current rust project.
let project = Project::builder()
.paths(ProjectPathsConfig::hardhat(env!("CARGO_MANIFEST_DIR")).unwrap())
.build()
.unwrap();
let output = project.compile().unwrap();
// Tell Cargo that if a source file changes, to rerun this build script.
project.rerun_if_sources_changed();
Attempts to compile the contracts found at the configured location.
NOTE: this does not check if the contracts were successfully compiled, see
CompilerOutput::has_error
instead.
NB: If the svm
feature is enabled, this function will automatically detect
solc versions across files.
pub fn compile_with_version(
&self,
solc: &Solc,
sources: Sources
) -> Result<ProjectCompileOutput<Artifacts>>
pub fn compile_with_version(
&self,
solc: &Solc,
sources: Sources
) -> Result<ProjectCompileOutput<Artifacts>>
Compiles the given source files with the exact Solc
executable
First all libraries for the sources are resolved by scanning all their imports.
If caching is enabled for the Project
, then all unchanged files are filtered from the
sources and their existing artifacts are read instead. This will also update the cache
file and cleans up entries for files which may have been removed. Unchanged files that
for which an artifact exist, are not compiled again.
Removes the project’s artifacts and cache file
Trait Implementations
Auto Trait Implementations
impl<Artifacts> RefUnwindSafe for Project<Artifacts> where
Artifacts: RefUnwindSafe,
impl<Artifacts> UnwindSafe for Project<Artifacts> where
Artifacts: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
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