User story / Problem statement
Currently, createMockAdapter() keeps its connected flag in page memory and implements no
restore(). DiscoveryClient.tryRestore() only restores through that optional hook
(if (!adapter.restore) return), so a mock-backed session can never survive a reload: every boot
lands disconnected even though the SDK's splice_discovery_client_session record still names the
mock. This is a problem because the SDK's own adapters (extension, WalletConnect, remote) all
implement restore(), so the mock is the one adapter whose reload behaviour diverges from a real
wallet — a dev running a mock-first dApp is logged out on every refresh, and useParty().wallet's
survives-a-reload contract cannot be demonstrated without a real wallet.
Found during #63's harness walkthrough (task 12): the reload flows only became walkable after
wrapping the mock with a harness-local persistence shim answering restore().
Expected outcome
A mock-backed session survives a reload the way a real adapter's does: after connect + reload, the
provider restores to connected, useParty()/useParties() repopulate, and useParty().wallet
names the mock again. Disconnect still ends the persisted session. Tests that want a hermetic mock
keep today's behaviour.
Acceptance criteria
Technical notes
The shim that proves the shape (persist on connect, clear on disconnect, replay inside
restore()) is in docs/harness/src/App.tsx (withPersistedConnection, gitignored). Keep the
mock's other rule intact: it answers the connect flow only, and everything else throws naming the
method.
Additional context
Restore path: sdk.init() → DiscoveryClient.restorePersistedSessionIfNeeded() →
adapter.restore() → DappClient rebuilt → status/listAccounts. See
@canton-network/core-wallet-discovery tryRestore().
User story / Problem statement
Currently,
createMockAdapter()keeps itsconnectedflag in page memory and implements norestore().DiscoveryClient.tryRestore()only restores through that optional hook(
if (!adapter.restore) return), so a mock-backed session can never survive a reload: every bootlands disconnected even though the SDK's
splice_discovery_client_sessionrecord still names themock. This is a problem because the SDK's own adapters (extension, WalletConnect, remote) all
implement
restore(), so the mock is the one adapter whose reload behaviour diverges from a realwallet — a dev running a mock-first dApp is logged out on every refresh, and
useParty().wallet'ssurvives-a-reload contract cannot be demonstrated without a real wallet.
Found during #63's harness walkthrough (task 12): the reload flows only became walkable after
wrapping the mock with a harness-local persistence shim answering
restore().Expected outcome
A mock-backed session survives a reload the way a real adapter's does: after connect + reload, the
provider restores to connected,
useParty()/useParties()repopulate, anduseParty().walletnames the mock again. Disconnect still ends the persisted session. Tests that want a hermetic mock
keep today's behaviour.
Acceptance criteria
createMockAdapter()accepts an opt-in persistence option (name to taste, e.g.persistSession: true) that stores the connected flag inlocalStoragerestore(): returns the provider when the flag is set,nullotherwisedisconnectclears the flag;restore()after disconnect returnsnulldocs/harnessis retired when this landsTechnical notes
The shim that proves the shape (persist on
connect, clear ondisconnect, replay insiderestore()) is indocs/harness/src/App.tsx(withPersistedConnection, gitignored). Keep themock's other rule intact: it answers the connect flow only, and everything else throws naming the
method.
Additional context
Restore path:
sdk.init()→DiscoveryClient.restorePersistedSessionIfNeeded()→adapter.restore()→DappClientrebuilt →status/listAccounts. See@canton-network/core-wallet-discoverytryRestore().