Skip to main content

Module contracts

Module contracts 

Source
Expand description

Commonly used contract types and functions.

Re-exportsΒ§

use crate::compile::PathOrContractInfo; πŸ”’
use crate::find_metadata_start; πŸ”’
use crate::strip_bytecode_placeholders; πŸ”’
use alloy_dyn_abi::JsonAbiExt; πŸ”’
use alloy_json_abi::Event; πŸ”’
use alloy_json_abi::Function; πŸ”’
use alloy_json_abi::JsonAbi; πŸ”’
use alloy_primitives::Address; πŸ”’
use alloy_primitives::B256; πŸ”’
use alloy_primitives::Bytes; πŸ”’
use alloy_primitives::Selector; πŸ”’
use alloy_primitives::address; πŸ”’
use alloy_primitives::hex; πŸ”’
use alloy_primitives::hex; πŸ”’
use eyre::OptionExt; πŸ”’
use eyre::Result; πŸ”’
use foundry_compilers::ArtifactId; πŸ”’
use foundry_compilers::Project; πŸ”’
use foundry_compilers::ProjectCompileOutput; πŸ”’
use foundry_compilers::artifacts::BytecodeObject; πŸ”’
use foundry_compilers::artifacts::CompactBytecode; πŸ”’
use foundry_compilers::artifacts::CompactContractBytecode; πŸ”’
use foundry_compilers::artifacts::CompactContractBytecodeCow; πŸ”’
use foundry_compilers::artifacts::CompactDeployedBytecode; πŸ”’
use foundry_compilers::artifacts::ConfigurableContractArtifact; πŸ”’
use foundry_compilers::artifacts::ContractBytecodeSome; πŸ”’
use foundry_compilers::artifacts::Offsets; πŸ”’
use foundry_compilers::artifacts::StorageLayout; πŸ”’
use foundry_compilers::utils::canonicalized; πŸ”’
use std::collections::BTreeMap; πŸ”’
use std::ops::Deref; πŸ”’
use std::path::Path; πŸ”’
use std::path::PathBuf; πŸ”’
use std::str::FromStr; πŸ”’
use std::sync::Arc; πŸ”’

StructsΒ§

BytecodeData
Subset of [CompactBytecode] excluding sourcemaps.
ContractData
Container for commonly used contract data.
ContractsByArtifact
Wrapper type that maps an artifact to a contract ABI and bytecode.
ContractsByArtifactBuilder
Builder for creating a ContractsByArtifact instance, optionally including storage layouts from project compile output.

ConstantsΒ§

CALL_PROTECTION_BYTECODE_PREFIX πŸ”’
Libraries’ runtime code always starts with the following instruction: PUSH20 0x0000000000000000000000000000000000000000
LIBRARY_DEPLOYER
Isolated account used to deploy libraries needed only while executing locally.

FunctionsΒ§

bytecode_diff_score
compact_to_contract
Helper function to convert CompactContractBytecode ~> ContractBytecodeSome
count_different_bytes πŸ”’ ⚠
Returns the amount of different bytes between two slices.
find_matching_contract_artifact
Returns the target artifact given the path and name.
find_target_path
Returns the canonicalized target path for the given identifier.
get_contract_name
Returns contract name for a given contract identifier.
get_file_name
This returns the file name part, See get_contract_name
matches_contract_creation
Very simple fuzzy matching of contract bytecode.
normalize_offsets πŸ”’
Sorts and merges overlapping or adjacent byte ranges.

Type AliasesΒ§

ArtifactWithContractRef πŸ”’
ContractsByAddress
Wrapper type that maps an address to a contract identifier and contract ABI.