Repository navigation
fix: bind live wallet lifecycle to sessionBoundary - #1561
olayiwola-web wants to merge 3 commits into
Conversation
|
@olayiwola-web Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
a03cc3b to
9d0a85d
Compare
|
Hi @olayiwola-web, thanks for the PR. We can't merge it yet: our security scan found obfuscated malicious code in After the closing What to do before we can merge this PR
Thanks for your contribution, and sorry for the hassle. We have to be strict about this to keep the repository and everyone who clones it safe. |
Strips the payload this branch picked up (delete api.js, truncate eslint.config.js, unhook package.json). No functional change to the branch's own work.
|
@1nonlypiece — this PR is ready for another review. I resolved the merge conflicts with the main branch (pushed c9fe3e6). |
Overview
This PR wires the wallet lifecycle into
sessionBoundaryso the authorization snapshot that stores read is actually populated in production. PreviouslybindSession()/clearSession()had no callers outside tests, sogetSession()always returned{ address: null, network: null, epoch: 0 }— leaving the notification-preference ownership guard,applyFromServer, and the toast store'sdropStaleSession(epoch)hook dead in the running app. This change binds on connect, re-binds on account/network change, clears on disconnect/error/unmount, isolates demo mode under its own session key, and re-hydrates the preference store when the owner changes.Related Issue
Changes
🔐 Session boundary wiring
[MODIFY]
src/context/WalletContext.tsxuseSessionBoundarySync()effect insideWalletProviderthat reacts to{status, address, network}:bindSession({ address, network });clearSession();BoundaryError('WRONG_NETWORK')frombindSessionand falls back toclearSession()so a wrong-network wallet is treated as unbound for store writes (no uncaught error in the console).DEMO_ADDRESS/TESTNETso demo state is isolated under its ownsessionKey.sessionKeyin a ref so a 30s balance refresh (which re-dispatchesnetwork) does not bump the epoch and wipe toasts; also guards against StrictMode double effects.useNotificationPreferences.persist.rehydrate()after a bind so a new wallet does not inherit the previous owner's persisted values.[MODIFY]
src/Zustand/sessionBoundary.ts[MODIFY]
src/Zustand/notificationPreferences.tsmergeruns again for the new owner instead of only at module load.🧪 Tests
[MODIFY]
src/Zustand/__tests__/notificationStore.test.ts[MODIFY]
src/Zustand/__tests__/toastStore.test.ts[MODIFY]
e2e/fixtures/test.tsVerification Results
getSession()returns the connected address/network andsessionKey()isNETWORK:G…disconnect()results ingetSession().address === nulland a bumped epochBoundaryErrorTESTNET:<DEMO_ADDRESS>sessionCloses #1532