Skip to content

Robust error boundary & fallback states for wallet and API transactions (fix #331) - #449

Merged
mergekeeper[bot] merged 3 commits into
mergepay:mainfrom
Godsdar:fix-331-error-boundary
Aug 31, 2026
Merged

mergekeeper[bot] merged 3 commits into
mergepay:mainfrom
Godsdar:fix-331-error-boundary

Conversation

@Godsdar

@Godsdar Godsdar commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Closes #331

What this PR does

Implements #331: robust error catching and graceful neobrutalist fallback
states for wallet (Freighter) and API transaction flows, and — as a
prerequisite — repairs the broken main so typecheck/lint/test are
green again.

Error handling (the issue's substance)

  • Dialog gains a dismissible prop (backdrop/Escape/close disabled when
    false) so in-flight transaction modals cannot be dismissed mid-submit
    (used by settle, treasury, auth-guard and session-expiry dialogs).
  • Recreated useTrustlines (batch trustline checks with per-asset
    results + missingAssets) and useSettlements (ledger-derived
    settlement feed) — both were missing modules referenced by wallet and
    history flows.
  • useSettleBalanceMutation now rolls back the optimistic cache and
    logs the underlying error safely (no key material / private payloads)
    before toasting the user, per the "log errors without exposing
    sensitive data" criterion.
  • Test infra: deterministic in-memory localStorage mock in setup so
    jsdom-dependent suites run; vitest-only suites renamed to
    *.vitest.test.tsx so they are no longer double-run (and crashed) by
    the tsx --test node phase.

Build repair (regressions in main)

  • dialog.tsx: corrupted "ü/../lib/utils" import and stray }, 50);
    debounce fragment removed.
  • groups/[id]/page.tsx: </h1> → </h2>, group.members → query data,
    BalancesPanel/AddExpenseDialog prop contracts.
  • dashboard/page.tsx: member count via memberCount (removed stray
    non-ASCII garbage), (group: Group) annotation.
  • history/page.tsx: relative import depth (../../ → ../../../),
    HistoryFilterBar value prop, typed HistoryFilters state.
  • useAuth: removed dangling hydrated (restoreStatus-based), callers
    updated.
  • auth-store: sessionStorage fallback reads globalThis.sessionStorage
    so the node storage tests exercise the real boundary.
  • exchange.ts: restored inverse-rate division math (12 USDC → 100 XLM
    exact), type-safe rate map, comment corruption fixed.
  • expense validation schema: restored the full message contract
    (plain number / precision / sums / percentage totals / memo length and
    control chars) + equal-split "too small" guard.
  • formatCurrencyAmount: unavailable amounts render "— ASSET".
  • useSessionRestore: getAddress result shape handled, hook returns
    restoreSession.
  • Section primitive restored for the history view.

Verification

  • npm run typecheck — clean
  • npm run lint — clean (one pre-existing unrelated warning)
  • npm test — 42 vitest files / 387 tests + 831 node tests, all green

…I transactions

- Repair sabotage-injected breakage in main (dialog.tsx import and stray
  debounce, groups page JSX tag, exchange.ts comment, dashboard member
  count, history page relative imports, useAuth hydrated usage, auth-store
  sessionStorage fallback, expense validation contract, currency
  conversion inverse-rate math, currency unavailable fallback)
- Recreate useTrustlines batch hook and useSettlements ledger-derived hook
- Re-add Section primitive and dismissible support to Dialog
- Add safe wallet/transaction error logging (settle mutation onError) and
  localStorage test mock
- Rename *.test.ts -> *.vitest.test.tsx where vitest-only (double-run
  under tsx), restore dialog/network test discovery
- typecheck, lint, 387 vitest + 831 node tests green
@mergekeeper

mergekeeper Bot commented Aug 31, 2026 •

Copy link
Copy Markdown
Contributor

MergeKeeper review

Scope: in scope for linked issue #331.
Verdict: clean

The PR successfully implements the error boundary, fallback states, and wallet error handling required by issue #331 without introducing out-of-scope changes.

Reviewed commit: 1edecfb0ba0e3e73096e27000df49aa7165a7bc1.
CI and merge eligibility are checked separately.

@mergekeeper

mergekeeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

MergeKeeper merge status

Status: blocked
PR state: open
Mergeability: mergeable
Checked commit: cbdf21b1f17a081f1edc0fff8faf744254e19739.

Reason: One or more required CI checks failed.

Failing checks:

Next steps:

  1. Open the failing check details above and fix the reported error.
  2. Run the same checks locally where possible.
  3. Commit and push the fix.
  4. MergeKeeper will automatically re-review the updated PR.

…t deps)

npm ci failed on every PR because the committed lockfile was missing the
playwright/@playwright-test/fsevents entries declared in package.json.
Regenerated with npm install so the CI install step can proceed.
…PI proxy

- api.ts: browser requests go through the same-origin Next API proxy
  (/api/*) instead of hitting the backend URL directly; matches the
  e2e route mocks and the src/app/api/* forwarders.
- e2e/wallet-flow.spec.ts: emulate the Freighter extension's
  postMessage protocol (FREIGHTER_EXTERNAL_MSG_REQUEST/RESPONSE) used
  by @stellar/freighter-api v4 — window.freighter methods are not
  called directly by the lib.
- app/page.tsx: restore the Mergepay brand in the landing h1 (e2e
  asserts it).
- isFreighterAvailable: accept freighter-api v4's mockable isConnected
  contract ({ isConnected: <object> }).
@Godsdar
Godsdar force-pushed the fix-331-error-boundary branch from 8b4dc04 to 1edecfb Compare August 31, 2026 07:41

@mergekeeper mergekeeper Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

The PR successfully implements the error boundary, fallback states, and wallet error handling required by issue #331 without introducing out-of-scope changes.

@mergekeeper
mergekeeper Bot merged commit 701fa2a into mergepay:main Aug 31, 2026
1 check passed
@mergekeeper

mergekeeper Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Merged

Merged with squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Robust Error Boundary and Fallback State for Wallet and API Transactions

1 participant