Skip to content

feat(init): show username and product account on success#182

Merged
UtkarshBhardwaj007 merged 4 commits into
mainfrom
feat/dot-init-identity-display
May 19, 2026
Merged

feat(init): show username and product account on success#182
UtkarshBhardwaj007 merged 4 commits into
mainfrom
feat/dot-init-identity-display

Conversation

@UtkarshBhardwaj007
Copy link
Copy Markdown
Member

Summary

  • dot init's logged-in confirmation now shows two new lines: username (on-chain identity from People parachain's Resources.Consumers, with a 5s timeout) and product account (SS58 + truncated H160 derived locally via sr25519 soft derivation).
  • Lets users eyeball that the CLI account matches what playground-app resolves for "My apps" — same root + same product id + same index = same SS58/H160 across hosts.
  • Phase 4 of the product-account unification work; Phases 1-2 already shipped upstream in paritytech/product-sdk#105.

What's where

  • src/utils/username.ts (+tests) — lookupUsername(ss58) returns a UsernameLookup union (loading | found | none | error) with a hard 5s timeout. Mirrors @novasamatech/host-papp's createIdentityRpcAdapter shape because the factory is not re-exported at the package root and host-papp blocks deep imports; the source-of-truth pointer + reasoning lives in the file's top-of-file comment.
  • src/commands/init/identityLine.ts (+tests) — pure helpers (productAccountAddresses, productAccountDisplay) lifted out of .tsx per repo convention. Currently imports deriveProductAccountPublicKey from src/utils/productAccountDerivation.ts; Phase 3 of the unification will swap this to @parity/product-sdk-keys once that minor publishes — mechanical import-swap, output is byte-identical.
  • src/commands/init/IdentityLines.tsx — the React component (stateful → stays in .tsx) that renders the two rows and drives the async lookup with cancellation.
  • src/commands/init/InitScreen.tsx — hooks IdentityLines in right after the existing "logged in" row.

Cross-host parity

Verified against the upstream sources:

  • triangle-js-sdks/packages/host-papp/src/identity/rpcAdapter.ts — exact upstream we're mirroring (Resources.Consumers + accCodec.dec + TextDecoder mapping).
  • polkadot-desktop — same fullUsername ?? liteUsername display pattern (UserInfoPopover.tsx, UserButton.tsx, accounts.tsx).
  • polkadot-app-android-v2 — same {fullUsername: String?, liteUsername: String} on-chain shape (OnChainConsumerInfo.kt).

Test plan

  • pnpm format:check, pnpm lint:license, pnpm test, pnpm build — all green locally; CI confirms.
  • Run pnpm dev init against a session with a registered DotNS username — verify three lines appear: logged in: <ss58>, username: <name>.dot, product account: <ss58-truncated> (<h160-truncated>).
  • Run pnpm dev init against a session WITHOUT a registered username — verify the username line shows (no username set on chain) and the product account still renders.
  • Run pnpm dev init with the network unreachable (e.g. block the People RPC) — verify the lookup falls back to (lookup failed) after ~5s and the product account line is unaffected.
  • Cross-check the printed product account SS58 + H160 against what playground-app shows in console.info for the same user (once that side ships — separate work).

Captures the design for consolidating sr25519 product-account derivation
in @parity/product-sdk-keys, locking it against frozen vitest vectors,
surfacing username + product account in `dot init`, renaming the
misleading blake2b util in product-sdk/identity, and deferring the
"CLI as host" option as a roadmap note.
Renders two new lines in the `dot init` logged-in confirmation: the
user's root username (queried on-chain from People parachain's
Resources.Consumers storage with a 5s timeout, falling back to a
"(no username set on chain)" / "(lookup failed)" placeholder) and
their product account address (SS58 + truncated H160 derived locally
via sr25519 soft derivation).

The product account line lets users eyeball that their CLI account
matches the one playground-app uses for "My apps" — same root account
+ same product id + same index = same SS58/H160 across hosts.

The on-chain lookup mirrors `@novasamatech/host-papp`'s
`createIdentityRpcAdapter` shape directly because the factory is not
re-exported at the package root and the package blocks deep imports;
the mapping is documented in `src/utils/username.ts` with a pointer
back to the upstream source.
@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/dot-init-identity-display bash

playground-cli doesn't commit plans, specs, or other design / brainstorming
docs (see the existing precedent of `docs-internal/` being gitignored).
Removes the design spec for the product-account unification work that was
committed in error, and gitignores the whole `docs/superpowers/` subtree so
plans + specs stay local-only going forward.
@UtkarshBhardwaj007 UtkarshBhardwaj007 merged commit 0f6fdaf into main May 19, 2026
8 of 9 checks passed
@UtkarshBhardwaj007 UtkarshBhardwaj007 deleted the feat/dot-init-identity-display branch May 19, 2026 14:57
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 19, 2026

E2E Test Pass · ✅ PASS

Tag: e2e-ci-pr · Branch: feat/dot-init-identity-display · Commit: dcdbd61 · Run logs

Cell Result Time
pr-init-session ✅ PASS 1m48s
pr-install ✅ PASS 0m46s
pr-mod ✅ PASS 1m17s
pr-deploy-frontend ✅ PASS 3m11s
pr-deploy-foundry ✅ PASS 1m23s
pr-deploy-cdm ✅ PASS 19m19s
${{ matrix.cell }} ⏭️ SKIP 0m-1s
pr-preflight ✅ PASS 2m03s
${{ matrix.cell }} ⏭️ SKIP 0m-1s

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