From cd633dd930b45181e610245cf2e87f082ec576bf Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Fri, 15 Aug 2025 08:05:06 +0200 Subject: [PATCH 01/15] feat(cheats): add fork cheats to load array vars --- crates/cheatcodes/assets/cheatcodes.json | 280 +++++++++++++++++++++++ crates/cheatcodes/spec/src/vm.rs | 70 ++++++ crates/cheatcodes/src/fork.rs | 172 +++++++++++++- crates/forge/tests/cli/script.rs | 231 ++++++++++++++++++- testdata/cheats/Vm.sol | 14 ++ 5 files changed, 757 insertions(+), 10 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 4481f89c2ea0b..6b5f5220d0459 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5884,6 +5884,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkAddressArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `address`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkAddressArray(string calldata key) external view returns (address[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkAddressArray(string)", + "selector": "0x96ab7625", + "selectorBytes": [ + 150, + 171, + 118, + 37 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkBool", @@ -5904,6 +5924,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkBoolArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bool`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkBoolArray(string calldata key) external view returns (bool[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkBoolArray(string)", + "selector": "0x6b377ca3", + "selectorBytes": [ + 107, + 55, + 124, + 163 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkBytes", @@ -5944,6 +5984,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkBytes32Array", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes32`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkBytes32Array(string calldata key) external view returns (bytes32[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkBytes32Array(string)", + "selector": "0x53576e0e", + "selectorBytes": [ + 83, + 87, + 110, + 14 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "forkBytesArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkBytesArray(string calldata key) external view returns (bytes[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkBytesArray(string)", + "selector": "0x47366dc7", + "selectorBytes": [ + 71, + 54, + 109, + 199 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkChain", @@ -5984,6 +6064,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkChainAddressArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `address`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkChainAddressArray(uint256,string)", + "selector": "0x636939d6", + "selectorBytes": [ + 99, + 105, + 57, + 214 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkChainBool", @@ -6004,6 +6104,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkChainBoolArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bool`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkChainBoolArray(uint256,string)", + "selector": "0xfc681f31", + "selectorBytes": [ + 252, + 104, + 31, + 49 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkChainBytes", @@ -6044,6 +6164,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkChainBytes32Array", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes32`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkChainBytes32Array(uint256,string)", + "selector": "0x0a7d84ef", + "selectorBytes": [ + 10, + 125, + 132, + 239 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "forkChainBytesArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkChainBytesArray(uint256,string)", + "selector": "0x7703a689", + "selectorBytes": [ + 119, + 3, + 166, + 137 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkChainId", @@ -6104,6 +6264,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkChainIntArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `int256`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkChainIntArray(uint256,string)", + "selector": "0xf9e251a3", + "selectorBytes": [ + 249, + 226, + 81, + 163 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkChainRpcUrl", @@ -6144,6 +6324,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkChainStringArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `string`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkChainStringArray(uint256,string)", + "selector": "0x560ccdd6", + "selectorBytes": [ + 86, + 12, + 205, + 214 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkChainUint", @@ -6164,6 +6364,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkChainUintArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `uint256`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkChainUintArray(uint256,string)", + "selector": "0x2b231c56", + "selectorBytes": [ + 43, + 35, + 28, + 86 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkChains", @@ -6204,6 +6424,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkIntArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `int256`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkIntArray(string calldata key) external view returns (int256[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkIntArray(string)", + "selector": "0x2aab15bd", + "selectorBytes": [ + 42, + 171, + 21, + 189 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkRpcUrl", @@ -6244,6 +6484,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkStringArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `string`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkStringArray(string calldata key) external view returns (string[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkStringArray(string)", + "selector": "0xbdd9262c", + "selectorBytes": [ + 189, + 217, + 38, + 44 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "forkUint", @@ -6264,6 +6524,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "forkUintArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `uint256`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function forkUintArray(string calldata key) external view returns (uint256[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "forkUintArray(string)", + "selector": "0xdbe1236b", + "selectorBytes": [ + 219, + 225, + 35, + 107 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "foundryVersionAtLeast", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 3281596acac62..2c881e7a349a7 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2229,6 +2229,16 @@ interface Vm { #[cheatcode(group = Forking)] function forkChainBool(uint256 chain, string calldata key) external view returns (bool); + /// Gets the value for the key `key` from the currently active fork and parses it as an array of `bool`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkBoolArray(string calldata key) external view returns (bool[] memory); + + /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bool`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory); + /// Gets the value for the key `key` from the currently active fork and parses it as `int256`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] @@ -2239,6 +2249,16 @@ interface Vm { #[cheatcode(group = Forking)] function forkChainInt(uint256 chain, string calldata key) external view returns (int256); + /// Gets the value for the key `key` from the currently active fork and parses it as an array of `int256`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkIntArray(string calldata key) external view returns (int256[] memory); + + /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `int256`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory); + /// Gets the value for the key `key` from the currently active fork and parses it as `uint256`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] @@ -2249,6 +2269,16 @@ interface Vm { #[cheatcode(group = Forking)] function forkChainUint(uint256 chain, string calldata key) external view returns (uint256); + /// Gets the value for the key `key` from the currently active fork and parses it as an array of `uint256`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkUintArray(string calldata key) external view returns (uint256[] memory); + + /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `uint256`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory); + /// Gets the value for the key `key` from the currently active fork and parses it as `address`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] @@ -2259,6 +2289,16 @@ interface Vm { #[cheatcode(group = Forking)] function forkChainAddress(uint256 chain, string calldata key) external view returns (address); + /// Gets the value for the key `key` from the currently active fork and parses it as an array of `address`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkAddressArray(string calldata key) external view returns (address[] memory); + + /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `address`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory); + /// Gets the value for the key `key` from the currently active fork and parses it as `bytes32`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] @@ -2269,6 +2309,16 @@ interface Vm { #[cheatcode(group = Forking)] function forkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32); + /// Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes32`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkBytes32Array(string calldata key) external view returns (bytes32[] memory); + + /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes32`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory); + /// Gets the value for the key `key` from the currently active fork and parses it as `string`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] @@ -2279,6 +2329,16 @@ interface Vm { #[cheatcode(group = Forking)] function forkChainString(uint256 chain, string calldata key) external view returns (string memory); + /// Gets the value for the key `key` from the currently active fork and parses it as an array of `string`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkStringArray(string calldata key) external view returns (string[] memory); + + /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `string`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory); + /// Gets the value for the key `key` from the currently active fork and parses it as `bytes`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] @@ -2289,6 +2349,16 @@ interface Vm { #[cheatcode(group = Forking)] function forkChainBytes(uint256 chain, string calldata key) external view returns (bytes memory); + /// Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkBytesArray(string calldata key) external view returns (bytes[] memory); + + /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes`. + /// Reverts if a key was not found or any of the values could not be parsed. + #[cheatcode(group = Forking)] + function forkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory); + // ======== Scripts ======== // -------- Broadcasting Transactions -------- diff --git a/crates/cheatcodes/src/fork.rs b/crates/cheatcodes/src/fork.rs index 8c15218e3424d..050ffd85d5c66 100644 --- a/crates/cheatcodes/src/fork.rs +++ b/crates/cheatcodes/src/fork.rs @@ -1,7 +1,7 @@ //! Implementations of [`Forking`](spec::Group::Forking) cheatcodes. use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Error, Result, Vm::*, string}; -use alloy_dyn_abi::DynSolType; +use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_sol_types::SolValue; use eyre::OptionExt; use foundry_evm_core::ContextExt; @@ -123,6 +123,20 @@ impl Cheatcode for forkBoolCall { } } +impl Cheatcode for forkBoolArrayCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { key } = self; + get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::Bool, ccx.state) + } +} + +impl Cheatcode for forkChainBoolArrayCall { + fn apply(&self, state: &mut crate::Cheatcodes) -> Result { + let Self { chain, key } = self; + get_array(chain.to::(), key, &DynSolType::Bool, state) + } +} + impl Cheatcode for forkChainIntCall { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { let Self { chain, key } = self; @@ -137,6 +151,20 @@ impl Cheatcode for forkIntCall { } } +impl Cheatcode for forkIntArrayCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { key } = self; + get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::Int(256), ccx.state) + } +} + +impl Cheatcode for forkChainIntArrayCall { + fn apply(&self, state: &mut crate::Cheatcodes) -> Result { + let Self { chain, key } = self; + get_array(chain.to::(), key, &DynSolType::Int(256), state) + } +} + impl Cheatcode for forkChainUintCall { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { let Self { chain, key } = self; @@ -151,6 +179,20 @@ impl Cheatcode for forkUintCall { } } +impl Cheatcode for forkUintArrayCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { key } = self; + get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::Uint(256), ccx.state) + } +} + +impl Cheatcode for forkChainUintArrayCall { + fn apply(&self, state: &mut crate::Cheatcodes) -> Result { + let Self { chain, key } = self; + get_array(chain.to::(), key, &DynSolType::Uint(256), state) + } +} + impl Cheatcode for forkChainAddressCall { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { let Self { chain, key } = self; @@ -166,6 +208,20 @@ impl Cheatcode for forkAddressCall { } } +impl Cheatcode for forkAddressArrayCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { key } = self; + get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::Address, ccx.state) + } +} + +impl Cheatcode for forkChainAddressArrayCall { + fn apply(&self, state: &mut crate::Cheatcodes) -> Result { + let Self { chain, key } = self; + get_array(chain.to::(), key, &DynSolType::Address, state) + } +} + impl Cheatcode for forkChainBytes32Call { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { let Self { chain, key } = self; @@ -181,6 +237,20 @@ impl Cheatcode for forkBytes32Call { } } +impl Cheatcode for forkBytes32ArrayCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { key } = self; + get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::FixedBytes(32), ccx.state) + } +} + +impl Cheatcode for forkChainBytes32ArrayCall { + fn apply(&self, state: &mut crate::Cheatcodes) -> Result { + let Self { chain, key } = self; + get_array(chain.to::(), key, &DynSolType::FixedBytes(32), state) + } +} + impl Cheatcode for forkChainBytesCall { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { let Self { chain, key } = self; @@ -196,6 +266,20 @@ impl Cheatcode for forkBytesCall { } } +impl Cheatcode for forkBytesArrayCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { key } = self; + get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::Bytes, ccx.state) + } +} + +impl Cheatcode for forkChainBytesArrayCall { + fn apply(&self, state: &mut crate::Cheatcodes) -> Result { + let Self { chain, key } = self; + get_array(chain.to::(), key, &DynSolType::Bytes, state) + } +} + impl Cheatcode for forkChainStringCall { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { let Self { chain, key } = self; @@ -211,6 +295,20 @@ impl Cheatcode for forkStringCall { } } +impl Cheatcode for forkStringArrayCall { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { key } = self; + get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::String, ccx.state) + } +} + +impl Cheatcode for forkChainStringArrayCall { + fn apply(&self, state: &mut crate::Cheatcodes) -> Result { + let Self { chain, key } = self; + get_array(chain.to::(), key, &DynSolType::String, state) + } +} + fn get_toml_value<'a>( name: &'a str, key: &'a str, @@ -286,3 +384,75 @@ fn get_type_from_str_input( bail!("Variable '{key}' in [fork.{name}] must be a string"); } } + +fn get_array(chain: u64, key: &str, element_ty: &DynSolType, state: &crate::Cheatcodes) -> Result { + let name = get_chain_name(chain)?; + let value = get_toml_value(name, key, state)?; + + if let Some(arr) = value.as_array() { + let mut result = Vec::new(); + for (i, elem) in arr.iter().enumerate() { + let parsed = match element_ty { + DynSolType::Bool => { + if let Some(b) = elem.as_bool() { + DynSolValue::Bool(b) + } else if let Some(v) = elem.as_integer() { + DynSolValue::Bool(v != 0) + } else if let Some(s) = elem.as_str() { + string::parse_value(s, element_ty) + .map_err(map_env_err(&format!("{key}[{i}]"), s))? + } else { + bail!( + "Element {i} of '{key}' in [fork.{name}] must be a boolean or a string" + ); + } + } + DynSolType::Int(256) => { + if let Some(int_value) = elem.as_integer() { + DynSolValue::Int(alloy_primitives::I256::try_from(int_value).unwrap(), 256) + } else if let Some(s) = elem.as_str() { + string::parse_value(s, element_ty) + .map_err(map_env_err(&format!("{key}[{i}]"), s))? + } else { + bail!( + "Element {i} of '{key}' in [fork.{name}] must be an integer or a string" + ); + } + } + DynSolType::Uint(256) => { + if let Some(int_value) = elem.as_integer() { + if int_value >= 0 { + DynSolValue::Uint(alloy_primitives::U256::from(int_value as u64), 256) + } else { + bail!("Element {i} of '{key}' in [fork.{name}] is a negative integer"); + } + } else if let Some(s) = elem.as_str() { + string::parse_value(s, element_ty) + .map_err(map_env_err(&format!("{key}[{i}]"), s))? + } else { + bail!( + "Element {i} of '{key}' in [fork.{name}] must be an integer or a string" + ); + } + } + DynSolType::Address + | DynSolType::FixedBytes(32) + | DynSolType::String + | DynSolType::Bytes => { + if let Some(s) = elem.as_str() { + string::parse_value(s, element_ty) + .map_err(map_env_err(&format!("{key}[{i}]"), s))? + } else { + bail!("Element {i} of '{key}' in [fork.{name}] must be a string"); + } + } + _ => bail!("Unsupported array element type for fork configuration"), + }; + result.push(parsed); + } + + Ok(DynSolValue::Array(result).abi_encode()) + } else { + bail!("Variable '{key}' in [fork.{name}] must be an array"); + } +} diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 29f274b5190eb..268efc53f64c2 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2614,13 +2614,13 @@ Chain 31337 accessList [] chainId 31337 gasLimit [..] -gasPrice +gasPrice input [..] -maxFeePerBlobGas -maxFeePerGas -maxPriorityFeePerGas +maxFeePerBlobGas +maxFeePerGas +maxPriorityFeePerGas nonce 0 -to +to type 0 value 0 @@ -2629,11 +2629,11 @@ value 0 accessList [] chainId 31337 gasLimit 93856 -gasPrice +gasPrice input 0x7357f5d2000000000000000000000000000000000000000000000000000000000000007b00000000000000000000000000000000000000000000000000000000000001c8 -maxFeePerBlobGas -maxFeePerGas -maxPriorityFeePerGas +maxFeePerBlobGas +maxFeePerGas +maxPriorityFeePerGas nonce 1 to 0x5FbDB2315678afecb367f032d93F642f64180aa3 type 0 @@ -3259,6 +3259,20 @@ forgetest_init!(can_access_fork_config_chain_ids, |prj, cmd| { ("addr".into(), "0xdeadbeef00000000000000000000000000000000".into()), ("bytes".into(), "0x00000000000f00".into()), ("str".into(), "bar".into()), + // Array configurations for testing new array cheatcodes + ("bool_array".into(), vec![true, false, true].into()), + ("int_array".into(), vec!["-100", "200", "-300"].into()), + ("uint_array".into(), vec!["100", "200", "300"].into()), + ("addr_array".into(), vec![ + "0x1111111111111111111111111111111111111111", + "0x2222222222222222222222222222222222222222" + ].into()), + ("bytes32_array".into(), vec![ + "0x1111111111111111111111111111111111111111111111111111111111111111", + "0x2222222222222222222222222222222222222222222222222222222222222222" + ].into()), + ("bytes_array".into(), vec!["0x1234", "0x5678", "0xabcd"].into()), + ("string_array".into(), vec!["hello", "world", "test"].into()), ] .into_iter() .collect(), @@ -3280,6 +3294,20 @@ forgetest_init!(can_access_fork_config_chain_ids, |prj, cmd| { ("addr".into(), "0x00000000000000000000000000000000deadbeef".into()), ("bytes".into(), "0x00f00000000000".into()), ("str".into(), "bazz".into()), + // Array configurations for testing new array cheatcodes + ("bool_array".into(), vec![false, true, false].into()), + ("int_array".into(), vec!["-400", "500", "-600"].into()), + ("uint_array".into(), vec!["400", "500", "600"].into()), + ("addr_array".into(), vec![ + "0x3333333333333333333333333333333333333333", + "0x4444444444444444444444444444444444444444" + ].into()), + ("bytes32_array".into(), vec![ + "0x3333333333333333333333333333333333333333333333333333333333333333", + "0x4444444444444444444444444444444444444444444444444444444444444444" + ].into()), + ("bytes_array".into(), vec!["0xdead", "0xbeef", "0xcafe"].into()), + ("string_array".into(), vec!["foo", "bar", "baz"].into()), ] .into_iter() .collect(), @@ -3337,6 +3365,50 @@ contract ForkScript is DSTest { || b256 == 0x000000000000000000000000000000000000000000000000000000deadc0ffee ); } + + // Test array cheatcodes in a separate function to avoid stack too deep + testArrayCheatcodes(); + } + + function testArrayCheatcodes() public view { + (uint256[2] memory chainIds, string[2] memory chains) = ([uint256(1), uint256(10)], ["mainnet", "optimism"]); + + for (uint256 i = 0; i < chains.length; i++) { + console.log("Testing arrays for chain:", chains[i]); + + // Test bool array + bool[] memory boolArray = vm.forkChainBoolArray(chainIds[i], "bool_array"); + assert(boolArray.length == 3); + console.log(" > bool_array[0]:", boolArray[0]); + + // Test int array + int256[] memory intArray = vm.forkChainIntArray(chainIds[i], "int_array"); + assert(intArray.length == 3); + console.log(" > int_array[0]:", intArray[0]); + + // Test uint array + uint256[] memory uintArray = vm.forkChainUintArray(chainIds[i], "uint_array"); + assert(uintArray.length == 3); + console.log(" > uint_array[0]:", uintArray[0]); + + // Test address array + address[] memory addrArray = vm.forkChainAddressArray(chainIds[i], "addr_array"); + assert(addrArray.length == 2); + console.log(" > addr_array[0]:", addrArray[0]); + + // Test bytes32 array + bytes32[] memory bytes32Array = vm.forkChainBytes32Array(chainIds[i], "bytes32_array"); + assert(bytes32Array.length == 2); + + // Test bytes array + bytes[] memory bytesArray = vm.forkChainBytesArray(chainIds[i], "bytes_array"); + assert(bytesArray.length == 3); + + // Test string array + string[] memory stringArray = vm.forkChainStringArray(chainIds[i], "string_array"); + assert(stringArray.length == 3); + console.log(" > string_array[0]:", stringArray[0]); + } } function eqString(string memory s1, string memory s2) public pure returns(bool) { @@ -3367,6 +3439,18 @@ contract ForkScript is DSTest { > bool: false > addr: 0x00000000000000000000000000000000DeaDBeef > string: bazz + Testing arrays for chain: mainnet + > bool_array[0]: true + > int_array[0]: -100 + > uint_array[0]: 100 + > addr_array[0]: 0x1111111111111111111111111111111111111111 + > string_array[0]: hello + Testing arrays for chain: optimism + > bool_array[0]: false + > int_array[0]: -400 + > uint_array[0]: 400 + > addr_array[0]: 0x3333333333333333333333333333333333333333 + > string_array[0]: foo "#]]); }); @@ -3398,6 +3482,20 @@ forgetest_init!(can_derive_chain_id_access_fork_config, |prj, cmd| { ("addr".into(), "0xdeadbeef00000000000000000000000000000000".into()), ("bytes".into(), "0x00000000000f00".into()), ("str".into(), "bar".into()), + // Array configurations for testing new array cheatcodes + ("bool_array".into(), vec![true, false, true].into()), + ("int_array".into(), vec!["-100", "200", "-300"].into()), + ("uint_array".into(), vec!["100", "200", "300"].into()), + ("addr_array".into(), vec![ + "0x1111111111111111111111111111111111111111", + "0x2222222222222222222222222222222222222222" + ].into()), + ("bytes32_array".into(), vec![ + "0x1111111111111111111111111111111111111111111111111111111111111111", + "0x2222222222222222222222222222222222222222222222222222222222222222" + ].into()), + ("bytes_array".into(), vec!["0x1234", "0x5678", "0xabcd"].into()), + ("string_array".into(), vec!["hello", "world", "test"].into()), ] .into_iter() .collect(), @@ -3419,6 +3517,20 @@ forgetest_init!(can_derive_chain_id_access_fork_config, |prj, cmd| { ("addr".into(), "0x00000000000000000000000000000000deadbeef".into()), ("bytes".into(), "0x00f00000000000".into()), ("str".into(), "bazz".into()), + // Array configurations for testing new array cheatcodes + ("bool_array".into(), vec![false, true, false].into()), + ("int_array".into(), vec!["-400", "500", "-600"].into()), + ("uint_array".into(), vec!["400", "500", "600"].into()), + ("addr_array".into(), vec![ + "0x3333333333333333333333333333333333333333", + "0x4444444444444444444444444444444444444444" + ].into()), + ("bytes32_array".into(), vec![ + "0x3333333333333333333333333333333333333333333333333333333333333333", + "0x4444444444444444444444444444444444444444444444444444444444444444" + ].into()), + ("bytes_array".into(), vec!["0xdead", "0xbeef", "0xcafe"].into()), + ("string_array".into(), vec!["foo", "bar", "baz"].into()), ] .into_iter() .collect(), @@ -3474,6 +3586,52 @@ contract ForkTest is DSTest { b256 == 0xdeadbeaf00000000000000000000000000000000000000000000000000000000 || b256 == 0x000000000000000000000000000000000000000000000000000000deadc0ffee ); + + // Test array cheatcodes in a separate function to avoid stack too deep + testArrayCheatcodes(); + } + + function testArrayCheatcodes() public { + // Test array cheatcodes without specifying chain (uses active fork) + console.log(" > Arrays:"); + + // Test bool array + bool[] memory boolArray = vm.forkBoolArray("bool_array"); + assert(boolArray.length == 3); + assert(boolArray[0] == true); + console.log(" > bool_array[0]:", boolArray[0]); + + // Test int array + int256[] memory intArray = vm.forkIntArray("int_array"); + assert(intArray.length == 3); + assert(intArray[0] == -100); + console.log(" > int_array[0]:", intArray[0]); + + // Test uint array + uint256[] memory uintArray = vm.forkUintArray("uint_array"); + assert(uintArray.length == 3); + assert(uintArray[0] == 100); + console.log(" > uint_array[0]:", uintArray[0]); + + // Test address array + address[] memory addrArray = vm.forkAddressArray("addr_array"); + assert(addrArray.length == 2); + assert(addrArray[0] == 0x1111111111111111111111111111111111111111); + console.log(" > addr_array[0]:", addrArray[0]); + + // Test bytes32 array + bytes32[] memory bytes32Array = vm.forkBytes32Array("bytes32_array"); + assert(bytes32Array.length == 2); + + // Test bytes array + bytes[] memory bytesArray = vm.forkBytesArray("bytes_array"); + assert(bytesArray.length == 3); + + // Test string array + string[] memory stringArray = vm.forkStringArray("string_array"); + assert(stringArray.length == 3); + assert(eqString(stringArray[0], "hello")); + console.log(" > string_array[0]:", stringArray[0]); } function eqString(string memory s1, string memory s2) public pure returns(bool) { @@ -3497,8 +3655,63 @@ Logs: > bool: true > addr: 0xdEADBEeF00000000000000000000000000000000 > string: bar + > Arrays: + > bool_array[0]: true + > int_array[0]: -100 + > uint_array[0]: 100 + > addr_array[0]: 0x1111111111111111111111111111111111111111 + > string_array[0]: hello [FAIL: vm.forkChain: a fork must be selected] test_panicsWhithoutSelectedFork() ([GAS]) ... "#]]); }); + +// Tests that it will throw an error when reading an address that is not 20 bytes +forgetest_init!(throws_error_when_reading_invalid_address, |prj, cmd| { + prj.insert_vm(); + prj.insert_console(); + prj.insert_ds_test(); + let mainnet_endpoint = rpc::next_http_rpc_endpoint(); + + prj.update_config(|config| { + config.forks = vec![( + "mainnet".to_string(), + ForkConfig { + rpc_endpoint: Some(RpcEndpoint::new(RpcEndpointUrl::Url(mainnet_endpoint.clone()))), + vars: vec![("owner".into(), "0xdeadbeef".into())].into_iter().collect(), + }, + )] + .into_iter() + .collect(); + }); + + prj.add_source( + "ForkTest.t.sol", + &r#" +import {Vm} from "./Vm.sol"; +import {DSTest} from "./test.sol"; +import {console} from "./console.sol"; + +contract ForkTest is DSTest { + Vm vm = Vm(HEVM_ADDRESS); + + function test_throwsErrorWhen() public { + vm.createSelectFork(""); + address owner = vm.forkAddress("owner"); + } +} + "# + .replace("", &mainnet_endpoint), + ) + .unwrap(); + + cmd.args(["test", "ForkTest"]).assert_failure().stdout_eq(str![[r#" +... +[FAIL: vm.forkAddress: failed parsing $owner as type `address`: parser error: +$owner +^ +invalid string length] test_throwsErrorWhen() ([GAS]) +... +"#]]); +}); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 69428698fb607..0426d391297c7 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -287,25 +287,39 @@ interface Vm { function fee(uint256 newBasefee) external; function ffi(string[] calldata commandInput) external returns (bytes memory result); function forkAddress(string calldata key) external view returns (address); + function forkAddressArray(string calldata key) external view returns (address[] memory); function forkBool(string calldata key) external view returns (bool); + function forkBoolArray(string calldata key) external view returns (bool[] memory); function forkBytes(string calldata key) external view returns (bytes memory); function forkBytes32(string calldata key) external view returns (bytes32); + function forkBytes32Array(string calldata key) external view returns (bytes32[] memory); + function forkBytesArray(string calldata key) external view returns (bytes[] memory); function forkChain() external view returns (string memory); function forkChainAddress(uint256 chain, string calldata key) external view returns (address); + function forkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory); function forkChainBool(uint256 chain, string calldata key) external view returns (bool); + function forkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory); function forkChainBytes(uint256 chain, string calldata key) external view returns (bytes memory); function forkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32); + function forkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory); + function forkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory); function forkChainId() external view returns (uint256); function forkChainIds() external view returns (uint256[] memory); function forkChainInt(uint256 chain, string calldata key) external view returns (int256); + function forkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory); function forkChainRpcUrl(uint256 id) external view returns (string memory); function forkChainString(uint256 chain, string calldata key) external view returns (string memory); + function forkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory); function forkChainUint(uint256 chain, string calldata key) external view returns (uint256); + function forkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory); function forkChains() external view returns (string[] memory); function forkInt(string calldata key) external view returns (int256); + function forkIntArray(string calldata key) external view returns (int256[] memory); function forkRpcUrl() external view returns (string memory); function forkString(string calldata key) external view returns (string memory); + function forkStringArray(string calldata key) external view returns (string[] memory); function forkUint(string calldata key) external view returns (uint256); + function forkUintArray(string calldata key) external view returns (uint256[] memory); function foundryVersionAtLeast(string calldata version) external view returns (bool); function foundryVersionCmp(string calldata version) external view returns (int256); function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); From fda1b89af423d58946c22a3b0a89ea5467521c5d Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Fri, 15 Aug 2025 08:19:36 +0200 Subject: [PATCH 02/15] add more tests --- crates/config/src/lib.rs | 59 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index d5f5511234919..7e276c26759bb 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -5175,6 +5175,21 @@ mod tests { pool_name = "USDC-ETH" pool_fee = 3000 max_slippage = 500 + + # Array configurations for testing array support + bool_array = [true, false, true] + int_array = [-100, 200, -300] + uint_array = [100, 200, 300] + addr_array = [ + "0x1111111111111111111111111111111111111111", + "0x2222222222222222222222222222222222222222" + ] + bytes32_array = [ + "0x1111111111111111111111111111111111111111111111111111111111111111", + "0x2222222222222222222222222222222222222222222222222222222222222222" + ] + bytes_array = ["0x1234", "0x5678", "0xabcd"] + string_array = ["hello", "world", "test"] "#, )?; let config = Config::load().unwrap(); @@ -5191,6 +5206,19 @@ mod tests { ("pool_name".into(), "USDC-ETH".into()), ("pool_fee".into(), 3000.into()), ("max_slippage".into(), 500.into()), + ("bool_array".into(), vec![true, false, true].into()), + ("int_array".into(), vec![-100i64, 200, -300].into()), + ("uint_array".into(), vec![100i64, 200, 300].into()), + ("addr_array".into(), vec![ + "0x1111111111111111111111111111111111111111", + "0x2222222222222222222222222222222222222222" + ].into()), + ("bytes32_array".into(), vec![ + "0x1111111111111111111111111111111111111111111111111111111111111111", + "0x2222222222222222222222222222222222222222222222222222222222222222" + ].into()), + ("bytes_array".into(), vec!["0x1234", "0x5678", "0xabcd"].into()), + ("string_array".into(), vec!["hello", "world", "test"].into()), ] .into_iter() .collect(), @@ -5209,6 +5237,37 @@ mod tests { for (k, v) in &expected_mainnet.vars { assert_eq!(v, mainnet.vars.get(k).unwrap()); } + + // Verify array values are properly loaded + let bool_array = mainnet.vars.get("bool_array").unwrap(); + assert!(bool_array.as_array().is_some()); + assert_eq!(bool_array.as_array().unwrap().len(), 3); + + let int_array = mainnet.vars.get("int_array").unwrap(); + assert!(int_array.as_array().is_some()); + assert_eq!(int_array.as_array().unwrap().len(), 3); + + let uint_array = mainnet.vars.get("uint_array").unwrap(); + assert!(uint_array.as_array().is_some()); + assert_eq!(uint_array.as_array().unwrap().len(), 3); + + let addr_array = mainnet.vars.get("addr_array").unwrap(); + assert!(addr_array.as_array().is_some()); + assert_eq!(addr_array.as_array().unwrap().len(), 2); + + let bytes32_array = mainnet.vars.get("bytes32_array").unwrap(); + assert!(bytes32_array.as_array().is_some()); + assert_eq!(bytes32_array.as_array().unwrap().len(), 2); + + let bytes_array = mainnet.vars.get("bytes_array").unwrap(); + assert!(bytes_array.as_array().is_some()); + assert_eq!(bytes_array.as_array().unwrap().len(), 3); + + let string_array = mainnet.vars.get("string_array").unwrap(); + assert!(string_array.as_array().is_some()); + assert_eq!(string_array.as_array().unwrap().len(), 3); + assert_eq!(string_array.as_array().unwrap()[0].as_str().unwrap(), "hello"); + Ok(()) }); } From 83e83eee758dd790c6a9132a45a738d757f2da44 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Fri, 15 Aug 2025 15:29:57 +0200 Subject: [PATCH 03/15] refactor to reduce duplicate code --- crates/cheatcodes/src/fork.rs | 471 +++++++++++----------------------- 1 file changed, 151 insertions(+), 320 deletions(-) diff --git a/crates/cheatcodes/src/fork.rs b/crates/cheatcodes/src/fork.rs index 050ffd85d5c66..af41e5c86da94 100644 --- a/crates/cheatcodes/src/fork.rs +++ b/crates/cheatcodes/src/fork.rs @@ -67,10 +67,6 @@ impl Cheatcode for forkRpcUrlCall { } } -fn cast_string(key: &str, val: &str, ty: &DynSolType) -> Result { - string::parse(val, ty).map_err(map_env_err(key, val)) -} - /// Converts the error message of a failed parsing attempt to a more user-friendly message that /// doesn't leak the value. fn map_env_err<'a>(key: &'a str, value: &'a str) -> impl FnOnce(Error) -> Error + 'a { @@ -109,205 +105,84 @@ fn get_active_fork_chain_name(ccx: &mut CheatsCtxt) -> Result<&'static str> { get_chain_name(get_active_fork_chain_id(ccx)?) } -impl Cheatcode for forkChainBoolCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_bool(chain.to::(), key, state) - } -} - -impl Cheatcode for forkBoolCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - get_bool(get_active_fork_chain_id(ccx)?, key, ccx.state) - } -} - -impl Cheatcode for forkBoolArrayCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::Bool, ccx.state) - } -} - -impl Cheatcode for forkChainBoolArrayCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_array(chain.to::(), key, &DynSolType::Bool, state) - } -} - -impl Cheatcode for forkChainIntCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_int256(chain.to::(), key, state) - } -} - -impl Cheatcode for forkIntCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - get_int256(get_active_fork_chain_id(ccx)?, key, ccx.state) - } -} - -impl Cheatcode for forkIntArrayCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::Int(256), ccx.state) - } -} - -impl Cheatcode for forkChainIntArrayCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_array(chain.to::(), key, &DynSolType::Int(256), state) - } -} - -impl Cheatcode for forkChainUintCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_uint256(chain.to::(), key, state) - } -} - -impl Cheatcode for forkUintCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - get_uint256(get_active_fork_chain_id(ccx)?, key, ccx.state) - } -} - -impl Cheatcode for forkUintArrayCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::Uint(256), ccx.state) - } -} - -impl Cheatcode for forkChainUintArrayCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_array(chain.to::(), key, &DynSolType::Uint(256), state) - } -} - -impl Cheatcode for forkChainAddressCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_type_from_str_input(chain.to::(), key, &DynSolType::Address, state) - } -} - -impl Cheatcode for forkAddressCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - let chain = get_active_fork_chain_id(ccx)?; - get_type_from_str_input(chain, key, &DynSolType::Address, ccx.state) - } -} - -impl Cheatcode for forkAddressArrayCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::Address, ccx.state) - } -} - -impl Cheatcode for forkChainAddressArrayCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_array(chain.to::(), key, &DynSolType::Address, state) - } -} - -impl Cheatcode for forkChainBytes32Call { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_type_from_str_input(chain.to::(), key, &DynSolType::FixedBytes(32), state) - } -} - -impl Cheatcode for forkBytes32Call { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - let chain = get_active_fork_chain_id(ccx)?; - get_type_from_str_input(chain, key, &DynSolType::FixedBytes(32), ccx.state) - } -} - -impl Cheatcode for forkBytes32ArrayCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::FixedBytes(32), ccx.state) - } -} - -impl Cheatcode for forkChainBytes32ArrayCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_array(chain.to::(), key, &DynSolType::FixedBytes(32), state) - } -} - -impl Cheatcode for forkChainBytesCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_type_from_str_input(chain.to::(), key, &DynSolType::Bytes, state) - } -} - -impl Cheatcode for forkBytesCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - let chain = get_active_fork_chain_id(ccx)?; - get_type_from_str_input(chain, key, &DynSolType::Bytes, ccx.state) - } -} - -impl Cheatcode for forkBytesArrayCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::Bytes, ccx.state) - } -} - -impl Cheatcode for forkChainBytesArrayCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_array(chain.to::(), key, &DynSolType::Bytes, state) - } -} - -impl Cheatcode for forkChainStringCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_type_from_str_input(chain.to::(), key, &DynSolType::String, state) - } -} - -impl Cheatcode for forkStringCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - let chain = get_active_fork_chain_id(ccx)?; - get_type_from_str_input(chain, key, &DynSolType::String, ccx.state) - } -} - -impl Cheatcode for forkStringArrayCall { - fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { - let Self { key } = self; - get_array(get_active_fork_chain_id(ccx)?, key, &DynSolType::String, ccx.state) - } +// Helper macros to generate cheatcode implementations +macro_rules! impl_get_value_cheatcode { + ($struct:ident, $sol_type:expr,stateful) => { + impl Cheatcode for $struct { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let chain = get_active_fork_chain_id(ccx)?; + get_value(chain, &self.key, $sol_type, ccx.state) + } + } + }; + ($struct:ident, $sol_type:expr) => { + impl Cheatcode for $struct { + fn apply(&self, state: &mut crate::Cheatcodes) -> Result { + get_value(self.chain.to::(), &self.key, $sol_type, state) + } + } + }; } -impl Cheatcode for forkChainStringArrayCall { - fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - let Self { chain, key } = self; - get_array(chain.to::(), key, &DynSolType::String, state) - } -} +macro_rules! impl_get_array_cheatcode { + ($struct:ident, $sol_type:expr,stateful) => { + impl Cheatcode for $struct { + fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let chain = get_active_fork_chain_id(ccx)?; + get_array(chain, &self.key, $sol_type, ccx.state) + } + } + }; + ($struct:ident, $sol_type:expr) => { + impl Cheatcode for $struct { + fn apply(&self, state: &mut crate::Cheatcodes) -> Result { + get_array(self.chain.to::(), &self.key, $sol_type, state) + } + } + }; +} + +// Bool +impl_get_value_cheatcode!(forkChainBoolCall, &DynSolType::Bool); +impl_get_value_cheatcode!(forkBoolCall, &DynSolType::Bool, stateful); +impl_get_array_cheatcode!(forkChainBoolArrayCall, &DynSolType::Bool); +impl_get_array_cheatcode!(forkBoolArrayCall, &DynSolType::Bool, stateful); + +// Int +impl_get_value_cheatcode!(forkChainIntCall, &DynSolType::Int(256)); +impl_get_value_cheatcode!(forkIntCall, &DynSolType::Int(256), stateful); +impl_get_array_cheatcode!(forkChainIntArrayCall, &DynSolType::Int(256)); +impl_get_array_cheatcode!(forkIntArrayCall, &DynSolType::Int(256), stateful); + +// Uint +impl_get_value_cheatcode!(forkChainUintCall, &DynSolType::Uint(256)); +impl_get_value_cheatcode!(forkUintCall, &DynSolType::Uint(256), stateful); +impl_get_array_cheatcode!(forkChainUintArrayCall, &DynSolType::Uint(256)); +impl_get_array_cheatcode!(forkUintArrayCall, &DynSolType::Uint(256), stateful); + +// Address +impl_get_value_cheatcode!(forkChainAddressCall, &DynSolType::Address); +impl_get_value_cheatcode!(forkAddressCall, &DynSolType::Address, stateful); +impl_get_array_cheatcode!(forkChainAddressArrayCall, &DynSolType::Address); +impl_get_array_cheatcode!(forkAddressArrayCall, &DynSolType::Address, stateful); + +// Bytes32 +impl_get_value_cheatcode!(forkChainBytes32Call, &DynSolType::FixedBytes(32)); +impl_get_value_cheatcode!(forkBytes32Call, &DynSolType::FixedBytes(32), stateful); +impl_get_array_cheatcode!(forkChainBytes32ArrayCall, &DynSolType::FixedBytes(32)); +impl_get_array_cheatcode!(forkBytes32ArrayCall, &DynSolType::FixedBytes(32), stateful); + +// Bytes +impl_get_value_cheatcode!(forkChainBytesCall, &DynSolType::Bytes); +impl_get_value_cheatcode!(forkBytesCall, &DynSolType::Bytes, stateful); +impl_get_array_cheatcode!(forkChainBytesArrayCall, &DynSolType::Bytes); +impl_get_array_cheatcode!(forkBytesArrayCall, &DynSolType::Bytes, stateful); + +// String +impl_get_value_cheatcode!(forkChainStringCall, &DynSolType::String); +impl_get_value_cheatcode!(forkStringCall, &DynSolType::String, stateful); +impl_get_array_cheatcode!(forkChainStringArrayCall, &DynSolType::String); +impl_get_array_cheatcode!(forkStringArrayCall, &DynSolType::String, stateful); fn get_toml_value<'a>( name: &'a str, @@ -325,134 +200,90 @@ fn get_toml_value<'a>( Ok(value) } -fn get_bool(chain: u64, key: &str, state: &crate::Cheatcodes) -> Result { - let name = get_chain_name(chain)?; - let value = get_toml_value(name, key, state)?; - - if let Some(b) = value.as_bool() { - Ok(b.abi_encode()) - } else if let Some(v) = value.as_integer() { - Ok((v == 0).abi_encode()) - } else if let Some(s) = value.as_str() { - cast_string(key, s, &DynSolType::Bool) - } else { - bail!("Variable '{key}' in [fork.{name}] must be a boolean or a string"); - } -} - -fn get_int256(chain: u64, key: &str, state: &crate::Cheatcodes) -> Result { +/// Generic helper to get any single value from the TOML config. +/// This replaces get_bool, get_int256, get_uint256, and get_type_from_str_input. +fn get_value(chain: u64, key: &str, ty: &DynSolType, state: &crate::Cheatcodes) -> Result { let name = get_chain_name(chain)?; let value = get_toml_value(name, key, state)?; - if let Some(int_value) = value.as_integer() { - Ok(int_value.abi_encode()) - } else if let Some(s) = value.as_str() { - cast_string(key, s, &DynSolType::Int(256)) - } else { - bail!("Variable '{key}' in [fork.{name}] must be an integer or a string"); - } -} - -fn get_uint256(chain: u64, key: &str, state: &crate::Cheatcodes) -> Result { - let name = get_chain_name(chain)?; - let value = get_toml_value(name, key, state)?; - - if let Some(int_value) = value.as_integer() { - if int_value >= 0 { - Ok((int_value as u64).abi_encode()) - } else { - bail!("Variable '{key}' in [fork.{name}] is a negative integer"); - } - } else if let Some(s) = value.as_str() { - cast_string(key, s, &DynSolType::Uint(256)) - } else { - bail!("Variable '{key}' in [fork.{name}] must be an integer or a string"); - } -} - -fn get_type_from_str_input( - chain: u64, - key: &str, - ty: &DynSolType, - state: &crate::Cheatcodes, -) -> Result { - let name = get_chain_name(chain)?; - let value = get_toml_value(name, key, state)?; - - if let Some(val) = value.as_str() { - cast_string(key, val, ty) - } else { - bail!("Variable '{key}' in [fork.{name}] must be a string"); - } + let sol_value = parse_toml_element(value, ty, key, name)?; + Ok(sol_value.abi_encode()) } +/// Generic helper to get an array of values from the TOML config. fn get_array(chain: u64, key: &str, element_ty: &DynSolType, state: &crate::Cheatcodes) -> Result { let name = get_chain_name(chain)?; let value = get_toml_value(name, key, state)?; - if let Some(arr) = value.as_array() { - let mut result = Vec::new(); - for (i, elem) in arr.iter().enumerate() { - let parsed = match element_ty { - DynSolType::Bool => { - if let Some(b) = elem.as_bool() { - DynSolValue::Bool(b) - } else if let Some(v) = elem.as_integer() { - DynSolValue::Bool(v != 0) - } else if let Some(s) = elem.as_str() { - string::parse_value(s, element_ty) - .map_err(map_env_err(&format!("{key}[{i}]"), s))? - } else { - bail!( - "Element {i} of '{key}' in [fork.{name}] must be a boolean or a string" - ); - } - } - DynSolType::Int(256) => { - if let Some(int_value) = elem.as_integer() { - DynSolValue::Int(alloy_primitives::I256::try_from(int_value).unwrap(), 256) - } else if let Some(s) = elem.as_str() { - string::parse_value(s, element_ty) - .map_err(map_env_err(&format!("{key}[{i}]"), s))? - } else { - bail!( - "Element {i} of '{key}' in [fork.{name}] must be an integer or a string" - ); - } - } - DynSolType::Uint(256) => { - if let Some(int_value) = elem.as_integer() { - if int_value >= 0 { - DynSolValue::Uint(alloy_primitives::U256::from(int_value as u64), 256) - } else { - bail!("Element {i} of '{key}' in [fork.{name}] is a negative integer"); - } - } else if let Some(s) = elem.as_str() { - string::parse_value(s, element_ty) - .map_err(map_env_err(&format!("{key}[{i}]"), s))? - } else { - bail!( - "Element {i} of '{key}' in [fork.{name}] must be an integer or a string" - ); - } - } - DynSolType::Address - | DynSolType::FixedBytes(32) - | DynSolType::String - | DynSolType::Bytes => { - if let Some(s) = elem.as_str() { - string::parse_value(s, element_ty) - .map_err(map_env_err(&format!("{key}[{i}]"), s))? - } else { - bail!("Element {i} of '{key}' in [fork.{name}] must be a string"); - } + let arr = value + .as_array() + .ok_or_else(|| fmt_err!("Variable '{key}' in [fork.{name}] must be an array"))?; + + let result: Result> = arr + .iter() + .enumerate() + .map(|(i, elem)| { + let context = format!("{key}[{i}]"); + parse_toml_element(elem, element_ty, &context, name) + }) + .collect(); + + Ok(DynSolValue::Array(result?).abi_encode()) +} + +/// Parses a single TOML value into a specific Solidity type. +fn parse_toml_element<'a>( + elem: &'a toml::Value, + element_ty: &DynSolType, + context: &str, + fork_name: &str, +) -> Result { + match element_ty { + DynSolType::Bool => { + if let Some(b) = elem.as_bool() { + Ok(DynSolValue::Bool(b)) + } else if let Some(v) = elem.as_integer() { + Ok(DynSolValue::Bool(v != 0)) + } else if let Some(s) = elem.as_str() { + string::parse_value(s, element_ty).map_err(map_env_err(context, s)) + } else { + bail!( + "Element '{context}' in [fork.{fork_name}] must be a boolean, integer, or a string" + ) + } + } + DynSolType::Int(256) => { + if let Some(int_value) = elem.as_integer() { + Ok(DynSolValue::Int(alloy_primitives::I256::try_from(int_value).unwrap(), 256)) + } else if let Some(s) = elem.as_str() { + string::parse_value(s, element_ty).map_err(map_env_err(context, s)) + } else { + bail!("Element '{context}' in [fork.{fork_name}] must be an integer or a string") + } + } + DynSolType::Uint(256) => { + if let Some(int_value) = elem.as_integer() { + if int_value < 0 { + bail!( + "Element '{context}' in [fork.{fork_name}] is a negative integer but expected an unsigned integer" + ); } - _ => bail!("Unsupported array element type for fork configuration"), - }; - result.push(parsed); + Ok(DynSolValue::Uint(alloy_primitives::U256::from(int_value as u64), 256)) + } else if let Some(s) = elem.as_str() { + string::parse_value(s, element_ty).map_err(map_env_err(context, s)) + } else { + bail!("Element '{context}' in [fork.{fork_name}] must be an integer or a string") + } } - - Ok(DynSolValue::Array(result).abi_encode()) - } else { - bail!("Variable '{key}' in [fork.{name}] must be an array"); + DynSolType::Address + | DynSolType::FixedBytes(32) + | DynSolType::String + | DynSolType::Bytes => { + if let Some(s) = elem.as_str() { + string::parse_value(s, element_ty).map_err(map_env_err(context, s)) + } else { + bail!("Element '{context}' in [fork.{fork_name}] must be a string"); + } + } + _ => bail!("Unsupported array element type for fork configuration: {element_ty:?}"), } } From 3acf9e1ebee793ad8fcb8d13f8255596fb7c0694 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com> Date: Fri, 15 Aug 2025 15:32:31 +0200 Subject: [PATCH 04/15] fix: test spacing From d0c121aacc8467ce9829e638027e8a36c0e37a37 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Fri, 15 Aug 2025 15:36:44 +0200 Subject: [PATCH 05/15] style: clippy --- crates/cheatcodes/src/fork.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/cheatcodes/src/fork.rs b/crates/cheatcodes/src/fork.rs index af41e5c86da94..9aa20979c62d4 100644 --- a/crates/cheatcodes/src/fork.rs +++ b/crates/cheatcodes/src/fork.rs @@ -184,6 +184,7 @@ impl_get_value_cheatcode!(forkStringCall, &DynSolType::String, stateful); impl_get_array_cheatcode!(forkChainStringArrayCall, &DynSolType::String); impl_get_array_cheatcode!(forkStringArrayCall, &DynSolType::String, stateful); +/// Generic helper to get any value from the TOML config. fn get_toml_value<'a>( name: &'a str, key: &'a str, @@ -201,7 +202,6 @@ fn get_toml_value<'a>( } /// Generic helper to get any single value from the TOML config. -/// This replaces get_bool, get_int256, get_uint256, and get_type_from_str_input. fn get_value(chain: u64, key: &str, ty: &DynSolType, state: &crate::Cheatcodes) -> Result { let name = get_chain_name(chain)?; let value = get_toml_value(name, key, state)?; @@ -231,8 +231,8 @@ fn get_array(chain: u64, key: &str, element_ty: &DynSolType, state: &crate::Chea } /// Parses a single TOML value into a specific Solidity type. -fn parse_toml_element<'a>( - elem: &'a toml::Value, +fn parse_toml_element( + elem: &toml::Value, element_ty: &DynSolType, context: &str, fork_name: &str, From 32bbd7609b018da5eb76854c2bc9e6f1513e9345 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com> Date: Fri, 15 Aug 2025 15:57:31 +0200 Subject: [PATCH 06/15] fix: test spacing --- crates/forge/tests/cli/script.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 268efc53f64c2..8bb6d8a6e7861 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2614,13 +2614,13 @@ Chain 31337 accessList [] chainId 31337 gasLimit [..] -gasPrice +gasPrice input [..] -maxFeePerBlobGas -maxFeePerGas -maxPriorityFeePerGas +maxFeePerBlobGas +maxFeePerGas +maxPriorityFeePerGas nonce 0 -to +to type 0 value 0 @@ -2629,11 +2629,11 @@ value 0 accessList [] chainId 31337 gasLimit 93856 -gasPrice +gasPrice input 0x7357f5d2000000000000000000000000000000000000000000000000000000000000007b00000000000000000000000000000000000000000000000000000000000001c8 -maxFeePerBlobGas -maxFeePerGas -maxPriorityFeePerGas +maxFeePerBlobGas +maxFeePerGas +maxPriorityFeePerGas nonce 1 to 0x5FbDB2315678afecb367f032d93F642f64180aa3 type 0 From d2cf99a37fb74ce2ebd5abce14d74a91958d9f62 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Fri, 15 Aug 2025 17:05:21 +0200 Subject: [PATCH 07/15] style: rename to `readFork..` --- crates/cheatcodes/assets/cheatcodes.json | 3702 ++++++++--------- .../cheatcodes/assets/cheatcodes.schema.json | 2 +- crates/cheatcodes/spec/src/cheatcode.rs | 2 +- crates/cheatcodes/spec/src/vm.rs | 56 +- crates/cheatcodes/src/fork.rs | 56 +- crates/forge/tests/cli/script.rs | 60 +- testdata/cheats/Vm.sol | 56 +- 7 files changed, 1967 insertions(+), 1967 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index 6b5f5220d0459..fa8d2f0a22083 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5866,18 +5866,18 @@ }, { "func": { - "id": "forkAddress", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `address`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkAddress(string calldata key) external view returns (address);", + "id": "forkChain", + "description": "Returns the chain name of the currently selected fork.", + "declaration": "function forkChain() external view returns (string memory);", "visibility": "external", "mutability": "view", - "signature": "forkAddress(string)", - "selector": "0x27b1efc0", + "signature": "forkChain()", + "selector": "0xe6075d94", "selectorBytes": [ - 39, - 177, - 239, - 192 + 230, + 7, + 93, + 148 ] }, "group": "forking", @@ -5886,18 +5886,18 @@ }, { "func": { - "id": "forkAddressArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `address`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkAddressArray(string calldata key) external view returns (address[] memory);", + "id": "forkChainId", + "description": "Returns the chain id of the currently selected fork.", + "declaration": "function forkChainId() external view returns (uint256);", "visibility": "external", "mutability": "view", - "signature": "forkAddressArray(string)", - "selector": "0x96ab7625", + "signature": "forkChainId()", + "selector": "0xe6b661e2", "selectorBytes": [ - 150, - 171, - 118, - 37 + 230, + 182, + 97, + 226 ] }, "group": "forking", @@ -5906,18 +5906,18 @@ }, { "func": { - "id": "forkBool", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `bool`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkBool(string calldata key) external view returns (bool);", + "id": "forkChainIds", + "description": "Returns an array with the ids of all the configured fork chains.\nNote that the configured fork chains are subsections of the `[fork]` section of 'foundry.toml'.", + "declaration": "function forkChainIds() external view returns (uint256[] memory);", "visibility": "external", "mutability": "view", - "signature": "forkBool(string)", - "selector": "0xc06e85dd", + "signature": "forkChainIds()", + "selector": "0x04dc8feb", "selectorBytes": [ - 192, - 110, - 133, - 221 + 4, + 220, + 143, + 235 ] }, "group": "forking", @@ -5926,18 +5926,18 @@ }, { "func": { - "id": "forkBoolArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bool`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkBoolArray(string calldata key) external view returns (bool[] memory);", + "id": "forkChainRpcUrl", + "description": "Returns the rpc url of the corresponding chain id.\nBy default, the rpc url of each fork is derived from the `[rpc_endpoints]`, unless\nthe rpc config is specifically informed in the fork config for that specific chain.", + "declaration": "function forkChainRpcUrl(uint256 id) external view returns (string memory);", "visibility": "external", "mutability": "view", - "signature": "forkBoolArray(string)", - "selector": "0x6b377ca3", + "signature": "forkChainRpcUrl(uint256)", + "selector": "0xa2c51cca", "selectorBytes": [ - 107, - 55, - 124, - 163 + 162, + 197, + 28, + 202 ] }, "group": "forking", @@ -5946,18 +5946,18 @@ }, { "func": { - "id": "forkBytes", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `bytes`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkBytes(string calldata key) external view returns (bytes memory);", + "id": "forkChains", + "description": "Returns an array with the name of all the configured fork chains.\nNote that the configured fork chains are subsections of the `[fork]` section of 'foundry.toml'.", + "declaration": "function forkChains() external view returns (string[] memory);", "visibility": "external", "mutability": "view", - "signature": "forkBytes(string)", - "selector": "0x7c055631", + "signature": "forkChains()", + "selector": "0x081f64cd", "selectorBytes": [ - 124, - 5, - 86, - 49 + 8, + 31, + 100, + 205 ] }, "group": "forking", @@ -5966,18 +5966,18 @@ }, { "func": { - "id": "forkBytes32", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `bytes32`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkBytes32(string calldata key) external view returns (bytes32);", + "id": "forkRpcUrl", + "description": "Returns the rpc url of the currently selected fork.\nBy default, the rpc url of each fork is derived from the `[rpc_endpoints]`, unless\nthe rpc config is specifically informed in the fork config for that specific chain.", + "declaration": "function forkRpcUrl() external view returns (string memory);", "visibility": "external", "mutability": "view", - "signature": "forkBytes32(string)", - "selector": "0xa912a3f4", + "signature": "forkRpcUrl()", + "selector": "0x66d48d21", "selectorBytes": [ - 169, - 18, - 163, - 244 + 102, + 212, + 141, + 33 ] }, "group": "forking", @@ -5986,758 +5986,738 @@ }, { "func": { - "id": "forkBytes32Array", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes32`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkBytes32Array(string calldata key) external view returns (bytes32[] memory);", + "id": "foundryVersionAtLeast", + "description": "Returns true if the current Foundry version is greater than or equal to the given version.\nThe given version string must be in the format `major.minor.patch`.\nThis is equivalent to `foundryVersionCmp(version) >= 0`.", + "declaration": "function foundryVersionAtLeast(string calldata version) external view returns (bool);", "visibility": "external", "mutability": "view", - "signature": "forkBytes32Array(string)", - "selector": "0x53576e0e", + "signature": "foundryVersionAtLeast(string)", + "selector": "0x6248be1f", "selectorBytes": [ - 83, - 87, - 110, - 14 + 98, + 72, + 190, + 31 ] }, - "group": "forking", + "group": "testing", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkBytesArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkBytesArray(string calldata key) external view returns (bytes[] memory);", + "id": "foundryVersionCmp", + "description": "Compares the current Foundry version with the given version string.\nThe given version string must be in the format `major.minor.patch`.\nReturns:\n-1 if current Foundry version is less than the given version\n0 if current Foundry version equals the given version\n1 if current Foundry version is greater than the given version\nThis result can then be used with a comparison operator against `0`.\nFor example, to check if the current Foundry version is greater than or equal to `1.0.0`:\n`if (foundryVersionCmp(\"1.0.0\") >= 0) { ... }`", + "declaration": "function foundryVersionCmp(string calldata version) external view returns (int256);", "visibility": "external", "mutability": "view", - "signature": "forkBytesArray(string)", - "selector": "0x47366dc7", + "signature": "foundryVersionCmp(string)", + "selector": "0xca7b0a09", "selectorBytes": [ - 71, - 54, - 109, - 199 + 202, + 123, + 10, + 9 ] }, - "group": "forking", + "group": "testing", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChain", - "description": "Returns the chain name of the currently selected fork.", - "declaration": "function forkChain() external view returns (string memory);", + "id": "fsMetadata", + "description": "Given a path, query the file system to get information about a file, directory, etc.", + "declaration": "function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);", "visibility": "external", "mutability": "view", - "signature": "forkChain()", - "selector": "0xe6075d94", + "signature": "fsMetadata(string)", + "selector": "0xaf368a08", "selectorBytes": [ - 230, - 7, - 93, - 148 + 175, + 54, + 138, + 8 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainAddress", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `address`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkChainAddress(uint256 chain, string calldata key) external view returns (address);", + "id": "getArtifactPathByCode", + "description": "Gets the artifact path from code (aka. creation code).", + "declaration": "function getArtifactPathByCode(bytes calldata code) external view returns (string memory path);", "visibility": "external", "mutability": "view", - "signature": "forkChainAddress(uint256,string)", - "selector": "0x5dc00a35", + "signature": "getArtifactPathByCode(bytes)", + "selector": "0xeb74848c", "selectorBytes": [ - 93, - 192, - 10, - 53 + 235, + 116, + 132, + 140 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainAddressArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `address`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory);", + "id": "getArtifactPathByDeployedCode", + "description": "Gets the artifact path from deployed code (aka. runtime code).", + "declaration": "function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path);", "visibility": "external", "mutability": "view", - "signature": "forkChainAddressArray(uint256,string)", - "selector": "0x636939d6", + "signature": "getArtifactPathByDeployedCode(bytes)", + "selector": "0x6d853ba5", "selectorBytes": [ - 99, - 105, - 57, - 214 + 109, + 133, + 59, + 165 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainBool", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bool`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkChainBool(uint256 chain, string calldata key) external view returns (bool);", + "id": "getBlobBaseFee", + "description": "Gets the current `block.blobbasefee`.\nYou should use this instead of `block.blobbasefee` if you use `vm.blobBaseFee`, as `block.blobbasefee` is assumed to be constant across a transaction,\nand as a result will get optimized out by the compiler.\nSee https://github.com/foundry-rs/foundry/issues/6180", + "declaration": "function getBlobBaseFee() external view returns (uint256 blobBaseFee);", "visibility": "external", "mutability": "view", - "signature": "forkChainBool(uint256,string)", - "selector": "0x8f947e16", + "signature": "getBlobBaseFee()", + "selector": "0x1f6d6ef7", "selectorBytes": [ - 143, - 148, - 126, - 22 + 31, + 109, + 110, + 247 ] }, - "group": "forking", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainBoolArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bool`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory);", + "id": "getBlobhashes", + "description": "Gets the blockhashes from the current transaction.\nNot available on EVM versions before Cancun.\nIf used on unsupported EVM versions it will revert.", + "declaration": "function getBlobhashes() external view returns (bytes32[] memory hashes);", "visibility": "external", "mutability": "view", - "signature": "forkChainBoolArray(uint256,string)", - "selector": "0xfc681f31", + "signature": "getBlobhashes()", + "selector": "0xf56ff18b", "selectorBytes": [ - 252, - 104, - 31, - 49 + 245, + 111, + 241, + 139 ] }, - "group": "forking", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "forkChainBytes", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bytes`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkChainBytes(uint256 chain, string calldata key) external view returns (bytes memory);", + "id": "getBlockNumber", + "description": "Gets the current `block.number`.\nYou should use this instead of `block.number` if you use `vm.roll`, as `block.number` is assumed to be constant across a transaction,\nand as a result will get optimized out by the compiler.\nSee https://github.com/foundry-rs/foundry/issues/6180", + "declaration": "function getBlockNumber() external view returns (uint256 height);", "visibility": "external", "mutability": "view", - "signature": "forkChainBytes(uint256,string)", - "selector": "0x0e73256d", + "signature": "getBlockNumber()", + "selector": "0x42cbb15c", "selectorBytes": [ - 14, - 115, - 37, - 109 + 66, + 203, + 177, + 92 ] }, - "group": "forking", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainBytes32", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bytes32`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32);", + "id": "getBlockTimestamp", + "description": "Gets the current `block.timestamp`.\nYou should use this instead of `block.timestamp` if you use `vm.warp`, as `block.timestamp` is assumed to be constant across a transaction,\nand as a result will get optimized out by the compiler.\nSee https://github.com/foundry-rs/foundry/issues/6180", + "declaration": "function getBlockTimestamp() external view returns (uint256 timestamp);", "visibility": "external", "mutability": "view", - "signature": "forkChainBytes32(uint256,string)", - "selector": "0x05dd6d07", + "signature": "getBlockTimestamp()", + "selector": "0x796b89b9", "selectorBytes": [ - 5, - 221, - 109, - 7 + 121, + 107, + 137, + 185 ] }, - "group": "forking", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainBytes32Array", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes32`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory);", + "id": "getBroadcast", + "description": "Returns the most recent broadcast for the given contract on `chainId` matching `txType`.\nFor example:\nThe most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`.\nThe most recent call can be fetched by passing `txType` as `CALL`.", + "declaration": "function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory);", "visibility": "external", "mutability": "view", - "signature": "forkChainBytes32Array(uint256,string)", - "selector": "0x0a7d84ef", + "signature": "getBroadcast(string,uint64,uint8)", + "selector": "0x3dc90cb3", "selectorBytes": [ - 10, - 125, - 132, - 239 + 61, + 201, + 12, + 179 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainBytesArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory);", + "id": "getBroadcasts_0", + "description": "Returns all broadcasts for the given contract on `chainId` with the specified `txType`.\nSorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.", + "declaration": "function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory);", "visibility": "external", "mutability": "view", - "signature": "forkChainBytesArray(uint256,string)", - "selector": "0x7703a689", + "signature": "getBroadcasts(string,uint64,uint8)", + "selector": "0xf7afe919", "selectorBytes": [ - 119, - 3, - 166, - 137 + 247, + 175, + 233, + 25 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainId", - "description": "Returns the chain id of the currently selected fork.", - "declaration": "function forkChainId() external view returns (uint256);", + "id": "getBroadcasts_1", + "description": "Returns all broadcasts for the given contract on `chainId`.\nSorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.", + "declaration": "function getBroadcasts(string calldata contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory);", "visibility": "external", "mutability": "view", - "signature": "forkChainId()", - "selector": "0xe6b661e2", + "signature": "getBroadcasts(string,uint64)", + "selector": "0xf2fa4a26", "selectorBytes": [ - 230, - 182, - 97, - 226 + 242, + 250, + 74, + 38 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainIds", - "description": "Returns an array with the ids of all the configured fork chains.\nNote that the configured fork chains are subsections of the `[fork]` section of 'foundry.toml'.", - "declaration": "function forkChainIds() external view returns (uint256[] memory);", + "id": "getChain_0", + "description": "Returns a Chain struct for specific alias", + "declaration": "function getChain(string calldata chainAlias) external view returns (Chain memory chain);", "visibility": "external", "mutability": "view", - "signature": "forkChainIds()", - "selector": "0x04dc8feb", + "signature": "getChain(string)", + "selector": "0x4cc1c2bb", "selectorBytes": [ - 4, - 220, - 143, - 235 + 76, + 193, + 194, + 187 ] }, - "group": "forking", + "group": "testing", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainInt", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `int256`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkChainInt(uint256 chain, string calldata key) external view returns (int256);", + "id": "getChain_1", + "description": "Returns a Chain struct for specific chainId", + "declaration": "function getChain(uint256 chainId) external view returns (Chain memory chain);", "visibility": "external", "mutability": "view", - "signature": "forkChainInt(uint256,string)", - "selector": "0xc1ff595f", + "signature": "getChain(uint256)", + "selector": "0xb6791ad4", "selectorBytes": [ - 193, - 255, - 89, - 95 + 182, + 121, + 26, + 212 ] }, - "group": "forking", + "group": "testing", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainIntArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `int256`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory);", + "id": "getCode", + "description": "Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the\nartifact in the form of :: where and parts are optional.", + "declaration": "function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);", "visibility": "external", "mutability": "view", - "signature": "forkChainIntArray(uint256,string)", - "selector": "0xf9e251a3", + "signature": "getCode(string)", + "selector": "0x8d1cc925", "selectorBytes": [ - 249, - 226, - 81, - 163 + 141, + 28, + 201, + 37 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainRpcUrl", - "description": "Returns the rpc url of the corresponding chain id.\nBy default, the rpc url of each fork is derived from the `[rpc_endpoints]`, unless\nthe rpc config is specifically informed in the fork config for that specific chain.", - "declaration": "function forkChainRpcUrl(uint256 id) external view returns (string memory);", + "id": "getDeployedCode", + "description": "Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the\nartifact in the form of :: where and parts are optional.", + "declaration": "function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);", "visibility": "external", "mutability": "view", - "signature": "forkChainRpcUrl(uint256)", - "selector": "0xa2c51cca", + "signature": "getDeployedCode(string)", + "selector": "0x3ebf73b4", "selectorBytes": [ - 162, - 197, - 28, - 202 + 62, + 191, + 115, + 180 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainString", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `string`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkChainString(uint256 chain, string calldata key) external view returns (string memory);", + "id": "getDeployment_0", + "description": "Returns the most recent deployment for the current `chainId`.", + "declaration": "function getDeployment(string calldata contractName) external view returns (address deployedAddress);", "visibility": "external", "mutability": "view", - "signature": "forkChainString(uint256,string)", - "selector": "0x24062881", + "signature": "getDeployment(string)", + "selector": "0xa8091d97", "selectorBytes": [ - 36, - 6, - 40, - 129 + 168, + 9, + 29, + 151 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainStringArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `string`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory);", + "id": "getDeployment_1", + "description": "Returns the most recent deployment for the given contract on `chainId`", + "declaration": "function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress);", "visibility": "external", "mutability": "view", - "signature": "forkChainStringArray(uint256,string)", - "selector": "0x560ccdd6", + "signature": "getDeployment(string,uint64)", + "selector": "0x0debd5d6", "selectorBytes": [ - 86, - 12, - 205, + 13, + 235, + 213, 214 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainUint", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `uint256`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkChainUint(uint256 chain, string calldata key) external view returns (uint256);", + "id": "getDeployments", + "description": "Returns all deployments for the given contract on `chainId`\nSorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.\nThe most recent deployment is the first element, and the oldest is the last.", + "declaration": "function getDeployments(string calldata contractName, uint64 chainId) external view returns (address[] memory deployedAddresses);", "visibility": "external", "mutability": "view", - "signature": "forkChainUint(uint256,string)", - "selector": "0x2bfffa5c", + "signature": "getDeployments(string,uint64)", + "selector": "0x74e133dd", "selectorBytes": [ - 43, - 255, - 250, - 92 + 116, + 225, + 51, + 221 ] }, - "group": "forking", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChainUintArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `uint256`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory);", + "id": "getFoundryVersion", + "description": "Returns the Foundry version.\nFormat: -+..\nSample output: 0.3.0-nightly+3cb96bde9b.1737036656.debug\nNote: Build timestamps may vary slightly across platforms due to separate CI jobs.\nFor reliable version comparisons, use UNIX format (e.g., >= 1700000000)\nto compare timestamps while ignoring minor time differences.", + "declaration": "function getFoundryVersion() external view returns (string memory version);", "visibility": "external", "mutability": "view", - "signature": "forkChainUintArray(uint256,string)", - "selector": "0x2b231c56", + "signature": "getFoundryVersion()", + "selector": "0xea991bb5", "selectorBytes": [ - 43, - 35, - 28, - 86 + 234, + 153, + 27, + 181 ] }, - "group": "forking", + "group": "testing", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkChains", - "description": "Returns an array with the name of all the configured fork chains.\nNote that the configured fork chains are subsections of the `[fork]` section of 'foundry.toml'.", - "declaration": "function forkChains() external view returns (string[] memory);", + "id": "getLabel", + "description": "Gets the label for the specified address.", + "declaration": "function getLabel(address account) external view returns (string memory currentLabel);", "visibility": "external", "mutability": "view", - "signature": "forkChains()", - "selector": "0x081f64cd", + "signature": "getLabel(address)", + "selector": "0x28a249b0", "selectorBytes": [ - 8, - 31, - 100, - 205 + 40, + 162, + 73, + 176 ] }, - "group": "forking", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkInt", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `int256`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkInt(string calldata key) external view returns (int256);", + "id": "getMappingKeyAndParentOf", + "description": "Gets the map key and parent of a mapping at a given slot, for a given address.", + "declaration": "function getMappingKeyAndParentOf(address target, bytes32 elementSlot) external returns (bool found, bytes32 key, bytes32 parent);", "visibility": "external", - "mutability": "view", - "signature": "forkInt(string)", - "selector": "0x4b326af0", + "mutability": "", + "signature": "getMappingKeyAndParentOf(address,bytes32)", + "selector": "0x876e24e6", "selectorBytes": [ - 75, - 50, - 106, - 240 + 135, + 110, + 36, + 230 ] }, - "group": "forking", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkIntArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `int256`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkIntArray(string calldata key) external view returns (int256[] memory);", + "id": "getMappingLength", + "description": "Gets the number of elements in the mapping at the given slot, for a given address.", + "declaration": "function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);", "visibility": "external", - "mutability": "view", - "signature": "forkIntArray(string)", - "selector": "0x2aab15bd", + "mutability": "", + "signature": "getMappingLength(address,bytes32)", + "selector": "0x2f2fd63f", "selectorBytes": [ - 42, - 171, - 21, - 189 + 47, + 47, + 214, + 63 ] }, - "group": "forking", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkRpcUrl", - "description": "Returns the rpc url of the currently selected fork.\nBy default, the rpc url of each fork is derived from the `[rpc_endpoints]`, unless\nthe rpc config is specifically informed in the fork config for that specific chain.", - "declaration": "function forkRpcUrl() external view returns (string memory);", + "id": "getMappingSlotAt", + "description": "Gets the elements at index idx of the mapping at the given slot, for a given address. The\nindex must be less than the length of the mapping (i.e. the number of keys in the mapping).", + "declaration": "function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);", "visibility": "external", - "mutability": "view", - "signature": "forkRpcUrl()", - "selector": "0x66d48d21", + "mutability": "", + "signature": "getMappingSlotAt(address,bytes32,uint256)", + "selector": "0xebc73ab4", "selectorBytes": [ - 102, - 212, - 141, - 33 + 235, + 199, + 58, + 180 ] }, - "group": "forking", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkString", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `string`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkString(string calldata key) external view returns (string memory);", + "id": "getNonce_0", + "description": "Gets the nonce of an account.", + "declaration": "function getNonce(address account) external view returns (uint64 nonce);", "visibility": "external", "mutability": "view", - "signature": "forkString(string)", - "selector": "0xd8525752", + "signature": "getNonce(address)", + "selector": "0x2d0335ab", "selectorBytes": [ - 216, - 82, - 87, - 82 + 45, + 3, + 53, + 171 ] }, - "group": "forking", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkStringArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `string`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkStringArray(string calldata key) external view returns (string[] memory);", + "id": "getNonce_1", + "description": "Get the nonce of a `Wallet`.", + "declaration": "function getNonce(Wallet calldata wallet) external returns (uint64 nonce);", "visibility": "external", - "mutability": "view", - "signature": "forkStringArray(string)", - "selector": "0xbdd9262c", + "mutability": "", + "signature": "getNonce((address,uint256,uint256,uint256))", + "selector": "0xa5748aad", "selectorBytes": [ - 189, - 217, - 38, - 44 + 165, + 116, + 138, + 173 ] }, - "group": "forking", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkUint", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `uint256`.\nReverts if the key was not found or the value could not be parsed.", - "declaration": "function forkUint(string calldata key) external view returns (uint256);", + "id": "getRawBlockHeader", + "description": "Gets the RLP encoded block header for a given block number.\nReturns the block header in the same format as `cast block --raw`.", + "declaration": "function getRawBlockHeader(uint256 blockNumber) external view returns (bytes memory rlpHeader);", "visibility": "external", "mutability": "view", - "signature": "forkUint(string)", - "selector": "0xbe0fe4a8", + "signature": "getRawBlockHeader(uint256)", + "selector": "0x2c667606", "selectorBytes": [ - 190, - 15, - 228, - 168 + 44, + 102, + 118, + 6 ] }, - "group": "forking", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "forkUintArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `uint256`.\nReverts if a key was not found or any of the values could not be parsed.", - "declaration": "function forkUintArray(string calldata key) external view returns (uint256[] memory);", + "id": "getRecordedLogs", + "description": "Gets all the recorded logs.", + "declaration": "function getRecordedLogs() external returns (Log[] memory logs);", "visibility": "external", - "mutability": "view", - "signature": "forkUintArray(string)", - "selector": "0xdbe1236b", + "mutability": "", + "signature": "getRecordedLogs()", + "selector": "0x191553a4", "selectorBytes": [ - 219, - 225, - 35, - 107 + 25, + 21, + 83, + 164 ] }, - "group": "forking", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "foundryVersionAtLeast", - "description": "Returns true if the current Foundry version is greater than or equal to the given version.\nThe given version string must be in the format `major.minor.patch`.\nThis is equivalent to `foundryVersionCmp(version) >= 0`.", - "declaration": "function foundryVersionAtLeast(string calldata version) external view returns (bool);", + "id": "getStateDiff", + "description": "Returns state diffs from current `vm.startStateDiffRecording` session.", + "declaration": "function getStateDiff() external view returns (string memory diff);", "visibility": "external", "mutability": "view", - "signature": "foundryVersionAtLeast(string)", - "selector": "0x6248be1f", + "signature": "getStateDiff()", + "selector": "0x80df01cc", "selectorBytes": [ - 98, - 72, - 190, - 31 + 128, + 223, + 1, + 204 ] }, - "group": "testing", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "foundryVersionCmp", - "description": "Compares the current Foundry version with the given version string.\nThe given version string must be in the format `major.minor.patch`.\nReturns:\n-1 if current Foundry version is less than the given version\n0 if current Foundry version equals the given version\n1 if current Foundry version is greater than the given version\nThis result can then be used with a comparison operator against `0`.\nFor example, to check if the current Foundry version is greater than or equal to `1.0.0`:\n`if (foundryVersionCmp(\"1.0.0\") >= 0) { ... }`", - "declaration": "function foundryVersionCmp(string calldata version) external view returns (int256);", + "id": "getStateDiffJson", + "description": "Returns state diffs from current `vm.startStateDiffRecording` session, in json format.", + "declaration": "function getStateDiffJson() external view returns (string memory diff);", "visibility": "external", "mutability": "view", - "signature": "foundryVersionCmp(string)", - "selector": "0xca7b0a09", + "signature": "getStateDiffJson()", + "selector": "0xf54fe009", "selectorBytes": [ - 202, - 123, - 10, + 245, + 79, + 224, 9 ] }, - "group": "testing", - "status": "stable", - "safety": "safe" - }, - { - "func": { - "id": "fsMetadata", - "description": "Given a path, query the file system to get information about a file, directory, etc.", - "declaration": "function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata);", - "visibility": "external", - "mutability": "view", - "signature": "fsMetadata(string)", - "selector": "0xaf368a08", - "selectorBytes": [ - 175, - 54, - 138, - 8 - ] - }, - "group": "filesystem", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "getArtifactPathByCode", - "description": "Gets the artifact path from code (aka. creation code).", - "declaration": "function getArtifactPathByCode(bytes calldata code) external view returns (string memory path);", + "id": "getStorageAccesses", + "description": "Returns an array of `StorageAccess` from current `vm.stateStateDiffRecording` session", + "declaration": "function getStorageAccesses() external view returns (StorageAccess[] memory accesses);", "visibility": "external", "mutability": "view", - "signature": "getArtifactPathByCode(bytes)", - "selector": "0xeb74848c", + "signature": "getStorageAccesses()", + "selector": "0x2899b1d0", "selectorBytes": [ - 235, - 116, - 132, - 140 + 40, + 153, + 177, + 208 ] }, - "group": "filesystem", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "getArtifactPathByDeployedCode", - "description": "Gets the artifact path from deployed code (aka. runtime code).", - "declaration": "function getArtifactPathByDeployedCode(bytes calldata deployedCode) external view returns (string memory path);", + "id": "getWallets", + "description": "Returns addresses of available unlocked wallets in the script environment.", + "declaration": "function getWallets() external returns (address[] memory wallets);", "visibility": "external", - "mutability": "view", - "signature": "getArtifactPathByDeployedCode(bytes)", - "selector": "0x6d853ba5", + "mutability": "", + "signature": "getWallets()", + "selector": "0xdb7a4605", "selectorBytes": [ - 109, - 133, - 59, - 165 + 219, + 122, + 70, + 5 ] }, - "group": "filesystem", + "group": "scripting", "status": "stable", "safety": "safe" }, { "func": { - "id": "getBlobBaseFee", - "description": "Gets the current `block.blobbasefee`.\nYou should use this instead of `block.blobbasefee` if you use `vm.blobBaseFee`, as `block.blobbasefee` is assumed to be constant across a transaction,\nand as a result will get optimized out by the compiler.\nSee https://github.com/foundry-rs/foundry/issues/6180", - "declaration": "function getBlobBaseFee() external view returns (uint256 blobBaseFee);", + "id": "indexOf", + "description": "Returns the index of the first occurrence of a `key` in an `input` string.\nReturns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found.\nReturns 0 in case of an empty `key`.", + "declaration": "function indexOf(string calldata input, string calldata key) external pure returns (uint256);", "visibility": "external", - "mutability": "view", - "signature": "getBlobBaseFee()", - "selector": "0x1f6d6ef7", + "mutability": "pure", + "signature": "indexOf(string,string)", + "selector": "0x8a0807b7", "selectorBytes": [ - 31, - 109, - 110, - 247 + 138, + 8, + 7, + 183 ] }, - "group": "evm", + "group": "string", "status": "stable", "safety": "safe" }, { "func": { - "id": "getBlobhashes", - "description": "Gets the blockhashes from the current transaction.\nNot available on EVM versions before Cancun.\nIf used on unsupported EVM versions it will revert.", - "declaration": "function getBlobhashes() external view returns (bytes32[] memory hashes);", + "id": "interceptInitcode", + "description": "Causes the next contract creation (via new) to fail and return its initcode in the returndata buffer.\nThis allows type-safe access to the initcode payload that would be used for contract creation.\nExample usage:\nvm.interceptInitcode();\nbytes memory initcode;\ntry new MyContract(param1, param2) { assert(false); }\ncatch (bytes memory interceptedInitcode) { initcode = interceptedInitcode; }", + "declaration": "function interceptInitcode() external;", "visibility": "external", - "mutability": "view", - "signature": "getBlobhashes()", - "selector": "0xf56ff18b", + "mutability": "", + "signature": "interceptInitcode()", + "selector": "0x838653c7", "selectorBytes": [ - 245, - 111, - 241, - 139 + 131, + 134, + 83, + 199 ] }, - "group": "evm", + "group": "utilities", "status": "stable", "safety": "unsafe" }, { "func": { - "id": "getBlockNumber", - "description": "Gets the current `block.number`.\nYou should use this instead of `block.number` if you use `vm.roll`, as `block.number` is assumed to be constant across a transaction,\nand as a result will get optimized out by the compiler.\nSee https://github.com/foundry-rs/foundry/issues/6180", - "declaration": "function getBlockNumber() external view returns (uint256 height);", + "id": "isContext", + "description": "Returns true if `forge` command was executed in given context.", + "declaration": "function isContext(ForgeContext context) external view returns (bool result);", "visibility": "external", "mutability": "view", - "signature": "getBlockNumber()", - "selector": "0x42cbb15c", + "signature": "isContext(uint8)", + "selector": "0x64af255d", "selectorBytes": [ - 66, - 203, - 177, - 92 + 100, + 175, + 37, + 93 ] }, - "group": "evm", + "group": "environment", "status": "stable", "safety": "safe" }, { "func": { - "id": "getBlockTimestamp", - "description": "Gets the current `block.timestamp`.\nYou should use this instead of `block.timestamp` if you use `vm.warp`, as `block.timestamp` is assumed to be constant across a transaction,\nand as a result will get optimized out by the compiler.\nSee https://github.com/foundry-rs/foundry/issues/6180", - "declaration": "function getBlockTimestamp() external view returns (uint256 timestamp);", + "id": "isDir", + "description": "Returns true if the path exists on disk and is pointing at a directory, else returns false.", + "declaration": "function isDir(string calldata path) external view returns (bool result);", "visibility": "external", "mutability": "view", - "signature": "getBlockTimestamp()", - "selector": "0x796b89b9", + "signature": "isDir(string)", + "selector": "0x7d15d019", "selectorBytes": [ - 121, - 107, - 137, - 185 + 125, + 21, + 208, + 25 ] }, - "group": "evm", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "getBroadcast", - "description": "Returns the most recent broadcast for the given contract on `chainId` matching `txType`.\nFor example:\nThe most recent deployment can be fetched by passing `txType` as `CREATE` or `CREATE2`.\nThe most recent call can be fetched by passing `txType` as `CALL`.", - "declaration": "function getBroadcast(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary memory);", + "id": "isFile", + "description": "Returns true if the path exists on disk and is pointing at a regular file, else returns false.", + "declaration": "function isFile(string calldata path) external view returns (bool result);", "visibility": "external", "mutability": "view", - "signature": "getBroadcast(string,uint64,uint8)", - "selector": "0x3dc90cb3", + "signature": "isFile(string)", + "selector": "0xe0eb04d4", "selectorBytes": [ - 61, - 201, - 12, - 179 + 224, + 235, + 4, + 212 ] }, "group": "filesystem", @@ -6746,2563 +6726,2583 @@ }, { "func": { - "id": "getBroadcasts_0", - "description": "Returns all broadcasts for the given contract on `chainId` with the specified `txType`.\nSorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.", - "declaration": "function getBroadcasts(string calldata contractName, uint64 chainId, BroadcastTxType txType) external view returns (BroadcastTxSummary[] memory);", + "id": "isPersistent", + "description": "Returns true if the account is marked as persistent.", + "declaration": "function isPersistent(address account) external view returns (bool persistent);", "visibility": "external", "mutability": "view", - "signature": "getBroadcasts(string,uint64,uint8)", - "selector": "0xf7afe919", + "signature": "isPersistent(address)", + "selector": "0xd92d8efd", "selectorBytes": [ - 247, - 175, - 233, - 25 + 217, + 45, + 142, + 253 ] }, - "group": "filesystem", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getBroadcasts_1", - "description": "Returns all broadcasts for the given contract on `chainId`.\nSorted such that the most recent broadcast is the first element, and the oldest is the last. i.e descending order of BroadcastTxSummary.blockNumber.", - "declaration": "function getBroadcasts(string calldata contractName, uint64 chainId) external view returns (BroadcastTxSummary[] memory);", + "id": "keyExists", + "description": "Checks if `key` exists in a JSON object\n`keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions.", + "declaration": "function keyExists(string calldata json, string calldata key) external view returns (bool);", "visibility": "external", "mutability": "view", - "signature": "getBroadcasts(string,uint64)", - "selector": "0xf2fa4a26", + "signature": "keyExists(string,string)", + "selector": "0x528a683c", "selectorBytes": [ - 242, - 250, - 74, - 38 + 82, + 138, + 104, + 60 ] }, - "group": "filesystem", - "status": "stable", - "safety": "safe" - }, - { - "func": { - "id": "getChain_0", - "description": "Returns a Chain struct for specific alias", - "declaration": "function getChain(string calldata chainAlias) external view returns (Chain memory chain);", - "visibility": "external", - "mutability": "view", - "signature": "getChain(string)", - "selector": "0x4cc1c2bb", - "selectorBytes": [ - 76, - 193, - 194, - 187 - ] + "group": "json", + "status": { + "deprecated": "replaced by `keyExistsJson`" }, - "group": "testing", - "status": "stable", "safety": "safe" }, { "func": { - "id": "getChain_1", - "description": "Returns a Chain struct for specific chainId", - "declaration": "function getChain(uint256 chainId) external view returns (Chain memory chain);", + "id": "keyExistsJson", + "description": "Checks if `key` exists in a JSON object.", + "declaration": "function keyExistsJson(string calldata json, string calldata key) external view returns (bool);", "visibility": "external", "mutability": "view", - "signature": "getChain(uint256)", - "selector": "0xb6791ad4", + "signature": "keyExistsJson(string,string)", + "selector": "0xdb4235f6", "selectorBytes": [ - 182, - 121, - 26, - 212 + 219, + 66, + 53, + 246 ] }, - "group": "testing", + "group": "json", "status": "stable", "safety": "safe" }, { "func": { - "id": "getCode", - "description": "Gets the creation bytecode from an artifact file. Takes in the relative path to the json file or the path to the\nartifact in the form of :: where and parts are optional.", - "declaration": "function getCode(string calldata artifactPath) external view returns (bytes memory creationBytecode);", + "id": "keyExistsToml", + "description": "Checks if `key` exists in a TOML table.", + "declaration": "function keyExistsToml(string calldata toml, string calldata key) external view returns (bool);", "visibility": "external", "mutability": "view", - "signature": "getCode(string)", - "selector": "0x8d1cc925", + "signature": "keyExistsToml(string,string)", + "selector": "0x600903ad", "selectorBytes": [ - 141, - 28, - 201, - 37 + 96, + 9, + 3, + 173 ] }, - "group": "filesystem", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "getDeployedCode", - "description": "Gets the deployed bytecode from an artifact file. Takes in the relative path to the json file or the path to the\nartifact in the form of :: where and parts are optional.", - "declaration": "function getDeployedCode(string calldata artifactPath) external view returns (bytes memory runtimeBytecode);", + "id": "label", + "description": "Labels an address in call traces.", + "declaration": "function label(address account, string calldata newLabel) external;", "visibility": "external", - "mutability": "view", - "signature": "getDeployedCode(string)", - "selector": "0x3ebf73b4", + "mutability": "", + "signature": "label(address,string)", + "selector": "0xc657c718", "selectorBytes": [ - 62, - 191, - 115, - 180 + 198, + 87, + 199, + 24 ] }, - "group": "filesystem", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "getDeployment_0", - "description": "Returns the most recent deployment for the current `chainId`.", - "declaration": "function getDeployment(string calldata contractName) external view returns (address deployedAddress);", + "id": "lastCallGas", + "description": "Gets the gas used in the last call from the callee perspective.", + "declaration": "function lastCallGas() external view returns (Gas memory gas);", "visibility": "external", "mutability": "view", - "signature": "getDeployment(string)", - "selector": "0xa8091d97", + "signature": "lastCallGas()", + "selector": "0x2b589b28", "selectorBytes": [ - 168, - 9, - 29, - 151 + 43, + 88, + 155, + 40 ] }, - "group": "filesystem", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "getDeployment_1", - "description": "Returns the most recent deployment for the given contract on `chainId`", - "declaration": "function getDeployment(string calldata contractName, uint64 chainId) external view returns (address deployedAddress);", + "id": "load", + "description": "Loads a storage slot from an address.", + "declaration": "function load(address target, bytes32 slot) external view returns (bytes32 data);", "visibility": "external", "mutability": "view", - "signature": "getDeployment(string,uint64)", - "selector": "0x0debd5d6", + "signature": "load(address,bytes32)", + "selector": "0x667f9d70", "selectorBytes": [ - 13, - 235, - 213, - 214 + 102, + 127, + 157, + 112 ] }, - "group": "filesystem", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "getDeployments", - "description": "Returns all deployments for the given contract on `chainId`\nSorted in descending order of deployment time i.e descending order of BroadcastTxSummary.blockNumber.\nThe most recent deployment is the first element, and the oldest is the last.", - "declaration": "function getDeployments(string calldata contractName, uint64 chainId) external view returns (address[] memory deployedAddresses);", + "id": "loadAllocs", + "description": "Load a genesis JSON file's `allocs` into the in-memory EVM state.", + "declaration": "function loadAllocs(string calldata pathToAllocsJson) external;", "visibility": "external", - "mutability": "view", - "signature": "getDeployments(string,uint64)", - "selector": "0x74e133dd", + "mutability": "", + "signature": "loadAllocs(string)", + "selector": "0xb3a056d7", "selectorBytes": [ - 116, - 225, - 51, - 221 + 179, + 160, + 86, + 215 ] }, - "group": "filesystem", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getFoundryVersion", - "description": "Returns the Foundry version.\nFormat: -+..\nSample output: 0.3.0-nightly+3cb96bde9b.1737036656.debug\nNote: Build timestamps may vary slightly across platforms due to separate CI jobs.\nFor reliable version comparisons, use UNIX format (e.g., >= 1700000000)\nto compare timestamps while ignoring minor time differences.", - "declaration": "function getFoundryVersion() external view returns (string memory version);", + "id": "makePersistent_0", + "description": "Marks that the account(s) should use persistent storage across fork swaps in a multifork setup\nMeaning, changes made to the state of this account will be kept when switching forks.", + "declaration": "function makePersistent(address account) external;", "visibility": "external", - "mutability": "view", - "signature": "getFoundryVersion()", - "selector": "0xea991bb5", + "mutability": "", + "signature": "makePersistent(address)", + "selector": "0x57e22dde", "selectorBytes": [ - 234, - 153, - 27, - 181 + 87, + 226, + 45, + 222 ] }, - "group": "testing", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getLabel", - "description": "Gets the label for the specified address.", - "declaration": "function getLabel(address account) external view returns (string memory currentLabel);", + "id": "makePersistent_1", + "description": "See `makePersistent(address)`.", + "declaration": "function makePersistent(address account0, address account1) external;", "visibility": "external", - "mutability": "view", - "signature": "getLabel(address)", - "selector": "0x28a249b0", + "mutability": "", + "signature": "makePersistent(address,address)", + "selector": "0x4074e0a8", "selectorBytes": [ - 40, - 162, - 73, - 176 + 64, + 116, + 224, + 168 ] }, - "group": "utilities", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getMappingKeyAndParentOf", - "description": "Gets the map key and parent of a mapping at a given slot, for a given address.", - "declaration": "function getMappingKeyAndParentOf(address target, bytes32 elementSlot) external returns (bool found, bytes32 key, bytes32 parent);", + "id": "makePersistent_2", + "description": "See `makePersistent(address)`.", + "declaration": "function makePersistent(address account0, address account1, address account2) external;", "visibility": "external", "mutability": "", - "signature": "getMappingKeyAndParentOf(address,bytes32)", - "selector": "0x876e24e6", + "signature": "makePersistent(address,address,address)", + "selector": "0xefb77a75", "selectorBytes": [ - 135, - 110, - 36, - 230 + 239, + 183, + 122, + 117 ] }, "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getMappingLength", - "description": "Gets the number of elements in the mapping at the given slot, for a given address.", - "declaration": "function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);", + "id": "makePersistent_3", + "description": "See `makePersistent(address)`.", + "declaration": "function makePersistent(address[] calldata accounts) external;", "visibility": "external", "mutability": "", - "signature": "getMappingLength(address,bytes32)", - "selector": "0x2f2fd63f", + "signature": "makePersistent(address[])", + "selector": "0x1d9e269e", "selectorBytes": [ - 47, - 47, - 214, - 63 + 29, + 158, + 38, + 158 ] }, "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getMappingSlotAt", - "description": "Gets the elements at index idx of the mapping at the given slot, for a given address. The\nindex must be less than the length of the mapping (i.e. the number of keys in the mapping).", - "declaration": "function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);", + "id": "mockCallRevert_0", + "description": "Reverts a call to an address with specified revert data.", + "declaration": "function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;", "visibility": "external", "mutability": "", - "signature": "getMappingSlotAt(address,bytes32,uint256)", - "selector": "0xebc73ab4", + "signature": "mockCallRevert(address,bytes,bytes)", + "selector": "0xdbaad147", "selectorBytes": [ - 235, - 199, - 58, - 180 + 219, + 170, + 209, + 71 ] }, "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getNonce_0", - "description": "Gets the nonce of an account.", - "declaration": "function getNonce(address account) external view returns (uint64 nonce);", + "id": "mockCallRevert_1", + "description": "Reverts a call to an address with a specific `msg.value`, with specified revert data.", + "declaration": "function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external;", "visibility": "external", - "mutability": "view", - "signature": "getNonce(address)", - "selector": "0x2d0335ab", + "mutability": "", + "signature": "mockCallRevert(address,uint256,bytes,bytes)", + "selector": "0xd23cd037", "selectorBytes": [ - 45, - 3, - 53, - 171 + 210, + 60, + 208, + 55 ] }, "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getNonce_1", - "description": "Get the nonce of a `Wallet`.", - "declaration": "function getNonce(Wallet calldata wallet) external returns (uint64 nonce);", + "id": "mockCallRevert_2", + "description": "Reverts a call to an address with specified revert data.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", + "declaration": "function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external;", "visibility": "external", "mutability": "", - "signature": "getNonce((address,uint256,uint256,uint256))", - "selector": "0xa5748aad", + "signature": "mockCallRevert(address,bytes4,bytes)", + "selector": "0x2dfba5df", "selectorBytes": [ + 45, + 251, 165, - 116, - 138, - 173 + 223 ] }, "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getRawBlockHeader", - "description": "Gets the RLP encoded block header for a given block number.\nReturns the block header in the same format as `cast block --raw`.", - "declaration": "function getRawBlockHeader(uint256 blockNumber) external view returns (bytes memory rlpHeader);", + "id": "mockCallRevert_3", + "description": "Reverts a call to an address with a specific `msg.value`, with specified revert data.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", + "declaration": "function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData) external;", "visibility": "external", - "mutability": "view", - "signature": "getRawBlockHeader(uint256)", - "selector": "0x2c667606", + "mutability": "", + "signature": "mockCallRevert(address,uint256,bytes4,bytes)", + "selector": "0x596c8f04", "selectorBytes": [ - 44, - 102, - 118, - 6 + 89, + 108, + 143, + 4 ] }, "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getRecordedLogs", - "description": "Gets all the recorded logs.", - "declaration": "function getRecordedLogs() external returns (Log[] memory logs);", + "id": "mockCall_0", + "description": "Mocks a call to an address, returning specified data.\nCalldata can either be strict or a partial match, e.g. if you only\npass a Solidity selector to the expected calldata, then the entire Solidity\nfunction will be mocked.", + "declaration": "function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;", "visibility": "external", "mutability": "", - "signature": "getRecordedLogs()", - "selector": "0x191553a4", + "signature": "mockCall(address,bytes,bytes)", + "selector": "0xb96213e4", "selectorBytes": [ - 25, - 21, - 83, - 164 + 185, + 98, + 19, + 228 ] }, "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getStateDiff", - "description": "Returns state diffs from current `vm.startStateDiffRecording` session.", - "declaration": "function getStateDiff() external view returns (string memory diff);", + "id": "mockCall_1", + "description": "Mocks a call to an address with a specific `msg.value`, returning specified data.\nCalldata match takes precedence over `msg.value` in case of ambiguity.", + "declaration": "function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;", "visibility": "external", - "mutability": "view", - "signature": "getStateDiff()", - "selector": "0x80df01cc", + "mutability": "", + "signature": "mockCall(address,uint256,bytes,bytes)", + "selector": "0x81409b91", "selectorBytes": [ - 128, - 223, - 1, - 204 + 129, + 64, + 155, + 145 ] }, "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getStateDiffJson", - "description": "Returns state diffs from current `vm.startStateDiffRecording` session, in json format.", - "declaration": "function getStateDiffJson() external view returns (string memory diff);", + "id": "mockCall_2", + "description": "Mocks a call to an address, returning specified data.\nCalldata can either be strict or a partial match, e.g. if you only\npass a Solidity selector to the expected calldata, then the entire Solidity\nfunction will be mocked.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", + "declaration": "function mockCall(address callee, bytes4 data, bytes calldata returnData) external;", "visibility": "external", - "mutability": "view", - "signature": "getStateDiffJson()", - "selector": "0xf54fe009", + "mutability": "", + "signature": "mockCall(address,bytes4,bytes)", + "selector": "0x08e0c537", "selectorBytes": [ - 245, - 79, + 8, 224, - 9 + 197, + 55 ] }, "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getStorageAccesses", - "description": "Returns an array of `StorageAccess` from current `vm.stateStateDiffRecording` session", - "declaration": "function getStorageAccesses() external view returns (StorageAccess[] memory accesses);", + "id": "mockCall_3", + "description": "Mocks a call to an address with a specific `msg.value`, returning specified data.\nCalldata match takes precedence over `msg.value` in case of ambiguity.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", + "declaration": "function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external;", "visibility": "external", - "mutability": "view", - "signature": "getStorageAccesses()", - "selector": "0x2899b1d0", + "mutability": "", + "signature": "mockCall(address,uint256,bytes4,bytes)", + "selector": "0xe7b36a3d", "selectorBytes": [ - 40, - 153, - 177, - 208 + 231, + 179, + 106, + 61 ] }, "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "getWallets", - "description": "Returns addresses of available unlocked wallets in the script environment.", - "declaration": "function getWallets() external returns (address[] memory wallets);", + "id": "mockCalls_0", + "description": "Mocks multiple calls to an address, returning specified data for each call.", + "declaration": "function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external;", "visibility": "external", "mutability": "", - "signature": "getWallets()", - "selector": "0xdb7a4605", + "signature": "mockCalls(address,bytes,bytes[])", + "selector": "0x5c5c3de9", "selectorBytes": [ - 219, - 122, - 70, - 5 + 92, + 92, + 61, + 233 ] }, - "group": "scripting", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "indexOf", - "description": "Returns the index of the first occurrence of a `key` in an `input` string.\nReturns `NOT_FOUND` (i.e. `type(uint256).max`) if the `key` is not found.\nReturns 0 in case of an empty `key`.", - "declaration": "function indexOf(string calldata input, string calldata key) external pure returns (uint256);", + "id": "mockCalls_1", + "description": "Mocks multiple calls to an address with a specific `msg.value`, returning specified data for each call.", + "declaration": "function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external;", "visibility": "external", - "mutability": "pure", - "signature": "indexOf(string,string)", - "selector": "0x8a0807b7", + "mutability": "", + "signature": "mockCalls(address,uint256,bytes,bytes[])", + "selector": "0x08bcbae1", "selectorBytes": [ - 138, 8, - 7, - 183 + 188, + 186, + 225 ] }, - "group": "string", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "interceptInitcode", - "description": "Causes the next contract creation (via new) to fail and return its initcode in the returndata buffer.\nThis allows type-safe access to the initcode payload that would be used for contract creation.\nExample usage:\nvm.interceptInitcode();\nbytes memory initcode;\ntry new MyContract(param1, param2) { assert(false); }\ncatch (bytes memory interceptedInitcode) { initcode = interceptedInitcode; }", - "declaration": "function interceptInitcode() external;", + "id": "mockFunction", + "description": "Whenever a call is made to `callee` with calldata `data`, this cheatcode instead calls\n`target` with the same calldata. This functionality is similar to a delegate call made to\n`target` contract from `callee`.\nCan be used to substitute a call to a function with another implementation that captures\nthe primary logic of the original function but is easier to reason about.\nIf calldata is not a strict match then partial match by selector is attempted.", + "declaration": "function mockFunction(address callee, address target, bytes calldata data) external;", "visibility": "external", "mutability": "", - "signature": "interceptInitcode()", - "selector": "0x838653c7", + "signature": "mockFunction(address,address,bytes)", + "selector": "0xadf84d21", "selectorBytes": [ - 131, - 134, - 83, - 199 + 173, + 248, + 77, + 33 ] }, - "group": "utilities", + "group": "evm", "status": "stable", "safety": "unsafe" }, { "func": { - "id": "isContext", - "description": "Returns true if `forge` command was executed in given context.", - "declaration": "function isContext(ForgeContext context) external view returns (bool result);", + "id": "noAccessList", + "description": "Utility cheatcode to remove any EIP-2930 access list set by `accessList` cheatcode.", + "declaration": "function noAccessList() external;", "visibility": "external", - "mutability": "view", - "signature": "isContext(uint8)", - "selector": "0x64af255d", + "mutability": "", + "signature": "noAccessList()", + "selector": "0x238ad778", "selectorBytes": [ - 100, - 175, - 37, - 93 + 35, + 138, + 215, + 120 ] }, - "group": "environment", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "isDir", - "description": "Returns true if the path exists on disk and is pointing at a directory, else returns false.", - "declaration": "function isDir(string calldata path) external view returns (bool result);", + "id": "parseAddress", + "description": "Parses the given `string` into an `address`.", + "declaration": "function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);", "visibility": "external", - "mutability": "view", - "signature": "isDir(string)", - "selector": "0x7d15d019", + "mutability": "pure", + "signature": "parseAddress(string)", + "selector": "0xc6ce059d", "selectorBytes": [ - 125, - 21, - 208, - 25 + 198, + 206, + 5, + 157 ] }, - "group": "filesystem", + "group": "string", "status": "stable", "safety": "safe" }, { "func": { - "id": "isFile", - "description": "Returns true if the path exists on disk and is pointing at a regular file, else returns false.", - "declaration": "function isFile(string calldata path) external view returns (bool result);", + "id": "parseBool", + "description": "Parses the given `string` into a `bool`.", + "declaration": "function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);", "visibility": "external", - "mutability": "view", - "signature": "isFile(string)", - "selector": "0xe0eb04d4", + "mutability": "pure", + "signature": "parseBool(string)", + "selector": "0x974ef924", "selectorBytes": [ - 224, - 235, - 4, - 212 + 151, + 78, + 249, + 36 ] }, - "group": "filesystem", + "group": "string", "status": "stable", "safety": "safe" }, { "func": { - "id": "isPersistent", - "description": "Returns true if the account is marked as persistent.", - "declaration": "function isPersistent(address account) external view returns (bool persistent);", + "id": "parseBytes", + "description": "Parses the given `string` into `bytes`.", + "declaration": "function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);", "visibility": "external", - "mutability": "view", - "signature": "isPersistent(address)", - "selector": "0xd92d8efd", + "mutability": "pure", + "signature": "parseBytes(string)", + "selector": "0x8f5d232d", "selectorBytes": [ - 217, - 45, - 142, - 253 + 143, + 93, + 35, + 45 ] }, - "group": "evm", + "group": "string", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "keyExists", - "description": "Checks if `key` exists in a JSON object\n`keyExists` is being deprecated in favor of `keyExistsJson`. It will be removed in future versions.", - "declaration": "function keyExists(string calldata json, string calldata key) external view returns (bool);", + "id": "parseBytes32", + "description": "Parses the given `string` into a `bytes32`.", + "declaration": "function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);", "visibility": "external", - "mutability": "view", - "signature": "keyExists(string,string)", - "selector": "0x528a683c", + "mutability": "pure", + "signature": "parseBytes32(string)", + "selector": "0x087e6e81", "selectorBytes": [ - 82, - 138, - 104, - 60 + 8, + 126, + 110, + 129 ] }, - "group": "json", - "status": { - "deprecated": "replaced by `keyExistsJson`" - }, + "group": "string", + "status": "stable", "safety": "safe" }, { "func": { - "id": "keyExistsJson", - "description": "Checks if `key` exists in a JSON object.", - "declaration": "function keyExistsJson(string calldata json, string calldata key) external view returns (bool);", + "id": "parseInt", + "description": "Parses the given `string` into a `int256`.", + "declaration": "function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);", "visibility": "external", - "mutability": "view", - "signature": "keyExistsJson(string,string)", - "selector": "0xdb4235f6", + "mutability": "pure", + "signature": "parseInt(string)", + "selector": "0x42346c5e", "selectorBytes": [ - 219, 66, - 53, - 246 + 52, + 108, + 94 ] }, - "group": "json", + "group": "string", "status": "stable", "safety": "safe" }, { "func": { - "id": "keyExistsToml", - "description": "Checks if `key` exists in a TOML table.", - "declaration": "function keyExistsToml(string calldata toml, string calldata key) external view returns (bool);", + "id": "parseJsonAddress", + "description": "Parses a string of JSON data at `key` and coerces it to `address`.", + "declaration": "function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);", "visibility": "external", - "mutability": "view", - "signature": "keyExistsToml(string,string)", - "selector": "0x600903ad", + "mutability": "pure", + "signature": "parseJsonAddress(string,string)", + "selector": "0x1e19e657", "selectorBytes": [ - 96, - 9, - 3, - 173 + 30, + 25, + 230, + 87 ] }, - "group": "toml", + "group": "json", "status": "stable", "safety": "safe" }, { "func": { - "id": "label", - "description": "Labels an address in call traces.", - "declaration": "function label(address account, string calldata newLabel) external;", + "id": "parseJsonAddressArray", + "description": "Parses a string of JSON data at `key` and coerces it to `address[]`.", + "declaration": "function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory);", "visibility": "external", - "mutability": "", - "signature": "label(address,string)", - "selector": "0xc657c718", + "mutability": "pure", + "signature": "parseJsonAddressArray(string,string)", + "selector": "0x2fce7883", "selectorBytes": [ - 198, - 87, - 199, - 24 + 47, + 206, + 120, + 131 ] }, - "group": "utilities", + "group": "json", "status": "stable", "safety": "safe" }, { "func": { - "id": "lastCallGas", - "description": "Gets the gas used in the last call from the callee perspective.", - "declaration": "function lastCallGas() external view returns (Gas memory gas);", + "id": "parseJsonBool", + "description": "Parses a string of JSON data at `key` and coerces it to `bool`.", + "declaration": "function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);", "visibility": "external", - "mutability": "view", - "signature": "lastCallGas()", - "selector": "0x2b589b28", + "mutability": "pure", + "signature": "parseJsonBool(string,string)", + "selector": "0x9f86dc91", "selectorBytes": [ - 43, - 88, - 155, - 40 + 159, + 134, + 220, + 145 ] }, - "group": "evm", + "group": "json", "status": "stable", "safety": "safe" }, { "func": { - "id": "load", - "description": "Loads a storage slot from an address.", - "declaration": "function load(address target, bytes32 slot) external view returns (bytes32 data);", + "id": "parseJsonBoolArray", + "description": "Parses a string of JSON data at `key` and coerces it to `bool[]`.", + "declaration": "function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);", "visibility": "external", - "mutability": "view", - "signature": "load(address,bytes32)", - "selector": "0x667f9d70", + "mutability": "pure", + "signature": "parseJsonBoolArray(string,string)", + "selector": "0x91f3b94f", "selectorBytes": [ - 102, - 127, - 157, - 112 + 145, + 243, + 185, + 79 ] }, - "group": "evm", + "group": "json", "status": "stable", "safety": "safe" }, { "func": { - "id": "loadAllocs", - "description": "Load a genesis JSON file's `allocs` into the in-memory EVM state.", - "declaration": "function loadAllocs(string calldata pathToAllocsJson) external;", + "id": "parseJsonBytes", + "description": "Parses a string of JSON data at `key` and coerces it to `bytes`.", + "declaration": "function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);", "visibility": "external", - "mutability": "", - "signature": "loadAllocs(string)", - "selector": "0xb3a056d7", + "mutability": "pure", + "signature": "parseJsonBytes(string,string)", + "selector": "0xfd921be8", "selectorBytes": [ - 179, - 160, - 86, - 215 + 253, + 146, + 27, + 232 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "makePersistent_0", - "description": "Marks that the account(s) should use persistent storage across fork swaps in a multifork setup\nMeaning, changes made to the state of this account will be kept when switching forks.", - "declaration": "function makePersistent(address account) external;", + "id": "parseJsonBytes32", + "description": "Parses a string of JSON data at `key` and coerces it to `bytes32`.", + "declaration": "function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);", "visibility": "external", - "mutability": "", - "signature": "makePersistent(address)", - "selector": "0x57e22dde", + "mutability": "pure", + "signature": "parseJsonBytes32(string,string)", + "selector": "0x1777e59d", "selectorBytes": [ - 87, - 226, - 45, - 222 + 23, + 119, + 229, + 157 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "makePersistent_1", - "description": "See `makePersistent(address)`.", - "declaration": "function makePersistent(address account0, address account1) external;", + "id": "parseJsonBytes32Array", + "description": "Parses a string of JSON data at `key` and coerces it to `bytes32[]`.", + "declaration": "function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory);", "visibility": "external", - "mutability": "", - "signature": "makePersistent(address,address)", - "selector": "0x4074e0a8", + "mutability": "pure", + "signature": "parseJsonBytes32Array(string,string)", + "selector": "0x91c75bc3", "selectorBytes": [ - 64, - 116, - 224, - 168 + 145, + 199, + 91, + 195 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "makePersistent_2", - "description": "See `makePersistent(address)`.", - "declaration": "function makePersistent(address account0, address account1, address account2) external;", + "id": "parseJsonBytesArray", + "description": "Parses a string of JSON data at `key` and coerces it to `bytes[]`.", + "declaration": "function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);", "visibility": "external", - "mutability": "", - "signature": "makePersistent(address,address,address)", - "selector": "0xefb77a75", + "mutability": "pure", + "signature": "parseJsonBytesArray(string,string)", + "selector": "0x6631aa99", "selectorBytes": [ - 239, - 183, - 122, - 117 + 102, + 49, + 170, + 153 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "makePersistent_3", - "description": "See `makePersistent(address)`.", - "declaration": "function makePersistent(address[] calldata accounts) external;", + "id": "parseJsonInt", + "description": "Parses a string of JSON data at `key` and coerces it to `int256`.", + "declaration": "function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);", "visibility": "external", - "mutability": "", - "signature": "makePersistent(address[])", - "selector": "0x1d9e269e", + "mutability": "pure", + "signature": "parseJsonInt(string,string)", + "selector": "0x7b048ccd", "selectorBytes": [ - 29, - 158, - 38, - 158 + 123, + 4, + 140, + 205 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockCallRevert_0", - "description": "Reverts a call to an address with specified revert data.", - "declaration": "function mockCallRevert(address callee, bytes calldata data, bytes calldata revertData) external;", + "id": "parseJsonIntArray", + "description": "Parses a string of JSON data at `key` and coerces it to `int256[]`.", + "declaration": "function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);", "visibility": "external", - "mutability": "", - "signature": "mockCallRevert(address,bytes,bytes)", - "selector": "0xdbaad147", + "mutability": "pure", + "signature": "parseJsonIntArray(string,string)", + "selector": "0x9983c28a", "selectorBytes": [ - 219, - 170, - 209, - 71 + 153, + 131, + 194, + 138 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockCallRevert_1", - "description": "Reverts a call to an address with a specific `msg.value`, with specified revert data.", - "declaration": "function mockCallRevert(address callee, uint256 msgValue, bytes calldata data, bytes calldata revertData) external;", + "id": "parseJsonKeys", + "description": "Returns an array of all the keys in a JSON object.", + "declaration": "function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);", "visibility": "external", - "mutability": "", - "signature": "mockCallRevert(address,uint256,bytes,bytes)", - "selector": "0xd23cd037", + "mutability": "pure", + "signature": "parseJsonKeys(string,string)", + "selector": "0x213e4198", "selectorBytes": [ - 210, - 60, - 208, - 55 + 33, + 62, + 65, + 152 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockCallRevert_2", - "description": "Reverts a call to an address with specified revert data.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", - "declaration": "function mockCallRevert(address callee, bytes4 data, bytes calldata revertData) external;", + "id": "parseJsonString", + "description": "Parses a string of JSON data at `key` and coerces it to `string`.", + "declaration": "function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);", "visibility": "external", - "mutability": "", - "signature": "mockCallRevert(address,bytes4,bytes)", - "selector": "0x2dfba5df", + "mutability": "pure", + "signature": "parseJsonString(string,string)", + "selector": "0x49c4fac8", "selectorBytes": [ - 45, - 251, - 165, - 223 + 73, + 196, + 250, + 200 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockCallRevert_3", - "description": "Reverts a call to an address with a specific `msg.value`, with specified revert data.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", - "declaration": "function mockCallRevert(address callee, uint256 msgValue, bytes4 data, bytes calldata revertData) external;", + "id": "parseJsonStringArray", + "description": "Parses a string of JSON data at `key` and coerces it to `string[]`.", + "declaration": "function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);", "visibility": "external", - "mutability": "", - "signature": "mockCallRevert(address,uint256,bytes4,bytes)", - "selector": "0x596c8f04", + "mutability": "pure", + "signature": "parseJsonStringArray(string,string)", + "selector": "0x498fdcf4", "selectorBytes": [ - 89, - 108, + 73, 143, - 4 + 220, + 244 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockCall_0", - "description": "Mocks a call to an address, returning specified data.\nCalldata can either be strict or a partial match, e.g. if you only\npass a Solidity selector to the expected calldata, then the entire Solidity\nfunction will be mocked.", - "declaration": "function mockCall(address callee, bytes calldata data, bytes calldata returnData) external;", + "id": "parseJsonTypeArray", + "description": "Parses a string of JSON data at `key` and coerces it to type array corresponding to `typeDescription`.", + "declaration": "function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", "visibility": "external", - "mutability": "", - "signature": "mockCall(address,bytes,bytes)", - "selector": "0xb96213e4", + "mutability": "pure", + "signature": "parseJsonTypeArray(string,string,string)", + "selector": "0x0175d535", "selectorBytes": [ - 185, - 98, - 19, - 228 + 1, + 117, + 213, + 53 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockCall_1", - "description": "Mocks a call to an address with a specific `msg.value`, returning specified data.\nCalldata match takes precedence over `msg.value` in case of ambiguity.", - "declaration": "function mockCall(address callee, uint256 msgValue, bytes calldata data, bytes calldata returnData) external;", + "id": "parseJsonType_0", + "description": "Parses a string of JSON data and coerces it to type corresponding to `typeDescription`.", + "declaration": "function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory);", "visibility": "external", - "mutability": "", - "signature": "mockCall(address,uint256,bytes,bytes)", - "selector": "0x81409b91", + "mutability": "pure", + "signature": "parseJsonType(string,string)", + "selector": "0xa9da313b", "selectorBytes": [ - 129, - 64, - 155, - 145 + 169, + 218, + 49, + 59 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockCall_2", - "description": "Mocks a call to an address, returning specified data.\nCalldata can either be strict or a partial match, e.g. if you only\npass a Solidity selector to the expected calldata, then the entire Solidity\nfunction will be mocked.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", - "declaration": "function mockCall(address callee, bytes4 data, bytes calldata returnData) external;", + "id": "parseJsonType_1", + "description": "Parses a string of JSON data at `key` and coerces it to type corresponding to `typeDescription`.", + "declaration": "function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", "visibility": "external", - "mutability": "", - "signature": "mockCall(address,bytes4,bytes)", - "selector": "0x08e0c537", + "mutability": "pure", + "signature": "parseJsonType(string,string,string)", + "selector": "0xe3f5ae33", "selectorBytes": [ - 8, - 224, - 197, - 55 + 227, + 245, + 174, + 51 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockCall_3", - "description": "Mocks a call to an address with a specific `msg.value`, returning specified data.\nCalldata match takes precedence over `msg.value` in case of ambiguity.\nOverload to pass the function selector directly `token.approve.selector` instead of `abi.encodeWithSelector(token.approve.selector)`.", - "declaration": "function mockCall(address callee, uint256 msgValue, bytes4 data, bytes calldata returnData) external;", + "id": "parseJsonUint", + "description": "Parses a string of JSON data at `key` and coerces it to `uint256`.", + "declaration": "function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);", "visibility": "external", - "mutability": "", - "signature": "mockCall(address,uint256,bytes4,bytes)", - "selector": "0xe7b36a3d", + "mutability": "pure", + "signature": "parseJsonUint(string,string)", + "selector": "0xaddde2b6", "selectorBytes": [ - 231, - 179, - 106, - 61 + 173, + 221, + 226, + 182 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockCalls_0", - "description": "Mocks multiple calls to an address, returning specified data for each call.", - "declaration": "function mockCalls(address callee, bytes calldata data, bytes[] calldata returnData) external;", + "id": "parseJsonUintArray", + "description": "Parses a string of JSON data at `key` and coerces it to `uint256[]`.", + "declaration": "function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);", "visibility": "external", - "mutability": "", - "signature": "mockCalls(address,bytes,bytes[])", - "selector": "0x5c5c3de9", + "mutability": "pure", + "signature": "parseJsonUintArray(string,string)", + "selector": "0x522074ab", "selectorBytes": [ - 92, - 92, - 61, - 233 + 82, + 32, + 116, + 171 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockCalls_1", - "description": "Mocks multiple calls to an address with a specific `msg.value`, returning specified data for each call.", - "declaration": "function mockCalls(address callee, uint256 msgValue, bytes calldata data, bytes[] calldata returnData) external;", + "id": "parseJson_0", + "description": "ABI-encodes a JSON object.", + "declaration": "function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);", "visibility": "external", - "mutability": "", - "signature": "mockCalls(address,uint256,bytes,bytes[])", - "selector": "0x08bcbae1", + "mutability": "pure", + "signature": "parseJson(string)", + "selector": "0x6a82600a", "selectorBytes": [ - 8, - 188, - 186, - 225 + 106, + 130, + 96, + 10 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "mockFunction", - "description": "Whenever a call is made to `callee` with calldata `data`, this cheatcode instead calls\n`target` with the same calldata. This functionality is similar to a delegate call made to\n`target` contract from `callee`.\nCan be used to substitute a call to a function with another implementation that captures\nthe primary logic of the original function but is easier to reason about.\nIf calldata is not a strict match then partial match by selector is attempted.", - "declaration": "function mockFunction(address callee, address target, bytes calldata data) external;", + "id": "parseJson_1", + "description": "ABI-encodes a JSON object at `key`.", + "declaration": "function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);", "visibility": "external", - "mutability": "", - "signature": "mockFunction(address,address,bytes)", - "selector": "0xadf84d21", + "mutability": "pure", + "signature": "parseJson(string,string)", + "selector": "0x85940ef1", "selectorBytes": [ - 173, - 248, - 77, - 33 + 133, + 148, + 14, + 241 ] }, - "group": "evm", + "group": "json", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "noAccessList", - "description": "Utility cheatcode to remove any EIP-2930 access list set by `accessList` cheatcode.", - "declaration": "function noAccessList() external;", + "id": "parseTomlAddress", + "description": "Parses a string of TOML data at `key` and coerces it to `address`.", + "declaration": "function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address);", "visibility": "external", - "mutability": "", - "signature": "noAccessList()", - "selector": "0x238ad778", + "mutability": "pure", + "signature": "parseTomlAddress(string,string)", + "selector": "0x65e7c844", "selectorBytes": [ - 35, - 138, - 215, - 120 + 101, + 231, + 200, + 68 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlAddressArray", + "description": "Parses a string of TOML data at `key` and coerces it to `address[]`.", + "declaration": "function parseTomlAddressArray(string calldata toml, string calldata key) external pure returns (address[] memory);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlAddressArray(string,string)", + "selector": "0x65c428e7", + "selectorBytes": [ + 101, + 196, + 40, + 231 + ] + }, + "group": "toml", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "parseTomlBool", + "description": "Parses a string of TOML data at `key` and coerces it to `bool`.", + "declaration": "function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool);", + "visibility": "external", + "mutability": "pure", + "signature": "parseTomlBool(string,string)", + "selector": "0xd30dced6", + "selectorBytes": [ + 211, + 13, + 206, + 214 ] }, - "group": "evm", + "group": "toml", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "parseAddress", - "description": "Parses the given `string` into an `address`.", - "declaration": "function parseAddress(string calldata stringifiedValue) external pure returns (address parsedValue);", + "id": "parseTomlBoolArray", + "description": "Parses a string of TOML data at `key` and coerces it to `bool[]`.", + "declaration": "function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory);", "visibility": "external", "mutability": "pure", - "signature": "parseAddress(string)", - "selector": "0xc6ce059d", + "signature": "parseTomlBoolArray(string,string)", + "selector": "0x127cfe9a", "selectorBytes": [ - 198, - 206, - 5, - 157 + 18, + 124, + 254, + 154 ] }, - "group": "string", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseBool", - "description": "Parses the given `string` into a `bool`.", - "declaration": "function parseBool(string calldata stringifiedValue) external pure returns (bool parsedValue);", + "id": "parseTomlBytes", + "description": "Parses a string of TOML data at `key` and coerces it to `bytes`.", + "declaration": "function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory);", "visibility": "external", "mutability": "pure", - "signature": "parseBool(string)", - "selector": "0x974ef924", + "signature": "parseTomlBytes(string,string)", + "selector": "0xd77bfdb9", "selectorBytes": [ - 151, - 78, - 249, - 36 + 215, + 123, + 253, + 185 ] }, - "group": "string", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseBytes", - "description": "Parses the given `string` into `bytes`.", - "declaration": "function parseBytes(string calldata stringifiedValue) external pure returns (bytes memory parsedValue);", + "id": "parseTomlBytes32", + "description": "Parses a string of TOML data at `key` and coerces it to `bytes32`.", + "declaration": "function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32);", "visibility": "external", "mutability": "pure", - "signature": "parseBytes(string)", - "selector": "0x8f5d232d", + "signature": "parseTomlBytes32(string,string)", + "selector": "0x8e214810", "selectorBytes": [ - 143, - 93, - 35, - 45 + 142, + 33, + 72, + 16 ] }, - "group": "string", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseBytes32", - "description": "Parses the given `string` into a `bytes32`.", - "declaration": "function parseBytes32(string calldata stringifiedValue) external pure returns (bytes32 parsedValue);", + "id": "parseTomlBytes32Array", + "description": "Parses a string of TOML data at `key` and coerces it to `bytes32[]`.", + "declaration": "function parseTomlBytes32Array(string calldata toml, string calldata key) external pure returns (bytes32[] memory);", "visibility": "external", "mutability": "pure", - "signature": "parseBytes32(string)", - "selector": "0x087e6e81", + "signature": "parseTomlBytes32Array(string,string)", + "selector": "0x3e716f81", "selectorBytes": [ - 8, - 126, - 110, + 62, + 113, + 111, 129 ] }, - "group": "string", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseInt", - "description": "Parses the given `string` into a `int256`.", - "declaration": "function parseInt(string calldata stringifiedValue) external pure returns (int256 parsedValue);", + "id": "parseTomlBytesArray", + "description": "Parses a string of TOML data at `key` and coerces it to `bytes[]`.", + "declaration": "function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory);", "visibility": "external", "mutability": "pure", - "signature": "parseInt(string)", - "selector": "0x42346c5e", + "signature": "parseTomlBytesArray(string,string)", + "selector": "0xb197c247", "selectorBytes": [ - 66, - 52, - 108, - 94 + 177, + 151, + 194, + 71 ] }, - "group": "string", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonAddress", - "description": "Parses a string of JSON data at `key` and coerces it to `address`.", - "declaration": "function parseJsonAddress(string calldata json, string calldata key) external pure returns (address);", + "id": "parseTomlInt", + "description": "Parses a string of TOML data at `key` and coerces it to `int256`.", + "declaration": "function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonAddress(string,string)", - "selector": "0x1e19e657", + "signature": "parseTomlInt(string,string)", + "selector": "0xc1350739", "selectorBytes": [ - 30, - 25, - 230, - 87 + 193, + 53, + 7, + 57 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonAddressArray", - "description": "Parses a string of JSON data at `key` and coerces it to `address[]`.", - "declaration": "function parseJsonAddressArray(string calldata json, string calldata key) external pure returns (address[] memory);", + "id": "parseTomlIntArray", + "description": "Parses a string of TOML data at `key` and coerces it to `int256[]`.", + "declaration": "function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonAddressArray(string,string)", - "selector": "0x2fce7883", + "signature": "parseTomlIntArray(string,string)", + "selector": "0xd3522ae6", "selectorBytes": [ - 47, - 206, - 120, - 131 + 211, + 82, + 42, + 230 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonBool", - "description": "Parses a string of JSON data at `key` and coerces it to `bool`.", - "declaration": "function parseJsonBool(string calldata json, string calldata key) external pure returns (bool);", + "id": "parseTomlKeys", + "description": "Returns an array of all the keys in a TOML table.", + "declaration": "function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonBool(string,string)", - "selector": "0x9f86dc91", + "signature": "parseTomlKeys(string,string)", + "selector": "0x812a44b2", "selectorBytes": [ - 159, - 134, - 220, - 145 + 129, + 42, + 68, + 178 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonBoolArray", - "description": "Parses a string of JSON data at `key` and coerces it to `bool[]`.", - "declaration": "function parseJsonBoolArray(string calldata json, string calldata key) external pure returns (bool[] memory);", + "id": "parseTomlString", + "description": "Parses a string of TOML data at `key` and coerces it to `string`.", + "declaration": "function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonBoolArray(string,string)", - "selector": "0x91f3b94f", + "signature": "parseTomlString(string,string)", + "selector": "0x8bb8dd43", "selectorBytes": [ - 145, - 243, - 185, - 79 + 139, + 184, + 221, + 67 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonBytes", - "description": "Parses a string of JSON data at `key` and coerces it to `bytes`.", - "declaration": "function parseJsonBytes(string calldata json, string calldata key) external pure returns (bytes memory);", + "id": "parseTomlStringArray", + "description": "Parses a string of TOML data at `key` and coerces it to `string[]`.", + "declaration": "function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonBytes(string,string)", - "selector": "0xfd921be8", + "signature": "parseTomlStringArray(string,string)", + "selector": "0x9f629281", "selectorBytes": [ - 253, + 159, + 98, 146, - 27, - 232 + 129 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonBytes32", - "description": "Parses a string of JSON data at `key` and coerces it to `bytes32`.", - "declaration": "function parseJsonBytes32(string calldata json, string calldata key) external pure returns (bytes32);", + "id": "parseTomlTypeArray", + "description": "Parses a string of TOML data at `key` and coerces it to type array corresponding to `typeDescription`.", + "declaration": "function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonBytes32(string,string)", - "selector": "0x1777e59d", + "signature": "parseTomlTypeArray(string,string,string)", + "selector": "0x49be3743", "selectorBytes": [ - 23, - 119, - 229, - 157 + 73, + 190, + 55, + 67 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonBytes32Array", - "description": "Parses a string of JSON data at `key` and coerces it to `bytes32[]`.", - "declaration": "function parseJsonBytes32Array(string calldata json, string calldata key) external pure returns (bytes32[] memory);", + "id": "parseTomlType_0", + "description": "Parses a string of TOML data and coerces it to type corresponding to `typeDescription`.", + "declaration": "function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonBytes32Array(string,string)", - "selector": "0x91c75bc3", + "signature": "parseTomlType(string,string)", + "selector": "0x47fa5e11", "selectorBytes": [ - 145, - 199, - 91, - 195 + 71, + 250, + 94, + 17 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonBytesArray", - "description": "Parses a string of JSON data at `key` and coerces it to `bytes[]`.", - "declaration": "function parseJsonBytesArray(string calldata json, string calldata key) external pure returns (bytes[] memory);", + "id": "parseTomlType_1", + "description": "Parses a string of TOML data at `key` and coerces it to type corresponding to `typeDescription`.", + "declaration": "function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", "visibility": "external", - "mutability": "pure", - "signature": "parseJsonBytesArray(string,string)", - "selector": "0x6631aa99", + "mutability": "pure", + "signature": "parseTomlType(string,string,string)", + "selector": "0xf9fa5cdb", "selectorBytes": [ - 102, - 49, - 170, - 153 + 249, + 250, + 92, + 219 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonInt", - "description": "Parses a string of JSON data at `key` and coerces it to `int256`.", - "declaration": "function parseJsonInt(string calldata json, string calldata key) external pure returns (int256);", + "id": "parseTomlUint", + "description": "Parses a string of TOML data at `key` and coerces it to `uint256`.", + "declaration": "function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonInt(string,string)", - "selector": "0x7b048ccd", + "signature": "parseTomlUint(string,string)", + "selector": "0xcc7b0487", "selectorBytes": [ + 204, 123, 4, - 140, - 205 + 135 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonIntArray", - "description": "Parses a string of JSON data at `key` and coerces it to `int256[]`.", - "declaration": "function parseJsonIntArray(string calldata json, string calldata key) external pure returns (int256[] memory);", + "id": "parseTomlUintArray", + "description": "Parses a string of TOML data at `key` and coerces it to `uint256[]`.", + "declaration": "function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonIntArray(string,string)", - "selector": "0x9983c28a", + "signature": "parseTomlUintArray(string,string)", + "selector": "0xb5df27c8", "selectorBytes": [ - 153, - 131, - 194, - 138 + 181, + 223, + 39, + 200 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonKeys", - "description": "Returns an array of all the keys in a JSON object.", - "declaration": "function parseJsonKeys(string calldata json, string calldata key) external pure returns (string[] memory keys);", + "id": "parseToml_0", + "description": "ABI-encodes a TOML table.", + "declaration": "function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonKeys(string,string)", - "selector": "0x213e4198", + "signature": "parseToml(string)", + "selector": "0x592151f0", "selectorBytes": [ + 89, 33, - 62, - 65, - 152 + 81, + 240 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonString", - "description": "Parses a string of JSON data at `key` and coerces it to `string`.", - "declaration": "function parseJsonString(string calldata json, string calldata key) external pure returns (string memory);", + "id": "parseToml_1", + "description": "ABI-encodes a TOML table at `key`.", + "declaration": "function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonString(string,string)", - "selector": "0x49c4fac8", + "signature": "parseToml(string,string)", + "selector": "0x37736e08", "selectorBytes": [ - 73, - 196, - 250, - 200 + 55, + 115, + 110, + 8 ] }, - "group": "json", + "group": "toml", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonStringArray", - "description": "Parses a string of JSON data at `key` and coerces it to `string[]`.", - "declaration": "function parseJsonStringArray(string calldata json, string calldata key) external pure returns (string[] memory);", + "id": "parseUint", + "description": "Parses the given `string` into a `uint256`.", + "declaration": "function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);", "visibility": "external", "mutability": "pure", - "signature": "parseJsonStringArray(string,string)", - "selector": "0x498fdcf4", + "signature": "parseUint(string)", + "selector": "0xfa91454d", "selectorBytes": [ - 73, - 143, - 220, - 244 + 250, + 145, + 69, + 77 ] }, - "group": "json", + "group": "string", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonTypeArray", - "description": "Parses a string of JSON data at `key` and coerces it to type array corresponding to `typeDescription`.", - "declaration": "function parseJsonTypeArray(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", + "id": "pauseGasMetering", + "description": "Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.", + "declaration": "function pauseGasMetering() external;", "visibility": "external", - "mutability": "pure", - "signature": "parseJsonTypeArray(string,string,string)", - "selector": "0x0175d535", + "mutability": "", + "signature": "pauseGasMetering()", + "selector": "0xd1a5b36f", "selectorBytes": [ - 1, - 117, - 213, - 53 + 209, + 165, + 179, + 111 ] }, - "group": "json", + "group": "evm", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonType_0", - "description": "Parses a string of JSON data and coerces it to type corresponding to `typeDescription`.", - "declaration": "function parseJsonType(string calldata json, string calldata typeDescription) external pure returns (bytes memory);", + "id": "pauseTracing", + "description": "Pauses collection of call traces. Useful in cases when you want to skip tracing of\ncomplex calls which are not useful for debugging.", + "declaration": "function pauseTracing() external view;", "visibility": "external", - "mutability": "pure", - "signature": "parseJsonType(string,string)", - "selector": "0xa9da313b", + "mutability": "view", + "signature": "pauseTracing()", + "selector": "0xc94d1f90", "selectorBytes": [ - 169, - 218, - 49, - 59 + 201, + 77, + 31, + 144 ] }, - "group": "json", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseJsonType_1", - "description": "Parses a string of JSON data at `key` and coerces it to type corresponding to `typeDescription`.", - "declaration": "function parseJsonType(string calldata json, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", + "id": "prank_0", + "description": "Sets the *next* call's `msg.sender` to be the input address.", + "declaration": "function prank(address msgSender) external;", "visibility": "external", - "mutability": "pure", - "signature": "parseJsonType(string,string,string)", - "selector": "0xe3f5ae33", + "mutability": "", + "signature": "prank(address)", + "selector": "0xca669fa7", "selectorBytes": [ - 227, - 245, - 174, - 51 + 202, + 102, + 159, + 167 ] }, - "group": "json", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "parseJsonUint", - "description": "Parses a string of JSON data at `key` and coerces it to `uint256`.", - "declaration": "function parseJsonUint(string calldata json, string calldata key) external pure returns (uint256);", + "id": "prank_1", + "description": "Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.", + "declaration": "function prank(address msgSender, address txOrigin) external;", "visibility": "external", - "mutability": "pure", - "signature": "parseJsonUint(string,string)", - "selector": "0xaddde2b6", + "mutability": "", + "signature": "prank(address,address)", + "selector": "0x47e50cce", "selectorBytes": [ - 173, - 221, - 226, - 182 + 71, + 229, + 12, + 206 ] }, - "group": "json", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "parseJsonUintArray", - "description": "Parses a string of JSON data at `key` and coerces it to `uint256[]`.", - "declaration": "function parseJsonUintArray(string calldata json, string calldata key) external pure returns (uint256[] memory);", + "id": "prank_2", + "description": "Sets the *next* delegate call's `msg.sender` to be the input address.", + "declaration": "function prank(address msgSender, bool delegateCall) external;", "visibility": "external", - "mutability": "pure", - "signature": "parseJsonUintArray(string,string)", - "selector": "0x522074ab", + "mutability": "", + "signature": "prank(address,bool)", + "selector": "0xa7f8bf5c", "selectorBytes": [ - 82, - 32, - 116, - 171 + 167, + 248, + 191, + 92 ] }, - "group": "json", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "parseJson_0", - "description": "ABI-encodes a JSON object.", - "declaration": "function parseJson(string calldata json) external pure returns (bytes memory abiEncodedData);", + "id": "prank_3", + "description": "Sets the *next* delegate call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.", + "declaration": "function prank(address msgSender, address txOrigin, bool delegateCall) external;", "visibility": "external", - "mutability": "pure", - "signature": "parseJson(string)", - "selector": "0x6a82600a", + "mutability": "", + "signature": "prank(address,address,bool)", + "selector": "0x7d73d042", "selectorBytes": [ - 106, - 130, - 96, - 10 + 125, + 115, + 208, + 66 ] }, - "group": "json", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "parseJson_1", - "description": "ABI-encodes a JSON object at `key`.", - "declaration": "function parseJson(string calldata json, string calldata key) external pure returns (bytes memory abiEncodedData);", - "visibility": "external", - "mutability": "pure", - "signature": "parseJson(string,string)", - "selector": "0x85940ef1", + "id": "prevrandao_0", + "description": "Sets `block.prevrandao`.\nNot available on EVM versions before Paris. Use `difficulty` instead.\nIf used on unsupported EVM versions it will revert.", + "declaration": "function prevrandao(bytes32 newPrevrandao) external;", + "visibility": "external", + "mutability": "", + "signature": "prevrandao(bytes32)", + "selector": "0x3b925549", "selectorBytes": [ - 133, - 148, - 14, - 241 + 59, + 146, + 85, + 73 ] }, - "group": "json", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "parseTomlAddress", - "description": "Parses a string of TOML data at `key` and coerces it to `address`.", - "declaration": "function parseTomlAddress(string calldata toml, string calldata key) external pure returns (address);", + "id": "prevrandao_1", + "description": "Sets `block.prevrandao`.\nNot available on EVM versions before Paris. Use `difficulty` instead.\nIf used on unsupported EVM versions it will revert.", + "declaration": "function prevrandao(uint256 newPrevrandao) external;", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlAddress(string,string)", - "selector": "0x65e7c844", + "mutability": "", + "signature": "prevrandao(uint256)", + "selector": "0x9cb1c0d4", "selectorBytes": [ - 101, - 231, - 200, - 68 + 156, + 177, + 192, + 212 ] }, - "group": "toml", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "parseTomlAddressArray", - "description": "Parses a string of TOML data at `key` and coerces it to `address[]`.", - "declaration": "function parseTomlAddressArray(string calldata toml, string calldata key) external pure returns (address[] memory);", + "id": "projectRoot", + "description": "Get the path of the current project root.", + "declaration": "function projectRoot() external view returns (string memory path);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlAddressArray(string,string)", - "selector": "0x65c428e7", + "mutability": "view", + "signature": "projectRoot()", + "selector": "0xd930a0e6", "selectorBytes": [ - 101, - 196, - 40, - 231 + 217, + 48, + 160, + 230 ] }, - "group": "toml", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlBool", - "description": "Parses a string of TOML data at `key` and coerces it to `bool`.", - "declaration": "function parseTomlBool(string calldata toml, string calldata key) external pure returns (bool);", + "id": "prompt", + "description": "Prompts the user for a string value in the terminal.", + "declaration": "function prompt(string calldata promptText) external returns (string memory input);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlBool(string,string)", - "selector": "0xd30dced6", + "mutability": "", + "signature": "prompt(string)", + "selector": "0x47eaf474", "selectorBytes": [ - 211, - 13, - 206, - 214 + 71, + 234, + 244, + 116 ] }, - "group": "toml", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlBoolArray", - "description": "Parses a string of TOML data at `key` and coerces it to `bool[]`.", - "declaration": "function parseTomlBoolArray(string calldata toml, string calldata key) external pure returns (bool[] memory);", + "id": "promptAddress", + "description": "Prompts the user for an address in the terminal.", + "declaration": "function promptAddress(string calldata promptText) external returns (address);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlBoolArray(string,string)", - "selector": "0x127cfe9a", + "mutability": "", + "signature": "promptAddress(string)", + "selector": "0x62ee05f4", "selectorBytes": [ - 18, - 124, - 254, - 154 + 98, + 238, + 5, + 244 ] }, - "group": "toml", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlBytes", - "description": "Parses a string of TOML data at `key` and coerces it to `bytes`.", - "declaration": "function parseTomlBytes(string calldata toml, string calldata key) external pure returns (bytes memory);", + "id": "promptSecret", + "description": "Prompts the user for a hidden string value in the terminal.", + "declaration": "function promptSecret(string calldata promptText) external returns (string memory input);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlBytes(string,string)", - "selector": "0xd77bfdb9", + "mutability": "", + "signature": "promptSecret(string)", + "selector": "0x1e279d41", "selectorBytes": [ - 215, - 123, - 253, - 185 + 30, + 39, + 157, + 65 ] }, - "group": "toml", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlBytes32", - "description": "Parses a string of TOML data at `key` and coerces it to `bytes32`.", - "declaration": "function parseTomlBytes32(string calldata toml, string calldata key) external pure returns (bytes32);", + "id": "promptSecretUint", + "description": "Prompts the user for hidden uint256 in the terminal (usually pk).", + "declaration": "function promptSecretUint(string calldata promptText) external returns (uint256);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlBytes32(string,string)", - "selector": "0x8e214810", + "mutability": "", + "signature": "promptSecretUint(string)", + "selector": "0x69ca02b7", "selectorBytes": [ - 142, - 33, - 72, - 16 + 105, + 202, + 2, + 183 ] }, - "group": "toml", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlBytes32Array", - "description": "Parses a string of TOML data at `key` and coerces it to `bytes32[]`.", - "declaration": "function parseTomlBytes32Array(string calldata toml, string calldata key) external pure returns (bytes32[] memory);", + "id": "promptUint", + "description": "Prompts the user for uint256 in the terminal.", + "declaration": "function promptUint(string calldata promptText) external returns (uint256);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlBytes32Array(string,string)", - "selector": "0x3e716f81", + "mutability": "", + "signature": "promptUint(string)", + "selector": "0x652fd489", "selectorBytes": [ - 62, - 113, - 111, - 129 + 101, + 47, + 212, + 137 ] }, - "group": "toml", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlBytesArray", - "description": "Parses a string of TOML data at `key` and coerces it to `bytes[]`.", - "declaration": "function parseTomlBytesArray(string calldata toml, string calldata key) external pure returns (bytes[] memory);", + "id": "publicKeyP256", + "description": "Derives secp256r1 public key from the provided `privateKey`.", + "declaration": "function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);", "visibility": "external", "mutability": "pure", - "signature": "parseTomlBytesArray(string,string)", - "selector": "0xb197c247", + "signature": "publicKeyP256(uint256)", + "selector": "0xc453949e", "selectorBytes": [ - 177, - 151, - 194, - 71 + 196, + 83, + 148, + 158 ] }, - "group": "toml", + "group": "crypto", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlInt", - "description": "Parses a string of TOML data at `key` and coerces it to `int256`.", - "declaration": "function parseTomlInt(string calldata toml, string calldata key) external pure returns (int256);", + "id": "randomAddress", + "description": "Returns a random `address`.", + "declaration": "function randomAddress() external view returns (address);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlInt(string,string)", - "selector": "0xc1350739", + "mutability": "view", + "signature": "randomAddress()", + "selector": "0xd5bee9f5", "selectorBytes": [ - 193, - 53, - 7, - 57 + 213, + 190, + 233, + 245 ] }, - "group": "toml", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlIntArray", - "description": "Parses a string of TOML data at `key` and coerces it to `int256[]`.", - "declaration": "function parseTomlIntArray(string calldata toml, string calldata key) external pure returns (int256[] memory);", + "id": "randomBool", + "description": "Returns a random `bool`.", + "declaration": "function randomBool() external view returns (bool);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlIntArray(string,string)", - "selector": "0xd3522ae6", + "mutability": "view", + "signature": "randomBool()", + "selector": "0xcdc126bd", "selectorBytes": [ - 211, - 82, - 42, - 230 + 205, + 193, + 38, + 189 ] }, - "group": "toml", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlKeys", - "description": "Returns an array of all the keys in a TOML table.", - "declaration": "function parseTomlKeys(string calldata toml, string calldata key) external pure returns (string[] memory keys);", + "id": "randomBytes", + "description": "Returns a random byte array value of the given length.", + "declaration": "function randomBytes(uint256 len) external view returns (bytes memory);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlKeys(string,string)", - "selector": "0x812a44b2", + "mutability": "view", + "signature": "randomBytes(uint256)", + "selector": "0x6c5d32a9", "selectorBytes": [ - 129, - 42, - 68, - 178 + 108, + 93, + 50, + 169 ] }, - "group": "toml", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlString", - "description": "Parses a string of TOML data at `key` and coerces it to `string`.", - "declaration": "function parseTomlString(string calldata toml, string calldata key) external pure returns (string memory);", + "id": "randomBytes4", + "description": "Returns a random fixed-size byte array of length 4.", + "declaration": "function randomBytes4() external view returns (bytes4);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlString(string,string)", - "selector": "0x8bb8dd43", + "mutability": "view", + "signature": "randomBytes4()", + "selector": "0x9b7cd579", "selectorBytes": [ - 139, - 184, - 221, - 67 + 155, + 124, + 213, + 121 ] }, - "group": "toml", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlStringArray", - "description": "Parses a string of TOML data at `key` and coerces it to `string[]`.", - "declaration": "function parseTomlStringArray(string calldata toml, string calldata key) external pure returns (string[] memory);", + "id": "randomBytes8", + "description": "Returns a random fixed-size byte array of length 8.", + "declaration": "function randomBytes8() external view returns (bytes8);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlStringArray(string,string)", - "selector": "0x9f629281", + "mutability": "view", + "signature": "randomBytes8()", + "selector": "0x0497b0a5", "selectorBytes": [ - 159, - 98, - 146, - 129 + 4, + 151, + 176, + 165 ] }, - "group": "toml", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlTypeArray", - "description": "Parses a string of TOML data at `key` and coerces it to type array corresponding to `typeDescription`.", - "declaration": "function parseTomlTypeArray(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", + "id": "randomInt_0", + "description": "Returns a random `int256` value.", + "declaration": "function randomInt() external view returns (int256);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlTypeArray(string,string,string)", - "selector": "0x49be3743", + "mutability": "view", + "signature": "randomInt()", + "selector": "0x111f1202", "selectorBytes": [ - 73, - 190, - 55, - 67 + 17, + 31, + 18, + 2 ] }, - "group": "toml", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlType_0", - "description": "Parses a string of TOML data and coerces it to type corresponding to `typeDescription`.", - "declaration": "function parseTomlType(string calldata toml, string calldata typeDescription) external pure returns (bytes memory);", + "id": "randomInt_1", + "description": "Returns a random `int256` value of given bits.", + "declaration": "function randomInt(uint256 bits) external view returns (int256);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlType(string,string)", - "selector": "0x47fa5e11", + "mutability": "view", + "signature": "randomInt(uint256)", + "selector": "0x12845966", "selectorBytes": [ - 71, - 250, - 94, - 17 + 18, + 132, + 89, + 102 ] }, - "group": "toml", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlType_1", - "description": "Parses a string of TOML data at `key` and coerces it to type corresponding to `typeDescription`.", - "declaration": "function parseTomlType(string calldata toml, string calldata key, string calldata typeDescription) external pure returns (bytes memory);", + "id": "randomUint_0", + "description": "Returns a random uint256 value.", + "declaration": "function randomUint() external view returns (uint256);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlType(string,string,string)", - "selector": "0xf9fa5cdb", + "mutability": "view", + "signature": "randomUint()", + "selector": "0x25124730", "selectorBytes": [ - 249, - 250, - 92, - 219 + 37, + 18, + 71, + 48 ] }, - "group": "toml", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlUint", - "description": "Parses a string of TOML data at `key` and coerces it to `uint256`.", - "declaration": "function parseTomlUint(string calldata toml, string calldata key) external pure returns (uint256);", + "id": "randomUint_1", + "description": "Returns random uint256 value between the provided range (=min..=max).", + "declaration": "function randomUint(uint256 min, uint256 max) external view returns (uint256);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlUint(string,string)", - "selector": "0xcc7b0487", + "mutability": "view", + "signature": "randomUint(uint256,uint256)", + "selector": "0xd61b051b", "selectorBytes": [ - 204, - 123, - 4, - 135 + 214, + 27, + 5, + 27 ] }, - "group": "toml", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseTomlUintArray", - "description": "Parses a string of TOML data at `key` and coerces it to `uint256[]`.", - "declaration": "function parseTomlUintArray(string calldata toml, string calldata key) external pure returns (uint256[] memory);", + "id": "randomUint_2", + "description": "Returns a random `uint256` value of given bits.", + "declaration": "function randomUint(uint256 bits) external view returns (uint256);", "visibility": "external", - "mutability": "pure", - "signature": "parseTomlUintArray(string,string)", - "selector": "0xb5df27c8", + "mutability": "view", + "signature": "randomUint(uint256)", + "selector": "0xcf81e69c", "selectorBytes": [ - 181, - 223, - 39, - 200 + 207, + 129, + 230, + 156 ] }, - "group": "toml", + "group": "utilities", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseToml_0", - "description": "ABI-encodes a TOML table.", - "declaration": "function parseToml(string calldata toml) external pure returns (bytes memory abiEncodedData);", + "id": "readCallers", + "description": "Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification.", + "declaration": "function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);", "visibility": "external", - "mutability": "pure", - "signature": "parseToml(string)", - "selector": "0x592151f0", + "mutability": "", + "signature": "readCallers()", + "selector": "0x4ad0bac9", "selectorBytes": [ - 89, - 33, - 81, - 240 + 74, + 208, + 186, + 201 ] }, - "group": "toml", + "group": "evm", "status": "stable", - "safety": "safe" + "safety": "unsafe" }, { "func": { - "id": "parseToml_1", - "description": "ABI-encodes a TOML table at `key`.", - "declaration": "function parseToml(string calldata toml, string calldata key) external pure returns (bytes memory abiEncodedData);", + "id": "readDir_0", + "description": "Reads the directory at the given path recursively, up to `maxDepth`.\n`maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned.\nFollows symbolic links if `followLinks` is true.", + "declaration": "function readDir(string calldata path) external view returns (DirEntry[] memory entries);", "visibility": "external", - "mutability": "pure", - "signature": "parseToml(string,string)", - "selector": "0x37736e08", + "mutability": "view", + "signature": "readDir(string)", + "selector": "0xc4bc59e0", "selectorBytes": [ - 55, - 115, - 110, - 8 + 196, + 188, + 89, + 224 ] }, - "group": "toml", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "parseUint", - "description": "Parses the given `string` into a `uint256`.", - "declaration": "function parseUint(string calldata stringifiedValue) external pure returns (uint256 parsedValue);", + "id": "readDir_1", + "description": "See `readDir(string)`.", + "declaration": "function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);", "visibility": "external", - "mutability": "pure", - "signature": "parseUint(string)", - "selector": "0xfa91454d", + "mutability": "view", + "signature": "readDir(string,uint64)", + "selector": "0x1497876c", "selectorBytes": [ - 250, - 145, - 69, - 77 + 20, + 151, + 135, + 108 ] }, - "group": "string", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "pauseGasMetering", - "description": "Pauses gas metering (i.e. gas usage is not counted). Noop if already paused.", - "declaration": "function pauseGasMetering() external;", + "id": "readDir_2", + "description": "See `readDir(string)`.", + "declaration": "function readDir(string calldata path, uint64 maxDepth, bool followLinks) external view returns (DirEntry[] memory entries);", "visibility": "external", - "mutability": "", - "signature": "pauseGasMetering()", - "selector": "0xd1a5b36f", + "mutability": "view", + "signature": "readDir(string,uint64,bool)", + "selector": "0x8102d70d", "selectorBytes": [ - 209, - 165, - 179, - 111 + 129, + 2, + 215, + 13 ] }, - "group": "evm", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "pauseTracing", - "description": "Pauses collection of call traces. Useful in cases when you want to skip tracing of\ncomplex calls which are not useful for debugging.", - "declaration": "function pauseTracing() external view;", + "id": "readFile", + "description": "Reads the entire content of file to string. `path` is relative to the project root.", + "declaration": "function readFile(string calldata path) external view returns (string memory data);", "visibility": "external", "mutability": "view", - "signature": "pauseTracing()", - "selector": "0xc94d1f90", + "signature": "readFile(string)", + "selector": "0x60f9bb11", "selectorBytes": [ - 201, - 77, - 31, - 144 + 96, + 249, + 187, + 17 ] }, - "group": "utilities", + "group": "filesystem", "status": "stable", "safety": "safe" }, { "func": { - "id": "prank_0", - "description": "Sets the *next* call's `msg.sender` to be the input address.", - "declaration": "function prank(address msgSender) external;", + "id": "readFileBinary", + "description": "Reads the entire content of file as binary. `path` is relative to the project root.", + "declaration": "function readFileBinary(string calldata path) external view returns (bytes memory data);", "visibility": "external", - "mutability": "", - "signature": "prank(address)", - "selector": "0xca669fa7", + "mutability": "view", + "signature": "readFileBinary(string)", + "selector": "0x16ed7bc4", "selectorBytes": [ - 202, - 102, - 159, - 167 + 22, + 237, + 123, + 196 ] }, - "group": "evm", + "group": "filesystem", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "prank_1", - "description": "Sets the *next* call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.", - "declaration": "function prank(address msgSender, address txOrigin) external;", + "id": "readForkAddress", + "description": "Gets the value for the key `key` from the currently active fork and parses it as `address`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkAddress(string calldata key) external view returns (address);", "visibility": "external", - "mutability": "", - "signature": "prank(address,address)", - "selector": "0x47e50cce", + "mutability": "view", + "signature": "readForkAddress(string)", + "selector": "0x80ab4bca", "selectorBytes": [ - 71, - 229, - 12, - 206 + 128, + 171, + 75, + 202 ] }, - "group": "evm", + "group": "forking", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "prank_2", - "description": "Sets the *next* delegate call's `msg.sender` to be the input address.", - "declaration": "function prank(address msgSender, bool delegateCall) external;", + "id": "readForkAddressArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `address`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkAddressArray(string calldata key) external view returns (address[] memory);", "visibility": "external", - "mutability": "", - "signature": "prank(address,bool)", - "selector": "0xa7f8bf5c", + "mutability": "view", + "signature": "readForkAddressArray(string)", + "selector": "0x3c69b4e5", "selectorBytes": [ - 167, - 248, - 191, - 92 + 60, + 105, + 180, + 229 ] }, - "group": "evm", + "group": "forking", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "prank_3", - "description": "Sets the *next* delegate call's `msg.sender` to be the input address, and the `tx.origin` to be the second input.", - "declaration": "function prank(address msgSender, address txOrigin, bool delegateCall) external;", + "id": "readForkBool", + "description": "Gets the value for the key `key` from the currently active fork and parses it as `bool`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkBool(string calldata key) external view returns (bool);", "visibility": "external", - "mutability": "", - "signature": "prank(address,address,bool)", - "selector": "0x7d73d042", + "mutability": "view", + "signature": "readForkBool(string)", + "selector": "0x59d46fc3", "selectorBytes": [ - 125, - 115, - 208, - 66 + 89, + 212, + 111, + 195 ] }, - "group": "evm", + "group": "forking", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "prevrandao_0", - "description": "Sets `block.prevrandao`.\nNot available on EVM versions before Paris. Use `difficulty` instead.\nIf used on unsupported EVM versions it will revert.", - "declaration": "function prevrandao(bytes32 newPrevrandao) external;", + "id": "readForkBoolArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bool`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkBoolArray(string calldata key) external view returns (bool[] memory);", "visibility": "external", - "mutability": "", - "signature": "prevrandao(bytes32)", - "selector": "0x3b925549", + "mutability": "view", + "signature": "readForkBoolArray(string)", + "selector": "0x31313ddd", "selectorBytes": [ - 59, - 146, - 85, - 73 + 49, + 49, + 61, + 221 ] }, - "group": "evm", + "group": "forking", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "prevrandao_1", - "description": "Sets `block.prevrandao`.\nNot available on EVM versions before Paris. Use `difficulty` instead.\nIf used on unsupported EVM versions it will revert.", - "declaration": "function prevrandao(uint256 newPrevrandao) external;", + "id": "readForkBytes", + "description": "Gets the value for the key `key` from the currently active fork and parses it as `bytes`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkBytes(string calldata key) external view returns (bytes memory);", "visibility": "external", - "mutability": "", - "signature": "prevrandao(uint256)", - "selector": "0x9cb1c0d4", + "mutability": "view", + "signature": "readForkBytes(string)", + "selector": "0xf577b434", "selectorBytes": [ - 156, - 177, - 192, - 212 + 245, + 119, + 180, + 52 ] }, - "group": "evm", + "group": "forking", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "projectRoot", - "description": "Get the path of the current project root.", - "declaration": "function projectRoot() external view returns (string memory path);", + "id": "readForkBytes32", + "description": "Gets the value for the key `key` from the currently active fork and parses it as `bytes32`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkBytes32(string calldata key) external view returns (bytes32);", "visibility": "external", "mutability": "view", - "signature": "projectRoot()", - "selector": "0xd930a0e6", + "signature": "readForkBytes32(string)", + "selector": "0x98d86b9f", "selectorBytes": [ - 217, - 48, - 160, - 230 + 152, + 216, + 107, + 159 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "prompt", - "description": "Prompts the user for a string value in the terminal.", - "declaration": "function prompt(string calldata promptText) external returns (string memory input);", + "id": "readForkBytes32Array", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes32`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkBytes32Array(string calldata key) external view returns (bytes32[] memory);", "visibility": "external", - "mutability": "", - "signature": "prompt(string)", - "selector": "0x47eaf474", + "mutability": "view", + "signature": "readForkBytes32Array(string)", + "selector": "0x31233ae7", "selectorBytes": [ - 71, - 234, - 244, - 116 + 49, + 35, + 58, + 231 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "promptAddress", - "description": "Prompts the user for an address in the terminal.", - "declaration": "function promptAddress(string calldata promptText) external returns (address);", + "id": "readForkBytesArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkBytesArray(string calldata key) external view returns (bytes[] memory);", "visibility": "external", - "mutability": "", - "signature": "promptAddress(string)", - "selector": "0x62ee05f4", + "mutability": "view", + "signature": "readForkBytesArray(string)", + "selector": "0xb8355047", "selectorBytes": [ - 98, - 238, - 5, - 244 + 184, + 53, + 80, + 71 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "promptSecret", - "description": "Prompts the user for a hidden string value in the terminal.", - "declaration": "function promptSecret(string calldata promptText) external returns (string memory input);", + "id": "readForkChainAddress", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `address`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkChainAddress(uint256 chain, string calldata key) external view returns (address);", "visibility": "external", - "mutability": "", - "signature": "promptSecret(string)", - "selector": "0x1e279d41", + "mutability": "view", + "signature": "readForkChainAddress(uint256,string)", + "selector": "0xada12db3", "selectorBytes": [ - 30, - 39, - 157, - 65 + 173, + 161, + 45, + 179 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "promptSecretUint", - "description": "Prompts the user for hidden uint256 in the terminal (usually pk).", - "declaration": "function promptSecretUint(string calldata promptText) external returns (uint256);", + "id": "readForkChainAddressArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `address`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory);", "visibility": "external", - "mutability": "", - "signature": "promptSecretUint(string)", - "selector": "0x69ca02b7", + "mutability": "view", + "signature": "readForkChainAddressArray(uint256,string)", + "selector": "0x563ee150", "selectorBytes": [ - 105, - 202, - 2, - 183 + 86, + 62, + 225, + 80 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "promptUint", - "description": "Prompts the user for uint256 in the terminal.", - "declaration": "function promptUint(string calldata promptText) external returns (uint256);", + "id": "readForkChainBool", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bool`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkChainBool(uint256 chain, string calldata key) external view returns (bool);", "visibility": "external", - "mutability": "", - "signature": "promptUint(string)", - "selector": "0x652fd489", + "mutability": "view", + "signature": "readForkChainBool(uint256,string)", + "selector": "0x60f0d22d", "selectorBytes": [ - 101, - 47, - 212, - 137 + 96, + 240, + 210, + 45 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "publicKeyP256", - "description": "Derives secp256r1 public key from the provided `privateKey`.", - "declaration": "function publicKeyP256(uint256 privateKey) external pure returns (uint256 publicKeyX, uint256 publicKeyY);", + "id": "readForkChainBoolArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bool`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory);", "visibility": "external", - "mutability": "pure", - "signature": "publicKeyP256(uint256)", - "selector": "0xc453949e", + "mutability": "view", + "signature": "readForkChainBoolArray(uint256,string)", + "selector": "0x7890a287", "selectorBytes": [ - 196, - 83, - 148, - 158 + 120, + 144, + 162, + 135 ] }, - "group": "crypto", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "randomAddress", - "description": "Returns a random `address`.", - "declaration": "function randomAddress() external view returns (address);", + "id": "readForkChainBytes", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bytes`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkChainBytes(uint256 chain, string calldata key) external view returns (bytes memory);", "visibility": "external", "mutability": "view", - "signature": "randomAddress()", - "selector": "0xd5bee9f5", + "signature": "readForkChainBytes(uint256,string)", + "selector": "0x26a8a87b", "selectorBytes": [ - 213, - 190, - 233, - 245 + 38, + 168, + 168, + 123 ] }, - "group": "utilities", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "randomBool", - "description": "Returns a random `bool`.", - "declaration": "function randomBool() external view returns (bool);", + "id": "readForkChainBytes32", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bytes32`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32);", "visibility": "external", "mutability": "view", - "signature": "randomBool()", - "selector": "0xcdc126bd", + "signature": "readForkChainBytes32(uint256,string)", + "selector": "0x3b94101d", "selectorBytes": [ - 205, - 193, - 38, - 189 + 59, + 148, + 16, + 29 ] }, - "group": "utilities", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "randomBytes", - "description": "Returns a random byte array value of the given length.", - "declaration": "function randomBytes(uint256 len) external view returns (bytes memory);", + "id": "readForkChainBytes32Array", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes32`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory);", "visibility": "external", "mutability": "view", - "signature": "randomBytes(uint256)", - "selector": "0x6c5d32a9", + "signature": "readForkChainBytes32Array(uint256,string)", + "selector": "0x1557cfd5", "selectorBytes": [ - 108, - 93, - 50, - 169 + 21, + 87, + 207, + 213 ] }, - "group": "utilities", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "randomBytes4", - "description": "Returns a random fixed-size byte array of length 4.", - "declaration": "function randomBytes4() external view returns (bytes4);", + "id": "readForkChainBytesArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory);", "visibility": "external", "mutability": "view", - "signature": "randomBytes4()", - "selector": "0x9b7cd579", + "signature": "readForkChainBytesArray(uint256,string)", + "selector": "0xbdcc82ec", "selectorBytes": [ - 155, - 124, - 213, - 121 + 189, + 204, + 130, + 236 ] }, - "group": "utilities", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "randomBytes8", - "description": "Returns a random fixed-size byte array of length 8.", - "declaration": "function randomBytes8() external view returns (bytes8);", + "id": "readForkChainInt", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `int256`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkChainInt(uint256 chain, string calldata key) external view returns (int256);", "visibility": "external", "mutability": "view", - "signature": "randomBytes8()", - "selector": "0x0497b0a5", + "signature": "readForkChainInt(uint256,string)", + "selector": "0x2f0cb2a2", "selectorBytes": [ - 4, - 151, - 176, - 165 + 47, + 12, + 178, + 162 ] }, - "group": "utilities", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "randomInt_0", - "description": "Returns a random `int256` value.", - "declaration": "function randomInt() external view returns (int256);", + "id": "readForkChainIntArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `int256`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory);", "visibility": "external", "mutability": "view", - "signature": "randomInt()", - "selector": "0x111f1202", + "signature": "readForkChainIntArray(uint256,string)", + "selector": "0xf47ef264", "selectorBytes": [ - 17, - 31, - 18, - 2 + 244, + 126, + 242, + 100 ] }, - "group": "utilities", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "randomInt_1", - "description": "Returns a random `int256` value of given bits.", - "declaration": "function randomInt(uint256 bits) external view returns (int256);", + "id": "readForkChainString", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `string`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkChainString(uint256 chain, string calldata key) external view returns (string memory);", "visibility": "external", "mutability": "view", - "signature": "randomInt(uint256)", - "selector": "0x12845966", + "signature": "readForkChainString(uint256,string)", + "selector": "0xf82a7685", "selectorBytes": [ - 18, - 132, - 89, - 102 + 248, + 42, + 118, + 133 ] }, - "group": "utilities", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "randomUint_0", - "description": "Returns a random uint256 value.", - "declaration": "function randomUint() external view returns (uint256);", + "id": "readForkChainStringArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `string`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory);", "visibility": "external", "mutability": "view", - "signature": "randomUint()", - "selector": "0x25124730", + "signature": "readForkChainStringArray(uint256,string)", + "selector": "0x03505f56", "selectorBytes": [ - 37, - 18, - 71, - 48 + 3, + 80, + 95, + 86 ] }, - "group": "utilities", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "randomUint_1", - "description": "Returns random uint256 value between the provided range (=min..=max).", - "declaration": "function randomUint(uint256 min, uint256 max) external view returns (uint256);", + "id": "readForkChainUint", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `uint256`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkChainUint(uint256 chain, string calldata key) external view returns (uint256);", "visibility": "external", "mutability": "view", - "signature": "randomUint(uint256,uint256)", - "selector": "0xd61b051b", + "signature": "readForkChainUint(uint256,string)", + "selector": "0x1b7eda4d", "selectorBytes": [ - 214, 27, - 5, - 27 + 126, + 218, + 77 ] }, - "group": "utilities", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "randomUint_2", - "description": "Returns a random `uint256` value of given bits.", - "declaration": "function randomUint(uint256 bits) external view returns (uint256);", + "id": "readForkChainUintArray", + "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `uint256`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory);", "visibility": "external", "mutability": "view", - "signature": "randomUint(uint256)", - "selector": "0xcf81e69c", + "signature": "readForkChainUintArray(uint256,string)", + "selector": "0xda7509b4", "selectorBytes": [ - 207, - 129, - 230, - 156 + 218, + 117, + 9, + 180 ] }, - "group": "utilities", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "readCallers", - "description": "Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification.", - "declaration": "function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);", + "id": "readForkInt", + "description": "Gets the value for the key `key` from the currently active fork and parses it as `int256`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkInt(string calldata key) external view returns (int256);", "visibility": "external", - "mutability": "", - "signature": "readCallers()", - "selector": "0x4ad0bac9", + "mutability": "view", + "signature": "readForkInt(string)", + "selector": "0xdbfced07", "selectorBytes": [ - 74, - 208, - 186, - 201 + 219, + 252, + 237, + 7 ] }, - "group": "evm", + "group": "forking", "status": "stable", - "safety": "unsafe" + "safety": "safe" }, { "func": { - "id": "readDir_0", - "description": "Reads the directory at the given path recursively, up to `maxDepth`.\n`maxDepth` defaults to 1, meaning only the direct children of the given directory will be returned.\nFollows symbolic links if `followLinks` is true.", - "declaration": "function readDir(string calldata path) external view returns (DirEntry[] memory entries);", + "id": "readForkIntArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `int256`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkIntArray(string calldata key) external view returns (int256[] memory);", "visibility": "external", "mutability": "view", - "signature": "readDir(string)", - "selector": "0xc4bc59e0", + "signature": "readForkIntArray(string)", + "selector": "0xd06f1229", "selectorBytes": [ - 196, - 188, - 89, - 224 + 208, + 111, + 18, + 41 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "readDir_1", - "description": "See `readDir(string)`.", - "declaration": "function readDir(string calldata path, uint64 maxDepth) external view returns (DirEntry[] memory entries);", + "id": "readForkString", + "description": "Gets the value for the key `key` from the currently active fork and parses it as `string`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkString(string calldata key) external view returns (string memory);", "visibility": "external", "mutability": "view", - "signature": "readDir(string,uint64)", - "selector": "0x1497876c", + "signature": "readForkString(string)", + "selector": "0xbdb621a5", "selectorBytes": [ - 20, - 151, - 135, - 108 + 189, + 182, + 33, + 165 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "readDir_2", - "description": "See `readDir(string)`.", - "declaration": "function readDir(string calldata path, uint64 maxDepth, bool followLinks) external view returns (DirEntry[] memory entries);", + "id": "readForkStringArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `string`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkStringArray(string calldata key) external view returns (string[] memory);", "visibility": "external", "mutability": "view", - "signature": "readDir(string,uint64,bool)", - "selector": "0x8102d70d", + "signature": "readForkStringArray(string)", + "selector": "0x3b469f94", "selectorBytes": [ - 129, - 2, - 215, - 13 + 59, + 70, + 159, + 148 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "readFile", - "description": "Reads the entire content of file to string. `path` is relative to the project root.", - "declaration": "function readFile(string calldata path) external view returns (string memory data);", + "id": "readForkUint", + "description": "Gets the value for the key `key` from the currently active fork and parses it as `uint256`.\nReverts if the key was not found or the value could not be parsed.", + "declaration": "function readForkUint(string calldata key) external view returns (uint256);", "visibility": "external", "mutability": "view", - "signature": "readFile(string)", - "selector": "0x60f9bb11", + "signature": "readForkUint(string)", + "selector": "0x28a1e7fe", "selectorBytes": [ - 96, - 249, - 187, - 17 + 40, + 161, + 231, + 254 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, { "func": { - "id": "readFileBinary", - "description": "Reads the entire content of file as binary. `path` is relative to the project root.", - "declaration": "function readFileBinary(string calldata path) external view returns (bytes memory data);", + "id": "readForkUintArray", + "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `uint256`.\nReverts if a key was not found or any of the values could not be parsed.", + "declaration": "function readForkUintArray(string calldata key) external view returns (uint256[] memory);", "visibility": "external", "mutability": "view", - "signature": "readFileBinary(string)", - "selector": "0x16ed7bc4", + "signature": "readForkUintArray(string)", + "selector": "0xac032c02", "selectorBytes": [ - 22, - 237, - 123, - 196 + 172, + 3, + 44, + 2 ] }, - "group": "filesystem", + "group": "forking", "status": "stable", "safety": "safe" }, diff --git a/crates/cheatcodes/assets/cheatcodes.schema.json b/crates/cheatcodes/assets/cheatcodes.schema.json index ef0e061b22764..83d4663bee42e 100644 --- a/crates/cheatcodes/assets/cheatcodes.schema.json +++ b/crates/cheatcodes/assets/cheatcodes.schema.json @@ -242,7 +242,7 @@ "const": "scripting" }, { - "description": "Cheatcodes that interact with the program's forking configuration.\n\nExamples: `forkChains`, `forkChainRpcUrl`, `forkUint`.\n\nSafety: safe.", + "description": "Cheatcodes that interact with the program's forking configuration.\n\nExamples: `forkChains`, `forkChainRpcUrl`, `readForkUint`.\n\nSafety: safe.", "type": "string", "const": "forking" }, diff --git a/crates/cheatcodes/spec/src/cheatcode.rs b/crates/cheatcodes/spec/src/cheatcode.rs index 216adb4aa84b2..805dc06b0aa92 100644 --- a/crates/cheatcodes/spec/src/cheatcode.rs +++ b/crates/cheatcodes/spec/src/cheatcode.rs @@ -88,7 +88,7 @@ pub enum Group { Scripting, /// Cheatcodes that interact with the program's forking configuration. /// - /// Examples: `forkChains`, `forkChainRpcUrl`, `forkUint`. + /// Examples: `forkChains`, `forkChainRpcUrl`, `readForkUint`, `readForkAddressArray`. /// /// Safety: safe. Forking, diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 2c881e7a349a7..9ddc13ca6d91f 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2222,142 +2222,142 @@ interface Vm { /// Gets the value for the key `key` from the currently active fork and parses it as `bool`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkBool(string calldata key) external view returns (bool); + function readForkBool(string calldata key) external view returns (bool); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bool`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkChainBool(uint256 chain, string calldata key) external view returns (bool); + function readForkChainBool(uint256 chain, string calldata key) external view returns (bool); /// Gets the value for the key `key` from the currently active fork and parses it as an array of `bool`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkBoolArray(string calldata key) external view returns (bool[] memory); + function readForkBoolArray(string calldata key) external view returns (bool[] memory); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bool`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory); + function readForkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory); /// Gets the value for the key `key` from the currently active fork and parses it as `int256`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkInt(string calldata key) external view returns (int256); + function readForkInt(string calldata key) external view returns (int256); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `int256`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkChainInt(uint256 chain, string calldata key) external view returns (int256); + function readForkChainInt(uint256 chain, string calldata key) external view returns (int256); /// Gets the value for the key `key` from the currently active fork and parses it as an array of `int256`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkIntArray(string calldata key) external view returns (int256[] memory); + function readForkIntArray(string calldata key) external view returns (int256[] memory); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `int256`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory); + function readForkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory); /// Gets the value for the key `key` from the currently active fork and parses it as `uint256`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkUint(string calldata key) external view returns (uint256); + function readForkUint(string calldata key) external view returns (uint256); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `uint256`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkChainUint(uint256 chain, string calldata key) external view returns (uint256); + function readForkChainUint(uint256 chain, string calldata key) external view returns (uint256); /// Gets the value for the key `key` from the currently active fork and parses it as an array of `uint256`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkUintArray(string calldata key) external view returns (uint256[] memory); + function readForkUintArray(string calldata key) external view returns (uint256[] memory); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `uint256`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory); + function readForkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory); /// Gets the value for the key `key` from the currently active fork and parses it as `address`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkAddress(string calldata key) external view returns (address); + function readForkAddress(string calldata key) external view returns (address); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `address`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkChainAddress(uint256 chain, string calldata key) external view returns (address); + function readForkChainAddress(uint256 chain, string calldata key) external view returns (address); /// Gets the value for the key `key` from the currently active fork and parses it as an array of `address`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkAddressArray(string calldata key) external view returns (address[] memory); + function readForkAddressArray(string calldata key) external view returns (address[] memory); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `address`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory); + function readForkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory); /// Gets the value for the key `key` from the currently active fork and parses it as `bytes32`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkBytes32(string calldata key) external view returns (bytes32); + function readForkBytes32(string calldata key) external view returns (bytes32); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bytes32`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32); + function readForkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32); /// Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes32`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkBytes32Array(string calldata key) external view returns (bytes32[] memory); + function readForkBytes32Array(string calldata key) external view returns (bytes32[] memory); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes32`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory); + function readForkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory); /// Gets the value for the key `key` from the currently active fork and parses it as `string`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkString(string calldata key) external view returns (string memory); + function readForkString(string calldata key) external view returns (string memory); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `string`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkChainString(uint256 chain, string calldata key) external view returns (string memory); + function readForkChainString(uint256 chain, string calldata key) external view returns (string memory); /// Gets the value for the key `key` from the currently active fork and parses it as an array of `string`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkStringArray(string calldata key) external view returns (string[] memory); + function readForkStringArray(string calldata key) external view returns (string[] memory); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `string`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory); + function readForkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory); /// Gets the value for the key `key` from the currently active fork and parses it as `bytes`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkBytes(string calldata key) external view returns (bytes memory); + function readForkBytes(string calldata key) external view returns (bytes memory); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bytes`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] - function forkChainBytes(uint256 chain, string calldata key) external view returns (bytes memory); + function readForkChainBytes(uint256 chain, string calldata key) external view returns (bytes memory); /// Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkBytesArray(string calldata key) external view returns (bytes[] memory); + function readForkBytesArray(string calldata key) external view returns (bytes[] memory); /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] - function forkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory); + function readForkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory); // ======== Scripts ======== // -------- Broadcasting Transactions -------- diff --git a/crates/cheatcodes/src/fork.rs b/crates/cheatcodes/src/fork.rs index 9aa20979c62d4..506776bd3080c 100644 --- a/crates/cheatcodes/src/fork.rs +++ b/crates/cheatcodes/src/fork.rs @@ -143,46 +143,46 @@ macro_rules! impl_get_array_cheatcode { } // Bool -impl_get_value_cheatcode!(forkChainBoolCall, &DynSolType::Bool); -impl_get_value_cheatcode!(forkBoolCall, &DynSolType::Bool, stateful); -impl_get_array_cheatcode!(forkChainBoolArrayCall, &DynSolType::Bool); -impl_get_array_cheatcode!(forkBoolArrayCall, &DynSolType::Bool, stateful); +impl_get_value_cheatcode!(readForkChainBoolCall, &DynSolType::Bool); +impl_get_value_cheatcode!(readForkBoolCall, &DynSolType::Bool, stateful); +impl_get_array_cheatcode!(readForkChainBoolArrayCall, &DynSolType::Bool); +impl_get_array_cheatcode!(readForkBoolArrayCall, &DynSolType::Bool, stateful); // Int -impl_get_value_cheatcode!(forkChainIntCall, &DynSolType::Int(256)); -impl_get_value_cheatcode!(forkIntCall, &DynSolType::Int(256), stateful); -impl_get_array_cheatcode!(forkChainIntArrayCall, &DynSolType::Int(256)); -impl_get_array_cheatcode!(forkIntArrayCall, &DynSolType::Int(256), stateful); +impl_get_value_cheatcode!(readForkChainIntCall, &DynSolType::Int(256)); +impl_get_value_cheatcode!(readForkIntCall, &DynSolType::Int(256), stateful); +impl_get_array_cheatcode!(readForkChainIntArrayCall, &DynSolType::Int(256)); +impl_get_array_cheatcode!(readForkIntArrayCall, &DynSolType::Int(256), stateful); // Uint -impl_get_value_cheatcode!(forkChainUintCall, &DynSolType::Uint(256)); -impl_get_value_cheatcode!(forkUintCall, &DynSolType::Uint(256), stateful); -impl_get_array_cheatcode!(forkChainUintArrayCall, &DynSolType::Uint(256)); -impl_get_array_cheatcode!(forkUintArrayCall, &DynSolType::Uint(256), stateful); +impl_get_value_cheatcode!(readForkChainUintCall, &DynSolType::Uint(256)); +impl_get_value_cheatcode!(readForkUintCall, &DynSolType::Uint(256), stateful); +impl_get_array_cheatcode!(readForkChainUintArrayCall, &DynSolType::Uint(256)); +impl_get_array_cheatcode!(readForkUintArrayCall, &DynSolType::Uint(256), stateful); // Address -impl_get_value_cheatcode!(forkChainAddressCall, &DynSolType::Address); -impl_get_value_cheatcode!(forkAddressCall, &DynSolType::Address, stateful); -impl_get_array_cheatcode!(forkChainAddressArrayCall, &DynSolType::Address); -impl_get_array_cheatcode!(forkAddressArrayCall, &DynSolType::Address, stateful); +impl_get_value_cheatcode!(readForkChainAddressCall, &DynSolType::Address); +impl_get_value_cheatcode!(readForkAddressCall, &DynSolType::Address, stateful); +impl_get_array_cheatcode!(readForkChainAddressArrayCall, &DynSolType::Address); +impl_get_array_cheatcode!(readForkAddressArrayCall, &DynSolType::Address, stateful); // Bytes32 -impl_get_value_cheatcode!(forkChainBytes32Call, &DynSolType::FixedBytes(32)); -impl_get_value_cheatcode!(forkBytes32Call, &DynSolType::FixedBytes(32), stateful); -impl_get_array_cheatcode!(forkChainBytes32ArrayCall, &DynSolType::FixedBytes(32)); -impl_get_array_cheatcode!(forkBytes32ArrayCall, &DynSolType::FixedBytes(32), stateful); +impl_get_value_cheatcode!(readForkChainBytes32Call, &DynSolType::FixedBytes(32)); +impl_get_value_cheatcode!(readForkBytes32Call, &DynSolType::FixedBytes(32), stateful); +impl_get_array_cheatcode!(readForkChainBytes32ArrayCall, &DynSolType::FixedBytes(32)); +impl_get_array_cheatcode!(readForkBytes32ArrayCall, &DynSolType::FixedBytes(32), stateful); // Bytes -impl_get_value_cheatcode!(forkChainBytesCall, &DynSolType::Bytes); -impl_get_value_cheatcode!(forkBytesCall, &DynSolType::Bytes, stateful); -impl_get_array_cheatcode!(forkChainBytesArrayCall, &DynSolType::Bytes); -impl_get_array_cheatcode!(forkBytesArrayCall, &DynSolType::Bytes, stateful); +impl_get_value_cheatcode!(readForkChainBytesCall, &DynSolType::Bytes); +impl_get_value_cheatcode!(readForkBytesCall, &DynSolType::Bytes, stateful); +impl_get_array_cheatcode!(readForkChainBytesArrayCall, &DynSolType::Bytes); +impl_get_array_cheatcode!(readForkBytesArrayCall, &DynSolType::Bytes, stateful); // String -impl_get_value_cheatcode!(forkChainStringCall, &DynSolType::String); -impl_get_value_cheatcode!(forkStringCall, &DynSolType::String, stateful); -impl_get_array_cheatcode!(forkChainStringArrayCall, &DynSolType::String); -impl_get_array_cheatcode!(forkStringArrayCall, &DynSolType::String, stateful); +impl_get_value_cheatcode!(readForkChainStringCall, &DynSolType::String); +impl_get_value_cheatcode!(readForkStringCall, &DynSolType::String, stateful); +impl_get_array_cheatcode!(readForkChainStringArrayCall, &DynSolType::String); +impl_get_array_cheatcode!(readForkStringArrayCall, &DynSolType::String, stateful); /// Generic helper to get any value from the TOML config. fn get_toml_value<'a>( diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 8bb6d8a6e7861..47ff3c50eb5ec 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -3344,13 +3344,13 @@ contract ForkScript is DSTest { console.log("id:", chainIds[i]); string memory rpc = vm.forkChainRpcUrl(chainIds[i]); - int256 i256 = vm.forkChainInt(chainIds[i], "i256"); - uint256 u256 = vm.forkChainUint(chainIds[i], "u256"); - bool boolean = vm.forkChainBool(chainIds[i], "bool"); - address addr = vm.forkChainAddress(chainIds[i], "addr"); - bytes32 b256 = vm.forkChainBytes32(chainIds[i], "b256"); - bytes memory byytes = vm.forkChainBytes(chainIds[i], "bytes"); - string memory str = vm.forkChainString(chainIds[i], "str"); + int256 i256 = vm.readForkChainInt(chainIds[i], "i256"); + uint256 u256 = vm.readForkChainUint(chainIds[i], "u256"); + bool boolean = vm.readForkChainBool(chainIds[i], "bool"); + address addr = vm.readForkChainAddress(chainIds[i], "addr"); + bytes32 b256 = vm.readForkChainBytes32(chainIds[i], "b256"); + bytes memory byytes = vm.readForkChainBytes(chainIds[i], "bytes"); + string memory str = vm.readForkChainString(chainIds[i], "str"); console.log(" > rpc:", rpc); console.log(" > vars:"); @@ -3377,35 +3377,35 @@ contract ForkScript is DSTest { console.log("Testing arrays for chain:", chains[i]); // Test bool array - bool[] memory boolArray = vm.forkChainBoolArray(chainIds[i], "bool_array"); + bool[] memory boolArray = vm.readForkChainBoolArray(chainIds[i], "bool_array"); assert(boolArray.length == 3); console.log(" > bool_array[0]:", boolArray[0]); // Test int array - int256[] memory intArray = vm.forkChainIntArray(chainIds[i], "int_array"); + int256[] memory intArray = vm.readForkChainIntArray(chainIds[i], "int_array"); assert(intArray.length == 3); console.log(" > int_array[0]:", intArray[0]); // Test uint array - uint256[] memory uintArray = vm.forkChainUintArray(chainIds[i], "uint_array"); + uint256[] memory uintArray = vm.readForkChainUintArray(chainIds[i], "uint_array"); assert(uintArray.length == 3); console.log(" > uint_array[0]:", uintArray[0]); // Test address array - address[] memory addrArray = vm.forkChainAddressArray(chainIds[i], "addr_array"); + address[] memory addrArray = vm.readForkChainAddressArray(chainIds[i], "addr_array"); assert(addrArray.length == 2); console.log(" > addr_array[0]:", addrArray[0]); // Test bytes32 array - bytes32[] memory bytes32Array = vm.forkChainBytes32Array(chainIds[i], "bytes32_array"); + bytes32[] memory bytes32Array = vm.readForkChainBytes32Array(chainIds[i], "bytes32_array"); assert(bytes32Array.length == 2); // Test bytes array - bytes[] memory bytesArray = vm.forkChainBytesArray(chainIds[i], "bytes_array"); + bytes[] memory bytesArray = vm.readForkChainBytesArray(chainIds[i], "bytes_array"); assert(bytesArray.length == 3); // Test string array - string[] memory stringArray = vm.forkChainStringArray(chainIds[i], "string_array"); + string[] memory stringArray = vm.readForkChainStringArray(chainIds[i], "string_array"); assert(stringArray.length == 3); console.log(" > string_array[0]:", stringArray[0]); } @@ -3567,13 +3567,13 @@ contract ForkTest is DSTest { console.log("id:", vm.forkChainId()); assert(eqString(vm.forkRpcUrl(), "")); - int256 i256 = vm.forkInt("i256"); - uint256 u256 = vm.forkUint("u256"); - bool boolean = vm.forkBool("bool"); - address addr = vm.forkAddress("addr"); - bytes32 b256 = vm.forkBytes32("b256"); - bytes memory byytes = vm.forkBytes("bytes"); - string memory str = vm.forkString("str"); + int256 i256 = vm.readForkInt("i256"); + uint256 u256 = vm.readForkUint("u256"); + bool boolean = vm.readForkBool("bool"); + address addr = vm.readForkAddress("addr"); + bytes32 b256 = vm.readForkBytes32("b256"); + bytes memory byytes = vm.readForkBytes("bytes"); + string memory str = vm.readForkString("str"); console.log(" > vars:"); console.log(" > i256:", i256); @@ -3596,39 +3596,39 @@ contract ForkTest is DSTest { console.log(" > Arrays:"); // Test bool array - bool[] memory boolArray = vm.forkBoolArray("bool_array"); + bool[] memory boolArray = vm.readForkBoolArray("bool_array"); assert(boolArray.length == 3); assert(boolArray[0] == true); console.log(" > bool_array[0]:", boolArray[0]); // Test int array - int256[] memory intArray = vm.forkIntArray("int_array"); + int256[] memory intArray = vm.readForkIntArray("int_array"); assert(intArray.length == 3); assert(intArray[0] == -100); console.log(" > int_array[0]:", intArray[0]); // Test uint array - uint256[] memory uintArray = vm.forkUintArray("uint_array"); + uint256[] memory uintArray = vm.readForkUintArray("uint_array"); assert(uintArray.length == 3); assert(uintArray[0] == 100); console.log(" > uint_array[0]:", uintArray[0]); // Test address array - address[] memory addrArray = vm.forkAddressArray("addr_array"); + address[] memory addrArray = vm.readForkAddressArray("addr_array"); assert(addrArray.length == 2); assert(addrArray[0] == 0x1111111111111111111111111111111111111111); console.log(" > addr_array[0]:", addrArray[0]); // Test bytes32 array - bytes32[] memory bytes32Array = vm.forkBytes32Array("bytes32_array"); + bytes32[] memory bytes32Array = vm.readForkBytes32Array("bytes32_array"); assert(bytes32Array.length == 2); // Test bytes array - bytes[] memory bytesArray = vm.forkBytesArray("bytes_array"); + bytes[] memory bytesArray = vm.readForkBytesArray("bytes_array"); assert(bytesArray.length == 3); // Test string array - string[] memory stringArray = vm.forkStringArray("string_array"); + string[] memory stringArray = vm.readForkStringArray("string_array"); assert(stringArray.length == 3); assert(eqString(stringArray[0], "hello")); console.log(" > string_array[0]:", stringArray[0]); @@ -3698,7 +3698,7 @@ contract ForkTest is DSTest { function test_throwsErrorWhen() public { vm.createSelectFork(""); - address owner = vm.forkAddress("owner"); + address owner = vm.readForkAddress("owner"); } } "# @@ -3708,7 +3708,7 @@ contract ForkTest is DSTest { cmd.args(["test", "ForkTest"]).assert_failure().stdout_eq(str![[r#" ... -[FAIL: vm.forkAddress: failed parsing $owner as type `address`: parser error: +[FAIL: vm.readForkAddress: failed parsing $owner as type `address`: parser error: $owner ^ invalid string length] test_throwsErrorWhen() ([GAS]) diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index 0426d391297c7..e18646a3bf027 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -286,40 +286,12 @@ interface Vm { function expectSafeMemoryCall(uint64 min, uint64 max) external; function fee(uint256 newBasefee) external; function ffi(string[] calldata commandInput) external returns (bytes memory result); - function forkAddress(string calldata key) external view returns (address); - function forkAddressArray(string calldata key) external view returns (address[] memory); - function forkBool(string calldata key) external view returns (bool); - function forkBoolArray(string calldata key) external view returns (bool[] memory); - function forkBytes(string calldata key) external view returns (bytes memory); - function forkBytes32(string calldata key) external view returns (bytes32); - function forkBytes32Array(string calldata key) external view returns (bytes32[] memory); - function forkBytesArray(string calldata key) external view returns (bytes[] memory); function forkChain() external view returns (string memory); - function forkChainAddress(uint256 chain, string calldata key) external view returns (address); - function forkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory); - function forkChainBool(uint256 chain, string calldata key) external view returns (bool); - function forkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory); - function forkChainBytes(uint256 chain, string calldata key) external view returns (bytes memory); - function forkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32); - function forkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory); - function forkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory); function forkChainId() external view returns (uint256); function forkChainIds() external view returns (uint256[] memory); - function forkChainInt(uint256 chain, string calldata key) external view returns (int256); - function forkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory); function forkChainRpcUrl(uint256 id) external view returns (string memory); - function forkChainString(uint256 chain, string calldata key) external view returns (string memory); - function forkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory); - function forkChainUint(uint256 chain, string calldata key) external view returns (uint256); - function forkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory); function forkChains() external view returns (string[] memory); - function forkInt(string calldata key) external view returns (int256); - function forkIntArray(string calldata key) external view returns (int256[] memory); function forkRpcUrl() external view returns (string memory); - function forkString(string calldata key) external view returns (string memory); - function forkStringArray(string calldata key) external view returns (string[] memory); - function forkUint(string calldata key) external view returns (uint256); - function forkUintArray(string calldata key) external view returns (uint256[] memory); function foundryVersionAtLeast(string calldata version) external view returns (bool); function foundryVersionCmp(string calldata version) external view returns (int256); function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); @@ -458,6 +430,34 @@ interface Vm { function readDir(string calldata path, uint64 maxDepth, bool followLinks) external view returns (DirEntry[] memory entries); function readFile(string calldata path) external view returns (string memory data); function readFileBinary(string calldata path) external view returns (bytes memory data); + function readForkAddress(string calldata key) external view returns (address); + function readForkAddressArray(string calldata key) external view returns (address[] memory); + function readForkBool(string calldata key) external view returns (bool); + function readForkBoolArray(string calldata key) external view returns (bool[] memory); + function readForkBytes(string calldata key) external view returns (bytes memory); + function readForkBytes32(string calldata key) external view returns (bytes32); + function readForkBytes32Array(string calldata key) external view returns (bytes32[] memory); + function readForkBytesArray(string calldata key) external view returns (bytes[] memory); + function readForkChainAddress(uint256 chain, string calldata key) external view returns (address); + function readForkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory); + function readForkChainBool(uint256 chain, string calldata key) external view returns (bool); + function readForkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory); + function readForkChainBytes(uint256 chain, string calldata key) external view returns (bytes memory); + function readForkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32); + function readForkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory); + function readForkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory); + function readForkChainInt(uint256 chain, string calldata key) external view returns (int256); + function readForkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory); + function readForkChainString(uint256 chain, string calldata key) external view returns (string memory); + function readForkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory); + function readForkChainUint(uint256 chain, string calldata key) external view returns (uint256); + function readForkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory); + function readForkInt(string calldata key) external view returns (int256); + function readForkIntArray(string calldata key) external view returns (int256[] memory); + function readForkString(string calldata key) external view returns (string memory); + function readForkStringArray(string calldata key) external view returns (string[] memory); + function readForkUint(string calldata key) external view returns (uint256); + function readForkUintArray(string calldata key) external view returns (uint256[] memory); function readLine(string calldata path) external view returns (string memory line); function readLink(string calldata linkPath) external view returns (string memory targetPath); function record() external; From 202d3b9479d6d8613a26c13e7c5438439c7ab790 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Fri, 15 Aug 2025 17:12:22 +0200 Subject: [PATCH 08/15] docs: improve cheat comments --- crates/cheatcodes/assets/cheatcodes.json | 56 +++++++++---------- .../cheatcodes/assets/cheatcodes.schema.json | 2 +- crates/cheatcodes/spec/src/vm.rs | 56 +++++++++---------- 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index fa8d2f0a22083..d09c416434748 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -8749,7 +8749,7 @@ { "func": { "id": "readForkAddress", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `address`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `address`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkAddress(string calldata key) external view returns (address);", "visibility": "external", "mutability": "view", @@ -8769,7 +8769,7 @@ { "func": { "id": "readForkAddressArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `address`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `address`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkAddressArray(string calldata key) external view returns (address[] memory);", "visibility": "external", "mutability": "view", @@ -8789,7 +8789,7 @@ { "func": { "id": "readForkBool", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `bool`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `bool`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkBool(string calldata key) external view returns (bool);", "visibility": "external", "mutability": "view", @@ -8809,7 +8809,7 @@ { "func": { "id": "readForkBoolArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bool`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `bool`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkBoolArray(string calldata key) external view returns (bool[] memory);", "visibility": "external", "mutability": "view", @@ -8829,7 +8829,7 @@ { "func": { "id": "readForkBytes", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `bytes`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `bytes`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkBytes(string calldata key) external view returns (bytes memory);", "visibility": "external", "mutability": "view", @@ -8849,7 +8849,7 @@ { "func": { "id": "readForkBytes32", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `bytes32`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `bytes32`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkBytes32(string calldata key) external view returns (bytes32);", "visibility": "external", "mutability": "view", @@ -8869,7 +8869,7 @@ { "func": { "id": "readForkBytes32Array", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes32`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `bytes32`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkBytes32Array(string calldata key) external view returns (bytes32[] memory);", "visibility": "external", "mutability": "view", @@ -8889,7 +8889,7 @@ { "func": { "id": "readForkBytesArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `bytes`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkBytesArray(string calldata key) external view returns (bytes[] memory);", "visibility": "external", "mutability": "view", @@ -8909,7 +8909,7 @@ { "func": { "id": "readForkChainAddress", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `address`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `address`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkChainAddress(uint256 chain, string calldata key) external view returns (address);", "visibility": "external", "mutability": "view", @@ -8929,7 +8929,7 @@ { "func": { "id": "readForkChainAddressArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `address`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `address`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory);", "visibility": "external", "mutability": "view", @@ -8949,7 +8949,7 @@ { "func": { "id": "readForkChainBool", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bool`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `bool`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkChainBool(uint256 chain, string calldata key) external view returns (bool);", "visibility": "external", "mutability": "view", @@ -8969,7 +8969,7 @@ { "func": { "id": "readForkChainBoolArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bool`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `bool`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory);", "visibility": "external", "mutability": "view", @@ -8989,7 +8989,7 @@ { "func": { "id": "readForkChainBytes", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bytes`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `bytes`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkChainBytes(uint256 chain, string calldata key) external view returns (bytes memory);", "visibility": "external", "mutability": "view", @@ -9009,7 +9009,7 @@ { "func": { "id": "readForkChainBytes32", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bytes32`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `bytes32`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32);", "visibility": "external", "mutability": "view", @@ -9029,7 +9029,7 @@ { "func": { "id": "readForkChainBytes32Array", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes32`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `bytes32`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory);", "visibility": "external", "mutability": "view", @@ -9049,7 +9049,7 @@ { "func": { "id": "readForkChainBytesArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `bytes`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory);", "visibility": "external", "mutability": "view", @@ -9069,7 +9069,7 @@ { "func": { "id": "readForkChainInt", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `int256`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `int256`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkChainInt(uint256 chain, string calldata key) external view returns (int256);", "visibility": "external", "mutability": "view", @@ -9089,7 +9089,7 @@ { "func": { "id": "readForkChainIntArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `int256`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `int256`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory);", "visibility": "external", "mutability": "view", @@ -9109,7 +9109,7 @@ { "func": { "id": "readForkChainString", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `string`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `string`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkChainString(uint256 chain, string calldata key) external view returns (string memory);", "visibility": "external", "mutability": "view", @@ -9129,7 +9129,7 @@ { "func": { "id": "readForkChainStringArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `string`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `string`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory);", "visibility": "external", "mutability": "view", @@ -9149,7 +9149,7 @@ { "func": { "id": "readForkChainUint", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as `uint256`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `uint256`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkChainUint(uint256 chain, string calldata key) external view returns (uint256);", "visibility": "external", "mutability": "view", @@ -9169,7 +9169,7 @@ { "func": { "id": "readForkChainUintArray", - "description": "Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `uint256`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `uint256`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory);", "visibility": "external", "mutability": "view", @@ -9189,7 +9189,7 @@ { "func": { "id": "readForkInt", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `int256`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `int256`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkInt(string calldata key) external view returns (int256);", "visibility": "external", "mutability": "view", @@ -9209,7 +9209,7 @@ { "func": { "id": "readForkIntArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `int256`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `int256`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkIntArray(string calldata key) external view returns (int256[] memory);", "visibility": "external", "mutability": "view", @@ -9229,7 +9229,7 @@ { "func": { "id": "readForkString", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `string`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `string`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkString(string calldata key) external view returns (string memory);", "visibility": "external", "mutability": "view", @@ -9249,7 +9249,7 @@ { "func": { "id": "readForkStringArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `string`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `string`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkStringArray(string calldata key) external view returns (string[] memory);", "visibility": "external", "mutability": "view", @@ -9269,7 +9269,7 @@ { "func": { "id": "readForkUint", - "description": "Gets the value for the key `key` from the currently active fork and parses it as `uint256`.\nReverts if the key was not found or the value could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `uint256`.\nReverts if the key was not found or the value could not be parsed.", "declaration": "function readForkUint(string calldata key) external view returns (uint256);", "visibility": "external", "mutability": "view", @@ -9289,7 +9289,7 @@ { "func": { "id": "readForkUintArray", - "description": "Gets the value for the key `key` from the currently active fork and parses it as an array of `uint256`.\nReverts if a key was not found or any of the values could not be parsed.", + "description": "Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `uint256`.\nReverts if a key was not found or any of the values could not be parsed.", "declaration": "function readForkUintArray(string calldata key) external view returns (uint256[] memory);", "visibility": "external", "mutability": "view", diff --git a/crates/cheatcodes/assets/cheatcodes.schema.json b/crates/cheatcodes/assets/cheatcodes.schema.json index 83d4663bee42e..ed89119b03bfa 100644 --- a/crates/cheatcodes/assets/cheatcodes.schema.json +++ b/crates/cheatcodes/assets/cheatcodes.schema.json @@ -242,7 +242,7 @@ "const": "scripting" }, { - "description": "Cheatcodes that interact with the program's forking configuration.\n\nExamples: `forkChains`, `forkChainRpcUrl`, `readForkUint`.\n\nSafety: safe.", + "description": "Cheatcodes that interact with the program's forking configuration.\n\nExamples: `forkChains`, `forkChainRpcUrl`, `readForkUint`, `readForkAddressArray`.\n\nSafety: safe.", "type": "string", "const": "forking" }, diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index 9ddc13ca6d91f..d1a555aef7106 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2219,142 +2219,142 @@ interface Vm { #[cheatcode(group = Forking)] function forkChainRpcUrl(uint256 id) external view returns (string memory); - /// Gets the value for the key `key` from the currently active fork and parses it as `bool`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `bool`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkBool(string calldata key) external view returns (bool); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bool`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `bool`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkChainBool(uint256 chain, string calldata key) external view returns (bool); - /// Gets the value for the key `key` from the currently active fork and parses it as an array of `bool`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `bool`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkBoolArray(string calldata key) external view returns (bool[] memory); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bool`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `bool`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkChainBoolArray(uint256 chain, string calldata key) external view returns (bool[] memory); - /// Gets the value for the key `key` from the currently active fork and parses it as `int256`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `int256`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkInt(string calldata key) external view returns (int256); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `int256`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `int256`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkChainInt(uint256 chain, string calldata key) external view returns (int256); - /// Gets the value for the key `key` from the currently active fork and parses it as an array of `int256`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `int256`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkIntArray(string calldata key) external view returns (int256[] memory); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `int256`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `int256`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory); - /// Gets the value for the key `key` from the currently active fork and parses it as `uint256`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `uint256`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkUint(string calldata key) external view returns (uint256); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `uint256`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `uint256`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkChainUint(uint256 chain, string calldata key) external view returns (uint256); - /// Gets the value for the key `key` from the currently active fork and parses it as an array of `uint256`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `uint256`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkUintArray(string calldata key) external view returns (uint256[] memory); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `uint256`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `uint256`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory); - /// Gets the value for the key `key` from the currently active fork and parses it as `address`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `address`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkAddress(string calldata key) external view returns (address); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `address`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `address`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkChainAddress(uint256 chain, string calldata key) external view returns (address); - /// Gets the value for the key `key` from the currently active fork and parses it as an array of `address`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `address`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkAddressArray(string calldata key) external view returns (address[] memory); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `address`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `address`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory); - /// Gets the value for the key `key` from the currently active fork and parses it as `bytes32`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `bytes32`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkBytes32(string calldata key) external view returns (bytes32); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bytes32`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `bytes32`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32); - /// Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes32`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `bytes32`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkBytes32Array(string calldata key) external view returns (bytes32[] memory); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes32`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `bytes32`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory); - /// Gets the value for the key `key` from the currently active fork and parses it as `string`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `string`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkString(string calldata key) external view returns (string memory); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `string`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `string`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkChainString(uint256 chain, string calldata key) external view returns (string memory); - /// Gets the value for the key `key` from the currently active fork and parses it as an array of `string`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `string`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkStringArray(string calldata key) external view returns (string[] memory); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `string`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `string`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory); - /// Gets the value for the key `key` from the currently active fork and parses it as `bytes`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `bytes`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkBytes(string calldata key) external view returns (bytes memory); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as `bytes`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as `bytes`. /// Reverts if the key was not found or the value could not be parsed. #[cheatcode(group = Forking)] function readForkChainBytes(uint256 chain, string calldata key) external view returns (bytes memory); - /// Gets the value for the key `key` from the currently active fork and parses it as an array of `bytes`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as an array of `bytes`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkBytesArray(string calldata key) external view returns (bytes[] memory); - /// Gets the value for the key `key` from the fork config for chain `chain` and parses it as an array of `bytes`. + /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the specified chain and parses it as an array of `bytes`. /// Reverts if a key was not found or any of the values could not be parsed. #[cheatcode(group = Forking)] function readForkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory); From da65c90237f88d3edb42c5ca53b8711a240e0972 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Fri, 15 Aug 2025 17:50:02 +0200 Subject: [PATCH 09/15] style: rename missing cheats --- crates/cheatcodes/assets/cheatcodes.json | 240 +++++++++++------------ crates/cheatcodes/spec/src/vm.rs | 12 +- crates/cheatcodes/src/fork.rs | 12 +- crates/forge/tests/cli/script.rs | 12 +- testdata/cheats/Vm.sol | 12 +- 5 files changed, 144 insertions(+), 144 deletions(-) diff --git a/crates/cheatcodes/assets/cheatcodes.json b/crates/cheatcodes/assets/cheatcodes.json index d09c416434748..7fb554eb045eb 100644 --- a/crates/cheatcodes/assets/cheatcodes.json +++ b/crates/cheatcodes/assets/cheatcodes.json @@ -5864,126 +5864,6 @@ "status": "stable", "safety": "safe" }, - { - "func": { - "id": "forkChain", - "description": "Returns the chain name of the currently selected fork.", - "declaration": "function forkChain() external view returns (string memory);", - "visibility": "external", - "mutability": "view", - "signature": "forkChain()", - "selector": "0xe6075d94", - "selectorBytes": [ - 230, - 7, - 93, - 148 - ] - }, - "group": "forking", - "status": "stable", - "safety": "safe" - }, - { - "func": { - "id": "forkChainId", - "description": "Returns the chain id of the currently selected fork.", - "declaration": "function forkChainId() external view returns (uint256);", - "visibility": "external", - "mutability": "view", - "signature": "forkChainId()", - "selector": "0xe6b661e2", - "selectorBytes": [ - 230, - 182, - 97, - 226 - ] - }, - "group": "forking", - "status": "stable", - "safety": "safe" - }, - { - "func": { - "id": "forkChainIds", - "description": "Returns an array with the ids of all the configured fork chains.\nNote that the configured fork chains are subsections of the `[fork]` section of 'foundry.toml'.", - "declaration": "function forkChainIds() external view returns (uint256[] memory);", - "visibility": "external", - "mutability": "view", - "signature": "forkChainIds()", - "selector": "0x04dc8feb", - "selectorBytes": [ - 4, - 220, - 143, - 235 - ] - }, - "group": "forking", - "status": "stable", - "safety": "safe" - }, - { - "func": { - "id": "forkChainRpcUrl", - "description": "Returns the rpc url of the corresponding chain id.\nBy default, the rpc url of each fork is derived from the `[rpc_endpoints]`, unless\nthe rpc config is specifically informed in the fork config for that specific chain.", - "declaration": "function forkChainRpcUrl(uint256 id) external view returns (string memory);", - "visibility": "external", - "mutability": "view", - "signature": "forkChainRpcUrl(uint256)", - "selector": "0xa2c51cca", - "selectorBytes": [ - 162, - 197, - 28, - 202 - ] - }, - "group": "forking", - "status": "stable", - "safety": "safe" - }, - { - "func": { - "id": "forkChains", - "description": "Returns an array with the name of all the configured fork chains.\nNote that the configured fork chains are subsections of the `[fork]` section of 'foundry.toml'.", - "declaration": "function forkChains() external view returns (string[] memory);", - "visibility": "external", - "mutability": "view", - "signature": "forkChains()", - "selector": "0x081f64cd", - "selectorBytes": [ - 8, - 31, - 100, - 205 - ] - }, - "group": "forking", - "status": "stable", - "safety": "safe" - }, - { - "func": { - "id": "forkRpcUrl", - "description": "Returns the rpc url of the currently selected fork.\nBy default, the rpc url of each fork is derived from the `[rpc_endpoints]`, unless\nthe rpc config is specifically informed in the fork config for that specific chain.", - "declaration": "function forkRpcUrl() external view returns (string memory);", - "visibility": "external", - "mutability": "view", - "signature": "forkRpcUrl()", - "selector": "0x66d48d21", - "selectorBytes": [ - 102, - 212, - 141, - 33 - ] - }, - "group": "forking", - "status": "stable", - "safety": "safe" - }, { "func": { "id": "foundryVersionAtLeast", @@ -8906,6 +8786,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "readForkChain", + "description": "Returns the chain name of the currently selected fork.", + "declaration": "function readForkChain() external view returns (string memory);", + "visibility": "external", + "mutability": "view", + "signature": "readForkChain()", + "selector": "0x99a10434", + "selectorBytes": [ + 153, + 161, + 4, + 52 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "readForkChainAddress", @@ -9066,6 +8966,46 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "readForkChainId", + "description": "Returns the chain id of the currently selected fork.", + "declaration": "function readForkChainId() external view returns (uint256);", + "visibility": "external", + "mutability": "view", + "signature": "readForkChainId()", + "selector": "0x69986b8c", + "selectorBytes": [ + 105, + 152, + 107, + 140 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, + { + "func": { + "id": "readForkChainIds", + "description": "Returns an array with the ids of all the configured fork chains.\nNote that the configured fork chains are subsections of the `[fork]` section of 'foundry.toml'.", + "declaration": "function readForkChainIds() external view returns (uint256[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "readForkChainIds()", + "selector": "0x890ec2f4", + "selectorBytes": [ + 137, + 14, + 194, + 244 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "readForkChainInt", @@ -9106,6 +9046,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "readForkChainRpcUrl", + "description": "Returns the rpc url of the corresponding chain id.\nBy default, the rpc url of each fork is derived from the `[rpc_endpoints]`, unless\nthe rpc config is specifically informed in the fork config for that specific chain.", + "declaration": "function readForkChainRpcUrl(uint256 id) external view returns (string memory);", + "visibility": "external", + "mutability": "view", + "signature": "readForkChainRpcUrl(uint256)", + "selector": "0x76394e84", + "selectorBytes": [ + 118, + 57, + 78, + 132 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "readForkChainString", @@ -9186,6 +9146,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "readForkChains", + "description": "Returns an array with the name of all the configured fork chains.\nNote that the configured fork chains are subsections of the `[fork]` section of 'foundry.toml'.", + "declaration": "function readForkChains() external view returns (string[] memory);", + "visibility": "external", + "mutability": "view", + "signature": "readForkChains()", + "selector": "0x237f2335", + "selectorBytes": [ + 35, + 127, + 35, + 53 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "readForkInt", @@ -9226,6 +9206,26 @@ "status": "stable", "safety": "safe" }, + { + "func": { + "id": "readForkRpcUrl", + "description": "Returns the rpc url of the currently selected fork.\nBy default, the rpc url of each fork is derived from the `[rpc_endpoints]`, unless\nthe rpc config is specifically informed in the fork config for that specific chain.", + "declaration": "function readForkRpcUrl() external view returns (string memory);", + "visibility": "external", + "mutability": "view", + "signature": "readForkRpcUrl()", + "selector": "0xb5ca8455", + "selectorBytes": [ + 181, + 202, + 132, + 85 + ] + }, + "group": "forking", + "status": "stable", + "safety": "safe" + }, { "func": { "id": "readForkString", diff --git a/crates/cheatcodes/spec/src/vm.rs b/crates/cheatcodes/spec/src/vm.rs index d1a555aef7106..b0f4477c9ca6a 100644 --- a/crates/cheatcodes/spec/src/vm.rs +++ b/crates/cheatcodes/spec/src/vm.rs @@ -2189,35 +2189,35 @@ interface Vm { /// /// Note that the configured fork chains are subsections of the `[fork]` section of 'foundry.toml'. #[cheatcode(group = Forking)] - function forkChains() external view returns (string[] memory); + function readForkChains() external view returns (string[] memory); /// Returns an array with the ids of all the configured fork chains. /// /// Note that the configured fork chains are subsections of the `[fork]` section of 'foundry.toml'. #[cheatcode(group = Forking)] - function forkChainIds() external view returns (uint256[] memory); + function readForkChainIds() external view returns (uint256[] memory); /// Returns the chain name of the currently selected fork. #[cheatcode(group = Forking)] - function forkChain() external view returns (string memory); + function readForkChain() external view returns (string memory); /// Returns the chain id of the currently selected fork. #[cheatcode(group = Forking)] - function forkChainId() external view returns (uint256); + function readForkChainId() external view returns (uint256); /// Returns the rpc url of the currently selected fork. /// /// By default, the rpc url of each fork is derived from the `[rpc_endpoints]`, unless /// the rpc config is specifically informed in the fork config for that specific chain. #[cheatcode(group = Forking)] - function forkRpcUrl() external view returns (string memory); + function readForkRpcUrl() external view returns (string memory); /// Returns the rpc url of the corresponding chain id. /// /// By default, the rpc url of each fork is derived from the `[rpc_endpoints]`, unless /// the rpc config is specifically informed in the fork config for that specific chain. #[cheatcode(group = Forking)] - function forkChainRpcUrl(uint256 id) external view returns (string memory); + function readForkChainRpcUrl(uint256 id) external view returns (string memory); /// Gets the value for the key `key` from the `[fork.]` section of `foundry.toml` for the currently active fork and parses it as `bool`. /// Reverts if the key was not found or the value could not be parsed. diff --git a/crates/cheatcodes/src/fork.rs b/crates/cheatcodes/src/fork.rs index 506776bd3080c..071f39e92c2a1 100644 --- a/crates/cheatcodes/src/fork.rs +++ b/crates/cheatcodes/src/fork.rs @@ -6,7 +6,7 @@ use alloy_sol_types::SolValue; use eyre::OptionExt; use foundry_evm_core::ContextExt; -impl Cheatcode for forkChainIdsCall { +impl Cheatcode for readForkChainIdsCall { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { let Self {} = self; Ok(state @@ -19,20 +19,20 @@ impl Cheatcode for forkChainIdsCall { } } -impl Cheatcode for forkChainsCall { +impl Cheatcode for readForkChainsCall { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { let Self {} = self; Ok(state.config.forks.keys().collect::>().abi_encode()) } } -impl Cheatcode for forkChainCall { +impl Cheatcode for readForkChainCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { Ok(get_active_fork_chain_name(ccx)?.abi_encode()) } } -impl Cheatcode for forkChainIdCall { +impl Cheatcode for readForkChainIdCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { Ok(get_active_fork_chain_id(ccx)?.abi_encode()) } @@ -52,7 +52,7 @@ fn resolve_rpc_url(name: &'static str, state: &mut crate::Cheatcodes) -> Result bail!("[fork.{name}] subsection not found in [fork] of 'foundry.toml'") } -impl Cheatcode for forkChainRpcUrlCall { +impl Cheatcode for readForkChainRpcUrlCall { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { let Self { id } = self; let name = get_chain_name(id.to::())?; @@ -60,7 +60,7 @@ impl Cheatcode for forkChainRpcUrlCall { } } -impl Cheatcode for forkRpcUrlCall { +impl Cheatcode for readForkRpcUrlCall { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { let name = get_active_fork_chain_name(ccx)?; resolve_rpc_url(name, ccx.state) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 47ff3c50eb5ec..c57ecb4a68ca4 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -3335,7 +3335,7 @@ contract ForkScript is DSTest { function run() public view { (uint256[2] memory chainIds, string[2] memory chains) = ([uint256(1), uint256(10)], ["mainnet", "optimism"]); - (uint256[] memory cheatChainIds, string[] memory cheatChains) = (vm.forkChainIds(), vm.forkChains()); + (uint256[] memory cheatChainIds, string[] memory cheatChains) = (vm.readForkChainIds(), vm.readForkChains()); for (uint256 i = 0; i < chains.length; i++) { assert(chainIds[i] == cheatChainIds[0] || chainIds[i] == cheatChainIds[1]); @@ -3343,7 +3343,7 @@ contract ForkScript is DSTest { console.log("chain:", chains[i]); console.log("id:", chainIds[i]); - string memory rpc = vm.forkChainRpcUrl(chainIds[i]); + string memory rpc = vm.readForkChainRpcUrl(chainIds[i]); int256 i256 = vm.readForkChainInt(chainIds[i], "i256"); uint256 u256 = vm.readForkChainUint(chainIds[i], "u256"); bool boolean = vm.readForkChainBool(chainIds[i], "bool"); @@ -3557,15 +3557,15 @@ contract ForkTest is DSTest { Vm vm = Vm(HEVM_ADDRESS); function test_panicsWhithoutSelectedFork() public { - vm.forkChain(); + vm.readForkChain(); } function test_forkVars() public { vm.createSelectFork(""); - console.log("chain:", vm.forkChain()); - console.log("id:", vm.forkChainId()); - assert(eqString(vm.forkRpcUrl(), "")); + console.log("chain:", vm.readForkChain()); + console.log("id:", vm.readForkChainId()); + assert(eqString(vm.readForkRpcUrl(), "")); int256 i256 = vm.readForkInt("i256"); uint256 u256 = vm.readForkUint("u256"); diff --git a/testdata/cheats/Vm.sol b/testdata/cheats/Vm.sol index e18646a3bf027..5bfb984158914 100644 --- a/testdata/cheats/Vm.sol +++ b/testdata/cheats/Vm.sol @@ -286,12 +286,6 @@ interface Vm { function expectSafeMemoryCall(uint64 min, uint64 max) external; function fee(uint256 newBasefee) external; function ffi(string[] calldata commandInput) external returns (bytes memory result); - function forkChain() external view returns (string memory); - function forkChainId() external view returns (uint256); - function forkChainIds() external view returns (uint256[] memory); - function forkChainRpcUrl(uint256 id) external view returns (string memory); - function forkChains() external view returns (string[] memory); - function forkRpcUrl() external view returns (string memory); function foundryVersionAtLeast(string calldata version) external view returns (bool); function foundryVersionCmp(string calldata version) external view returns (int256); function fsMetadata(string calldata path) external view returns (FsMetadata memory metadata); @@ -438,6 +432,7 @@ interface Vm { function readForkBytes32(string calldata key) external view returns (bytes32); function readForkBytes32Array(string calldata key) external view returns (bytes32[] memory); function readForkBytesArray(string calldata key) external view returns (bytes[] memory); + function readForkChain() external view returns (string memory); function readForkChainAddress(uint256 chain, string calldata key) external view returns (address); function readForkChainAddressArray(uint256 chain, string calldata key) external view returns (address[] memory); function readForkChainBool(uint256 chain, string calldata key) external view returns (bool); @@ -446,14 +441,19 @@ interface Vm { function readForkChainBytes32(uint256 chain, string calldata key) external view returns (bytes32); function readForkChainBytes32Array(uint256 chain, string calldata key) external view returns (bytes32[] memory); function readForkChainBytesArray(uint256 chain, string calldata key) external view returns (bytes[] memory); + function readForkChainId() external view returns (uint256); + function readForkChainIds() external view returns (uint256[] memory); function readForkChainInt(uint256 chain, string calldata key) external view returns (int256); function readForkChainIntArray(uint256 chain, string calldata key) external view returns (int256[] memory); + function readForkChainRpcUrl(uint256 id) external view returns (string memory); function readForkChainString(uint256 chain, string calldata key) external view returns (string memory); function readForkChainStringArray(uint256 chain, string calldata key) external view returns (string[] memory); function readForkChainUint(uint256 chain, string calldata key) external view returns (uint256); function readForkChainUintArray(uint256 chain, string calldata key) external view returns (uint256[] memory); + function readForkChains() external view returns (string[] memory); function readForkInt(string calldata key) external view returns (int256); function readForkIntArray(string calldata key) external view returns (int256[] memory); + function readForkRpcUrl() external view returns (string memory); function readForkString(string calldata key) external view returns (string memory); function readForkStringArray(string calldata key) external view returns (string[] memory); function readForkUint(string calldata key) external view returns (uint256); From e2b6c5dcb99415dbb706a2a0fe837cf33d87cc63 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Fri, 15 Aug 2025 17:52:50 +0200 Subject: [PATCH 10/15] docs: update cmnts --- crates/cheatcodes/spec/src/cheatcode.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/cheatcodes/spec/src/cheatcode.rs b/crates/cheatcodes/spec/src/cheatcode.rs index 805dc06b0aa92..ab95c05da7b6b 100644 --- a/crates/cheatcodes/spec/src/cheatcode.rs +++ b/crates/cheatcodes/spec/src/cheatcode.rs @@ -88,7 +88,7 @@ pub enum Group { Scripting, /// Cheatcodes that interact with the program's forking configuration. /// - /// Examples: `forkChains`, `forkChainRpcUrl`, `readForkUint`, `readForkAddressArray`. + /// Examples: `readForkChains`, `readForkChainRpcUrl`, `readForkUint`, `readForkAddressArray`. /// /// Safety: safe. Forking, From 503b4fe67b4a9241346b2fbdc151757766d78d64 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Fri, 15 Aug 2025 19:02:55 +0200 Subject: [PATCH 11/15] fix: use existing toml and json parsing helper fns --- crates/cheatcodes/src/fork.rs | 72 ++++------------------------------- crates/cheatcodes/src/toml.rs | 2 +- 2 files changed, 8 insertions(+), 66 deletions(-) diff --git a/crates/cheatcodes/src/fork.rs b/crates/cheatcodes/src/fork.rs index 071f39e92c2a1..7c59a9f1ad5a0 100644 --- a/crates/cheatcodes/src/fork.rs +++ b/crates/cheatcodes/src/fork.rs @@ -1,6 +1,9 @@ //! Implementations of [`Forking`](spec::Group::Forking) cheatcodes. -use crate::{Cheatcode, CheatsCtxt, DatabaseExt, Error, Result, Vm::*, string}; +use crate::{ + Cheatcode, CheatsCtxt, DatabaseExt, Result, Vm::*, json::parse_json_as, + toml::toml_to_json_value, +}; use alloy_dyn_abi::{DynSolType, DynSolValue}; use alloy_sol_types::SolValue; use eyre::OptionExt; @@ -67,21 +70,6 @@ impl Cheatcode for readForkRpcUrlCall { } } -/// Converts the error message of a failed parsing attempt to a more user-friendly message that -/// doesn't leak the value. -fn map_env_err<'a>(key: &'a str, value: &'a str) -> impl FnOnce(Error) -> Error + 'a { - move |e| { - // failed parsing as type `uint256`: parser error: - // - // ^ - // expected at least one digit - let mut e = e.to_string(); - e = e.replacen(&format!("\"{value}\""), &format!("${key}"), 1); - e = e.replacen(&format!("\n{value}\n"), &format!("\n${key}\n"), 1); - Error::from(e) - } -} - /// Gets the alloy chain name for a given chain id. fn get_chain_name(id: u64) -> Result<&'static str> { let chain = alloy_chains::Chain::from_id(id) @@ -237,53 +225,7 @@ fn parse_toml_element( context: &str, fork_name: &str, ) -> Result { - match element_ty { - DynSolType::Bool => { - if let Some(b) = elem.as_bool() { - Ok(DynSolValue::Bool(b)) - } else if let Some(v) = elem.as_integer() { - Ok(DynSolValue::Bool(v != 0)) - } else if let Some(s) = elem.as_str() { - string::parse_value(s, element_ty).map_err(map_env_err(context, s)) - } else { - bail!( - "Element '{context}' in [fork.{fork_name}] must be a boolean, integer, or a string" - ) - } - } - DynSolType::Int(256) => { - if let Some(int_value) = elem.as_integer() { - Ok(DynSolValue::Int(alloy_primitives::I256::try_from(int_value).unwrap(), 256)) - } else if let Some(s) = elem.as_str() { - string::parse_value(s, element_ty).map_err(map_env_err(context, s)) - } else { - bail!("Element '{context}' in [fork.{fork_name}] must be an integer or a string") - } - } - DynSolType::Uint(256) => { - if let Some(int_value) = elem.as_integer() { - if int_value < 0 { - bail!( - "Element '{context}' in [fork.{fork_name}] is a negative integer but expected an unsigned integer" - ); - } - Ok(DynSolValue::Uint(alloy_primitives::U256::from(int_value as u64), 256)) - } else if let Some(s) = elem.as_str() { - string::parse_value(s, element_ty).map_err(map_env_err(context, s)) - } else { - bail!("Element '{context}' in [fork.{fork_name}] must be an integer or a string") - } - } - DynSolType::Address - | DynSolType::FixedBytes(32) - | DynSolType::String - | DynSolType::Bytes => { - if let Some(s) = elem.as_str() { - string::parse_value(s, element_ty).map_err(map_env_err(context, s)) - } else { - bail!("Element '{context}' in [fork.{fork_name}] must be a string"); - } - } - _ => bail!("Unsupported array element type for fork configuration: {element_ty:?}"), - } + // Convert TOML value to JSON value and use existing JSON parsing logic + parse_json_as(&toml_to_json_value(elem.to_owned()), element_ty) + .map_err(|e| fmt_err!("Failed to parse '{context}' in [fork.{fork_name}]: {e}")) } diff --git a/crates/cheatcodes/src/toml.rs b/crates/cheatcodes/src/toml.rs index 4ae16340ec6be..1f1e2a279b20f 100644 --- a/crates/cheatcodes/src/toml.rs +++ b/crates/cheatcodes/src/toml.rs @@ -228,7 +228,7 @@ fn format_json_to_toml(json: JsonValue) -> Result { } /// Convert a TOML value to a JSON value. -fn toml_to_json_value(toml: TomlValue) -> JsonValue { +pub(super) fn toml_to_json_value(toml: TomlValue) -> JsonValue { match toml { TomlValue::String(s) => match s.as_str() { "null" => JsonValue::Null, From 9bc005fd867f20777f905ecef71a2d3789c3a563 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Sat, 16 Aug 2025 19:25:27 +0200 Subject: [PATCH 12/15] feat: resolve env vars in 'fork' config --- crates/cheatcodes/src/config.rs | 4 +- crates/config/src/fork_config.rs | 100 +++++++++++++++++++ crates/config/src/lib.rs | 92 +++++++++++++---- crates/forge/tests/cli/script.rs | 166 ++++++++++++++++--------------- 4 files changed, 259 insertions(+), 103 deletions(-) create mode 100644 crates/config/src/fork_config.rs diff --git a/crates/cheatcodes/src/config.rs b/crates/cheatcodes/src/config.rs index 361c1a9fe59da..8331bb4be6abc 100644 --- a/crates/cheatcodes/src/config.rs +++ b/crates/cheatcodes/src/config.rs @@ -4,7 +4,7 @@ use alloy_primitives::{U256, map::AddressHashMap}; use foundry_common::{ContractsByArtifact, fs::normalize_path}; use foundry_compilers::{ArtifactId, ProjectPathsConfig, utils::canonicalize}; use foundry_config::{ - Config, ForkConfig, FsPermissions, ResolvedRpcEndpoint, ResolvedRpcEndpoints, RpcEndpoint, + Config, ForkConfigs, FsPermissions, ResolvedRpcEndpoint, ResolvedRpcEndpoints, RpcEndpoint, RpcEndpointUrl, cache::StorageCachingConfig, fs_permissions::FsAccessKind, }; use foundry_evm_core::opts::EvmOpts; @@ -64,7 +64,7 @@ pub struct CheatsConfig { /// Mapping of chain IDs to their aliases pub chain_id_to_alias: HashMap, /// Fork configuration - pub forks: HashMap, + pub forks: ForkConfigs, } /// Chain data for getChain cheatcodes diff --git a/crates/config/src/fork_config.rs b/crates/config/src/fork_config.rs new file mode 100644 index 0000000000000..2f757816633fe --- /dev/null +++ b/crates/config/src/fork_config.rs @@ -0,0 +1,100 @@ +use crate::{ + RpcEndpoint, + error::ExtractConfigError, + resolve::{RE_PLACEHOLDER, UnresolvedEnvVarError, interpolate}, +}; + +use serde::{Deserialize, Serialize}; +use std::{collections::HashMap, ops::Deref}; + +/// Fork-scoped config for tests and scripts. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)] +pub struct ForkConfigs(pub HashMap); + +impl ForkConfigs { + /// Resolve environment variables in all fork config fields + pub fn resolve_env_vars(&mut self) -> Result<(), ExtractConfigError> { + for (name, fork_config) in &mut self.0 { + // Take temporary ownership of the config, so that it can be consumed. + let config = std::mem::take(fork_config); + + // Resolve the env vars and place it back into the map. + *fork_config = config.resolved().map_err(|e| { + let msg = if !e.var.is_empty() { + format!("environment variable `{}` not found", e.var) + } else { + e.to_string() + }; + ExtractConfigError::new(figment::Error::from(format!( + "Failed to resolve fork config [forks.{name}]: {msg}" + ))) + })?; + } + + Ok(()) + } +} + +impl Deref for ForkConfigs { + type Target = HashMap; + + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +/// Fork-scoped config for tests and scripts. +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, Default)] +pub struct ForkChainConfig { + // Optional RPC endpoint for the fork. + // + // If uninformed, it will attempt to load one from `[rpc_endpoints]` with a matching alias + // for the name of the forked chain. + pub rpc_endpoint: Option, + // Any arbitrary key-value pair of variables. + pub vars: HashMap, +} + +impl ForkChainConfig { + /// Resolves environment variables in the fork configuration. + /// Returns a new ForkConfig with all environment variables resolved. + pub fn resolved(self) -> Result { + let mut resolved_vars = HashMap::new(); + for (key, value) in self.vars { + resolved_vars.insert(key, resolve_toml_value(value)?); + } + + Ok(Self { rpc_endpoint: self.rpc_endpoint, vars: resolved_vars }) + } +} + +/// Recursively resolves environment variables in a toml::Value +fn resolve_toml_value(value: toml::Value) -> Result { + match value { + toml::Value::String(s) => { + // Check if the string contains environment variable placeholders + if RE_PLACEHOLDER.is_match(&s) { + // Resolve the environment variables + let resolved = interpolate(&s)?; + Ok(toml::Value::String(resolved)) + } else { + Ok(toml::Value::String(s)) + } + } + toml::Value::Array(arr) => { + // Recursively resolve each element in the array + let resolved_arr: Result, _> = arr.into_iter().map(resolve_toml_value).collect(); + Ok(toml::Value::Array(resolved_arr?)) + } + toml::Value::Table(table) => { + // Recursively resolve each value in the table + let mut resolved_table = toml::map::Map::new(); + for (k, v) in table { + resolved_table.insert(k, resolve_toml_value(v)?); + } + Ok(toml::Value::Table(resolved_table)) + } + // Other types don't need resolution + other => Ok(other), + } +} diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 7e276c26759bb..8e6964822c7b2 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -45,7 +45,7 @@ use semver::Version; use serde::{Deserialize, Serialize, Serializer}; use std::{ borrow::Cow, - collections::{BTreeMap, HashMap}, + collections::BTreeMap, fs, path::{Path, PathBuf}, str::FromStr, @@ -82,6 +82,9 @@ pub mod fs_permissions; pub use fs_permissions::FsPermissions; use fs_permissions::PathPermission; +pub mod fork_config; +pub use fork_config::{ForkChainConfig, ForkConfigs}; + pub mod error; use error::ExtractConfigError; pub use error::SolidityErrorCode; @@ -447,7 +450,7 @@ pub struct Config { #[serde(default, skip_serializing_if = "RpcEndpoints::is_empty")] pub rpc_endpoints: RpcEndpoints, /// Fork configuration - pub forks: HashMap, + pub forks: ForkConfigs, /// Whether to store the referenced sources in the metadata as literal data. pub use_literal_content: bool, /// Whether to include the metadata hash. @@ -563,18 +566,6 @@ pub struct Config { pub _non_exhaustive: (), } -/// Fork-scoped config for tests and scripts. -#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub struct ForkConfig { - // Optional RPC endpoint for the fork. - // - // If uninformed, it will attempt to load one from `[rpc_endpoints]` with a matching alias - // for the name of the forked chain. - pub rpc_endpoint: Option, - // Any arbitrary key-value pair of variables. - pub vars: HashMap, -} - /// Mapping of fallback standalone sections. See [`FallbackProfileProvider`]. pub const STANDALONE_FALLBACK_SECTIONS: &[(&str, &str)] = &[("invariant", "fuzz")]; @@ -698,6 +689,7 @@ impl Config { add_profile(&config.profile); config.normalize_optimizer_settings(); + config.forks.resolve_env_vars()?; Ok(config) } @@ -2643,7 +2635,7 @@ mod tests { use itertools::Itertools; use similar_asserts::assert_eq; use soldeer_core::remappings::RemappingsLocation; - use std::{fs::File, io::Write}; + use std::{collections::HashMap, fs::File, io::Write}; use tempfile::tempdir; // Helper function to clear `__warnings` in config, since it will be populated during loading @@ -5159,7 +5151,7 @@ mod tests { } #[test] - fn test_get_script_config() { + fn test_get_fork_config() { figment::Jail::expect_with(|jail| { jail.create_file( "foundry.toml", @@ -5167,10 +5159,10 @@ mod tests { [forks] [forks.mainnet] - rpc_endpoint = "mainnet-rpc" + rpc_endpoint = "${_MAINNET_RPC}" [forks.mainnet.vars] - weth = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" + weth = "${_WETH_ADDRESS}" usdc = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48" pool_name = "USDC-ETH" pool_fee = 3000 @@ -5181,7 +5173,7 @@ mod tests { int_array = [-100, 200, -300] uint_array = [100, 200, 300] addr_array = [ - "0x1111111111111111111111111111111111111111", + "${_ADDR1}", "0x2222222222222222222222222222222222222222" ] bytes32_array = [ @@ -5192,11 +5184,18 @@ mod tests { string_array = ["hello", "world", "test"] "#, )?; + + // Now set the environment variables + jail.set_env("_MAINNET_RPC", "mainnet-rpc"); + jail.set_env("_WETH_ADDRESS", "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"); + jail.set_env("_ADDR1", "0x1111111111111111111111111111111111111111"); + + // Reload the config with env vars set let config = Config::load().unwrap(); - let expected: HashMap = vec![( + let expected: HashMap = vec![( "mainnet".to_string(), - ForkConfig { + ForkChainConfig { rpc_endpoint: Some(RpcEndpoint::new(RpcEndpointUrl::Url( "mainnet-rpc".to_string(), ))), @@ -5233,7 +5232,19 @@ mod tests { let expected_mainnet = expected.get("mainnet").unwrap(); let mainnet = config.forks.get("mainnet").unwrap(); - assert_eq!(expected_mainnet.rpc_endpoint, mainnet.rpc_endpoint); + + // Verify that rpc_endpoint is now resolved to the actual value + if let Some(rpc) = &mainnet.rpc_endpoint { + // The rpc endpoint should be resolved after env var is set + let resolved_url = rpc.to_owned().resolve().url().unwrap(); + assert_eq!(resolved_url, "mainnet-rpc"); + } + + // Verify that weth is now resolved to the actual address + let weth_after = mainnet.vars.get("weth").unwrap(); + assert_eq!(weth_after.as_str().unwrap(), "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"); + + // Check all other vars match expected values for (k, v) in &expected_mainnet.vars { assert_eq!(v, mainnet.vars.get(k).unwrap()); } @@ -5251,9 +5262,18 @@ mod tests { assert!(uint_array.as_array().is_some()); assert_eq!(uint_array.as_array().unwrap().len(), 3); + // Verify that the environment variable in the array was resolved let addr_array = mainnet.vars.get("addr_array").unwrap(); assert!(addr_array.as_array().is_some()); assert_eq!(addr_array.as_array().unwrap().len(), 2); + assert_eq!( + addr_array.as_array().unwrap()[0].as_str().unwrap(), + "0x1111111111111111111111111111111111111111" + ); + assert_eq!( + addr_array.as_array().unwrap()[1].as_str().unwrap(), + "0x2222222222222222222222222222222222222222" + ); let bytes32_array = mainnet.vars.get("bytes32_array").unwrap(); assert!(bytes32_array.as_array().is_some()); @@ -5272,6 +5292,34 @@ mod tests { }); } + #[test] + fn test_fork_config_missing_env_var_fails() { + figment::Jail::expect_with(|jail| { + jail.create_file( + "foundry.toml", + r#" + [forks] + [forks.mainnet] + rpc_endpoint = "${MISSING_RPC_VAR}" + + [forks.mainnet.vars] + some_value = "${MISSING_VAR}" + "#, + )?; + let result = Config::load(); + assert!(result.is_err()); + let err_str = result.unwrap_err().to_string(); + + // Check that the error message contains the chain name and specific variable name + assert!( + err_str.contains("[forks.mainnet]") + && (err_str.contains("MISSING_RPC_VAR") || err_str.contains("MISSING_VAR")) + ); + + Ok(()) + }); + } + #[test] fn test_can_inherit_a_base_toml() { figment::Jail::expect_with(|jail| { diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index c57ecb4a68ca4..69f60e70a677f 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -5,7 +5,7 @@ use alloy_hardforks::EthereumHardfork; use alloy_primitives::{Address, Bytes, address, hex}; use anvil::{NodeConfig, spawn}; use forge_script_sequence::ScriptSequence; -use foundry_config::{ForkConfig, RpcEndpoint, RpcEndpointUrl, RpcEndpoints}; +use foundry_config::{ForkChainConfig, ForkConfigs, RpcEndpoint, RpcEndpointUrl, RpcEndpoints}; use foundry_test_utils::{ ScriptOutcome, ScriptTester, rpc::{self, next_http_archive_rpc_url}, @@ -2615,12 +2615,12 @@ accessList [] chainId 31337 gasLimit [..] gasPrice -input [..] -maxFeePerBlobGas + [..] +maxFeePerBlobmaxFeePerBlobGas maxFeePerGas maxPriorityFeePerGas -nonce 0 -to + 0 +to type 0 value 0 @@ -3240,14 +3240,15 @@ forgetest_init!(can_access_fork_config_chain_ids, |prj, cmd| { prj.insert_ds_test(); prj.update_config(|config| { - config.forks = vec![ - ( - "mainnet".to_string(), - ForkConfig { - rpc_endpoint: Some(RpcEndpoint::new(RpcEndpointUrl::Url( - "mainnet-rpc".to_string(), - ))), - vars: vec![ + config.forks = ForkConfigs( + vec![ + ( + "mainnet".to_string(), + ForkChainConfig { + rpc_endpoint: Some(RpcEndpoint::new(RpcEndpointUrl::Url( + "mainnet-rpc".to_string(), + ))), + vars: vec![ ("i256".into(), "-1234".into()), ("u256".into(), 1234.into()), ("bool".into(), true.into()), @@ -3274,15 +3275,15 @@ forgetest_init!(can_access_fork_config_chain_ids, |prj, cmd| { ("bytes_array".into(), vec!["0x1234", "0x5678", "0xabcd"].into()), ("string_array".into(), vec!["hello", "world", "test"].into()), ] - .into_iter() - .collect(), - }, - ), - ( - "optimism".to_string(), - ForkConfig { - rpc_endpoint: None, - vars: vec![ + .into_iter() + .collect(), + }, + ), + ( + "optimism".to_string(), + ForkChainConfig { + rpc_endpoint: None, + vars: vec![ ("i256".into(), "-4321".into()), ("u256".into(), 4321.into()), ("bool".into(), "false".into()), @@ -3309,13 +3310,14 @@ forgetest_init!(can_access_fork_config_chain_ids, |prj, cmd| { ("bytes_array".into(), vec!["0xdead", "0xbeef", "0xcafe"].into()), ("string_array".into(), vec!["foo", "bar", "baz"].into()), ] - .into_iter() - .collect(), - }, - ), - ] - .into_iter() - .collect(); + .into_iter() + .collect(), + }, + ), + ] + .into_iter() + .collect(), + ); config.rpc_endpoints = RpcEndpoints::new(vec![( "optimism", @@ -3372,38 +3374,38 @@ contract ForkScript is DSTest { function testArrayCheatcodes() public view { (uint256[2] memory chainIds, string[2] memory chains) = ([uint256(1), uint256(10)], ["mainnet", "optimism"]); - + for (uint256 i = 0; i < chains.length; i++) { console.log("Testing arrays for chain:", chains[i]); - + // Test bool array bool[] memory boolArray = vm.readForkChainBoolArray(chainIds[i], "bool_array"); assert(boolArray.length == 3); console.log(" > bool_array[0]:", boolArray[0]); - + // Test int array int256[] memory intArray = vm.readForkChainIntArray(chainIds[i], "int_array"); assert(intArray.length == 3); console.log(" > int_array[0]:", intArray[0]); - + // Test uint array uint256[] memory uintArray = vm.readForkChainUintArray(chainIds[i], "uint_array"); assert(uintArray.length == 3); console.log(" > uint_array[0]:", uintArray[0]); - + // Test address array address[] memory addrArray = vm.readForkChainAddressArray(chainIds[i], "addr_array"); assert(addrArray.length == 2); console.log(" > addr_array[0]:", addrArray[0]); - + // Test bytes32 array bytes32[] memory bytes32Array = vm.readForkChainBytes32Array(chainIds[i], "bytes32_array"); assert(bytes32Array.length == 2); - - // Test bytes array + + // Test bytes array bytes[] memory bytesArray = vm.readForkChainBytesArray(chainIds[i], "bytes_array"); assert(bytesArray.length == 3); - + // Test string array string[] memory stringArray = vm.readForkChainStringArray(chainIds[i], "string_array"); assert(stringArray.length == 3); @@ -3463,14 +3465,15 @@ forgetest_init!(can_derive_chain_id_access_fork_config, |prj, cmd| { let mainnet_endpoint = rpc::next_http_rpc_endpoint(); prj.update_config(|config| { - config.forks = vec![ - ( - "mainnet".to_string(), - ForkConfig { - rpc_endpoint: Some(RpcEndpoint::new(RpcEndpointUrl::Url( - mainnet_endpoint.clone(), - ))), - vars: vec![ + config.forks = ForkConfigs( + vec![ + ( + "mainnet".to_string(), + ForkChainConfig { + rpc_endpoint: Some(RpcEndpoint::new(RpcEndpointUrl::Url( + mainnet_endpoint.clone(), + ))), + vars: vec![ ("i256".into(), "-1234".into()), ("u256".into(), 1234.into()), ("bool".into(), true.into()), @@ -3497,15 +3500,15 @@ forgetest_init!(can_derive_chain_id_access_fork_config, |prj, cmd| { ("bytes_array".into(), vec!["0x1234", "0x5678", "0xabcd"].into()), ("string_array".into(), vec!["hello", "world", "test"].into()), ] - .into_iter() - .collect(), - }, - ), - ( - "optimism".to_string(), - ForkConfig { - rpc_endpoint: None, - vars: vec![ + .into_iter() + .collect(), + }, + ), + ( + "optimism".to_string(), + ForkChainConfig { + rpc_endpoint: None, + vars: vec![ ("i256".into(), "-4321".into()), ("u256".into(), 4321.into()), ("bool".into(), "false".into()), @@ -3532,13 +3535,14 @@ forgetest_init!(can_derive_chain_id_access_fork_config, |prj, cmd| { ("bytes_array".into(), vec!["0xdead", "0xbeef", "0xcafe"].into()), ("string_array".into(), vec!["foo", "bar", "baz"].into()), ] - .into_iter() - .collect(), - }, - ), - ] - .into_iter() - .collect(); + .into_iter() + .collect(), + }, + ), + ] + .into_iter() + .collect(), + ); config.rpc_endpoints = RpcEndpoints::new(vec![( "optimism", @@ -3594,39 +3598,39 @@ contract ForkTest is DSTest { function testArrayCheatcodes() public { // Test array cheatcodes without specifying chain (uses active fork) console.log(" > Arrays:"); - + // Test bool array bool[] memory boolArray = vm.readForkBoolArray("bool_array"); assert(boolArray.length == 3); assert(boolArray[0] == true); console.log(" > bool_array[0]:", boolArray[0]); - + // Test int array int256[] memory intArray = vm.readForkIntArray("int_array"); assert(intArray.length == 3); assert(intArray[0] == -100); console.log(" > int_array[0]:", intArray[0]); - + // Test uint array uint256[] memory uintArray = vm.readForkUintArray("uint_array"); assert(uintArray.length == 3); assert(uintArray[0] == 100); console.log(" > uint_array[0]:", uintArray[0]); - + // Test address array address[] memory addrArray = vm.readForkAddressArray("addr_array"); assert(addrArray.length == 2); assert(addrArray[0] == 0x1111111111111111111111111111111111111111); console.log(" > addr_array[0]:", addrArray[0]); - + // Test bytes32 array bytes32[] memory bytes32Array = vm.readForkBytes32Array("bytes32_array"); assert(bytes32Array.length == 2); - + // Test bytes array bytes[] memory bytesArray = vm.readForkBytesArray("bytes_array"); assert(bytesArray.length == 3); - + // Test string array string[] memory stringArray = vm.readForkStringArray("string_array"); assert(stringArray.length == 3); @@ -3662,7 +3666,7 @@ Logs: > addr_array[0]: 0x1111111111111111111111111111111111111111 > string_array[0]: hello -[FAIL: vm.forkChain: a fork must be selected] test_panicsWhithoutSelectedFork() ([GAS]) +[FAIL: vm.readForkChain: a fork must be selected] test_panicsWhithoutSelectedFork() ([GAS]) ... "#]]); }); @@ -3675,15 +3679,19 @@ forgetest_init!(throws_error_when_reading_invalid_address, |prj, cmd| { let mainnet_endpoint = rpc::next_http_rpc_endpoint(); prj.update_config(|config| { - config.forks = vec![( - "mainnet".to_string(), - ForkConfig { - rpc_endpoint: Some(RpcEndpoint::new(RpcEndpointUrl::Url(mainnet_endpoint.clone()))), - vars: vec![("owner".into(), "0xdeadbeef".into())].into_iter().collect(), - }, - )] - .into_iter() - .collect(); + config.forks = ForkConfigs( + vec![( + "mainnet".to_string(), + ForkChainConfig { + rpc_endpoint: Some(RpcEndpoint::new(RpcEndpointUrl::Url( + mainnet_endpoint.clone(), + ))), + vars: vec![("owner".into(), "0xdeadbeef".into())].into_iter().collect(), + }, + )] + .into_iter() + .collect(), + ); }); prj.add_source( From e3ad11f536f96359e1b962df52b8af15489eae32 Mon Sep 17 00:00:00 2001 From: 0xrusowsky <90208954+0xrusowsky@users.noreply.github.com> Date: Sat, 16 Aug 2025 19:35:17 +0200 Subject: [PATCH 13/15] fix: test spacing --- crates/forge/tests/cli/script.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 69f60e70a677f..114d16f2bbe29 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -2615,12 +2615,12 @@ accessList [] chainId 31337 gasLimit [..] gasPrice - [..] -maxFeePerBlobmaxFeePerBlobGas +input [..] +maxFeePerBlobGas maxFeePerGas maxPriorityFeePerGas - 0 -to +nonce 0 +to type 0 value 0 From 535fdc543000b7d94827cd265184d862f33db94b Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Sat, 16 Aug 2025 19:50:42 +0200 Subject: [PATCH 14/15] fix: expected test logs --- crates/forge/tests/cli/script.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/forge/tests/cli/script.rs b/crates/forge/tests/cli/script.rs index 114d16f2bbe29..5706fba924cc8 100644 --- a/crates/forge/tests/cli/script.rs +++ b/crates/forge/tests/cli/script.rs @@ -3716,8 +3716,8 @@ contract ForkTest is DSTest { cmd.args(["test", "ForkTest"]).assert_failure().stdout_eq(str![[r#" ... -[FAIL: vm.readForkAddress: failed parsing $owner as type `address`: parser error: -$owner +[FAIL: vm.readForkAddress: Failed to parse 'owner' in [fork.mainnet]: failed parsing "0xdeadbeef" as type `address`: parser error: +0xdeadbeef ^ invalid string length] test_throwsErrorWhen() ([GAS]) ... From 655384b9fa5871235dda23d85f5e5249bfefd49e Mon Sep 17 00:00:00 2001 From: 0xrusowsky <0xrusowsky@proton.me> Date: Mon, 18 Aug 2025 09:29:11 +0200 Subject: [PATCH 15/15] fix: use `let Self { .. } = self` syntax --- crates/cheatcodes/src/fork.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/cheatcodes/src/fork.rs b/crates/cheatcodes/src/fork.rs index 7c59a9f1ad5a0..e0d698658ea39 100644 --- a/crates/cheatcodes/src/fork.rs +++ b/crates/cheatcodes/src/fork.rs @@ -98,15 +98,17 @@ macro_rules! impl_get_value_cheatcode { ($struct:ident, $sol_type:expr,stateful) => { impl Cheatcode for $struct { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { key } = self; let chain = get_active_fork_chain_id(ccx)?; - get_value(chain, &self.key, $sol_type, ccx.state) + get_value(chain, key, $sol_type, ccx.state) } } }; ($struct:ident, $sol_type:expr) => { impl Cheatcode for $struct { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - get_value(self.chain.to::(), &self.key, $sol_type, state) + let Self { chain, key } = self; + get_value(chain.to::(), key, $sol_type, state) } } }; @@ -116,15 +118,17 @@ macro_rules! impl_get_array_cheatcode { ($struct:ident, $sol_type:expr,stateful) => { impl Cheatcode for $struct { fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result { + let Self { key } = self; let chain = get_active_fork_chain_id(ccx)?; - get_array(chain, &self.key, $sol_type, ccx.state) + get_array(chain, key, $sol_type, ccx.state) } } }; ($struct:ident, $sol_type:expr) => { impl Cheatcode for $struct { fn apply(&self, state: &mut crate::Cheatcodes) -> Result { - get_array(self.chain.to::(), &self.key, $sol_type, state) + let Self { chain, key } = self; + get_array(chain.to::(), key, $sol_type, state) } } };