Files
observer/web/src/App.tsx
T
grenadeandClaude Opus 5 6b45004907
deploy / build (push) Successful in 7m46s
deploy / deploy-web (push) Successful in 5s
deploy / deploy-api (push) Successful in 15s
feat: the call index — declared surface against actual use
Every explorer shows what happened on a chain. None shows the difference
between what a chain can do and what it has done, because none holds the
runtime's declared surface next to the activity. We already hold both, so this
is a join rather than new indexing.

    quantus    v152   6 of 58 dispatchables used
    heisenberg v148   6 of 58 — and a different six

The gap is the interesting half. ReversibleTransfers, TechReferenda, Vesting
and Preimage are shipped, documented and untouched; "this chain has governance
nobody has used" is a different statement from "this chain has no governance",
and only one of them appears on a list of what happened. Unused calls keep their
signature and their docs, both read from the chain rather than a source tree,
and are dimmed rather than hidden.

Two chains on the same runtime family diverging is the other thing it surfaces:
mainnet has exercised the wormhole batch verifiers and nothing else, while
Heisenberg has a whole multisig lifecycle and no wormhole traffic.

`/:chain/call/:pallet/:call` is the feed behind a row — who dispatched it, with
what arguments, and whether it worked. Nothing is written per call type: the
arguments render through the same `Payload` as everything else, so a pallet
added next year gets a row on the index when the runtime declares it and a
working page the moment somebody uses it.

`BlockExtrinsic` gained `height` and `at`, which are redundant on a block's own
page and the entire point on a feed where every row is a different block.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Jp6a8EDar9ueEhAxzep4V5
2026-09-10 07:44:29 +03:00

343 lines
14 KiB
TypeScript

