Skip to content

feat: implement multi-wallet support - #261

Open
Samaro1 wants to merge 1 commit into
Afro-Pay:mainfrom
Samaro1:feature/multi-wallet-support
Open

feat: implement multi-wallet support#261
Samaro1 wants to merge 1 commit into
Afro-Pay:mainfrom
Samaro1:feature/multi-wallet-support

Conversation

@Samaro1

@Samaro1 Samaro1 commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

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)

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

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

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

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.

Multi-wallet support: allow users to create and switch between named Stellar accounts in the dashboard

1 participant