-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(cheatcodes
): vm.getScriptWallets()
#9052
Conversation
cheatcodes
): vm.getScriptWallets()
Are the referenced issues being fixed with this PR? If so please add the GH keywords. |
Done |
This reverts commit 4d64356.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
"#]]);
});
forge-std companion PR: foundry-rs/forge-std#620 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Companion PR for foundry-rs/foundry#9052 Adds the cheatcode `function getWallets() external returns (address[] memory wallets)`
Companion PR for foundry-rs/foundry#9052 Adds the cheatcode `function getWallets() external returns (address[] memory wallets)`
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.