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): change startPrank to overwrite existing prank instead of erroring #4826

Merged
merged 16 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove clones by only updating prank after first time applied
  • Loading branch information
4meta5 committed Apr 29, 2023
commit a29f3375711fc7f0d8b6a1a37c014371d47dd35b
7 changes: 4 additions & 3 deletions evm/src/executor/inspector/cheatcodes/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,12 @@ impl Prank {
}

/// Apply the prank by setting `used` to true iff it is false
pub fn apply(&self) -> Self {
/// Only returns self in the case it is updated
pub fn apply(&self) -> Option<Self> {
if self.used {
self.clone()
None
} else {
Prank { used: true, ..self.clone() }
Some(Prank { used: true, ..self.clone() })
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion evm/src/executor/inspector/cheatcodes/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,11 @@ where
prank_applied = true;
}
// If prank applied, then update the prank state accordingly
// iff it has changed (after the first time applied)
if prank_applied {
self.prank = Some(prank.apply());
if let Some(applied_prank) = prank.apply() {
self.prank = Some(applied_prank);
}
}
}
}
Expand Down