/**
* The page.
*
* A chain and a window, with at most one of a block, a miner or an account in
* focus above the standings. All of it lives in the path — see `lib/routes` for
* the grammar and why it is a path rather than a hash — so every view here can
* be linked to, opened in a new tab, and returned to with the back button.
*/
import { useCallback, useEffect, useMemo } from 'react'
import { Link, useLocation, useNavigate } from 'react-router-dom'
import { AccountPanel } from './components/AccountPanel'
import { AccountsIndex } from './components/AccountsIndex'
import { BlockPanel } from './components/BlockPanel'
import { BlocksIndex } from './components/BlocksIndex'
import { CallPanel } from './components/CallPanel'
import { CallsIndex } from './components/CallsIndex'
import { BlockTicker } from './components/BlockTicker'
import { ChainSwitcher } from './components/ChainSwitcher'
import { Leaderboard } from './components/Leaderboard'
import { MinerPanel } from './components/MinerPanel'
import { RuntimePanel } from './components/RuntimePanel'
import { RuntimesIndex } from './components/RuntimesIndex'
import { SectionNav } from './components/SectionNav'
import { StatBar } from './components/StatBar'
import { seconds, windowSpan } from './lib/format'
import { href, parse, WINDOWS } from './lib/routes'
import { useObserver, usePinnedMiners, useWatch } from './lib/store'
export default function App() {
const state = useObserver()
const location = useLocation()
const navigate = useNavigate()
const { pinned } = usePinnedMiners()
const route = useMemo(() => parse(location.pathname), [location.pathname])
// Default to the busiest chain we can actually track — the list is ordered
// by node count, and an untracked chain has nothing behind it.
const fallbackChain = state.chains.find((c) => c.tracking === 'full')?.id ?? null
const chain = route.chain ?? fallbackChain
const info = useMemo(
() => state.chains.find((c) => c.id === chain) ?? null,
[state.chains, chain],
)
// `/` is not a page, it is "whichever chain the operator put first" — a
// question only the backend can answer, and only once it has answered the
// chain list. Replacing rather than pushing keeps the bare domain out of the
// back stack, where it would bounce the user straight forward again.
useEffect(() => {
if (!route.chain && fallbackChain) {
navigate(href({ chain: fallbackChain, window: route.window }), { replace: true })
}
}, [route.chain, route.window, fallbackChain, navigate])
// The standings and a miner's page, which is one row of them. Everything
// else is about a thing that happened once.
const windowApplies =
route.index === null &&
route.block === null &&
route.account === null &&
route.runtime === null &&
route.call === null
// Normalise a path that resolves to the standings but is not spelled like
// them: `/quantus`, `/quantus/miner` (the standings *are* the miner index),
// and anything unrecognised, which `parse` degrades to the front page rather
// than a 404. Without this the address bar keeps saying something the page is
// not, and the section nav cannot mark where the reader is.
useEffect(() => {
if (!chain) return
const standings =
route.index === null &&
route.block === null &&
route.miner === null &&
route.account === null &&
route.runtime === null &&
route.call === null
const canonical = href({ chain, window: route.window })
if (standings && location.pathname !== canonical) {
navigate(canonical, { replace: true })
}
}, [chain, route, location.pathname, navigate])
useWatch(chain, route.window)
/**
* A height has resolved to its hash; put the hash in the address bar.
*
* `replace`, not a navigation: it is the same block under the name that will
* still mean this block after a reorg, so it belongs in place of the height
* rather than on top of it in the back stack. The panel keeps rendering from
* the height it was given — `BlockPanel` keys on its own prop — so this does
* not refetch.
*/
const blockResolved = useCallback(
(hash: string) => {
if (!chain) return
navigate(href({ chain, block: hash }), { replace: true })
},
[chain, navigate],
)
const interval =
state.summary?.block_interval_seconds ?? state.summary?.target_block_time_seconds ?? 6
const activeWindow = WINDOWS.find((w) => w.id === route.window) ?? WINDOWS[1]!
return (
<div className="shell">
<header className="masthead">
<div className="mark">
<Sigil />
<div>
<div className="mark-name">
blackbeard<span>.observer</span>
</div>
<div className="mark-tagline">quantus mining · this is sparta</div>
</div>
</div>
<div className="masthead-right">
{/* Only where a window means something. It sets the span the ranks
are computed over, so it belongs on the standings and on a
miner's page — which is one row of those same standings. A block,
an account, a runtime and the three indexes have no window: a
block happened once, a balance has no span, and a control that
does nothing where it sits teaches a reader to distrust it. */}
{windowApplies && (
<nav className="segmented" aria-label="Leaderboard window">
{WINDOWS.map((w) => (
<Link
key={w.id}
// Carried onto whatever page this is, not back to the
// standings: changing the span of a miner's rank is not a
// reason to stop looking at that miner.
to={href({ ...route, chain, window: w.id })}
aria-current={w.id === route.window ? 'page' : undefined}
title={`${w.blocks.toLocaleString('en-US')} blocks — ${windowSpan(w.blocks, interval)}`}
>
{w.label}
</Link>
))}
</nav>
)}
<div className={`status status-${state.connection}`}>
<span className="status-dot" />
{state.connection}
</div>
</div>
</header>
<ChainSwitcher chains={state.chains} active={chain} window={route.window} />
<SectionNav chain={chain} route={route} window={route.window} />
{info?.status === 'awaiting' && (
<div className="banner banner-warn">
<strong>{info.display_name}</strong> has not started producing blocks yet. This page will
come alive on its own the moment it does — no refresh needed.
</div>
)}
{info?.status === 'unreachable' && (
<div className="banner banner-warn">
The observer has lost contact with the {info.display_name} node. The standings below are
the last it saw.
</div>
)}
{info?.status === 'syncing' && (
<div className="banner banner-warn">
The node is still importing history. Block interval — and therefore every hashrate on this
page — is nominal until it reaches the tip.
</div>
)}
<StatBar summary={state.summary} windowName={route.window} />
{route.block && chain && (
<BlockPanel
chain={chain}
block={route.block}
targetSeconds={info?.target_block_time_seconds ?? 6}
decimals={info?.token_decimals ?? 12}
symbol={info?.token_symbol ?? ''}
onResolved={blockResolved}
/>
)}
{route.account && chain && (
<AccountPanel
chain={chain}
address={route.account}
// Read from the chain rather than assumed: 12 is what Quantus
// reports, but a chain that said otherwise would render every
// balance on this page wrong and look entirely plausible doing it.
decimals={info?.token_decimals ?? 12}
symbol={info?.token_symbol ?? ''}
/>
)}
{route.miner && chain && (
<MinerPanel chain={chain} miner={route.miner} windowName={route.window} />
)}
{/* Every one of these is a page, not something opened over the board. A
URL that names one thing has that thing as its whole subject, and
leaving eleven unrelated mining rows underneath is the site failing to
notice which page it is on. The board is what `/:chain/:window` is
for. */}
{route.runtime !== null && chain && <RuntimePanel chain={chain} spec={route.runtime} />}
{route.index === 'block' && chain && <BlocksIndex chain={chain} />}
{route.index === 'call' && chain && <CallsIndex chain={chain} />}
{route.call && chain && (
<CallPanel
chain={chain}
pallet={route.call[0]}
call={route.call[1]}
decimals={info?.token_decimals ?? 12}
symbol={info?.token_symbol ?? ''}
/>
)}
{route.index === 'account' && chain && (
<AccountsIndex
chain={chain}
decimals={info?.token_decimals ?? 12}
symbol={info?.token_symbol ?? ''}
/>
)}
{route.index === 'runtime' && chain && (
<RuntimesIndex chain={chain} current={state.summary?.spec_version ?? null} />
)}
{!route.account &&
!route.miner &&
!route.block &&
route.runtime === null &&
route.call === null &&
route.index === null && (
<div className="two-col">
<section className="panel">
<div className="panel-head">
<h2 className="panel-title">The Standings</h2>
<span className="eyebrow">
last {activeWindow.blocks.toLocaleString('en-US')} blocks ·{' '}
{windowSpan(activeWindow.blocks, interval)}
{pinned.length > 0 && ` · ${pinned.length} marked yours`}
</span>
</div>
<Leaderboard rows={state.leaderboard} chain={chain} ready={state.ready} />
</section>
<section className="panel">
<div className="panel-head">
<h2 className="panel-title">Live Blocks</h2>
<span className="eyebrow">
{state.summary?.block_interval_seconds
? `${seconds(state.summary.block_interval_seconds)} apart`
: 'measuring'}
</span>
</div>
<BlockTicker blocks={state.blocks} chain={chain} />
</section>
</div>
)}
<footer className="footer">
<span>
Every miner on this board is derived from the <code>pow_</code> digest in each block
header — no registration, no opt-in, no way to be left out.
</span>
<span>
Hashrates are estimates over a finite window, not measurements of anyone's hardware. A
miner's figure is the difficulty of the blocks it won — expected hashes, by definition —
divided by the time they spanned, so a miner that won while the network was smaller is
credited with the work it actually did rather than a share of what the network is now.
</span>
<span>
Node names are a best-effort mapping, inferred from which node reported a block to
telemetry first — never a claim the miner made. A <code>node?</code> tag marks one resting
on a single block or a narrow lead; later blocks correct it. The reward preimage beside it
is the only identity the chain itself asserts. An <code>elsewhere</code> tag means the
name was earned by the same reward preimage on another chain, not observed on this one.
</span>
{state.summary?.spec_version !== null && state.summary?.spec_version !== undefined && (
<span>
{/* "Decoded how?" has an answer, and it is a page. Every event and
reward on this site was read against this runtime's own type
registry rather than against anything written here, so the
runtime is a load-bearing part of the explanation and not a
footnote. */}
Rewards and transfers are decoded against the chain's own metadata — the type registry
the node produces by running the runtime WASM in each block's state, not a schema
written here. This chain is on{' '}
<Link to={href({ chain, runtime: state.summary.spec_version })}>
{state.summary.spec_name ?? 'runtime'} v{state.summary.spec_version}
</Link>
.
</span>
)}
<span className="colophon">
{/* Its own line rather than a fourth item in the `space-between`
flow: the three above are caveats about the numbers, this is
where to go and check them. Opens in a tab of its own so the
socket behind this page keeps its connection. */}
Every number here is derived from public block headers, and the code that derives them is
public too —{' '}
<a
href="https://git.lair.cafe/quantus/blackbeard.observer"
target="_blank"
rel="noreferrer noopener"
>
git.lair.cafe/quantus/blackbeard.observer
</a>
.
</span>
</footer>
</div>
)
}
/** The mark: a spear-point shield, drawn rather than shipped as an asset. */
function Sigil() {
return (
<svg width="34" height="40" viewBox="0 0 34 40" aria-hidden="true">
<path
d="M17 1 L32 7 V20 C32 29 25 35 17 39 C9 35 2 29 2 20 V7 Z"
fill="none"
stroke="var(--data)"
strokeWidth="1.6"
/>
<path
d="M17 8 L24 12 V21 C24 26 20.5 29.5 17 31.5 C13.5 29.5 10 26 10 21 V12 Z"
fill="var(--data-wash)"
/>
<path d="M17 11 V28" stroke="var(--accent)" strokeWidth="1.6" />
<path d="M13 15 L17 11 L21 15" fill="none" stroke="var(--accent)" strokeWidth="1.6" />
</svg>
)
}