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