Skip to content

fix: wallet disconnect calls DELETE instead of PATCH { stellarAddress: null } (#714) - #819

Merged
chonilius merged 2 commits into
mainfrom
fix/714-wallet-disconnect-uses-delete
Oct 29, 2026
Merged

chonilius merged 2 commits into
mainfrom
fix/714-wallet-disconnect-uses-delete

Conversation

@chonilius

Copy link
Copy Markdown
Contributor

Summary

Closes #714

Root cause: disconnect() called PATCH /users/:id/stellar-address with { stellarAddress: null }. The backend's @IsStellarAddress() validator runs StrKey.isValidEd25519PublicKey(null) → false → 400 Bad Request. The .catch(() => {}) silently discarded the failure, so AuthUser.stellarAddress stayed set on the backend while the UI appeared disconnected. Every "Disconnect" click was a no-op on the server.

Fix (frontend — this PR):

  • disconnect() now calls DELETE /users/:id/stellar-address (no body), which maps to the new dedicated unlink route added in the companion backend PR [fix: wallet disconnect fails silently — add DELETE /users/:id/stellar-address (#714) backend#718].
  • Replaces the silent .catch(() => {}) with console.error(...) so backend unlink failures are visible in devtools. The local disconnect (UI + localStorage) still completes synchronously regardless, so the UI is never lying about local state.
  • Updates the WalletContext test that asserted PATCH { stellarAddress: null } to assert DELETE instead.

Backend companion PR: MergeFi/backend#718

Test plan

  • npm test — updated WalletContext disconnect test passes; no other test regressions
  • Connect a Stellar wallet, click Disconnect — AuthUser.stellarAddress is null in the database after the call
  • Disconnect while signed out — no backend call fired (existing guard still in place)
  • Network tab in devtools shows DELETE /users/:id/stellar-address → 200 on disconnect

…ink (#714)

PATCH { stellarAddress: null } was always rejected with 400 by the backend
because @IsStellarAddress() only accepts a valid Stellar Ed25519 public key.
The .catch(() => {}) silently discarded the error, so AuthUser.stellarAddress
remained set on the backend even though the local UI showed "disconnected".

Changes:
- Call DELETE /users/:id/stellar-address instead of PATCH with null body.
- Replace the silent .catch(() => {}) with a console.error so backend
  unlink failures are visible in devtools without blocking the local
  disconnect flow.
#714)

The assertion that checked for PATCH { stellarAddress: null } would have
started failing after the WalletContext change. Updated to assert the
DELETE method with no body, matching the new backend route.
@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
merge-fi Error Error Oct 29, 2026 8:06pm UTC

@chonilius
chonilius merged commit 03a2add into main Oct 29, 2026
3 of 5 checks passed

This branch had an error being deployed

1 failed deployment
Preview — 603bc83d Deployed Oct 29, 2026 by vercel[bot]
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.

Wallet 'Disconnect' never sticks: PATCH { stellarAddress: null } always fails validation and the error is swallowed

1 participant