Skip to content

Conversation

@0xrusowsky
Copy link
Contributor

@0xrusowsky 0xrusowsky commented Aug 15, 2025

Motivation

  • Extends the newly created fork cheatcodes that load variables from foundry.toml, so that they also support arrays.
  • Renames the cheatcodes so that they start with readFork to be more idiomatic.
  • Adds env var resolving in all fields of the fork config

refs:

example usage:

[forks]

[forks.mainnet]
rpc_endpoint = "${MAINNET_RPC_URL}" # resolves the env var

[forks.mainnet.vars]
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"]

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to prefix all of these with read or parse, read is prob better,

so that these can be mistaken for the exxisting actual fork related cheatcodes

@0xrusowsky 0xrusowsky requested a review from mattsse August 15, 2025 15:13
@0xrusowsky 0xrusowsky moved this to Ready For Review in Foundry Aug 15, 2025
@0xrusowsky 0xrusowsky added this to the v1.4.0 milestone Aug 15, 2025
@0xrusowsky 0xrusowsky self-assigned this Aug 15, 2025
@0xrusowsky 0xrusowsky changed the title feat(cheats): add fork cheats to load array vars feat(cheats): support arrays + rename read + resolve env vars Aug 16, 2025
($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)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls use the let Self {...} = self syntax to not miss arguments

@0xrusowsky 0xrusowsky requested a review from DaniPopes August 18, 2025 07:44
Copy link
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@grandizzy grandizzy merged commit 7cd93eb into master Aug 19, 2025
22 checks passed
@github-project-automation github-project-automation bot moved this from Ready For Review to Done in Foundry Aug 19, 2025
@grandizzy grandizzy deleted the rusowsky/extend-fork-cheats branch August 19, 2025 06:01
grandizzy added a commit to foundry-rs/forge-std that referenced this pull request Aug 19, 2025
- update of read fork cheatcodes:
foundry-rs/foundry#11302
- `getStorageAccesses` cheatcode:
foundry-rs/foundry#11296

---------

Co-authored-by: grandizzy <[email protected]>
@grandizzy grandizzy moved this from Done to Completed in Foundry Aug 25, 2025
MerkleBoy pushed a commit to MerkleBoy/foundry that referenced this pull request Sep 17, 2025
…dry-rs#11302)

* feat(cheats): add fork cheats to load array vars

* add more tests

* refactor to reduce duplicate code

* fix: test spacing

* style: clippy

* fix: test spacing

* style: rename to `readFork..`

* docs: improve cheat comments

* style: rename missing cheats

* docs: update cmnts

* fix: use existing toml and json parsing helper fns

* feat: resolve env vars in 'fork' config

* fix: test spacing

* fix: expected test logs

* fix: use `let Self { .. } = self` syntax

---------

Co-authored-by: grandizzy <[email protected]>
aubBrooks919 added a commit to aubBrooks919/forge-std that referenced this pull request Sep 25, 2025
- update of read fork cheatcodes:
foundry-rs/foundry#11302
- `getStorageAccesses` cheatcode:
foundry-rs/foundry#11296

---------

Co-authored-by: grandizzy <[email protected]>
davidLong89 added a commit to davidLong89/forge-std that referenced this pull request Sep 25, 2025
- update of read fork cheatcodes:
foundry-rs/foundry#11302
- `getStorageAccesses` cheatcode:
foundry-rs/foundry#11296

---------

Co-authored-by: grandizzy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Completed

Development

Successfully merging this pull request may close these issues.

5 participants