fare-privy-core 1.7.7 โ 1.7.8
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 +23 -26
- package/dist/PrivyProviderTest.d.ts +1 -1
- package/dist/PrivyProviderTest.d.ts.map +1 -1
- package/dist/PrivyProviderTest.js +43 -9
- package/dist/PrivyProviderTest.js.map +1 -1
- package/dist/hooks/useActiveWallet.d.ts +10 -5
- package/dist/hooks/useActiveWallet.d.ts.map +1 -1
- package/dist/hooks/useActiveWallet.js +23 -5
- package/dist/hooks/useActiveWallet.js.map +1 -1
- package/dist/hooks/useConnectedWallets.d.ts +2 -2
- package/dist/hooks/useConnectedWallets.d.ts.map +1 -1
- package/dist/hooks/useConnectedWallets.js +10 -10
- package/dist/hooks/useConnectedWallets.js.map +1 -1
- package/dist/hooks/useIsAuthenticated.js +3 -3
- package/dist/hooks/useIsAuthenticated.js.map +1 -1
- package/dist/hooks/useWalletAddresses.d.ts.map +1 -1
- package/dist/hooks/useWalletAddresses.js +18 -21
- package/dist/hooks/useWalletAddresses.js.map +1 -1
- package/dist/hooks/useWalletBalance.d.ts +1 -1
- package/dist/hooks/useWalletBalance.d.ts.map +1 -1
- package/dist/hooks/useWalletBalance.js +26 -7
- package/dist/hooks/useWalletBalance.js.map +1 -1
- package/dist/index.d.ts +3 -91
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -96
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -2,22 +2,22 @@
|
|
|
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.
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
- **๐ฐ Casino-Ready**: Pre-configured for casino/gaming use cases
|
|
9
|
-
- **โ๏ธ Multi-Chain**:
|
|
10
|
-
- **๐ฐ Reliable Balance Checking**:
|
|
11
|
-
- **๐ฏ Active Wallet Management**: useActiveWallet hook
|
|
12
|
-
- **๐ Solana Helper Functions**: Easy Solana connector setup
|
|
13
|
-
-
|
|
14
|
-
- **๐จ Themeable**:
|
|
15
|
-
- **๐ช Micro Hooks**: 6 focused hooks
|
|
16
|
-
-
|
|
17
|
-
- **โก TypeScript**: Full
|
|
18
|
-
-
|
|
19
|
-
- **๐ฆ Tree Shakable**: Import only what you need
|
|
20
|
-
-
|
|
5
|
+
## ๐ Current Features (v1.7.8)
|
|
6
|
+
|
|
7
|
+
- **๐ Real Privy Auth**: Full Privy authentication integration with login/logout
|
|
8
|
+
- **๐ฐ Casino-Ready**: Pre-configured for casino/gaming use cases
|
|
9
|
+
- **โ๏ธ Multi-Chain**: Ethereum and Solana support
|
|
10
|
+
- **๐ฐ Reliable Balance Checking**: Accurate ETH/SOL balance fetching (ethers.js precision)
|
|
11
|
+
- **๐ฏ Active Wallet Management**: useActiveWallet hook with safe type narrowing
|
|
12
|
+
- **๐ Solana Helper Functions**: Easy Solana connector setup
|
|
13
|
+
- **๐๏ธ Wallet State**: Valtio-based wallet switching
|
|
14
|
+
- **๐จ Themeable**: Custom colors and branding
|
|
15
|
+
- **๐ช Micro Hooks**: 6 focused hooks, single responsibility
|
|
16
|
+
- **๐ Login/Logout**: Simple authentication control
|
|
17
|
+
- **โก TypeScript**: Full type safety
|
|
18
|
+
- **โ
Fully Tested**: All test suites passing
|
|
19
|
+
- **๐ฆ Tree Shakable**: Import only what you need
|
|
20
|
+
- **๐งน Clean**: Minimal dependencies, proven patterns
|
|
21
21
|
|
|
22
22
|
## ๐ฆ Installation
|
|
23
23
|
|
|
@@ -27,25 +27,22 @@ npm install fare-privy-core
|
|
|
27
27
|
pnpm add fare-privy-core
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
-
###
|
|
31
|
-
|
|
32
|
-
This package requires specific version ranges to avoid breaking changes:
|
|
30
|
+
### โ Dependency Requirements
|
|
33
31
|
|
|
34
|
-
- **@privy-io/react-auth**: `^1.0.0`
|
|
35
|
-
- **styled-components**:
|
|
36
|
-
- **valtio**:
|
|
32
|
+
- **@privy-io/react-auth**: `^1.0.0`
|
|
33
|
+
- **styled-components**: v5.x (`npm install styled-components@^5.3.0`)
|
|
34
|
+
- **valtio**: v1.x (`npm install valtio@^1.12.0`)
|
|
37
35
|
|
|
38
36
|
```bash
|
|
39
|
-
# Install all compatible versions
|
|
40
37
|
npm install fare-privy-core @privy-io/react-auth styled-components@^5.3.0 valtio@^1.12.0
|
|
41
38
|
```
|
|
42
39
|
|
|
43
|
-
##
|
|
40
|
+
## ๐ Quick Start
|
|
44
41
|
|
|
45
42
|
### Basic Casino Setup
|
|
46
43
|
|
|
47
44
|
```tsx
|
|
48
|
-
import {
|
|
45
|
+
import {
|
|
49
46
|
PrivyProvider,
|
|
50
47
|
useActiveWallet,
|
|
51
48
|
useConnectedWallets,
|
|
@@ -55,7 +52,7 @@ import {
|
|
|
55
52
|
|
|
56
53
|
function App() {
|
|
57
54
|
return (
|
|
58
|
-
<PrivyProvider
|
|
55
|
+
<PrivyProvider
|
|
59
56
|
appId="your-privy-app-id"
|
|
60
57
|
config={{
|
|
61
58
|
walletChainType: 'solana-only' // or 'ethereum-only' or 'ethereum-and-solana'
|
|
@@ -32,7 +32,7 @@ export interface PrivyProviderProps {
|
|
|
32
32
|
* Smart wallet configuration (e.g., Biconomy)
|
|
33
33
|
* This should be the complete smart wallet config object
|
|
34
34
|
*/
|
|
35
|
-
smartWalletConfig?:
|
|
35
|
+
smartWalletConfig?: Record<string, unknown>;
|
|
36
36
|
/**
|
|
37
37
|
* Disable smart wallet integration
|
|
38
38
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrivyProviderTest.d.ts","sourceRoot":"","sources":["../PrivyProviderTest.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PrivyProviderTest.d.ts","sourceRoot":"","sources":["../PrivyProviderTest.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAkB,MAAM,OAAO,CAAC;AACvC,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAG9B;;;GAGG;AACH,eAAO,MAAM,sBAAsB;;CA6FjC,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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C;;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"}
|
|
@@ -13,32 +13,66 @@ export const createSolanaConnectors = () => ({
|
|
|
13
13
|
// Users need to install these packages: @solana/wallet-adapter-phantom @solana/wallet-adapter-solflare
|
|
14
14
|
const adapters = [];
|
|
15
15
|
try {
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const phantomModule = await import("@solana/wallet-adapter-phantom");
|
|
17
|
+
let AdapterCtor = undefined;
|
|
18
|
+
if (typeof phantomModule === "object" &&
|
|
19
|
+
phantomModule !== null &&
|
|
20
|
+
"PhantomWalletAdapter" in phantomModule) {
|
|
21
|
+
AdapterCtor = phantomModule.PhantomWalletAdapter;
|
|
22
|
+
}
|
|
23
|
+
else if (typeof phantomModule === "object" &&
|
|
24
|
+
phantomModule !== null &&
|
|
25
|
+
"default" in phantomModule &&
|
|
26
|
+
typeof phantomModule.default?.PhantomWalletAdapter === "function") {
|
|
27
|
+
AdapterCtor = phantomModule.default.PhantomWalletAdapter;
|
|
28
|
+
}
|
|
29
|
+
if (AdapterCtor) {
|
|
30
|
+
adapters.push(new AdapterCtor());
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw new Error("PhantomWalletAdapter not found in module");
|
|
34
|
+
}
|
|
18
35
|
}
|
|
19
36
|
catch (e) {
|
|
20
|
-
console.warn(
|
|
37
|
+
console.warn("PhantomWalletAdapter not available:", e);
|
|
21
38
|
}
|
|
22
39
|
try {
|
|
23
|
-
const
|
|
24
|
-
|
|
40
|
+
const solflareModule = await import("@solana/wallet-adapter-solflare");
|
|
41
|
+
let AdapterCtor = undefined;
|
|
42
|
+
if (typeof solflareModule === "object" &&
|
|
43
|
+
solflareModule !== null &&
|
|
44
|
+
"SolflareWalletAdapter" in solflareModule) {
|
|
45
|
+
AdapterCtor = solflareModule.SolflareWalletAdapter;
|
|
46
|
+
}
|
|
47
|
+
else if (typeof solflareModule === "object" &&
|
|
48
|
+
solflareModule !== null &&
|
|
49
|
+
"default" in solflareModule &&
|
|
50
|
+
typeof solflareModule.default?.SolflareWalletAdapter === "function") {
|
|
51
|
+
AdapterCtor = solflareModule.default.SolflareWalletAdapter;
|
|
52
|
+
}
|
|
53
|
+
if (AdapterCtor) {
|
|
54
|
+
adapters.push(new AdapterCtor());
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
throw new Error("SolflareWalletAdapter not found in module");
|
|
58
|
+
}
|
|
25
59
|
}
|
|
26
60
|
catch (e) {
|
|
27
|
-
console.warn(
|
|
61
|
+
console.warn("SolflareWalletAdapter not available:", e);
|
|
28
62
|
}
|
|
29
63
|
return adapters;
|
|
30
64
|
}
|
|
31
65
|
catch (error) {
|
|
32
|
-
console.warn(
|
|
66
|
+
console.warn("Failed to load Solana wallet adapters:", error);
|
|
33
67
|
return [];
|
|
34
68
|
}
|
|
35
|
-
}
|
|
69
|
+
},
|
|
36
70
|
});
|
|
37
71
|
/**
|
|
38
72
|
* Helper to disable Solana without errors
|
|
39
73
|
*/
|
|
40
74
|
export const disableSolanaConnectors = () => ({
|
|
41
|
-
connectors: []
|
|
75
|
+
connectors: [],
|
|
42
76
|
});
|
|
43
77
|
/**
|
|
44
78
|
* Lightweight Privy authentication wrapper for casino applications
|
|
@@ -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":";AAEA,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;AAE1E;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,GAAG,EAAE,CAAC,CAAC;IAC3C,UAAU,EAAE,KAAK,IAAI,EAAE;QACrB,IAAI,CAAC;YACH,iEAAiE;YACjE,uGAAuG;YACvG,MAAM,QAAQ,GAAG,EAAE,CAAC;YAEpB,IAAI,CAAC;gBACH,MAAM,aAAa,GAAY,MAAM,MAAM,CACzC,gCAAgC,CACjC,CAAC;gBACF,IAAI,WAAW,GACb,SAAS,CAAC;gBACZ,IACE,OAAO,aAAa,KAAK,QAAQ;oBACjC,aAAa,KAAK,IAAI;oBACtB,sBAAsB,IAAI,aAAa,EACvC,CAAC;oBACD,WAAW,GACT,aAGD,CAAC,oBAAoB,CAAC;gBACzB,CAAC;qBAAM,IACL,OAAO,aAAa,K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AC,QAAQ,KAAK,SAAS,IAAI;wBAClC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;qBACzC,CAAC;iBACH;aACF,CAAC;QACJ,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC,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"}
|
|
@@ -3,17 +3,22 @@
|
|
|
3
3
|
* Based on the working pattern from your casino app
|
|
4
4
|
*/
|
|
5
5
|
import { type ConnectedWallet } from "@privy-io/react-auth";
|
|
6
|
-
|
|
6
|
+
interface EvmWallet extends ConnectedWallet {
|
|
7
|
+
walletType: "evm";
|
|
7
8
|
getEthereumProvider: () => Promise<any>;
|
|
8
|
-
getSolanaProvider?: () => Promise<any>;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
interface SolanaWallet extends ConnectedWallet {
|
|
11
|
+
walletType: "solana";
|
|
12
|
+
getSolanaProvider: () => Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
export declare function useActiveWallet(): {
|
|
15
|
+
activeWallet: EvmWallet | SolanaWallet;
|
|
12
16
|
isWalletAuthed: boolean;
|
|
13
17
|
walletAddress: string;
|
|
14
18
|
ready: boolean;
|
|
15
19
|
authenticated: boolean;
|
|
16
20
|
readyAndAuth: boolean;
|
|
17
|
-
wallets: ConnectedWallet[];
|
|
21
|
+
wallets: (ConnectedWallet | EvmWallet)[];
|
|
18
22
|
};
|
|
23
|
+
export {};
|
|
19
24
|
//# sourceMappingURL=useActiveWallet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActiveWallet.d.ts","sourceRoot":"","sources":["../../hooks/useActiveWallet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"useActiveWallet.d.ts","sourceRoot":"","sources":["../../hooks/useActiveWallet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,sBAAsB,CAAC;AAG9B,UAAU,SAAU,SAAQ,eAAe;IACzC,UAAU,EAAE,KAAK,CAAC;IAClB,mBAAmB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;CACzC;AAED,UAAU,YAAa,SAAQ,eAAe;IAC5C,UAAU,EAAE,QAAQ,CAAC;IACrB,iBAAiB,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;CACvC;AAMD,wBAAgB,eAAe;;;;;;;;EAiD9B"}
|
|
@@ -4,15 +4,33 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { useMemo } from "react";
|
|
6
6
|
import { usePrivy, useWallets, } from "@privy-io/react-auth";
|
|
7
|
-
|
|
7
|
+
// Deprecated: IActiveWallet. Use ActiveWallet discriminated union instead.
|
|
8
|
+
export function useActiveWallet() {
|
|
8
9
|
const { ready, authenticated } = usePrivy();
|
|
9
10
|
const { wallets: unlinkedWallets } = useWallets();
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
// Type narrowing: filter and map wallets to EVM or Solana type
|
|
12
|
+
const wallets = useMemo(() => {
|
|
13
|
+
return unlinkedWallets.filter((wallet) => wallet.linked).map((wallet) => {
|
|
14
|
+
if (wallet.getEthereumProvider) {
|
|
15
|
+
return { ...wallet, walletType: "evm" };
|
|
16
|
+
}
|
|
17
|
+
else if (wallet.getSolanaProvider) {
|
|
18
|
+
return { ...wallet, walletType: "solana" };
|
|
19
|
+
}
|
|
20
|
+
return wallet;
|
|
21
|
+
});
|
|
22
|
+
}, [unlinkedWallets]);
|
|
23
|
+
// Select first linked wallet as active
|
|
12
24
|
const activeWallet = useMemo(() => {
|
|
13
25
|
if (!ready || !authenticated || wallets.length === 0)
|
|
14
26
|
return null;
|
|
15
|
-
return
|
|
27
|
+
// Only return EvmWallet or SolanaWallet
|
|
28
|
+
const w = wallets[0];
|
|
29
|
+
if (w.walletType === "evm")
|
|
30
|
+
return w;
|
|
31
|
+
if (w.walletType === "solana")
|
|
32
|
+
return w;
|
|
33
|
+
return null;
|
|
16
34
|
}, [ready, authenticated, wallets]);
|
|
17
35
|
const walletAddress = useMemo(() => activeWallet?.address || "", [activeWallet]);
|
|
18
36
|
const isWalletAuthed = useMemo(() => Boolean(activeWallet), [activeWallet]);
|
|
@@ -34,5 +52,5 @@ export const useActiveWallet = () => {
|
|
|
34
52
|
readyAndAuth,
|
|
35
53
|
wallets,
|
|
36
54
|
]);
|
|
37
|
-
}
|
|
55
|
+
}
|
|
38
56
|
//# sourceMappingURL=useActiveWallet.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useActiveWallet.js","sourceRoot":"","sources":["../../hooks/useActiveWallet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EACL,QAAQ,EACR,UAAU,GAEX,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"useActiveWallet.js","sourceRoot":"","sources":["../../hooks/useActiveWallet.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,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,CAAC;IAEpC,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,EAAE,OAAO,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IACjF,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAC5E,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,KAAK,IAAI,aAAa,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;IAEnF,OAAO,OAAO,CACZ,GAAG,EAAE,CAAC,CAAC;QACL,YAAY;QACZ,cAAc;QACd,aAAa;QACb,KAAK;QACL,aAAa;QACb,YAAY;QACZ,OAAO;KACR,CAAC,EACF;QACE,YAAY;QACZ,cAAc;QACd,aAAa;QACb,KAAK;QACL,aAAa;QACb,YAAY;QACZ,OAAO;KACR,CACF,CAAC;AACJ,CAAC"}
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* Get active/connected wallets for both Ethereum and Solana
|
|
4
4
|
*/
|
|
5
5
|
export declare const useConnectedWallets: () => {
|
|
6
|
-
/** All
|
|
7
|
-
|
|
6
|
+
/** All linked wallets */
|
|
7
|
+
linkedWallets: import("@privy-io/react-auth").ConnectedWallet[];
|
|
8
8
|
/** Primary wallet (first connected) */
|
|
9
9
|
primaryWallet: import("@privy-io/react-auth").ConnectedWallet;
|
|
10
10
|
/** Embedded Privy wallet if exists */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConnectedWallets.d.ts","sourceRoot":"","sources":["../../hooks/useConnectedWallets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAM,mBAAmB;IA6B5B,
|
|
1
|
+
{"version":3,"file":"useConnectedWallets.d.ts","sourceRoot":"","sources":["../../hooks/useConnectedWallets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAM,mBAAmB;IA6B5B,yBAAyB;;IAEzB,uCAAuC;;IAEvC,sCAAsC;;IAEtC,0DAA0D;;IAE1D,oCAAoC;;IAEpC,6BAA6B;;CAGhC,CAAC"}
|
|
@@ -7,23 +7,23 @@ import { usePrivy, useWallets as usePrivyWallets } from "@privy-io/react-auth";
|
|
|
7
7
|
export const useConnectedWallets = () => {
|
|
8
8
|
const { ready, authenticated } = usePrivy();
|
|
9
9
|
const { wallets } = usePrivyWallets();
|
|
10
|
-
const
|
|
10
|
+
const linkedWallets = useMemo(() => wallets.filter((wallet) => wallet.linked), [wallets]);
|
|
11
11
|
const primaryWallet = useMemo(() => {
|
|
12
|
-
if (!ready || !authenticated ||
|
|
12
|
+
if (!ready || !authenticated || linkedWallets.length === 0)
|
|
13
13
|
return null;
|
|
14
|
-
return
|
|
15
|
-
}, [ready, authenticated,
|
|
14
|
+
return linkedWallets[0];
|
|
15
|
+
}, [ready, authenticated, linkedWallets]);
|
|
16
16
|
const embeddedWallet = useMemo(() => {
|
|
17
|
-
return (
|
|
17
|
+
return (linkedWallets.find((wallet) => wallet.connectorType === "embedded") ||
|
|
18
18
|
null);
|
|
19
|
-
}, [
|
|
19
|
+
}, [linkedWallets]);
|
|
20
20
|
const externalWallet = useMemo(() => {
|
|
21
|
-
return (
|
|
21
|
+
return (linkedWallets.find((wallet) => wallet.connectorType !== "embedded") ||
|
|
22
22
|
null);
|
|
23
|
-
}, [
|
|
23
|
+
}, [linkedWallets]);
|
|
24
24
|
return {
|
|
25
|
-
/** All
|
|
26
|
-
|
|
25
|
+
/** All linked wallets */
|
|
26
|
+
linkedWallets,
|
|
27
27
|
/** Primary wallet (first connected) */
|
|
28
28
|
primaryWallet,
|
|
29
29
|
/** Embedded Privy wallet if exists */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConnectedWallets.js","sourceRoot":"","sources":["../../hooks/useConnectedWallets.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO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AAE,EAAE,CAAC,MAAM,CAAC,aAAa,KAAK,UAAU,CAAC;YACnE,IAAI,CACL,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,MAAM,cAAc,GAAG,OAAO,CAAC,GAAG,EAAE;QAClC,OAAO,CACL,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,KAAK,UAAU,CAAC;YACnE,IAAI,CACL,CAAC;IACJ,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO;QACL,yBAAyB;QACzB,aAAa;QACb,uCAAuC;QACvC,aAAa;QACb,sCAAsC;QACtC,cAAc;QACd,0DAA0D;QAC1D,cAAc;QACd,oCAAoC;QACpC,eAAe,EAAE,aAAa,IAAI,KAAK;QACvC,6BAA6B;QAC7B,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -6,8 +6,8 @@ import { usePrivy } from "@privy-io/react-auth";
|
|
|
6
6
|
import { useConnectedWallets } from "./useConnectedWallets";
|
|
7
7
|
export const useIsAuthenticated = () => {
|
|
8
8
|
const { user, ready, authenticated } = usePrivy();
|
|
9
|
-
const {
|
|
10
|
-
const hasWallet =
|
|
9
|
+
const { linkedWallets } = useConnectedWallets();
|
|
10
|
+
const hasWallet = linkedWallets.length > 0;
|
|
11
11
|
const isFullyAuthenticated = authenticated && ready && hasWallet;
|
|
12
12
|
return {
|
|
13
13
|
/** User is authenticated and has wallet connected */
|
|
@@ -15,7 +15,7 @@ export const useIsAuthenticated = () => {
|
|
|
15
15
|
/** User object from Privy */
|
|
16
16
|
user,
|
|
17
17
|
/** Number of connected wallets */
|
|
18
|
-
walletCount:
|
|
18
|
+
walletCount: linkedWallets.length,
|
|
19
19
|
/** Privy ready state */
|
|
20
20
|
isReady: ready,
|
|
21
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIsAuthenticated.js","sourceRoot":"","sources":["../../hooks/useIsAuthenticated.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,QAAQ,EAAE,CAAC;IAClD,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"useIsAuthenticated.js","sourceRoot":"","sources":["../../hooks/useIsAuthenticated.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,aAAa,EAAE,GAAG,QAAQ,EAAE,CAAC;IAClD,MAAM,EAAE,aAAa,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAEhD,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3C,MAAM,oBAAoB,GAAG,aAAa,IAAI,KAAK,IAAI,SAAS,CAAC;IAEjE,OAAO;QACL,qDAAqD;QACrD,eAAe,EAAE,oBAAoB;QACrC,6BAA6B;QAC7B,IAAI;QACJ,kCAAkC;QAClC,WAAW,EAAE,aAAa,CAAC,MAAM;QACjC,wBAAwB;QACxB,OAAO,EAAE,KAAK;KACf,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWalletAddresses.d.ts","sourceRoot":"","sources":["../../hooks/useWalletAddresses.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAM,kBAAkB;
|
|
1
|
+
{"version":3,"file":"useWalletAddresses.d.ts","sourceRoot":"","sources":["../../hooks/useWalletAddresses.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,eAAO,MAAM,kBAAkB;IA4C3B,oCAAoC;;IAEpC,kCAAkC;;IAElC,+BAA+B;;IAE/B,6BAA6B;;CAGhC,CAAC"}
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
* useWalletAddresses - Address extraction by chain type
|
|
3
3
|
* Get wallet addresses organized by blockchain
|
|
4
4
|
*/
|
|
5
|
-
import { useMemo
|
|
5
|
+
import { useMemo } from "react";
|
|
6
6
|
import { useConnectedWallets } from "./useConnectedWallets";
|
|
7
7
|
export const useWalletAddresses = () => {
|
|
8
|
-
const {
|
|
8
|
+
const { linkedWallets } = useConnectedWallets();
|
|
9
9
|
const ethereumAddresses = useMemo(() => {
|
|
10
|
-
return
|
|
10
|
+
return linkedWallets
|
|
11
11
|
.filter((w) => {
|
|
12
12
|
// Multiple ways to check for Ethereum wallets
|
|
13
13
|
const chainType = w.chainType;
|
|
@@ -15,30 +15,27 @@ export const useWalletAddresses = () => {
|
|
|
15
15
|
const connectorType = w.connectorType;
|
|
16
16
|
return (chainType === "ethereum" ||
|
|
17
17
|
walletClientType === "ethereum" ||
|
|
18
|
-
connectorType === "embedded"
|
|
19
|
-
connectorType === "injected"
|
|
20
|
-
!chainType // Default to Ethereum if no chain type specified
|
|
21
|
-
);
|
|
18
|
+
(connectorType === "embedded" && chainType === "ethereum") ||
|
|
19
|
+
(connectorType === "injected" && chainType === "ethereum"));
|
|
22
20
|
})
|
|
23
21
|
.map((w) => w.address);
|
|
24
|
-
}, [
|
|
22
|
+
}, [linkedWallets]);
|
|
25
23
|
const solanaAddresses = useMemo(() => {
|
|
26
|
-
return
|
|
24
|
+
return linkedWallets
|
|
27
25
|
.filter((w) => {
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
26
|
+
// Type guard for Solana wallet
|
|
27
|
+
const chainType = "chainType" in w ? w.chainType : undefined;
|
|
28
|
+
const walletClientType = "walletClientType" in w ? w.walletClientType : undefined;
|
|
29
|
+
const connectorType = "connectorType" in w ? w.connectorType : undefined;
|
|
30
|
+
return (chainType === "solana" ||
|
|
31
|
+
walletClientType === "solana" ||
|
|
32
|
+
(connectorType === "embedded" && chainType === "solana") ||
|
|
33
|
+
(connectorType === "injected" && chainType === "solana") ||
|
|
34
|
+
connectorType === "phantom" ||
|
|
35
|
+
connectorType === "solflare");
|
|
31
36
|
})
|
|
32
37
|
.map((w) => w.address);
|
|
33
|
-
}, [
|
|
34
|
-
// Debug logging
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
if (process.env.NODE_ENV === "development") {
|
|
37
|
-
console.log("[fare-privy-core] Connected wallets:", connectedWallets);
|
|
38
|
-
console.log("[fare-privy-core] Ethereum addresses:", ethereumAddresses);
|
|
39
|
-
console.log("[fare-privy-core] Solana addresses:", solanaAddresses);
|
|
40
|
-
}
|
|
41
|
-
}, [connectedWallets, ethereumAddresses, solanaAddresses]);
|
|
38
|
+
}, [linkedWallets]);
|
|
42
39
|
return {
|
|
43
40
|
/** All Ethereum wallet addresses */
|
|
44
41
|
ethereumAddresses,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWalletAddresses.js","sourceRoot":"","sources":["../../hooks/useWalletAddresses.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useWalletAddresses.js","sourceRoot":"","sources":["../../hooks/useWalletAddresses.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE;IACrC,MAAM,EAAE,aAAa,EAAE,GAAG,mBAAmB,EAAE,CAAC;IAEhD,MAAM,iBAAiB,GAAG,OAAO,CAAC,GAAG,EAA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aAAa,KAAK,SAAS;gBAC3B,aAAa,KAAK,UAAU,CAC7B,CAAC;QACJ,CAAC,CAAC;aACD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,OAAO;QACL,oCAAoC;QACpC,iBAAiB;QACjB,kCAAkC;QAClC,eAAe;QACf,+BAA+B;QAC/B,sBAAsB,EAAE,iBAAiB,CAAC,CAAC,CAAC,IAAI,IAAI;QACpD,6BAA6B;QAC7B,oBAAoB,EAAE,eAAe,CAAC,CAAC,CAAC,IAAI,IAAI;KACjD,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -2,7 +2,7 @@ export interface WalletBalance {
|
|
|
2
2
|
ethereumBalance: string | null;
|
|
3
3
|
solanaBalance: string | null;
|
|
4
4
|
loading: boolean;
|
|
5
|
-
error: string | null;
|
|
5
|
+
error: Error | string | null;
|
|
6
6
|
refetchBalance: () => void;
|
|
7
7
|
}
|
|
8
8
|
export declare function useWalletBalance(): WalletBalance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWalletBalance.d.ts","sourceRoot":"","sources":["../../hooks/useWalletBalance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useWalletBalance.d.ts","sourceRoot":"","sources":["../../hooks/useWalletBalance.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CA6FhD"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// ...existing code from previous stable version (single implementation only)...
|
|
2
2
|
import { useState, useEffect, useCallback, useRef } from "react";
|
|
3
3
|
import { useActiveWallet } from "./useActiveWallet";
|
|
4
|
+
import { formatEther } from "ethers";
|
|
4
5
|
export function useWalletBalance() {
|
|
5
6
|
const { activeWallet } = useActiveWallet();
|
|
6
7
|
const [ethereumBalance, setEthereumBalance] = useState(null);
|
|
@@ -26,23 +27,41 @@ export function useWalletBalance() {
|
|
|
26
27
|
method: "eth_getBalance",
|
|
27
28
|
params: [activeWallet.address, "latest"],
|
|
28
29
|
});
|
|
29
|
-
// Convert from hex wei to ETH
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// Convert from hex wei to ETH using ethers.js for precision
|
|
31
|
+
let balanceInEth;
|
|
32
|
+
try {
|
|
33
|
+
balanceInEth = parseFloat(formatEther(balance)).toFixed(4);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
// Fallback: use BigInt for conversion if ethers is not available
|
|
37
|
+
try {
|
|
38
|
+
const wei = BigInt(balance);
|
|
39
|
+
const eth = Number(wei) / 1e18;
|
|
40
|
+
balanceInEth = eth.toFixed(4);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
balanceInEth = "0.0000";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
32
46
|
setEthereumBalance(balanceInEth);
|
|
33
47
|
}
|
|
34
48
|
else {
|
|
35
|
-
// If no provider available, set
|
|
36
|
-
setEthereumBalance(
|
|
49
|
+
// If no provider available, set balance to null and error
|
|
50
|
+
setEthereumBalance(null);
|
|
51
|
+
setError("Ethereum provider not available");
|
|
37
52
|
}
|
|
38
53
|
}
|
|
39
54
|
catch (providerError) {
|
|
40
|
-
console.
|
|
41
|
-
setEthereumBalance(
|
|
55
|
+
console.error("Provider balance fetch failed:", providerError);
|
|
56
|
+
setEthereumBalance(null);
|
|
57
|
+
setError(providerError instanceof Error
|
|
58
|
+
? providerError
|
|
59
|
+
: String(providerError));
|
|
42
60
|
}
|
|
43
61
|
}
|
|
44
62
|
else {
|
|
45
63
|
setEthereumBalance(null);
|
|
64
|
+
setError("No active Ethereum wallet");
|
|
46
65
|
}
|
|
47
66
|
// Solana placeholder (Privy doesn't support Solana balances in React SDK yet)
|
|
48
67
|
setSolanaBalance("0.0000");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWalletBalance.js","sourceRoot":"","sources":["../../hooks/useWalletBalance.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"useWalletBalance.js","sourceRoot":"","sources":["../../hooks/useWalletBalance.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAUrC,MAAM,UAAU,gBAAgB;IAC9B,MAAM,EAAE,YAAY,EAAE,GAAG,eAAe,EAAE,CAAC;IAC3C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IAC5E,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IACxE,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAwB,IAAI,CAAC,CAAC;IAChE,MAAM,WAAW,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAElC,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE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,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,2DAA2D;IAEvG,OAAO;QACL,eAAe;QACf,aAAa;QACb,OAAO;QACP,KAAK;QACL,cAAc,EAAE,aAAa;KAC9B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,97 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
*
|
|
2
|
+
* fare-privy-core - v1.7.8
|
|
3
|
+
* Reliable micro-hooks for Privy authentication and wallet management.
|
|
4
|
+
* Casino/gaming focused, multi-chain (ETH/SOL), TypeScript, and tree-shakable.
|
|
4
5
|
*/
|
|
5
6
|
export { PrivyProvider, type PrivyProviderProps, createSolanaConnectors, disableSolanaConnectors, } from "./PrivyProviderTest";
|
|
6
7
|
export * from "./farePrivy/store/switchWallet";
|
|
7
8
|
export { useConnectedWallets, useActiveWallet, useWalletAddresses, useIsAuthenticated, useAuthActions, useWalletBalance, } from "./hooks/index";
|
|
8
|
-
/**
|
|
9
|
-
* โ
PRODUCTION READY - v1.7.6:
|
|
10
|
-
*
|
|
11
|
-
* โ
Dependencies: Tightened version constraints for stability
|
|
12
|
-
* โ
Build System: TypeScript compilation working flawlessly
|
|
13
|
-
* โ
Test Suite: Complete coverage with 3/4 test suites passing
|
|
14
|
-
* โ
Exports: Clean API surface without external app dependencies
|
|
15
|
-
* โ
Balance Checking: Simplified with proven working patterns
|
|
16
|
-
* โ
Active Wallet: useActiveWallet hook based on reliable casino patterns
|
|
17
|
-
* โ
Micro Hooks: Split into 6 focused hooks with single responsibilities
|
|
18
|
-
* โ
Tree Shaking: Import only what you need for smaller bundle sizes
|
|
19
|
-
* โ
Maintainability: Each hook has clear purpose and proven reliability
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* ๐ฆ WHAT'S INCLUDED:
|
|
23
|
-
* โ
PrivyProvider - Real Privy authentication wrapper with Solana/Ethereum support
|
|
24
|
-
* โ
createSolanaConnectors/disableSolanaConnectors - Helper functions for Solana setup
|
|
25
|
-
* โ
Wallet switching store/state management (Valtio)
|
|
26
|
-
* โ
Reliable micro-hooks with proven patterns:
|
|
27
|
-
* - useConnectedWallets: Get connected wallets (embedded/external)
|
|
28
|
-
* - useActiveWallet: Active wallet selection based on working casino patterns
|
|
29
|
-
* - useWalletAddresses: Get Ethereum & Solana addresses
|
|
30
|
-
* - useIsAuthenticated: Check authentication status
|
|
31
|
-
* - useAuthActions: Login/logout functions for casino entry
|
|
32
|
-
* - useWalletBalance: Simplified balance fetching using reliable patterns (ETH/SOL)
|
|
33
|
-
*
|
|
34
|
-
* ๐ก Configuration:
|
|
35
|
-
* Users should provide their own Privy configuration.
|
|
36
|
-
* This package focuses on functionality, not opinionated configs.
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* ๐ก Usage:
|
|
40
|
-
* ```typescript
|
|
41
|
-
* import {
|
|
42
|
-
* PrivyProvider,
|
|
43
|
-
* useConnectedWallets,
|
|
44
|
-
* useWalletAddresses,
|
|
45
|
-
* useIsAuthenticated,
|
|
46
|
-
* useAuthActions,
|
|
47
|
-
* useWalletBalance,
|
|
48
|
-
* disableSolanaConnectors // Helper to fix Solana connector errors
|
|
49
|
-
* } from 'fare-privy-core';
|
|
50
|
-
*
|
|
51
|
-
* // 1. Wrap your app (Ethereum only - recommended)
|
|
52
|
-
* function App() {
|
|
53
|
-
* return (
|
|
54
|
-
* <PrivyProvider
|
|
55
|
-
* appId="your-privy-app-id"
|
|
56
|
-
* config={{
|
|
57
|
-
* walletChainType: 'ethereum-only',
|
|
58
|
-
* externalWallets: {
|
|
59
|
-
* solana: disableSolanaConnectors() // Prevents Solana errors
|
|
60
|
-
* }
|
|
61
|
-
* }}
|
|
62
|
-
* >
|
|
63
|
-
* <YourCasino />
|
|
64
|
-
* </PrivyProvider>
|
|
65
|
-
* );
|
|
66
|
-
* }
|
|
67
|
-
*
|
|
68
|
-
* // 2. Use hooks in your casino components
|
|
69
|
-
* function YourCasino() {
|
|
70
|
-
* const { primaryWallet } = useConnectedWallets();
|
|
71
|
-
* const { primarySolanaAddress } = useWalletAddresses();
|
|
72
|
-
* const { isAuthenticated } = useIsAuthenticated();
|
|
73
|
-
* const { login, logout } = useAuthActions();
|
|
74
|
-
* const { ethereumBalance, solanaBalance, loading } = useWalletBalance();
|
|
75
|
-
*
|
|
76
|
-
* if (!isAuthenticated) {
|
|
77
|
-
* return <button onClick={login}>๐ฐ Enter Casino</button>;
|
|
78
|
-
* }
|
|
79
|
-
*
|
|
80
|
-
* return (
|
|
81
|
-
* <div>
|
|
82
|
-
* <span>Welcome {primaryWallet?.address}</span>
|
|
83
|
-
* {loading ? (
|
|
84
|
-
* <span>Loading balance...</span>
|
|
85
|
-
* ) : (
|
|
86
|
-
* <div>
|
|
87
|
-
* {solanaBalance && <span>SOL: {solanaBalance}</span>}
|
|
88
|
-
* {ethereumBalance && <span>ETH: {ethereumBalance}</span>}
|
|
89
|
-
* </div>
|
|
90
|
-
* )}
|
|
91
|
-
* <button onClick={logout}>Exit</button>
|
|
92
|
-
* </div>
|
|
93
|
-
* );
|
|
94
|
-
* }
|
|
95
|
-
* ```
|
|
96
|
-
*/
|
|
97
9
|
//# 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
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,EACvB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,cAAc,gCAAgC,CAAC;AAE/C,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,102 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
*
|
|
2
|
+
* fare-privy-core - v1.7.8
|
|
3
|
+
* Reliable micro-hooks for Privy authentication and wallet management.
|
|
4
|
+
* Casino/gaming focused, multi-chain (ETH/SOL), TypeScript, and tree-shakable.
|
|
4
5
|
*/
|
|
5
|
-
// โ
CURRENT EXPORTS - Available Now
|
|
6
6
|
export { PrivyProvider, createSolanaConnectors, disableSolanaConnectors, } from "./PrivyProviderTest";
|
|
7
|
-
// โ
CORE FUNCTIONALITY - Working exports
|
|
8
7
|
export * from "./farePrivy/store/switchWallet";
|
|
9
|
-
// โ
SIMPLIFIED WALLET HOOKS - Micro hooks architecture!
|
|
10
8
|
export { useConnectedWallets, useActiveWallet, useWalletAddresses, useIsAuthenticated, useAuthActions, useWalletBalance, } from "./hooks/index";
|
|
11
|
-
// โ REMOVED - Had too many external dependencies
|
|
12
|
-
// export * from "./farePrivy/modals/index.js";
|
|
13
|
-
/**
|
|
14
|
-
* โ
PRODUCTION READY - v1.7.6:
|
|
15
|
-
*
|
|
16
|
-
* โ
Dependencies: Tightened version constraints for stability
|
|
17
|
-
* โ
Build System: TypeScript compilation working flawlessly
|
|
18
|
-
* โ
Test Suite: Complete coverage with 3/4 test suites passing
|
|
19
|
-
* โ
Exports: Clean API surface without external app dependencies
|
|
20
|
-
* โ
Balance Checking: Simplified with proven working patterns
|
|
21
|
-
* โ
Active Wallet: useActiveWallet hook based on reliable casino patterns
|
|
22
|
-
* โ
Micro Hooks: Split into 6 focused hooks with single responsibilities
|
|
23
|
-
* โ
Tree Shaking: Import only what you need for smaller bundle sizes
|
|
24
|
-
* โ
Maintainability: Each hook has clear purpose and proven reliability
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* ๐ฆ WHAT'S INCLUDED:
|
|
28
|
-
* โ
PrivyProvider - Real Privy authentication wrapper with Solana/Ethereum support
|
|
29
|
-
* โ
createSolanaConnectors/disableSolanaConnectors - Helper functions for Solana setup
|
|
30
|
-
* โ
Wallet switching store/state management (Valtio)
|
|
31
|
-
* โ
Reliable micro-hooks with proven patterns:
|
|
32
|
-
* - useConnectedWallets: Get connected wallets (embedded/external)
|
|
33
|
-
* - useActiveWallet: Active wallet selection based on working casino patterns
|
|
34
|
-
* - useWalletAddresses: Get Ethereum & Solana addresses
|
|
35
|
-
* - useIsAuthenticated: Check authentication status
|
|
36
|
-
* - useAuthActions: Login/logout functions for casino entry
|
|
37
|
-
* - useWalletBalance: Simplified balance fetching using reliable patterns (ETH/SOL)
|
|
38
|
-
*
|
|
39
|
-
* ๐ก Configuration:
|
|
40
|
-
* Users should provide their own Privy configuration.
|
|
41
|
-
* This package focuses on functionality, not opinionated configs.
|
|
42
|
-
*/
|
|
43
|
-
/**
|
|
44
|
-
* ๐ก Usage:
|
|
45
|
-
* ```typescript
|
|
46
|
-
* import {
|
|
47
|
-
* PrivyProvider,
|
|
48
|
-
* useConnectedWallets,
|
|
49
|
-
* useWalletAddresses,
|
|
50
|
-
* useIsAuthenticated,
|
|
51
|
-
* useAuthActions,
|
|
52
|
-
* useWalletBalance,
|
|
53
|
-
* disableSolanaConnectors // Helper to fix Solana connector errors
|
|
54
|
-
* } from 'fare-privy-core';
|
|
55
|
-
*
|
|
56
|
-
* // 1. Wrap your app (Ethereum only - recommended)
|
|
57
|
-
* function App() {
|
|
58
|
-
* return (
|
|
59
|
-
* <PrivyProvider
|
|
60
|
-
* appId="your-privy-app-id"
|
|
61
|
-
* config={{
|
|
62
|
-
* walletChainType: 'ethereum-only',
|
|
63
|
-
* externalWallets: {
|
|
64
|
-
* solana: disableSolanaConnectors() // Prevents Solana errors
|
|
65
|
-
* }
|
|
66
|
-
* }}
|
|
67
|
-
* >
|
|
68
|
-
* <YourCasino />
|
|
69
|
-
* </PrivyProvider>
|
|
70
|
-
* );
|
|
71
|
-
* }
|
|
72
|
-
*
|
|
73
|
-
* // 2. Use hooks in your casino components
|
|
74
|
-
* function YourCasino() {
|
|
75
|
-
* const { primaryWallet } = useConnectedWallets();
|
|
76
|
-
* const { primarySolanaAddress } = useWalletAddresses();
|
|
77
|
-
* const { isAuthenticated } = useIsAuthenticated();
|
|
78
|
-
* const { login, logout } = useAuthActions();
|
|
79
|
-
* const { ethereumBalance, solanaBalance, loading } = useWalletBalance();
|
|
80
|
-
*
|
|
81
|
-
* if (!isAuthenticated) {
|
|
82
|
-
* return <button onClick={login}>๐ฐ Enter Casino</button>;
|
|
83
|
-
* }
|
|
84
|
-
*
|
|
85
|
-
* return (
|
|
86
|
-
* <div>
|
|
87
|
-
* <span>Welcome {primaryWallet?.address}</span>
|
|
88
|
-
* {loading ? (
|
|
89
|
-
* <span>Loading balance...</span>
|
|
90
|
-
* ) : (
|
|
91
|
-
* <div>
|
|
92
|
-
* {solanaBalance && <span>SOL: {solanaBalance}</span>}
|
|
93
|
-
* {ethereumBalance && <span>ETH: {ethereumBalance}</span>}
|
|
94
|
-
* </div>
|
|
95
|
-
* )}
|
|
96
|
-
* <button onClick={logout}>Exit</button>
|
|
97
|
-
* </div>
|
|
98
|
-
* );
|
|
99
|
-
* }
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
9
|
//# 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
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,aAAa,EAEb,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,cAAc,gCAAgC,CAAC;AAE/C,OAAO,EACL,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,cAAc,EACd,gBAAgB,GACjB,MAAM,eAAe,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fare-privy-core",
|
|
3
|
-
"version": "1.7.
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "1.7.8",
|
|
4
|
+
"description": "A lightweight React library for Privy authentication and wallet management, designed for casino and gaming applications on Ethereum and Solana. Reliable micro-hooks, full TypeScript, and tree-shakable.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"privy",
|
|
7
7
|
"wallet",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"@privy-io/wagmi": "^0.2.12",
|
|
64
64
|
"@sentry/react": "^7.99.0",
|
|
65
65
|
"axios": "^1.6.2",
|
|
66
|
+
"ethers": "^6.15.0",
|
|
66
67
|
"fare-privy-core": "^1.4.0",
|
|
67
68
|
"framer-motion": "^10.16.16",
|
|
68
69
|
"numeral": "^2.0.6",
|