Skip to content
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

Log failure instead of failing when decoding an event #769

Merged
merged 3 commits into from
Oct 7, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions crates/cargo-contract/src/cmd/extrinsics/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,18 @@ impl DisplayEvents {
) && field.name() == Some("data")
{
tracing::debug!("event data: {:?}", hex::encode(&event_data));
let contract_event = transcoder.decode_contract_event(event_data)?;
let field = Field::new(String::from("data"), contract_event);
event_entry.fields.push(field);
match transcoder.decode_contract_event(event_data) {
Result::Ok(contract_event) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Result::Ok(contract_event) => {
Ok(contract_event) => {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately, we already import method Ok() from anyhow and there would be a collision

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like a mistake, please remove that import.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok :)

let field = Field::new(String::from("data"), contract_event);
event_entry.fields.push(field);
}
Err(err) => {
tracing::warn!(
"Decoding contract event failed: {:?}. It might have come from another contract.",
err
)
}
}
} else {
let field_name =
field.name().map(ToOwned::to_owned).unwrap_or_else(|| {
Expand Down