From a6cd6a52368c80c06bbdfd30029f4947dcf455dc Mon Sep 17 00:00:00 2001 From: aglkm <39521015+aglkm@users.noreply.github.com> Date: Mon, 7 Jul 2025 12:29:48 +0300 Subject: [PATCH] adding status field --- src/requests.rs | 22 ++++++++++++++++++++-- templates/kernel.html.tera | 12 ++++++------ templates/output.html.tera | 12 ++++++------ 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/requests.rs b/src/requests.rs index 3a689cf..2afcde9 100644 --- a/src/requests.rs +++ b/src/requests.rs @@ -500,7 +500,16 @@ pub async fn get_output(commit: &str, output: &mut Output) -> Result<(), anyhow: output.height = resp["result"]["Ok"][0]["block_height"].to_string(); output.commit = resp["result"]["Ok"][0]["commit"].as_str().unwrap().to_string(); output.out_type = resp["result"]["Ok"][0]["output_type"].as_str().unwrap().to_string(); - output.raw_data = serde_json::to_string_pretty(&resp).unwrap() + output.raw_data = serde_json::to_string_pretty(&resp).unwrap(); + + let resp_status = call("get_status", "[]", "1", "owner").await?; + + if resp_status != Value::Null { + let curr_height = resp_status["result"]["Ok"]["tip"]["height"].to_string(); + let num_conf = curr_height.parse::().unwrap() - output.height.parse::().unwrap() + 1; + + output.status = format!("{} Confirmations", num_conf.to_string()); + } } Ok(()) @@ -546,7 +555,16 @@ pub async fn get_kernel(excess: &str, kernel: &mut Kernel) -> Result<(), anyhow: kernel.ker_type = resp["result"]["Ok"]["tx_kernel"]["features"].as_str().unwrap().to_string(); } - kernel.raw_data = serde_json::to_string_pretty(&resp).unwrap() + kernel.raw_data = serde_json::to_string_pretty(&resp).unwrap(); + + let resp_status = call("get_status", "[]", "1", "owner").await?; + + if resp_status != Value::Null { + let curr_height = resp_status["result"]["Ok"]["tip"]["height"].to_string(); + let num_conf = curr_height.parse::().unwrap() - kernel.height.parse::().unwrap() + 1; + + kernel.status = format!("{} Confirmations", num_conf.to_string()); + } } Ok(()) diff --git a/templates/kernel.html.tera b/templates/kernel.html.tera index b202c10..05ef409 100644 --- a/templates/kernel.html.tera +++ b/templates/kernel.html.tera @@ -6,12 +6,7 @@
-
-
KERNEL
- {% if kernel.status == "Unconfirmed" %} - UNCONFIRMED - {% endif %} -
+
KERNEL

Excess 
@@ -40,6 +35,11 @@
{{ kernel.fee }}
{% endif %} +
+
+
Status 
+
{{ kernel.status }}
+
diff --git a/templates/output.html.tera b/templates/output.html.tera index 2ef9414..13ec2ab 100644 --- a/templates/output.html.tera +++ b/templates/output.html.tera @@ -6,12 +6,7 @@
-
-
OUTPUT
- {% if output.status == "Unconfirmed" %} - UNCONFIRMED - {% endif %} -
+
OUTPUT

Commitment 
@@ -33,6 +28,11 @@
Type 
{{ output.out_type }}
+
+
+
Status 
+
{{ output.status }}
+