Skip to content

feat(wallet): universal adapter layer — delegate to mobileWalletConne…#55

Open
abrak01 wants to merge 1 commit into
Kalebtron1:mainfrom
abrak01:feat/46-wallet-adapter
Open

feat(wallet): universal adapter layer — delegate to mobileWalletConne…#55
abrak01 wants to merge 1 commit into
Kalebtron1:mainfrom
abrak01:feat/46-wallet-adapter

Conversation

@abrak01
Copy link
Copy Markdown

@abrak01 abrak01 commented May 28, 2026

Problem

AppContext was entirely in-memory. Every page reload reset depositsCount,
isUnlocked, and creditWithdrawn to zero, forcing users to re-verify their flow
state even when nothing had changed on-chain.

What changed

src/context/AppContext.tsx only.

Two helpers:

  • loadSession() — reads vinculo_app_state from localStorage on mount. Discards
    the entry if it is older than 24 hours.
  • saveSession() — writes the current snapshot on every relevant state change.
    Fails silently if storage is unavailable.

AppProvider seeds its initial state from loadSession() and runs a useEffect to
call saveSession() whenever depositsCount, isUnlocked, or creditWithdrawn
changes.

What is persisted

┌───────┬────────┐
│ Field │ Reason │
├───────────────┼────────┤
│ depositsCount │ Determines whether the unlock threshold is met │
├───────────────┼────────────────────────────────────────────────┤
│ isUnlocked │ Controls credit section visibility │
├─────────────────┼────────────────────────────────────────────────┤
│ creditWithdrawn │ Prevents the withdraw button from showing when a loan │
│ │ is active │
└─────────────────┴─────────────────────────────────────────────────────────┘

Balance, deposit history, withdrawals, and stakes are intentionally not
persisted — they are re-fetched from Supabase or the chain on demand.

Wallet address recovery (vinculo_wallet, vinculo_wallet_provider) was already
handled by useWallet.tsx and is unchanged.

Stale state fallback

Snapshots older than 24 hours are discarded and the app starts from clean
defaults. This prevents a stale creditWithdrawn: true from blocking a user
whose loan has since been repaid.

Reviewer steps

  1. npm run dev → make a deposit → reload → confirm deposit count and unlock
    state are restored.
  2. Clear vinculo_app_state from localStorage → confirm the app starts fresh.
  3. npm run build → confirm 0 errors.

close #47

@vercel
Copy link
Copy Markdown

vercel Bot commented May 28, 2026

@abrak01 is attempting to deploy a commit to the alankcr1-6443's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@abrak01 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

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.

Recuperacion de sesion y state restore

1 participant