feat(init): claim playground username during setup#209
Merged
Conversation
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".
Contributor
|
Dev build ready — try this branch: |
Contributor
E2E Test Pass · ✅ PASSTag:
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
dot initreads 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-runsisUsernameAvailableto avoid burning a tx on a taken name, then signsregistry.setUsername. Pinned gas + storage-deposit limits mirror playground-app's known-good values to avoidRevive.OutOfGason first-time storage inserts.validate_usernamebyte-for-byte (3-30 chars, ASCIIa-z/0-9/-, no leading/trailing hyphen, no double-dash). Enforced at three layers: input validator, prompt submit, andsetRegistryUsernameitself so no public caller can ever push invalid input on-chain.account in userow showing derivation slug + H160 + SS58. The two earlier rows were the same account in two encodings and read as "two accounts" to users.polkadot playgroundsubtitle indot initto make room for the username, and addswrap="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).SubmitUsernameowns 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 initalso drains the sharedgetConnection()in a finally block on command exit. Init runs withhardExit: false, so a stray WS would hang the process after "setup complete".Test plan
pnpm format:checkcleanpnpm lint:licenseclean (180 files have headers)pnpm test— 527 tests pass (was 504; +23 acrossusername.test.tsandcompletion.test.ts)pnpm buildclean (Bun SEA)dot initagainst the v11 registry on a fresh account → prompt appears, claim succeeds, header shows the chosen handle, process exits cleanly without hangingdot initagainst an account that already has a username → no prompt, header shows the existing handle, process exits cleanly--or a 31-char name → input rejects with inline copy before any tx is attemptedisUsernameAvailableprecheck, no tx is sent