feat: Add api route for possible outbidded domains
This commit is contained in:
41
account.py
41
account.py
@@ -628,6 +628,47 @@ def getBids(account, domain="NONE"):
|
||||
bids.append(bid)
|
||||
return bids
|
||||
|
||||
def getPossibleOutbids(account):
|
||||
# Get all bids
|
||||
bids = getBids(account)
|
||||
if 'error' in bids:
|
||||
return []
|
||||
|
||||
# Get current height
|
||||
current_height = getBlockHeight()
|
||||
|
||||
# Sort out bids older than 720 blocks
|
||||
bids = [bid for bid in bids if (current_height - bid['height']) <= 720]
|
||||
possible_outbids = []
|
||||
|
||||
for bid in bids:
|
||||
domain = bid['name']
|
||||
|
||||
# Check to make sure that bidding is still happening
|
||||
domain_info = getDomain(domain)
|
||||
if 'info' not in domain_info or 'state' not in domain_info['info']:
|
||||
print(f"Domain {domain} not found or no info available",flush=True)
|
||||
continue
|
||||
if domain_info['info']['state'] != "BIDDING":
|
||||
continue
|
||||
|
||||
|
||||
current_highest_bid = bid['value']
|
||||
domain_bids = getBids(account, domain)
|
||||
print(domain)
|
||||
print(json.dumps(domain_bids, indent=4))
|
||||
for domain_bid in domain_bids:
|
||||
if domain_bid["own"]:
|
||||
current_highest_bid = max(current_highest_bid, domain_bid['value'])
|
||||
continue
|
||||
if domain_bid['value'] != -1000000:
|
||||
print("Revealed bid")
|
||||
continue
|
||||
if current_highest_bid < domain_bid["lockup"]:
|
||||
possible_outbids.append(domain)
|
||||
break
|
||||
|
||||
return possible_outbids
|
||||
|
||||
def getReveals(account, domain):
|
||||
return hsw.getWalletRevealsByName(domain, account)
|
||||
|
||||
6
main.py
6
main.py
@@ -1673,6 +1673,12 @@ def api_wallet(function):
|
||||
|
||||
return send_file('templates/assets/img/HNS.png')
|
||||
|
||||
|
||||
if function == "possibleOutbids":
|
||||
return jsonify({"result": account_module.getPossibleOutbids(account)})
|
||||
|
||||
|
||||
|
||||
return jsonify({"error": "Invalid function", "result": "Invalid function"}), 400
|
||||
|
||||
@app.route('/api/v1/wallet/<function>/mobile', methods=["GET"])
|
||||
|
||||
@@ -358,7 +358,7 @@ def bidDomains(bids,domains, sortbyDomains=False):
|
||||
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='/auction/{domain['name']}'>{renderDomain(domain['name'])}</a></td>"
|
||||
html += f"<td>{domain['state']}</td>"
|
||||
html += f"<td style='white-space: nowrap;'>{bidDisplay}</td>"
|
||||
html += f"<td class='hide-mobile'>{domain['height']:,}</td>"
|
||||
html += f"<td class='hide-mobile'>{bid['height']:,}</td>"
|
||||
html += "</tr>"
|
||||
else:
|
||||
for domain in domains:
|
||||
@@ -374,7 +374,7 @@ def bidDomains(bids,domains, sortbyDomains=False):
|
||||
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='/auction/{domain['name']}'>{renderDomain(domain['name'])}</a></td>"
|
||||
html += f"<td>{domain['state']}</td>"
|
||||
html += f"<td>{bidDisplay}</td>"
|
||||
html += f"<td class='hide-mobile'>{domain['height']:,}</td>"
|
||||
html += f"<td class='hide-mobile'>{bid['height']:,}</td>"
|
||||
html += "</tr>"
|
||||
return html
|
||||
|
||||
|
||||
Reference in New Issue
Block a user