Skip to content

Commit

Permalink
chore: provide a better error message for unknown cheatcodes (#7436)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Mar 19, 2024
1 parent a064b63 commit ffed0de
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion crates/cheatcodes/src/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,17 @@ impl Cheatcodes {
call: &CallInputs,
) -> Result {
// decode the cheatcode call
let decoded = Vm::VmCalls::abi_decode(&call.input, false)?;
let decoded = Vm::VmCalls::abi_decode(&call.input, false).map_err(|e| {
if let alloy_sol_types::Error::UnknownSelector { name: _, selector } = e {
let msg = format!(
"unknown cheatcode with selector {selector}; \
you may have a mismatch between the `Vm` interface (likely in `forge-std`) \
and the `forge` version"
);
return alloy_sol_types::Error::Other(std::borrow::Cow::Owned(msg));
}
e
})?;
let caller = call.context.caller;

// ensure the caller is allowed to execute cheatcodes,
Expand Down

0 comments on commit ffed0de

Please sign in to comment.