Skip to content

feat(init): claim playground username during setup#209

Merged
UtkarshBhardwaj007 merged 1 commit into
mainfrom
feat/set-username-in-init
May 26, 2026
Merged

feat(init): claim playground username during setup#209
UtkarshBhardwaj007 merged 1 commit into
mainfrom
feat/set-username-in-init

Conversation

@UtkarshBhardwaj007
Copy link
Copy Markdown
Member

Summary

  • dot init reads the user's playground-registry username (best-block dry-run) and surfaces it in the top breadcrumb (alongside command, network, version). If none is set, a Yes/No picker offers to claim one; on Yes the prompt opens a text input, dry-runs isUsernameAvailable to avoid burning a tx on a taken name, then signs registry.setUsername. Pinned gas + storage-deposit limits mirror playground-app's known-good values to avoid Revive.OutOfGas on first-time storage inserts.
  • Username validation mirrors the contract's validate_username byte-for-byte (3-30 chars, ASCII a-z/0-9/-, no leading/trailing hyphen, no double-dash). Enforced at three layers: input validator, prompt submit, and setRegistryUsername itself so no public caller can ever push invalid input on-chain.
  • Identity block collapsed to a single account in use row showing derivation slug + H160 + SS58. The two earlier rows were the same account in two encodings and read as "two accounts" to users.
  • Header drops the decorative polkadot playground subtitle in dot init to make room for the username, and adds wrap="truncate-end" to breadcrumb pieces as a defensive cap (a 30-char username on a narrow terminal now clips with instead of wrapping every piece into garbage).
  • Resource cleanup: SubmitUsername owns and tears down its session-signer adapter on every exit path — getSessionSigner() is not memoised, so each call spins up a fresh terminal-adapter WebSocket. dot init also drains the shared getConnection() in a finally block on command exit. Init runs with hardExit: false, so a stray WS would hang the process after "setup complete".

Test plan

  • pnpm format:check clean
  • pnpm lint:license clean (180 files have headers)
  • pnpm test — 527 tests pass (was 504; +23 across username.test.ts and completion.test.ts)
  • pnpm build clean (Bun SEA)
  • Manual: dot init against the v11 registry on a fresh account → prompt appears, claim succeeds, header shows the chosen handle, process exits cleanly without hanging
  • Manual: dot init against an account that already has a username → no prompt, header shows the existing handle, process exits cleanly
  • Manual: try -- or a 31-char name → input rejects with inline copy before any tx is attempted
  • Manual: try a name another account holds → "already taken" error surfaces from the isUsernameAvailable precheck, no tx is sent

After auth + account setup land, `dot init` reads the user's
playground-registry username via best-block dry-run. If one's already
claimed it gets surfaced in the top breadcrumb (alongside command,
network, version) so it stays visible across the run. If not, a Yes/No
picker offers to claim one; selecting Yes opens a text input that
validates client-side, dry-runs `isUsernameAvailable` to avoid burning
a tx on a taken name, then signs `registry.setUsername`. Pinned gas +
storage-deposit limits mirror playground-app's known-good values to
avoid `Revive.OutOfGas` on first-time storage inserts.

Validation mirrors the contract's `validate_username` byte-for-byte:
3-30 chars, ASCII `a-z` + `0-9` + `-`, no leading/trailing hyphen, no
double-dash. Enforced at three layers (input validator, prompt submit,
and `setRegistryUsername` itself so no public caller can ever push
invalid input on-chain).

Identity block collapsed to one `account in use` row showing
derivation slug + H160 + SS58 (the two earlier rows were the same
account in two encodings and read as "two accounts"). Header drops the
decorative `polkadot playground` subtitle in `dot init` to make room
for the username, and adds `wrap="truncate-end"` to breadcrumb pieces
as a defensive cap so a 30-char username on a narrow terminal clips
with `…` instead of wrapping into garbage.

The `UsernamePrompt.SubmitUsername` step explicitly owns and tears down
its session-signer adapter on every exit path: `getSessionSigner()` is
not memoised, so each call spins up a fresh terminal-adapter WebSocket.
Init also drains the shared `getConnection()` in a finally block on
command exit; init runs with `hardExit: false`, so a stray WS would
hang the process after "setup complete".
@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/set-username-in-init bash

@github-actions
Copy link
Copy Markdown
Contributor

E2E Test Pass · ✅ PASS

Tag: e2e-ci-pr · Branch: feat/set-username-in-init · Commit: 7a5253a · Run logs

Cell Result Time
pr-install ✅ PASS 0m42s
pr-deploy-cdm ✅ PASS 2m03s
pr-mod ✅ PASS 1m32s
pr-deploy-foundry ✅ PASS 0m39s
pr-init-session ✅ PASS 1m44s
pr-preflight ✅ PASS 1m24s
pr-deploy-frontend ✅ PASS 3m10s
${{ matrix.cell }} ⏭️ SKIP 0m00s
${{ matrix.cell }} ⏭️ SKIP 0m00s

Sentry traces: view spans for this run

@UtkarshBhardwaj007 UtkarshBhardwaj007 merged commit 69010b0 into main May 26, 2026
20 checks passed
@UtkarshBhardwaj007 UtkarshBhardwaj007 deleted the feat/set-username-in-init branch May 26, 2026 13:27
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