Crate cyfrin_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.

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.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};

// 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::CompilerOutput;
pub use artifacts::EvmVersion;
pub use artifacts::SolcInput;
pub use hh::HardhatArtifact;
pub use hh::HardhatArtifacts;
pub use resolver::Graph;

Modules§

artifacts
Solc artifact types.
buildinfo
Represents an entire build
cache
Support for compiling contracts.
compilers
contracts
error
flatten
hh
Hardhat support
info
Commonly used identifiers for contracts in the compiled output.
many
output
The output of a compiled project
project
Manages compiling of a Project
project_utilproject-util
Utilities for creating, mocking and testing of (temporary) projects Utilities for mocking project workspaces.
remappings
report
Subscribe to events in the compiler pipeline
resolver
Resolution of the entire dependency graph for a project.
sourcemap
sources
utils
Utility functions

Structs§

AggregatedCompilerOutput
The aggregated output of (multiple) compile jobs
ArtifactFile
Represents an artifact file representing a crate::Contract
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
ConfigurableContractArtifact
Represents the Artifact that ConfigurableArtifacts emits.
ExtraOutputFiles
Determines what to emit as additional file
ExtraOutputValues
Determines the additional values to include in the contract’s artifact file
FilteredSources
Container type for a mapping from source path to SourceCompilationKind
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
Solc
Abstraction over solc command line utility
SolcConfig
The config to use when compiling the contracts
SolcSparseFileFilter
Wrapper around a FileFilter that includes files matched by the inner filter and their link references obtained from GraphEdges.
TestFileFilter
An FileFilter that matches all solidity files that end with .t.sol

Enums§

CompilerConfig
PathStyle
SourceCompilationKind
Represents the state of a filtered Source
SparseOutputFilter
A type that can apply a filter to a set of preprocessed FilteredSources in order to set sparse output for specific files

Constants§

BERLIN_SOLC
Berlin support https://blog.soliditylang.org/2021/06/10/solidity-0.8.5-release-announcement/
BYZANTIUM_SOLC
Support for configuring the EVM version https://blog.soliditylang.org/2018/03/08/solidity-0.4.21-release-announcement/
CANCUN_SOLC
Cancun support https://soliditylang.org/blog/2024/01/26/solidity-0.8.24-release-announcement/
CONSTANTINOPLE_SOLC
Bug fix for configuring the EVM version with Constantinople https://blog.soliditylang.org/2018/03/08/solidity-0.4.21-release-announcement/
ISTANBUL_SOLC
Istanbul support https://blog.soliditylang.org/2019/12/09/solidity-0.5.14-release-announcement/
LONDON_SOLC
London support https://blog.soliditylang.org/2021/08/11/solidity-0.8.7-release-announcement/
PARIS_SOLC
Paris support https://blog.soliditylang.org/2023/02/01/solidity-0.8.18-release-announcement/
PETERSBURG_SOLC
Petersburg support https://blog.soliditylang.org/2019/03/05/solidity-0.5.5-release-announcement/
SHANGHAI_SOLC
Shanghai support https://blog.soliditylang.org/2023/05/10/solidity-0.8.20-release-announcement/
SOLC
The name of the solc binary on the system
SOLC_EXTENSIONS
Extensions acceptable by solc compiler.

Statics§

RELEASESsvm-solc
A 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
SUPPORTS_BASE_PATH
SUPPORTS_INCLUDE_PATH

Traits§

Artifact
A trait representation for a crate::Contract artifact
ArtifactOutput
Handler invoked with the output of solc
FileFilter
A predicate property that determines whether a file satisfies a certain condition
SparseOutputFileFilter
This trait behaves in a similar way to FileFilter but used to configure OutputSelection configuration. In certain cases, we might want to include some of the file dependencies into the compiler output even if we might not be directly interested in them.