import { fetchBlocks, fetchTransactions, fetchReceipts, } from "../lib/mockData"; export const overviewTitle = "Network Overview"; export function renderOverviewPage(): string { return ` High-level summaries of recent blocks, transactions, and receipts will appear here. Latest Block Loading block data… Recent Transactions Loading transaction data… Receipt Metrics Loading receipt data… `; } export async function initOverviewPage(): Promise { const [blocks, transactions, receipts] = await Promise.all([ fetchBlocks(), fetchTransactions(), fetchReceipts(), ]); const blockStats = document.querySelector( "#overview-block-stats", ); if (blockStats) { if (blocks.length > 0) { const latest = blocks[0]; blockStats.innerHTML = ` Height: ${latest.height} Hash: ${latest.hash.slice(0, 18)}… Proposer: ${latest.proposer} Time: ${new Date(latest.timestamp).toLocaleString()} `; } else { blockStats.innerHTML = `No mock block data available.`; } } const txStats = document.querySelector( "#overview-transaction-stats", ); if (txStats) { if (transactions.length > 0) { const succeeded = transactions.filter((tx) => tx.status === "Succeeded"); txStats.innerHTML = ` Total Mock Tx: ${transactions.length} Succeeded: ${succeeded.length} Pending: ${transactions.length - succeeded.length} `; } else { txStats.innerHTML = `No mock transaction data available.`; } } const receiptStats = document.querySelector( "#overview-receipt-stats", ); if (receiptStats) { if (receipts.length > 0) { const attested = receipts.filter((receipt) => receipt.status === "Attested"); receiptStats.innerHTML = ` Total Receipts: ${receipts.length} Attested: ${attested.length} Pending: ${receipts.length - attested.length} `; } else { receiptStats.innerHTML = `No mock receipt data available.`; } } }
High-level summaries of recent blocks, transactions, and receipts will appear here.