Add Product CDM runtime adapter - #110
Merged
Merged
Conversation
This was referenced Jul 28, 2026
knzeng-e
marked this pull request as ready for review
August 3, 2026 13:33
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.
Outcome
Adds an experimental Product CDM/PAPI runtime adapter behind Dotify's new
RuntimeReadPort/RuntimeWritePortboundary.The adapter maps the existing Dotify SmartRuntime method surface to Product SDK contract-handle style
query/txcalls, validates CDM package address mismatches, returns Product transaction hashes, and fails explicitly for unsupported Product runtime history reads. It is not selected by the shipped UI yet.Issue and context
Refs #85.
Stacked on #109, which extracts the runtime ports. This PR is the next Product portability step after that boundary exists.
Local scope docs:
docs/backlog/polkadot-product-readiness-and-killer-dapp-roadmap.mddocs/explanation/product-devnet-architecture.mddocs/explanation/architecture-overview.mddocs/operations/product-devnet-deployment.mdOfficial Product docs now describe CDM as the Product contract package model: contracts are deployed to Product DevNet Asset Hub through
pallet-revive, registered by package name, installed into a frontend throughcdm.json, and consumed with@parity/product-sdk-contractshandles. Dotify's current deployed runtime remains viem/EVM, so the safe next step is an adapter that can consume those CDM handles without wiring it into user flows before a real Dotify CDM manifest exists.References:
Architecture and key concepts
The adapter has three layers:
ProductCdmRuntimeContractResolver: resolves directory, factory, and dynamic artist runtime handles.createProductCdmRuntimeReader: maps reads such asruntimeOf,artistsPage,musicRegGetTrack,musicAccCanAccess, andpendingRuntimeStageOf.createProductCdmRuntimeWriter: maps writes such ascreateRuntime,installRuntimeStep,musicRegRegister,musicRoyPayAccess,musicRegSetAccessMode, and release activation/deactivation.The resolver reflects CDM's package model. Directory and factory can be package-resolved static contracts. Artist runtimes are dynamic instances that share a SmartRuntime ABI, so the adapter requires an explicit
runtimeContractFactory(runtimeAddress, runtimePackage).How it works
The adapter accepts structural Product contract handles compatible with the Product SDK contracts API:
.query(...)returns{ success, value };.tx(...)returns a Result carrying a Product SDK transaction result withtxHash.Queries normalize the same values the viem adapter returns to the hooks:
null;Transactions return the SDK
txHashas Dotify's existingHashtype.waitForTransactionis a no-op because Product SDK.tx()already signs, submits, and watches before resolving.Royalty payment history deliberately throws
ProductCdmRuntimeUnsupportedOperationError. The current Product contract handle surface does not replace viem's historicalgetLogscall. Product mode must use the backend catalog/read-model indexer, or a future Product event/indexer API, for that artist-console history.Design decisions and tradeoffs
The adapter is present but not selected by default. That keeps standalone Netlify/Fly behavior and the Product DevNet baseline stable while giving the next PR a concrete integration target once
cdm.jsonand generated types exist.Alternatives considered:
Security, failure, and operations
Security invariants preserved:
Operationally, there are no new Netlify, Fly, or Product environment variables in this PR. To actually enable this adapter later, operators still need CDM-deployed Dotify runtime packages,
cdm.json, generated contract types,pallet-reviveaccount mapping, Bulletin authorization, and real Product host transaction smoke evidence.Review guide
Suggested order
web/src/features/runtime/productCdmRuntimeAdapter.ts- verify the adapter implements the runtime ports without selecting Product mode by default.web/src/features/runtime/productCdmRuntimeAdapter.test.ts- verify method routing, failure behavior, zero-address normalization, split fallback, and transaction hash handling.docs/explanation/product-devnet-architecture.md- verify the docs do not overclaim Product write readiness.docs/backlog/polkadot-product-readiness-and-killer-dapp-roadmap.md,docs/backlog/README.md,README.md,spec.md,docs/index.html, anddocs/operations/product-devnet-deployment.md- verify roadmap and operator wording stays aligned.Verify carefully
.tx()error handling reject SDK errors, dispatch failures, and invalid hashes?Validation
cd web && npm run test:unit -- --run src/features/runtime/productCdmRuntimeAdapter.test.ts src/features/runtime/viemRuntimeAdapter.test.tscd web && npm run lintApp.tsxandArtistShell.tsx.cd web && npm run test:unitcd web && npm run buildcd web && npm run build:product-devnetcd web && npm run fmt:checkgit diff --checknode scripts/backlog-sync.mjs --check --offlineKnown limitations and follow-ups
This PR should remain
Refs #85, notCloses #85.Remaining before #85 can close:
cdm.jsonmanifest and generated Product contract types into Product mode;Metadata checklist
Dotify sprints)knzeng-edotify-backlog,product-sdk