refactor(sdk): split RelayerDispatcher into ChainRouter [SDK-193]#414
Open
ghermet wants to merge 14 commits into
Open
refactor(sdk): split RelayerDispatcher into ChainRouter [SDK-193]#414ghermet wants to merge 14 commits into
ghermet wants to merge 14 commits into
Conversation
…rForChain [SDK-193] Service call sites become `router.relayer.X()` (instead of `router.active.X()`), and the explicit per-chain accessor becomes `router.relayerForChain(chainId)` (instead of `router.for(chainId)`). - `relayer` names the type (`RelayerSDK`) instead of the lifecycle state. - `relayerForChain` mirrors `switchChain` and avoids the JS-reserved `for`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Only ChainRouter remains in the SDK surface; ZamaSDK.terminate() now calls router.terminate(). buildZamaConfig still constructs a RelayerDispatcher (which extends ChainRouter); Task 6 swaps that to ChainRouter and removes the dispatcher entirely. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
buildZamaConfig now constructs ChainRouter directly. The deprecated RelayerDispatcher subclass and its tests are removed; chain-router.test.ts covers the surviving chain-management behaviour. Public surface drops RelayerDispatcher; WorkerLike re-exports from chain-router. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- RelayerDispatcher class export removed - ChainRouter class export added (with `relayer` getter and `relayerForChain` method) - ZamaConfig.relayer → router; ZamaSDK.relayer → router - Decryption namespace ctor signature: relayer → router Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Resolved ZamaConfig duplicated the chain list (chains + router.chains). The ChainRouter owns the chain registry; consumers read config.router.chains instead. Only one in-tree reader (ZamaSDK's registry-address loop) needed adjusting. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Public API Changes
|
After ZamaConfig.chains was removed (the router now owns the chain list), test fixtures still set chains: [chain] via `as unknown as ZamaConfig` casts. Dead now — the router fixture (which depends on the chain fixture) already encapsulates the chain. Drops the FheChain import and the chain dep from WrapperDeps in the react-sdk wrapper. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… [SDK-193] - TSDoc on ChainRouter members (constructor, chain, chains, relayer, relayerForChain, switchChain, terminate, [Symbol.dispose]) - Refresh API report to clear the resulting `(undocumented)` markers - Drop the stale `RelayerDispatcher` reference from the SDK-205 migration doc — class was deleted in SDK-193 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The node e2e specs under test/playwright/tests/node/ were missed during the ChainRouter migration — they still called sdk.relayer.X(), which is undefined now that ZamaSDK exposes the router instead. 9 specs across 4 files were failing with `Cannot read properties of undefined (reading 'generateKeypair')`. Rename to sdk.router.relayer.X() throughout. The drift wasn't caught at typecheck time because tests/ is outside test/playwright/tsconfig.json's include — only fixtures/ and top-level *.ts are typechecked there. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…r-into-a-chain-router-and-a-per-chain
…r-into-a-chain-router-and-a-per-chain
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
Splits
RelayerDispatcher— which was both routing requests across chains and acting as a per-chainRelayerSDKfacade — into two single-purpose concepts:ChainRouter— owns the per-chainRelayerSDKinstances and exposesrouter.relayer(active chain) androuter.relayerForChain(id)(specific chain).RelayerSDK— unchanged, but now accessed exclusively via the router.Services consume
this.#router.relayer.X()instead of dispatching through a singleRelayerSDK-shaped facade. DropsZamaSDK.relayer,ZamaConfig.relayer, and the redundantZamaConfig.chainsfrom the public surface;ZamaSDK.router/ZamaConfig.routerreplace them. Clean break — no shims.Test plan
pnpm typecheckclean across all packagespnpm api-reportclean (API reports regenerated, no drift)pnpm test(sdk + react-sdk)🤖 Generated with Claude Code