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.
- package/README.md +182 -485
- 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.d.ts +1 -3
- package/dist/src/components/WalletOverview.d.ts.map +1 -1
- package/dist/src/components/WalletOverview.js +2 -2
- 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,567 +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
|
-
/>
|
|
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
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
##
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
###
|
|
96
|
+
### With Smart Wallets
|
|
227
97
|
|
|
228
98
|
```tsx
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
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
|
|
107
|
+
### Multi-Chain Support
|
|
256
108
|
|
|
257
109
|
```tsx
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
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
|
-
|
|
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
|
-
|
|
285
|
-
import { useAuthActions } from 'fare-privy-core';
|
|
120
|
+
## π§© UI Components
|
|
286
121
|
|
|
287
|
-
|
|
288
|
-
const { login, logout, isAuthenticated, isReady } = useAuthActions();
|
|
122
|
+
### SelectWalletModal
|
|
289
123
|
|
|
290
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
306
|
-
import { useConnectedWallets } from 'fare-privy-core';
|
|
140
|
+
### WalletOverview
|
|
307
141
|
|
|
308
|
-
|
|
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
|
-
|
|
317
|
-
}
|
|
318
|
-
```
|
|
144
|
+
**Props:**
|
|
319
145
|
|
|
320
|
-
|
|
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
|
-
|
|
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
|
-
###
|
|
154
|
+
### FundWalletModal
|
|
341
155
|
|
|
342
|
-
|
|
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
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
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
|
-
|
|
352
|
-
|
|
353
|
-
{primarySolanaAddress && <SolBalance address={primarySolanaAddress} />}
|
|
354
|
-
{primaryEthereumAddress && <EthBalance address={primaryEthereumAddress} />}
|
|
355
|
-
</div>
|
|
356
|
-
);
|
|
357
|
-
}
|
|
358
|
-
```
|
|
164
|
+
**Usage:**
|
|
165
|
+
---
|
|
359
166
|
|
|
360
|
-
|
|
167
|
+
## πͺ Hooks Overview
|
|
361
168
|
|
|
362
|
-
|
|
363
|
-
|
|
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
|
-
|
|
366
|
-
const { isAuthenticated, user } = useIsAuthenticated();
|
|
176
|
+
See [HOOKS.md](./HOOKS.md) for full details and advanced usage.
|
|
367
177
|
|
|
368
|
-
|
|
369
|
-
return <CasinoGame />;
|
|
370
|
-
}
|
|
371
|
-
```
|
|
178
|
+
---
|
|
372
179
|
|
|
373
|
-
|
|
180
|
+
## π οΈ Advanced Configuration & Casino Features
|
|
374
181
|
|
|
375
|
-
|
|
376
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 {
|
|
487
|
-
import { useSnapshot } from 'valtio';
|
|
198
|
+
import { CasinoAuthProvider } from 'fare-privy-core/lib/casino-auth';
|
|
488
199
|
|
|
489
|
-
function
|
|
490
|
-
const snap = useSnapshot(switchWalletState);
|
|
491
|
-
|
|
200
|
+
function CustomCasino() {
|
|
492
201
|
return (
|
|
493
|
-
<
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
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
|
-
|
|
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
|
-
|
|
248
|
+
## π¨ Styling & Theming
|
|
531
249
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
258
|
+
ISC License - see LICENSE file for details.
|
|
561
259
|
|
|
562
|
-
|
|
260
|
+
---
|
|
563
261
|
|
|
564
|
-
##
|
|
262
|
+
## π€ Contributing
|
|
565
263
|
|
|
566
|
-
|
|
567
|
-
>>>>>>> fb7640de89ab4d90f33248c3264f6a50a43b4008
|
|
264
|
+
Pull requests and issues are welcome!
|