feat(init): show username and product account on success#182
Merged
Conversation
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.
Contributor
|
Dev build ready — try this branch: |
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.
Contributor
E2E Test Pass · ✅ PASSTag:
Sentry traces: view spans for this run |
7 tasks
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 init's logged-in confirmation now shows two new lines: username (on-chain identity from People parachain'sResources.Consumers, with a 5s timeout) and product account (SS58 + truncated H160 derived locally via sr25519 soft derivation).playground-appresolves for "My apps" — same root + same product id + same index = same SS58/H160 across hosts.What's where
src/utils/username.ts(+tests) —lookupUsername(ss58)returns aUsernameLookupunion (loading | found | none | error) with a hard 5s timeout. Mirrors@novasamatech/host-papp'screateIdentityRpcAdaptershape 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.tsxper repo convention. Currently importsderiveProductAccountPublicKeyfromsrc/utils/productAccountDerivation.ts; Phase 3 of the unification will swap this to@parity/product-sdk-keysonce 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— hooksIdentityLinesin 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+TextDecodermapping).polkadot-desktop— samefullUsername ?? liteUsernamedisplay 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.pnpm dev initagainst a session with a registered DotNS username — verify three lines appear:logged in: <ss58>,username: <name>.dot,product account: <ss58-truncated> (<h160-truncated>).pnpm dev initagainst a session WITHOUT a registered username — verify the username line shows(no username set on chain)and the product account still renders.pnpm dev initwith 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.playground-appshows inconsole.infofor the same user (once that side ships — separate work).