Skip to content

chore(10027-cheatcode-mutability-tags): Fix Mutability Tags for Cheatcodes that are Missing Them #10351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions crates/cheatcodes/assets/cheatcodes.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions crates/cheatcodes/spec/src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ interface Vm {

/// Get the nonce of a `Wallet`.
#[cheatcode(group = Evm, safety = Safe)]
function getNonce(Wallet calldata wallet) external returns (uint64 nonce);
function getNonce(Wallet calldata wallet) external view returns (uint64 nonce);

/// Loads a storage slot from an address.
#[cheatcode(group = Evm, safety = Safe)]
Expand Down Expand Up @@ -405,7 +405,7 @@ interface Vm {

/// Gets all accessed reads and write slot from a `vm.record` session, for a given address.
#[cheatcode(group = Evm, safety = Safe)]
function accesses(address target) external returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);
function accesses(address target) external view returns (bytes32[] memory readSlots, bytes32[] memory writeSlots);

/// Record all account accesses as part of CREATE, CALL or SELFDESTRUCT opcodes in order,
/// along with the context of the calls
Expand Down Expand Up @@ -436,17 +436,18 @@ interface Vm {

/// Gets the number of elements in the mapping at the given slot, for a given address.
#[cheatcode(group = Evm, safety = Safe)]
function getMappingLength(address target, bytes32 mappingSlot) external returns (uint256 length);
function getMappingLength(address target, bytes32 mappingSlot) external view returns (uint256 length);

/// Gets the elements at index idx of the mapping at the given slot, for a given address. The
/// index must be less than the length of the mapping (i.e. the number of keys in the mapping).
#[cheatcode(group = Evm, safety = Safe)]
function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external returns (bytes32 value);
function getMappingSlotAt(address target, bytes32 mappingSlot, uint256 idx) external view returns (bytes32 value);

/// Gets the map key and parent of a mapping at a given slot, for a given address.
#[cheatcode(group = Evm, safety = Safe)]
function getMappingKeyAndParentOf(address target, bytes32 elementSlot)
external
view
returns (bool found, bytes32 key, bytes32 parent);

// -------- Block and Transaction Properties --------
Expand Down Expand Up @@ -570,7 +571,7 @@ interface Vm {

/// Utility cheatcode to remove any EIP-2930 access list set by `accessList` cheatcode.
#[cheatcode(group = Evm, safety = Unsafe)]
function noAccessList() external;
function noAccessList() external view;

/// Utility cheatcode to mark specific storage slot as warm, simulating a prior read.
#[cheatcode(group = Evm, safety = Unsafe)]
Expand Down Expand Up @@ -694,7 +695,7 @@ interface Vm {

/// Reads the current `msg.sender` and `tx.origin` from state and reports if there is any active caller modification.
#[cheatcode(group = Evm, safety = Unsafe)]
function readCallers() external returns (CallerMode callerMode, address msgSender, address txOrigin);
function readCallers() external view returns (CallerMode callerMode, address msgSender, address txOrigin);

// ----- Arbitrary Snapshots -----

Expand Down Expand Up @@ -866,6 +867,7 @@ interface Vm {
#[cheatcode(group = Evm, safety = Safe)]
function eth_getLogs(uint256 fromBlock, uint256 toBlock, address target, bytes32[] calldata topics)
external
view
returns (EthGetLogs[] memory logs);

// --- Behavior ---
Expand Down Expand Up @@ -907,7 +909,7 @@ interface Vm {

/// Gets all the recorded logs.
#[cheatcode(group = Evm, safety = Safe)]
function getRecordedLogs() external returns (Log[] memory logs);
function getRecordedLogs() external view returns (Log[] memory logs);

// -------- Gas Metering --------

Expand Down Expand Up @@ -2242,7 +2244,7 @@ interface Vm {

/// Returns addresses of available unlocked wallets in the script environment.
#[cheatcode(group = Scripting)]
function getWallets() external returns (address[] memory wallets);
function getWallets() external view returns (address[] memory wallets);

// ======== Utilities ========

Expand Down Expand Up @@ -2308,7 +2310,7 @@ interface Vm {
function indexOf(string calldata input, string calldata key) external pure returns (uint256);
/// Returns true if `search` is found in `subject`, false otherwise.
#[cheatcode(group = String)]
function contains(string calldata subject, string calldata search) external returns (bool result);
function contains(string calldata subject, string calldata search) external pure returns (bool result);

// ======== JSON Parsing and Manipulation ========

Expand Down
20 changes: 10 additions & 10 deletions crates/forge/tests/cli/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2259,7 +2259,7 @@ forgetest_init!(can_get_script_wallets, |prj, cmd| {
import "forge-std/Script.sol";

interface Vm {
function getWallets() external returns (address[] memory wallets);
function getWallets() external view returns (address[] memory wallets);
}

contract WalletScript is Script {
Expand Down Expand Up @@ -2576,13 +2576,13 @@ Chain 31337
accessList []
chainId 31337
gasLimit 228247
gasPrice
gasPrice
input [..]
maxFeePerBlobGas
maxFeePerGas
maxPriorityFeePerGas
maxFeePerBlobGas
maxFeePerGas
maxPriorityFeePerGas
nonce 0
to
to
type 0
value 0

Expand All @@ -2591,11 +2591,11 @@ value 0
accessList []
chainId 31337
gasLimit 93856
gasPrice
gasPrice
input 0x7357f5d2000000000000000000000000000000000000000000000000000000000000007b00000000000000000000000000000000000000000000000000000000000001c8
maxFeePerBlobGas
maxFeePerGas
maxPriorityFeePerGas
maxFeePerBlobGas
maxFeePerGas
maxPriorityFeePerGas
nonce 1
to 0x5FbDB2315678afecb367f032d93F642f64180aa3
type 0
Expand Down
Loading