Skip to content

Commit

Permalink
fix: use Error(string) signature to verify custom errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rplusq committed Nov 29, 2024
1 parent b87dbaa commit fe50a7e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions crates/cast/bin/cmd/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,8 @@ impl SendTxArgs {
if let Some(RpcError::ErrorResp(error_payload)) =
report.downcast_ref::<RpcError<TransportErrorKind>>()
{
// 1. Return if it's not a revert / custom error
if error_payload.code != 3 ||
!error_payload.message.ends_with("execution reverted")
{
// 1. Return if it's not a revert
if error_payload.code != 3 {
return Err(report);
}
// 2. Extract the error data from the ErrorPayload
Expand All @@ -199,6 +197,11 @@ impl SendTxArgs {
};
let error_data_string = error_data.as_str().unwrap_or_default();

// Check if it's a revert string (has an Error(string) signature)
if error_data_string.starts_with("0x08c379a0") {
return Err(report);
}

let pretty_calldata = match pretty_calldata(error_data_string, false).await
{
Ok(pretty_calldata) => pretty_calldata,
Expand Down

0 comments on commit fe50a7e

Please sign in to comment.