Query logs
In this gas
branch, there's only one major change and it's in the sample-actor project. The sample-txn-executor has no change because it has nothing to do with gas fee logs. The sample-front-end added a new UI but mainly it's just typical VUE web UI code changes, so there's no need to explain it in our tutorial. So let's only focus on the sample-actor project.
We'll need to add a new query to get the list of logs and a txn to set the allowance. You can find them in the dfn.rs
file:
These are called "queryOpLogs" and 'setAllownace' which you can see at the end of the file. The txn to setAllowance
is related to the fact that each TApp has an allowance associated with it. The TApp will only be able to spend user funds up to the amount set as the allowance.
In api.rs you can find the async fn query_op_logs
function. The major logic is to call the get_statements_async
function.
then convert the rows to human readable format:
In our runtime, we store records in the log based on date. So we'll query the backend on which dates to query.
Once we've received the json response, the calback function formats them to a UI-friendly format. After that, help::cache_json_with_uuid(&uuid, x).await?;
caches it to local memory and waits for the front end to check this result at a later time.
The code above shows a typical example of how to convert the data from the backend to the web UI friendly format. In this tutorial we cover it for TApp development but it's the same formatting that's commonly used everywhere.
Last updated