Struct ethers::solc::Project[][src]

pub struct Project<Artifacts = MinimalCombinedArtifacts> where
    Artifacts: ArtifactOutput
{ 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, Global>, pub allowed_lib_paths: AllowedLibPaths, }
Expand description

Handles contract compiling

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, Global>

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 all sources found under the project’s 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.
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.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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