Extract runtime contract ports - #109
Merged
Merged
Conversation
15 tasks
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
Extracts Dotify's runtime contract reads and writes behind typed frontend ports. The current viem/EVM behavior is preserved, but the listener and artist hooks no longer need to import contract ABIs directly for catalog reads, access checks, Classic payments, artist runtime bootstrap, track publication, access updates, release activation, or royalty payment history.
This is the next stacked step after the Product DevNet baseline in #108. It prepares the codebase for a Product-native CDM/PAPI adapter without making Product account signing authoritative yet.
Issue and context
Refs #85.
Local scope docs:
docs/backlog/polkadot-product-readiness-and-killer-dapp-roadmap.mddocs/explanation/product-devnet-architecture.mddocs/explanation/architecture-overview.mdThe Product DevNet baseline proves that Dotify can run inside a compatible Product host, publish through Bulletin/DotNS, and use an app-scoped Product account as presence identity. The next blocker is contract portability. Today Dotify's authoritative runtime path is viem against Paseo Asset Hub EVM, while Product contract helpers are expected to move through CDM/PAPI and host-mediated signing.
Without a port boundary, adding that adapter would force Product-specific conditionals into
useCataloganduseArtistConsole, two hooks that already sit on critical listening and artist-publish paths. This PR keeps the product behavior unchanged and moves the contract boundary into a small typed feature module first.Architecture and key concepts
The new boundary is intentionally narrow:
RuntimeReadPortowns contract reads needed by the current UI:RuntimeWritePortowns the existing write surface:createViemRuntimeReaderandcreateViemRuntimeWriterare the only implementations in this PR. Product-native writes remain a follow-up adapter behind the same interfaces.How it works
In standalone and Netlify/Fly mode, the hooks instantiate the viem adapter with the configured RPC URL and existing wallet client. Catalog loading still enumerates the artist directory and SmartRuntime records when the backend catalog API is not configured. Free access checks still use the zero address for walletless visitors. Classic unlocks still submit
musicRoyPayAccesswith value through the connected EVM wallet.In the artist console, runtime bootstrap, track registration, access updates, release activation, and royalty payment history now call the runtime port instead of issuing raw
readContract,writeContract, andgetLogscalls inline.Design decisions and tradeoffs
The PR extracts ports before adding the Product adapter. That keeps the risk small: the active runtime behavior is the same, but the next PR can focus on CDM/PAPI mapping instead of untangling UI hooks at the same time.
Alternatives considered:
Security, failure, and operations
Security invariants preserved:
Operationally, there are no new environment variables or hosted settings. This PR updates architecture docs because it changes the contract integration boundary, but it does not require Netlify, Fly, or Product DevNet dashboard changes.
Review guide
Suggested order
web/src/features/runtime/runtimePorts.ts- verify the port shape is small enough for both viem and future CDM/PAPI adapters.web/src/features/runtime/viemRuntimeAdapter.ts- verify each method preserves the previous ABI call, pagination, zero-address handling, royalty split fallback, event log normalization, and receipt waiting behavior.web/src/hooks/useCatalog.ts- verify catalog discovery, walletless Free access, paid access, and registry refresh behavior did not change.web/src/hooks/useArtistConsole.ts- verify artist runtime bootstrap, release registration, access edits, activation edits, and royalty history still use the same user-facing states.docs/explanation,docs/backlog, anddocs/index.html- verify the Product roadmap now says ports are delivered but CDM/PAPI and Product-signed key requests remain future work.Verify carefully
nullbefore reaching hooks?Validation
git diff --cached --checkcd web && npm run lintApp.tsxandArtistShell.tsx.cd web && npm run test:unit -- --run src/features/runtime/viemRuntimeAdapter.test.tscd web && npm run test:unitcd web && npm run buildcd web && npm run build:product-devnetnode scripts/backlog-sync.mjs --check --offlineKnown limitations and follow-ups
This PR should remain
Refs #85, notCloses #85.Remaining before #85 can close:
Metadata checklist
Dotify sprints)knzeng-edotify-backlog,product-sdk