feat: the call index — declared surface against actual use
deploy / build (push) Successful in 7m46s
deploy / deploy-web (push) Successful in 5s
deploy / deploy-api (push) Successful in 15s

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
This commit is contained in:
2026-09-10 07:44:29 +03:00
co-authored by Claude Opus 5
parent 93358dd920
commit 6b45004907
18 changed files with 1040 additions and 26 deletions
@@ -0,0 +1,86 @@
{
"db_name": "PostgreSQL",
"query": "\n select height, extrinsic_index, pallet, call, signer, signature,\n signature_bytes, args as \"args!\", extra, success, at\n from chain_extrinsic\n where chain = $1 and pallet = $2 and call = $3 and height < $4\n order by height desc, extrinsic_index desc\n limit $5\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "height",
"type_info": "Int8"
},
{
"ordinal": 1,
"name": "extrinsic_index",
"type_info": "Int4"
},
{
"ordinal": 2,
"name": "pallet",
"type_info": "Text"
},
{
"ordinal": 3,
"name": "call",
"type_info": "Text"
},
{
"ordinal": 4,
"name": "signer",
"type_info": "Text"
},
{
"ordinal": 5,
"name": "signature",
"type_info": "Text"
},
{
"ordinal": 6,
"name": "signature_bytes",
"type_info": "Int4"
},
{
"ordinal": 7,
"name": "args!",
"type_info": "Jsonb"
},
{
"ordinal": 8,
"name": "extra",
"type_info": "Jsonb"
},
{
"ordinal": 9,
"name": "success",
"type_info": "Bool"
},
{
"ordinal": 10,
"name": "at",
"type_info": "Timestamptz"
}
],
"parameters": {
"Left": [
"Text",
"Text",
"Text",
"Int8",
"Int8"
]
},
"nullable": [
false,
false,
false,
false,
true,
true,
false,
false,
true,
true,
true
]
},
"hash": "0cd66820c66d352a4345b1e784b87ff70fd53f27a516d4e1cd796cb59b126874"
}
@@ -0,0 +1,64 @@
{
"db_name": "PostgreSQL",
"query": "\n select pallet, call,\n count(*) as \"calls!\",\n count(distinct signer) as \"signers!\",\n count(*) filter (where success is false) as \"failed!\",\n count(*) filter (where signer is null) as \"unsigned!\",\n max(height) as \"last_height!\",\n max(at) as last_at\n from chain_extrinsic\n where chain = $1\n group by pallet, call\n ",
"describe": {
"columns": [
{
"ordinal": 0,
"name": "pallet",
"type_info": "Text"
},
{
"ordinal": 1,
"name": "call",
"type_info": "Text"
},
{
"ordinal": 2,
"name": "calls!",
"type_info": "Int8"
},
{
"ordinal": 3,
"name": "signers!",
"type_info": "Int8"
},
{
"ordinal": 4,
"name": "failed!",
"type_info": "Int8"
},
{
"ordinal": 5,
"name": "unsigned!",
"type_info": "Int8"
},
{
"ordinal": 6,
"name": "last_height!",
"type_info": "Int8"
},
{
"ordinal": 7,
"name": "last_at",
"type_info": "Timestamptz"
}
],
"parameters": {
"Left": [
"Text"
]
},
"nullable": [
false,
false,
null,
null,
null,
null,
null,
null
]
},
"hash": "510c0a92c30e07373c60071cebc61ee808274d38e3355ec4152ac7f384980cb3"
}
+152 -20
View File
@@ -17,9 +17,10 @@ use axum::routing::get;
use axum::{Json, Router};
use blackbeard_entities::{
AccountDetail, AccountEvent, AccountRow, ActivitySource, ApiError, BigUintDec, BlockDetail,
ChainInfo, ChainSeries, ChainSummary, LeaderboardRow, MinerDetail, MinerId, MinerSeriesPoint,
RecentBlock, RewardSummary, RuntimeConstant, RuntimeDetail, RuntimeField, RuntimePallet,
RuntimeSignedExtension, RuntimeStorage, RuntimeSummary, RuntimeVariant, Window,
CallIndex, CallSummary, ChainInfo, ChainSeries, ChainSummary, LeaderboardRow, MinerDetail,
MinerId, MinerSeriesPoint, RecentBlock, RewardSummary, RuntimeConstant, RuntimeDetail,
RuntimeField, RuntimePallet, RuntimeSignedExtension, RuntimeStorage, RuntimeSummary,
RuntimeVariant, Window,
};
use serde::{Deserialize, Serialize};
use tower_http::compression::CompressionLayer;
@@ -54,6 +55,8 @@ pub fn router(state: AppState, allowed_origins: &[String]) -> Router {
.route("/v1/chains/{chain}/miners/{miner}", get(miner))
.route("/v1/chains/{chain}/accounts", get(accounts))
.route("/v1/chains/{chain}/accounts/{address}", get(account))
.route("/v1/chains/{chain}/calls", get(calls))
.route("/v1/chains/{chain}/calls/{pallet}/{call}", get(call_feed))
.route("/v1/chains/{chain}/runtimes", get(runtimes))
.route("/v1/chains/{chain}/runtimes/{spec}", get(runtime))
.route("/v1/ws", get(crate::ws::handler))
@@ -437,23 +440,30 @@ async fn block_body(
let Ok(rows) = state.store.extrinsics_at(chain, height).await else {
return Vec::new();
};
rows.into_iter()
.map(|x| blackbeard_entities::BlockExtrinsic {
index: x.extrinsic_index,
pallet: x.pallet,
call: x.call,
signer_address: x
.signer
.as_deref()
.and_then(blackbeard_core::wormhole::ss58_of),
addresses: collect_addresses(&x.args),
signer: x.signer,
signature: x.signature,
signature_bytes: x.signature_bytes,
args: x.args,
success: x.success,
})
.collect()
rows.into_iter().map(into_block_extrinsic).collect()
}
/// One stored extrinsic, in the shape a page renders.
fn into_block_extrinsic(
x: blackbeard_data::store::StoredExtrinsic,
) -> blackbeard_entities::BlockExtrinsic {
blackbeard_entities::BlockExtrinsic {
index: x.extrinsic_index,
height: x.height,
pallet: x.pallet,
call: x.call,
signer_address: x
.signer
.as_deref()
.and_then(blackbeard_core::wormhole::ss58_of),
addresses: collect_addresses(&x.args),
signer: x.signer,
signature: x.signature,
signature_bytes: x.signature_bytes,
args: x.args,
success: x.success,
at: x.at,
}
}
/// Every account id anywhere in a decoded payload, as `0x hex → SS58`.
@@ -722,6 +732,128 @@ async fn accounts(
))
}
/// Every dispatchable the runtime declares, with what has been done with it.
///
/// The declared surface comes from the metadata already parsed for decoding;
/// the usage comes from the extrinsic index. Neither half is interesting alone
/// — a list of calls is documentation, a list of counts is a log — and the join
/// is the thing no explorer shows: which of a chain's capabilities have ever
/// been exercised.
async fn calls(
State(state): State<AppState>,
Path(chain): Path<String>,
) -> Result<Json<CallIndex>, Failure> {
let runtime = state.chain(&chain).ok_or_else(|| unknown_chain(&chain))?;
let id = runtime.id();
let (parsed, spec_version) = {
let inner = runtime.read();
(inner.current_runtime(), inner.spec_version)
};
let Some(parsed) = parsed else {
// No metadata yet means no declared surface to report. An empty list
// would read as "this chain has no calls", which is a different claim.
return Err(Failure(
StatusCode::SERVICE_UNAVAILABLE,
ApiError::new(
"runtime_unknown",
"no runtime metadata cached for this chain yet",
),
));
};
let usage: std::collections::HashMap<(String, String), blackbeard_data::store::CallUsage> =
state
.store
.call_usage(&id)
.await
.map_err(database_unavailable)?
.into_iter()
.map(|u| ((u.pallet.clone(), u.call.clone()), u))
.collect();
let scan = state
.store
.event_scan(&id)
.await
.map_err(database_unavailable)?;
let described = parsed.describe();
let mut calls: Vec<CallSummary> = Vec::new();
for pallet in &described.pallets {
for c in &pallet.calls {
let seen = usage.get(&(pallet.name.clone(), c.name.clone()));
calls.push(CallSummary {
pallet_index: pallet.index,
call_index: c.index,
signature: signature_of(c),
docs: c
.docs
.iter()
.find(|d| !d.trim().is_empty())
.map(|d| d.trim().to_owned()),
calls: seen.map(|u| u.calls).unwrap_or(0),
signers: seen.map(|u| u.signers).unwrap_or(0),
failed: seen.map(|u| u.failed).unwrap_or(0),
unsigned: seen.map(|u| u.unsigned).unwrap_or(0),
last_height: seen.map(|u| u.last_height),
last_at: seen.and_then(|u| u.last_at),
pallet: pallet.name.clone(),
call: c.name.clone(),
});
}
}
// Busiest first, then by the runtime's own declaration order — which puts
// the unused calls in pallet order rather than alphabetically, so a whole
// untouched pallet reads as a block instead of being scattered.
calls.sort_by(|a, b| {
b.calls
.cmp(&a.calls)
.then(a.pallet_index.cmp(&b.pallet_index))
.then(a.call_index.cmp(&b.call_index))
});
let used = calls.iter().filter(|c| c.calls > 0).count() as u32;
Ok(Json(CallIndex {
chain: id,
spec_version,
used,
calls,
indexed_from: scan.map(|(low, _)| low),
indexed_to: scan.map(|(_, high)| high),
}))
}
/// Every dispatch of one kind of call, newest first.
async fn call_feed(
State(state): State<AppState>,
Path((chain, pallet, call)): Path<(String, String, String)>,
Query(query): Query<BeforeQuery>,
) -> Result<Json<Vec<blackbeard_entities::BlockExtrinsic>>, Failure> {
let runtime = state.chain(&chain).ok_or_else(|| unknown_chain(&chain))?;
let rows = state
.store
.extrinsics_of_kind(&runtime.id(), &pallet, &call, query.before, INDEX_PAGE)
.await
.map_err(database_unavailable)?;
Ok(Json(rows.into_iter().map(into_block_extrinsic).collect()))
}
/// A call's arguments as the runtime's own source would write them.
fn signature_of(c: &blackbeard_core::runtime::VariantDescription) -> String {
if c.fields.is_empty() {
return String::new();
}
let args: Vec<String> = c
.fields
.iter()
.map(|f| match &f.name {
Some(n) => format!("{n}: {}", f.type_name),
None => f.type_name.clone(),
})
.collect();
args.join(", ")
}
/// Every runtime this chain has been seen running, oldest first.
async fn runtimes(
State(state): State<AppState>,
+106
View File
@@ -208,6 +208,28 @@ pub struct ActivityRow {
pub accounts: Vec<String>,
}
/// How often one kind of call has been dispatched.
#[derive(Debug, Clone)]
pub struct CallUsage {
/// Dispatching pallet.
pub pallet: String,
/// The call.
pub call: String,
/// How many times it has been dispatched in the indexed record.
pub calls: u64,
/// How many distinct accounts have signed one.
pub signers: u64,
/// How many failed.
pub failed: u64,
/// How many carried no signature — inherents and unsigned dispatches, which
/// on this chain is most of the traffic.
pub unsigned: u64,
/// The most recent block it appeared in.
pub last_height: u64,
/// When that was.
pub last_at: Option<DateTime<Utc>>,
}
/// One decoded extrinsic, ready to store.
#[derive(Debug, Clone)]
pub struct ExtrinsicRecord {
@@ -1277,6 +1299,90 @@ impl Store {
Ok(result.rows_affected())
}
/// How often each kind of call has actually been dispatched.
///
/// The other half of the call index: the runtime declares what is
/// *possible* and this says what has been *done*. Grouped rather than
/// counted per kind because the interesting output is the whole table at
/// once, including the rows that come back empty.
pub async fn call_usage(&self, chain: &ChainId) -> Result<Vec<CallUsage>, DataError> {
let rows = sqlx::query!(
r#"
select pallet, call,
count(*) as "calls!",
count(distinct signer) as "signers!",
count(*) filter (where success is false) as "failed!",
count(*) filter (where signer is null) as "unsigned!",
max(height) as "last_height!",
max(at) as last_at
from chain_extrinsic
where chain = $1
group by pallet, call
"#,
chain.as_str(),
)
.fetch_all(&self.pool)
.await?;
Ok(rows
.into_iter()
.map(|r| CallUsage {
pallet: r.pallet,
call: r.call,
calls: r.calls.max(0) as u64,
signers: r.signers.max(0) as u64,
failed: r.failed.max(0) as u64,
unsigned: r.unsigned.max(0) as u64,
last_height: r.last_height.max(0) as u64,
last_at: r.last_at,
})
.collect())
}
/// Every dispatch of one kind of call, newest first.
pub async fn extrinsics_of_kind(
&self,
chain: &ChainId,
pallet: &str,
call: &str,
before: Option<u64>,
limit: i64,
) -> Result<Vec<StoredExtrinsic>, DataError> {
let before = before.map(|h| h as i64).unwrap_or(i64::MAX);
let rows = sqlx::query!(
r#"
select height, extrinsic_index, pallet, call, signer, signature,
signature_bytes, args as "args!", extra, success, at
from chain_extrinsic
where chain = $1 and pallet = $2 and call = $3 and height < $4
order by height desc, extrinsic_index desc
limit $5
"#,
chain.as_str(),
pallet,
call,
before,
limit,
)
.fetch_all(&self.pool)
.await?;
Ok(rows
.into_iter()
.map(|r| StoredExtrinsic {
height: r.height.max(0) as u64,
extrinsic_index: r.extrinsic_index.max(0) as u32,
pallet: r.pallet,
call: r.call,
signer: r.signer,
signature: r.signature,
signature_bytes: r.signature_bytes.max(0) as u32,
args: r.args,
extra: r.extra,
success: r.success,
at: r.at,
})
.collect())
}
/// One block's extrinsics, in body order.
pub async fn extrinsics_at(
&self,
+6
View File
@@ -16,6 +16,10 @@ pub struct BlockExtrinsic {
/// points at.
#[ts(type = "number")]
pub index: u32,
/// The block it was included in. Redundant on a block's own page and the
/// whole point on a call feed, where every row is a different block.
#[ts(type = "number")]
pub height: u64,
/// Dispatching pallet, as the runtime names it.
pub pallet: String,
/// The call, as the runtime names it.
@@ -42,6 +46,8 @@ pub struct BlockExtrinsic {
/// browser.
#[ts(type = "Record<string, string>")]
pub addresses: BTreeMap<String, String>,
/// The block's own timestamp.
pub at: Option<DateTime<Utc>>,
}
/// A block as the observer recorded it.
+80
View File
@@ -0,0 +1,80 @@
//! What a chain can do, and what it has done.
//!
//! Every explorer shows the second. This crate can carry both, because the
//! runtime declares its whole dispatchable surface in the same metadata the
//! decoder already reads — so "58 calls exist, 10 have ever been used" is a
//! join rather than a research project.
//!
//! The gap is the interesting half. A pallet nobody has touched is a statement
//! about a chain: `ReversibleTransfers` and `TechReferenda` are shipped,
//! documented, and unused, which is a different fact from their not existing.
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use ts_rs::TS;
use crate::ChainId;
/// One dispatchable, declared and — sometimes — used.
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export, export_to = "CallSummary.ts")]
pub struct CallSummary {
/// Dispatching pallet, as the runtime names it.
pub pallet: String,
/// The call, as the runtime names it.
pub call: String,
/// The pallet's index, which is the first byte of this call's encoding.
#[ts(type = "number")]
pub pallet_index: u8,
/// The call's index within that pallet, which is the second byte.
#[ts(type = "number")]
pub call_index: u8,
/// Its arguments, rendered as the runtime's own signature.
pub signature: String,
/// The first line of the runtime's documentation for it, when it carries
/// any. This comes from the chain, not from a source tree.
pub docs: Option<String>,
/// How many times it has been dispatched in the indexed record. Zero means
/// declared and never used, which is a fact worth showing rather than a row
/// worth hiding.
#[ts(type = "number")]
pub calls: u64,
/// How many distinct accounts have signed one.
#[ts(type = "number")]
pub signers: u64,
/// How many failed.
#[ts(type = "number")]
pub failed: u64,
/// How many carried no signature — inherents and unsigned dispatches.
#[ts(type = "number")]
pub unsigned: u64,
/// The most recent block it appeared in, if ever.
#[ts(type = "number")]
pub last_height: Option<u64>,
/// When that was.
pub last_at: Option<DateTime<Utc>>,
}
/// The call surface of one runtime, with its usage.
#[derive(Debug, Clone, Serialize, Deserialize, TS)]
#[ts(export, export_to = "CallIndex.ts")]
pub struct CallIndex {
/// Which chain.
pub chain: ChainId,
/// The runtime this surface was read from. A different runtime declares a
/// different set, so the number is part of the answer.
#[ts(type = "number")]
pub spec_version: Option<u32>,
/// Every dispatchable the runtime declares, used or not.
pub calls: Vec<CallSummary>,
/// How many of them have ever been dispatched.
#[ts(type = "number")]
pub used: u32,
/// The lowest and highest block whose extrinsics have been read — the
/// honest scope of every count above.
#[ts(type = "number")]
pub indexed_from: Option<u64>,
/// The highest block whose extrinsics have been read.
#[ts(type = "number")]
pub indexed_to: Option<u64>,
}
+2
View File
@@ -17,6 +17,7 @@
mod account;
mod block;
mod call;
mod chain;
mod error;
mod miner;
@@ -26,6 +27,7 @@ mod ws;
pub use account::{AccountDetail, AccountEvent, AccountRow, ActivitySource, RewardSummary};
pub use block::{BlockDetail, BlockExtrinsic, BlockObservation, RecentBlock};
pub use call::{CallIndex, CallSummary};
pub use chain::{ChainId, ChainInfo, ChainStatus, ChainSummary, ClientVersion, Tracking};
pub use error::{ApiError, EntityError};
pub use miner::{AttributionSource, LeaderboardRow, MinerDetail, MinerId, MinerSeriesPoint};
+27
View File
@@ -190,6 +190,33 @@ become one decimal rather than four or eight little-endian limbs. Difficulty as
`[1189189, 0, 0, 0, 0, 0, 0, 0]` is a correct description of the bytes and tells
a reader nothing.
## What the chain can do, and what it has done
`/quantus/call` is the one page here that does not exist elsewhere. Every
explorer shows activity; this shows activity against the *declared surface*,
because the runtime describes all 58 of its dispatchables in the same metadata
the decoder already reads. The join is free and the gap is the interesting half:
quantus v152 6 of 58 calls used
heisenberg v148 6 of 58 — and a different six
`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 is
visible on an explorer that lists what happened. The unused rows keep their
signature and their documentation, both straight from the chain rather than from
a source tree.
Two chains diverging on the same runtime family is the other thing it shows:
mainnet has exercised the wormhole batch verifiers and nothing else, while
Heisenberg has a multisig lifecycle — create, propose, approve, execute — and no
wormhole traffic at all.
Nothing on the page is written per call. `/quantus/call/Utility/batch_all` feeds
from the same generic index and renders its arguments through the same
`Payload`, so a pallet added next year has a working page the moment somebody
uses it — and a row on the index the moment the runtime declares it.
## Extrinsics: what was asked, not only what happened
An event is the chain's account of what happened. An extrinsic is the request
+20 -2
View File
@@ -14,6 +14,8 @@ 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'
@@ -56,7 +58,11 @@ export default function App() {
// 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.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),
@@ -70,7 +76,8 @@ export default function App() {
route.block === null &&
route.miner === null &&
route.account === null &&
route.runtime === null
route.runtime === null &&
route.call === null
const canonical = href({ chain, window: route.window })
if (standings && location.pathname !== canonical) {
navigate(canonical, { replace: true })
@@ -205,6 +212,16 @@ export default function App() {
{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}
@@ -220,6 +237,7 @@ export default function App() {
!route.miner &&
!route.block &&
route.runtime === null &&
route.call === null &&
route.index === null && (
<div className="two-col">
<section className="panel">
+10 -1
View File
@@ -9,6 +9,11 @@ export type BlockExtrinsic = {
* points at.
*/
index: number,
/**
* The block it was included in. Redundant on a block's own page and the
* whole point on a call feed, where every row is a different block.
*/
height: number,
/**
* Dispatching pallet, as the runtime names it.
*/
@@ -49,4 +54,8 @@ success: boolean | null,
* rendered and linked without a second implementation of SS58 in the
* browser.
*/
addresses: Record<string, string>, };
addresses: Record<string, string>,
/**
* The block's own timestamp.
*/
at: string | null, };
+34
View File
@@ -0,0 +1,34 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { CallSummary } from "./CallSummary";
import type { ChainId } from "./ChainId";
/**
* The call surface of one runtime, with its usage.
*/
export type CallIndex = {
/**
* Which chain.
*/
chain: ChainId,
/**
* The runtime this surface was read from. A different runtime declares a
* different set, so the number is part of the answer.
*/
spec_version: number,
/**
* Every dispatchable the runtime declares, used or not.
*/
calls: Array<CallSummary>,
/**
* How many of them have ever been dispatched.
*/
used: number,
/**
* The lowest and highest block whose extrinsics have been read — the
* honest scope of every count above.
*/
indexed_from: number,
/**
* The highest block whose extrinsics have been read.
*/
indexed_to: number, };
+57
View File
@@ -0,0 +1,57 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
/**
* One dispatchable, declared and — sometimes — used.
*/
export type CallSummary = {
/**
* Dispatching pallet, as the runtime names it.
*/
pallet: string,
/**
* The call, as the runtime names it.
*/
call: string,
/**
* The pallet's index, which is the first byte of this call's encoding.
*/
pallet_index: number,
/**
* The call's index within that pallet, which is the second byte.
*/
call_index: number,
/**
* Its arguments, rendered as the runtime's own signature.
*/
signature: string,
/**
* The first line of the runtime's documentation for it, when it carries
* any. This comes from the chain, not from a source tree.
*/
docs: string | null,
/**
* How many times it has been dispatched in the indexed record. Zero means
* declared and never used, which is a fact worth showing rather than a row
* worth hiding.
*/
calls: number,
/**
* How many distinct accounts have signed one.
*/
signers: number,
/**
* How many failed.
*/
failed: number,
/**
* How many carried no signature — inherents and unsigned dispatches.
*/
unsigned: number,
/**
* The most recent block it appeared in, if ever.
*/
last_height: number,
/**
* When that was.
*/
last_at: string | null, };
+27
View File
@@ -10,6 +10,8 @@ import type { AccountDetail } from './generated/AccountDetail'
import type { AccountRow } from './generated/AccountRow'
import type { ApiError } from './generated/ApiError'
import type { BlockDetail } from './generated/BlockDetail'
import type { BlockExtrinsic } from './generated/BlockExtrinsic'
import type { CallIndex } from './generated/CallIndex'
import type { ChainSeries } from './generated/ChainSeries'
import type { RecentBlock } from './generated/RecentBlock'
import type { MinerDetail } from './generated/MinerDetail'
@@ -104,6 +106,31 @@ export function fetchAccount(
)
}
/**
* Every dispatchable the runtime declares, with what has been done with it.
*
* The declared half comes from metadata and the used half from the index; the
* join is the thing worth looking at, so it arrives as one document.
*/
export function fetchCalls(chain: string, signal?: AbortSignal): Promise<CallIndex> {
return get<CallIndex>(`/chains/${encodeURIComponent(chain)}/calls`, signal)
}
/** Every dispatch of one kind of call, newest first. */
export function fetchCallFeed(
chain: string,
pallet: string,
call: string,
before?: number,
signal?: AbortSignal,
): Promise<BlockExtrinsic[]> {
const cursor = before === undefined ? '' : `?before=${before}`
return get<BlockExtrinsic[]>(
`/chains/${encodeURIComponent(chain)}/calls/${encodeURIComponent(pallet)}/${encodeURIComponent(call)}${cursor}`,
signal,
)
}
/** Accounts ranked by what they have been paid, most first. */
export function fetchAccounts(chain: string, signal?: AbortSignal): Promise<AccountRow[]> {
return get<AccountRow[]>(`/chains/${encodeURIComponent(chain)}/accounts`, signal)
+158
View File
@@ -0,0 +1,158 @@
/**
* Every dispatch of one kind of call.
*
* The feed behind a row of the call index: who called it, with what arguments,
* in which block, and whether it worked. Nothing here is written per call type
* — the arguments render from the runtime's own names, so a pallet added next
* year has a working page the moment somebody uses it.
*/
import { useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import type { BlockExtrinsic } from '../api/generated/BlockExtrinsic'
import { RequestFailed, fetchCallFeed } from '../api/rest'
import { height as fmtHeight, shortAddress, when } from '../lib/format'
import { href } from '../lib/routes'
import { Payload } from './Payload'
export function CallPanel({
chain,
pallet,
call,
decimals,
symbol,
}: {
chain: string
pallet: string
call: string
decimals: number
symbol: string
}) {
const [rows, setRows] = useState<BlockExtrinsic[] | null>(null)
const [error, setError] = useState<string | null>(null)
const [before, setBefore] = useState<number | null>(null)
useEffect(() => {
const controller = new AbortController()
setRows(null)
setError(null)
fetchCallFeed(chain, pallet, call, before ?? undefined, controller.signal)
.then(setRows)
.catch((e: unknown) => {
if (controller.signal.aborted) return
setError(e instanceof RequestFailed ? e.message : 'Could not reach the observer.')
})
return () => controller.abort()
}, [chain, pallet, call, before])
const oldest = rows && rows.length > 0 ? rows[rows.length - 1]!.height : null
return (
<section className="panel" style={{ marginBottom: 26 }}>
<div className="panel-head">
<div>
<div className="eyebrow">Call</div>
<h2 className="panel-title" style={{ marginTop: 4, textTransform: 'none' }}>
<code>
{pallet}::{call}
</code>
</h2>
</div>
<Link className="segmented panel-button" to={href({ chain, index: 'call' })}>
All calls
</Link>
</div>
{error && <p className="empty">{error}</p>}
{!error && rows === null && <p className="empty">Reading the record…</p>}
{rows !== null && rows.length === 0 && (
<p className="empty">
No dispatch of this call in the indexed range. It is declared by the runtime and has not
been used here.
</p>
)}
{rows !== null && rows.length > 0 && (
<div className="scroll-x">
<table className="board">
<caption className="visually-hidden">
Every dispatch of {pallet}::{call}, newest first
</caption>
<thead>
<tr>
<th scope="col">Block</th>
<th scope="col" className="left">
Signer
</th>
<th scope="col" className="left">
Arguments
</th>
<th scope="col" className="event-when">
When
</th>
</tr>
</thead>
<tbody>
{rows.map((x) => (
<tr key={`${x.height}-${x.index}`}>
<td className="numeral">
<span className="miner-cell">
<Link to={href({ chain, block: String(x.height) })}>
#{fmtHeight(x.height)}
</Link>
{x.success === false && (
<span className="chip chip-failed" title="The dispatch failed.">
failed
</span>
)}
</span>
</td>
<td className="left">
{x.signer_address ? (
<Link
className="numeral"
to={href({ chain, account: x.signer_address })}
title={`${x.signer_address}\n${x.signer}`}
>
{shortAddress(x.signer_address)}
</Link>
) : (
<span className="runtime-modifier">inherent</span>
)}
</td>
<td className="left">
<Payload
value={x.args}
ctx={{ chain, addresses: x.addresses, decimals, symbol }}
/>
</td>
<td className="numeral event-when" style={{ color: 'var(--text-muted)' }}>
{when(x.at)}
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
<div className="pager">
<button
className="segmented panel-button"
disabled={before === null}
onClick={() => setBefore(null)}
>
← Newest
</button>
<button
className="segmented panel-button"
disabled={oldest === null || oldest <= 1}
onClick={() => setBefore(oldest)}
>
Older →
</button>
</div>
</section>
)
}
+170
View File
@@ -0,0 +1,170 @@
/**
* What this chain can do, and what it has done.
*
* Every explorer shows the second half. This shows both, because the runtime
* declares its whole dispatchable surface in the same metadata the decoder
* reads — so a call nobody has ever made is a row here rather than an absence.
*
* That gap is the point. `ReversibleTransfers`, `TechReferenda` and `Vesting`
* are shipped, documented and untouched, and "this chain has governance nobody
* has used" is a different statement from "this chain has no governance". The
* unused rows keep their documentation, straight from the chain.
*/
import { useEffect, useState } from 'react'
import { Link } from 'react-router-dom'
import type { CallIndex } from '../api/generated/CallIndex'
import { RequestFailed, fetchCalls } from '../api/rest'
import { ago, height as fmtHeight } from '../lib/format'
import { href } from '../lib/routes'
export function CallsIndex({ chain }: { chain: string }) {
const [index, setIndex] = useState<CallIndex | null>(null)
const [error, setError] = useState<string | null>(null)
const [showUnused, setShowUnused] = useState(true)
useEffect(() => {
const controller = new AbortController()
setIndex(null)
setError(null)
fetchCalls(chain, controller.signal)
.then(setIndex)
.catch((e: unknown) => {
if (controller.signal.aborted) return
setError(e instanceof RequestFailed ? e.message : 'Could not reach the observer.')
})
return () => controller.abort()
}, [chain])
const rows = index ? index.calls.filter((c) => showUnused || c.calls > 0) : []
return (
<section className="panel" style={{ marginBottom: 26 }}>
<div className="panel-head">
<h2 className="panel-title">Calls</h2>
{index && (
<span className="eyebrow">
{index.used} of {index.calls.length} used
{index.spec_version !== null && ` · runtime v${index.spec_version}`}
</span>
)}
</div>
{error && <p className="empty">{error}</p>}
{!error && index === null && <p className="empty">Reading the runtime…</p>}
{index !== null && (
<>
{/* The unused rows are the interesting half, so they are on by
default — but somebody reading the activity wants them gone, and
that is one click rather than a different page. */}
<div className="pager" style={{ borderTop: 0, borderBottom: 'var(--rule)' }}>
<button
className="segmented panel-button"
aria-pressed={showUnused}
onClick={() => setShowUnused(!showUnused)}
>
{showUnused ? '✓ Showing unused' : 'Show unused'}
</button>
</div>
<div className="scroll-x">
<table className="board">
<caption className="visually-hidden">
Every dispatchable the runtime declares, with how often it has been used
</caption>
<thead>
<tr>
<th scope="col">#</th>
<th scope="col" className="left">
Call
</th>
<th scope="col">Dispatched</th>
<th scope="col">Signers</th>
<th scope="col">Failed</th>
<th scope="col" className="event-when">
Last seen
</th>
</tr>
</thead>
<tbody>
{rows.map((c) => (
<tr
key={`${c.pallet}.${c.call}`}
className={c.calls === 0 ? 'call-unused' : undefined}
>
{/* The two bytes this call encodes as. Reading down the
column is how you see a pallet was inserted rather than
appended, which renumbers everything after it. */}
<td className="numeral">
<span className="runtime-index">
{c.pallet_index}.{c.call_index}
</span>
</td>
<td className="left">
<div className="call-cell">
{c.calls > 0 ? (
<Link to={href({ chain, call: [c.pallet, c.call] })}>
<code>
{c.pallet}::{c.call}
</code>
</Link>
) : (
<code>
{c.pallet}::{c.call}
</code>
)}
{c.signature && <span className="runtime-type">({c.signature})</span>}
{c.docs && <span className="runtime-doc">{c.docs}</span>}
</div>
</td>
<td className="numeral">
{c.calls === 0 ? (
<span className="runtime-modifier">never</span>
) : (
fmtHeight(c.calls)
)}
</td>
<td className="numeral">
{/* Unsigned is not "nobody": an inherent is the block
author's, and on this chain most traffic is unsigned. */}
{c.calls === 0 ? '—' : c.signers > 0 ? fmtHeight(c.signers) : 'unsigned'}
</td>
<td className="numeral">
{c.failed > 0 ? (
<span className="chip chip-failed">{c.failed}</span>
) : c.calls === 0 ? (
'—'
) : (
'0'
)}
</td>
<td className="numeral event-when" style={{ color: 'var(--text-muted)' }}>
{c.last_at
? ago(c.last_at)
: c.last_height
? `#${fmtHeight(c.last_height)}`
: '—'}
</td>
</tr>
))}
</tbody>
</table>
</div>
<p className="panel-note">
The declared surface comes from the runtime's own metadata; the counts come from this
observer's extrinsic index, over blocks{' '}
{index.indexed_from !== null && index.indexed_to !== null
? `${fmtHeight(index.indexed_from)} to ${fmtHeight(index.indexed_to)}`
: 'it has read'}
. A call showing <em>never</em> has not been dispatched in that range — which for a
chain this young is most of them, and is the more interesting half of the table.
Documentation is the runtime's, not ours.
</p>
</>
)}
</section>
)
}
+7 -2
View File
@@ -35,7 +35,8 @@ export function SectionNav({
route.block === null &&
route.miner === null &&
route.account === null &&
route.runtime === null
route.runtime === null &&
route.call === null
return (
<nav className="sections" aria-label="Section">
@@ -51,7 +52,11 @@ export function SectionNav({
key={s.id}
to={href({ chain, index: s.id })}
className="section-link"
aria-current={route.index === s.id ? 'page' : undefined}
// A call's own page belongs to the Calls section, so the nav marks
// it there rather than nowhere.
aria-current={
route.index === s.id || (s.id === 'call' && route.call !== null) ? 'page' : undefined
}
>
{s.label}
</Link>
+24
View File
@@ -1298,3 +1298,27 @@ tr.mine .share-bar > i {
.rate-weak {
color: var(--text-muted);
}
/* A call, its signature and its documentation, stacked. The signature is the
runtime's own and long enough to wrap, so it gets the width rather than a
column of its own. */
.call-cell {
display: flex;
flex-wrap: wrap;
align-items: baseline;
gap: 3px 8px;
}
.call-cell .runtime-doc {
padding-left: 0;
}
/* Declared and never dispatched. Dimmed rather than hidden: the unused surface
is the half of this table nobody else shows. */
.call-unused {
color: var(--text-muted);
}
.call-unused code {
color: var(--text-secondary);
}
+10 -1
View File
@@ -40,6 +40,8 @@ export interface Route {
account: string | null
/** A `spec_version`. */
runtime: number | null
/** One kind of dispatchable, as `[pallet, call]`. */
call: [string, string] | null
/**
* A kind with no value: the index of everything of that kind.
*
@@ -52,7 +54,7 @@ export interface Route {
}
/** The kinds that have an index. */
export type SectionName = 'block' | 'account' | 'runtime'
export type SectionName = 'block' | 'call' | 'account' | 'runtime'
/**
* The sections, in the order the nav shows them.
@@ -63,6 +65,7 @@ export type SectionName = 'block' | 'account' | 'runtime'
*/
export const SECTIONS: { id: SectionName; label: string }[] = [
{ id: 'block', label: 'Blocks' },
{ id: 'call', label: 'Calls' },
{ id: 'account', label: 'Accounts' },
{ id: 'runtime', label: 'Runtimes' },
]
@@ -78,6 +81,7 @@ export const EMPTY: Route = {
miner: null,
account: null,
runtime: null,
call: null,
index: null,
}
@@ -146,6 +150,10 @@ export function parse(pathname: string): Route {
}
if (kind === 'account') return { ...EMPTY, chain, account: value }
if (kind === 'runtime') return { ...EMPTY, chain, runtime: spec(value) }
// `/quantus/call/Balances/transfer_allow_death` — a pallet and a call, both
// as the runtime names them, because those names are the identity and any
// slug of ours would be a second vocabulary to keep in step.
if (kind === 'call' && parts[3]) return { ...EMPTY, chain, call: [value, parts[3]] }
}
// A kind with nothing after it — `/quantus/account` or `/quantus/account/`,
// which `filter(Boolean)` above makes the same path. The index of that kind.
@@ -170,6 +178,7 @@ export function href(route: Partial<Route>): string {
const window = route.window ?? DEFAULT_WINDOW
return chain ? `/${chain}/miner/${route.miner}/${window}` : `/miner/${route.miner}/${window}`
}
if (route.call) return `/${chain}/call/${route.call[0]}/${route.call[1]}`
if (route.index) return `/${chain}/${route.index}`
if (route.account) return `/${chain}/account/${route.account}`
if (route.runtime !== null && route.runtime !== undefined) {