Skip to content

feat(wallet): implement real EVM wallet connection lifecycle (V2-FE-006) - #287

Open
abdullahilateefat03-boop wants to merge 3 commits into
DigiNodes:mainfrom
abdullahilateefat03-boop:feat/v2-fe-006-wallet-lifecycle
Open

feat(wallet): implement real EVM wallet connection lifecycle (V2-FE-006)#287
abdullahilateefat03-boop wants to merge 3 commits into
DigiNodes:mainfrom
abdullahilateefat03-boop:feat/v2-fe-006-wallet-lifecycle

Conversation

@abdullahilateefat03-boop

Copy link
Copy Markdown

closes #241

Summary

Implements V2-FE-006 — Real Wallet Connection Lifecycle for the
TruthBounty canonical Optimism/EVM runtime.

What changed

Replaced

  • hooks/useWallet.ts — mock balance hook replaced with canonical EVM
    lifecycle hook: connect, reconnect, disconnect, account-change detection,
    connector-error state, hydration guard, connector-id preference persistence
  • hooks/useAccount.ts — Stellar/Freighter implementation replaced with
    wagmi useAccount wrapper; hydration-safe (null before mount), exposes
    address, displayName, chainId
  • components/features/claim-submission/ClaimSubmissionForm.tsx — removed
    @stellar/freighter-api setAllowed(); replaced with wagmi useConnect /
    useConnectors

Deleted

  • lib/mock-wagmi.ts — removed; wagmi's built-in mock connector used in tests
  • lib/mock-wallet-provider.tsx — removed; no synthetic wallet state remains
  • lib/transaction-simulator.ts — removed; synthetic tx hashes are banned
    per spec; production paths use wagmi writeContract

Added

  • src/__tests__/integration/wallet-lifecycle.test.tsx — integration tests
    at the Wagmi boundary: connect, disconnect, account-change, reconnect,
    wrong-network, hydration safety, no synthetic state

Tests updated

  • hooks/tests/useWallet.test.tsx — lifecycle tests replacing mock balance tests
  • hooks/__tests__/useAccount.test.ts — EVM tests replacing Freighter mocks
  • ClaimSubmissionForm.wallet.test.tsx — wagmi connect mock replacing Freighter
  • ClaimSubmissionForm.modal.test.tsx — Freighter mock removed

Acceptance criteria evidence

Criterion Evidence
connect / reconnect / disconnect / account-change / connector-error useWallet.ts + wallet-lifecycle.test.tsx
Hydration-safe, no phantom connected state useIsMounted guard in useWallet + useAccount; hydration tests
Persist only minimal non-sensitive wallet preferences connector id only written to localStorage (no address/key)
No synthetic production transaction or protocol state transaction-simulator.ts deleted; mock-wagmi.ts deleted
No Stellar/Freighter runtime dependency in affected paths setAllowed() removed from ClaimSubmissionForm; Freighter mocks purged from tests
No visual redesign UI components untouched

Security notes

  • Only the connector id (e.g. "injected") is written to localStorage
  • No addresses, keys, balances, or hashes are persisted
  • On-chain reads remain routed through lib/contracts/registry.ts

Residual risks

  • @stellar/freighter-api and @stellar/stellar-sdk remain in package.json
    as transitive entries; they can be removed with pnpm remove once
    confirmed no other feature branch depends on them

@dDevAhmed

Copy link
Copy Markdown
Contributor

resolve conflicts @abdullahilateefat03-boop

- Resolved conflicts in useWallet.ts, useAccount.ts, and test files
- Kept HEAD version (feat branch) EVM/Wagmi implementation
- Resolved ClaimSubmissionForm.tsx to use wagmi connectors
- Removed deleted transaction-simulator.ts
- Fixed useAccount.test.ts extension to .tsx for JSX support
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.

V2-FE-006 — Implement Real Wallet Connection Lifecycle

2 participants