Skip to content

fix(lib): handle storage fallbacks and local tokens (#420) - #435

Merged
Jaydbrown merged 6 commits into
conduit-protocol:mainfrom
Danlee76:fix/420-423-storage-boundary-tokens
Aug 31, 2026
Merged

fix(lib): handle storage fallbacks and local tokens (#420)#435
Jaydbrown merged 6 commits into
conduit-protocol:mainfrom
Danlee76:fix/420-423-storage-boundary-tokens

Conversation

@Danlee76

Copy link
Copy Markdown

What does this PR do?

Fixes four browser/runtime edge cases around storage fallback behavior, ErrorBoundary recovery scheduling, settings persistence, and local token metadata.

Type of change

  • Bug fix
  • New feature / page / component
  • Refactor
  • Style / design fix
  • Test coverage
  • Documentation
  • Dependency update

Related issue

Closes #420
Closes #421
Closes #422
Closes #423

Changes

File Change
lib/wallet-storage.ts Prefer the in-memory fallback before localStorage so stale persisted sessions do not override the current wallet session.
components/ErrorBoundary.tsx Move circuit-breaker reset scheduling from render() into componentDidUpdate().
app/settings/page.tsx Skip the initial settings rewrite and ignore unavailable localStorage writes.
lib/tokens.ts Add an explicit empty local token list so local networks do not receive testnet contract IDs.
Tests Add regression coverage for all four fixes.
CHANGELOG.md Document the fixes under [Unreleased].

Checklist

  • npm run typecheck — no errors
  • npm run lint — no warnings
  • npm test — all tests pass
  • npm run build — production build succeeds
  • Tested in browser with Freighter on testnet
  • No hue-named Tailwind colour classes added (black/white/gray only)
  • Loading state handled for any new data-fetching UI
  • Error state handled and displayed inline (no alert())
  • 'use client' added only where genuinely needed
  • CHANGELOG.md updated under [Unreleased]

Screenshots

No visible UI changes.

Notes for reviewers

Browser wallet testing was not required for these storage/library-only regression fixes; local unit coverage exercises the failing cases directly.

Add regression coverage for stale wallet sessions when localStorage writes fail and for settings persistence when browser storage is unavailable.

These cases need coverage because Safari private mode and restricted webviews can allow reads while throwing on writes.
Assert that ErrorBoundary rendering remains pure when the breaker UI is active and that local token lookup does not reuse testnet contracts.

These checks protect against render-phase timers and opaque local-network token failures.
Read wallet sessions from the in-memory fallback before localStorage so the current session wins when browser storage writes fail but reads still succeed.

Guard Settings writes and skip the initial mount rewrite so unavailable localStorage degrades to non-persistent settings instead of crashing.

Closes conduit-protocol#420

Closes conduit-protocol#422
Move ErrorBoundary breaker recovery scheduling into componentDidUpdate so timers are created after committed state changes instead of during render.

Return an explicit local token list instead of falling through to testnet contract addresses, making unconfigured local networks fail clearly.

Closes conduit-protocol#421

Closes conduit-protocol#423
Record the fixed storage fallback, ErrorBoundary reset scheduling, guarded settings persistence, and local token behavior in the Unreleased changelog.

The PR has been checked with typecheck, lint, unit tests, and production build locally.
@drips-wave

drips-wave Bot commented Aug 31, 2026

Copy link
Copy Markdown

@Danlee76 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! 🚀

Learn more about application limits

@Jaydbrown

Copy link
Copy Markdown
Contributor

Merged main in locally and ran tsc --noEmit: the result doesn't type-check. contexts/WalletContext.tsx gets a Duplicate identifier 'resetTokenAllowanceGateway' (both this branch and merged work add it), app/dashboard/page.tsx has Promise.allSettled result-type errors, and lib/token-allowance-gateway.test.ts calls a 3-arg signature with 2 args (the gateway API changed on main). Needs a rebase + reconciliation with the current token-allowance-gateway API. Leaving open per instruction.

@Jaydbrown
Jaydbrown merged commit f83f6bf into conduit-protocol:main Aug 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment