fare-privy-core 1.6.0 โ 1.7.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 +42 -6
- package/dist/hooks/useWallets.d.ts +18 -0
- package/dist/hooks/useWallets.d.ts.map +1 -1
- package/dist/hooks/useWallets.js +126 -1
- package/dist/hooks/useWallets.js.map +1 -1
- package/dist/index.d.ts +15 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,14 +2,15 @@
|
|
|
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.
|
|
5
|
+
## ๐ Current Features (v1.7.0)
|
|
6
6
|
|
|
7
7
|
- **๐ Real Privy Auth**: Full Privy authentication integration with login/logout
|
|
8
|
-
- **๐ฐ Casino-Ready**: Pre-configured for casino/gaming use cases
|
|
8
|
+
- **๐ฐ Casino-Ready**: Pre-configured for casino/gaming use cases
|
|
9
9
|
- **โ๏ธ Multi-Chain**: Support for both Ethereum and Solana networks
|
|
10
|
-
-
|
|
10
|
+
- **๏ฟฝ Balance Checking**: Native currency balance fetching (ETH/SOL)
|
|
11
|
+
- **๏ฟฝ๐ผ Wallet State**: Valtio-based wallet switching state management
|
|
11
12
|
- **๐จ Themeable**: Customize colors and branding per casino
|
|
12
|
-
- **๐ช Complete Hooks**:
|
|
13
|
+
- **๐ช Complete Hooks**: 5 dependency-free hooks including balance checking
|
|
13
14
|
- **๐ช Login/Logout**: Easy authentication control for casino entry/exit
|
|
14
15
|
- **โก TypeScript**: Full TypeScript support with type declarations
|
|
15
16
|
- **๐งช Tested**: Complete test suite with 17 passing tests
|
|
@@ -45,7 +46,8 @@ npm install fare-privy-core @privy-io/react-auth styled-components@^5.3.0 valtio
|
|
|
45
46
|
import {
|
|
46
47
|
PrivyProvider,
|
|
47
48
|
useConnectedWallets,
|
|
48
|
-
useIsAuthenticated
|
|
49
|
+
useIsAuthenticated,
|
|
50
|
+
useWalletBalance
|
|
49
51
|
} from 'fare-privy-core';
|
|
50
52
|
|
|
51
53
|
function App() {
|
|
@@ -267,11 +269,45 @@ function ProtectedGame() {
|
|
|
267
269
|
}
|
|
268
270
|
```
|
|
269
271
|
|
|
272
|
+
### `useWalletBalance()` - Get native currency balances
|
|
273
|
+
|
|
274
|
+
```tsx
|
|
275
|
+
import { useWalletBalance } from 'fare-privy-core';
|
|
276
|
+
|
|
277
|
+
function WalletBalanceDisplay() {
|
|
278
|
+
const {
|
|
279
|
+
ethereumBalance,
|
|
280
|
+
solanaBalance,
|
|
281
|
+
loading,
|
|
282
|
+
error,
|
|
283
|
+
refreshBalances
|
|
284
|
+
} = useWalletBalance();
|
|
285
|
+
|
|
286
|
+
if (loading) return <div>Loading balances...</div>;
|
|
287
|
+
if (error) return <div>Error: {error}</div>;
|
|
288
|
+
|
|
289
|
+
return (
|
|
290
|
+
<div>
|
|
291
|
+
<p>ETH Balance: {ethereumBalance || "0.00"} ETH</p>
|
|
292
|
+
<p>SOL Balance: {solanaBalance || "0.00"} SOL</p>
|
|
293
|
+
<button onClick={refreshBalances}>Refresh</button>
|
|
294
|
+
</div>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
```
|
|
298
|
+
|
|
270
299
|
๐ **[See complete hook documentation โ](./HOOKS.md)**
|
|
271
300
|
|
|
272
301
|
## ๏ฟฝ Changelog
|
|
273
302
|
|
|
274
|
-
### v1.
|
|
303
|
+
### v1.7.0 (Latest)
|
|
304
|
+
- **๐ฐ Added**: useWalletBalance hook for native currency balance checking
|
|
305
|
+
- **โ๏ธ Enhanced**: Support for ETH and SOL balance fetching via RPC calls
|
|
306
|
+
- **โก Improved**: Real-time balance updates with loading states and error handling
|
|
307
|
+
- **๐ Added**: Manual balance refresh functionality
|
|
308
|
+
- **๐งช Tested**: All 17 tests passing including new balance functionality
|
|
309
|
+
|
|
310
|
+
### v1.6.0
|
|
275
311
|
- **๐๏ธ Optimized**: Removed unused files and dependencies
|
|
276
312
|
- **๐งน Cleaned**: Streamlined codebase for better performance
|
|
277
313
|
- **๐ฆ Smaller**: Reduced package bloat while maintaining all functionality
|
|
@@ -60,4 +60,22 @@ export declare const useAuthActions: () => {
|
|
|
60
60
|
/** Whether user is currently authenticated */
|
|
61
61
|
isAuthenticated: boolean;
|
|
62
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Get wallet balances for Ethereum and Solana
|
|
65
|
+
* Fetches native currency balances (ETH, SOL)
|
|
66
|
+
*/
|
|
67
|
+
export declare const useWalletBalance: () => {
|
|
68
|
+
/** Ethereum balance in ETH (formatted to 6 decimals) */
|
|
69
|
+
ethereumBalance: string;
|
|
70
|
+
/** Solana balance in SOL (formatted to 6 decimals) */
|
|
71
|
+
solanaBalance: string;
|
|
72
|
+
/** Whether balance fetch is in progress */
|
|
73
|
+
loading: boolean;
|
|
74
|
+
/** Error message if balance fetch failed */
|
|
75
|
+
error: string;
|
|
76
|
+
/** Manually refresh balances */
|
|
77
|
+
refreshBalances: () => Promise<void>;
|
|
78
|
+
/** Whether any balances are available */
|
|
79
|
+
hasBalances: boolean;
|
|
80
|
+
};
|
|
63
81
|
//# sourceMappingURL=useWallets.d.ts.map
|
|
@@ -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;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;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;IAMvB,yCAAyC;;IAEzC,yCAAyC;;IAEzC,uCAAuC;;IAEvC,8CAA8C;;CAGjD,CAAC"}
|
|
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;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;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc;IAMvB,yCAAyC;;IAEzC,yCAAyC;;IAEzC,uCAAuC;;IAEvC,8CAA8C;;CAGjD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB;IA2HzB,wDAAwD;;IAExD,sDAAsD;;IAEtD,2CAA2C;;IAE3C,4CAA4C;;IAE5C,gCAAgC;;IAEhC,yCAAyC;;CAG5C,CAAC"}
|
package/dist/hooks/useWallets.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Simplified wallet hooks for casino clients
|
|
3
3
|
* No external dependencies - ready to use!
|
|
4
4
|
*/
|
|
5
|
-
import { useMemo } from "react";
|
|
5
|
+
import { useMemo, useState, useEffect } from "react";
|
|
6
6
|
import { usePrivy, useWallets as usePrivyWallets, useLogin, useLogout, } from "@privy-io/react-auth";
|
|
7
7
|
/**
|
|
8
8
|
* Get active/connected wallets
|
|
@@ -99,4 +99,129 @@ export const useAuthActions = () => {
|
|
|
99
99
|
isAuthenticated: authenticated,
|
|
100
100
|
};
|
|
101
101
|
};
|
|
102
|
+
/**
|
|
103
|
+
* Get wallet balances for Ethereum and Solana
|
|
104
|
+
* Fetches native currency balances (ETH, SOL)
|
|
105
|
+
*/
|
|
106
|
+
export const useWalletBalance = () => {
|
|
107
|
+
const { primaryEthereumAddress, primarySolanaAddress } = useWalletAddresses();
|
|
108
|
+
const [balances, setBalances] = useState({
|
|
109
|
+
ethereum: null,
|
|
110
|
+
solana: null,
|
|
111
|
+
loading: false,
|
|
112
|
+
error: null,
|
|
113
|
+
});
|
|
114
|
+
const fetchEthereumBalance = async (address) => {
|
|
115
|
+
try {
|
|
116
|
+
// Use a public RPC endpoint for Ethereum mainnet
|
|
117
|
+
const response = await fetch("https://eth.llamarpc.com", {
|
|
118
|
+
method: "POST",
|
|
119
|
+
headers: {
|
|
120
|
+
"Content-Type": "application/json",
|
|
121
|
+
},
|
|
122
|
+
body: JSON.stringify({
|
|
123
|
+
jsonrpc: "2.0",
|
|
124
|
+
method: "eth_getBalance",
|
|
125
|
+
params: [address, "latest"],
|
|
126
|
+
id: 1,
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
129
|
+
const data = await response.json();
|
|
130
|
+
if (data.error)
|
|
131
|
+
throw new Error(data.error.message);
|
|
132
|
+
// Convert from wei to ETH
|
|
133
|
+
const balanceInWei = BigInt(data.result);
|
|
134
|
+
const balanceInEth = Number(balanceInWei) / 1e18;
|
|
135
|
+
return balanceInEth.toFixed(6);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.error("Error fetching Ethereum balance:", error);
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
const fetchSolanaBalance = async (address) => {
|
|
143
|
+
try {
|
|
144
|
+
// Use a public RPC endpoint for Solana mainnet
|
|
145
|
+
const response = await fetch("https://api.mainnet-beta.solana.com", {
|
|
146
|
+
method: "POST",
|
|
147
|
+
headers: {
|
|
148
|
+
"Content-Type": "application/json",
|
|
149
|
+
},
|
|
150
|
+
body: JSON.stringify({
|
|
151
|
+
jsonrpc: "2.0",
|
|
152
|
+
id: 1,
|
|
153
|
+
method: "getBalance",
|
|
154
|
+
params: [address],
|
|
155
|
+
}),
|
|
156
|
+
});
|
|
157
|
+
const data = await response.json();
|
|
158
|
+
if (data.error)
|
|
159
|
+
throw new Error(data.error.message);
|
|
160
|
+
// Convert from lamports to SOL
|
|
161
|
+
const balanceInLamports = data.result.value;
|
|
162
|
+
const balanceInSol = balanceInLamports / 1e9;
|
|
163
|
+
return balanceInSol.toFixed(6);
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
console.error("Error fetching Solana balance:", error);
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const refreshBalances = async () => {
|
|
171
|
+
if (!primaryEthereumAddress && !primarySolanaAddress)
|
|
172
|
+
return;
|
|
173
|
+
setBalances((prev) => ({ ...prev, loading: true, error: null }));
|
|
174
|
+
try {
|
|
175
|
+
const promises = [];
|
|
176
|
+
if (primaryEthereumAddress) {
|
|
177
|
+
promises.push(fetchEthereumBalance(primaryEthereumAddress)
|
|
178
|
+
.then((balance) => {
|
|
179
|
+
setBalances((prev) => ({ ...prev, ethereum: balance }));
|
|
180
|
+
})
|
|
181
|
+
.catch((error) => {
|
|
182
|
+
setBalances((prev) => ({ ...prev, error: error.message }));
|
|
183
|
+
}));
|
|
184
|
+
}
|
|
185
|
+
if (primarySolanaAddress) {
|
|
186
|
+
promises.push(fetchSolanaBalance(primarySolanaAddress)
|
|
187
|
+
.then((balance) => {
|
|
188
|
+
setBalances((prev) => ({ ...prev, solana: balance }));
|
|
189
|
+
})
|
|
190
|
+
.catch((error) => {
|
|
191
|
+
setBalances((prev) => ({ ...prev, error: error.message }));
|
|
192
|
+
}));
|
|
193
|
+
}
|
|
194
|
+
await Promise.allSettled(promises);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
setBalances((prev) => ({
|
|
198
|
+
...prev,
|
|
199
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
200
|
+
}));
|
|
201
|
+
}
|
|
202
|
+
finally {
|
|
203
|
+
setBalances((prev) => ({ ...prev, loading: false }));
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
// Auto-fetch balances when addresses change
|
|
207
|
+
useEffect(() => {
|
|
208
|
+
if (primaryEthereumAddress || primarySolanaAddress) {
|
|
209
|
+
refreshBalances();
|
|
210
|
+
}
|
|
211
|
+
}, [primaryEthereumAddress, primarySolanaAddress]);
|
|
212
|
+
return {
|
|
213
|
+
/** Ethereum balance in ETH (formatted to 6 decimals) */
|
|
214
|
+
ethereumBalance: balances.ethereum,
|
|
215
|
+
/** Solana balance in SOL (formatted to 6 decimals) */
|
|
216
|
+
solanaBalance: balances.solana,
|
|
217
|
+
/** Whether balance fetch is in progress */
|
|
218
|
+
loading: balances.loading,
|
|
219
|
+
/** Error message if balance fetch failed */
|
|
220
|
+
error: balances.error,
|
|
221
|
+
/** Manually refresh balances */
|
|
222
|
+
refreshBalances,
|
|
223
|
+
/** Whether any balances are available */
|
|
224
|
+
hasBalances: !!(balances.ethereum || balances.solana),
|
|
225
|
+
};
|
|
226
|
+
};
|
|
102
227
|
//# sourceMappingURL=useWallets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWallets.js","sourceRoot":"","sources":["../../hooks/useWallets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3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sBAAsB,IAAI,oBAAoB,EAAE,CAAC;YACnD,eAAe,EAAE,CAAC;QACpB,CAAC;IACH,CAAC,EAAE,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAEnD,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
|
@@ -4,14 +4,15 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export { PrivyProvider, type PrivyProviderProps } from "./PrivyProviderTest.js";
|
|
6
6
|
export * from "./farePrivy/store/switchWallet.js";
|
|
7
|
-
export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthActions, } from "./hooks/useWallets.js";
|
|
7
|
+
export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthActions, useWalletBalance, } from "./hooks/useWallets.js";
|
|
8
8
|
/**
|
|
9
|
-
* โ
PRODUCTION READY - v1.
|
|
9
|
+
* โ
PRODUCTION READY - v1.7.0:
|
|
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: Native currency balance fetching for ETH/SOL
|
|
15
16
|
* โ
Package Size: Ultra-lean - optimized with unnecessary files removed
|
|
16
17
|
* โ
Code Quality: Cleaned up unused dependencies and components
|
|
17
18
|
*/
|
|
@@ -24,6 +25,7 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
24
25
|
* - useWalletAddresses: Get Ethereum & Solana addresses
|
|
25
26
|
* - useIsAuthenticated: Check authentication status
|
|
26
27
|
* - useAuthActions: Login/logout functions for casino entry
|
|
28
|
+
* - useWalletBalance: Get native currency balances (ETH/SOL)
|
|
27
29
|
*
|
|
28
30
|
* ๐ก Configuration:
|
|
29
31
|
* Users should provide their own Privy configuration.
|
|
@@ -37,7 +39,8 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
37
39
|
* useConnectedWallets,
|
|
38
40
|
* useWalletAddresses,
|
|
39
41
|
* useIsAuthenticated,
|
|
40
|
-
* useAuthActions
|
|
42
|
+
* useAuthActions,
|
|
43
|
+
* useWalletBalance
|
|
41
44
|
* } from 'fare-privy-core';
|
|
42
45
|
*
|
|
43
46
|
* // 1. Wrap your app
|
|
@@ -58,6 +61,7 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
58
61
|
* const { primarySolanaAddress } = useWalletAddresses();
|
|
59
62
|
* const { isAuthenticated } = useIsAuthenticated();
|
|
60
63
|
* const { login, logout } = useAuthActions();
|
|
64
|
+
* const { ethereumBalance, solanaBalance, loading } = useWalletBalance();
|
|
61
65
|
*
|
|
62
66
|
* if (!isAuthenticated) {
|
|
63
67
|
* return <button onClick={login}>๐ฐ Enter Casino</button>;
|
|
@@ -66,6 +70,14 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
66
70
|
* return (
|
|
67
71
|
* <div>
|
|
68
72
|
* <span>Welcome {primaryWallet?.address}</span>
|
|
73
|
+
* {loading ? (
|
|
74
|
+
* <span>Loading balance...</span>
|
|
75
|
+
* ) : (
|
|
76
|
+
* <div>
|
|
77
|
+
* {solanaBalance && <span>SOL: {solanaBalance}</span>}
|
|
78
|
+
* {ethereumBalance && <span>ETH: {ethereumBalance}</span>}
|
|
79
|
+
* </div>
|
|
80
|
+
* )}
|
|
69
81
|
* <button onClick={logout}>Exit</button>
|
|
70
82
|
* </div>
|
|
71
83
|
* );
|
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;AAGlD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,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,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAK/B;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG"}
|
package/dist/index.js
CHANGED
|
@@ -7,16 +7,17 @@ export { PrivyProvider } 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!
|
|
10
|
-
export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthActions, } from "./hooks/useWallets.js";
|
|
10
|
+
export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthActions, useWalletBalance, } from "./hooks/useWallets.js";
|
|
11
11
|
// โ REMOVED - Had too many external dependencies
|
|
12
12
|
// export * from "./farePrivy/modals/index.js";
|
|
13
13
|
/**
|
|
14
|
-
* โ
PRODUCTION READY - v1.
|
|
14
|
+
* โ
PRODUCTION READY - v1.7.0:
|
|
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: Native currency balance fetching for ETH/SOL
|
|
20
21
|
* โ
Package Size: Ultra-lean - optimized with unnecessary files removed
|
|
21
22
|
* โ
Code Quality: Cleaned up unused dependencies and components
|
|
22
23
|
*/
|
|
@@ -29,6 +30,7 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
29
30
|
* - useWalletAddresses: Get Ethereum & Solana addresses
|
|
30
31
|
* - useIsAuthenticated: Check authentication status
|
|
31
32
|
* - useAuthActions: Login/logout functions for casino entry
|
|
33
|
+
* - useWalletBalance: Get native currency balances (ETH/SOL)
|
|
32
34
|
*
|
|
33
35
|
* ๐ก Configuration:
|
|
34
36
|
* Users should provide their own Privy configuration.
|
|
@@ -42,7 +44,8 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
42
44
|
* useConnectedWallets,
|
|
43
45
|
* useWalletAddresses,
|
|
44
46
|
* useIsAuthenticated,
|
|
45
|
-
* useAuthActions
|
|
47
|
+
* useAuthActions,
|
|
48
|
+
* useWalletBalance
|
|
46
49
|
* } from 'fare-privy-core';
|
|
47
50
|
*
|
|
48
51
|
* // 1. Wrap your app
|
|
@@ -63,6 +66,7 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
63
66
|
* const { primarySolanaAddress } = useWalletAddresses();
|
|
64
67
|
* const { isAuthenticated } = useIsAuthenticated();
|
|
65
68
|
* const { login, logout } = useAuthActions();
|
|
69
|
+
* const { ethereumBalance, solanaBalance, loading } = useWalletBalance();
|
|
66
70
|
*
|
|
67
71
|
* if (!isAuthenticated) {
|
|
68
72
|
* return <button onClick={login}>๐ฐ Enter Casino</button>;
|
|
@@ -71,6 +75,14 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
|
|
|
71
75
|
* return (
|
|
72
76
|
* <div>
|
|
73
77
|
* <span>Welcome {primaryWallet?.address}</span>
|
|
78
|
+
* {loading ? (
|
|
79
|
+
* <span>Loading balance...</span>
|
|
80
|
+
* ) : (
|
|
81
|
+
* <div>
|
|
82
|
+
* {solanaBalance && <span>SOL: {solanaBalance}</span>}
|
|
83
|
+
* {ethereumBalance && <span>ETH: {ethereumBalance}</span>}
|
|
84
|
+
* </div>
|
|
85
|
+
* )}
|
|
74
86
|
* <button onClick={logout}>Exit</button>
|
|
75
87
|
* </div>
|
|
76
88
|
* );
|
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,wDAAwD;AACxD,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,
|
|
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,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,iDAAiD;AACjD,+CAA+C;AAE/C;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;;;GAcG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fare-privy-core",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "A comprehensive React library for Privy authentication and wallet management with casino gaming features",
|
|
3
|
+
"version": "1.7.0",
|
|
4
|
+
"description": "A comprehensive React library for Privy authentication and wallet management with casino gaming features including balance checking",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"privy",
|
|
7
7
|
"wallet",
|