fare-privy-core 1.5.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 CHANGED
@@ -2,18 +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.5.0)
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
- - **๐Ÿ’ผ Wallet State**: Valtio-based wallet switching state management
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**: 4 dependency-free hooks including auth actions
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
- - **๐Ÿงช Tested**: Complete test suite
16
- - **๐Ÿ“ฆ Lightweight**: Minimal dependencies, focused API
16
+ - **๐Ÿงช Tested**: Complete test suite with 17 passing tests
17
+ - **๐Ÿ“ฆ Optimized**: Streamlined codebase with unused files removed
18
+ - **๐Ÿ—‚๏ธ Clean**: Minimal dependencies, focused API
17
19
 
18
20
  ## ๐Ÿ“ฆ Installation
19
21
 
@@ -44,7 +46,8 @@ npm install fare-privy-core @privy-io/react-auth styled-components@^5.3.0 valtio
44
46
  import {
45
47
  PrivyProvider,
46
48
  useConnectedWallets,
47
- useIsAuthenticated
49
+ useIsAuthenticated,
50
+ useWalletBalance
48
51
  } from 'fare-privy-core';
49
52
 
50
53
  function App() {
@@ -266,9 +269,60 @@ function ProtectedGame() {
266
269
  }
267
270
  ```
268
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
+
269
299
  ๐Ÿ“– **[See complete hook documentation โ†’](./HOOKS.md)**
270
300
 
271
- ## ๐Ÿ“š API Reference
301
+ ## ๏ฟฝ Changelog
302
+
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
311
+ - **๐Ÿ—‚๏ธ Optimized**: Removed unused files and dependencies
312
+ - **๐Ÿงน Cleaned**: Streamlined codebase for better performance
313
+ - **๐Ÿ“ฆ Smaller**: Reduced package bloat while maintaining all functionality
314
+ - **โœ… Tested**: All 17 tests passing after cleanup
315
+ - **๐Ÿ”ง Fixed**: Resolved circular import issues in useWallets.ts
316
+
317
+ ### v1.5.0
318
+ - **๐Ÿช Added**: useAuthActions hook for login/logout control
319
+ - **๐Ÿšช Enhanced**: Complete authentication management for casino apps
320
+
321
+ ### v1.4.0
322
+ - **๐ŸŽฐ Added**: Four dependency-free wallet hooks
323
+ - **๐Ÿ”— Enhanced**: Multi-chain support for Ethereum and Solana
324
+
325
+ ## ๏ฟฝ๐Ÿ“š API Reference
272
326
 
273
327
  ### PrivyProvider
274
328
 
@@ -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"}
@@ -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,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AW,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,CAAC;KACtD,CAAC;AACJ,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,18 +1,20 @@
1
1
  /**
2
- * fare-privy-core - v1.5.0 - Streamlined Package
2
+ * fare-privy-core - v1.6.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, useAuthActions, } from "./hooks/useWallets.js";
7
+ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthActions, useWalletBalance, } from "./hooks/useWallets.js";
8
8
  /**
9
- * โœ… PRODUCTION READY - v1.4.0:
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
- * โœ… Package Size: Ultra-lean - removed all UI components with external dependencies
15
+ * โœ… Balance Checking: Native currency balance fetching for ETH/SOL
16
+ * โœ… Package Size: Ultra-lean - optimized with unnecessary files removed
17
+ * โœ… Code Quality: Cleaned up unused dependencies and components
16
18
  */
17
19
  /**
18
20
  * ๐Ÿ“ฆ WHAT'S INCLUDED:
@@ -23,6 +25,7 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
23
25
  * - useWalletAddresses: Get Ethereum & Solana addresses
24
26
  * - useIsAuthenticated: Check authentication status
25
27
  * - useAuthActions: Login/logout functions for casino entry
28
+ * - useWalletBalance: Get native currency balances (ETH/SOL)
26
29
  *
27
30
  * ๐Ÿ’ก Configuration:
28
31
  * Users should provide their own Privy configuration.
@@ -36,7 +39,8 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
36
39
  * useConnectedWallets,
37
40
  * useWalletAddresses,
38
41
  * useIsAuthenticated,
39
- * useAuthActions
42
+ * useAuthActions,
43
+ * useWalletBalance
40
44
  * } from 'fare-privy-core';
41
45
  *
42
46
  * // 1. Wrap your app
@@ -57,6 +61,7 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
57
61
  * const { primarySolanaAddress } = useWalletAddresses();
58
62
  * const { isAuthenticated } = useIsAuthenticated();
59
63
  * const { login, logout } = useAuthActions();
64
+ * const { ethereumBalance, solanaBalance, loading } = useWalletBalance();
60
65
  *
61
66
  * if (!isAuthenticated) {
62
67
  * return <button onClick={login}>๐ŸŽฐ Enter Casino</button>;
@@ -65,6 +70,14 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
65
70
  * return (
66
71
  * <div>
67
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
+ * )}
68
81
  * <button onClick={logout}>Exit</button>
69
82
  * </div>
70
83
  * );
@@ -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,GACf,MAAM,uBAAuB,CAAC;AAK/B;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG"}
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
@@ -1,5 +1,5 @@
1
1
  /**
2
- * fare-privy-core - v1.5.0 - Streamlined Package
2
+ * fare-privy-core - v1.6.0 - Streamlined Package
3
3
  * This package exports core functionality without external app dependencies.
4
4
  */
5
5
  // โœ… CURRENT EXPORTS - Available Now
@@ -7,17 +7,19 @@ 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.4.0:
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
- * โœ… Package Size: Ultra-lean - removed all UI components with external dependencies
20
+ * โœ… Balance Checking: Native currency balance fetching for ETH/SOL
21
+ * โœ… Package Size: Ultra-lean - optimized with unnecessary files removed
22
+ * โœ… Code Quality: Cleaned up unused dependencies and components
21
23
  */
22
24
  /**
23
25
  * ๐Ÿ“ฆ WHAT'S INCLUDED:
@@ -28,6 +30,7 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
28
30
  * - useWalletAddresses: Get Ethereum & Solana addresses
29
31
  * - useIsAuthenticated: Check authentication status
30
32
  * - useAuthActions: Login/logout functions for casino entry
33
+ * - useWalletBalance: Get native currency balances (ETH/SOL)
31
34
  *
32
35
  * ๐Ÿ’ก Configuration:
33
36
  * Users should provide their own Privy configuration.
@@ -41,7 +44,8 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
41
44
  * useConnectedWallets,
42
45
  * useWalletAddresses,
43
46
  * useIsAuthenticated,
44
- * useAuthActions
47
+ * useAuthActions,
48
+ * useWalletBalance
45
49
  * } from 'fare-privy-core';
46
50
  *
47
51
  * // 1. Wrap your app
@@ -62,6 +66,7 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
62
66
  * const { primarySolanaAddress } = useWalletAddresses();
63
67
  * const { isAuthenticated } = useIsAuthenticated();
64
68
  * const { login, logout } = useAuthActions();
69
+ * const { ethereumBalance, solanaBalance, loading } = useWalletBalance();
65
70
  *
66
71
  * if (!isAuthenticated) {
67
72
  * return <button onClick={login}>๐ŸŽฐ Enter Casino</button>;
@@ -70,6 +75,14 @@ export { useConnectedWallets, useWalletAddresses, useIsAuthenticated, useAuthAct
70
75
  * return (
71
76
  * <div>
72
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
+ * )}
73
86
  * <button onClick={logout}>Exit</button>
74
87
  * </div>
75
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,GACf,MAAM,uBAAuB,CAAC;AAE/B,iDAAiD;AACjD,+CAA+C;AAE/C;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG"}
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.5.0",
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",