Fetch recovery status when walletId is missing instead of fake delay - #746
Merged
Conversation
|
@chidinma000 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
useRecovery(null)(no wallet selected) ran a simulatedsetTimeout(1200)"bootstrap" before flipping to
idle— a demo stub masquerading as a statusfetch. The loading skeleton on
/recoverywas driven by a fake timer ratherthan any real request.
closes #620
Change
useRecovery— thestubLoaded/stubErrorstate, thesetTimeout(1200)effect, and thenow-unused
useEffectimport are gone.UseRecoveryOptions { walletsLoading?: boolean }. WhenwalletIdis
nullthere is no wallet to fetch a per-wallet recovery status for, sothe hook no longer fabricates one. It mirrors the caller's real wallet-list
fetch instead:
loadingwhilewalletsLoadingis true, then straight tothe CTA state machine (
idle). Identical behavior in every environment —no fake delay, no
NODE_ENVbranch on the status path.src/app/recovery/page.tsxpassesuseWallets().loadingthrough aswalletsLoading, so the loading skeleton tracks the actual/api/walletsrequest. Once a wallet resolves, the existing
walletId !== nullpath(
useRecoveryStatus/fetchRecoveryStatus) takes over.confirmRecoverykeeps its existing explicit production/demo split(production rejects with "Select a wallet before initiating recovery.";
non-production keeps a demo stub). Only the stale comment referencing the
deleted bootstrap was updated. No custody secrets are ever sent — only the
wallet identifier.
Production vs demo/mock split
walletId !== nulluseRecoveryStatus; loading/error come from that fetchwalletId === nullwalletsLoading) →idle. No simulated delay, any environmentconfirmRecovery, no wallet, productionconfirmRecovery, no wallet, non-productionTests
src/hooks/__tests__/useRecovery.test.ts— reworked the stub-mode block intoa
#620block that fails if the gap returns:idlewhen the wallet list is not loading (no fake delay)loadingwhilewalletsLoadingis trueloading → idlewhen the wallet list settlessetTimeout)idleimmediately; no faked success on confirm)retained
pnpm exec vitest run src/hooks/__tests__/useRecovery.test.ts src/app/recovery/__tests__/page.test.tsx→ 50 passed. Runnable in CI viapnpm test.No Playwright test added: the only user-visible effect is a loading skeleton
with no live backend, and there is no recovery e2e harness.
Docs
src/docs/API_Hooks.md— updated theuseRecoverysection to the newsignature
useRecovery(walletId, { walletsLoading })and contract.src/lib/env.ts.confirmRecoverydemo stub).Out of scope
Backend API work (mux-backend). No new default secrets; no cookie-only auth.
Pre-existing issues (not touched)
Repo-wide
tsc --noEmiterrors and failing suites (recoveryApi.test.ts,useRecoveryStatus.test.ts,RecoveryTimelineEvent/RecoveryTimelineList/darkModecomponent tests) were confirmed present on a clean tree viagit stashand are unrelated to this change. Files edited here type-check andlint clean.