fare-privy-core 1.1.0 โ 1.3.0
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 +319 -20
- package/dist/PrivyProviderTest.d.ts +45 -4
- package/dist/PrivyProviderTest.d.ts.map +1 -1
- package/dist/PrivyProviderTest.js +54 -13
- package/dist/PrivyProviderTest.js.map +1 -1
- package/dist/hooks/useWallets.d.ts +50 -0
- package/dist/hooks/useWallets.d.ts.map +1 -0
- package/dist/hooks/useWallets.js +84 -0
- package/dist/hooks/useWallets.js.map +1 -0
- package/dist/index.d.ts +34 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +37 -9
- package/dist/index.js.map +1 -1
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
# fare-privy-core
|
|
2
2
|
|
|
3
|
-
A React library for Privy authentication and wallet management
|
|
3
|
+
A lightweight React library for Privy authentication and wallet management, designed for casino and gaming applications on **Ethereum and Solana**.
|
|
4
4
|
|
|
5
|
-
## ๐ Current Features (v1.
|
|
5
|
+
## ๐ Current Features (v1.3.0)
|
|
6
6
|
|
|
7
|
-
- **๐
|
|
8
|
-
-
|
|
9
|
-
-
|
|
7
|
+
- **๐ Real Privy Auth**: Full Privy authentication integration
|
|
8
|
+
- **๐ฐ Casino-Ready**: Pre-configured for casino/gaming use cases
|
|
9
|
+
- **โ๏ธ Multi-Chain**: Support for both Ethereum and Solana networks
|
|
10
|
+
- **๐ผ Wallet State**: Valtio-based wallet switching state management
|
|
11
|
+
- **๐จ Themeable**: Customize colors and branding per casino
|
|
12
|
+
- **๐ช Simple Hooks**: 3 dependency-free hooks for wallet operations
|
|
13
|
+
- **โก TypeScript**: Full TypeScript support with type declarations
|
|
10
14
|
- **๐งช Tested**: Complete test suite
|
|
15
|
+
- **๐ฆ Lightweight**: Minimal dependencies, focused API
|
|
11
16
|
|
|
12
17
|
## ๐ฆ Installation
|
|
13
18
|
|
|
@@ -17,44 +22,338 @@ npm install fare-privy-core
|
|
|
17
22
|
pnpm add fare-privy-core
|
|
18
23
|
```
|
|
19
24
|
|
|
25
|
+
### โ ๏ธ Important Dependency Requirements
|
|
26
|
+
|
|
27
|
+
This package requires specific version ranges to avoid breaking changes:
|
|
28
|
+
|
|
29
|
+
- **@privy-io/react-auth**: `^1.0.0` - Core Privy authentication
|
|
30
|
+
- **styled-components**: Must use v5.x (not v6.x) - `npm install styled-components@^5.3.0`
|
|
31
|
+
- **valtio**: Must use v1.x (not v2.x) - `npm install valtio@^1.12.0`
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# Install all compatible versions
|
|
35
|
+
npm install fare-privy-core @privy-io/react-auth styled-components@^5.3.0 valtio@^1.12.0
|
|
36
|
+
```
|
|
37
|
+
|
|
20
38
|
## ๐ป Quick Start
|
|
21
39
|
|
|
40
|
+
### Basic Casino Setup
|
|
41
|
+
|
|
22
42
|
```tsx
|
|
23
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
PrivyProvider,
|
|
45
|
+
useConnectedWallets,
|
|
46
|
+
useIsAuthenticated
|
|
47
|
+
} from 'fare-privy-core';
|
|
24
48
|
|
|
25
49
|
function App() {
|
|
26
50
|
return (
|
|
27
|
-
<PrivyProvider
|
|
28
|
-
|
|
51
|
+
<PrivyProvider
|
|
52
|
+
appId="your-privy-app-id"
|
|
53
|
+
config={{
|
|
54
|
+
walletChainType: 'solana-only' // or 'ethereum-only' or 'ethereum-and-solana'
|
|
55
|
+
}}
|
|
56
|
+
theme={{
|
|
57
|
+
accentColor: "#0066ff",
|
|
58
|
+
darkMode: true
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
<YourCasinoApp />
|
|
62
|
+
</PrivyProvider>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### With Custom Branding
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { PrivyProvider } from 'fare-privy-core';
|
|
71
|
+
|
|
72
|
+
function MyCasino() {
|
|
73
|
+
return (
|
|
74
|
+
<PrivyProvider
|
|
75
|
+
appId="your-privy-app-id"
|
|
76
|
+
theme={{
|
|
77
|
+
accentColor: "#ff6b35", // Your casino color
|
|
78
|
+
logo: "/your-casino-logo.png",
|
|
79
|
+
darkMode: true
|
|
80
|
+
}}
|
|
81
|
+
config={{
|
|
82
|
+
loginMethods: ['email', 'wallet', 'google'],
|
|
83
|
+
appearance: {
|
|
84
|
+
showWalletLoginFirst: true,
|
|
85
|
+
}
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<CasinoGames />
|
|
89
|
+
</PrivyProvider>
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### With Smart Wallets (for sponsored transactions)
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { PrivyProvider } from 'fare-privy-core';
|
|
98
|
+
|
|
99
|
+
// Your Biconomy or other smart wallet config
|
|
100
|
+
const biconomyConfig = {
|
|
101
|
+
// Your smart wallet configuration here
|
|
102
|
+
// Same structure as your original biconomyPrivyConfig
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
function AdvancedCasino() {
|
|
106
|
+
return (
|
|
107
|
+
<PrivyProvider
|
|
108
|
+
appId="your-privy-app-id"
|
|
109
|
+
smartWalletConfig={biconomyConfig} // Pass as 'config' prop
|
|
110
|
+
theme={{
|
|
111
|
+
accentColor: "#00d4ff"
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
<CasinoWithGaslessTransactions />
|
|
115
|
+
</PrivyProvider>
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### With Environment-Specific Config
|
|
121
|
+
|
|
122
|
+
```tsx
|
|
123
|
+
import { PrivyProvider } from 'fare-privy-core';
|
|
124
|
+
|
|
125
|
+
function ProductionCasino() {
|
|
126
|
+
return (
|
|
127
|
+
<PrivyProvider
|
|
128
|
+
appId="your-privy-app-id"
|
|
129
|
+
environment="production" // 'production' | 'staging' | 'development'
|
|
130
|
+
config={{
|
|
131
|
+
loginMethods: ['email', 'wallet'],
|
|
132
|
+
// Your full Privy config
|
|
133
|
+
}}
|
|
134
|
+
>
|
|
135
|
+
<CasinoApp />
|
|
136
|
+
</PrivyProvider>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Solana Casino Example
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
import { PrivyProvider } from 'fare-privy-core';
|
|
145
|
+
|
|
146
|
+
function SolanaCasino() {
|
|
147
|
+
return (
|
|
148
|
+
<PrivyProvider
|
|
149
|
+
appId="your-privy-app-id"
|
|
150
|
+
config={{
|
|
151
|
+
loginMethods: ['wallet', 'email'],
|
|
152
|
+
// Privy automatically detects and supports Solana wallets
|
|
153
|
+
// like Phantom, Solflare, Backpack, etc.
|
|
154
|
+
appearance: {
|
|
155
|
+
walletChainType: 'solana-only', // Show only Solana wallets
|
|
156
|
+
showWalletLoginFirst: true,
|
|
157
|
+
},
|
|
158
|
+
}}
|
|
159
|
+
theme={{
|
|
160
|
+
accentColor: "#14F195", // Solana green
|
|
161
|
+
darkMode: true
|
|
162
|
+
}}
|
|
163
|
+
>
|
|
164
|
+
<YourSolanaGames />
|
|
165
|
+
</PrivyProvider>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Multi-Chain Support (Ethereum + Solana)
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
import { PrivyProvider } from 'fare-privy-core';
|
|
174
|
+
|
|
175
|
+
function MultiChainCasino() {
|
|
176
|
+
return (
|
|
177
|
+
<PrivyProvider
|
|
178
|
+
appId="your-privy-app-id"
|
|
179
|
+
config={{
|
|
180
|
+
loginMethods: ['wallet', 'email'],
|
|
181
|
+
appearance: {
|
|
182
|
+
walletChainType: 'ethereum-and-solana', // Support both chains
|
|
183
|
+
},
|
|
184
|
+
// Users can connect both Ethereum and Solana wallets
|
|
185
|
+
}}
|
|
186
|
+
>
|
|
187
|
+
<CrossChainCasino />
|
|
29
188
|
</PrivyProvider>
|
|
30
189
|
);
|
|
31
190
|
}
|
|
32
191
|
```
|
|
33
192
|
|
|
193
|
+
## ๐ช Using Wallet Hooks
|
|
194
|
+
|
|
195
|
+
Three simple, **dependency-free** hooks to access wallet data in your casino:
|
|
196
|
+
|
|
197
|
+
### `useConnectedWallets()` - Get all wallet info
|
|
198
|
+
|
|
199
|
+
```tsx
|
|
200
|
+
import { useConnectedWallets } from 'fare-privy-core';
|
|
201
|
+
|
|
202
|
+
function WalletDisplay() {
|
|
203
|
+
const {
|
|
204
|
+
primaryWallet, // First connected wallet
|
|
205
|
+
embeddedWallet, // Privy embedded wallet
|
|
206
|
+
externalWallet, // MetaMask/Phantom etc.
|
|
207
|
+
isAuthenticated, // true if user has wallet
|
|
208
|
+
} = useConnectedWallets();
|
|
209
|
+
|
|
210
|
+
return <div>Address: {primaryWallet?.address}</div>;
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### `useWalletAddresses()` - Get addresses by chain
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
import { useWalletAddresses } from 'fare-privy-core';
|
|
218
|
+
|
|
219
|
+
function BalanceDisplay() {
|
|
220
|
+
const {
|
|
221
|
+
primarySolanaAddress,
|
|
222
|
+
primaryEthereumAddress
|
|
223
|
+
} = useWalletAddresses();
|
|
224
|
+
|
|
225
|
+
return (
|
|
226
|
+
<div>
|
|
227
|
+
{primarySolanaAddress && <SolBalance address={primarySolanaAddress} />}
|
|
228
|
+
{primaryEthereumAddress && <EthBalance address={primaryEthereumAddress} />}
|
|
229
|
+
</div>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### `useIsAuthenticated()` - Simple auth check
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
import { useIsAuthenticated } from 'fare-privy-core';
|
|
238
|
+
|
|
239
|
+
function ProtectedGame() {
|
|
240
|
+
const { isAuthenticated, user } = useIsAuthenticated();
|
|
241
|
+
|
|
242
|
+
if (!isAuthenticated) return <LoginPrompt />;
|
|
243
|
+
return <CasinoGame />;
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
๐ **[See complete hook documentation โ](./HOOKS.md)**
|
|
248
|
+
|
|
34
249
|
## ๐ API Reference
|
|
35
250
|
|
|
36
251
|
### PrivyProvider
|
|
37
252
|
|
|
38
|
-
Main authentication provider
|
|
253
|
+
Main authentication provider for your casino application.
|
|
39
254
|
|
|
40
|
-
**Props:**
|
|
41
|
-
- `appId` (string): Your Privy application ID
|
|
42
|
-
- `
|
|
43
|
-
|
|
255
|
+
**Required Props:**
|
|
256
|
+
- `appId` (string): Your Privy application ID (get this from [Privy Dashboard](https://dashboard.privy.io))
|
|
257
|
+
- `children` (ReactNode): Your casino application components
|
|
258
|
+
|
|
259
|
+
**Optional Props:**
|
|
260
|
+
- `clientId` (string): Privy client ID for enhanced security
|
|
261
|
+
- `config` (PrivyClientConfig): Full Privy configuration object
|
|
262
|
+
- `loginMethods`: Array of auth methods (e.g., `['email', 'wallet', 'google']`)
|
|
263
|
+
- `appearance`: UI customization options
|
|
264
|
+
- See [Privy docs](https://docs.privy.io/guide/react/configuration) for all options
|
|
265
|
+
- `smartWalletConfig` (object): Smart wallet configuration object (e.g., your Biconomy config)
|
|
266
|
+
- **Important**: Pass the complete config object, not spread props
|
|
267
|
+
- Example: `smartWalletConfig={biconomyPrivyConfig}`
|
|
268
|
+
- `disableSmartWallets` (boolean): Disable smart wallet integration (default: false)
|
|
269
|
+
- `environment` ('production' | 'staging' | 'development'): Environment-specific config overrides
|
|
270
|
+
- `theme` (object): Quick theme customization (merged with config.appearance)
|
|
271
|
+
- `accentColor`: Primary color for your casino brand
|
|
272
|
+
- `logo`: URL to your casino logo
|
|
273
|
+
- `darkMode`: Enable/disable dark theme
|
|
44
274
|
|
|
45
275
|
### Wallet State Management
|
|
46
276
|
|
|
277
|
+
Import and use the wallet switching state in your components:
|
|
278
|
+
|
|
279
|
+
```tsx
|
|
280
|
+
import { switchWalletState } from 'fare-privy-core';
|
|
281
|
+
import { useSnapshot } from 'valtio';
|
|
282
|
+
|
|
283
|
+
function MyWalletUI() {
|
|
284
|
+
const snap = useSnapshot(switchWalletState);
|
|
285
|
+
|
|
286
|
+
return (
|
|
287
|
+
<div>
|
|
288
|
+
<p>Modal Open: {snap.isWalletModalOpen ? 'Yes' : 'No'}</p>
|
|
289
|
+
<p>Selected: {snap.selectedConnectorType}</p>
|
|
290
|
+
<button onClick={() => switchWalletState.isWalletModalOpen = true}>
|
|
291
|
+
Open Wallet Modal
|
|
292
|
+
</button>
|
|
293
|
+
</div>
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**State Properties:**
|
|
299
|
+
- `isWalletModalOpen` (boolean): Controls wallet modal visibility
|
|
300
|
+
- `selectedConnectorType` (string): Currently selected wallet connector type
|
|
301
|
+
|
|
302
|
+
## ๐ฏ Package Philosophy
|
|
303
|
+
|
|
304
|
+
This package provides **core authentication and state management** without opinionated UI components. Perfect for casino operators who want to:
|
|
305
|
+
|
|
306
|
+
- โ
Quick integration of Privy auth into their casino
|
|
307
|
+
- โ
Customize branding and colors per casino
|
|
308
|
+
- โ
Build their own game UI that matches their design
|
|
309
|
+
- โ
Keep bundle size minimal
|
|
310
|
+
- โ
Maintain full control over user experience
|
|
311
|
+
- โ
Support multiple casinos from one codebase
|
|
312
|
+
|
|
313
|
+
## ๐ฐ For Casino Operators
|
|
314
|
+
|
|
315
|
+
This library is designed for operators running multiple casinos on the same platform. Each casino can:
|
|
316
|
+
|
|
317
|
+
1. **Use their own Privy App ID** for isolated user bases
|
|
318
|
+
2. **Customize theme colors** to match their brand
|
|
319
|
+
3. **Configure login methods** based on their audience
|
|
320
|
+
4. **Add their own logo** and branding
|
|
321
|
+
5. **Build custom game UIs** using the wallet state management
|
|
322
|
+
6. **Support Ethereum, Solana, or both chains**
|
|
323
|
+
|
|
324
|
+
Example multi-casino setup:
|
|
325
|
+
|
|
47
326
|
```tsx
|
|
48
|
-
|
|
49
|
-
|
|
327
|
+
// Ethereum Casino
|
|
328
|
+
<PrivyProvider
|
|
329
|
+
appId="eth-casino-id"
|
|
330
|
+
config={{ appearance: { walletChainType: 'ethereum-only' }}}
|
|
331
|
+
theme={{ accentColor: "#627EEA" }}
|
|
332
|
+
>
|
|
333
|
+
<EthereumCasino />
|
|
334
|
+
</PrivyProvider>
|
|
335
|
+
|
|
336
|
+
// Solana Casino
|
|
337
|
+
<PrivyProvider
|
|
338
|
+
appId="sol-casino-id"
|
|
339
|
+
config={{ appearance: { walletChainType: 'solana-only' }}}
|
|
340
|
+
theme={{ accentColor: "#14F195" }}
|
|
341
|
+
>
|
|
342
|
+
<SolanaCasino />
|
|
343
|
+
</PrivyProvider>
|
|
344
|
+
|
|
345
|
+
// Multi-Chain Casino
|
|
346
|
+
<PrivyProvider
|
|
347
|
+
appId="multi-casino-id"
|
|
348
|
+
config={{ appearance: { walletChainType: 'ethereum-and-solana' }}}
|
|
349
|
+
>
|
|
350
|
+
<MultiChainCasino />
|
|
351
|
+
</PrivyProvider>
|
|
50
352
|
```
|
|
51
353
|
|
|
52
|
-
## ๐
|
|
354
|
+
## ๐ What's Next
|
|
53
355
|
|
|
54
|
-
|
|
55
|
-
- v1.3.0: Hook exports
|
|
56
|
-
- v1.4.0: UI components
|
|
57
|
-
- v2.0.0: Full feature set
|
|
356
|
+
Want more features? Open an issue or PR on [GitHub](https://github.com/farePrivy/fare-privy-core)!
|
|
58
357
|
|
|
59
358
|
## ๐ License
|
|
60
359
|
|
|
@@ -1,15 +1,56 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { type PrivyClientConfig } from "@privy-io/react-auth";
|
|
2
3
|
export interface PrivyProviderProps {
|
|
3
4
|
children: React.ReactNode;
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Your Privy App ID (required)
|
|
7
|
+
*/
|
|
8
|
+
appId: string;
|
|
9
|
+
/**
|
|
10
|
+
* Optional Privy Client ID for enhanced security
|
|
11
|
+
*/
|
|
5
12
|
clientId?: string;
|
|
6
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Custom Privy configuration for your casino
|
|
15
|
+
* @see https://docs.privy.io/guide/react/configuration
|
|
16
|
+
*/
|
|
17
|
+
config?: PrivyClientConfig;
|
|
18
|
+
/**
|
|
19
|
+
* Smart wallet configuration (e.g., Biconomy)
|
|
20
|
+
* This should be the complete smart wallet config object
|
|
21
|
+
*/
|
|
7
22
|
smartWalletConfig?: any;
|
|
23
|
+
/**
|
|
24
|
+
* Disable smart wallet integration
|
|
25
|
+
*/
|
|
8
26
|
disableSmartWallets?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Environment override for configuration selection
|
|
29
|
+
*/
|
|
30
|
+
environment?: "production" | "staging" | "development";
|
|
31
|
+
/**
|
|
32
|
+
* Custom theme for your casino
|
|
33
|
+
*/
|
|
34
|
+
theme?: {
|
|
35
|
+
accentColor?: string;
|
|
36
|
+
logo?: string;
|
|
37
|
+
darkMode?: boolean;
|
|
38
|
+
};
|
|
9
39
|
}
|
|
10
40
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
41
|
+
* Lightweight Privy authentication wrapper for casino applications
|
|
42
|
+
* Compatible with the original farePrivy architecture
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```tsx
|
|
46
|
+
* <PrivyProvider
|
|
47
|
+
* appId="your-app-id"
|
|
48
|
+
* theme={{ accentColor: "#0066ff" }}
|
|
49
|
+
* smartWalletConfig={biconomyConfig}
|
|
50
|
+
* >
|
|
51
|
+
* <YourCasinoApp />
|
|
52
|
+
* </PrivyProvider>
|
|
53
|
+
* ```
|
|
13
54
|
*/
|
|
14
55
|
export declare const PrivyProvider: React.FC<PrivyProviderProps>;
|
|
15
56
|
//# sourceMappingURL=PrivyProviderTest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivyProviderTest.d.ts","sourceRoot":"","sources":["../PrivyProviderTest.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"PrivyProviderTest.d.ts","sourceRoot":"","sources":["../PrivyProviderTest.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAG9B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,GAAG,CAAC;IACxB;;OAEG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;OAEG;IACH,WAAW,CAAC,EAAE,YAAY,GAAG,SAAS,GAAG,aAAa,CAAC;IACvD;;OAEG;IACH,KAAK,CAAC,EAAE;QACN,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA8DtD,CAAC"}
|
|
@@ -1,18 +1,59 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { PrivyProvider as _PrivyProvider, } from "@privy-io/react-auth";
|
|
4
|
+
import { SmartWalletsProvider } from "@privy-io/react-auth/smart-wallets";
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
6
|
+
* Lightweight Privy authentication wrapper for casino applications
|
|
7
|
+
* Compatible with the original farePrivy architecture
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <PrivyProvider
|
|
12
|
+
* appId="your-app-id"
|
|
13
|
+
* theme={{ accentColor: "#0066ff" }}
|
|
14
|
+
* smartWalletConfig={biconomyConfig}
|
|
15
|
+
* >
|
|
16
|
+
* <YourCasinoApp />
|
|
17
|
+
* </PrivyProvider>
|
|
18
|
+
* ```
|
|
5
19
|
*/
|
|
6
|
-
export const PrivyProvider = ({ children, appId, clientId, config, smartWalletConfig, disableSmartWallets, }) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
export const PrivyProvider = ({ children, appId, clientId, config, smartWalletConfig, disableSmartWallets = false, environment, theme, }) => {
|
|
21
|
+
// Merge configurations (similar to original implementation)
|
|
22
|
+
const finalConfig = useMemo(() => {
|
|
23
|
+
let baseConfig = { ...config };
|
|
24
|
+
// Apply environment-specific overrides
|
|
25
|
+
if (environment) {
|
|
26
|
+
if (environment === "development") {
|
|
27
|
+
// Add development-specific overrides if needed
|
|
28
|
+
baseConfig = {
|
|
29
|
+
...baseConfig,
|
|
30
|
+
// Your dev overrides here
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Apply theme overrides
|
|
35
|
+
if (theme) {
|
|
36
|
+
baseConfig = {
|
|
37
|
+
...baseConfig,
|
|
38
|
+
appearance: {
|
|
39
|
+
...baseConfig.appearance,
|
|
40
|
+
...(theme.accentColor && {
|
|
41
|
+
accentColor: theme.accentColor,
|
|
42
|
+
}),
|
|
43
|
+
...(theme.logo && { logo: theme.logo }),
|
|
44
|
+
...(theme.darkMode !== undefined && {
|
|
45
|
+
theme: theme.darkMode ? "dark" : "light",
|
|
46
|
+
}),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return baseConfig;
|
|
51
|
+
}, [config, environment, theme]);
|
|
52
|
+
// If smart wallets are disabled, just use basic PrivyProvider
|
|
53
|
+
if (disableSmartWallets) {
|
|
54
|
+
return (_jsx(_PrivyProvider, { appId: appId, clientId: clientId, config: finalConfig, children: children }));
|
|
55
|
+
}
|
|
56
|
+
// With smart wallet support (matches original pattern with 'config' prop)
|
|
57
|
+
return (_jsx(_PrivyProvider, { appId: appId, clientId: clientId, config: finalConfig, children: _jsx(SmartWalletsProvider, { config: smartWalletConfig, children: children }) }));
|
|
17
58
|
};
|
|
18
59
|
//# sourceMappingURL=PrivyProviderTest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivyProviderTest.js","sourceRoot":"","sources":["../PrivyProviderTest.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"PrivyProviderTest.js","sourceRoot":"","sources":["../PrivyProviderTest.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EACL,aAAa,IAAI,cAAc,GAEhC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAwC1E;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,aAAa,GAAiC,CAAC,EAC1D,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,mBAAmB,GAAG,KAAK,EAC3B,WAAW,EACX,KAAK,GACN,EAAE,EAAE;IACH,4DAA4D;IAC5D,MAAM,WAAW,GAAsB,OAAO,CAAC,GAAG,EAAE;QAClD,IAAI,UAAU,GAAsB,EAAE,GAAG,MAAM,EAAE,CAAC;QAElD,uCAAuC;QACvC,IAAI,WAAW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allet hooks for casino clients
|
|
3
|
+
* No external dependencies - ready to use!
|
|
4
|
+
*/
|
|
5
|
+
import { type ConnectedWallet } from "@privy-io/react-auth";
|
|
6
|
+
/**
|
|
7
|
+
* Get active/connected wallets
|
|
8
|
+
* Works with both Ethereum and Solana wallets
|
|
9
|
+
*/
|
|
10
|
+
export declare const useConnectedWallets: () => {
|
|
11
|
+
/** All connected/linked wallets */
|
|
12
|
+
connectedWallets: ConnectedWallet[];
|
|
13
|
+
/** Primary wallet (first connected) */
|
|
14
|
+
primaryWallet: ConnectedWallet;
|
|
15
|
+
/** Embedded Privy wallet if exists */
|
|
16
|
+
embeddedWallet: ConnectedWallet;
|
|
17
|
+
/** External wallet (MetaMask, Phantom, etc.) if exists */
|
|
18
|
+
externalWallet: ConnectedWallet;
|
|
19
|
+
/** Whether user is authenticated */
|
|
20
|
+
isAuthenticated: boolean;
|
|
21
|
+
/** Whether Privy is ready */
|
|
22
|
+
isReady: boolean;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Get wallet addresses by chain type
|
|
26
|
+
*/
|
|
27
|
+
export declare const useWalletAddresses: () => {
|
|
28
|
+
/** All Ethereum wallet addresses */
|
|
29
|
+
ethereumAddresses: string[];
|
|
30
|
+
/** All Solana wallet addresses */
|
|
31
|
+
solanaAddresses: string[];
|
|
32
|
+
/** Primary Ethereum address */
|
|
33
|
+
primaryEthereumAddress: string;
|
|
34
|
+
/** Primary Solana address */
|
|
35
|
+
primarySolanaAddress: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Check if user is authenticated with wallet
|
|
39
|
+
*/
|
|
40
|
+
export declare const useIsAuthenticated: () => {
|
|
41
|
+
/** User is authenticated and has wallet connected */
|
|
42
|
+
isAuthenticated: boolean;
|
|
43
|
+
/** User object from Privy */
|
|
44
|
+
user: import("@privy-io/react-auth").User;
|
|
45
|
+
/** Number of connected wallets */
|
|
46
|
+
walletCount: number;
|
|
47
|
+
/** Privy ready state */
|
|
48
|
+
isReady: boolean;
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=useWallets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWallets.d.ts","sourceRoot":"","sources":["../../hooks/useWallets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,eAAO,MAAM,mBAAmB;IA6B5B,mCAAmC;;IAEnC,uCAAuC;;IAEvC,sCAAsC;;IAEtC,0DAA0D;;IAE1D,oCAAoC;;IAEpC,6BAA6B;;CAGhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAoB3B,oCAAoC;;IAEpC,kCAAkC;;IAElC,+BAA+B;;IAE/B,6BAA6B;;CAGhC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAQ3B,qDAAqD;;IAErD,6BAA6B;;IAE7B,kCAAkC;;IAElC,wBAAwB;;CAG3B,CAAC"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simplified wallet hooks for casino clients
|
|
3
|
+
* No external dependencies - ready to use!
|
|
4
|
+
*/
|
|
5
|
+
import { useMemo } from "react";
|
|
6
|
+
import { usePrivy, useWallets as usePrivyWallets, } from "@privy-io/react-auth";
|
|
7
|
+
/**
|
|
8
|
+
* Get active/connected wallets
|
|
9
|
+
* Works with both Ethereum and Solana wallets
|
|
10
|
+
*/
|
|
11
|
+
export const useConnectedWallets = () => {
|
|
12
|
+
const { ready, authenticated } = usePrivy();
|
|
13
|
+
const { wallets } = usePrivyWallets();
|
|
14
|
+
const connectedWallets = useMemo(() => wallets.filter((wallet) => wallet.linked), [wallets]);
|
|
15
|
+
const primaryWallet = useMemo(() => {
|
|
16
|
+
if (!ready || !authenticated || connectedWallets.length === 0)
|
|
17
|
+
return null;
|
|
18
|
+
return connectedWallets[0];
|
|
19
|
+
}, [ready, authenticated, connectedWallets]);
|
|
20
|
+
const embeddedWallet = useMemo(() => {
|
|
21
|
+
return (connectedWallets.find((wallet) => wallet.connectorType === "embedded") ||
|
|
22
|
+
null);
|
|
23
|
+
}, [connectedWallets]);
|
|
24
|
+
const externalWallet = useMemo(() => {
|
|
25
|
+
return (connectedWallets.find((wallet) => wallet.connectorType !== "embedded") ||
|
|
26
|
+
null);
|
|
27
|
+
}, [connectedWallets]);
|
|
28
|
+
return {
|
|
29
|
+
/** All connected/linked wallets */
|
|
30
|
+
connectedWallets,
|
|
31
|
+
/** Primary wallet (first connected) */
|
|
32
|
+
primaryWallet,
|
|
33
|
+
/** Embedded Privy wallet if exists */
|
|
34
|
+
embeddedWallet,
|
|
35
|
+
/** External wallet (MetaMask, Phantom, etc.) if exists */
|
|
36
|
+
externalWallet,
|
|
37
|
+
/** Whether user is authenticated */
|
|
38
|
+
isAuthenticated: authenticated && ready,
|
|
39
|
+
/** Whether Privy is ready */
|
|
40
|
+
isReady: ready,
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Get wallet addresses by chain type
|
|
45
|
+
*/
|
|
46
|
+
export const useWalletAddresses = () => {
|
|
47
|
+
const { connectedWallets } = useConnectedWallets();
|
|
48
|
+
const ethereumAddresses = useMemo(() => connectedWallets
|
|
49
|
+
.filter((w) => w.chainType === "ethereum")
|
|
50
|
+
.map((w) => w.address), [connectedWallets]);
|
|
51
|
+
const solanaAddresses = useMemo(() => connectedWallets
|
|
52
|
+
.filter((w) => w.chainType === "solana")
|
|
53
|
+
.map((w) => w.address), [connectedWallets]);
|
|
54
|
+
return {
|
|
55
|
+
/** All Ethereum wallet addresses */
|
|
56
|
+
ethereumAddresses,
|
|
57
|
+
/** All Solana wallet addresses */
|
|
58
|
+
solanaAddresses,
|
|
59
|
+
/** Primary Ethereum address */
|
|
60
|
+
primaryEthereumAddress: ethereumAddresses[0] || null,
|
|
61
|
+
/** Primary Solana address */
|
|
62
|
+
primarySolanaAddress: solanaAddresses[0] || null,
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Check if user is authenticated with wallet
|
|
67
|
+
*/
|
|
68
|
+
export const useIsAuthenticated = () => {
|
|
69
|
+
const { user, ready, authenticated } = usePrivy();
|
|
70
|
+
const { connectedWallets } = useConnectedWallets();
|
|
71
|
+
const hasWallet = connectedWallets.length > 0;
|
|
72
|
+
const isFullyAuthenticated = authenticated && ready && hasWallet;
|
|
73
|
+
return {
|
|
74
|
+
/** User is authenticated and has wallet connected */
|
|
75
|
+
isAuthenticated: isFullyAuthenticated,
|
|
76
|
+
/** User object from Privy */
|
|
77
|
+
user,
|
|
78
|
+
/** Number of connected wallets */
|
|
79
|
+
walletCount: connectedWallets.length,
|
|
80
|
+
/** Privy ready state */
|
|
81
|
+
isReady: ready,
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
//# sourceMappingURL=useWallets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWallets.js","sourceRoot":"","sources":["../../hooks/useWallets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EACL,QAAQ,EACR,UAAU,IAAI,eAAe,GAE9B,MAAM,sBAAsB,CAAC;AAE9B;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,EAAE;IACtC,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC5C,MAAM,EAAE,OAAO,EAAE,GAAG,eAAe,EAAE,CAAC;IAEtC,MAAM,gBAAgB,GAAG,OAAO,CAC9B,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAC/C,CAAC,OAAO,CAAC,CACV,CAAC;IAEF,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,E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.3.0 - Streamlined Package
|
|
3
3
|
* This package exports core functionality without external app dependencies.
|
|
4
4
|
*/
|
|
5
5
|
export { PrivyProvider, type PrivyProviderProps } from "./PrivyProviderTest.js";
|
|
6
6
|
export * from "./farePrivy/store/switchWallet.js";
|
|
7
|
+
export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, } from "./hooks/useWallets.js";
|
|
7
8
|
/**
|
|
8
|
-
* โ
PRODUCTION READY - v1.
|
|
9
|
+
* โ
PRODUCTION READY - v1.3.0:
|
|
9
10
|
*
|
|
10
|
-
* โ
Dependencies:
|
|
11
|
+
* โ
Dependencies: Tightened version constraints for stability
|
|
11
12
|
* โ
Build System: TypeScript compilation working flawlessly
|
|
12
13
|
* โ
Test Suite: Complete coverage with all tests passing
|
|
13
14
|
* โ
Exports: Clean API surface without external app dependencies
|
|
14
|
-
* โ
|
|
15
|
+
* โ
Package Size: Ultra-lean - removed all UI components with external dependencies
|
|
15
16
|
*/
|
|
16
17
|
/**
|
|
17
18
|
* ๐ฆ WHAT'S INCLUDED:
|
|
18
|
-
* โ
PrivyProvider
|
|
19
|
-
* โ
Wallet switching store/state management
|
|
19
|
+
* โ
PrivyProvider - Real Privy authentication wrapper with Solana/Ethereum support
|
|
20
|
+
* โ
Wallet switching store/state management (Valtio)
|
|
21
|
+
* โ
Simplified wallet hooks - NO external dependencies!
|
|
22
|
+
* - useConnectedWallets: Get connected wallets (embedded/external)
|
|
23
|
+
* - useWalletAddresses: Get Ethereum & Solana addresses
|
|
24
|
+
* - useIsAuthenticated: Check authentication status
|
|
20
25
|
*
|
|
21
26
|
* ๐ก Configuration:
|
|
22
27
|
* Users should provide their own Privy configuration.
|
|
@@ -25,15 +30,35 @@ export * from "./farePrivy/store/switchWallet.js";
|
|
|
25
30
|
/**
|
|
26
31
|
* ๐ก Usage:
|
|
27
32
|
* ```typescript
|
|
28
|
-
* import {
|
|
33
|
+
* import {
|
|
34
|
+
* PrivyProvider,
|
|
35
|
+
* useConnectedWallets,
|
|
36
|
+
* useWalletAddresses,
|
|
37
|
+
* useIsAuthenticated
|
|
38
|
+
* } from 'fare-privy-core';
|
|
29
39
|
*
|
|
40
|
+
* // 1. Wrap your app
|
|
30
41
|
* function App() {
|
|
31
42
|
* return (
|
|
32
|
-
* <PrivyProvider
|
|
33
|
-
*
|
|
43
|
+
* <PrivyProvider
|
|
44
|
+
* appId="your-privy-app-id"
|
|
45
|
+
* config={{ walletChainType: 'solana-only' }} // or 'ethereum-only' or 'ethereum-and-solana'
|
|
46
|
+
* >
|
|
47
|
+
* <YourCasino />
|
|
34
48
|
* </PrivyProvider>
|
|
35
49
|
* );
|
|
36
50
|
* }
|
|
51
|
+
*
|
|
52
|
+
* // 2. Use hooks in your casino components
|
|
53
|
+
* function YourCasino() {
|
|
54
|
+
* const { primaryWallet, embeddedWallet, externalWallet } = useConnectedWallets();
|
|
55
|
+
* const { primarySolanaAddress, primaryEthereumAddress } = useWalletAddresses();
|
|
56
|
+
* const { isAuthenticated, user } = useIsAuthenticated();
|
|
57
|
+
*
|
|
58
|
+
* if (!isAuthenticated) return <LoginButton />;
|
|
59
|
+
*
|
|
60
|
+
* return <div>Welcome {primaryWallet?.address}</div>;
|
|
61
|
+
* }
|
|
37
62
|
* ```
|
|
38
63
|
*/
|
|
39
64
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGhF,cAAc,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAGhF,cAAc,mCAAmC,CAAC;AAGlD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAK/B;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG"}
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* fare-privy-core - v1.
|
|
2
|
+
* fare-privy-core - v1.3.0 - Streamlined Package
|
|
3
3
|
* This package exports core functionality without external app dependencies.
|
|
4
4
|
*/
|
|
5
5
|
// โ
CURRENT EXPORTS - Available Now
|
|
6
6
|
export { PrivyProvider } from "./PrivyProviderTest.js";
|
|
7
7
|
// โ
CORE FUNCTIONALITY - Working exports
|
|
8
8
|
export * from "./farePrivy/store/switchWallet.js";
|
|
9
|
+
// โ
SIMPLIFIED WALLET HOOKS - No external dependencies!
|
|
10
|
+
export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, } from "./hooks/useWallets.js";
|
|
11
|
+
// โ REMOVED - Had too many external dependencies
|
|
12
|
+
// export * from "./farePrivy/modals/index.js";
|
|
9
13
|
/**
|
|
10
|
-
* โ
PRODUCTION READY - v1.
|
|
14
|
+
* โ
PRODUCTION READY - v1.3.0:
|
|
11
15
|
*
|
|
12
|
-
* โ
Dependencies:
|
|
16
|
+
* โ
Dependencies: Tightened version constraints for stability
|
|
13
17
|
* โ
Build System: TypeScript compilation working flawlessly
|
|
14
18
|
* โ
Test Suite: Complete coverage with all tests passing
|
|
15
19
|
* โ
Exports: Clean API surface without external app dependencies
|
|
16
|
-
* โ
|
|
20
|
+
* โ
Package Size: Ultra-lean - removed all UI components with external dependencies
|
|
17
21
|
*/
|
|
18
22
|
/**
|
|
19
23
|
* ๐ฆ WHAT'S INCLUDED:
|
|
20
|
-
* โ
PrivyProvider
|
|
21
|
-
* โ
Wallet switching store/state management
|
|
24
|
+
* โ
PrivyProvider - Real Privy authentication wrapper with Solana/Ethereum support
|
|
25
|
+
* โ
Wallet switching store/state management (Valtio)
|
|
26
|
+
* โ
Simplified wallet hooks - NO external dependencies!
|
|
27
|
+
* - useConnectedWallets: Get connected wallets (embedded/external)
|
|
28
|
+
* - useWalletAddresses: Get Ethereum & Solana addresses
|
|
29
|
+
* - useIsAuthenticated: Check authentication status
|
|
22
30
|
*
|
|
23
31
|
* ๐ก Configuration:
|
|
24
32
|
* Users should provide their own Privy configuration.
|
|
@@ -27,15 +35,35 @@ export * from "./farePrivy/store/switchWallet.js";
|
|
|
27
35
|
/**
|
|
28
36
|
* ๐ก Usage:
|
|
29
37
|
* ```typescript
|
|
30
|
-
* import {
|
|
38
|
+
* import {
|
|
39
|
+
* PrivyProvider,
|
|
40
|
+
* useConnectedWallets,
|
|
41
|
+
* useWalletAddresses,
|
|
42
|
+
* useIsAuthenticated
|
|
43
|
+
* } from 'fare-privy-core';
|
|
31
44
|
*
|
|
45
|
+
* // 1. Wrap your app
|
|
32
46
|
* function App() {
|
|
33
47
|
* return (
|
|
34
|
-
* <PrivyProvider
|
|
35
|
-
*
|
|
48
|
+
* <PrivyProvider
|
|
49
|
+
* appId="your-privy-app-id"
|
|
50
|
+
* config={{ walletChainType: 'solana-only' }} // or 'ethereum-only' or 'ethereum-and-solana'
|
|
51
|
+
* >
|
|
52
|
+
* <YourCasino />
|
|
36
53
|
* </PrivyProvider>
|
|
37
54
|
* );
|
|
38
55
|
* }
|
|
56
|
+
*
|
|
57
|
+
* // 2. Use hooks in your casino components
|
|
58
|
+
* function YourCasino() {
|
|
59
|
+
* const { primaryWallet, embeddedWallet, externalWallet } = useConnectedWallets();
|
|
60
|
+
* const { primarySolanaAddress, primaryEthereumAddress } = useWalletAddresses();
|
|
61
|
+
* const { isAuthenticated, user } = useIsAuthenticated();
|
|
62
|
+
*
|
|
63
|
+
* if (!isAuthenticated) return <LoginButton />;
|
|
64
|
+
*
|
|
65
|
+
* return <div>Welcome {primaryWallet?.address}</div>;
|
|
66
|
+
* }
|
|
39
67
|
* ```
|
|
40
68
|
*/
|
|
41
69
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oCAAoC;AACpC,OAAO,EAAE,aAAa,EAA2B,MAAM,wBAAwB,CAAC;AAEhF,yCAAyC;AACzC,cAAc,mCAAmC,CAAC;AAElD;;;;;;;;GAQG;AAEH
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oCAAoC;AACpC,OAAO,EAAE,aAAa,EAA2B,MAAM,wBAAwB,CAAC;AAEhF,yCAAyC;AACzC,cAAc,mCAAmC,CAAC;AAElD,wDAAwD;AACxD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAE/B,iDAAiD;AACjD,+CAA+C;AAE/C;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fare-privy-core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "A comprehensive React library for Privy authentication and wallet management with casino gaming features",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"privy",
|
|
@@ -12,15 +12,16 @@
|
|
|
12
12
|
"casino",
|
|
13
13
|
"gaming",
|
|
14
14
|
"blockchain",
|
|
15
|
-
"ethereum"
|
|
15
|
+
"ethereum",
|
|
16
|
+
"solana"
|
|
16
17
|
],
|
|
17
|
-
"homepage": "https://github.com/farePrivy#readme",
|
|
18
|
+
"homepage": "https://github.com/farePrivy/fare-privy-core#readme",
|
|
18
19
|
"repository": {
|
|
19
20
|
"type": "git",
|
|
20
|
-
"url": "https://github.com/farePrivy.git"
|
|
21
|
+
"url": "https://github.com/farePrivy/fare-privy-core.git"
|
|
21
22
|
},
|
|
22
23
|
"bugs": {
|
|
23
|
-
"url": "https://github.com/farePrivy/issues"
|
|
24
|
+
"url": "https://github.com/farePrivy/fare-privy-core/issues"
|
|
24
25
|
},
|
|
25
26
|
"license": "ISC",
|
|
26
27
|
"author": {
|
|
@@ -65,8 +66,8 @@
|
|
|
65
66
|
"framer-motion": "^10.16.16",
|
|
66
67
|
"numeral": "^2.0.6",
|
|
67
68
|
"react-countup": "^6.5.0",
|
|
68
|
-
"styled-components": "^
|
|
69
|
-
"valtio": "^1.12.
|
|
69
|
+
"styled-components": "^5.3.0",
|
|
70
|
+
"valtio": "^1.12.0 <2.0.0",
|
|
70
71
|
"viem": "^2.26.2",
|
|
71
72
|
"wagmi": "^2.12.0"
|
|
72
73
|
},
|
|
@@ -75,8 +76,8 @@
|
|
|
75
76
|
"framer-motion": ">=6.0.0",
|
|
76
77
|
"react": "^18.0.0",
|
|
77
78
|
"react-dom": "^18.0.0",
|
|
78
|
-
"styled-components": ">=5.0.0",
|
|
79
|
-
"valtio": ">=1.0.0"
|
|
79
|
+
"styled-components": ">=5.0.0 <6.0.0",
|
|
80
|
+
"valtio": ">=1.0.0 <2.0.0"
|
|
80
81
|
},
|
|
81
82
|
"devDependencies": {
|
|
82
83
|
"@testing-library/jest-dom": "^6.9.1",
|