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 all 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
20 changes: 13 additions & 7 deletions crates/cargo-contract/src/cmd/extrinsics/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ use transcode::{
Value,
};

use anyhow::{
Ok,
Result,
};
use anyhow::Result;
use std::fmt::Write;
use subxt::{
self,
Expand Down Expand Up @@ -107,9 +104,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) {
Ok(contract_event) => {
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