Overview
TheTransactionHistory component provides a comprehensive view of user transactions, including swaps and transfers. It features expandable transaction cards, pagination support, real-time refresh, and detailed chain operation information.
Import
Props
The user’s wallet address. When not provided, the component displays a login prompt.
Features
Automatic Data Loading
The component automatically fetches transaction history when auserAddress is provided using the useTransactionHistory hook.
Transaction Cards
Each transaction displays:- Type badge: Swap or Transfer
- Status badge: COMPLETED, FAILED, PENDING, or REFUNDED
- Token amounts: With fiat values when available
- Timestamp: Formatted date and time
- Expandable details: Quote ID, chain operations, transaction hashes
Pagination
Supports infinite scrolling with a “Load More” button when additional transactions are available.State Management
- Loading state: Spinner during initial load
- Empty state: Helpful message when no transactions exist
- Error state: Alert banner for API failures
- Refresh: Manual refresh button with loading indicator
Usage Example
Transaction Types
Swap Transactions
Display both origin and destination tokens:Transfer Transactions
Show single token being transferred:Expandable Details
When a transaction card is clicked, it expands to show:- Quote ID
- Origin Chain
- Destination Chain
Status Indicators
COMPLETED
Green badge with checkmark icon
FAILED
Red badge with X icon
PENDING
Yellow badge with clock icon
REFUNDED
Orange badge with warning icon
Data Hook
The component usesuseTransactionHistory which provides:
Token Amount Formatting
The component intelligently formats token amounts:- Very small amounts (
< 0.000001): Exponential notation - Small amounts (
< 0.01): 6 decimal places - Medium amounts (
< 1): 4 decimal places - Standard amounts (
< 1000): 2 decimal places - Large amounts (
>= 1000): Abbreviated with K/M suffix
Responsive Design
The component adapts to different screen sizes:- Mobile: Stacked layout with smaller text
- Tablet/Desktop: Side-by-side layout with full details
- Touch-friendly: Expandable cards for easy interaction
Integration with Other Hooks
Styling
The component uses:Cardfor containers and individual transactionsBadgefor transaction type and statusButtonfor actions (refresh, load more)Alertfor error messagesCollapsiblefor expandable transaction details
Performance
- Lazy loading: Loads 10 transactions at a time by default
- Optimized rendering: Uses React keys for efficient updates
- State persistence: Maintains scroll position during pagination
Related Components
- TransactionStatus - Display active transaction status
- SwapForm - Create swap transactions
- TransferForm - Create transfer transactions
Notes
The component automatically refreshes when the
userAddress prop changes.