Skip to content

feat: centralize Zod validation layer and refactor Freighter wallet integration#144

Merged
SudiptaPaul-31 merged 1 commit into
Lumina-eX:mainfrom
patopatrish:fix/issues-101-125
Jun 30, 2026
Merged

feat: centralize Zod validation layer and refactor Freighter wallet integration#144
SudiptaPaul-31 merged 1 commit into
Lumina-eX:mainfrom
patopatrish:fix/issues-101-125

Conversation

@patopatrish

Copy link
Copy Markdown
Contributor

Summary

Resolves #101 and #125

  • Centralized Zod validation layer (lib/validations/index.ts) covering all four scopes: Project, Milestone (create + update), User (profile, auth inputs, roles), and Wallet (address regex, signature, transaction payload)
  • Milestone routes (POST /api/milestones, PATCH /api/milestones/[id]) updated to use CreateMilestoneSchema / UpdateMilestoneSchema with structured fieldErrors responses instead of manual ad-hoc checks
  • Reusable useFreighter hook added at lib/hooks/use-freighter.ts — re-exports useStellarWallet, helpers (truncateStellarAddress, networkLabel), and types from the wallet provider for consistent usage across the app
  • WalletConnect component refactored to consume the global StellarWalletProvider context via useFreighter instead of duplicating local state — eliminates the redundancy and adds wrong-network UI feedback inline

Issues Closed

Test plan

  • POST /api/milestones with missing/invalid fields returns 422 with fieldErrors
  • PATCH /api/milestones/:id with invalid amount (negative) returns 422
  • WalletConnect button shows "Connect Wallet", triggers Freighter popup, displays truncated address on success
  • Disconnecting wallet clears address from UI and localStorage
  • Connecting on wrong network (Mainnet) shows "Wrong network" inline warning
  • Importing useFreighter from lib/hooks/use-freighter resolves correctly

🤖 Generated with Claude Code

…tion

Resolves Lumina-eX#101 and Lumina-eX#125

- Add lib/validations/index.ts with centralized Zod schemas for
  Project, Milestone (create + update), User (profile, auth), and
  Wallet (address, signature, transaction) covering all backend routes
- Update POST /api/milestones and PATCH /api/milestones/[id] to use
  CreateMilestoneSchema / UpdateMilestoneSchema with structured field
  errors instead of manual ad-hoc checks
- Add lib/hooks/use-freighter.ts as a reusable hook re-exporting
  useStellarWallet, helpers, and types from the wallet provider
- Refactor WalletConnect component to consume the global
  StellarWalletProvider context via useFreighter instead of managing
  duplicate local state; adds wrong-network UI feedback

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

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

@SudiptaPaul-31 SudiptaPaul-31 merged commit 32a9f15 into Lumina-eX:main Jun 30, 2026
1 check passed
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.

[Feature]: Freighter Wallet Integration Backend Validation Layer with Zod

2 participants