feat: Add bid sorting to auction page and add tx links
All checks were successful
Build Docker / Build Image (push) Successful in 1m16s
All checks were successful
Build Docker / Build Image (push) Successful in 1m16s
This commit is contained in:
Binary file not shown.
@@ -476,9 +476,11 @@ def getAddressFromCoin(coinhash: str, coinindex = 0):
|
|||||||
# Get the address from the hash
|
# Get the address from the hash
|
||||||
response = requests.get(get_node_api_url(f"coin/{coinhash}/{coinindex}"))
|
response = requests.get(get_node_api_url(f"coin/{coinhash}/{coinindex}"))
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
|
print(f"Error getting address from coin: {response.text}")
|
||||||
return "No Owner"
|
return "No Owner"
|
||||||
data = response.json()
|
data = response.json()
|
||||||
if 'address' not in data:
|
if 'address' not in data:
|
||||||
|
print(json.dumps(data, indent=4))
|
||||||
return "No Owner"
|
return "No Owner"
|
||||||
return data['address']
|
return data['address']
|
||||||
|
|
||||||
|
|||||||
55
render.py
55
render.py
@@ -278,30 +278,61 @@ def timestamp_to_readable_time(timestamp):
|
|||||||
return readable_time
|
return readable_time
|
||||||
|
|
||||||
def bids(bids,reveals):
|
def bids(bids,reveals):
|
||||||
html = ''
|
# Create a list to hold bid data for sorting
|
||||||
|
bid_data = []
|
||||||
|
|
||||||
|
# Prepare data for sorting
|
||||||
for bid in bids:
|
for bid in bids:
|
||||||
lockup = bid['lockup']
|
lockup = bid['lockup'] / 1000000
|
||||||
lockup = lockup / 1000000
|
|
||||||
html += "<tr>"
|
|
||||||
html += f"<td>{lockup:,.2f} HNS</td>"
|
|
||||||
revealed = False
|
revealed = False
|
||||||
|
value = 0
|
||||||
|
|
||||||
|
# Check if this bid has been revealed
|
||||||
for reveal in reveals:
|
for reveal in reveals:
|
||||||
if reveal['bid'] == bid['prevout']['hash']:
|
if reveal['bid'] == bid['prevout']['hash']:
|
||||||
revealed = True
|
revealed = True
|
||||||
value = reveal['value']
|
value = reveal['value'] / 1000000
|
||||||
value = value / 1000000
|
|
||||||
html += f"<td>{value:,.2f} HNS</td>"
|
|
||||||
bidValue = lockup - value
|
|
||||||
html += f"<td>{bidValue:,.2f} HNS</td>"
|
|
||||||
break
|
break
|
||||||
if not revealed:
|
|
||||||
|
# Store all relevant information for sorting and display
|
||||||
|
bid_data.append({
|
||||||
|
'bid': bid,
|
||||||
|
'lockup': lockup,
|
||||||
|
'revealed': revealed,
|
||||||
|
'value': value,
|
||||||
|
'sort_value': value if revealed else lockup # Use value for sorting if revealed, otherwise lockup
|
||||||
|
})
|
||||||
|
|
||||||
|
# Sort by the sort_value in descending order (highest first)
|
||||||
|
bid_data.sort(key=lambda x: x['sort_value'], reverse=True)
|
||||||
|
|
||||||
|
# Generate HTML from sorted data
|
||||||
|
html = ''
|
||||||
|
for data in bid_data:
|
||||||
|
bid = data['bid']
|
||||||
|
lockup = data['lockup']
|
||||||
|
revealed = data['revealed']
|
||||||
|
value = data['value']
|
||||||
|
|
||||||
|
html += "<tr>"
|
||||||
|
html += f"<td>{lockup:,.2f} HNS</td>"
|
||||||
|
|
||||||
|
if revealed:
|
||||||
|
bidValue = lockup - value
|
||||||
|
html += f"<td>{value:,.2f} HNS</td>"
|
||||||
|
html += f"<td>{bidValue:,.2f} HNS</td>"
|
||||||
|
else:
|
||||||
html += f"<td>Hidden until reveal</td>"
|
html += f"<td>Hidden until reveal</td>"
|
||||||
html += f"<td>Hidden until reveal</td>"
|
html += f"<td>Hidden until reveal</td>"
|
||||||
|
|
||||||
if bid['own']:
|
if bid['own']:
|
||||||
html += "<td>You</td>"
|
html += "<td>You</td>"
|
||||||
else:
|
else:
|
||||||
html += "<td>Unknown</td>"
|
html += f"<td>Unknown</td>"
|
||||||
|
|
||||||
|
html += f"<td><a class='text-decoration-none' style='color: var(--bs-table-color-state, var(--bs-table-color-type, var(--bs-table-color)));' href='{TX_EXPLORER_URL}{bid['prevout']['hash']}'>Bid TX 🔗</a></td>"
|
||||||
html += "</tr>"
|
html += "</tr>"
|
||||||
|
|
||||||
return html
|
return html
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,7 @@
|
|||||||
<th>Bid</th>
|
<th>Bid</th>
|
||||||
<th>Blind</th>
|
<th>Blind</th>
|
||||||
<th>Owner</th>
|
<th>Owner</th>
|
||||||
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
Reference in New Issue
Block a user