fare-privy-core 1.7.1 โ 1.7.3
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 +21 -7
- package/dist/PrivyProviderTest.d.ts +13 -0
- package/dist/PrivyProviderTest.d.ts.map +1 -1
- package/dist/PrivyProviderTest.js +38 -0
- package/dist/PrivyProviderTest.js.map +1 -1
- package/dist/hooks/useWallets.d.ts +2 -2
- package/dist/hooks/useWallets.d.ts.map +1 -1
- package/dist/hooks/useWallets.js +98 -53
- package/dist/hooks/useWallets.js.map +1 -1
- package/dist/index.d.ts +19 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
|
|
3
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.7.
|
|
5
|
+
## ๐ Current Features (v1.7.3)
|
|
6
6
|
|
|
7
7
|
- **๐ Real Privy Auth**: Full Privy authentication integration with login/logout
|
|
8
8
|
- **๐ฐ Casino-Ready**: Pre-configured for casino/gaming use cases
|
|
9
9
|
- **โ๏ธ Multi-Chain**: Support for both Ethereum and Solana networks
|
|
10
|
-
-
|
|
10
|
+
- **๐ฐ Native Balance Checking**: Uses Privy's built-in providers for reliable balance fetching (ETH/SOL)
|
|
11
|
+
- **๏ฟฝ Solana Helper Functions**: Easy Solana connector setup with TypeScript compatibility
|
|
11
12
|
- **๏ฟฝ๐ผ Wallet State**: Valtio-based wallet switching state management
|
|
12
13
|
- **๐จ Themeable**: Customize colors and branding per casino
|
|
13
|
-
- **๐ช Complete Hooks**: 5 dependency-free hooks
|
|
14
|
+
- **๐ช Complete Hooks**: 5 dependency-free hooks with improved balance checking
|
|
14
15
|
- **๐ช Login/Logout**: Easy authentication control for casino entry/exit
|
|
15
16
|
- **โก TypeScript**: Full TypeScript support with type declarations
|
|
16
17
|
- **๐งช Tested**: Complete test suite with 17 passing tests
|
|
17
|
-
- **๐ฆ Optimized**: Streamlined codebase
|
|
18
|
+
- **๐ฆ Optimized**: Streamlined codebase using Privy's native infrastructure
|
|
18
19
|
- **๐๏ธ Clean**: Minimal dependencies, focused API
|
|
19
20
|
|
|
20
21
|
## ๐ฆ Installation
|
|
@@ -298,11 +299,24 @@ function WalletBalanceDisplay() {
|
|
|
298
299
|
|
|
299
300
|
๐ **[See complete hook documentation โ](./HOOKS.md)**
|
|
300
301
|
|
|
301
|
-
##
|
|
302
|
+
## ๐ Changelog
|
|
302
303
|
|
|
303
|
-
### v1.7.
|
|
304
|
+
### v1.7.3 (Latest) - Enhanced Balance with Privy Providers
|
|
305
|
+
- **๐ Enhanced**: useWalletBalance now uses Privy's native wallet providers instead of manual RPC calls
|
|
306
|
+
- **โก Improved**: More reliable balance fetching with proper provider integration
|
|
307
|
+
- **๐ง Added**: createSolanaConnectors() and disableSolanaConnectors() helper functions
|
|
308
|
+
- **๐ ๏ธ Fixed**: Solana connector TypeScript compatibility issues
|
|
309
|
+
- **๐งช Tested**: All functionality verified with improved architecture
|
|
310
|
+
- **๐ Documentation**: Updated with balance improvements and new helper functions
|
|
311
|
+
|
|
312
|
+
### v1.7.2
|
|
313
|
+
- **๐ Fixed**: Solana connector configuration with proper TypeScript types
|
|
314
|
+
- **๐ Added**: Helper functions for dynamic Solana connector management
|
|
315
|
+
- **โก Improved**: Error handling for missing Solana wallet adapter packages
|
|
316
|
+
|
|
317
|
+
### v1.7.1
|
|
304
318
|
- **๐ฐ Added**: useWalletBalance hook for native currency balance checking
|
|
305
|
-
- **โ๏ธ Enhanced**: Support for ETH and SOL balance fetching
|
|
319
|
+
- **โ๏ธ Enhanced**: Support for ETH and SOL balance fetching
|
|
306
320
|
- **โก Improved**: Real-time balance updates with loading states and error handling
|
|
307
321
|
- **๐ Added**: Manual balance refresh functionality
|
|
308
322
|
- **๐งช Tested**: All 17 tests passing including new balance functionality
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { type PrivyClientConfig } from "@privy-io/react-auth";
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to create proper Solana wallet configuration
|
|
5
|
+
* Use this to avoid TypeScript errors with Solana connectors
|
|
6
|
+
*/
|
|
7
|
+
export declare const createSolanaConnectors: () => {
|
|
8
|
+
connectors: () => Promise<any[]>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Helper to disable Solana without errors
|
|
12
|
+
*/
|
|
13
|
+
export declare const disableSolanaConnectors: () => {
|
|
14
|
+
connectors: any[];
|
|
15
|
+
};
|
|
3
16
|
export interface PrivyProviderProps {
|
|
4
17
|
children: React.ReactNode;
|
|
5
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
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
|
+
{"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;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;CA2BjC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB;;CAElC,CAAC;AAEH,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"}
|
|
@@ -2,6 +2,44 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { PrivyProvider as _PrivyProvider, } from "@privy-io/react-auth";
|
|
4
4
|
import { SmartWalletsProvider } from "@privy-io/react-auth/smart-wallets";
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to create proper Solana wallet configuration
|
|
7
|
+
* Use this to avoid TypeScript errors with Solana connectors
|
|
8
|
+
*/
|
|
9
|
+
export const createSolanaConnectors = () => ({
|
|
10
|
+
connectors: async () => {
|
|
11
|
+
try {
|
|
12
|
+
// Dynamically import wallet adapters to avoid bundle size issues
|
|
13
|
+
// Users need to install these packages: @solana/wallet-adapter-phantom @solana/wallet-adapter-solflare
|
|
14
|
+
const adapters = [];
|
|
15
|
+
try {
|
|
16
|
+
const { PhantomWalletAdapter } = await import('@solana/wallet-adapter-phantom');
|
|
17
|
+
adapters.push(new PhantomWalletAdapter());
|
|
18
|
+
}
|
|
19
|
+
catch (e) {
|
|
20
|
+
console.warn('PhantomWalletAdapter not available');
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
const { SolflareWalletAdapter } = await import('@solana/wallet-adapter-solflare');
|
|
24
|
+
adapters.push(new SolflareWalletAdapter());
|
|
25
|
+
}
|
|
26
|
+
catch (e) {
|
|
27
|
+
console.warn('SolflareWalletAdapter not available');
|
|
28
|
+
}
|
|
29
|
+
return adapters;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.warn('Failed to load Solana wallet adapters:', error);
|
|
33
|
+
return [];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
/**
|
|
38
|
+
* Helper to disable Solana without errors
|
|
39
|
+
*/
|
|
40
|
+
export const disableSolanaConnectors = () => ({
|
|
41
|
+
connectors: []
|
|
42
|
+
});
|
|
5
43
|
/**
|
|
6
44
|
* Lightweight Privy authentication wrapper for casino applications
|
|
7
45
|
* Compatible with the original farePrivy architecture
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivyProviderTest.js","sourceRoot":"","sources":["../PrivyProviderTest.tsx"],"names":[],"mappings":";AAAA,OAAc,EAAE,OAAO,EAAE,MA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AC,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;IAEjC,8DAA8D;IAC9D,IAAI,mBAAmB,EAAE,CAAC;QACxB,OAAO,CACL,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,YAClE,QAAQ,GACM,CAClB,CAAC;IACJ,CAAC;IAED,0EAA0E;IAC1E,OAAO,CACL,KAAC,cAAc,IAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,YACnE,KAAC,oBAAoB,IAAC,MAAM,EAAE,iBAAiB,YAC5C,QAAQ,GACY,GACR,CAClB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -61,8 +61,8 @@ export declare const useAuthActions: () => {
|
|
|
61
61
|
isAuthenticated: boolean;
|
|
62
62
|
};
|
|
63
63
|
/**
|
|
64
|
-
* Get wallet balances for Ethereum and Solana
|
|
65
|
-
*
|
|
64
|
+
* Get wallet balances for Ethereum and Solana using Privy's built-in providers
|
|
65
|
+
* Much cleaner than manual RPC calls!
|
|
66
66
|
*/
|
|
67
67
|
export declare const useWalletBalance: () => {
|
|
68
68
|
/** Ethereum balance in ETH (formatted to 6 decimals) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWallets.d.ts","sourceRoot":"","sources":["../../hooks/useWallets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAKL,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;
|
|
1
|
+
{"version":3,"file":"useWallets.d.ts","sourceRoot":"","sources":["../../hooks/useWallets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAKL,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;IA2C3B,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;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;IAMvB,yCAAyC;;IAEzC,yCAAyC;;IAEzC,uCAAuC;;IAEvC,8CAA8C;;CAGjD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB;IAuJzB,wDAAwD;;IAExD,sDAAsD;;IAEtD,2CAA2C;;IAE3C,4CAA4C;;IAE5C,gCAAgC;;IAEhC,yCAAyC;;CAG5C,CAAC"}
|
package/dist/hooks/useWallets.js
CHANGED
|
@@ -45,12 +45,39 @@ export const useConnectedWallets = () => {
|
|
|
45
45
|
*/
|
|
46
46
|
export const useWalletAddresses = () => {
|
|
47
47
|
const { connectedWallets } = useConnectedWallets();
|
|
48
|
-
const ethereumAddresses = useMemo(() =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
const ethereumAddresses = useMemo(() => {
|
|
49
|
+
return connectedWallets
|
|
50
|
+
.filter((w) => {
|
|
51
|
+
// Multiple ways to check for Ethereum wallets
|
|
52
|
+
const chainType = w.chainType;
|
|
53
|
+
const walletClientType = w.walletClientType;
|
|
54
|
+
const connectorType = w.connectorType;
|
|
55
|
+
return (chainType === "ethereum" ||
|
|
56
|
+
walletClientType === "ethereum" ||
|
|
57
|
+
connectorType === "embedded" || // Embedded wallets are usually Ethereum
|
|
58
|
+
connectorType === "injected" || // MetaMask, etc.
|
|
59
|
+
!chainType // Default to Ethereum if no chain type specified
|
|
60
|
+
);
|
|
61
|
+
})
|
|
62
|
+
.map((w) => w.address);
|
|
63
|
+
}, [connectedWallets]);
|
|
64
|
+
const solanaAddresses = useMemo(() => {
|
|
65
|
+
return connectedWallets
|
|
66
|
+
.filter((w) => {
|
|
67
|
+
const chainType = w.chainType;
|
|
68
|
+
const walletClientType = w.walletClientType;
|
|
69
|
+
return chainType === "solana" || walletClientType === "solana";
|
|
70
|
+
})
|
|
71
|
+
.map((w) => w.address);
|
|
72
|
+
}, [connectedWallets]);
|
|
73
|
+
// Debug logging
|
|
74
|
+
useEffect(() => {
|
|
75
|
+
if (process.env.NODE_ENV === "development") {
|
|
76
|
+
console.log("[fare-privy-core] Connected wallets:", connectedWallets);
|
|
77
|
+
console.log("[fare-privy-core] Ethereum addresses:", ethereumAddresses);
|
|
78
|
+
console.log("[fare-privy-core] Solana addresses:", solanaAddresses);
|
|
79
|
+
}
|
|
80
|
+
}, [connectedWallets, ethereumAddresses, solanaAddresses]);
|
|
54
81
|
return {
|
|
55
82
|
/** All Ethereum wallet addresses */
|
|
56
83
|
ethereumAddresses,
|
|
@@ -100,94 +127,106 @@ export const useAuthActions = () => {
|
|
|
100
127
|
};
|
|
101
128
|
};
|
|
102
129
|
/**
|
|
103
|
-
* Get wallet balances for Ethereum and Solana
|
|
104
|
-
*
|
|
130
|
+
* Get wallet balances for Ethereum and Solana using Privy's built-in providers
|
|
131
|
+
* Much cleaner than manual RPC calls!
|
|
105
132
|
*/
|
|
106
133
|
export const useWalletBalance = () => {
|
|
107
|
-
const {
|
|
134
|
+
const { wallets } = usePrivyWallets();
|
|
108
135
|
const [balances, setBalances] = useState({
|
|
109
136
|
ethereum: null,
|
|
110
137
|
solana: null,
|
|
111
138
|
loading: false,
|
|
112
139
|
error: null,
|
|
113
140
|
});
|
|
114
|
-
const
|
|
141
|
+
const fetchEthereumBalanceFromWallet = async (wallet) => {
|
|
115
142
|
try {
|
|
116
|
-
// Use
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
method: "eth_getBalance",
|
|
125
|
-
params: [address, "latest"],
|
|
126
|
-
id: 1,
|
|
127
|
-
}),
|
|
143
|
+
// Use Privy's built-in getEthereumProvider method
|
|
144
|
+
const provider = await wallet.getEthereumProvider();
|
|
145
|
+
if (!provider)
|
|
146
|
+
throw new Error("No Ethereum provider available");
|
|
147
|
+
// Use the provider to get balance
|
|
148
|
+
const balanceHex = await provider.request({
|
|
149
|
+
method: "eth_getBalance",
|
|
150
|
+
params: [wallet.address, "latest"],
|
|
128
151
|
});
|
|
129
|
-
const data = await response.json();
|
|
130
|
-
if (data.error)
|
|
131
|
-
throw new Error(data.error.message);
|
|
132
152
|
// Convert from wei to ETH
|
|
133
|
-
const balanceInWei = BigInt(
|
|
153
|
+
const balanceInWei = BigInt(balanceHex);
|
|
134
154
|
const balanceInEth = Number(balanceInWei) / 1e18;
|
|
135
155
|
return balanceInEth.toFixed(6);
|
|
136
156
|
}
|
|
137
157
|
catch (error) {
|
|
138
|
-
console.error("Error fetching Ethereum balance:", error);
|
|
158
|
+
console.error("Error fetching Ethereum balance via Privy provider:", error);
|
|
139
159
|
throw error;
|
|
140
160
|
}
|
|
141
161
|
};
|
|
142
|
-
const
|
|
162
|
+
const fetchSolanaBalanceFromWallet = async (wallet) => {
|
|
143
163
|
try {
|
|
144
|
-
// Use
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
id: 1,
|
|
153
|
-
method: "getBalance",
|
|
154
|
-
params: [address],
|
|
155
|
-
}),
|
|
164
|
+
// Use Privy's built-in getSolanaProvider method
|
|
165
|
+
const provider = await wallet.getSolanaProvider();
|
|
166
|
+
if (!provider)
|
|
167
|
+
throw new Error("No Solana provider available");
|
|
168
|
+
// Get balance using Solana provider
|
|
169
|
+
const response = await provider.request({
|
|
170
|
+
method: "getBalance",
|
|
171
|
+
params: [wallet.address],
|
|
156
172
|
});
|
|
157
|
-
const data = await response.json();
|
|
158
|
-
if (data.error)
|
|
159
|
-
throw new Error(data.error.message);
|
|
160
173
|
// Convert from lamports to SOL
|
|
161
|
-
const balanceInLamports =
|
|
174
|
+
const balanceInLamports = response;
|
|
162
175
|
const balanceInSol = balanceInLamports / 1e9;
|
|
163
176
|
return balanceInSol.toFixed(6);
|
|
164
177
|
}
|
|
165
178
|
catch (error) {
|
|
166
|
-
console.error("Error fetching Solana balance:", error);
|
|
179
|
+
console.error("Error fetching Solana balance via Privy provider:", error);
|
|
167
180
|
throw error;
|
|
168
181
|
}
|
|
169
182
|
};
|
|
170
183
|
const refreshBalances = async () => {
|
|
171
|
-
if (
|
|
184
|
+
if (wallets.length === 0)
|
|
172
185
|
return;
|
|
173
186
|
setBalances((prev) => ({ ...prev, loading: true, error: null }));
|
|
174
187
|
try {
|
|
175
188
|
const promises = [];
|
|
176
|
-
|
|
177
|
-
|
|
189
|
+
// Find Ethereum wallets and get their balances
|
|
190
|
+
const ethereumWallets = wallets.filter((w) => {
|
|
191
|
+
const chainType = w.chainType;
|
|
192
|
+
const connectorType = w.connectorType;
|
|
193
|
+
return (chainType === "ethereum" ||
|
|
194
|
+
connectorType === "embedded" ||
|
|
195
|
+
connectorType === "injected" ||
|
|
196
|
+
!chainType // Default to Ethereum if unclear
|
|
197
|
+
);
|
|
198
|
+
});
|
|
199
|
+
// Find Solana wallets and get their balances
|
|
200
|
+
const solanaWallets = wallets.filter((w) => {
|
|
201
|
+
const chainType = w.chainType;
|
|
202
|
+
return chainType === "solana";
|
|
203
|
+
});
|
|
204
|
+
if (process.env.NODE_ENV === "development") {
|
|
205
|
+
console.log("[fare-privy-core] Found wallets:", {
|
|
206
|
+
total: wallets.length,
|
|
207
|
+
ethereum: ethereumWallets.length,
|
|
208
|
+
solana: solanaWallets.length,
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
// Get Ethereum balance from first Ethereum wallet
|
|
212
|
+
if (ethereumWallets.length > 0) {
|
|
213
|
+
promises.push(fetchEthereumBalanceFromWallet(ethereumWallets[0])
|
|
178
214
|
.then((balance) => {
|
|
179
215
|
setBalances((prev) => ({ ...prev, ethereum: balance }));
|
|
180
216
|
})
|
|
181
217
|
.catch((error) => {
|
|
218
|
+
console.error("Failed to fetch Ethereum balance:", error);
|
|
182
219
|
setBalances((prev) => ({ ...prev, error: error.message }));
|
|
183
220
|
}));
|
|
184
221
|
}
|
|
185
|
-
|
|
186
|
-
|
|
222
|
+
// Get Solana balance from first Solana wallet
|
|
223
|
+
if (solanaWallets.length > 0) {
|
|
224
|
+
promises.push(fetchSolanaBalanceFromWallet(solanaWallets[0])
|
|
187
225
|
.then((balance) => {
|
|
188
226
|
setBalances((prev) => ({ ...prev, solana: balance }));
|
|
189
227
|
})
|
|
190
228
|
.catch((error) => {
|
|
229
|
+
console.error("Failed to fetch Solana balance:", error);
|
|
191
230
|
setBalances((prev) => ({ ...prev, error: error.message }));
|
|
192
231
|
}));
|
|
193
232
|
}
|
|
@@ -203,12 +242,18 @@ export const useWalletBalance = () => {
|
|
|
203
242
|
setBalances((prev) => ({ ...prev, loading: false }));
|
|
204
243
|
}
|
|
205
244
|
};
|
|
206
|
-
// Auto-fetch balances when
|
|
245
|
+
// Auto-fetch balances when wallets change
|
|
207
246
|
useEffect(() => {
|
|
208
|
-
if (
|
|
247
|
+
if (process.env.NODE_ENV === "development") {
|
|
248
|
+
console.log("[fare-privy-core] Wallets changed:", wallets);
|
|
249
|
+
}
|
|
250
|
+
if (wallets.length > 0) {
|
|
251
|
+
if (process.env.NODE_ENV === "development") {
|
|
252
|
+
console.log("[fare-privy-core] Starting balance fetch with Privy providers...");
|
|
253
|
+
}
|
|
209
254
|
refreshBalances();
|
|
210
255
|
}
|
|
211
|
-
}, [
|
|
256
|
+
}, [wallets]);
|
|
212
257
|
return {
|
|
213
258
|
/** Ethereum balance in ETH (formatted to 6 decimals) */
|
|
214
259
|
ethereumBalance: balances.ethereum,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWallets.js","sourceRoot":"","sources":["../../hooks/useWallets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EACL,QAAQ,EACR,UAAU,IAAI,eAAe,EAC7B,QAAQ,EACR,SAAS,GAEV,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,EAAE;QACjC,IAAI,CAAC,KAAK,IAAI,CAAC,aAAa,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAC3E,OAAO,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE7C,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE;QAClC,OAAO,CACL,gBAAgB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM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EAAE,CAAC;YACvB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE,CAAC;gBAC3C,OAAO,CAAC,GAAG,CACT,kEAAkE,CACnE,CAAC;YACJ,CAAC;YACD,eAAe,EAAE,CAAC;QACpB,CAAC;IACH,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IAEd,OAAO;QACL,wDAAwD;QACxD,eAAe,EAAE,QAAQ,CAAC,QAAQ;QAClC,sDAAsD;QACtD,aAAa,EAAE,QAAQ,CAAC,MAAM;QAC9B,2CAA2C;QAC3C,OAAO,EAAE,QAAQ,CAAC,OAAO;QACzB,4CAA4C;QAC5C,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,gCAAgC;QAChC,eAAe;QACf,yCAAyC;QACzC,WAAW,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC;KACtD,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* fare-privy-core - v1.7.
|
|
3
|
-
* This package exports core functionality
|
|
2
|
+
* fare-privy-core - v1.7.3 - Enhanced Balance Checking with Privy Providers
|
|
3
|
+
* This package exports core functionality with improved balance fetching using Privy's native providers.
|
|
4
4
|
*/
|
|
5
|
-
export { PrivyProvider, type PrivyProviderProps } from "./PrivyProviderTest.js";
|
|
5
|
+
export { PrivyProvider, type PrivyProviderProps, createSolanaConnectors, disableSolanaConnectors, } from "./PrivyProviderTest.js";
|
|
6
6
|
export * from "./farePrivy/store/switchWallet.js";
|
|
7
7
|
export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthActions, useWalletBalance, } from "./hooks/useWallets.js";
|
|
8
8
|
/**
|
|
9
|
-
* โ
PRODUCTION READY - v1.7.
|
|
9
|
+
* โ
PRODUCTION READY - v1.7.3:
|
|
10
10
|
*
|
|
11
11
|
* โ
Dependencies: Tightened version constraints for stability
|
|
12
12
|
* โ
Build System: TypeScript compilation working flawlessly
|
|
13
13
|
* โ
Test Suite: Complete coverage with all tests passing
|
|
14
14
|
* โ
Exports: Clean API surface without external app dependencies
|
|
15
|
-
* โ
Balance Checking:
|
|
15
|
+
* โ
Balance Checking: Enhanced with Privy's native wallet providers (ETH/SOL)
|
|
16
|
+
* โ
Solana Support: Helper functions for proper Solana connector configuration
|
|
16
17
|
* โ
Package Size: Ultra-lean - optimized with unnecessary files removed
|
|
17
|
-
* โ
Code Quality:
|
|
18
|
+
* โ
Code Quality: Uses Privy's infrastructure instead of manual RPC calls
|
|
18
19
|
*/
|
|
19
20
|
/**
|
|
20
21
|
* ๐ฆ WHAT'S INCLUDED:
|
|
21
22
|
* โ
PrivyProvider - Real Privy authentication wrapper with Solana/Ethereum support
|
|
23
|
+
* โ
createSolanaConnectors/disableSolanaConnectors - Helper functions for Solana setup
|
|
22
24
|
* โ
Wallet switching store/state management (Valtio)
|
|
23
|
-
* โ
|
|
25
|
+
* โ
Enhanced wallet hooks using Privy's native providers:
|
|
24
26
|
* - useConnectedWallets: Get connected wallets (embedded/external)
|
|
25
27
|
* - useWalletAddresses: Get Ethereum & Solana addresses
|
|
26
28
|
* - useIsAuthenticated: Check authentication status
|
|
27
29
|
* - useAuthActions: Login/logout functions for casino entry
|
|
28
|
-
* - useWalletBalance: Get native currency balances (ETH/SOL)
|
|
30
|
+
* - useWalletBalance: Get native currency balances using Privy providers (ETH/SOL)
|
|
29
31
|
*
|
|
30
32
|
* ๐ก Configuration:
|
|
31
33
|
* Users should provide their own Privy configuration.
|
|
@@ -40,15 +42,21 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
40
42
|
* useWalletAddresses,
|
|
41
43
|
* useIsAuthenticated,
|
|
42
44
|
* useAuthActions,
|
|
43
|
-
* useWalletBalance
|
|
45
|
+
* useWalletBalance,
|
|
46
|
+
* disableSolanaConnectors // Helper to fix Solana connector errors
|
|
44
47
|
* } from 'fare-privy-core';
|
|
45
48
|
*
|
|
46
|
-
* // 1. Wrap your app
|
|
49
|
+
* // 1. Wrap your app (Ethereum only - recommended)
|
|
47
50
|
* function App() {
|
|
48
51
|
* return (
|
|
49
52
|
* <PrivyProvider
|
|
50
53
|
* appId="your-privy-app-id"
|
|
51
|
-
* config={{
|
|
54
|
+
* config={{
|
|
55
|
+
* walletChainType: 'ethereum-only',
|
|
56
|
+
* externalWallets: {
|
|
57
|
+
* solana: disableSolanaConnectors() // Prevents Solana errors
|
|
58
|
+
* }
|
|
59
|
+
* }}
|
|
52
60
|
* >
|
|
53
61
|
* <YourCasino />
|
|
54
62
|
* </PrivyProvider>
|
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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,EACvB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAGhC,cAAc,mCAAmC,CAAC;AAGlD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAK/B;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG"}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* fare-privy-core - v1.7.
|
|
3
|
-
* This package exports core functionality
|
|
2
|
+
* fare-privy-core - v1.7.3 - Enhanced Balance Checking with Privy Providers
|
|
3
|
+
* This package exports core functionality with improved balance fetching using Privy's native providers.
|
|
4
4
|
*/
|
|
5
5
|
// โ
CURRENT EXPORTS - Available Now
|
|
6
|
-
export { PrivyProvider } from "./PrivyProviderTest.js";
|
|
6
|
+
export { PrivyProvider, createSolanaConnectors, disableSolanaConnectors, } from "./PrivyProviderTest.js";
|
|
7
7
|
// โ
CORE FUNCTIONALITY - Working exports
|
|
8
8
|
export * from "./farePrivy/store/switchWallet.js";
|
|
9
9
|
// โ
SIMPLIFIED WALLET HOOKS - No external dependencies!
|
|
@@ -11,26 +11,28 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
11
11
|
// โ REMOVED - Had too many external dependencies
|
|
12
12
|
// export * from "./farePrivy/modals/index.js";
|
|
13
13
|
/**
|
|
14
|
-
* โ
PRODUCTION READY - v1.7.
|
|
14
|
+
* โ
PRODUCTION READY - v1.7.3:
|
|
15
15
|
*
|
|
16
16
|
* โ
Dependencies: Tightened version constraints for stability
|
|
17
17
|
* โ
Build System: TypeScript compilation working flawlessly
|
|
18
18
|
* โ
Test Suite: Complete coverage with all tests passing
|
|
19
19
|
* โ
Exports: Clean API surface without external app dependencies
|
|
20
|
-
* โ
Balance Checking:
|
|
20
|
+
* โ
Balance Checking: Enhanced with Privy's native wallet providers (ETH/SOL)
|
|
21
|
+
* โ
Solana Support: Helper functions for proper Solana connector configuration
|
|
21
22
|
* โ
Package Size: Ultra-lean - optimized with unnecessary files removed
|
|
22
|
-
* โ
Code Quality:
|
|
23
|
+
* โ
Code Quality: Uses Privy's infrastructure instead of manual RPC calls
|
|
23
24
|
*/
|
|
24
25
|
/**
|
|
25
26
|
* ๐ฆ WHAT'S INCLUDED:
|
|
26
27
|
* โ
PrivyProvider - Real Privy authentication wrapper with Solana/Ethereum support
|
|
28
|
+
* โ
createSolanaConnectors/disableSolanaConnectors - Helper functions for Solana setup
|
|
27
29
|
* โ
Wallet switching store/state management (Valtio)
|
|
28
|
-
* โ
|
|
30
|
+
* โ
Enhanced wallet hooks using Privy's native providers:
|
|
29
31
|
* - useConnectedWallets: Get connected wallets (embedded/external)
|
|
30
32
|
* - useWalletAddresses: Get Ethereum & Solana addresses
|
|
31
33
|
* - useIsAuthenticated: Check authentication status
|
|
32
34
|
* - useAuthActions: Login/logout functions for casino entry
|
|
33
|
-
* - useWalletBalance: Get native currency balances (ETH/SOL)
|
|
35
|
+
* - useWalletBalance: Get native currency balances using Privy providers (ETH/SOL)
|
|
34
36
|
*
|
|
35
37
|
* ๐ก Configuration:
|
|
36
38
|
* Users should provide their own Privy configuration.
|
|
@@ -45,15 +47,21 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
45
47
|
* useWalletAddresses,
|
|
46
48
|
* useIsAuthenticated,
|
|
47
49
|
* useAuthActions,
|
|
48
|
-
* useWalletBalance
|
|
50
|
+
* useWalletBalance,
|
|
51
|
+
* disableSolanaConnectors // Helper to fix Solana connector errors
|
|
49
52
|
* } from 'fare-privy-core';
|
|
50
53
|
*
|
|
51
|
-
* // 1. Wrap your app
|
|
54
|
+
* // 1. Wrap your app (Ethereum only - recommended)
|
|
52
55
|
* function App() {
|
|
53
56
|
* return (
|
|
54
57
|
* <PrivyProvider
|
|
55
58
|
* appId="your-privy-app-id"
|
|
56
|
-
* config={{
|
|
59
|
+
* config={{
|
|
60
|
+
* walletChainType: 'ethereum-only',
|
|
61
|
+
* externalWallets: {
|
|
62
|
+
* solana: disableSolanaConnectors() // Prevents Solana errors
|
|
63
|
+
* }
|
|
64
|
+
* }}
|
|
57
65
|
* >
|
|
58
66
|
* <YourCasino />
|
|
59
67
|
* </PrivyProvider>
|
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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,oCAAoC;AACpC,OAAO,EACL,aAAa,EAEb,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,wBAAwB,CAAC;AAEhC,yCAAyC;AACzC,cAAc,mCAAmC,CAAC;AAElD,wDAAwD;AACxD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,iDAAiD;AACjD,+CAA+C;AAE/C;;;;;;;;;;;GAWG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0DG"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fare-privy-core",
|
|
3
|
-
"version": "1.7.
|
|
4
|
-
"description": "A comprehensive React library for Privy authentication and wallet management with casino gaming features
|
|
3
|
+
"version": "1.7.3",
|
|
4
|
+
"description": "A comprehensive React library for Privy authentication and wallet management with casino gaming features, now with improved balance checking using Privy's native providers",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"privy",
|
|
7
7
|
"wallet",
|