Skip to content

feat: harden wallet state, API timeouts, and mutation retries - #713

Open
francescoricc1 wants to merge 4 commits into
TrusTrove:mainfrom
francescoricc1:feat/stellar-drips-wave-636-637-638-639
Open

feat: harden wallet state, API timeouts, and mutation retries#713
francescoricc1 wants to merge 4 commits into
TrusTrove:mainfrom
francescoricc1:feat/stellar-drips-wave-636-637-638-639

Conversation

@francescoricc1

Copy link
Copy Markdown

Summary

Second repository-wide audit wave covering four functional edge cases in apps/web: stale auth tokens, hung requests, missing retry on financial mutations, and a wallet state desync after reload. One commit per issue.

Changes

Testing

Unit tests added alongside each fix following existing vitest patterns (apps/web/lib/api.test.ts, apps/web/store/wallet.test.ts).

Closes #636
Closes #637
Closes #638
Closes #639

francescoricc1 and others added 4 commits August 30, 2026 12:54
initApiClientWithToken only set a token when one existed, so logout
(setToken(null) then re-init) left the previous JWT cached in the
client and continued sending an Authorization header on later calls.
Add explicit clearToken() and invoke it whenever the store token is
falsy.

Closes TrusTrove#637

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
None of the fetch wrappers passed an AbortSignal, so a hung backend or
dropped connection left requests pending indefinitely and polling hooks
stacked new calls on top of stuck ones. Add a 20s timeout for every
request and thread react-query's own query signal through the polling
queryFns so in-flight calls cancel on unmount/refetch.

Closes TrusTrove#638

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
All useMutation calls used react-query's default retry: 0, so a single
transient 503/504 gateway blip failed money-moving actions outright. Add
a shared mutationRetryPolicy (bounded 3-attempt retry with exponential
backoff capped at 8s) that only retries transient 5xx/network errors,
never user rejections or permanent 4xx errors, and attach status codes
to API errors so the policy can classify them.

Closes TrusTrove#639

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
The Zustand wallet store persisted address/network/role but not
`connected`, so after a reload the address rehydrated while `connected`
reset to false. Queries keyed on address fired while the UI (which gates
on connected && address) showed a disconnected wallet. Persist
`connected` and clear a stale rehydrated address/network when the store
restarts disconnected, so no address-keyed query runs while disconnected.

Closes TrusTrove#636

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@vercel

vercel Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

@francescoricc1 is attempting to deploy a commit to the K1NGD4VID Team on Vercel.

A member of the Team first needs to authorize it.

@mergekeeper

mergekeeper Bot commented Aug 30, 2026

Copy link
Copy Markdown

MergeKeeper review

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

The PR successfully resolves the four linked issues (#636, #637, #638, and #639) without introducing unrelated changes.

Reviewed commit: 8c67f6a55fb7102dc2d26c3398441d9919d0cf95.
CI and merge eligibility are checked separately.

@mergekeeper

mergekeeper Bot commented Aug 30, 2026

Copy link
Copy Markdown

MergeKeeper merge status

Status: blocked
PR state: open
Mergeability: unknown
Checked commit: 8c67f6a55fb7102dc2d26c3398441d9919d0cf95.

Reason:
GitHub pull request merge request failed with 405: Pull Request has merge conflicts

Next steps:

  1. Update this branch with the latest main.
  2. Resolve the merge conflicts locally.
  3. Run the relevant tests, commit, and push the fix.
  4. MergeKeeper will automatically re-review the new head commit.

@mergekeeper mergekeeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved

The PR successfully resolves the four linked issues (#636, #637, #638, and #639) without introducing unrelated changes.

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