Skip to content

feat: add playground status and fix native token decimals (10, not 12)#401

Merged
UtkarshBhardwaj007 merged 1 commit into
mainfrom
feat/status-command
Jun 16, 2026
Merged

feat: add playground status and fix native token decimals (10, not 12)#401
UtkarshBhardwaj007 merged 1 commit into
mainfrom
feat/status-command

Conversation

@UtkarshBhardwaj007

Copy link
Copy Markdown
Member

Summary

Adds a read-only playground status command and fixes a pre-existing native-token decimal bug surfaced while building it.

playground status

A no-phone-interaction snapshot of the signed-in account:

  • Product account SS58 + H160 (from the persisted session, no phone tap)
  • Native balance (PAS/SUM) and PGAS balance
  • Bulletin authorization valid-until block with a humanized time estimate (~9d 12h · #690,349), read against the slot account the authorization is keyed to — reuses the existing checkAttestation/getBulletinBlockTimeMs/formatAttestation helpers
  • Login freshness (with the stale-session warning when >2 days)

Each 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 — mirrors playground drip.

Native token decimal fix (10, not 12)

The repo hardcoded PAS as 12 decimals; it is 10. Verified live against paseo-next-v2:

Source Result
Asset Hub system_properties.tokenDecimals 10
People chain system_properties.tokenDecimals 10
Balances.ExistentialDeposit = 100000000 planck 0.01 PAS only at 10 decimals (canonical Polkadot ED)

Impact of the fix:

  • Balance displays were under-shown 100x — now correct (e.g. 220.5 PAS, not 2.205).
  • playground drip behavior change: it now transfers the documented 1 PAS per run (10 PAS cap) instead of 100 PAS (1000 PAS cap). DRIP_AMOUNT = ONE_PAS, and ONE_PAS went from 1e12 to 1e10.
  • PGAS carries no on-chain metadata (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 single PAS_DECIMALS constant.

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 match formatPas)
  • src/utils/allowances/bulletin.tsgetCachedBulletinSlotAddress (local cache read, no phone)
  • src/config.ts (+ test) — per-env pgasAssetId + getPgasAssetId()
  • src/utils/account/drip.ts (+ test) — PAS_DECIMALS = 10, formatPas parametrized
  • src/index.ts, src/telemetry-config.ts — command registration + CliCommandName

Verification

  • pnpm typecheck — clean
  • pnpm format:check — clean
  • pnpm lint:license — clean
  • pnpm test — 935 passed
  • Live pg status renders correctly and exits 0

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
@github-actions

Copy link
Copy Markdown
Contributor

Dev build ready — try this branch:

curl -fsSL https://raw.githubusercontent.com/paritytech/playground-cli/main/install.sh | VERSION=dev/feat/status-command bash

@UtkarshBhardwaj007 UtkarshBhardwaj007 merged commit 685b86d into main Jun 16, 2026
17 of 20 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

E2E Test Pass · ❌ FAIL

Tag: e2e-ci-pr · Branch: feat/status-command · Commit: a571afa · Run logs

Cell Result Time
pr-deploy-cdm ✅ PASS 3m52s
pr-login-session ✅ PASS 2m22s
pr-install ✅ PASS 0m50s
pr-preflight ❌ FAIL 6m38s
pr-deploy-frontend ❌ FAIL 16m40s
pr-mod ❌ FAIL 3m23s
pr-deploy-foundry ✅ PASS 0m48s
${{ matrix.cell }} ⏭️ SKIP 0m00s
${{ matrix.cell }} ⏭️ SKIP 0m-2s
❌ Failed tests (1)
  • e2e/cli/build.test.ts › dot build > exits non-zero when no build strategy can be detected
    expected '\n✖ No package.json found in /tmp/dot…' to contain 'No build strategy detected'

Sentry traces: view spans for this run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant