You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently canton-connect/src/CantonConnectProvider.tsx is ~640 lines. The connect/cancel/restore
race core has to stay together (five concerns share four refs plus the transition helpers;
splitting them threads the same refs through every file boundary), but roughly 150-200 lines are
leaf concerns with little or no shared state: the adapter building, the two public context types,
and the in-page picker bridge. A reader pays the whole file to find any one of them.
Sized by #63's pre-undraft review pass; this issue is the profitable slice.
Expected outcome
The provider file holds only the race core and context assembly (roughly 440-540 lines depending
on whether the picker bridge moves). Behavior identical, public API identical, and the existing
test suite passes textually unchanged (it imports only the public surface).
Acceptance criteria
buildAdditionalAdapters and AdapterConfig move to src/adapters.ts
TxStatusSnapshot and CantonConnectContextValue move to src/types.ts, re-exported from CantonConnectProvider so existing imports keep resolving
Optional, judged at implementation time: the in-page picker bridge (inPagePicker, select/cancel, cancelPending, offeredWallets) becomes a hook taking the shared refs
as stable params; inPagePicker's identity stays stable (it keys the sdk memo)
The race core (connect, runConnect, syncFromStatus, the mount effect, disconnect)
stays in CantonConnectProvider.tsx, per canton-connect/CLAUDE.md
pnpm -C canton-connect test passes with no test edits; no public API change
Technical notes
Do this after the #47..#63 stack merges: a rename-heavy diff on top would churn the review
anchors. The deeper hook split (useConnectAttempt, useSessionRestore, ...) was evaluated and
rejected for now, because it scatters the transition helpers that #63's recorded reducer deferral
wants gathered in one place. Revisit only at that trigger; the reducer work shrinks the provider
naturally (the transitions become a sibling connectionReducer.ts, independently testable).
User story / Problem statement
Currently
canton-connect/src/CantonConnectProvider.tsxis ~640 lines. The connect/cancel/restorerace core has to stay together (five concerns share four refs plus the transition helpers;
splitting them threads the same refs through every file boundary), but roughly 150-200 lines are
leaf concerns with little or no shared state: the adapter building, the two public context types,
and the in-page picker bridge. A reader pays the whole file to find any one of them.
Sized by #63's pre-undraft review pass; this issue is the profitable slice.
Expected outcome
The provider file holds only the race core and context assembly (roughly 440-540 lines depending
on whether the picker bridge moves). Behavior identical, public API identical, and the existing
test suite passes textually unchanged (it imports only the public surface).
Acceptance criteria
buildAdditionalAdaptersandAdapterConfigmove tosrc/adapters.tsTxStatusSnapshotandCantonConnectContextValuemove tosrc/types.ts, re-exported fromCantonConnectProviderso existing imports keep resolvinginPagePicker,select/cancel,cancelPending,offeredWallets) becomes a hook taking the shared refsas stable params;
inPagePicker's identity stays stable (it keys thesdkmemo)connect,runConnect,syncFromStatus, the mount effect,disconnect)stays in
CantonConnectProvider.tsx, percanton-connect/CLAUDE.mdpnpm -C canton-connect testpasses with no test edits; no public API changeTechnical notes
Do this after the #47..#63 stack merges: a rename-heavy diff on top would churn the review
anchors. The deeper hook split (
useConnectAttempt,useSessionRestore, ...) was evaluated andrejected for now, because it scatters the transition helpers that #63's recorded reducer deferral
wants gathered in one place. Revisit only at that trigger; the reducer work shrinks the provider
naturally (the transitions become a sibling
connectionReducer.ts, independently testable).