feat(cheatcodes): vm.getScriptWallets()#9052
Merged
Merged
Conversation
cheatcodes): vm.getScriptWallets()
Member
|
Are the referenced issues being fixed with this PR? If so please add the GH keywords. |
Contributor
Author
Done |
This reverts commit 4d64356.
grandizzy
reviewed
Oct 8, 2024
grandizzy
left a comment
Collaborator
There was a problem hiding this comment.
we could add following test in forge/tests/cli/script.rs
// Tests that the `getScriptWallets` cheatcode works correctly.
forgetest_init!(can_get_script_wallets, |prj, cmd| {
let script = prj
.add_source(
"Foo",
r#"
import "forge-std/Script.sol";
interface Vm {
function getScriptWallets() external returns (address[] memory wallets);
}
contract WalletScript is Script {
function run() public {
address[] memory wallets = Vm(address(vm)).getScriptWallets();
console.log(wallets[0]);
}
}"#,
)
.unwrap();
cmd.arg("script")
.arg(script)
.args([
"--private-key",
"0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6",
"-v",
])
.assert_success()
.stdout_eq(str![[r#"
[COMPILING_FILES] with [SOLC_VERSION]
[SOLC_VERSION] [ELAPSED]
Compiler run successful!
Script ran successfully.
[GAS]
== Logs ==
0xa0Ee7A142d267C1f36714E4a8F75612F20a79720
"#]]);
});
Contributor
Author
|
forge-std companion PR: foundry-rs/forge-std#620 |
yash-atreya
added a commit
to foundry-rs/forge-std
that referenced
this pull request
Oct 15, 2024
Companion PR for foundry-rs/foundry#9052 Adds the cheatcode `function getWallets() external returns (address[] memory wallets)`
thomas-lamb-tech
pushed a commit
to thomas-lamb-tech/std_forge
that referenced
this pull request
Dec 26, 2024
Companion PR for foundry-rs/foundry#9052 Adds the cheatcode `function getWallets() external returns (address[] memory wallets)`
aubBrooks919
added a commit
to aubBrooks919/forge-std
that referenced
this pull request
Sep 25, 2025
Companion PR for foundry-rs/foundry#9052 Adds the cheatcode `function getWallets() external returns (address[] memory wallets)`
davidLong89
added a commit
to davidLong89/forge-std
that referenced
this pull request
Sep 25, 2025
Companion PR for foundry-rs/foundry#9052 Adds the cheatcode `function getWallets() external returns (address[] memory wallets)`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #7213 + Closes #6198
Solution
Adds
vm.getScriptWallets()that returns an array of addresses whose private keys are locally available i.e provided by the user.This cheatcode helps write scripts that require access to multiple wallets and use them conditionally.