feat: implement multi-wallet support - #261
Open
Samaro1 wants to merge 1 commit into
Open
Conversation
- Remove unique constraint on Wallet.userId to allow multiple wallets per user - Add alias and isDefault fields to Wallet model - Create Prisma migration for schema changes - Implement multi-wallet CRUD operations in wallet.service.ts - createWallet: Create first wallet (marked as default) or additional wallets - getWallets: Retrieve all wallets for a user - getDefaultWallet: Get the active wallet - setDefaultWallet: Switch active wallet - updateWalletAlias: Edit wallet alias (max 32 chars) - deleteWallet: Remove wallet (prevent deletion of last wallet) - Add wallet limit enforcement (max 5 wallets per user) - Update wallet.controller.ts with new endpoints: - POST /wallet/create: Create first wallet - POST /wallet/add: Add additional wallet - GET /wallet/list: Get all wallets - GET /wallet/public-key: Get default wallet's public key - POST /wallet/:id/set-default: Switch active wallet - PUT /wallet/:id/alias: Update wallet alias - DELETE /wallet/:id: Delete wallet - Enhance walletStore.ts with multi-wallet state management - Track all wallets and active wallet ID - Add methods: fetchWallets, switchWallet, addWallet, removeWallet, updateWalletAlias - Update WalletSetup.tsx component for multi-wallet UI - Display list of existing wallets - Add form to create/add new wallets - Show wallet alias and public key - Ability to switch, edit, and delete wallets - Display active wallet's QR code and public key - Update Header.tsx to show wallet picker dropdown - Switch between wallets from the header - Show active wallet name/alias - Support wallet navigation for power users - Add comprehensive unit tests for multi-wallet CRUD operations - Maintain backward compatibility: existing single-wallet users retain their wallet as default
|
@Samaro1 is attempting to deploy a commit to the milah's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Closes #211
Overview
This PR enables Stellar power users to manage multiple wallets from a single AfroPay account, each with customizable aliases. Users can create up to 5 wallets, switch between them via a dashboard dropdown, and perform transactions on their active wallet.
Changes Summary
Backend
Prisma Schema & Migration: Removed @unique constraint on Wallet.userId, added optional alias field (max 32 chars) and isDefault boolean flag
Wallet Service: Enhanced with multi-wallet CRUD operations
createWallet() - First wallet auto-marked as default; subsequent wallets respect 5-wallet limit
getWallets() - Retrieve all user wallets
getDefaultWallet() - Get active wallet
setDefaultWallet() - Switch active wallet
updateWalletAlias() - Edit wallet alias
deleteWallet() - Delete wallet (prevents orphaning last wallet)
Wallet Controller: Added 7 new endpoints for multi-wallet operations
POST /wallet/create - Create first wallet
POST /wallet/add - Add additional wallets
GET /wallet/list - List all wallets
GET /wallet/public-key - Get active wallet's public key
POST /wallet/:id/set-default - Switch active wallet
PUT /wallet/:id/alias - Update alias
DELETE /wallet/:id - Delete wallet
Frontend
Wallet Store: Enhanced state management with wallet tracking, active wallet ID, and multi-wallet methods (fetchWallets, switchWallet, addWallet, removeWallet, updateWalletAlias)
WalletSetup Component: Complete redesign supporting wallet list, creation form, alias editing, and public key/QR display for active wallet
Header Component: Added dropdown wallet picker for seamless switching between wallets
Tests
Added comprehensive unit tests for multi-wallet CRUD operations covering edge cases (wallet limit, alias validation, deletion constraints)