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(forge): prompt address and uint cheatcodes #7600

Merged
merged 3 commits into from
Apr 10, 2024

Conversation

kamuik16
Copy link
Contributor

@kamuik16 kamuik16 commented Apr 9, 2024

Closes #5509

cc @mattsse

In case of parse failure, it fails with these errors:

[FAIL. Reason: failed parsing "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293B" as type `address`: parser error:
0x3C44CdDdB6a900fa2b585dd299e03d12FA4293B
^
Odd number of digits] testPrompt_Address() (gas: 2948)
[FAIL. Reason: failed parsing "-1" as type `uint256`: parser error:
-1
^
expected at least one digit] testPrompt_Uint() (gas: 3008)

Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

I'm not sure about this, since these are just vm.parse<Type>(vm.prompt()) users can do this in "userland", rather than keep bloating the already massive list of cheatcodes we have.

cc @mattsse @mds1 @klkvr

crates/cheatcodes/src/fs.rs Outdated Show resolved Hide resolved
crates/cheatcodes/src/fs.rs Outdated Show resolved Hide resolved
Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

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

some feedback on tests, and lets check in on @mds1 if this is what we actually want:

testdata/default/cheats/Prompt.t.sol Outdated Show resolved Hide resolved
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 think the most common prompts will be address and uint, so having a builtin for these makes sense imo

@mds1
Copy link
Collaborator

mds1 commented Apr 9, 2024

One argument in favor of native cheats here is better UX. If I do vm.parseAddress(vm.prompt()) and the user leaves a character off the address, the script would revert when parsing fails, and now you have to start over. But if I do vm.promptAddress() I'd expect the TUI to say "invalid address" and let you try again without starting over

@mattsse mattsse merged commit 9a0f0c2 into foundry-rs:master Apr 10, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat(forge): vm.prompt* cheatcodes
5 participants