Skip to content
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

feat(cheatcode): coinbase(address) - modify block.coinbase #1493

Merged
merged 4 commits into from
May 4, 2022

Conversation

wardbradt
Copy link
Contributor

This PR adds the cheat code bank(address) which sets block.coinbase by internally modifying data.env.block.coinbase.

I'm not too familiar with foundry's internals, so I'm not highly confident that this doesn't break something unexpected. But it is a pretty small change and all tests pass.

Motivation

This is useful for testing contracts that depend on the value of block.coinbase.

@@ -17,6 +17,7 @@ ethers::contract::abigen!(
roll(uint256)
warp(uint256)
fee(uint256)
bank(address)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think naming the cheatcode coinbase would be more clear/intuitive, and consistent with fee and chainId. Otherwise LGTM! 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, updated accordingly

@wardbradt wardbradt changed the title feat(cheatcode): bank(address) - modify block.coinbase feat(cheatcode): coinbase(address) - modify block.coinbase May 4, 2022
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.

thanks, lgtm

@mattsse mattsse merged commit e14774f into foundry-rs:master May 4, 2022
@onbjerg onbjerg added the T-feature Type: feature label May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-feature Type: feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants