Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

fix: do proper lookup for event keys for transaction status #60

Merged
merged 3 commits into from
Dec 11, 2023
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
19 changes: 13 additions & 6 deletions src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -635,12 +635,19 @@ impl Database {

// Look for the reurn code associated to the tx
for event in end_events {
// we assume it will always be in this order
if event.attributes[5].key == "hash"
&& event.attributes[5].value.to_ascii_lowercase() == hex::encode(&hash_id)
{
// using unwrap here is ok because we assume it is always going to be a number unless there is a bug in the node
return_code = Some(event.attributes[0].value.parse().unwrap());
for attr in event.attributes.iter() {
// We look to confirm hash of transaction
if attr.key == "hash"
&& attr.value.to_ascii_lowercase() == hex::encode(&hash_id)
{
// Now we look for the return code
for attr in event.attributes.iter() {
if attr.key == "code" {
// using unwrap here is ok because we assume it is always going to be a number unless there is a bug in the node
return_code = Some(attr.value.parse().unwrap());
}
}
}
}
}

Expand Down
Loading