Crate foundry_compilers

Source
Expand description

§Foundry Compilers

| Docs |

Originally part of ethers-rs as ethers-solc, Foundry Compilers is the compilation backend for Foundry.

ethers-rs’s ethers-solc is considered to be in maintenance mode, and any fixes to it will also be reflected on Foundry Compilers. No action is currently needed from devs, although we heavily recommend using Foundry Compilers instead of ethers-solc.

Build Status Telegram chat

§Supported Rust Versions

Foundry Compilers will keep a rolling MSRV (minimum supported rust version) policy of at least 6 months. When increasing the MSRV, the new Rust version must have been released at least six months ago. The current MSRV is 1.83.0.

Note that the MSRV is not increased automatically, and only as part of a minor release.

§Contributing

Thanks for your help in improving the project! We are so happy to have you! We have a contributing guide to help you get involved in the Foundry Compilers project.

Pull requests will not be merged unless CI passes, so please ensure that your contribution follows the linting rules and passes clippy.

§Overview

To install, simply add foundry-compilers to your cargo dependencies.

[dependencies]
foundry-compilers = "0.10.1"

Example usage:

use foundry_compilers::{Project, ProjectPathsConfig};
use std::path::Path;

// configure the project with all its paths, solc, cache etc.
let project = Project::builder()
    .paths(ProjectPathsConfig::hardhat(Path::new(env!("CARGO_MANIFEST_DIR"))).unwrap())
    .build(Default::default())
    .unwrap();
let output = project.compile().unwrap();

// Tell Cargo that if a source file changes, to rerun this build script.
project.rerun_if_sources_changed();

Re-exports§

pub use resolver::Graph;
pub use foundry_compilers_artifacts as artifacts;
pub use compilers::*;

Modules§

buildinfo
Represents an entire build
cache
Support for compiling contracts.
compilers
contracts
error
flatten
info
Commonly used identifiers for contracts in the compiled output.
many
output
The output of a compiled project
project
Manages compiling of a Project
report
Subscribe to events in the compiler pipeline
resolver
Resolution of the entire dependency graph for a project.
sources
utils
Utility functions

Structs§

AggregatedCompilerOutput
The aggregated output of (multiple) compile jobs
ArtifactFile
Represents an artifact file representing a crate::compilers::CompilerContract
ArtifactId
Represents unique artifact metadata for identifying artifacts on output
Artifacts
Represents a set of Artifacts
ConfigurableArtifacts
An Artifact implementation that can be configured to include additional content and emit additional files
ExtraOutputFiles
Determines what to emit as an additional file
ExtraOutputValues
Determines the additional values to include in the contract’s artifact file
HardhatArtifacts
Hardhat style artifacts handler
MinimalCombinedArtifacts
An Artifact implementation that uses a compact representation
MinimalCombinedArtifactsHardhatFallback
An Artifacts handler implementation that works the same as MinimalCombinedArtifacts but also supports reading hardhat artifacts if an initial attempt to deserialize an artifact failed
OutputContext
Additional context to use during ArtifactOutput::on_output()
Project
Represents a project workspace and handles solc compiling of all contracts in that workspace.
ProjectBuilder
ProjectCompileOutput
Contains a mixture of already compiled/cached artifacts and the input set of sources that still need to be compiled.
ProjectPaths
This is a subset of ProjectPathsConfig that contains all relevant folders in the project
ProjectPathsConfig
Where to find all files or where to write them
SolcConfig
The config to use when compiling the contracts
TestFileFilter
An FileFilter that matches all solidity files that end with .t.sol

Enums§

PathStyle
SparseOutputFilter
A type that can apply a filter to a set of preprocessed Sources in order to set sparse output for specific files

Traits§

Artifact
A trait representation for a crate::compilers::CompilerContract artifact
ArtifactOutput
Handler invoked with the output of solc
FileFilter
A predicate property that determines whether a file satisfies a certain condition

Functions§

apply_updates
Utility function to apply a set of updates to provided sources.
replace_source_content
Utility function to change source content ranges with provided updates. Assumes that the updates are sorted.

Type Aliases§

Updates
Updates to be applied to the sources.