Skip to content
Merged
Prev Previous commit
Next Next commit
Fmt
  • Loading branch information
ascjones committed Jun 28, 2023
commit 7fae74c636da94ba4e548a70ad87d76008a6783c
2 changes: 1 addition & 1 deletion crates/cargo-contract/src/cmd/extrinsics/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl DisplayEvents {

/// Construct the contract event data field, attempting to decode the event using the
/// [`ContractMessageTranscoder`] if available.
fn contract_event_data_field(
fn contract_event_data_field(
transcoder: Option<&ContractMessageTranscoder>,
field_metadata: &scale_info::Field<PortableForm>,
event_sig_topic: Option<&sp_core::H256>,
Expand Down
16 changes: 11 additions & 5 deletions crates/transcode/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,11 @@ impl ContractMessageTranscoder {
.find(|msg| msg.label() == &name.to_string())
}

pub fn decode_contract_event(&self, event_sig_topic: &primitive_types::H256, data: &mut &[u8]) -> Result<Value> {
pub fn decode_contract_event(
&self,
event_sig_topic: &primitive_types::H256,
data: &mut &[u8],
) -> Result<Value> {
// data is an encoded `Vec<u8>` so is prepended with its length `Compact<u32>`,
// which we ignore because the structure of the event data is known for
// decoding.
Expand All @@ -296,10 +300,12 @@ impl ContractMessageTranscoder {
.spec()
.events()
.iter()
.find(|event| if let Some(sig_topic) = event.signature_topic() {
sig_topic.as_bytes() == event_sig_topic.as_bytes()
} else {
false
.find(|event| {
if let Some(sig_topic) = event.signature_topic() {
sig_topic.as_bytes() == event_sig_topic.as_bytes()
} else {
false
}
})
.ok_or_else(|| {
anyhow::anyhow!(
Expand Down