Skip to content

Commit

Permalink
Log failure instead of failing when decoding an event (#769)
Browse files Browse the repository at this point in the history
* Log failure instead of failing

* if/else -> match

* ok
  • Loading branch information
pmikolajczyk41 authored Oct 7, 2022
1 parent 5fb010d commit 0b65d42
Showing 1 changed file with 13 additions and 7 deletions.
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

0 comments on commit 0b65d42

Please sign in to comment.