From c3a137bfa9f47e5c401ba16dc56fb5d8b1d08ea5 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Thu, 14 Jan 2021 14:24:00 -0800 Subject: [PATCH] use built-in method to retrieve balances on op page, dont run twice --- app/routes/operation.py | 2 -- app/templates/view_operation.html | 17 ++++++++++------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/app/routes/operation.py b/app/routes/operation.py index 88a950f..13cccc8 100644 --- a/app/routes/operation.py +++ b/app/routes/operation.py @@ -52,7 +52,6 @@ def view_operation(id): qr_uri = f'monero:{op.address}?tx_description={op.codename}' qrcode_make(qr_uri).save(_address_qr) qrcode = b64encode(_address_qr.getvalue()).decode() - balance = wallet.balances(op.account_idx) txes = cache.get_transfers(op.account_idx) for type in txes: for tx in txes[type]: @@ -65,7 +64,6 @@ def view_operation(id): 'view_operation.html', op=op, qrcode=qrcode, - balance=balance, txes=all_transfers, prices=op.get_pricing(), droplet=droplet, diff --git a/app/templates/view_operation.html b/app/templates/view_operation.html index fd5e954..80e3bf6 100644 --- a/app/templates/view_operation.html +++ b/app/templates/view_operation.html @@ -1,4 +1,7 @@ {% set node_url = op.codename + '.node.' + config.DO_DOMAIN %} +{% set balances = op.get_balances() %} +{% set balance = balances['balance'] %} +{% set unlocked = balances['unlocked'] %} @@ -14,11 +17,11 @@
{% if txes %} - {% if (balance[0] | from_atomic_xmr) > prices['minimum_xmr'] or droplet %} + {% if (balance | from_atomic_xmr) > prices['minimum_xmr'] or droplet %}

Operation is a Go!

Created: {{ op.create_date }} ({{ op.create_date | humanize }})

Codename: {{ op.codename }}

-

Balance: {{ balance[1] | from_atomic_xmr }} XMR ({{ (balance[0] - balance[1]) | from_atomic_xmr }} locked)

+

Balance: {{ unlocked | from_atomic_xmr }} XMR ({{ (balance - unlocked) | from_atomic_xmr }} locked)

{% if droplet %}

Node: {{ op.get_node_url() }} - @@ -32,16 +35,16 @@

Current XMR price: ${{ prices['xmr_price'] }}

Estimated flight times remaining:

{% else %}

Operation is not ready!

You haven't sent enough XMR.

Codename: {{ op.codename }}

-

Balance: {{ balance[1] | from_atomic_xmr }} XMR ({{ (balance[0] - balance[1]) | from_atomic_xmr }} locked)

+

Balance: {{ unlocked | from_atomic_xmr }} XMR ({{ (balance - unlocked) | from_atomic_xmr }} locked)

Minimum: {{ prices['minimum_xmr'] }}

{% if droplet %}

@@ -88,7 +91,7 @@

{{ op.address }}


-

Balance: {{ balance[1] | from_atomic_xmr }} XMR ({{ (balance[0] - balance[1]) | from_atomic_xmr }} locked)

+

Balance: {{ unlocked | from_atomic_xmr }} XMR ({{ (balance - unlocked) | from_atomic_xmr }} locked)


{% if txes %}