feat: Add values to single bids
All checks were successful
Build Docker / Build Image (push) Successful in 1m9s

This commit is contained in:
2025-06-27 14:46:37 +10:00
parent 0e7a72a136
commit 01c6b4ffba

View File

@@ -76,21 +76,21 @@ actionMap = {
"REGISTER": "Registered ", "REGISTER": "Registered ",
"RENEW": "Renewed ", "RENEW": "Renewed ",
"BID": "Bid on ", "BID": "Bid on ",
"REVEAL": "Revealed Bid for ", "REVEAL": "Revealed bid for ",
"REDEEM": "Redeemed Bid for ", "REDEEM": "Redeemed bid for ",
"TRANSFER": "Started Transfer for ", "TRANSFER": "Started transfer for ",
"NONE": "Multiple Actions" "NONE": "Multiple actions"
} }
actionMapPlural = { actionMapPlural = {
"UPDATE": "Updated Multiple Domains' Records", "UPDATE": "Updated multiple domains' records",
"REGISTER": "Registered Multiple Domains", "REGISTER": "Registered multiple domains",
"RENEW": "Renewed Multiple Domains", "RENEW": "Renewed multiple domains",
"BID": "Bid on Domains", "BID": "Bid on multiple domains",
"REVEAL": "Revealed Bids", "REVEAL": "Revealed multiple bids",
"REDEEM": "Redeemed Bids", "REDEEM": "Redeemed multiple bids",
"TRANSFER": "Started Multiple Domain Transfers", "TRANSFER": "Started multiple domain transfers",
"NONE": "Multiple Actions" "NONE": "Multiple actions"
} }
def transactions(txs): def transactions(txs):
@@ -98,11 +98,9 @@ def transactions(txs):
if len(txs) == 0: if len(txs) == 0:
return '<tr><td colspan="5">No transactions found</td></tr>' return '<tr><td colspan="5">No transactions found</td></tr>'
html = '' html = ''
print(f"Processing {len(txs)} transactions")
for tx in txs: for tx in txs:
action = "HNS Transfer" action = "HNS Transfer"
address = tx["outputs"][0]["address"] txhash = tx["hash"]
hash = tx["hash"]
confirmations=tx["confirmations"] confirmations=tx["confirmations"]
mined_date = "Pending" mined_date = "Pending"
if confirmations >= 1: if confirmations >= 1:
@@ -114,6 +112,7 @@ def transactions(txs):
mined_date = datetime.datetime.strptime(mined_date, "%Y-%m-%dT%H:%M:%SZ").strftime("%d %b %Y") mined_date = datetime.datetime.strptime(mined_date, "%Y-%m-%dT%H:%M:%SZ").strftime("%d %b %Y")
incomming = True incomming = True
amount = 0 amount = 0
bid_value = 0
isMulti = False isMulti = False
nameHashes = [] nameHashes = []
@@ -142,12 +141,18 @@ def transactions(txs):
if output["path"] and output["covenant"]["action"] == "NONE": if output["path"] and output["covenant"]["action"] == "NONE":
amount += output["value"] amount += output["value"]
# Check if this is a bid
if output["covenant"]["action"] == "BID":
bid_value += output["value"]
amount -= output["value"]
if not incomming: if not incomming:
# Subtract fee to make it easier to read # Subtract fee to make it easier to read
amount += tx["fee"] amount += tx["fee"]
amount = amount / 1000000 amount = amount / 1000000
bid_value = bid_value / 1000000
humanAction = action humanAction = action
if action == "HNS Transfer": if action == "HNS Transfer":
@@ -157,37 +162,20 @@ def transactions(txs):
humanAction = f"Sent {(amount*-1):,.2f} HNS" humanAction = f"Sent {(amount*-1):,.2f} HNS"
elif action == "FINALIZE": elif action == "FINALIZE":
if incomming and not isMulti: if incomming and not isMulti:
# humanAction = "Received Domain"
# if CONVERT_NAME:
# name = hsd.rpc_getNameByHash(nameHashes[0])
# if name["error"] is None:
# name = name["result"]
humanAction = f"Received {renderFromNameHash(nameHashes[0])}" humanAction = f"Received {renderFromNameHash(nameHashes[0])}"
elif incomming and isMulti: elif incomming and isMulti:
humanAction = "Received Multiple Domains" humanAction = "Received Multiple Domains"
elif not isMulti: elif not isMulti:
humanAction = f"Finalized {renderFromNameHash(nameHashes[0])}" humanAction = f"Finalized {renderFromNameHash(nameHashes[0])}"
# if CONVERT_NAME:
# name = hsd.rpc_getNameByHash(nameHashes[0])
# if name["error"] is None:
# name = name["result"]
# humanAction = f"Finalized {renderDomain(name)}"
else: else:
humanAction = "Finalized Multiple Domain Transfers" humanAction = "Finalized Multiple Domain Transfers"
elif action == "BID" and not isMulti:
humanAction = f"Bid {bid_value:,.2f} HNS on {renderFromNameHash(nameHashes[0])}"
elif isMulti: elif isMulti:
humanAction = actionMapPlural.get(action, "Unknown Action") humanAction = actionMapPlural.get(action, "Unknown Action")
else: else:
humanAction = actionMap.get(action, "Unknown Action") humanAction = actionMap.get(action, "Unknown Action")
humanAction += renderFromNameHash(nameHashes[0]) humanAction += renderFromNameHash(nameHashes[0])
# if CONVERT_NAME:
# name = hsd.rpc_getNameByHash(nameHashes[0])
# if name["error"] is None:
# name = name["result"]
# else:
# name = None
# humanAction += renderDomain(name) if name else "domain"
# else:
# humanAction += "domain"
if amount < 0: if amount < 0:
amount = f"<span style='color: red;'>{amount:,.2f}</span>" amount = f"<span style='color: red;'>{amount:,.2f}</span>"
elif amount > 0: elif amount > 0:
@@ -206,7 +194,7 @@ def transactions(txs):
html += f''' html += f'''
<tr> <tr>
<td style='white-space: nowrap;'>{txdate}</td> <td style='white-space: nowrap;'>{txdate}</td>
<td><a style="color:var(--bs-body-color);" target="_blank" href="{TX_EXPLORER_URL}{hash}">{humanAction}</a></td> <td><a style="color:var(--bs-body-color);" target="_blank" href="{TX_EXPLORER_URL}{txhash}">{humanAction}</a></td>
</tr> </tr>
''' '''
return html return html