Show account balances #12
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The extension shows no balances at all. Upstream does not either — it is a signer, and balances are the dapp's job — but that reasoning does not survive contact with this wallet: a Quantus account id is a Poseidon2 hash rather than a public key, so a user cannot paste an address into a block explorer they already trust and recognise it as theirs. The extension is the only thing that knows the account is the one they made.
It is also the cheapest way to make the account list tell the truth. Right now an account that has never been funded and an account holding a thousand QTC look identical.
What it needs
@quantus/codeccan already do the reading (quantus/wasm#4):Note the
raw ?? target.default.System::Accountis aDefaultentry, so the node returning nothing means a zero balance rather than a failure, and conflating the two would show "error" for every account nobody has funded yet — which is every account at the moment it is created.What is missing is everything around it:
system_propertiesor the stored metadata definition — QTC on mainnet, HEI on Heisenberg.state_subscribeStorage) or a poll, and a sensible answer for what happens when the endpoint is unreachable: showing a stale balance as current is worse than showing none.Suggested shape
Balances behind an explicit, off-by-default setting naming the endpoint, so the privacy trade is the user's to make rather than one this fork makes for them.
blackbeard.observerhas working endpoints configured for both mainnet and the testnets.Acceptance
qzk1Nxai3dZD9Cn5kwGcgL6mKxsfxwqdis7kDQJ52aJS2vSn7shows its real Heisenberg balance in the account list, formatted in HEI; a freshly created account shows0, not an error; and with no endpoint configured the extension makes no network requests at all.Done, with the endpoint as a setting rather than off by default
I proposed off-by-default when I filed this. That was the wrong call, and the reason is straightforward: a user can point this at their own node, which is what anyone who doubts the defaults should be doing anyway. Balances off by default means nobody sees them, which is the same as not building it.
So: on by default, pointed at mainnet, with the endpoint editable and "off" in the list.
What landed
Balancesin the background holds one connection and readsSystem::Accountthrough@quantus/codec's storage addressing (quantus/wasm#4), then watches it withstate_subscribeStorage. Two details that are easy to get wrong:System::Accountis aDefaultentry. A node returning nothing means a zero balance, not a failure. Conflating them would show an error for every account at the moment it is created, which is the worst possible time to tell somebody their wallet is broken.Verified against Heisenberg
then, with a transfer submitted while watching:
So the read, the decode, the subscription and the merge all work against a real node.
The endpoint setting
Known endpoints, all verified reachable on 2026-09-15:
wss://rpc1-mainnet.quantus.comwss://a1-heisenberg.quantus.cat,wss://a2-heisenberg.quantus.catwss://a1-planck.quantus.cat,wss://a2-planck.quantus.catA dropdown offers those plus "off"; a text field beside it takes anything, which is the point of the feature rather than an edge case. Nothing connects until the popup asks, and the connection closes with the last subscriber — a signer holding a socket open to somebody's node for the life of the browser would report far more than this needs.
Not stored in
@polkadot/ui-settings'apiUrl. That field means the endpoint polkadot-js apps talks to, and it ships a default ofws://127.0.0.1:9944/— reusing it would have pointed the extension at a local node nobody is running and shown no balances at all, with nothing on screen to say why. It has its ownlocalStoragekey, where an empty string is a deliberate "off" and an absent key means "never chosen".Formatting
String arithmetic throughout. At 12 decimals
2^53smallest units is about 9 007 tokens, so any balance above that loses digits to aNumber— quietly, on the one screen whose whole job is telling somebody how much money they have. The fraction truncates rather than rounds, so a displayed amount is never more than the account actually holds. Tested.(I claimed in a first draft of that test that crystal_alice's 527 HEI already exceeded
2^53. It does not — the threshold is 9 007 tokens, not a few hundred. Corrected.)Acceptance
0, not an errorUnverified
The account list itself is unverified visually — driving the extension's own UI needs a privileged browsing context this tooling cannot script, the same limitation as #7 tier 2. The background half above is verified against a real node, and the formatter is unit tested, so what remains untested is the popup rendering a string it has been handed.