Skip to content

Commit 72046f8

Browse files
refactor: simplify gas snapshot handling in cheatcodes (#12605)
1 parent d9e9239 commit 72046f8

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

crates/cheatcodes/src/evm.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1214,8 +1214,7 @@ fn inner_start_gas_snapshot(
12141214
name: Option<String>,
12151215
) -> Result {
12161216
// Revert if there is an active gas snapshot as we can only have one active snapshot at a time.
1217-
if ccx.state.gas_metering.active_gas_snapshot.is_some() {
1218-
let (group, name) = ccx.state.gas_metering.active_gas_snapshot.as_ref().unwrap().clone();
1217+
if let Some((group, name)) = &ccx.state.gas_metering.active_gas_snapshot {
12191218
bail!("gas snapshot was already started with group: {group} and name: {name}");
12201219
}
12211220

@@ -1241,10 +1240,9 @@ fn inner_stop_gas_snapshot(
12411240
name: Option<String>,
12421241
) -> Result {
12431242
// If group and name are not provided, use the last snapshot group and name.
1244-
let (group, name) = group.zip(name).unwrap_or_else(|| {
1245-
let (group, name) = ccx.state.gas_metering.active_gas_snapshot.as_ref().unwrap().clone();
1246-
(group, name)
1247-
});
1243+
let (group, name) = group
1244+
.zip(name)
1245+
.unwrap_or_else(|| ccx.state.gas_metering.active_gas_snapshot.clone().unwrap());
12481246

12491247
if let Some(record) = ccx
12501248
.state

0 commit comments

Comments
 (0)