Crate foundry_compilers
source ·Expand description
§Foundry Compilers
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 reflect on Foundry Compilers. No action is currently needed from devs, although we heavily recommend using Foundry Compilers instead of ethers-solc.
§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.65.0.
Note that the MSRV is not increased automatically, and only as part of a minor release.
§Contributing
Thanks for your help 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 = { git = "https://github.com/foundry-rs/compilers" }
Example usage:
use foundry_compilers::{Project, ProjectPathsConfig};
fn main() {
    // 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();
}Re-exports§
- pub use artifacts::CompilerInput;
- pub use artifacts::CompilerOutput;
- pub use artifacts::EvmVersion;
- pub use hh::HardhatArtifact;
- pub use hh::HardhatArtifacts;
- pub use resolver::Graph;
Modules§
- Solc artifact types.
- Represents an entire build
- Support for compiling contracts.
- Hardhat support
- Commonly used identifiers for contracts in the compiled output.
- The output of a compiled project
- Manages compiling of aProject
- project_utilproject-utilUtilities for creating, mocking and testing of (temporary) projects Utilities for mocking project workspaces.
- Subscribe to events in the compiler pipeline
- Resolution of the entire dependency graph for a project.
- Utility functions
Structs§
- The aggregated output of (multiple) compile jobs
- Helper struct for serializing--allow-pathsarguments to Solc
- Represents an artifact file representing acrate::Contract
- Represents unique artifact metadata for identifying artifacts on output
- Represents a set of Artifacts
- AnArtifactimplementation that can be configured to include additional content and emit additional files
- Represents theArtifactthatConfigurableArtifactsemits.
- Determines what to emit as additional file
- Determines the additional values to include in the contract’s artifact file
- AnArtifactimplementation that uses a compact representation
- An Artifacts handler implementation that works the same asMinimalCombinedArtifactsbut also supports reading hardhat artifacts if an initial attempt to deserialize an artifact failed
- Additional context to use duringArtifactOutput::on_output()
- Represents a project workspace and handlessolccompiling of all contracts in that workspace.
- Contains a mixture of already compiled/cached artifacts and the input set of sources that still need to be compiled.
- This is a subset of ProjectPathsConfig that contains all relevant folders in the project
- Where to find all files or where to write them
- Abstraction oversolccommand line utility
- The config to use when compiling the contracts
- An FileFilter that matches all solidity files that end with.t.sol
Enums§
- ASolcversion is either installed (available locally) or can be downloaded, from the remote endpoint
Constants§
- Support for configuring the EVM version https://blog.soliditylang.org/2018/03/08/solidity-0.4.21-release-announcement/
- Bug fix for configuring the EVM version with Constantinople https://blog.soliditylang.org/2018/03/08/solidity-0.4.21-release-announcement/
- The name of thesolcbinary on the system
Statics§
- RELEASESsvm-solcA list of upstream Solc releases, used to check which version we should download. The boolean value marks whether there was an error accessing the release list
Traits§
- A trait representation for acrate::Contractartifact
- Handler invoked with the output ofsolc
- A predicate property that determines whether a file satisfies a certain condition