feat: Add info on when bidding closes
All checks were successful
Build Docker / Build Image (push) Successful in 1m14s
All checks were successful
Build Docker / Build Image (push) Successful in 1m14s
This commit is contained in:
Binary file not shown.
@@ -184,7 +184,6 @@ def selectWallet(account: str):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def getBalance(account: str):
|
def getBalance(account: str):
|
||||||
# Get the total balance
|
# Get the total balance
|
||||||
info = hsw.getBalance('default', account)
|
info = hsw.getBalance('default', account)
|
||||||
@@ -446,6 +445,13 @@ def send(account, address, amount):
|
|||||||
|
|
||||||
|
|
||||||
def isOwnDomain(account, name: str):
|
def isOwnDomain(account, name: str):
|
||||||
|
# Get domain
|
||||||
|
domain_info = getDomain(name)
|
||||||
|
owner = getAddressFromCoin(domain_info['info']['owner']['hash'],domain_info['info']['owner']['index'])
|
||||||
|
# Select the account
|
||||||
|
print(hsw.rpc_selectWallet(account))
|
||||||
|
print(hsw.rpc_getAccount(owner))
|
||||||
|
|
||||||
domains = getDomains(account)
|
domains = getDomains(account)
|
||||||
for domain in domains:
|
for domain in domains:
|
||||||
if domain['name'] == name:
|
if domain['name'] == name:
|
||||||
|
|||||||
41
main.py
41
main.py
@@ -36,18 +36,24 @@ THEME = os.getenv("THEME")
|
|||||||
def blocks_to_time(blocks: int) -> str:
|
def blocks_to_time(blocks: int) -> str:
|
||||||
"""
|
"""
|
||||||
Convert blocks to time in a human-readable format.
|
Convert blocks to time in a human-readable format.
|
||||||
|
Blocks are mined approximately every 10 minutes.
|
||||||
"""
|
"""
|
||||||
if blocks < 0:
|
if blocks < 0:
|
||||||
return "Invalid time"
|
return "Invalid time"
|
||||||
|
|
||||||
hours = blocks // 10
|
if blocks < 6:
|
||||||
minutes = (blocks % 10) * 6
|
return f"{blocks * 10} mins"
|
||||||
if hours >= 24:
|
elif blocks < 144:
|
||||||
days = hours // 24
|
hours = blocks // 6
|
||||||
hours = hours % 24
|
minutes = (blocks % 6) * 10
|
||||||
return f"{days}d {hours}h"
|
return f"{hours} hrs {minutes} mins"
|
||||||
|
else:
|
||||||
return f"{hours}h {minutes}m"
|
days = blocks // 144
|
||||||
|
hours = (blocks % 144) // 6
|
||||||
|
return f"{days} days {hours} hrs"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@@ -520,11 +526,8 @@ def manage(domain: str):
|
|||||||
return redirect("/logout")
|
return redirect("/logout")
|
||||||
|
|
||||||
domain = domain.lower()
|
domain = domain.lower()
|
||||||
|
|
||||||
own_domains = account_module.getDomains(account)
|
if not account_module.isOwnDomain(account, domain):
|
||||||
own_domains = [x['name'] for x in own_domains]
|
|
||||||
own_domains = [x.lower() for x in own_domains]
|
|
||||||
if domain not in own_domains:
|
|
||||||
return redirect("/search?q=" + domain)
|
return redirect("/search?q=" + domain)
|
||||||
|
|
||||||
domain_info = account_module.getDomain(domain)
|
domain_info = account_module.getDomain(domain)
|
||||||
@@ -952,7 +955,17 @@ def auction(domain):
|
|||||||
elif state == 'OPENING':
|
elif state == 'OPENING':
|
||||||
next = f"Bidding opens in {str(stats['blocksUntilBidding'])} blocks (~{blocks_to_time(stats['blocksUntilBidding'])})"
|
next = f"Bidding opens in {str(stats['blocksUntilBidding'])} blocks (~{blocks_to_time(stats['blocksUntilBidding'])})"
|
||||||
elif state == 'BIDDING':
|
elif state == 'BIDDING':
|
||||||
next = f"Reveal in {str(stats['blocksUntilReveal'])} blocks (~{blocks_to_time(stats['blocksUntilReveal'])})"
|
next = f"Reveal in {stats['blocksUntilReveal']} blocks (~{blocks_to_time(stats['blocksUntilReveal'])})"
|
||||||
|
if stats['blocksUntilReveal'] == 1:
|
||||||
|
next += "<br>Bidding no longer possible"
|
||||||
|
elif stats['blocksUntilReveal'] == 2:
|
||||||
|
next += "<br>LAST CHANCE TO BID"
|
||||||
|
elif stats['blocksUntilReveal'] == 3:
|
||||||
|
next += f"<br>Next block is last chance to bid"
|
||||||
|
elif stats['blocksUntilReveal'] < 6:
|
||||||
|
next += f"<br>Last chance to bid in {stats['blocksUntilReveal']-2} blocks"
|
||||||
|
|
||||||
|
|
||||||
elif state == 'REVEAL':
|
elif state == 'REVEAL':
|
||||||
next = f"Reveal ends in {str(stats['blocksUntilClose'])} blocks (~{blocks_to_time(stats['blocksUntilClose'])})"
|
next = f"Reveal ends in {str(stats['blocksUntilClose'])} blocks (~{blocks_to_time(stats['blocksUntilClose'])})"
|
||||||
next_action = f'<a href="/auction/{domain}/reveal">Reveal All</a>'
|
next_action = f'<a href="/auction/{domain}/reveal">Reveal All</a>'
|
||||||
|
|||||||
@@ -68,7 +68,7 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="stick-right">{{next_action|safe}}</div>
|
<div class="stick-right">{{next_action|safe}}</div>
|
||||||
<h4 class="card-title">{{rendered}}</h4>
|
<h4 class="card-title">{{rendered}}</h4>
|
||||||
<h6 class="text-muted mb-2 card-subtitle">{{next}}</h6>
|
<h6 class="text-muted mb-2 card-subtitle">{{next | safe}}</h6>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user