feat: add playground status and fix native token decimals (10, not 12)#401
Merged
Conversation
Add a read-only `playground status` command showing the signed-in product account (SS58 + H160), native and PGAS balances, Bulletin authorization validity with a humanized time estimate, and login freshness. No phone interaction; each chain-dependent field degrades independently to "unavailable" and the command exits 0 on soft outcomes. Fix the native token decimal scale repo-wide: PAS/SUM are 10 decimals, not 12. Verified live against paseo-next-v2 — system_properties.tokenDecimals is 10 on both asset hub and people chains, and Balances.ExistentialDeposit (100_000_000 planck) is the canonical 0.01 PAS only at 10 decimals. This corrects every balance display (amounts were under-shown 100x) and makes `playground drip` transfer the documented 1 PAS per run (10 PAS cap) instead of 100 PAS (1000 PAS cap). PGAS, which carries no on-chain metadata and is 1:1 with PAS, renders at the same 10-decimal scale. - New src/commands/status/ (index + StatusScreen + testable gather.ts) - src/utils/account/pgas.ts: PGAS balance reader + grouped token formatter - src/utils/allowances/bulletin.ts: getCachedBulletinSlotAddress (no-phone) - src/config.ts: per-env pgasAssetId + getPgasAssetId accessor - src/utils/account/drip.ts: PAS_DECIMALS = 10, formatPas parametrized
Contributor
|
Dev build ready — try this branch: |
Contributor
E2E Test Pass · ❌ FAILTag:
❌ Failed tests (1)
Sentry traces: view spans for this run |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a read-only
playground statuscommand and fixes a pre-existing native-token decimal bug surfaced while building it.playground statusA no-phone-interaction snapshot of the signed-in account:
~9d 12h · #690,349), read against the slot account the authorization is keyed to — reuses the existingcheckAttestation/getBulletinBlockTimeMs/formatAttestationhelpersEach chain-dependent field degrades independently to
unavailable; addresses + login stamp still render if the chain is unreachable. Exits 0 on soft outcomes (not-logged-in), 1 only on unexpected errors — mirrorsplayground drip.Native token decimal fix (10, not 12)
The repo hardcoded PAS as 12 decimals; it is 10. Verified live against paseo-next-v2:
system_properties.tokenDecimals10system_properties.tokenDecimals10Balances.ExistentialDeposit=100000000planck0.01 PASonly at 10 decimals (canonical Polkadot ED)Impact of the fix:
220.5 PAS, not2.205).playground dripbehavior change: it now transfers the documented 1 PAS per run (10 PAS cap) instead of 100 PAS (1000 PAS cap).DRIP_AMOUNT = ONE_PAS, andONE_PASwent from1e12to1e10.decimals = 0) and is 1:1 with PAS, so it renders at the same 10-decimal scale (35.4793 PGAS). SUM (summit) is also 10 decimals — covered by the singlePAS_DECIMALSconstant.Files
src/commands/status/—index.ts(command),StatusScreen.tsx(Ink UI),gather.ts+gather.test.ts(React-free, testable orchestrator)src/utils/account/pgas.ts(+ test) — PGAS balance reader and grouped token formatter (caps at 4 fractional digits to matchformatPas)src/utils/allowances/bulletin.ts—getCachedBulletinSlotAddress(local cache read, no phone)src/config.ts(+ test) — per-envpgasAssetId+getPgasAssetId()src/utils/account/drip.ts(+ test) —PAS_DECIMALS = 10,formatPasparametrizedsrc/index.ts,src/telemetry-config.ts— command registration +CliCommandNameVerification
pnpm typecheck— cleanpnpm format:check— cleanpnpm lint:license— cleanpnpm test— 935 passedpg statusrenders correctly and exits 0