From 2b6447fd1207ec4fbbaf893b42f88ed397a5b59f Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Tue, 28 Jan 2025 10:56:24 +1100 Subject: [PATCH] fix: Add rounding to bid display and strip batch inputs --- main.py | 15 ++++++++------- plugins/batching.py | 14 ++++++++++++++ render.py | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 7bf2f37..4d864ea 100644 --- a/main.py +++ b/main.py @@ -278,6 +278,8 @@ def auctions(): balance = account_module.getBalance(account) locked = balance['locked'] + # Round to 2 decimals + locked = round(locked, 2) # Add commas to the numbers locked = "{:,}".format(locked) @@ -289,7 +291,7 @@ def auctions(): # Sort sort = request.args.get("sort") if sort == None: - sort = "domain" + sort = "state" sort = sort.lower() sort_price = "" sort_price_next = "⬇" @@ -301,7 +303,10 @@ def auctions(): direction = request.args.get("direction") if direction == None: - direction = "⬇" + if sort == "state": + direction = "⬆" + else: + direction = "⬇" if direction == "⬆": reverse = True @@ -342,10 +347,6 @@ def auctions(): pending_reveals += 1 plugins = "" - # dashFunctions = plugins_module.getDashboardFunctions() - # for function in dashFunctions: - # functionOutput = plugins_module.runPluginFunction(function["plugin"],function["function"],{},request.cookies.get("account")) - # plugins += render.plugin_output_dash(functionOutput,plugins_module.getPluginFunctionReturns(function["plugin"],function["function"])) message = '' if 'message' in request.args: @@ -377,7 +378,7 @@ def revealAllBids(): return redirect("/auctions?message=No reveals pending") return redirect("/auctions?message=" + response['error']['message']) - return redirect("/success?tx=" + response['hash']) + return redirect("/success?tx=" + response['result']['hash']) @app.route('/search') diff --git a/plugins/batching.py b/plugins/batching.py index 3a7321f..fa944c7 100644 --- a/plugins/batching.py +++ b/plugins/batching.py @@ -290,6 +290,8 @@ def transfer(params, authentication): domains = params["domains"] address = params["address"] domains = domains.splitlines() + domains = [x.strip() for x in domains] + domains = [x for x in domains if x != ""] wallet = authentication.split(":")[0] owned = account.getDomains(wallet) @@ -322,6 +324,8 @@ def transfer(params, authentication): def simple(batchType,params, authentication): domains = params["domains"] domains = domains.splitlines() + domains = [x.strip() for x in domains] + domains = [x for x in domains if x != ""] batch = [] for domain in domains: @@ -351,6 +355,9 @@ def open(params, authentication): def bid(params, authentication): domains = params["domains"] domains = domains.splitlines() + domains = [x.strip() for x in domains] + domains = [x for x in domains if x != ""] + try: bid = float(params["bid"]) blind = float(params["blind"]) @@ -387,6 +394,9 @@ def redeem(params, authentication): def register(params, authentication): domains = params["domains"] domains = domains.splitlines() + domains = [x.strip() for x in domains] + domains = [x for x in domains if x != ""] + batch = [] for domain in domains: batch.append(['UPDATE', domain,{"records": []}]) @@ -410,6 +420,8 @@ def renew(params, authentication): def advancedBid(params, authentication): bids = params["bids"] bids = bids.splitlines() + bids = [x.strip() for x in bids] + bids = [x for x in bids if x != ""] batch = [] for bid in bids: @@ -437,6 +449,8 @@ def advancedBid(params, authentication): def advancedBatch(params, authentication): transactions = params["transactions"] transactions = transactions.splitlines() + transactions = [x.strip() for x in transactions] + transactions = [x for x in transactions if x != ""] batch = [] for transaction in transactions: diff --git a/render.py b/render.py index 2229394..81fe830 100644 --- a/render.py +++ b/render.py @@ -189,6 +189,7 @@ def bidDomains(bids,domains, sortState=False): bidValue = round(bidValue, 2) blind = lockup - bidValue bidValue = "{:,}".format(bidValue) + blind = round(blind, 2) blind = "{:,}".format(blind) bidDisplay = f'{bidValue} HNS + {blind} HNS blind'