Skip to main content

Module utils

Module utils 

Source

Re-exportsΒ§

use alloy_json_abi::JsonAbi; πŸ”’
use alloy_primitives::Address; πŸ”’
use alloy_primitives::U256; πŸ”’
use alloy_primitives::map::HashMap; πŸ”’
use alloy_provider::Network; πŸ”’
use alloy_provider::Provider; πŸ”’
use alloy_provider::RootProvider; πŸ”’
use alloy_provider::network::AnyNetwork; πŸ”’
use eyre::ContextCompat; πŸ”’
use eyre::Result; πŸ”’
use foundry_common::provider::ProviderBuilder; πŸ”’
use foundry_common::shell; πŸ”’
use foundry_config::Chain; πŸ”’
use foundry_config::Config; πŸ”’
use itertools::Itertools; πŸ”’
use path_slash::PathExt; πŸ”’
use regex::Regex; πŸ”’
use serde::de::DeserializeOwned; πŸ”’
use std::collections::BTreeMap; πŸ”’
use std::collections::BTreeSet; πŸ”’
use std::ffi::OsStr; πŸ”’
use std::ffi::OsString; πŸ”’
use std::path::Path; πŸ”’
use std::path::PathBuf; πŸ”’
use std::process::Command; πŸ”’
use std::process::Output; πŸ”’
use std::process::Stdio; πŸ”’
use std::str::FromStr; πŸ”’
use std::sync::LazyLock; πŸ”’
use std::sync::OnceLock; πŸ”’
use std::time::Duration; πŸ”’
use std::time::SystemTime; πŸ”’
use std::time::UNIX_EPOCH; πŸ”’
use tracing_subscriber::EnvFilter; πŸ”’
use tracing_subscriber::reload; πŸ”’
use tracing_subscriber::prelude::*; πŸ”’

ModulesΒ§

abi πŸ”’
allocator πŸ”’
Abstract global allocator implementation.
cmd πŸ”’
suggestions πŸ”’
Helper functions for suggesting alternative values for a possibly erroneous user input.
tempo πŸ”’
Tempo utilities: fee token parsing and named nonce lanes (2D nonces).

StructsΒ§

Git
ResolvedLane
Result of resolving a --tempo.lane <name> argument against a lanes file.
Submodule
Deserialized git submodule status lib/dep output.
SubmoduleCheckout
A submodule checkout inspected without changing its worktree or index.
Submodules
Deserialized git submodule status output.
TraceResult
A slimmed down return from the executor used for returning minimal trace + gas metering info

EnumsΒ§

SubmoduleCheckoutStatus
State of an inspected submodule checkout.

ConstantsΒ§

DEFAULT_LANES_FILE
Default name of the lanes file at the project root.
STATIC_FUZZ_SEED
Deterministic fuzzer seed used for gas snapshots and coverage reports.

StaticsΒ§

FILTER_RELOAD_HANDLE πŸ”’
Handle to reload the tracing EnvFilter at runtime.
SUBMODULE_STATUS_REGEX
Regex used to parse git submodule status output.

TraitsΒ§

CommandUtils
Useful extensions to std::process::Command.
FoundryPathExt
Useful extensions to std::path::Path.
LoadConfig
Helpers for loading configuration.

FunctionsΒ§

apply_gas_estimate_multiplier
Applies an optional percentage multiplier to a gas estimate.
cache_local_signatures
Traverse the artifacts in the project to generate local signatures and merge them into the cache file.
cache_signatures_from_abis
Traverses all files at folder_path, parses any JSON ABI files found, and caches their function/event/error signatures to the local signatures cache.
common_setup
Common setup for all CLI tools. Does not include tracing subscriber.
did_you_mean
Filters multiple strings from a given list of possible values which are similar to the passed in value v within a certain confidence by least confidence.
emit_warnings
enable_paint
Sets the default [yansi] color output condition.
ensure_clean_constructor
Returns error if constructor has arguments.
env_filter πŸ”’
eta_key
fetch_abi_from_etherscan
Fetches the ABI of a contract from Etherscan.
find_contract_artifacts
Given a Project’s output, finds the contract by path and name and returns its ABI, creation bytecode, and ArtifactId.
get_chain
get_provider
Returns a [RootProvider] instantiated using Config’s RPC settings.
get_provider_builder
Returns a ProviderBuilder instantiated using Config values.
has_batch_support
True if it supports broadcasting in batches.
has_different_gas_calc
True if the network calculates gas costs differently.
init_progress
install_crypto_provider
This force installs the default crypto provider.
load_config_from_provider
Loads and sanitizes Config from a provider and emits generated warnings.
load_dotenv
Loads dotenv files from the cwd and project root, deferring diagnostics until shell setup.
load_lanes
Loads a TOML lanes file from path.
maybe_print_resolved_lane
Prints lane: <name> (nonce_key=<key>, nonce=<n>) to stderr (so it doesn’t pollute stdout for commands like cast mktx whose stdout is meant to be piped), giving visibility into which 2D nonce lane was used.
needs_setup
new_allocator
Creates a new allocator.
new_allocator_wrapper
now
Returns the current time as a Duration since the Unix epoch.
parse_constructor_args
Parses constructor arguments by matching them against the constructor’s input parameters.
parse_delay
Parses a Duration from a &str
parse_ether_value
Parses an ether value from a string.
parse_fee_token_address
Parses a fee token address, numeric TIP-20 token id, or known Tempo fee-token symbol.
parse_fee_token_symbol
parse_function_args
parse_json
Parses a T from a string using serde_json::from_str.
parse_lanes
print_traces
read_constructor_args_file
Read contract constructor arguments from the given file.
resolve_lane
Resolves opts.lane against a lanes file and writes the resulting nonce_key to opts.nonce_key. Returns the resolved lane (or None if no --tempo.lane was set).
resolve_name_args
subscriber
Initializes a tracing Subscriber for logging.
token_id_to_address
update_tracing_filter
Replaces the active tracing EnvFilter at runtime.
validate_checkout_ref πŸ”’

Type AliasesΒ§

Allocator
AllocatorInner
AllocatorWrapper