Skip to content

Commit

Permalink
remove unrwap and add condition
Browse files Browse the repository at this point in the history
  • Loading branch information
sisuresh committed Sep 18, 2024
1 parent f0e0e11 commit 5c44199
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions soroban-env-host/src/events/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,23 @@ impl core::fmt::Display for HostEvent {
// tries to deduce if the event is the fn_call event.
if i == 1 && is_fn_call {
if let ScVal::Bytes(bytes) = topic {
let hash: [u8; 32] = bytes.clone().0.try_into().unwrap();
let strkey = stellar_strkey::Contract(hash);
write!(f, "{}", strkey)?
} else {
display_scval(topic, f)?;
let try_convert_to_hash =
TryInto::<[u8; 32]>::try_into(bytes.0.clone());
if let Ok(contract_id) = try_convert_to_hash {
let strkey = stellar_strkey::Contract(contract_id);
write!(f, "{}", strkey)?;
continue;
}
}
} else {
display_scval(topic, f)?;
}

if let ScVal::Symbol(first_topic_str) = topic {
if first_topic_str.0.as_slice() == "fn_call".as_bytes() {
is_fn_call = true;
display_scval(topic, f)?;

if i == 0 {
if let ScVal::Symbol(first_topic_str) = topic {
if first_topic_str.0.as_slice() == "fn_call".as_bytes() {
is_fn_call = true;
}
}
}
}
Expand Down

0 comments on commit 5c44199

Please sign in to comment.