fare-privy-core 1.8.0 β 1.8.2
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.
- package/README.md +182 -482
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/src/components/WalletOverview.js +1 -1
- package/dist/src/components/WalletOverview.js.map +1 -1
- package/dist/src/components/shared/Modal/Card.d.ts.map +1 -1
- package/dist/src/components/shared/Modal/Card.js +2 -2
- package/dist/src/components/shared/Modal/Card.js.map +1 -1
- package/dist/src/components/shared/Modal/types.d.ts +3 -3
- package/dist/src/components/shared/Modal/types.d.ts.map +1 -1
- package/dist/src/modals/FundWalletModal/CardCarousel.d.ts +21 -0
- package/dist/src/modals/FundWalletModal/CardCarousel.d.ts.map +1 -0
- package/dist/src/modals/FundWalletModal/CardCarousel.js +17 -0
- package/dist/src/modals/FundWalletModal/CardCarousel.js.map +1 -0
- package/dist/src/modals/FundWalletModal/DescriptionDetails.d.ts +4 -0
- package/dist/src/modals/FundWalletModal/DescriptionDetails.d.ts.map +1 -0
- package/dist/src/modals/FundWalletModal/DescriptionDetails.js +16 -0
- package/dist/src/modals/FundWalletModal/DescriptionDetails.js.map +1 -0
- package/dist/src/modals/FundWalletModal/FundWalletMenu.d.ts +11 -0
- package/dist/src/modals/FundWalletModal/FundWalletMenu.d.ts.map +1 -0
- package/dist/src/modals/FundWalletModal/FundWalletMenu.js +26 -0
- package/dist/src/modals/FundWalletModal/FundWalletMenu.js.map +1 -0
- package/dist/src/modals/FundWalletModal/FundWalletModalState.d.ts +5 -0
- package/dist/src/modals/FundWalletModal/FundWalletModalState.d.ts.map +1 -0
- package/dist/src/modals/FundWalletModal/FundWalletModalState.js +6 -0
- package/dist/src/modals/FundWalletModal/FundWalletModalState.js.map +1 -0
- package/dist/src/modals/FundWalletModal/FundsAccordion.d.ts +19 -0
- package/dist/src/modals/FundWalletModal/FundsAccordion.d.ts.map +1 -0
- package/dist/src/modals/FundWalletModal/FundsAccordion.js +23 -0
- package/dist/src/modals/FundWalletModal/FundsAccordion.js.map +1 -0
- package/dist/src/modals/FundWalletModal/TransferFunds.d.ts +13 -0
- package/dist/src/modals/FundWalletModal/TransferFunds.d.ts.map +1 -0
- package/dist/src/modals/FundWalletModal/TransferFunds.js +21 -0
- package/dist/src/modals/FundWalletModal/TransferFunds.js.map +1 -0
- package/dist/src/modals/FundWalletModal/index.d.ts +2 -0
- package/dist/src/modals/FundWalletModal/index.d.ts.map +1 -0
- package/dist/src/modals/FundWalletModal/index.js +30 -0
- package/dist/src/modals/FundWalletModal/index.js.map +1 -0
- package/dist/src/modals/styles.d.ts +2980 -0
- package/dist/src/modals/styles.d.ts.map +1 -0
- package/dist/src/modals/styles.js +248 -0
- package/dist/src/modals/styles.js.map +1 -0
- package/package.json +115 -114
package/README.md
CHANGED
|
@@ -1,564 +1,264 @@
|
|
|
1
|
-
|
|
1
|
+
# FarePrivy Authentication & Wallet Management System
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
7
|
+
## π¦ Installation
|
|
13
8
|
|
|
14
9
|
```bash
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
91
|
-
|
|
92
|
-
MIT
|
|
93
|
-
|
|
94
|
-
---
|
|
95
|
-
|
|
96
|
-
## π€ Contributing
|
|
21
|
+
## ποΈ Folder Structure (Key Modules)
|
|
97
22
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
54
|
+
---
|
|
106
55
|
|
|
107
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
###
|
|
96
|
+
### With Smart Wallets
|
|
224
97
|
|
|
225
98
|
```tsx
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
|
107
|
+
### Multi-Chain Support
|
|
253
108
|
|
|
254
109
|
```tsx
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
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
|
-
|
|
282
|
-
import { useAuthActions } from 'fare-privy-core';
|
|
120
|
+
## π§© UI Components
|
|
283
121
|
|
|
284
|
-
|
|
285
|
-
const { login, logout, isAuthenticated, isReady } = useAuthActions();
|
|
122
|
+
### SelectWalletModal
|
|
286
123
|
|
|
287
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
303
|
-
import { useConnectedWallets } from 'fare-privy-core';
|
|
140
|
+
### WalletOverview
|
|
304
141
|
|
|
305
|
-
|
|
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
|
-
|
|
314
|
-
}
|
|
315
|
-
```
|
|
144
|
+
**Props:**
|
|
316
145
|
|
|
317
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
154
|
+
### FundWalletModal
|
|
338
155
|
|
|
339
|
-
|
|
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
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
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
|
-
|
|
349
|
-
|
|
350
|
-
{primarySolanaAddress && <SolBalance address={primarySolanaAddress} />}
|
|
351
|
-
{primaryEthereumAddress && <EthBalance address={primaryEthereumAddress} />}
|
|
352
|
-
</div>
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
```
|
|
164
|
+
**Usage:**
|
|
165
|
+
---
|
|
356
166
|
|
|
357
|
-
|
|
167
|
+
## πͺ Hooks Overview
|
|
358
168
|
|
|
359
|
-
|
|
360
|
-
|
|
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
|
-
|
|
363
|
-
const { isAuthenticated, user } = useIsAuthenticated();
|
|
176
|
+
See [HOOKS.md](./HOOKS.md) for full details and advanced usage.
|
|
364
177
|
|
|
365
|
-
|
|
366
|
-
return <CasinoGame />;
|
|
367
|
-
}
|
|
368
|
-
```
|
|
178
|
+
---
|
|
369
179
|
|
|
370
|
-
|
|
180
|
+
## π οΈ Advanced Configuration & Casino Features
|
|
371
181
|
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
484
|
-
import { useSnapshot } from 'valtio';
|
|
198
|
+
import { CasinoAuthProvider } from 'fare-privy-core/lib/casino-auth';
|
|
485
199
|
|
|
486
|
-
function
|
|
487
|
-
const snap = useSnapshot(switchWalletState);
|
|
488
|
-
|
|
200
|
+
function CustomCasino() {
|
|
489
201
|
return (
|
|
490
|
-
<
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
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
|
-
|
|
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
|
-
|
|
248
|
+
## π¨ Styling & Theming
|
|
528
249
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
258
|
+
ISC License - see LICENSE file for details.
|
|
558
259
|
|
|
559
|
-
|
|
260
|
+
---
|
|
560
261
|
|
|
561
|
-
##
|
|
262
|
+
## π€ Contributing
|
|
562
263
|
|
|
563
|
-
|
|
564
|
-
>>>>>>> fb7640de89ab4d90f33248c3264f6a50a43b4008
|
|
264
|
+
Pull requests and issues are welcome!
|