This document describes the dedicated Freighter wallet connection modal implemented for TradeFlow-Web as part of the wallet connection enhancement.
-
Modal opens when user clicks "Connect Wallet" button
- The modal is triggered from the main page header button
- Uses proper state management with
isModalOpenstate
-
Freighter browser extension detection
- Automatically detects if Freighter is installed using
window.freighterobject - Shows loading state while checking for installation
- TypeScript declarations added in
src/types/freighter.d.ts
- Automatically detects if Freighter is installed using
-
Clear UI state when Freighter is NOT installed
- Shows amber warning banner when Freighter is not detected
- Provides direct download link to official Freighter extension
- Includes educational information about Freighter wallet
- External link indicator for better UX
-
Successful connection handling
- Retrieves user's Stellar public key using existing Web3 store
- Stores public key in global state via
useWalletConnectionhook - Shows success toast notification upon connection
-
UI updates for authenticated state
- Header button displays truncated public key format:
GABC...XYZ1 - Button shows "Connecting..." during connection process
- Pulse animation removed when wallet is connected
- Button disabled during connection to prevent multiple clicks
- Header button displays truncated public key format:
FreighterConnectModal.tsx: Main modal component with wallet detectionpage.tsx: Updated to use new modal and Web3 store integrationfreighter.d.ts: TypeScript declarations for Freighter API
- Uses existing
useWeb3Storefor wallet connection state - Integrates with
useWalletConnectionhook for clean separation - Proper loading and error state handling
- Loading spinner during wallet detection
- Clear success/error states with appropriate colors
- Responsive design with proper mobile support
- Smooth transitions and micro-interactions
- Accessible modal with proper close functionality
- Click "Connect Wallet" button in header
- If Freighter is not installed, click "Download Freighter Extension"
- Install and refresh the page
- Click "Connect Wallet" again
- Approve connection in Freighter extension
- Wallet address will appear in header button
import FreighterConnectModal from '../components/FreighterConnectModal';
const [isModalOpen, setIsModalOpen] = useState(false);
<FreighterConnectModal isOpen={isModalOpen} onClose={() => setIsModalOpen(false)} />;- Modal opens and closes properly
- Freighter detection works (with/without extension)
- Download link opens in new tab
- Connection flow integrates with Web3 store
- Header button shows correct states
- Error handling displays properly
- TypeScript compilation without errors
- Responsive design on mobile devices
- React hooks (
useState,useEffect) - Lucide React icons
- React Hot Toast for notifications
- Existing Web3 store infrastructure
- Tailwind CSS for styling
- Support for additional wallet types
- Connection persistence across sessions
- Network switching capabilities
- Advanced transaction signing flows