feat: Add mempool bids and dynamic loading
All checks were successful
Build Docker / Build Image (push) Successful in 50s
All checks were successful
Build Docker / Build Image (push) Successful in 50s
This commit is contained in:
Binary file not shown.
@@ -110,25 +110,33 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
async function loadBids() {
|
async function loadBids(initial = false) {
|
||||||
const tbody = document.getElementById('bids-tbody');
|
const tbody = document.getElementById('bids-tbody');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// Fetch all required data
|
||||||
const response = await fetch(`/api/v1/wallet/domainBids?domain={{search_term}}`);
|
const response = await fetch(`/api/v1/wallet/domainBids?domain={{search_term}}`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
if (initial) {
|
||||||
if (response.ok && data.result) {
|
if (response.ok && data.result) {
|
||||||
tbody.innerHTML = data.result;
|
tbody.innerHTML = data.result;
|
||||||
} else {
|
} else {
|
||||||
tbody.innerHTML = '<tr><td colspan="5" class="text-center text-muted">No bids found. <a href="/auction/{{search_term}}/scan">Rescan Auction</a></td></tr>';
|
tbody.innerHTML = '<tr><td colspan="5" class="text-center text-muted">No bids found. <a href="/auction/{{search_term}}/scan">Rescan Auction</a></td></tr>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
const mempoolResponse = await fetch('/api/v1/hsd/mempoolBids');
|
||||||
console.error('Error loading bids:', error);
|
|
||||||
tbody.innerHTML = '<tr><td colspan="5" class="text-center text-danger">Error loading bids</td></tr>';
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const nextStateResponse = await fetch(`/api/v1/hsd/nextAuctionState?domain={{search_term}}`);
|
const nextStateResponse = await fetch(`/api/v1/hsd/nextAuctionState?domain={{search_term}}`);
|
||||||
|
|
||||||
|
if (!initial) {
|
||||||
|
if (response.ok && data.result) {
|
||||||
|
tbody.innerHTML = data.result;
|
||||||
|
} else {
|
||||||
|
tbody.innerHTML = '<tr><td colspan="5" class="text-center text-muted">No bids found. <a href="/auction/{{search_term}}/scan">Rescan Auction</a></td></tr>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const nextStateData = await nextStateResponse.json();
|
const nextStateData = await nextStateResponse.json();
|
||||||
|
|
||||||
if (nextStateResponse.ok && nextStateData.state) {
|
if (nextStateResponse.ok && nextStateData.state) {
|
||||||
@@ -139,28 +147,20 @@
|
|||||||
document.getElementById('next-action').innerHTML = '';
|
document.getElementById('next-action').innerHTML = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Error fetching next state:', error);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
const mempoolResponse = await fetch('/api/v1/hsd/mempoolBids');
|
|
||||||
const mempoolData = await mempoolResponse.json();
|
const mempoolData = await mempoolResponse.json();
|
||||||
if (mempoolResponse.ok && mempoolData.result) {
|
if (mempoolResponse.ok && mempoolData.result) {
|
||||||
const domainBids = mempoolData.result['{{search_term}}'];
|
const domainBids = mempoolData.result['{{search_term}}'];
|
||||||
if (domainBids && domainBids.length > 0) {
|
if (domainBids && domainBids.length > 0) {
|
||||||
let mempoolRows = '';
|
let mempoolRows = '';
|
||||||
domainBids.forEach(bid => {
|
domainBids.forEach(bid => {
|
||||||
const bidValue = bid.revealed ? (bid.value / 1000000).toFixed(2) : 'Hidden until reveal';
|
const bidValue = bid.revealed ? `${(bid.value / 1000000).toFixed(2)} HNS` : 'Hidden until reveal';
|
||||||
const lockupValue = (bid.lockup / 1000000).toFixed(2);
|
const lockupValue = (bid.lockup / 1000000).toFixed(2);
|
||||||
const blindValue = bid.revealed ? (lockupValue - bidValue).toFixed(2) : 'Hidden until reveal';
|
const blindValue = bid.revealed ? `${((bid.lockup - bid.value) / 1000000).toFixed(2)} HNS` : 'Hidden until reveal';
|
||||||
const type = bid.revealed ? 'Reveal' : 'Bid';
|
const type = bid.revealed ? 'Reveal' : 'Bid';
|
||||||
mempoolRows += `<tr class="table-warning">
|
mempoolRows += `<tr class="table-warning">
|
||||||
<td>${lockupValue} HNS</td>
|
<td>${lockupValue} HNS</td>
|
||||||
<td>${bidValue} HNS</td>
|
<td>${bidValue}</td>
|
||||||
<td>${blindValue} HNS</td>
|
<td>${blindValue}</td>
|
||||||
<td>${bid.owner}</td>
|
<td>${bid.owner}</td>
|
||||||
<td><a class='text-decoration-none' style='color: var(--bs-table-color-state, var(--bs-table-color-type, var(--bs-table-color)));' target='_blank' href='https://shakeshift.com/transaction/${bid.txid}'>Mempool ${type} 🔗</a></td>
|
<td><a class='text-decoration-none' style='color: var(--bs-table-color-state, var(--bs-table-color-type, var(--bs-table-color)));' target='_blank' href='https://shakeshift.com/transaction/${bid.txid}'>Mempool ${type} 🔗</a></td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
@@ -169,17 +169,15 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error loading mempool bids:', error);
|
console.error('Error loading bids:', error);
|
||||||
// Don't override the main table content on mempool error
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load bids when page loads
|
// Load bids when page loads
|
||||||
document.addEventListener('DOMContentLoaded', loadBids);
|
document.addEventListener('DOMContentLoaded', () => loadBids(true));
|
||||||
|
|
||||||
// Auto-refresh bids every 20 seconds
|
// Auto-refresh bids every 20 seconds
|
||||||
setInterval(loadBids, 20000);
|
setInterval(() => loadBids(false), 20000);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user