refactor(cheatcodes): mv ScriptWallets into Cheatcode#9106
Merged
Conversation
grandizzy
reviewed
Oct 14, 2024
grandizzy
left a comment
Collaborator
There was a problem hiding this comment.
lgtm, have one suggestion, pls check
| /// Returns the configured script wallets. | ||
| pub fn script_wallets(&self) -> Option<&ScriptWallets> { | ||
| self.config.script_wallets.as_ref() | ||
| pub fn script_wallets(&self) -> Option<&Wallets> { |
Collaborator
There was a problem hiding this comment.
nit, maybe instead script_wallets and set_wallets fns we could have single
pub fn script_wallets(&mut self) -> &Wallets {
self.wallets.get_or_insert(Wallets::new(MultiWallet::default(), None))
}then we can simplify inject_wallet to
fn inject_wallet(state: &mut Cheatcodes, wallet: LocalSigner<SigningKey>) -> Address {
let address = wallet.address();
state.script_wallets().add_local_signer(wallet);
address
}and getWalletsCall to
impl Cheatcode for getWalletsCall {
fn apply_stateful(&self, ccx: &mut CheatsCtxt) -> Result {
let signers = ccx.state.script_wallets().signers().unwrap_or_default();
Ok(signers.abi_encode())
}
}wdyt?
Member
There was a problem hiding this comment.
oops didn't notice the auto-merge, @yash-atreya please take a look, I think this is reasonable
Contributor
Author
There was a problem hiding this comment.
Sorry @grandizzy, it was on auto-merge. I'll make a follow up PR
klkvr
approved these changes
Oct 14, 2024
rplusq
pushed a commit
to rplusq/foundry
that referenced
this pull request
Nov 29, 2024
…rs#9106) * refactor(`cheatcodes`): mv `ScriptWallets` into `Cheatcode` from `CheatsConfig` * nit * rename `ScriptWallets` to `Wallets` * rename cheatcode * doc nits
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 #9104
Solution
ScriptWalletsintoCheatcodefromCheatsConfig.walletsandwallets(&self, w: ScriptWallets) -> Selfto InspectorStackBuilder. This holds the script wallets till we build theCheatcodes.CheatsConfigcloning i.eArc::make_mut(&mut state.config).ScriptWalletstoWalletsas this refactor opens up space for adding unlocked wallets in the test environment as well.