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

results from logs #1176

Merged
merged 7 commits into from
Sep 12, 2023
Merged
Changes from 3 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
17 changes: 17 additions & 0 deletions framework/scenario/src/scenario/model/transaction/tx_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ impl TxResponse {

if let Some(out_scr) = out_scr {
self.out = decode_scr_data_or_panic(&out_scr.data);
} else if let Some(write_log_logs) = self.find_last_log("writeLog") {
if let Some(data) = &write_log_logs.data {
let decoded_data = String::from_utf8(base64::decode(data).unwrap()).unwrap();
self.out = decode_scr_data_or_panic(decoded_data.as_str());
}
}

self
Expand Down Expand Up @@ -178,4 +183,16 @@ impl TxResponse {
None
}
}

// Finds last api logs matching the given log identifier.
fn find_last_log(&self, log_identifier: &str) -> Option<&Events> {
if let Some(logs) = &self.api_logs {
logs.events
.iter()
.filter(|event| event.identifier == log_identifier)
.last()
} else {
None
}
}
}