Skip to content

Commit a02ee13

Browse files
authored
chore: aggregate PRs (#12493)
This PR aggregates changes from the following PRs: - Closes #12448 by @\strmfos - Closes #12465 by @\wedjob0X - Closes #12485 by @\Doryu001 - Closes #12487 by @\kilavvy - Closes #12492 by @\avorylli
1 parent c45e880 commit a02ee13

File tree

5 files changed

+26
-43
lines changed

5 files changed

+26
-43
lines changed

crates/cheatcodes/src/evm.rs

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ fn get_recorded_state_diffs(ccx: &mut CheatsCtxt) -> BTreeMap<Address, AccountSt
14971497
});
14981498
let layout = storage_layouts.get(&storage_access.account);
14991499
// Update state diff. Do not overwrite the initial value if already set.
1500-
match account_diff.state_diff.entry(storage_access.slot) {
1500+
let entry = match account_diff.state_diff.entry(storage_access.slot) {
15011501
Entry::Vacant(slot_state_diff) => {
15021502
// Get storage layout info for this slot
15031503
// Include mapping slots if available for the account
@@ -1509,9 +1509,8 @@ fn get_recorded_state_diffs(ccx: &mut CheatsCtxt) -> BTreeMap<Address, AccountSt
15091509

15101510
let slot_info = layout.and_then(|layout| {
15111511
let decoder = SlotIdentifier::new(layout.clone());
1512-
decoder
1513-
.identify(&storage_access.slot, mapping_slots)
1514-
.or_else(|| {
1512+
decoder.identify(&storage_access.slot, mapping_slots).or_else(
1513+
|| {
15151514
// Create a map of new values for bytes/string
15161515
// identification. These values are used to determine
15171516
// the length of the data which helps determine how many
@@ -1524,43 +1523,31 @@ fn get_recorded_state_diffs(ccx: &mut CheatsCtxt) -> BTreeMap<Address, AccountSt
15241523
&storage_access.slot,
15251524
&current_base_slot_values,
15261525
)
1527-
})
1528-
.map(|mut info| {
1529-
// Always decode values first
1530-
info.decode_values(
1531-
storage_access.previousValue,
1532-
storage_access.newValue,
1533-
);
1534-
1535-
// Then handle long bytes/strings if applicable
1536-
if info.is_bytes_or_string() {
1537-
info.decode_bytes_or_string_values(
1538-
&storage_access.slot,
1539-
&raw_changes_by_slot,
1540-
);
1541-
}
1542-
1543-
info
1544-
})
1526+
},
1527+
)
15451528
});
15461529

15471530
slot_state_diff.insert(SlotStateDiff {
15481531
previous_value: storage_access.previousValue,
15491532
new_value: storage_access.newValue,
15501533
slot_info,
1551-
});
1534+
})
15521535
}
1553-
Entry::Occupied(mut slot_state_diff) => {
1554-
let entry = slot_state_diff.get_mut();
1536+
Entry::Occupied(slot_state_diff) => {
1537+
let entry = slot_state_diff.into_mut();
15551538
entry.new_value = storage_access.newValue;
1556-
1557-
// Update decoded values if we have slot info
1558-
if let Some(ref mut slot_info) = entry.slot_info {
1559-
slot_info.decode_values(
1560-
entry.previous_value,
1561-
storage_access.newValue,
1562-
);
1563-
}
1539+
entry
1540+
}
1541+
};
1542+
1543+
// Update decoded values if we have slot info
1544+
if let Some(slot_info) = &mut entry.slot_info {
1545+
slot_info.decode_values(entry.previous_value, storage_access.newValue);
1546+
if slot_info.is_bytes_or_string() {
1547+
slot_info.decode_bytes_or_string_values(
1548+
&storage_access.slot,
1549+
&raw_changes_by_slot,
1550+
);
15641551
}
15651552
}
15661553
}

crates/doc/src/preprocessor/git_source.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ impl Preprocessor for GitSource {
2626
fn preprocess(&self, documents: Vec<Document>) -> Result<Vec<Document>, eyre::Error> {
2727
if let Some(ref repo) = self.repository {
2828
let repo = repo.trim_end_matches('/');
29-
let commit = self.commit.clone().unwrap_or("master".to_owned());
29+
let commit = self.commit.as_deref().unwrap_or("master");
3030
for document in &documents {
3131
if document.from_library {
3232
continue;

crates/script-sequence/src/sequence.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,10 @@ impl ScriptSequence {
194194

195195
// TODO: ideally we want the name of the function here if sig is calldata
196196
let filename = sig_to_file_name(sig);
197+
let filename_with_ext = format!("{filename}-latest.json");
197198

198-
broadcast.push(format!("{filename}-latest.json"));
199-
cache.push(format!("{filename}-latest.json"));
199+
broadcast.push(&filename_with_ext);
200+
cache.push(&filename_with_ext);
200201

201202
Ok((broadcast, cache))
202203
}
@@ -237,7 +238,6 @@ pub fn sig_to_file_name(sig: &str) -> String {
237238
return sig.to_string();
238239
}
239240

240-
// return sig as is
241241
sig.to_string()
242242
}
243243

crates/script/src/simulate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl PreSimulationState {
239239
let mut script_config = self.script_config.clone();
240240
script_config.evm_opts.fork_url = Some(rpc.clone());
241241
let runner = script_config.get_runner().await?;
242-
Ok((rpc.clone(), runner))
242+
Ok((rpc, runner))
243243
});
244244
try_join_all(futs).await
245245
}

crates/sol-macro-gen/src/sol_macro_gen.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,7 @@ edition = "2021"
325325
}
326326

327327
fn check_file_contents(&self, file_path: &Path, expected_contents: &str) -> Result<()> {
328-
eyre::ensure!(
329-
file_path.is_file() && file_path.exists(),
330-
"{} is not a file",
331-
file_path.display()
332-
);
328+
eyre::ensure!(file_path.is_file(), "{} is not a file", file_path.display());
333329
let file_contents = &fs::read_to_string(file_path).wrap_err("Failed to read file")?;
334330

335331
// Format both

0 commit comments

Comments
 (0)