fare-privy-core 1.7.9 β†’ 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +182 -485
  2. package/dist/index.d.ts +8 -2
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +9 -2
  5. package/dist/index.js.map +1 -1
  6. package/dist/src/components/WalletOverview.d.ts +1 -3
  7. package/dist/src/components/WalletOverview.d.ts.map +1 -1
  8. package/dist/src/components/WalletOverview.js +2 -2
  9. package/dist/src/components/WalletOverview.js.map +1 -1
  10. package/dist/src/components/shared/Modal/Card.d.ts.map +1 -1
  11. package/dist/src/components/shared/Modal/Card.js +2 -2
  12. package/dist/src/components/shared/Modal/Card.js.map +1 -1
  13. package/dist/src/components/shared/Modal/types.d.ts +3 -3
  14. package/dist/src/components/shared/Modal/types.d.ts.map +1 -1
  15. package/dist/src/modals/FundWalletModal/CardCarousel.d.ts +21 -0
  16. package/dist/src/modals/FundWalletModal/CardCarousel.d.ts.map +1 -0
  17. package/dist/src/modals/FundWalletModal/CardCarousel.js +17 -0
  18. package/dist/src/modals/FundWalletModal/CardCarousel.js.map +1 -0
  19. package/dist/src/modals/FundWalletModal/DescriptionDetails.d.ts +4 -0
  20. package/dist/src/modals/FundWalletModal/DescriptionDetails.d.ts.map +1 -0
  21. package/dist/src/modals/FundWalletModal/DescriptionDetails.js +16 -0
  22. package/dist/src/modals/FundWalletModal/DescriptionDetails.js.map +1 -0
  23. package/dist/src/modals/FundWalletModal/FundWalletMenu.d.ts +11 -0
  24. package/dist/src/modals/FundWalletModal/FundWalletMenu.d.ts.map +1 -0
  25. package/dist/src/modals/FundWalletModal/FundWalletMenu.js +26 -0
  26. package/dist/src/modals/FundWalletModal/FundWalletMenu.js.map +1 -0
  27. package/dist/src/modals/FundWalletModal/FundWalletModalState.d.ts +5 -0
  28. package/dist/src/modals/FundWalletModal/FundWalletModalState.d.ts.map +1 -0
  29. package/dist/src/modals/FundWalletModal/FundWalletModalState.js +6 -0
  30. package/dist/src/modals/FundWalletModal/FundWalletModalState.js.map +1 -0
  31. package/dist/src/modals/FundWalletModal/FundsAccordion.d.ts +19 -0
  32. package/dist/src/modals/FundWalletModal/FundsAccordion.d.ts.map +1 -0
  33. package/dist/src/modals/FundWalletModal/FundsAccordion.js +23 -0
  34. package/dist/src/modals/FundWalletModal/FundsAccordion.js.map +1 -0
  35. package/dist/src/modals/FundWalletModal/TransferFunds.d.ts +13 -0
  36. package/dist/src/modals/FundWalletModal/TransferFunds.d.ts.map +1 -0
  37. package/dist/src/modals/FundWalletModal/TransferFunds.js +21 -0
  38. package/dist/src/modals/FundWalletModal/TransferFunds.js.map +1 -0
  39. package/dist/src/modals/FundWalletModal/index.d.ts +2 -0
  40. package/dist/src/modals/FundWalletModal/index.d.ts.map +1 -0
  41. package/dist/src/modals/FundWalletModal/index.js +30 -0
  42. package/dist/src/modals/FundWalletModal/index.js.map +1 -0
  43. package/dist/src/modals/styles.d.ts +2980 -0
  44. package/dist/src/modals/styles.d.ts.map +1 -0
  45. package/dist/src/modals/styles.js +248 -0
  46. package/dist/src/modals/styles.js.map +1 -0
  47. package/package.json +115 -114
package/README.md CHANGED
@@ -1,567 +1,264 @@
1
- @zynkah/privy-lib
1
+ # FarePrivy Authentication & Wallet Management System
2
2
 
