-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
fix(cast): try decoding custom errors when execution reverted in cast send #9794
Conversation
crates/cast/bin/tx.rs
Outdated
|
||
/// Helper function that tries to decode custom error name and inputs from error payload data. | ||
async fn decode_execution_revert(data: &RawValue) -> Result<Option<String>> { | ||
if let Some(err_data) = data.to_string().replace("\"", "").strip_prefix("0x") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serde_json::from_value::<String is probably better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to using serde_json::from_str::<String>
in e9b5e66
crates/cast/bin/tx.rs
Outdated
let mut decoded_error = known_error.name.clone(); | ||
if !known_error.inputs.is_empty() { | ||
decoded_error.push('('); | ||
let error = known_error.decode_error(&hex::decode(err_data)?)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should be able to do write!("({})", ...) with itertools .format(", ")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed in e9b5e66
crates/cast/bin/tx.rs
Outdated
Ok(()) | ||
} | ||
Err(err) => { | ||
if let TransportError::ErrorResp(ref payload) = err { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please use &
not ref
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, fixed
amazingggg, thank you! |
Motivation
cast send
with local artifacts #9789Solution