Struct foundry_config::Config
source · pub struct Config {Show 78 fields
pub profile: Profile,
pub src: PathBuf,
pub test: PathBuf,
pub script: PathBuf,
pub out: PathBuf,
pub libs: Vec<PathBuf>,
pub remappings: Vec<RelativeRemapping>,
pub auto_detect_remappings: bool,
pub libraries: Vec<String>,
pub cache: bool,
pub cache_path: PathBuf,
pub broadcast: PathBuf,
pub allow_paths: Vec<PathBuf>,
pub include_paths: Vec<PathBuf>,
pub force: bool,
pub evm_version: EvmVersion,
pub gas_reports: Vec<String>,
pub gas_reports_ignore: Vec<String>,
pub solc: Option<SolcReq>,
pub auto_detect_solc: bool,
pub offline: bool,
pub optimizer: bool,
pub optimizer_runs: usize,
pub optimizer_details: Option<OptimizerDetails>,
pub model_checker: Option<ModelCheckerSettings>,
pub verbosity: u8,
pub eth_rpc_url: Option<String>,
pub eth_rpc_jwt: Option<String>,
pub etherscan_api_key: Option<String>,
pub etherscan: EtherscanConfigs,
pub ignored_error_codes: Vec<SolidityErrorCode>,
pub deny_warnings: bool,
pub test_pattern: Option<RegexWrapper>,
pub test_pattern_inverse: Option<RegexWrapper>,
pub contract_pattern: Option<RegexWrapper>,
pub contract_pattern_inverse: Option<RegexWrapper>,
pub path_pattern: Option<Glob>,
pub path_pattern_inverse: Option<Glob>,
pub fuzz: FuzzConfig,
pub invariant: InvariantConfig,
pub ffi: bool,
pub sender: Address,
pub tx_origin: Address,
pub initial_balance: U256,
pub block_number: u64,
pub fork_block_number: Option<u64>,
pub chain_id: Option<Chain>,
pub gas_limit: GasLimit,
pub code_size_limit: Option<usize>,
pub gas_price: Option<u64>,
pub block_base_fee_per_gas: u64,
pub block_coinbase: Address,
pub block_timestamp: u64,
pub block_difficulty: u64,
pub block_prevrandao: H256,
pub block_gas_limit: Option<GasLimit>,
pub memory_limit: u64,
pub extra_output: Vec<ContractOutputSelection>,
pub extra_output_files: Vec<ContractOutputSelection>,
pub names: bool,
pub sizes: bool,
pub via_ir: bool,
pub rpc_storage_caching: StorageCachingConfig,
pub no_storage_caching: bool,
pub no_rpc_rate_limit: bool,
pub rpc_endpoints: RpcEndpoints,
pub use_literal_content: bool,
pub bytecode_hash: BytecodeHash,
pub cbor_metadata: bool,
pub revert_strings: Option<RevertStrings>,
pub sparse_mode: bool,
pub build_info: bool,
pub build_info_path: Option<PathBuf>,
pub fmt: FormatterConfig,
pub doc: DocConfig,
pub fs_permissions: FsPermissions,
pub cancun: bool,
pub __warnings: Vec<Warning>,
/* private fields */
}Expand description
Foundry configuration
Defaults
All configuration values have a default, documented in the fields
section below. Config::default() returns the default values for
the default profile while Config::with_root() returns the values based on the given
directory. Config::load() starts with the default profile and merges various providers into
the config, same for Config::load_with_root(), but there the default values are determined
by Config::with_root()
Provider Details
Config is a Figment Provider with the following characteristics:
-
Profile
The profile is set to the value of the
profilefield. -
Metadata
This provider is named
Foundry Config. It does not specify aSourceand uses default interpolation. -
Data
The data emitted by this provider are the keys and values corresponding to the fields and values of the structure. The dictionary is emitted to the “default” meta-profile.
Note that these behaviors differ from those of Config::figment().
Fields§
§profile: ProfileThe selected profile. (default: default default)
Note: This field is never serialized nor deserialized. When a
Config is merged into a Figment as a Provider, this profile is
selected on the Figment. When a Config is extracted, this field is
set to the extracting Figment’s selected Profile.
src: PathBufpath of the source contracts dir, like src or contracts
test: PathBufpath of the test dir
script: PathBufpath of the script dir
out: PathBufpath to where artifacts shut be written to
libs: Vec<PathBuf>all library folders to include, lib, node_modules
remappings: Vec<RelativeRemapping>Remappings to use for this repo
auto_detect_remappings: boolWhether to autodetect remappings by scanning the libs folders recursively
libraries: Vec<String>library addresses to link
cache: boolwhether to enable cache
cache_path: PathBufwhere the cache is stored if enabled
broadcast: PathBufwhere the broadcast logs are stored
allow_paths: Vec<PathBuf>additional solc allow paths for --allow-paths
include_paths: Vec<PathBuf>additional solc include paths for --include-path
force: boolwhether to force a project.clean()
evm_version: EvmVersionevm version to use
gas_reports: Vec<String>list of contracts to report gas of
gas_reports_ignore: Vec<String>list of contracts to ignore for gas reports
solc: Option<SolcReq>The Solc instance to use if any.
This takes precedence over auto_detect_solc, if a version is set then this overrides
auto-detection.
Note for backwards compatibility reasons this also accepts solc_version from the toml
file, see [BackwardsCompatProvider]
auto_detect_solc: boolwhether to autodetect the solc compiler version to use
offline: boolOffline mode, if set, network access (downloading solc) is disallowed.
Relationship with auto_detect_solc:
- if
auto_detect_solc = trueandoffline = true, the required solc version(s) will be auto detected but if the solc version is not installed, it will not try to install it
optimizer: boolWhether to activate optimizer
optimizer_runs: usizeSets the optimizer runs
optimizer_details: Option<OptimizerDetails>Switch optimizer components on or off in detail. The “enabled” switch above provides two defaults which can be tweaked here. If “details” is given, “enabled” can be omitted.
model_checker: Option<ModelCheckerSettings>Model checker settings.
verbosity: u8verbosity to use
eth_rpc_url: Option<String>url of the rpc server that should be used for any rpc calls
eth_rpc_jwt: Option<String>JWT secret that should be used for any rpc calls
etherscan_api_key: Option<String>etherscan API key, or alias for an EtherscanConfig in etherscan table
etherscan: EtherscanConfigsMultiple etherscan api configs and their aliases
ignored_error_codes: Vec<SolidityErrorCode>list of solidity error codes to always silence in the compiler output
deny_warnings: boolWhen true, compiler warnings are treated as errors
test_pattern: Option<RegexWrapper>Only run test functions matching the specified regex pattern.
test_pattern_inverse: Option<RegexWrapper>Only run test functions that do not match the specified regex pattern.
contract_pattern: Option<RegexWrapper>Only run tests in contracts matching the specified regex pattern.
contract_pattern_inverse: Option<RegexWrapper>Only run tests in contracts that do not match the specified regex pattern.
path_pattern: Option<Glob>Only run tests in source files matching the specified glob pattern.
path_pattern_inverse: Option<Glob>Only run tests in source files that do not match the specified glob pattern.
fuzz: FuzzConfigConfiguration for fuzz testing
invariant: InvariantConfigConfiguration for invariant testing
ffi: boolWhether to allow ffi cheatcodes in test
sender: AddressThe address which will be executing all tests
tx_origin: AddressThe tx.origin value during EVM execution
initial_balance: U256the initial balance of each deployed test contract
block_number: u64the block.number value during EVM execution
fork_block_number: Option<u64>pins the block number for the state fork
chain_id: Option<Chain>The chain id to use
gas_limit: GasLimitBlock gas limit
code_size_limit: Option<usize>EIP-170: Contract code size limit in bytes. Useful to increase this because of tests.
gas_price: Option<u64>tx.gasprice value during EVM execution“
This is an Option, so we can determine in fork mode whether to use the config’s gas price (if set by user) or the remote client’s gas price
block_base_fee_per_gas: u64the base fee in a block
block_coinbase: Addressthe block.coinbase value during EVM execution
block_timestamp: u64the block.timestamp value during EVM execution
block_difficulty: u64the block.difficulty value during EVM execution
block_prevrandao: H256Before merge the block.max_hash after merge it is block.prevrandao
block_gas_limit: Option<GasLimit>the block.gaslimit value during EVM execution
memory_limit: u64The memory limit of the EVM (32 MB by default)
extra_output: Vec<ContractOutputSelection>Additional output selection for all contracts such as “ir”, “devdoc”, “storageLayout”, etc. See Solc Compiler Api
The following values are always set because they’re required by forge
extra_output_files: Vec<ContractOutputSelection>If set , a separate json file will be emitted for every contract depending on the
selection, eg. extra_output_files = ["metadata"] will create a metadata.json for
each contract in the project. See Contract Metadata
The difference between extra_output = ["metadata"] and
extra_output_files = ["metadata"] is that the former will include the
contract’s metadata in the contract’s json artifact, whereas the latter will emit the
output selection as separate files.
names: boolPrint the names of the compiled contracts
sizes: boolPrint the sizes of the compiled contracts
via_ir: boolIf set to true, changes compilation pipeline to go through the Yul intermediate representation.
rpc_storage_caching: StorageCachingConfigRPC storage caching settings determines what chains and endpoints to cache
no_storage_caching: boolDisables storage caching entirely. This overrides any settings made in
rpc_storage_caching
no_rpc_rate_limit: boolDisables rate limiting entirely. This overrides any settings made in
compute_units_per_second
rpc_endpoints: RpcEndpointsMultiple rpc endpoints and their aliases
use_literal_content: boolWhether to store the referenced sources in the metadata as literal data.
bytecode_hash: BytecodeHashWhether to include the metadata hash.
The metadata hash is machine dependent. By default, this is set to BytecodeHash::None to allow for deterministic code, See: https://docs.soliditylang.org/en/latest/metadata.html
cbor_metadata: boolWhether to append the metadata hash to the bytecode.
If this is false and the bytecode_hash option above is not None solc will issue a
warning.
revert_strings: Option<RevertStrings>How to treat revert (and require) reason strings.
sparse_mode: boolWhether to compile in sparse mode
If this option is enabled, only the required contracts/files will be selected to be included in solc’s output selection, see also OutputSelection
build_info: boolWhether to emit additional build info files
If set to true, ethers-solc will generate additional build info json files for every
new build, containing the CompilerInput and CompilerOutput
build_info_path: Option<PathBuf>The path to the build-info directory that contains the build info json files.
fmt: FormatterConfigConfiguration for forge fmt
doc: DocConfigConfiguration for forge doc
fs_permissions: FsPermissionsConfigures the permissions of cheat codes that touch the file system.
This includes what operations can be executed (read, write)
cancun: boolTemporary config to enable SpecId::CANCUN
https://github.com/foundry-rs/foundry/issues/5782 Should be removed once EvmVersion Cancun is supported by solc
__warnings: Vec<Warning>Warnings gathered when loading the Config. See WarningsProvider for more information
Implementations§
source§impl Config
impl Config
sourcepub const DEFAULT_PROFILE: Profile = _
pub const DEFAULT_PROFILE: Profile = _
The default profile: “default”
sourcepub const HARDHAT_PROFILE: Profile = _
pub const HARDHAT_PROFILE: Profile = _
The hardhat profile: “hardhat”
sourcepub const PROFILE_SECTION: &'static str = "profile"
pub const PROFILE_SECTION: &'static str = "profile"
TOML section for profiles
sourcepub const STANDALONE_SECTIONS: &'static [&'static str] = _
pub const STANDALONE_SECTIONS: &'static [&'static str] = _
Standalone sections in the config which get integrated into the selected profile
sourcepub const FOUNDRY_DIR_NAME: &'static str = ".foundry"
pub const FOUNDRY_DIR_NAME: &'static str = ".foundry"
The name of the directory foundry reserves for itself under the user’s home directory: ~
sourcepub const DEFAULT_SENDER: H160 = _
pub const DEFAULT_SENDER: H160 = _
Default address for tx.origin
0x1804c8AB1F12E6bbf3894d4083f33e07309d1f38
sourcepub fn load_with_root(root: impl Into<PathBuf>) -> Self
pub fn load_with_root(root: impl Into<PathBuf>) -> Self
Returns the current Config
See Config::figment_with_root
sourcepub fn from_provider<T: Provider>(provider: T) -> Self
pub fn from_provider<T: Provider>(provider: T) -> Self
Extract a Config from provider, panicking if extraction fails.
Panics
If extraction fails, prints an error message indicating the failure and
panics. For a version that doesn’t panic, use Config::try_from().
Example
use foundry_config::Config;
use figment::providers::{Toml, Format, Env};
// Use foundry's default `Figment`, but allow values from `other.toml`
// to supersede its values.
let figment = Config::figment()
.merge(Toml::file("other.toml").nested());
let config = Config::from_provider(figment);sourcepub fn try_from<T: Provider>(provider: T) -> Result<Self, ExtractConfigError>
pub fn try_from<T: Provider>(provider: T) -> Result<Self, ExtractConfigError>
Attempts to extract a Config from provider, returning the result.
Example
use foundry_config::Config;
use figment::providers::{Toml, Format, Env};
// Use foundry's default `Figment`, but allow values from `other.toml`
// to supersede its values.
let figment = Config::figment()
.merge(Toml::file("other.toml").nested());
let config = Config::try_from(figment);sourcepub fn canonic(self) -> Self
pub fn canonic(self) -> Self
The config supports relative paths and tracks the root path separately see
Config::with_root
This joins all relative paths with the current root and attempts to make them canonic
sourcepub fn canonic_at(self, root: impl Into<PathBuf>) -> Self
pub fn canonic_at(self, root: impl Into<PathBuf>) -> Self
Joins all relative paths with the given root so that paths that are defined as:
[profile.default]
src = "src"
out = "./out"
libs = ["lib", "/var/lib"]
Will be made canonic with the given root:
[profile.default]
src = "<root>/src"
out = "<root>/out"
libs = ["<root>/lib", "/var/lib"]
sourcepub fn sanitized(self) -> Self
pub fn sanitized(self) -> Self
Returns a sanitized version of the Config where are paths are set correctly and potential duplicates are resolved
See Self::canonic
sourcepub fn sanitize_remappings(&mut self)
pub fn sanitize_remappings(&mut self)
Cleans up any duplicate Remapping and sorts them
On windows this will convert any \ in the remapping path into a /
sourcepub fn install_lib_dir(&self) -> &Path
pub fn install_lib_dir(&self) -> &Path
Returns the directory in which dependencies should be installed
Returns the first dir from libs that is not node_modules or lib if libs is empty
sourcepub fn project(&self) -> Result<Project, SolcError>
pub fn project(&self) -> Result<Project, SolcError>
Serves as the entrypoint for obtaining the project.
Returns the Project configured with all solc and path related values.
Note: this also cleans Project::cleanup the workspace if force is set to true.
Example
use foundry_config::Config;
let config = Config::load_with_root(".").sanitized();
let project = config.project();sourcepub fn ephemeral_no_artifacts_project(&self) -> Result<Project, SolcError>
pub fn ephemeral_no_artifacts_project(&self) -> Result<Project, SolcError>
Same as Self::project() but sets configures the project to not emit artifacts and ignore
cache, caching causes no output until https://github.com/gakonst/ethers-rs/issues/727
sourcepub fn evm_spec_id(&self) -> SpecId
pub fn evm_spec_id(&self) -> SpecId
Returns the SpecId derived from the configured EvmVersion
sourcepub fn is_auto_detect(&self) -> bool
pub fn is_auto_detect(&self) -> bool
Returns whether the compiler version should be auto-detected
Returns false if solc_version is explicitly set, otherwise returns the value of
auto_detect_solc
sourcepub fn enable_caching(&self, endpoint: &str, chain_id: impl Into<u64>) -> bool
pub fn enable_caching(&self, endpoint: &str, chain_id: impl Into<u64>) -> bool
Whether caching should be enabled for the given chain id
sourcepub fn project_paths(&self) -> ProjectPathsConfig
pub fn project_paths(&self) -> ProjectPathsConfig
Returns the ProjectPathsConfig sub set of the config.
NOTE: this uses the paths as they are and does not modify them, see
[Self::sanitized]
Example
use foundry_config::Config;
let config = Config::load_with_root(".").sanitized();
let paths = config.project_paths();sourcepub fn get_all_remappings(&self) -> Vec<Remapping>
pub fn get_all_remappings(&self) -> Vec<Remapping>
Returns all configured [Remappings]
Note: this will add an additional <src>/=<src path> remapping here, see
Self::get_source_dir_remapping()
So that
import "./math/math.sol";
import "contracts/tokens/token.sol";
in contracts/contract.sol are resolved to
contracts/tokens/token.sol
contracts/math/math.sol
sourcepub fn get_rpc_jwt_secret(
&self
) -> Result<Option<Cow<'_, str>>, UnresolvedEnvVarError>
pub fn get_rpc_jwt_secret( &self ) -> Result<Option<Cow<'_, str>>, UnresolvedEnvVarError>
Returns the configured rpc jwt secret
Returns:
- The jwt secret, if configured
Example
use foundry_config::Config;
let config = Config::with_root("./");
let rpc_jwt = config.get_rpc_jwt_secret().unwrap().unwrap();sourcepub fn get_rpc_url(&self) -> Option<Result<Cow<'_, str>, UnresolvedEnvVarError>>
pub fn get_rpc_url(&self) -> Option<Result<Cow<'_, str>, UnresolvedEnvVarError>>
Returns the configured rpc url
Returns:
- the matching, resolved url of
rpc_endpointsifeth_rpc_urlis an alias - the
eth_rpc_urlas-is if it isn’t an alias
Example
use foundry_config::Config;
let config = Config::with_root("./");
let rpc_url = config.get_rpc_url().unwrap().unwrap();sourcepub fn get_rpc_url_with_alias(
&self,
maybe_alias: &str
) -> Option<Result<Cow<'_, str>, UnresolvedEnvVarError>>
pub fn get_rpc_url_with_alias( &self, maybe_alias: &str ) -> Option<Result<Cow<'_, str>, UnresolvedEnvVarError>>
Resolves the given alias to a matching rpc url
Returns:
- the matching, resolved url of
rpc_endpointsifmaybe_aliasis an alias - None otherwise
Example
use foundry_config::Config;
let config = Config::with_root("./");
let rpc_url = config.get_rpc_url_with_alias("mainnet").unwrap().unwrap();sourcepub fn get_rpc_url_or<'a>(
&'a self,
fallback: impl Into<Cow<'a, str>>
) -> Result<Cow<'_, str>, UnresolvedEnvVarError>
pub fn get_rpc_url_or<'a>( &'a self, fallback: impl Into<Cow<'a, str>> ) -> Result<Cow<'_, str>, UnresolvedEnvVarError>
Returns the configured rpc, or the fallback url
Example
use foundry_config::Config;
let config = Config::with_root("./");
let rpc_url = config.get_rpc_url_or("http://localhost:8545").unwrap();sourcepub fn get_rpc_url_or_localhost_http(
&self
) -> Result<Cow<'_, str>, UnresolvedEnvVarError>
pub fn get_rpc_url_or_localhost_http( &self ) -> Result<Cow<'_, str>, UnresolvedEnvVarError>
Returns the configured rpc or "http://localhost:8545" if no eth_rpc_url is set
Example
use foundry_config::Config;
let config = Config::with_root("./");
let rpc_url = config.get_rpc_url_or_localhost_http().unwrap();sourcepub fn get_etherscan_config(
&self
) -> Option<Result<ResolvedEtherscanConfig, EtherscanConfigError>>
pub fn get_etherscan_config( &self ) -> Option<Result<ResolvedEtherscanConfig, EtherscanConfigError>>
Returns the EtherscanConfig to use, if any
Returns
- the matching
ResolvedEtherscanConfigof theetherscantable ifetherscan_api_keyis an alias - the Mainnet
ResolvedEtherscanConfigifetherscan_api_keyis set,Noneotherwise
Example
use foundry_config::Config;
let config = Config::with_root("./");
let etherscan_config = config.get_etherscan_config().unwrap().unwrap();
let client = etherscan_config.into_client().unwrap();sourcepub fn get_etherscan_config_with_chain(
&self,
chain: Option<impl Into<Chain>>
) -> Result<Option<ResolvedEtherscanConfig>, EtherscanConfigError>
pub fn get_etherscan_config_with_chain( &self, chain: Option<impl Into<Chain>> ) -> Result<Option<ResolvedEtherscanConfig>, EtherscanConfigError>
Same as Self::get_etherscan_config() but optionally updates the config with the given
chain, and etherscan_api_key
If not matching alias was found, then this will try to find the first entry in the table with a matching chain id. If an etherscan_api_key is already set it will take precedence over the chain’s entry in the table.
sourcepub fn get_etherscan_api_key(
&self,
chain: Option<impl Into<Chain>>
) -> Option<String>
pub fn get_etherscan_api_key( &self, chain: Option<impl Into<Chain>> ) -> Option<String>
Helper function to just get the API key
sourcepub fn get_source_dir_remapping(&self) -> Option<Remapping>
pub fn get_source_dir_remapping(&self) -> Option<Remapping>
Returns the remapping for the project’s src directory
Note: this will add an additional <src>/=<src path> remapping here so imports that
look like import {Foo} from "src/Foo.sol"; are properly resolved.
This is due the fact that solc’s VFS resolves direct imports that start with the source directory’s name.
sourcepub fn get_test_dir_remapping(&self) -> Option<Remapping>
pub fn get_test_dir_remapping(&self) -> Option<Remapping>
Returns the remapping for the project’s test directory, but only if it exists
sourcepub fn get_script_dir_remapping(&self) -> Option<Remapping>
pub fn get_script_dir_remapping(&self) -> Option<Remapping>
Returns the remapping for the project’s script directory, but only if it exists
sourcepub fn configured_artifacts_handler(&self) -> ConfigurableArtifacts
pub fn configured_artifacts_handler(&self) -> ConfigurableArtifacts
returns the ethers_solc::ConfigurableArtifacts for this config, that includes the
extra_output fields
sourcepub fn parsed_libraries(&self) -> Result<Libraries, SolcError>
pub fn parsed_libraries(&self) -> Result<Libraries, SolcError>
Parses all libraries in the form of
<file>:<lib>:<addr>
sourcepub fn solc_settings(&self) -> Result<Settings, SolcError>
pub fn solc_settings(&self) -> Result<Settings, SolcError>
Returns the configured solc Settings that includes:
- all libraries
- the optimizer (including details, if configured)
- evm version
sourcepub fn figment() -> Figment
pub fn figment() -> Figment
Returns the default figment
The default figment reads from the following sources, in ascending priority order:
Config::default()(see defaults)foundry.tomlor filename inFOUNDRY_CONFIGenvironment variableFOUNDRY_prefixed environment variables
The profile selected is the value set in the FOUNDRY_PROFILE
environment variable. If it is not set, it defaults to default.
Example
use foundry_config::Config;
use serde::Deserialize;
let my_config = Config::figment().extract::<Config>();sourcepub fn figment_with_root(root: impl Into<PathBuf>) -> Figment
pub fn figment_with_root(root: impl Into<PathBuf>) -> Figment
Returns the default figment enhanced with additional context extracted from the provided root, like remappings and directories.
Example
use foundry_config::Config;
use serde::Deserialize;
let my_config = Config::figment_with_root(".").extract::<Config>();sourcepub fn with_root(root: impl Into<PathBuf>) -> Self
pub fn with_root(root: impl Into<PathBuf>) -> Self
Creates a new Config that adds additional context extracted from the provided root.
Example
use foundry_config::Config;
let my_config = Config::with_root(".");sourcepub fn into_basic(self) -> BasicConfig
pub fn into_basic(self) -> BasicConfig
Extracts a basic subset of the config, used for initialisations.
Example
use foundry_config::Config;
let my_config = Config::with_root(".").into_basic();sourcepub fn update_at<F>(root: impl Into<PathBuf>, f: F) -> Result<()>where
F: FnOnce(&Config, &mut Document) -> bool,
pub fn update_at<F>(root: impl Into<PathBuf>, f: F) -> Result<()>where F: FnOnce(&Config, &mut Document) -> bool,
Updates the foundry.toml file for the given root based on the provided closure.
Note: the closure will only be invoked if the foundry.toml file exists, See
Self::get_config_path() and if the closure returns true.
sourcepub fn update<F>(&self, f: F) -> Result<()>where
F: FnOnce(&mut Document) -> bool,
pub fn update<F>(&self, f: F) -> Result<()>where F: FnOnce(&mut Document) -> bool,
Updates the foundry.toml file this Config ias based on with the provided closure.
Note: the closure will only be invoked if the foundry.toml file exists, See
Self::get_config_path() and if the closure returns true
sourcepub fn update_libs(&self) -> Result<()>
pub fn update_libs(&self) -> Result<()>
Sets the libs entry inside a foundry.toml file but only if it exists
Errors
An error if the foundry.toml could not be parsed.
sourcepub fn to_string_pretty(&self) -> Result<String, Error>
pub fn to_string_pretty(&self) -> Result<String, Error>
Serialize the config type as a String of TOML.
This serializes to a table with the name of the profile
[profile.default]
src = "src"
out = "out"
libs = ["lib"]
# ...
sourcepub fn get_config_path(&self) -> PathBuf
pub fn get_config_path(&self) -> PathBuf
Returns the path to the foundry.toml of this Config
sourcepub fn selected_profile() -> Profile
pub fn selected_profile() -> Profile
Returns the selected profile
If the FOUNDRY_PROFILE env variable is not set, this returns the DEFAULT_PROFILE
sourcepub fn foundry_dir_toml() -> Option<PathBuf>
pub fn foundry_dir_toml() -> Option<PathBuf>
Returns the path to foundry’s global toml file that’s stored at ~/.foundry/foundry.toml
sourcepub fn foundry_dir() -> Option<PathBuf>
pub fn foundry_dir() -> Option<PathBuf>
Returns the path to foundry’s config dir ~/.foundry/
sourcepub fn foundry_cache_dir() -> Option<PathBuf>
pub fn foundry_cache_dir() -> Option<PathBuf>
Returns the path to foundry’s cache dir ~/.foundry/cache
sourcepub fn foundry_rpc_cache_dir() -> Option<PathBuf>
pub fn foundry_rpc_cache_dir() -> Option<PathBuf>
Returns the path to foundry rpc cache dir ~/.foundry/cache/rpc
sourcepub fn foundry_chain_cache_dir(chain_id: impl Into<Chain>) -> Option<PathBuf>
pub fn foundry_chain_cache_dir(chain_id: impl Into<Chain>) -> Option<PathBuf>
Returns the path to foundry chain’s cache dir ~/.foundry/cache/rpc/<chain>
sourcepub fn foundry_etherscan_cache_dir() -> Option<PathBuf>
pub fn foundry_etherscan_cache_dir() -> Option<PathBuf>
Returns the path to foundry’s etherscan cache dir ~/.foundry/cache/etherscan
sourcepub fn foundry_keystores_dir() -> Option<PathBuf>
pub fn foundry_keystores_dir() -> Option<PathBuf>
Returns the path to foundry’s keystores dir ~/.foundry/keystores
sourcepub fn foundry_etherscan_chain_cache_dir(
chain_id: impl Into<Chain>
) -> Option<PathBuf>
pub fn foundry_etherscan_chain_cache_dir( chain_id: impl Into<Chain> ) -> Option<PathBuf>
Returns the path to foundry’s etherscan cache dir for chain_id
~/.foundry/cache/etherscan/<chain>
sourcepub fn foundry_block_cache_dir(
chain_id: impl Into<Chain>,
block: u64
) -> Option<PathBuf>
pub fn foundry_block_cache_dir( chain_id: impl Into<Chain>, block: u64 ) -> Option<PathBuf>
Returns the path to the cache dir of the block on the chain
`~/.foundry/cache/rpc/
sourcepub fn foundry_block_cache_file(
chain_id: impl Into<Chain>,
block: u64
) -> Option<PathBuf>
pub fn foundry_block_cache_file( chain_id: impl Into<Chain>, block: u64 ) -> Option<PathBuf>
Returns the path to the cache file of the block on the chain
~/.foundry/cache/rpc/<chain>/<block>/storage.json
sourcepub fn data_dir() -> Result<PathBuf>
pub fn data_dir() -> Result<PathBuf>
Returns the path to foundry’s data directory inside the user’s data directory
|Platform | Value | Example |
| —–– | ———————————–– | –––––––––––––––– |
| Linux | $XDG_CONFIG_HOME or $HOME/.config/foundry | /home/alice/.config/foundry|
| macOS | $HOME/Library/Application Support/foundry | /Users/Alice/Library/Application Support/foundry |
| Windows | {FOLDERID_RoamingAppData}/foundry | C:\Users\Alice\AppData\Roaming/foundry |
sourcepub fn find_config_file() -> Option<PathBuf>
pub fn find_config_file() -> Option<PathBuf>
Returns the path to the foundry.toml file, the file is searched for in
the current working directory and all parent directories until the root,
and the first hit is used.
If this search comes up empty, then it checks if a global foundry.toml exists at
~/.foundry/foundry.tol, see Self::foundry_dir_toml()
sourcepub fn clean_foundry_cache() -> Result<()>
pub fn clean_foundry_cache() -> Result<()>
Clears the foundry cache
sourcepub fn clean_foundry_chain_cache(chain: Chain) -> Result<()>
pub fn clean_foundry_chain_cache(chain: Chain) -> Result<()>
Clears the foundry cache for chain
sourcepub fn clean_foundry_block_cache(chain: Chain, block: u64) -> Result<()>
pub fn clean_foundry_block_cache(chain: Chain, block: u64) -> Result<()>
Clears the foundry cache for chain and block
sourcepub fn clean_foundry_etherscan_cache() -> Result<()>
pub fn clean_foundry_etherscan_cache() -> Result<()>
Clears the foundry etherscan cache
sourcepub fn clean_foundry_etherscan_chain_cache(chain: Chain) -> Result<()>
pub fn clean_foundry_etherscan_chain_cache(chain: Chain) -> Result<()>
Clears the foundry etherscan cache for chain
sourcepub fn list_foundry_cache() -> Result<Cache>
pub fn list_foundry_cache() -> Result<Cache>
List the data in the foundry cache
sourcepub fn list_foundry_chain_cache(chain: Chain) -> Result<ChainCache>
pub fn list_foundry_chain_cache(chain: Chain) -> Result<ChainCache>
List the cached data for chain
Trait Implementations§
source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl PartialEq<Config> for Config
impl PartialEq<Config> for Config
source§impl Provider for Config
impl Provider for Config
impl StructuralPartialEq for Config
Auto Trait Implementations§
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where &'a Self: for<'a> IntoIterator,
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere Self: Borrow<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> Rwhere Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere Self: AsRef<U>, U: 'a + ?Sized, R: 'a,
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere Self: AsMut<U>, U: 'a + ?Sized, R: 'a,
self, then passes self.as_mut() into the pipe
function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere Self: Deref<Target = T>, T: ?Sized,
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere Self: DerefMut<Target = T> + Deref, T: ?Sized,
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere Self: Borrow<B>, B: ?Sized,
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere Self: BorrowMut<B>, B: ?Sized,
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere Self: AsRef<R>, R: ?Sized,
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere Self: AsMut<R>, R: ?Sized,
.tap_ref_mut() only in debug builds, and is erased in release
builds.