|
| 1 | +# Wallet Customization Guide |
| 2 | + |
| 3 | +This guide shows how to use the new customizable wallet system in `@bitte-ai/react`. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The new system allows you to specify exactly which wallets you want to include by passing an array of wallet keywords to the `wallets` prop. This gives you full control over which wallets are available to your users. |
| 8 | + |
| 9 | +## Supported Wallet Types |
| 10 | + |
| 11 | +| Keyword | Wallet Name | Description | |
| 12 | +|---------|-------------|-------------| |
| 13 | +| `"bitte"` | Bitte Wallet | The Bitte AI wallet | |
| 14 | +| `"meteor"` | Meteor Wallet | Popular NEAR wallet | |
| 15 | +| `"here"` | HERE Wallet | Mobile-first NEAR wallet | |
| 16 | +| `"mynear"` | MyNearWallet | Official NEAR wallet | |
| 17 | +| `"intear"` | Intear Wallet | Intear wallet for NEAR | |
| 18 | +| `"okx"` | OKX Wallet | OKX exchange wallet for NEAR | |
| 19 | +| `"hot"` | HOT Wallet | HOT wallet for NEAR | |
| 20 | + |
| 21 | +## Basic Usage |
| 22 | + |
| 23 | +### New Customizable Approach |
| 24 | + |
| 25 | +```tsx |
| 26 | +import { BitteWalletContextProvider, SupportedWalletType } from "@bitte-ai/react"; |
| 27 | + |
| 28 | +function App() { |
| 29 | + // Only include Bitte, Intear, and OKX wallets |
| 30 | + const wallets: SupportedWalletType[] = ["bitte", "intear", "okx"]; |
| 31 | + |
| 32 | + return ( |
| 33 | + <BitteWalletContextProvider |
| 34 | + network="mainnet" |
| 35 | + wallets={wallets} |
| 36 | + > |
| 37 | + <YourAppContent /> |
| 38 | + </BitteWalletContextProvider> |
| 39 | + ); |
| 40 | +} |
| 41 | +``` |
| 42 | + |
| 43 | +### With Wallet-Specific Options |
| 44 | + |
| 45 | +```tsx |
| 46 | +import { |
| 47 | + BitteWalletContextProvider, |
| 48 | + SupportedWalletType, |
| 49 | + WalletSetupOptions |
| 50 | +} from "@bitte-ai/react"; |
| 51 | + |
| 52 | +function App() { |
| 53 | + const wallets: SupportedWalletType[] = ["bitte", "meteor", "intear", "okx", "hot"]; |
| 54 | + |
| 55 | + const walletOptions = { |
| 56 | + bitte: { |
| 57 | + walletUrl: "https://custom-wallet.bitte.ai" |
| 58 | + }, |
| 59 | + // Other wallets will use their default options |
| 60 | + }; |
| 61 | + |
| 62 | + return ( |
| 63 | + <BitteWalletContextProvider |
| 64 | + network="mainnet" |
| 65 | + wallets={wallets} |
| 66 | + walletOptions={walletOptions} |
| 67 | + > |
| 68 | + <YourAppContent /> |
| 69 | + </BitteWalletContextProvider> |
| 70 | + ); |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +## Common Use Cases |
| 75 | + |
| 76 | +### Only Bitte Wallet |
| 77 | +```tsx |
| 78 | +<BitteWalletContextProvider |
| 79 | + network="mainnet" |
| 80 | + wallets={["bitte"]} |
| 81 | +> |
| 82 | + <YourApp /> |
| 83 | +</BitteWalletContextProvider> |
| 84 | +``` |
| 85 | + |
| 86 | +### All Available Wallets |
| 87 | +```tsx |
| 88 | +<BitteWalletContextProvider |
| 89 | + network="mainnet" |
| 90 | + wallets={["bitte", "meteor", "here", "mynear", "intear", "okx", "hot"]} |
| 91 | +> |
| 92 | + <YourApp /> |
| 93 | +</BitteWalletContextProvider> |
| 94 | +``` |
| 95 | + |
| 96 | +### Mobile-Focused Setup |
| 97 | +```tsx |
| 98 | +<BitteWalletContextProvider |
| 99 | + network="mainnet" |
| 100 | + wallets={["here", "meteor", "bitte", "hot"]} |
| 101 | +> |
| 102 | + <YourApp /> |
| 103 | +</BitteWalletContextProvider> |
| 104 | +``` |
| 105 | + |
| 106 | +### DeFi/Trading Apps |
| 107 | +```tsx |
| 108 | +<BitteWalletContextProvider |
| 109 | + network="mainnet" |
| 110 | + wallets={["meteor", "mynear", "bitte", "okx"]} |
| 111 | +> |
| 112 | + <YourApp /> |
| 113 | +</BitteWalletContextProvider> |
| 114 | +``` |
| 115 | + |
| 116 | +### Exchange-Focused Setup |
| 117 | +```tsx |
| 118 | +<BitteWalletContextProvider |
| 119 | + network="mainnet" |
| 120 | + wallets={["okx", "meteor", "bitte"]} |
| 121 | +> |
| 122 | + <YourApp /> |
| 123 | +</BitteWalletContextProvider> |
| 124 | +``` |
| 125 | + |
| 126 | +## Backward Compatibility |
| 127 | + |
| 128 | +The package still supports the legacy props for backward compatibility: |
| 129 | + |
| 130 | +```tsx |
| 131 | +// Legacy approach (still works) |
| 132 | +<BitteWalletContextProvider |
| 133 | + network="mainnet" |
| 134 | + onlyBitteWallet={true} |
| 135 | + walletUrl="https://wallet.bitte.ai" |
| 136 | +> |
| 137 | + <YourApp /> |
| 138 | +</BitteWalletContextProvider> |
| 139 | +``` |
| 140 | + |
| 141 | +However, we recommend migrating to the new `wallets` prop: |
| 142 | + |
| 143 | +```tsx |
| 144 | +// New approach (recommended) |
| 145 | +<BitteWalletContextProvider |
| 146 | + network="mainnet" |
| 147 | + wallets={["bitte"]} |
| 148 | + walletOptions={{ |
| 149 | + bitte: { walletUrl: "https://wallet.bitte.ai" } |
| 150 | + }} |
| 151 | +> |
| 152 | + <YourApp /> |
| 153 | +</BitteWalletContextProvider> |
| 154 | +``` |
| 155 | + |
| 156 | +## Migration Guide |
| 157 | + |
| 158 | +### From `onlyBitteWallet={true}` |
| 159 | +```tsx |
| 160 | +// Old |
| 161 | +<BitteWalletContextProvider onlyBitteWallet={true} /> |
| 162 | + |
| 163 | +// New |
| 164 | +<BitteWalletContextProvider wallets={["bitte"]} /> |
| 165 | +``` |
| 166 | + |
| 167 | +### From Default (All Wallets) |
| 168 | +```tsx |
| 169 | +// Old |
| 170 | +<BitteWalletContextProvider network="mainnet" /> |
| 171 | + |
| 172 | +// New - specify exactly which wallets you want |
| 173 | +<BitteWalletContextProvider |
| 174 | + network="mainnet" |
| 175 | + wallets={["meteor", "mynear", "here", "intear", "okx", "hot"]} |
| 176 | +/> |
| 177 | +``` |
| 178 | + |
| 179 | +### With Additional Wallets |
| 180 | +```tsx |
| 181 | +// Old |
| 182 | +<BitteWalletContextProvider |
| 183 | + additionalWallets={[customWallet()]} |
| 184 | +/> |
| 185 | + |
| 186 | +// New - use the wallets prop and include custom wallets separately if needed |
| 187 | +<BitteWalletContextProvider |
| 188 | + wallets={["bitte", "meteor", "okx"]} |
| 189 | + additionalWallets={[customWallet()]} // Still supported |
| 190 | +/> |
| 191 | +``` |
| 192 | + |
| 193 | +## Error Handling |
| 194 | + |
| 195 | +The system will throw an error if you specify an unsupported wallet type: |
| 196 | + |
| 197 | +```tsx |
| 198 | +// This will throw an error |
| 199 | +<BitteWalletContextProvider |
| 200 | + wallets={["bitte", "unsupported-wallet"]} // ❌ Error! |
| 201 | +/> |
| 202 | +``` |
| 203 | + |
| 204 | +## TypeScript Support |
| 205 | + |
| 206 | +The package provides full TypeScript support with autocomplete for wallet types: |
| 207 | + |
| 208 | +```tsx |
| 209 | +import { SupportedWalletType } from "@bitte-ai/react"; |
| 210 | + |
| 211 | +const wallets: SupportedWalletType[] = ["bitte", "intear", "okx", "hot"]; // ✅ Autocomplete works |
| 212 | +``` |
| 213 | + |
| 214 | +## Performance Considerations |
| 215 | + |
| 216 | +- Only the wallets you specify will be loaded, reducing bundle size |
| 217 | +- Each wallet adds approximately 50-150kb to your bundle |
| 218 | +- Choose only the wallets your users actually need |
| 219 | + |
| 220 | +## Testing |
| 221 | + |
| 222 | +You can easily test different wallet configurations: |
| 223 | + |
| 224 | +```tsx |
| 225 | +// Test with single wallet |
| 226 | +const testWallets = process.env.NODE_ENV === 'test' |
| 227 | + ? ["bitte"] |
| 228 | + : ["bitte", "meteor", "intear", "okx", "hot"]; |
| 229 | + |
| 230 | +<BitteWalletContextProvider wallets={testWallets} /> |
| 231 | +``` |
0 commit comments