Skip to content

fix: add wallet ready state to prevent signing with null keypair after page refresh (Closes #172) - #218

Open
waterWang wants to merge 1 commit into
Epta-Node:mainfrom
waterWang:fix/wallet-keypair-persistence-172
Open

fix: add wallet ready state to prevent signing with null keypair after page refresh (Closes #172)#218
waterWang wants to merge 1 commit into
Epta-Node:mainfrom
waterWang:fix/wallet-keypair-persistence-172

Conversation

@waterWang

Copy link
Copy Markdown

Summary

Fixes #172 — CRITICAL: Wallet Keypair Loss on Page Refresh.

Root Cause

The Stellar SDK Keypair object is not JSON-serializable and cannot be stored in localStorage. After page refresh:

  1. publicKey is restored from localStorage → connected = true
  2. keypair is always null → signing fails
  3. SendXLMForm.handleConfirm() calls transaction.sign(keypair) with null → crash

Changes

WalletContext.tsx — Added ready derived state:

  • Freighter: always ready when connected (Freighter handles signing)
  • Secret key: only ready when keypair is in memory

WalletPage.tsx — When wallet is connected but not ready (secret-key after refresh), shows a reconnect prompt with:

  • The public key displayed for reference
  • Secret key input field to re-enter
  • Reconnect and Disconnect buttons

TopNav.tsx — Shows "Reconnect Required" badge when wallet is not ready

Navbar.tsx — Shows Connect button instead of wallet chip when wallet is not ready

Acceptance Criteria

  • Wallet does not show as fully connected when keypair is null after refresh
  • Secret-key users see a clear reconnect prompt instead of a broken wallet UI
  • Freighter users are unaffected (always ready when connected)
  • TopNav shows "Reconnect Required" badge when wallet needs reconnection
  • Landing page Navbar shows Connect button when wallet is not ready

…r page refresh (Closes Epta-Node#172)

The wallet appeared connected after page refresh (publicKey restored from
localStorage) but keypair was always null since Keypair is not JSON-serializable,
causing all transaction signing to fail.

Changes:
- Add  state to WalletContext — true for Freighter (always ready
  when connected), true for secret-key only when keypair is in memory
- WalletPage: show reconnect prompt when secret-key wallet is connected
  but not ready (keypair null after refresh), with public key displayed
  for reference and Reconnect/Disconnect buttons
- TopNav: show 'Reconnect Required' badge instead of full wallet UI
  when wallet is not ready
- Navbar: show Connect button instead of wallet chip when not ready
@vercel

vercel Bot commented Jul 31, 2026

Copy link
Copy Markdown

@water is attempting to deploy a commit to the Jaja's projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

[CRITICAL] Fix Wallet Keypair Loss on Page Refresh — Wallet Non-Functional After Reload

1 participant