3
- A lightweight React library for wallet selection and wallet overview UI components. Designed for easy integration, full portability, and consumer-provided icons and styles. Includes:
4
-
5
- - **SelectWalletModal**: Animated, responsive modal for selecting and linking wallets.
6
- - **WalletOverview**: Displays the active wallet’s name and icon.
7
- - **No asset or config imports**: Consumers provide their own icons and wallet data.
8
- - **Styled with [styled-components](https://styled-components.com/)**
3
+ FarePrivy is a robust, scalable React library for authentication, wallet management, and casino-specific integrations, built around Privy Auth with advanced configuration, smart wallet, and USDC Vault support.
9
4
 
10
5
  ---
11
6
 
12
- ## πŸš€ Installation
7
+ ## πŸ“¦ Installation
13
8
 
14
9
  ```bash
15
-
16
- ### SelectWalletModal
17
-
18
- ```tsx
19
- import { SelectWalletModal } from "@zynkah/privy-lib";
20
-
21
- <SelectWalletModal
22
- isOpen={isWalletModalOpen}
23
- onClose={() => setWalletModalOpen(false)}
24
- wallets={wallets} // Array of wallet objects
25
- appWalletClientType={appWalletClientType}
26
- setAppWalletClientType={setAppWalletClientType}
27
- linkWalletToUser={linkWalletToUser}
28
- embeddedWalletLinks={embeddedWalletLinks}
29
- icons={{
30
- dragBar: "/icons/drag-bar.svg",
31
- privyIcon: "/icons/privy.svg",
32
- caretDown: "/icons/caret-down.svg",
33
- linkWallet: "/icons/link-wallet.svg",
34
- }}
35
- isMobileScreen={isMobileScreen}
36
- />
10
+ npm install fare-privy-core @privy-io/react-auth styled-components@^5.3.0 valtio@^1.12.0
11
+ # or
12
+ pnpm add fare-privy-core @privy-io/react-auth styled-components@^5.3.0 valtio@^1.12.0
37
13
  ```
38
14
 
39
- ### WalletOverview
40
-
41
- ```tsx
42
- import { WalletOverview } from "@zynkah/privy-lib";
43
-
44
- <WalletOverview
45
- activeWallet={{
46
- meta: { name: "Privy Wallet", icon: "/icons/privy.svg" }
47
- }}
48
- onClick={() => setWalletModalOpen(true)}
49
- fallbackIcon="/icons/default-wallet.svg"
50
- isTabletScreen={false}
51
- isMobileScreen={true}
52
- />
53
- ```
15
+ **Important:**
16
+ - Use `styled-components` v5.x (not v6.x)
17
+ - Use `valtio` v1.x (not v2.x)
54
18
 
55
19
  ---
56
20
 
57
- ## πŸ“ Props
58
-
59
- ### SelectWalletModal
60
-
61
- | Prop | Type | Description |
62
- |-----------------------|----------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
63
- | `isOpen` | `boolean` | Controls modal visibility. |
64
- | `onClose` | `() => void` | Function to close the modal. |
65
- | `wallets` | `Array<{ address, meta, walletClientType, linked }>` | List of wallet objects to display. |
66
- | `appWalletClientType` | `string` | The currently selected wallet client type. |
67
- | `setAppWalletClientType` | `(type: string) => void` | Function to set the selected wallet client type. |
68
- | `linkWalletToUser` | `() => Promise<void>` | Function to link a new wallet to the user. |
69
- | `embeddedWalletLinks` | `Array<{ type, address?, number? }>` | (Optional) List of embedded wallet links for the privy wallet. |
70
- | `icons` | `{ dragBar, privyIcon, caretDown, linkWallet: string }` | Object containing icon URLs or paths for modal UI. |
71
- | `isMobileScreen` | `boolean` | (Optional) If true, enables mobile-specific modal behavior and layout. |
21
+ ## πŸ—οΈ Folder Structure (Key Modules)
72
22
 
73
- ### WalletOverview
74
-
75
- | Prop | Type | Description |
76
- |-----------------|---------------------------------------|------------------------------------------------------------------|
77
- | `activeWallet` | `{ meta: { name: string, icon?: string } }` | The wallet object with metadata including name and optional icon URL. |
78
- | `onClick` | `() => void` | Optional click handler for the component. |
79
- | `fallbackIcon` | `string` | Optional fallback icon URL if `activeWallet.meta.icon` is not provided. |
80
- | `isTabletScreen`| `boolean` | Optional. If true, hides the wallet name on tablet screens. |
81
- | `isMobileScreen`| `boolean` | Optional. If true, shows the wallet name on mobile screens. |
82
-
83
- ---
84
-
85
- ## 🎨 Styling & Customization
86
-
87
- - Uses `styled-components` for all styles.
88
- - Consumers can override styles via a theme or by extending the styled components.
89
- - No direct asset imports; all icons are provided by the consumer.
90
-
91
- ---
92
-
93
- ## πŸ“‹ License
94
-
95
- MIT
96
-
97
- ---
98
-
99
- ## 🀝 Contributing
100
-
101
- Pull requests and issues are welcome!
102
- =======
103
- npm install fare-privy-core
104
- # or
105
- pnpm add fare-privy-core
23
+ ```
24
+ src/
25
+ β”œβ”€β”€ components/
26
+ β”‚ β”œβ”€β”€ SelectWalletModal.tsx
27
+ β”‚ └── WalletOverview.tsx
28
+ β”œβ”€β”€ config/
29
+ β”‚ β”œβ”€β”€ privy.config.ts
30
+ β”‚ β”œβ”€β”€ ConfigBuilder.ts
31
+ β”‚ β”œβ”€β”€ constants.ts
32
+ β”‚ β”œβ”€β”€ ConfigManager.ts
33
+ β”‚ └── usage-examples.ts
34
+ β”œβ”€β”€ hooks/
35
+ β”‚ β”œβ”€β”€ useActiveWallet.ts
36
+ β”‚ β”œβ”€β”€ useAuthActions.ts
37
+ β”‚ β”œβ”€β”€ useConnectedWallets.ts
38
+ β”‚ β”œβ”€β”€ useIsAuthenticated.ts
39
+ β”‚ β”œβ”€β”€ useWalletAddresses.ts
40
+ β”‚ β”œβ”€β”€ useWalletBalance.ts
41
+ β”‚ └── common/
42
+ β”œβ”€β”€ lib/
43
+ β”‚ └── casino-auth/
44
+ β”‚ β”œβ”€β”€ CasinoAuthProvider.tsx
45
+ β”‚ β”œβ”€β”€ config-factory.ts
46
+ β”‚ β”œβ”€β”€ ExtendedConfigBuilder.ts
47
+ β”‚ └── hooks/
48
+ β”œβ”€β”€ modals/
49
+ β”œβ”€β”€ store/
50
+ β”œβ”€β”€ styles/
51
+ └── utility/
106
52
  ```
107
53
 
108
- ### ⚠️ Important Dependency Requirements
109
-
110
- This package requires specific version ranges to avoid breaking changes:
111
-
112
- - **@privy-io/react-auth**: `^1.0.0` - Core Privy authentication
113
- - **styled-components**: Must use v5.x (not v6.x) - `npm install styled-components@^5.3.0`
114
- - **valtio**: Must use v1.x (not v2.x) - `npm install valtio@^1.12.0`
54
+ ---
115
55
 
116
- ```bash
117
- # Install all compatible versions
118
- npm install fare-privy-core @privy-io/react-auth styled-components@^5.3.0 valtio@^1.12.0
119
- ```
56
+ ## πŸš€ Quick Start
120
57
 
121
- ## πŸ’» Quick Start
122
58
 
123
59
  ### Basic Casino Setup
124
60
 
61
+ // Example biconomyConfig definition (see Advanced Configuration for more details)
62
+ const biconomyConfig = {
63
+ chainId: 42161, // required, e.g. Arbitrum One
64
+ bundlerUrl: 'https://bundler.biconomy.io/api/v2/42161/abc...', // required
65
+ paymasterUrl: 'https://paymaster.biconomy.io/api/v1/42161/xyz...', // required
66
+ // Optional fields:
67
+ entryPointAddress: '0x...', // optional, default provided by SDK
68
+ // ...add any other supported Biconomy config keys
69
+ };
70
+
125
71
  ```tsx
126
- import {
127
- PrivyProvider,
128
- useActiveWallet,
129
- useConnectedWallets,
130
- useIsAuthenticated,
131
- useWalletBalance
132
- } from 'fare-privy-core';
72
+ import { PrivyProvider } from 'fare-privy-core';
133
73
 
134
74
  function App() {
135
75
  return (
136
- <PrivyProvider
137
- appId="your-privy-app-id"
138
- config={{
139
- walletChainType: 'solana-only' // or 'ethereum-only' or 'ethereum-and-solana'
140
- }}
141
- theme={{
142
- accentColor: "#0066ff",
143
- darkMode: true
144
- }}
145
- >
76
+ <PrivyProvider appId="your-privy-app-id" smartWalletConfig={biconomyConfig}>
146
77
  <YourCasinoApp />
147
78
  </PrivyProvider>
148
79
  );
149
80
  }
150
81
  ```
82
+ // For more details on biconomyConfig, see the Advanced Configuration section below.
151
83
 
152
84
  ### With Custom Branding
153
85
 
154
86
  ```tsx
155
- import { PrivyProvider } from 'fare-privy-core';
156
-
157
- function MyCasino() {
158
- return (
159
- <PrivyProvider
160
- appId="your-privy-app-id"
161
- theme={{
162
- accentColor: "#ff6b35", // Your casino color
163
- logo: "/your-casino-logo.png",
164
- darkMode: true
165
- }}
166
- config={{
167
- loginMethods: ['email', 'wallet', 'google'],
168
- appearance: {
169
- showWalletLoginFirst: true,
170
- }
171
- }}
172
- >
173
- <CasinoGames />
174
- </PrivyProvider>
175
- );
176
- }
177
- ```
178
-
179
- ### With Smart Wallets (for sponsored transactions)
180
-
181
- ```tsx
182
- import { PrivyProvider } from 'fare-privy-core';
183
-
184
- // Your Biconomy or other smart wallet config
185
- const biconomyConfig = {
186
- // Your smart wallet configuration here
187
- // Same structure as your original biconomyPrivyConfig
188
- };
189
-
190
- function AdvancedCasino() {
191
- return (
192
- <PrivyProvider
193
- appId="your-privy-app-id"
194
- smartWalletConfig={biconomyConfig} // Pass as 'config' prop
195
- theme={{
196
- accentColor: "#00d4ff"
197
- }}
198
- >
199
- <CasinoWithGaslessTransactions />
200
- </PrivyProvider>
201
- );
202
- }
203
- ```
204
-
205
- ### With Environment-Specific Config
206
-
207
- ```tsx
208
- import { PrivyProvider } from 'fare-privy-core';
209
-
210
- function ProductionCasino() {
211
- return (
212
- <PrivyProvider
213
- appId="your-privy-app-id"
214
- environment="production" // 'production' | 'staging' | 'development'
215
- config={{
216
- loginMethods: ['email', 'wallet'],
217
- // Your full Privy config
218
- }}
219
- >
220
- <CasinoApp />
221
- </PrivyProvider>
222
- );
223
- }
87
+ <PrivyProvider
88
+ appId="your-privy-app-id"
89
+ theme={{ accentColor: '#ff6b35', logo: '/logo.png', darkMode: true }}
90
+ config={{ loginMethods: ['email', 'wallet', 'google'] }}
91
+ >
92
+ <CasinoGames />
93
+ </PrivyProvider>
224
94
  ```
225
95
 
226
- ### Solana Casino Example
96
+ ### With Smart Wallets
227
97
 
228
98
  ```tsx
229
- import { PrivyProvider } from 'fare-privy-core';
230
-
231
- function SolanaCasino() {
232
- return (
233
- <PrivyProvider
234
- appId="your-privy-app-id"
235
- config={{
236
- loginMethods: ['wallet', 'email'],
237
- // Privy automatically detects and supports Solana wallets
238
- // like Phantom, Solflare, Backpack, etc.
239
- appearance: {
240
- walletChainType: 'solana-only', // Show only Solana wallets
241
- showWalletLoginFirst: true,
242
- },
243
- }}
244
- theme={{
245
- accentColor: "#14F195", // Solana green
246
- darkMode: true
247
- }}
248
- >
249
- <YourSolanaGames />
250
- </PrivyProvider>
251
- );
252
- }
99
+ <PrivyProvider
100
+ appId="your-privy-app-id"
101
+ smartWalletConfig={biconomyConfig}
102
+ >
103
+ <CasinoWithGaslessTransactions />
104
+ </PrivyProvider>
253
105
  ```
254
106
 
255
- ### Multi-Chain Support (Ethereum + Solana)
107
+ ### Multi-Chain Support
256
108
 
257
109
  ```tsx
258
- import { PrivyProvider } from 'fare-privy-core';
259
-
260
- function MultiChainCasino() {
261
- return (
262
- <PrivyProvider
263
- appId="your-privy-app-id"
264
- config={{
265
- loginMethods: ['wallet', 'email'],
266
- appearance: {
267
- walletChainType: 'ethereum-and-solana', // Support both chains
268
- },
269
- // Users can connect both Ethereum and Solana wallets
270
- }}
271
- >
272
- <CrossChainCasino />
273
- </PrivyProvider>
274
- );
275
- }
110
+ <PrivyProvider
111
+ appId="your-privy-app-id"
112
+ config={{ appearance: { walletChainType: 'ethereum-and-solana' } }}
113
+ >
114
+ <CrossChainCasino />
115
+ </PrivyProvider>
276
116
  ```
277
117
 
278
- ## πŸͺ Using Wallet Hooks
279
-
280
- Six focused **micro hooks** with proven patterns - import only what you need for optimal bundle sizes:
281
-
282
- ### `useAuthActions()` - Login & Logout Control
118
+ ---
283
119
 
284
- ```tsx
285
- import { useAuthActions } from 'fare-privy-core';
120
+ ## 🧩 UI Components
286
121
 
287
- function CasinoEntry() {
288
- const { login, logout, isAuthenticated, isReady } = useAuthActions();
122
+ ### SelectWalletModal
289
123
 
290
- if (!isAuthenticated) {
291
- return <button onClick={login}>🎰 Enter Casino</button>;
292
- }
124
+ Animated, responsive modal for selecting and linking wallets. You provide wallet data and icons.
293
125
 
294
- return (
295
- <div>
296
- <span>Welcome to the Casino!</span>
297
- <button onClick={logout}>Exit</button>
298
- </div>
299
- );
300
- }
301
- ```
126
+ **Props:**
302
127
 
303
- ### `useConnectedWallets()` - Get all wallet info
128
+ | Prop | Type | Description |
129
+ |-----------------------|----------------------------------------------------------------------|---------------------------------------------------------------------------------------------|
130
+ | `isOpen` | `boolean` | Controls modal visibility. |
131
+ | `onClose` | `() => void` | Function to close the modal. |
132
+ | `wallets` | `Array<{ address, meta, walletClientType, linked }>` | List of wallet objects to display. |
133
+ | `appWalletClientType` | `string` | The currently selected wallet client type. |
134
+ | `setAppWalletClientType` | `(type: string) => void` | Function to set the selected wallet client type. |
135
+ | `linkWalletToUser` | `() => Promise<void>` | Function to link a new wallet to the user. |
136
+ | `embeddedWalletLinks` | `Array<{ type, address?, number? }>` | (Optional) List of embedded wallet links for the privy wallet. |
137
+ | `icons` | `{ dragBar, privyIcon, caretDown, linkWallet: string }` | Object containing icon URLs or paths for modal UI. |
138
+ | `isMobileScreen` | `boolean` | (Optional) If true, enables mobile-specific modal behavior and layout. |
304
139
 
305
- ```tsx
306
- import { useConnectedWallets } from 'fare-privy-core';
140
+ ### WalletOverview
307
141
 
308
- function WalletDisplay() {
309
- const {
310
- primaryWallet, // First connected wallet
311
- embeddedWallet, // Privy embedded wallet
312
- externalWallet, // MetaMask/Phantom etc.
313
- isAuthenticated, // true if user has wallet
314
- } = useConnectedWallets();
142
+ Displays the active wallet’s name and icon.
315
143
 
316
- return <div>Address: {primaryWallet?.address}</div>;
317
- }
318
- ```
144
+ **Props:**
319
145
 
320
- ### `useActiveWallet()` - Get active wallet (proven pattern)
146
+ | Prop | Type | Description |
147
+ |-----------------|---------------------------------------|------------------------------------------------------------------|
148
+ | `activeWallet` | `{ meta: { name: string, icon?: string } }` | The wallet object with metadata including name and optional icon URL. |
149
+ | `onClick` | `() => void` | Optional click handler for the component. |
150
+ | `fallbackIcon` | `string` | Optional fallback icon URL if `activeWallet.meta.icon` is not provided. |
321
151
 
322
- ```tsx
323
- import { useActiveWallet } from 'fare-privy-core';
324
-
325
- function CasinoGame() {
326
- const {
327
- activeWallet, // Current active wallet
328
- privyWallet, // Embedded Privy wallet
329
- externalWallet, // MetaMask/Phantom etc.
330
- walletAddress, // Active wallet address
331
- isWalletAuthed, // Boolean: has active wallet
332
- readyAndAuth // Boolean: ready and authenticated
333
- } = useActiveWallet();
334
-
335
- if (!isWalletAuthed) return <div>Connect wallet to play</div>;
336
- return <div>Playing with: {walletAddress}</div>;
337
- }
338
- ```
152
+ ---
339
153
 
340
- ### `useWalletAddresses()` - Get addresses by chain
154
+ ### FundWalletModal
341
155
 
342
- ```tsx
343
- import { useWalletAddresses } from 'fare-privy-core';
156
+ A ready-to-use modal for funding your wallet, with animated carousel and exchange/card options.
344
157
 
345
- function BalanceDisplay() {
346
- const {
347
- primarySolanaAddress,
348
- primaryEthereumAddress
349
- } = useWalletAddresses();
158
+ **Features:**
159
+ - Animated card carousel (`CardCarousel`)
160
+ - Transfer funds via exchange or card
161
+ - Uses `useWalletBalance` for live balances
162
+ - Minimal required props, npm-friendly defaults
350
163
 
351
- return (
352
- <div>
353
- {primarySolanaAddress && <SolBalance address={primarySolanaAddress} />}
354
- {primaryEthereumAddress && <EthBalance address={primaryEthereumAddress} />}
355
- </div>
356
- );
357
- }
358
- ```
164
+ **Usage:**
165
+ ---
359
166
 
360
- ### `useIsAuthenticated()` - Simple auth check
167
+ ## πŸͺ Hooks Overview
361
168
 
362
- ```tsx
363
- import { useIsAuthenticated } from 'fare-privy-core';
169
+ - `useAuthActions()` – Login/logout control
170
+ - `useConnectedWallets()` – All wallet info
171
+ - `useActiveWallet()` – Get active wallet
172
+ - `useWalletAddresses()` – Get addresses by chain
173
+ - `useIsAuthenticated()` – Simple auth check
174
+ - `useWalletBalance()` – Native currency balances
364
175
 
365
- function ProtectedGame() {
366
- const { isAuthenticated, user } = useIsAuthenticated();
176
+ See [HOOKS.md](./HOOKS.md) for full details and advanced usage.
367
177
 
368
- if (!isAuthenticated) return <LoginPrompt />;
369
- return <CasinoGame />;
370
- }
371
- ```
178
+ ---
372
179
 
373
- ### `useWalletBalance()` - Get native currency balances
180
+ ## πŸ› οΈ Advanced Configuration & Casino Features
374
181
 
375
- ```tsx
376
- import { useWalletBalance } from 'fare-privy-core';
182
+ - **ConfigBuilder & ExtendedConfigBuilder**: Fluent APIs for building complex, environment/device/region-specific configs
183
+ - **CasinoAuthProvider**: Modular provider for casino-specific authentication, USDC Vault, and advanced permissions
184
+ - **Smart Wallet Integration**: Biconomy and embedded wallet support, gas sponsorship, VRF, and trial management
185
+ - **Adaptability**: Device-responsive, user-tier, and region-specific configuration
186
+ - **State Management**: Valtio-powered wallet switching and modal state
187
+ - **Styling**: Fully themeable with `styled-components` and CSS variable overrides
377
188
 
378
- function WalletBalanceDisplay() {
379
- const {
380
- ethereumBalance,
381
- solanaBalance,
382
- loading,
383
- error,
384
- refreshBalances
385
- } = useWalletBalance();
189
+ ---
386
190
 
387
- if (loading) return <div>Loading balances...</div>;
388
- if (error) return <div>Error: {error}</div>;
389
191
 
390
- return (
391
- <div>
392
- <p>ETH Balance: {ethereumBalance || "0.00"} ETH</p>
393
- <p>SOL Balance: {solanaBalance || "0.00"} SOL</p>
394
- <button onClick={refreshBalances}>Refresh</button>
395
- </div>
396
- );
397
- }
398
- ```
192
+ ## πŸ“š Example: Enhanced Casino Auth with USDC Vault
399
193
 
400
- πŸ“– **[See complete hook documentation β†’](./HOOKS.md)**
401
-
402
- ## πŸ“ Changelog
403
-
404
- ### v1.7.6 (Latest) - Reliable Patterns & Simplified Balance
405
- - **🎯 Added**: useActiveWallet hook based on proven working casino patterns
406
- - **πŸ’° Simplified**: useWalletBalance rewritten with reliable single-wallet approach
407
- - **πŸ”§ Fixed**: Removed complex wallet filtering in favor of simple active wallet selection
408
- - **⚑ Improved**: Balance fetching now uses sequential approach instead of complex promises
409
- - **πŸ§ͺ Tested**: 3/4 test suites passing with reliable integration tests
410
- - **πŸ“– Enhanced**: Updated documentation with new useActiveWallet examples
411
-
412
- ### v1.7.4 - Micro Hooks Architecture
413
- - **πŸͺ Refactored**: Split monolithic useWallets hook into 5 focused micro hooks
414
- - **🌳 Tree Shaking**: Import only the hooks you need for smaller bundle sizes
415
- - **🧹 Maintainable**: Each hook has single responsibility and clear purpose
416
- - **πŸ“ Organized**: Proper hooks/index.ts structure for clean imports
417
- - **⚑ Performance**: Reduced coupling between hook functionalities
418
- - **πŸ”§ Developer Experience**: Easier testing and debugging of individual hooks
419
-
420
- ### v1.7.3 - Enhanced Balance with Privy Providers
421
- - **πŸ”— Enhanced**: useWalletBalance now uses Privy's native wallet providers instead of manual RPC calls
422
- - **⚑ Improved**: More reliable balance fetching with proper provider integration
423
- - **πŸ”§ Added**: createSolanaConnectors() and disableSolanaConnectors() helper functions
424
- - **πŸ› οΈ Fixed**: Solana connector TypeScript compatibility issues
425
- - **πŸ§ͺ Tested**: All functionality verified with improved architecture
426
- - **πŸ“– Documentation**: Updated with balance improvements and new helper functions
427
-
428
- ### v1.7.2
429
- - **πŸ› Fixed**: Solana connector configuration with proper TypeScript types
430
- - **πŸ”„ Added**: Helper functions for dynamic Solana connector management
431
- - **⚑ Improved**: Error handling for missing Solana wallet adapter packages
432
-
433
- ### v1.7.1
434
- - **πŸ’° Added**: useWalletBalance hook for native currency balance checking
435
- - **⛓️ Enhanced**: Support for ETH and SOL balance fetching
436
- - **⚑ Improved**: Real-time balance updates with loading states and error handling
437
- - **πŸ”„ Added**: Manual balance refresh functionality
438
- - **πŸ§ͺ Tested**: All 17 tests passing including new balance functionality
439
-
440
- ### v1.6.0
441
- - **πŸ—‚οΈ Optimized**: Removed unused files and dependencies
442
- - **🧹 Cleaned**: Streamlined codebase for better performance
443
- - **πŸ“¦ Smaller**: Reduced package bloat while maintaining all functionality
444
- - **βœ… Tested**: All 17 tests passing after cleanup
445
- - **πŸ”§ Fixed**: Resolved circular import issues in useWallets.ts
446
-
447
- ### v1.5.0
448
- - **πŸͺ Added**: useAuthActions hook for login/logout control
449
- - **πŸšͺ Enhanced**: Complete authentication management for casino apps
450
-
451
- ### v1.4.0
452
- - **🎰 Added**: Four dependency-free wallet hooks
453
- - **πŸ”— Enhanced**: Multi-chain support for Ethereum and Solana
454
-
455
- ## οΏ½πŸ“š API Reference
456
-
457
- ### PrivyProvider
458
-
459
- Main authentication provider for your casino application.
460
-
461
- **Required Props:**
462
- - `appId` (string): Your Privy application ID (get this from [Privy Dashboard](https://dashboard.privy.io))
463
- - `children` (ReactNode): Your casino application components
464
-
465
- **Optional Props:**
466
- - `clientId` (string): Privy client ID for enhanced security
467
- - `config` (PrivyClientConfig): Full Privy configuration object
468
- - `loginMethods`: Array of auth methods (e.g., `['email', 'wallet', 'google']`)
469
- - `appearance`: UI customization options
470
- - See [Privy docs](https://docs.privy.io/guide/react/configuration) for all options
471
- - `smartWalletConfig` (object): Smart wallet configuration object (e.g., your Biconomy config)
472
- - **Important**: Pass the complete config object, not spread props
473
- - Example: `smartWalletConfig={biconomyPrivyConfig}`
474
- - `disableSmartWallets` (boolean): Disable smart wallet integration (default: false)
475
- - `environment` ('production' | 'staging' | 'development'): Environment-specific config overrides
476
- - `theme` (object): Quick theme customization (merged with config.appearance)
477
- - `accentColor`: Primary color for your casino brand
478
- - `logo`: URL to your casino logo
479
- - `darkMode`: Enable/disable dark theme
480
-
481
- ### Wallet State Management
482
-
483
- Import and use the wallet switching state in your components:
194
+ // Legend: // required, // optional, // default: ...
195
+ // Note: casinoSlug and casinoEntity.id should match for consistency, but can differ if you support multiple brands. Required fields are marked, optional fields and defaults are noted. See docs for mutually exclusive options.
484
196
 
485
197
  ```tsx
486
- import { switchWalletState } from 'fare-privy-core';
487
- import { useSnapshot } from 'valtio';
198
+ import { CasinoAuthProvider } from 'fare-privy-core/lib/casino-auth';
488
199
 
489
- function MyWalletUI() {
490
- const snap = useSnapshot(switchWalletState);
491
-
200
+ function CustomCasino() {
492
201
  return (
493
- <div>
494
- <p>Modal Open: {snap.isWalletModalOpen ? 'Yes' : 'No'}</p>
495
- <p>Selected: {snap.selectedConnectorType}</p>
496
- <button onClick={() => switchWalletState.isWalletModalOpen = true}>
497
- Open Wallet Modal
498
- </button>
499
- </div>
202
+ <CasinoAuthProvider
203
+ casinoSlug="my-casino" // required, should match casinoEntity.id
204
+ customConfig={{
205
+ appearance: { // optional
206
+ accentColor: '#ff0000', // optional
207
+ logo: '/my-logo.png' // optional
208
+ },
209
+ blockchain: { // required
210
+ currency: 'USDC', // required
211
+ primaryChain: 'ARBITRUM', // required
212
+ smartWallet: { // optional
213
+ provider: 'biconomy', // required if smartWallet used
214
+ vaultConfig: { // required if using smartWallet
215
+ vaultAddress: '0x...', // required
216
+ fareAAAddress: '0x...', // required
217
+ usdcAddress: '0x...' // required
218
+ }
219
+ }
220
+ },
221
+ api: { // optional
222
+ contracts: {
223
+ vaultAddress: '0x...', // required if using vault features
224
+ vrfWrapperAddress: '0x...' // optional, required for VRF
225
+ }
226
+ }
227
+ }}
228
+ casinoEntity={{
229
+ id: 'my-casino', // required, should match casinoSlug
230
+ username: 'mycasino', // required
231
+ config: {
232
+ title: 'My Custom Casino', // required
233
+ colors: { // optional
234
+ themeColor1: '#ff0000', // optional
235
+ themeColor2: '#darkred' // optional
236
+ }
237
+ }
238
+ }}
239
+ >
240
+ <CasinoApp />
241
+ </CasinoAuthProvider>
500
242
  );
501
243
  }
502
244
  ```
503
245
 
504
- **State Properties:**
505
- - `isWalletModalOpen` (boolean): Controls wallet modal visibility
506
- - `selectedConnectorType` (string): Currently selected wallet connector type
507
-
508
- ## 🎯 Package Philosophy
509
-
510
- This package provides **core authentication and state management** without opinionated UI components. Perfect for casino operators who want to:
511
-
512
- - βœ… Quick integration of Privy auth into their casino
513
- - βœ… Customize branding and colors per casino
514
- - βœ… Build their own game UI that matches their design
515
- - βœ… Keep bundle size minimal
516
- - βœ… Maintain full control over user experience
517
- - βœ… Support multiple casinos from one codebase
518
-
519
- ## 🎰 For Casino Operators
520
-
521
- This library is designed for operators running multiple casinos on the same platform. Each casino can:
522
-
523
- 1. **Use their own Privy App ID** for isolated user bases
524
- 2. **Customize theme colors** to match their brand
525
- 3. **Configure login methods** based on their audience
526
- 4. **Add their own logo** and branding
527
- 5. **Build custom game UIs** using the wallet state management
528
- 6. **Support Ethereum, Solana, or both chains**
246
+ ---
529
247
 
530
- Example multi-casino setup:
248
+ ## 🎨 Styling & Theming
531
249
 
532
- ```tsx
533
- // Ethereum Casino
534
- <PrivyProvider
535
- appId="eth-casino-id"
536
- config={{ appearance: { walletChainType: 'ethereum-only' }}}
537
- theme={{ accentColor: "#627EEA" }}
538
- >
539
- <EthereumCasino />
540
- </PrivyProvider>
250
+ - Uses `styled-components` for all styles
251
+ - Theme via provider or CSS variables (see `styles/privy-theme-override.css`)
252
+ - No direct asset imports; all icons are provided by the consumer
541
253
 
542
- // Solana Casino
543
- <PrivyProvider
544
- appId="sol-casino-id"
545
- config={{ appearance: { walletChainType: 'solana-only' }}}
546
- theme={{ accentColor: "#14F195" }}
547
- >
548
- <SolanaCasino />
549
- </PrivyProvider>
254
+ ---
550
255
 
551
- // Multi-Chain Casino
552
- <PrivyProvider
553
- appId="multi-casino-id"
554
- config={{ appearance: { walletChainType: 'ethereum-and-solana' }}}
555
- >
556
- <MultiChainCasino />
557
- </PrivyProvider>
558
- ```
256
+ ## πŸ“„ License
559
257
 
560
- ## πŸ”„ What's Next
258
+ ISC License - see LICENSE file for details.
561
259
 
562
- Want more features? Open an issue or PR on [GitHub](https://github.com/farePrivy/fare-privy-core)!
260
+ ---
563
261
 
564
- ## πŸ“„ License
262
+ ## 🀝 Contributing
565
263
 
566
- ISC License - see LICENSE file for details.
567
- >>>>>>> fb7640de89ab4d90f33248c3264f6a50a43b4008
264
+ Pull requests and issues are welcome!