From c4d3df61c87befcad4a8a86ad418e8f2c0fa955a Mon Sep 17 00:00:00 2001 From: lalanza808 Date: Sat, 4 Apr 2020 02:05:09 -0700 Subject: [PATCH] updating static for transaction page --- src/main.rs | 8 +++- templates/transaction.html.tera | 82 ++++++++------------------------- 2 files changed, 24 insertions(+), 66 deletions(-) diff --git a/src/main.rs b/src/main.rs index 34a4700..1d71cff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -85,11 +85,15 @@ fn get_block_by_height(block_height: String) -> Template { } #[get("/transaction/")] -fn get_transaction_by_hash(tx_hash: String) -> Json { +fn get_transaction_by_hash(tx_hash: String) -> Template { let params: JsonValue = json!({"txs_hashes": [&tx_hash]}); let res: GetTransactions = issue_raw_rpc(&"get_transactions", params) .send().unwrap().json().unwrap(); - Json(res) + let context = json!({ + "tx_info": res.txs, + "tx_hash": tx_hash + }); + Template::render("transaction", context) } #[get("/search?")] diff --git a/templates/transaction.html.tera b/templates/transaction.html.tera index 5396af6..7b7b9de 100644 --- a/templates/transaction.html.tera +++ b/templates/transaction.html.tera @@ -2,100 +2,54 @@ {% block content %} +{% for i in tx_info %} +{{i.block_height}} +{{i.block_timestamp}} +{{i.double_spend_seen}} +{{i.in_pool}} +{{i.output_indices}} +{% endfor %} +
-

Transaction {{ block_header.height }}

-

Hash: {{ block_header.hash }}

-

Timestamp: {{ block_header.timestamp }} +

Transaction {{ tx_hash | truncate(length=4) }}

+

Full Hash: {{ tx_hash }}

+

Block Timestamp: {{ tx_info.0.block_timestamp }}

-

Size

-
-

{{ block_header.block_size }} bytes

-
-
-
-
-
-

Depth

-
-

{{ block_header.depth }}

-
-
-
-
-
-

Difficulty

-
-

{{ block_header.difficulty }}

-
-
-
-
-
-

Transactions

+

Block Height

-

{% if tx_hashes %}{{ tx_hashes | length }}{% else %}0{% endif %}

+

{{ tx_info.0.block_height }}

-

Orphaned

+

In Pool

-

{{ block_header.orphan_status }}

+

{{ tx_info.0.in_pool }}

-

Nonce

+

Double Spend

-

{{ block_header.nonce }}

+

{{ tx_info.0.double_spend_seen }}



-
- - - - - - - - - - - - - - - - - {% if tx_hashes %} - {% for hash in tx_hashes %} - - - - - - - - {% endfor %} - {% endif %} -

Block Transactions

CoinbaseHashAmountFeeBytes
{{ block_header.miner_tx_hash | truncate(length=8) }}{{ block_header.reward / 1000000000000 }} XMR0?
{{ hash | truncate(length=8) }}???
-
-

Previous Block

+

View Block