|
| 1 | +# Swig Wallet Migration Guide |
| 2 | + |
| 3 | +## Migration Timeline |
| 4 | + |
| 5 | +### Phase 1: Deprecation Warnings (Current) |
| 6 | +- `useSafeWallet` hook displays deprecation warnings in console |
| 7 | +- `WalletMultiButton` component shows deprecation warning |
| 8 | +- All functionality remains intact |
| 9 | +- **Timeline**: Current release |
| 10 | + |
| 11 | +### Phase 2: Migration Support (v1.5.0) |
| 12 | +- Add migration tool to scan codebase for deprecated usage |
| 13 | +- Provide automated migration scripts |
| 14 | +- Enhanced documentation and examples |
| 15 | +- **Timeline**: Next minor release |
| 16 | + |
| 17 | +### Phase 3: Removal (v2.0.0) |
| 18 | +- Remove deprecated aliases completely |
| 19 | +- Clean up legacy code paths |
| 20 | +- **Timeline**: Next major release |
| 21 | + |
| 22 | +## New Features & Improvements |
| 23 | + |
| 24 | +### Enhanced Error Handling System |
| 25 | +The new Swig wallet integration includes a categorized error handling system: |
| 26 | + |
| 27 | +#### Error Categories |
| 28 | +- **Critical Errors**: Authentication failures, API issues (persistent toasts) |
| 29 | +- **System Errors**: Network issues, connection problems (actionable toasts) |
| 30 | +- **Informational Errors**: Form validation, user input (inline or brief toasts) |
| 31 | +- **Success Messages**: Brief confirmation toasts |
| 32 | + |
| 33 | +#### Usage Examples |
| 34 | +```javascript |
| 35 | +const { toast } = useToast(); |
| 36 | + |
| 37 | +// Critical errors - persistent with retry actions |
| 38 | +toast.criticalError('Authentication failed', { |
| 39 | + action: <button onClick={retry}>Retry</button> |
| 40 | +}); |
| 41 | + |
| 42 | +// System errors - connection issues with fallbacks |
| 43 | +toast.systemError('Connection lost', { |
| 44 | + action: <button onClick={reconnect}>Reconnect</button> |
| 45 | +}); |
| 46 | + |
| 47 | +// Success messages - brief confirmations |
| 48 | +toast.success('Wallet connected successfully'); |
| 49 | +``` |
| 50 | + |
| 51 | +### Improved Reconnection Logic |
| 52 | +- **Exponential backoff with jitter** prevents thundering herd problems |
| 53 | +- **Comprehensive timeout cleanup** prevents memory leaks |
| 54 | +- **Progress tracking UI** shows reconnection attempts to users |
| 55 | +- **Cancellation support** allows users to stop reconnection |
| 56 | + |
| 57 | +### Enhanced Popup Handling |
| 58 | +- **Better popup blocker detection** including mobile browsers |
| 59 | +- **Fallback options** for blocked popups (same-tab navigation) |
| 60 | +- **Sequential popup management** reduces blocker issues |
| 61 | +- **User-friendly error messages** with actionable buttons |
| 62 | + |
| 63 | +### Accessibility Improvements |
| 64 | +- **Focus trapping** in modals for keyboard navigation |
| 65 | +- **ARIA labels** for screen readers |
| 66 | +- **Escape key support** for modal dismissal |
| 67 | +- **Proper focus restoration** after modal close |
| 68 | + |
| 69 | +## Migration Steps |
| 70 | + |
| 71 | +### 1. Update Hook Usage |
| 72 | + |
| 73 | +**Before (Deprecated):** |
| 74 | +```javascript |
| 75 | +import { useSafeWallet } from './contexts/SwigWalletProvider'; |
| 76 | + |
| 77 | +const MyComponent = () => { |
| 78 | + const wallet = useSafeWallet(); |
| 79 | + // ... |
| 80 | +}; |
| 81 | +``` |
| 82 | + |
| 83 | +**After (Recommended):** |
| 84 | +```javascript |
| 85 | +import { useSwigWallet } from './contexts/SwigWalletProvider'; |
| 86 | + |
| 87 | +const MyComponent = () => { |
| 88 | + const wallet = useSwigWallet(); |
| 89 | + // ... |
| 90 | +}; |
| 91 | +``` |
| 92 | + |
| 93 | +### 2. Update Component Usage |
| 94 | + |
| 95 | +**Before (Deprecated):** |
| 96 | +```javascript |
| 97 | +import { WalletMultiButton } from './components/SwigWalletButton'; |
| 98 | + |
| 99 | +const MyComponent = () => ( |
| 100 | + <WalletMultiButton /> |
| 101 | +); |
| 102 | +``` |
| 103 | + |
| 104 | +**After (Recommended):** |
| 105 | +```javascript |
| 106 | +import { SwigWalletButton } from './components/SwigWalletButton'; |
| 107 | + |
| 108 | +const MyComponent = () => ( |
| 109 | + <SwigWalletButton /> |
| 110 | +); |
| 111 | +``` |
| 112 | + |
| 113 | +### 3. Update Provider Usage |
| 114 | + |
| 115 | +**Before (Legacy):** |
| 116 | +```javascript |
| 117 | +import { SafeWalletProvider } from './contexts/SwigWalletProvider'; |
| 118 | +``` |
| 119 | + |
| 120 | +**After (Current):** |
| 121 | +```javascript |
| 122 | +import { SwigWalletProvider } from './contexts/SwigWalletProvider'; |
| 123 | +``` |
| 124 | + |
| 125 | +## Breaking Changes in v2.0.0 |
| 126 | + |
| 127 | +1. **Removed Exports:** |
| 128 | + - `useSafeWallet` hook |
| 129 | + - `WalletMultiButton` component alias |
| 130 | + - `SafeWalletProvider` component alias |
| 131 | + |
| 132 | +2. **Updated Interface:** |
| 133 | + - All wallet context properties now use consistent naming |
| 134 | + - Error handling moved to toast notifications by default |
| 135 | + |
| 136 | +## Migration Tool Usage |
| 137 | + |
| 138 | +Run the migration tool to automatically update your codebase: |
| 139 | + |
| 140 | +```bash |
| 141 | +npm run migrate-wallet-hooks |
| 142 | +``` |
| 143 | + |
| 144 | +This will: |
| 145 | +- Scan your codebase for deprecated usage |
| 146 | +- Automatically replace deprecated hooks and components |
| 147 | +- Generate a migration report |
| 148 | +- Backup original files |
| 149 | + |
| 150 | +## Need Help? |
| 151 | + |
| 152 | +- Check the updated documentation in `SWIG_WALLET_INTEGRATION.md` |
| 153 | +- Review the example implementations in the `/examples` folder |
| 154 | +- Create an issue if you encounter migration problems |
| 155 | + |
| 156 | +## Compatibility Promise |
| 157 | + |
| 158 | +We guarantee backward compatibility through v1.x releases. All deprecated features will continue to work with warnings until v2.0.0. |
0 commit comments