Skip to content

Migrate CLI to product-sdk#148

Merged
UtkarshBhardwaj007 merged 11 commits intomainfrom
migrate-to-product-sdk
May 9, 2026
Merged

Migrate CLI to product-sdk#148
UtkarshBhardwaj007 merged 11 commits intomainfrom
migrate-to-product-sdk

Conversation

@charlesHetterich
Copy link
Copy Markdown
Collaborator

@charlesHetterich charlesHetterich commented May 8, 2026

closes #144
closes #145

Summary

  • migrate direct @polkadot-apps/* dependencies/imports to @parity/product-sdk-*
  • use terminal product-account signing for playground.dot while preserving the dot-cli session namespace
  • update PAPI v2 chain access, Bulletin metadata upload/gateway reads, and remove the old session signer patch

Verification

  • pnpm install
  • npx tsc --noEmit
  • pnpm test
  • pnpm format:check
  • pnpm build
  • pnpm cli:install
  • bun run src/index.ts deploy --help
  • bun run src/index.ts logout --help
  • bun run src/index.ts init --help
  • ~/.polkadot/bin/dot --help

Notes

  • pnpm-lock.yaml still contains transitive @polkadot-apps/* entries through @dotdm/contracts@1.0.1; direct app/runtime imports are migrated.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Dev build ready — try this branch:

curl -fsSL https://raw.githubusercontent.com/paritytech/playground-cli/main/install.sh | VERSION=dev/migrate-to-product-sdk bash

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

E2E Test Pass · ❌ FAIL

Tag: e2e-ci-pr · Branch: migrate-to-product-sdk · Commit: 88eb86b · Run logs

Cell Result Time
pr-deploy-frontend ✅ PASS 10m11s
pr-mod ❌ FAIL 2m49s
pr-install ✅ PASS 0m43s
${{ matrix.cell }} ⏭️ SKIP -14m-16s
pr-preflight ✅ PASS 2m15s
pr-deploy-cdm ✅ PASS 2m55s
${{ matrix.cell }} ⏭️ SKIP -14m-17s
pr-init-session ✅ PASS 1m43s
pr-deploy-foundry ✅ PASS 1m35s

Sentry traces: view spans for this run

@charlesHetterich charlesHetterich force-pushed the migrate-to-product-sdk branch from 1d9f7ef to 0b5960c Compare May 8, 2026 03:42
charlesHetterich and others added 10 commits May 8, 2026 00:27
…dProof

The published @parity/product-sdk-terminal@0.1.0 funnels every signing op
through session.signRaw, which the mobile wallet wraps with <Bytes>...</Bytes>
(anti-phishing envelope, see polkadot-app-android-v2's
MessageSigningContext.kt::generalUntrustedMessage). For tx payloads that
produces a signature the chain rejects as BadProof.

Mirror the upstream fix (paritytech/product-sdk a33edf3) locally in
auth.ts: build a PJS signer with split callbacks — tx via session.signPayload
(no envelope), bytes via session.signRaw (envelope correct for free-form
data). Drop back to createSessionSignerForAccount once the upstream fix
ships on npm.

Also: pin @parity/product-sdk-* to exact versions (pre-1.0 SDK; carets
let patch bumps silently flip wire shape), bump changeset to minor (the
PR is a runtime SDK swap), refresh CLAUDE.md and README.md to reflect
the product-sdk surface and the still-load-bearing <Bytes> invariant.
…, tests

- AGENTS.md: refresh dependency rules (drop stale @polkadot-apps/chain-client
  reference, document the @dotdm/contracts/PAPI-1.x blocker), update the
  metadata-upload rule to point at calculateCid + direct PAPI submit, and
  add a Runtime Safety entry for the still-load-bearing <Bytes> mobile-wrap
  invariant + the createPlaygroundSigner workaround.
- tools/list-registry-apps.ts: drop the inline fetchJsonFromGateway (own
  goal in commit ac4aaaa) and reuse src/utils/bulletinGateway.ts, which
  reads the gateway URL from getChainConfig() instead of hardcoding paseo.
- src/utils/auth.ts: mark makeSignPayloadCallback / makeSignRawCallback
  @internal, mirroring the existing clearLocalAppStorage convention so
  the test seams aren't mistaken for a public API.
- src/utils/bulletinGateway.test.ts: cover URL composition, 2xx/non-2xx
  paths, abort-on-timeout, and JSON parsing — 8 new tests, all passing.
… logout

@parity/product-sdk-terminal@0.1.0::destroy() tears down the underlying
polkadot-api client without awaiting in-flight statement-subscription
unsubscribes. PAPI's raw-client disconnect() then errors every pending
request with `new DestroyedError("Client destroyed")`
(@polkadot-api/raw-client/dist/esm/createClient.mjs:58 —
`responses.forEach((r) => r.onError(new DestroyedError()))`), which
surfaces as an unhandled promise rejection right above our "✓ signed
out" line.

The error is benign: the actual logout already succeeded, this fires
purely as a teardown-race artifact. DestroyedError is exclusive to
PAPI's raw-client teardown path (only `disconnect()` constructs and
throws this class), so matching the bare error name in our existing
benign-unsubscription filter is safe.

Same family as the UnsubscriptionError / Not connected and DisjointError
shapes we already suppress for `dot deploy`. Real upstream fix is for
product-sdk-terminal's destroy() to drain statement-subscription
teardowns before disconnecting the lazy client; tracking that
separately.
@parity/product-sdk-terminal 0.2.0 ships both fixes the CLI was
working around:

  - createSessionSignerForAccount now uses a split-callback PJS signer
    (tx → session.signPayload, bytes → session.signRaw) under the hood,
    so the local PJS-based replacement in auth.ts is gone — back to a
    one-line SDK call.
  - destroy() is now async and awaits lazyClient.awaitPendingUnsubs()
    between sessions.dispose() and lazyClient.disconnect(), so the
    DestroyedError unhandled rejection on `dot logout` no longer fires.
    The corresponding suppression in isBenignUnsubscriptionError is
    removed; if DestroyedError ever resurfaces it's now a real
    regression and must escalate.

Bumped the rest of @parity/product-sdk-* within their existing caret
ranges (bulletin/chain-client/contracts/descriptors 0.2.0 → 0.2.1).

Updated CLAUDE.md, AGENTS.md, README.md to reflect the simpler shape.
@dotdm/contracts published 1.1.1-dev.1778274929 from the CDM
migrate-to-product-sdk PR (paritytech/contract-dependency-manager#13)
which drops the entire @polkadot-apps/* line in favor of
@parity/product-sdk-{bulletin,contracts,descriptors,tx} on PAPI 2.x.
Pinning to that exact dev tag because the `latest` stable (1.1.1)
still pulls the legacy stack — switch back to a caret/latest once
the maintainer promotes the migrated build.

Add a `pnpm.overrides` block forcing @novasamatech/{host-api,host-papp,
product-sdk,scale,statement-store,storage-adapter} to 0.7.8-2 (the
current latest). They come in transitively from product-sdk-terminal
whose `^0.7.7` caret doesn't auto-widen across patches in lockfile
updates, so an explicit override is required to align the tree.

Result: `grep '@polkadot-apps/' pnpm-lock.yaml` returns 0 hits. The
lockfile still resolves polkadot-api@1.23.3 but only because
@parity/dotns-cli (a bundled CLI binary) declares it; the bundle
inlines all its deps and never resolves them at runtime, so the CLI
process is effectively PAPI 2.x-only.

CLAUDE.md / AGENTS.md / README.md refreshed to reflect the new shape:
the @polkadot-apps/* invariant is now stated as fact rather than
"transient via @dotdm/contracts", the upgrade rule for polkadot-api
no longer references the @dotdm-blocked compat constraint, and the
@dotdm/contracts dev-pin and Novasama override are documented.
- auth.ts: wrap findSession's `await adapter.destroy()` in try/catch on
  the no-session path, mirroring waitForLogout's teardown. A hypothetical
  destroy-time throw would otherwise propagate to lookupSession in
  commands/logout/index.ts and misreport "no account is signed in" as
  "Could not reach the login service".

- @parity/dotns-cli pin: bump 0.6.0 → 0.6.1 to match the version
  bulletin-deploy@0.7.13 declares (`^0.6.1`). Eliminates the duplicate
  dotns-cli resolution we previously had (top-level pin landed 0.6.0,
  bulletin-deploy's transitive resolution landed 0.6.1) and aligns
  Bun's bundle path (src/dotns-cli-dispatch.ts) with bulletin-deploy's
  runtime `_require.resolve` lookup. Both 0.6.0 and 0.6.1 still ship
  the broken `file:.papi/descriptors` manifest, so the existing stub
  override stays load-bearing — CLAUDE.md updated to reflect that the
  workaround applies to both versions.

- json-rpc-provider override: investigated removing it. The override
  is still load-bearing — without it, pnpm resolves three versions
  (0.0.1 optional / 0.0.4 / 0.2.0) for different transitive consumers
  in the PAPI 2.x ecosystem. Documented in CLAUDE.md why it stays.

No code-behavior changes beyond the auth.ts try/catch. dotns-cli bump
is a patch within the same broken-manifest range; bundle path resolves
the same way.
@UtkarshBhardwaj007 UtkarshBhardwaj007 merged commit 6cbb86b into main May 9, 2026
16 of 18 checks passed
@UtkarshBhardwaj007 UtkarshBhardwaj007 deleted the migrate-to-product-sdk branch May 9, 2026 11:30
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.

Playground-CLI to the new terminal package in product SDK dot init is failing when logged out with: innerDecoder is not a function (v0.19.3)

2 participants