@meshconnect/uwc-react 0.9.4 → 0.10.1
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/dist/hooks/useConnection.d.ts.map +1 -1
- package/dist/hooks/useConnection.js +15 -6
- package/dist/hooks/useConnection.js.map +1 -1
- package/dist/hooks/useConnectionContext.d.ts +15 -0
- package/dist/hooks/useConnectionContext.d.ts.map +1 -0
- package/dist/hooks/useConnectionContext.js +22 -0
- package/dist/hooks/useConnectionContext.js.map +1 -0
- package/dist/hooks/useDetectedWallets.d.ts.map +1 -1
- package/dist/hooks/useDetectedWallets.js +6 -6
- package/dist/hooks/useDetectedWallets.js.map +1 -1
- package/dist/hooks/useDisconnect.d.ts.map +1 -1
- package/dist/hooks/useDisconnect.js +6 -6
- package/dist/hooks/useDisconnect.js.map +1 -1
- package/dist/hooks/useNetworks.d.ts.map +1 -1
- package/dist/hooks/useNetworks.js +2 -6
- package/dist/hooks/useNetworks.js.map +1 -1
- package/dist/hooks/useSession.d.ts.map +1 -1
- package/dist/hooks/useSession.js +2 -6
- package/dist/hooks/useSession.js.map +1 -1
- package/dist/hooks/useSignMessage.d.ts.map +1 -1
- package/dist/hooks/useSignMessage.js +4 -7
- package/dist/hooks/useSignMessage.js.map +1 -1
- package/dist/hooks/useSignSolanaTransaction.d.ts.map +1 -1
- package/dist/hooks/useSignSolanaTransaction.js +4 -7
- package/dist/hooks/useSignSolanaTransaction.js.map +1 -1
- package/dist/hooks/useSignTypedData.d.ts.map +1 -1
- package/dist/hooks/useSignTypedData.js +4 -7
- package/dist/hooks/useSignTypedData.js.map +1 -1
- package/dist/hooks/useSwitchNetwork.d.ts.map +1 -1
- package/dist/hooks/useSwitchNetwork.js +9 -6
- package/dist/hooks/useSwitchNetwork.js.map +1 -1
- package/dist/hooks/useTransaction.d.ts.map +1 -1
- package/dist/hooks/useTransaction.js +4 -7
- package/dist/hooks/useTransaction.js.map +1 -1
- package/dist/hooks/useWallet.d.ts.map +1 -1
- package/dist/hooks/useWallet.js +2 -6
- package/dist/hooks/useWallet.js.map +1 -1
- package/dist/hooks/useWalletCapabilities.d.ts.map +1 -1
- package/dist/hooks/useWalletCapabilities.js +6 -8
- package/dist/hooks/useWalletCapabilities.js.map +1 -1
- package/dist/hooks/useWallets.d.ts.map +1 -1
- package/dist/hooks/useWallets.js +2 -6
- package/dist/hooks/useWallets.js.map +1 -1
- package/dist/providers/ConnectionProvider.d.ts +10 -2
- package/dist/providers/ConnectionProvider.d.ts.map +1 -1
- package/dist/providers/ConnectionProvider.js +32 -5
- package/dist/providers/ConnectionProvider.js.map +1 -1
- package/package.json +2 -2
- package/src/hooks/useConnection.ts +18 -8
- package/src/hooks/useConnectionContext.ts +25 -0
- package/src/hooks/useDetectedWallets.ts +6 -10
- package/src/hooks/useDisconnect.ts +6 -8
- package/src/hooks/useNetworks.ts +2 -8
- package/src/hooks/useSession.ts +2 -8
- package/src/hooks/useSignMessage.ts +4 -9
- package/src/hooks/useSignSolanaTransaction.ts +4 -11
- package/src/hooks/useSignTypedData.ts +4 -9
- package/src/hooks/useSwitchNetwork.ts +10 -8
- package/src/hooks/useTransaction.ts +4 -9
- package/src/hooks/useWallet.ts +2 -8
- package/src/hooks/useWalletCapabilities.ts +6 -12
- package/src/hooks/useWallets.ts +2 -8
- package/src/providers/ConnectionProvider.emptyWallets.test.tsx +105 -0
- package/src/providers/ConnectionProvider.singleton.test.tsx +18 -7
- package/src/providers/ConnectionProvider.tsx +46 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConnection.d.ts","sourceRoot":"","sources":["../../src/hooks/useConnection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,mBAAmB,EAEpB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useConnection.d.ts","sourceRoot":"","sources":["../../src/hooks/useConnection.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,mBAAmB,EAEpB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAqKnE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useState, useEffect } from 'react';
|
|
2
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for managing wallet connections with both injected and WalletConnect modes
|
|
5
5
|
* @param walletId - The ID of the wallet to connect to (e.g., 'metamask', 'trust')
|
|
@@ -20,10 +20,7 @@ import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export function useConnection(walletId) {
|
|
23
|
-
const context =
|
|
24
|
-
if (!context) {
|
|
25
|
-
throw new Error('useConnection must be used within a ConnectionProvider');
|
|
26
|
-
}
|
|
23
|
+
const context = useConnectionContext('useConnection');
|
|
27
24
|
const { connector, isReady } = context;
|
|
28
25
|
const [walletConnectLoading, setWalletConnectLoading] = useState(false);
|
|
29
26
|
const [injectedLoading, setInjectedLoading] = useState(false);
|
|
@@ -38,6 +35,9 @@ export function useConnection(walletId) {
|
|
|
38
35
|
const [tonConnectAvailable, setTonConnectAvailable] = useState(false);
|
|
39
36
|
// Update connection URI and availability when they change
|
|
40
37
|
useEffect(() => {
|
|
38
|
+
// No connector (wallet-less session): nothing to connect or track.
|
|
39
|
+
if (!connector)
|
|
40
|
+
return;
|
|
41
41
|
const checkState = () => {
|
|
42
42
|
const uri = connector.getConnectionURI();
|
|
43
43
|
if (walletConnectLoading) {
|
|
@@ -60,6 +60,9 @@ export function useConnection(walletId) {
|
|
|
60
60
|
return unsubscribe;
|
|
61
61
|
}, [connector, walletId, walletConnectLoading, tonConnectLoading]);
|
|
62
62
|
const connectWalletConnect = useCallback(async (networkId) => {
|
|
63
|
+
if (!connector) {
|
|
64
|
+
throw new Error('No wallet connected');
|
|
65
|
+
}
|
|
63
66
|
setWalletConnectLoading(true);
|
|
64
67
|
setWalletConnectError(undefined);
|
|
65
68
|
setWalletConnectURI(undefined);
|
|
@@ -87,6 +90,9 @@ export function useConnection(walletId) {
|
|
|
87
90
|
setWalletConnectURI(undefined);
|
|
88
91
|
}, [connector, walletId]);
|
|
89
92
|
const connectInjected = useCallback(async (networkId) => {
|
|
93
|
+
if (!connector) {
|
|
94
|
+
throw new Error('No wallet connected');
|
|
95
|
+
}
|
|
90
96
|
setInjectedLoading(true);
|
|
91
97
|
setInjectedError(undefined);
|
|
92
98
|
try {
|
|
@@ -102,6 +108,9 @@ export function useConnection(walletId) {
|
|
|
102
108
|
}
|
|
103
109
|
}, [connector, walletId]);
|
|
104
110
|
const connectTonConnect = useCallback(async (networkId) => {
|
|
111
|
+
if (!connector) {
|
|
112
|
+
throw new Error('No wallet connected');
|
|
113
|
+
}
|
|
105
114
|
setTonConnectLoading(true);
|
|
106
115
|
setTonConnectError(undefined);
|
|
107
116
|
setTonConnectURI(undefined);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConnection.js","sourceRoot":"","sources":["../../src/hooks/useConnection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useConnection.js","sourceRoot":"","sources":["../../src/hooks/useConnection.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ConnectionContextValue } from '../providers/ConnectionProvider';
|
|
2
|
+
/**
|
|
3
|
+
* Reads the connection context, throwing the canonical
|
|
4
|
+
* "must be used within a ConnectionProvider" error when the hook is used
|
|
5
|
+
* outside the provider tree. Centralizes the guard every hook needs so the
|
|
6
|
+
* check and its message live in one place.
|
|
7
|
+
*
|
|
8
|
+
* Note: a non-null context can still carry a `null` connector (a wallet-less
|
|
9
|
+
* session — see `ConnectionContextValue.connector`). Callers that need the
|
|
10
|
+
* connector must handle that case; this guard only covers "no provider".
|
|
11
|
+
*
|
|
12
|
+
* @param hookName - Name used in the error, e.g. `'useSession'`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useConnectionContext(hookName: string): ConnectionContextValue;
|
|
15
|
+
//# sourceMappingURL=useConnectionContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConnectionContext.d.ts","sourceRoot":"","sources":["../../src/hooks/useConnectionContext.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,iCAAiC,CAAA;AAExC;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,CAM7E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the connection context, throwing the canonical
|
|
5
|
+
* "must be used within a ConnectionProvider" error when the hook is used
|
|
6
|
+
* outside the provider tree. Centralizes the guard every hook needs so the
|
|
7
|
+
* check and its message live in one place.
|
|
8
|
+
*
|
|
9
|
+
* Note: a non-null context can still carry a `null` connector (a wallet-less
|
|
10
|
+
* session — see `ConnectionContextValue.connector`). Callers that need the
|
|
11
|
+
* connector must handle that case; this guard only covers "no provider".
|
|
12
|
+
*
|
|
13
|
+
* @param hookName - Name used in the error, e.g. `'useSession'`.
|
|
14
|
+
*/
|
|
15
|
+
export function useConnectionContext(hookName) {
|
|
16
|
+
const context = useContext(ConnectionContext);
|
|
17
|
+
if (!context) {
|
|
18
|
+
throw new Error(`${hookName} must be used within a ConnectionProvider`);
|
|
19
|
+
}
|
|
20
|
+
return context;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=useConnectionContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useConnectionContext.js","sourceRoot":"","sources":["../../src/hooks/useConnectionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EACL,iBAAiB,EAElB,MAAM,iCAAiC,CAAA;AAExC;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,MAAM,OAAO,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAA;IAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,QAAQ,2CAA2C,CAAC,CAAA;IACzE,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDetectedWallets.d.ts","sourceRoot":"","sources":["../../src/hooks/useDetectedWallets.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,wBAAwB,EAEzB,MAAM,wBAAwB,CAAA;AAE/B,wBAAgB,kBAAkB,IAAI,wBAAwB,
|
|
1
|
+
{"version":3,"file":"useDetectedWallets.d.ts","sourceRoot":"","sources":["../../src/hooks/useDetectedWallets.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,wBAAwB,EAEzB,MAAM,wBAAwB,CAAA;AAE/B,wBAAgB,kBAAkB,IAAI,wBAAwB,CA0B7D"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
3
|
export function useDetectedWallets() {
|
|
4
|
-
const context =
|
|
5
|
-
if (!context) {
|
|
6
|
-
throw new Error('useInjectedAvailableWallets must be used within a ConnectionProvider');
|
|
7
|
-
}
|
|
4
|
+
const context = useConnectionContext('useInjectedAvailableWallets');
|
|
8
5
|
const { connector, wallets, isReady } = context;
|
|
9
6
|
const [detectedWallets, setDetectedWallets] = useState([]);
|
|
10
7
|
useEffect(() => {
|
|
8
|
+
// No connector (wallet-less session): nothing can be detected.
|
|
9
|
+
if (!connector)
|
|
10
|
+
return;
|
|
11
11
|
const checkState = () => {
|
|
12
12
|
const newDetectedWallets = wallets.filter(wallet => connector.isConnectionModeAvailable('injected', wallet.id));
|
|
13
13
|
setDetectedWallets(newDetectedWallets);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDetectedWallets.js","sourceRoot":"","sources":["../../src/hooks/useDetectedWallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useDetectedWallets.js","sourceRoot":"","sources":["../../src/hooks/useDetectedWallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAM7D,MAAM,UAAU,kBAAkB;IAChC,MAAM,OAAO,GAAG,oBAAoB,CAAC,6BAA6B,CAAC,CAAA;IACnE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAE/C,MAAM,CAAC,eAAe,EAAE,kBAAkB,CAAC,GAAG,QAAQ,CAAmB,EAAE,CAAC,CAAA;IAE5E,SAAS,CAAC,GAAG,EAAE;QACb,+DAA+D;QAC/D,IAAI,CAAC,SAAS;YAAE,OAAM;QAEtB,MAAM,UAAU,GAAG,GAAG,EAAE;YACtB,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CACjD,SAAS,CAAC,yBAAyB,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,CAAC,CAC3D,CAAA;YAED,kBAAkB,CAAC,kBAAkB,CAAC,CAAA;QACxC,CAAC,CAAA;QAED,uCAAuC;QACvC,UAAU,EAAE,CAAA;QACZ,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAEnD,OAAO,WAAW,CAAA;IACpB,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAA;IAExB,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,CAAA;AACrC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDisconnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useDisconnect.ts"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/B,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,IAAI,mBAAmB,
|
|
1
|
+
{"version":3,"file":"useDisconnect.d.ts","sourceRoot":"","sources":["../../src/hooks/useDisconnect.ts"],"names":[],"mappings":"AAGA,UAAU,mBAAmB;IAC3B,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/B,SAAS,EAAE,OAAO,CAAA;CACnB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,aAAa,IAAI,mBAAmB,CAqBnD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for disconnecting the current wallet
|
|
5
5
|
* @returns Disconnect function and loading state
|
|
@@ -21,13 +21,13 @@ import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
23
|
export function useDisconnect() {
|
|
24
|
-
const context =
|
|
25
|
-
if (!context) {
|
|
26
|
-
throw new Error('useDisconnect must be used within a ConnectionProvider');
|
|
27
|
-
}
|
|
24
|
+
const context = useConnectionContext('useDisconnect');
|
|
28
25
|
const { connector } = context;
|
|
29
26
|
const [isLoading, setIsLoading] = useState(false);
|
|
30
27
|
const disconnect = useCallback(async () => {
|
|
28
|
+
// No connector (wallet-less session) means nothing to disconnect.
|
|
29
|
+
if (!connector)
|
|
30
|
+
return;
|
|
31
31
|
setIsLoading(true);
|
|
32
32
|
try {
|
|
33
33
|
await connector.disconnect();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDisconnect.js","sourceRoot":"","sources":["../../src/hooks/useDisconnect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useDisconnect.js","sourceRoot":"","sources":["../../src/hooks/useDisconnect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAO7D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,OAAO,GAAG,oBAAoB,CAAC,eAAe,CAAC,CAAA;IACrD,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAC7B,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEjD,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QACxC,kEAAkE;QAClE,IAAI,CAAC,SAAS;YAAE,OAAM;QAEtB,YAAY,CAAC,IAAI,CAAC,CAAA;QAClB,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,UAAU,EAAE,CAAA;QAC9B,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;IACH,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAEf,OAAO;QACL,UAAU;QACV,SAAS;KACV,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNetworks.d.ts","sourceRoot":"","sources":["../../src/hooks/useNetworks.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNetworks.d.ts","sourceRoot":"","sources":["../../src/hooks/useNetworks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAErD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,IAAI,OAAO,EAAE,CAGvC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
1
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
2
|
/**
|
|
4
3
|
* Hook for accessing the list of configured networks
|
|
5
4
|
* @returns Array of network configurations
|
|
@@ -14,10 +13,7 @@ import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
|
14
13
|
* ```
|
|
15
14
|
*/
|
|
16
15
|
export function useNetworks() {
|
|
17
|
-
const context =
|
|
18
|
-
if (!context) {
|
|
19
|
-
throw new Error('useNetworks must be used within a ConnectionProvider');
|
|
20
|
-
}
|
|
16
|
+
const context = useConnectionContext('useNetworks');
|
|
21
17
|
return context.networks;
|
|
22
18
|
}
|
|
23
19
|
//# sourceMappingURL=useNetworks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNetworks.js","sourceRoot":"","sources":["../../src/hooks/useNetworks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useNetworks.js","sourceRoot":"","sources":["../../src/hooks/useNetworks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAG7D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,OAAO,GAAG,oBAAoB,CAAC,aAAa,CAAC,CAAA;IACnD,OAAO,OAAO,CAAC,QAAQ,CAAA;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSession.d.ts","sourceRoot":"","sources":["../../src/hooks/useSession.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSession.d.ts","sourceRoot":"","sources":["../../src/hooks/useSession.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAE9D;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,IAAI,gBAAgB,CAe7C"}
|
package/dist/hooks/useSession.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
1
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
2
|
/**
|
|
4
3
|
* Hook for accessing the current wallet session state
|
|
5
4
|
* @returns Session information including active address, network, and connection details
|
|
@@ -16,10 +15,7 @@ import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
|
16
15
|
* ```
|
|
17
16
|
*/
|
|
18
17
|
export function useSession() {
|
|
19
|
-
const context =
|
|
20
|
-
if (!context) {
|
|
21
|
-
throw new Error('useSession must be used within a ConnectionProvider');
|
|
22
|
-
}
|
|
18
|
+
const context = useConnectionContext('useSession');
|
|
23
19
|
const { session } = context;
|
|
24
20
|
return {
|
|
25
21
|
session,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSession.js","sourceRoot":"","sources":["../../src/hooks/useSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useSession.js","sourceRoot":"","sources":["../../src/hooks/useSession.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAG7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,OAAO,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAA;IAClD,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAE3B,OAAO;QACL,OAAO;QACP,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,wBAAwB,EAAE,OAAO,CAAC,wBAAwB;QAC1D,+BAA+B,EAAE,OAAO,CAAC,+BAA+B;QACxE,iBAAiB,EAAE,OAAO,CAAC,iBAAiB;QAC5C,eAAe,EAAE,OAAO,CAAC,cAAc;QACvC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;QAC9C,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignMessage.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignMessage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,
|
|
1
|
+
{"version":3,"file":"useSignMessage.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignMessage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CAwCrD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for signing messages with the connected wallet
|
|
5
5
|
* @returns Object containing signMessage function, loading state, and last signature
|
|
@@ -20,16 +20,13 @@ import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export function useSignMessage() {
|
|
23
|
-
const context =
|
|
24
|
-
if (!context) {
|
|
25
|
-
throw new Error('useSignMessage must be used within a ConnectionProvider');
|
|
26
|
-
}
|
|
23
|
+
const context = useConnectionContext('useSignMessage');
|
|
27
24
|
const { connector, session } = context;
|
|
28
25
|
const [isLoading, setIsLoading] = useState(false);
|
|
29
26
|
const [signature, setSignature] = useState();
|
|
30
27
|
const [error, setError] = useState();
|
|
31
28
|
const signMessage = useCallback(async (message) => {
|
|
32
|
-
if (!session.activeAddress) {
|
|
29
|
+
if (!connector || !session.activeAddress) {
|
|
33
30
|
throw new Error('No wallet connected');
|
|
34
31
|
}
|
|
35
32
|
if (!message) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignMessage.js","sourceRoot":"","sources":["../../src/hooks/useSignMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useSignMessage.js","sourceRoot":"","sources":["../../src/hooks/useSignMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAO7D;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAA;IACtD,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IACtC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAA6B,CAAA;IACvE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA2B,CAAA;IAE7D,MAAM,WAAW,GAAG,WAAW,CAC7B,KAAK,EAAE,OAAe,EAA0B,EAAE;QAChD,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACxC,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACxC,CAAC;QAED,YAAY,CAAC,IAAI,CAAC,CAAA;QAClB,QAAQ,CAAC,SAAS,CAAC,CAAA;QACnB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;YAChD,YAAY,CAAC,GAAG,CAAC,CAAA;YACjB,OAAO,GAAG,CAAA;QACZ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,WAAW,GAAG,GAAkB,CAAA;YACtC,QAAQ,CAAC,WAAW,CAAC,CAAA;YACrB,MAAM,GAAG,CAAA;QACX,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;IACH,CAAC,EACD,CAAC,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,CACnC,CAAA;IAED,OAAO;QACL,WAAW;QACX,SAAS;QACT,SAAS;QACT,KAAK;KACN,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignSolanaTransaction.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignSolanaTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,8BAA8B,EAE/B,MAAM,wBAAwB,CAAA;AAE/B,wBAAgB,wBAAwB,IAAI,8BAA8B,
|
|
1
|
+
{"version":3,"file":"useSignSolanaTransaction.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignSolanaTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,8BAA8B,EAE/B,MAAM,wBAAwB,CAAA;AAE/B,wBAAgB,wBAAwB,IAAI,8BAA8B,CAgCzE"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
3
|
export function useSignSolanaTransaction() {
|
|
4
|
-
const context =
|
|
5
|
-
if (!context) {
|
|
6
|
-
throw new Error('useSignSolanaTransaction must be used within a ConnectionProvider');
|
|
7
|
-
}
|
|
4
|
+
const context = useConnectionContext('useSignSolanaTransaction');
|
|
8
5
|
const { connector, session } = context;
|
|
9
6
|
const [isLoading, setIsLoading] = useState(false);
|
|
10
7
|
const [error, setError] = useState();
|
|
11
8
|
const signSolanaTransaction = useCallback(async (serializedTx) => {
|
|
12
|
-
if (!session.activeAddress) {
|
|
9
|
+
if (!connector || !session.activeAddress) {
|
|
13
10
|
throw new Error('No wallet connected');
|
|
14
11
|
}
|
|
15
12
|
if (!serializedTx?.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignSolanaTransaction.js","sourceRoot":"","sources":["../../src/hooks/useSignSolanaTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useSignSolanaTransaction.js","sourceRoot":"","sources":["../../src/hooks/useSignSolanaTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAM7D,MAAM,UAAU,wBAAwB;IACtC,MAAM,OAAO,GAAG,oBAAoB,CAAC,0BAA0B,CAAC,CAAA;IAChE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IACtC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA2B,CAAA;IAE7D,MAAM,qBAAqB,GAAG,WAAW,CACvC,KAAK,EAAE,YAAwB,EAAuB,EAAE;QACtD,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACxC,CAAC;QAED,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAA;QACnD,CAAC;QAED,YAAY,CAAC,IAAI,CAAC,CAAA;QAClB,QAAQ,CAAC,SAAS,CAAC,CAAA;QACnB,IAAI,CAAC;YACH,OAAO,MAAM,SAAS,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAA;QAC5D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,WAAW,GAAG,GAAkB,CAAA;YACtC,QAAQ,CAAC,WAAW,CAAC,CAAA;YACrB,MAAM,GAAG,CAAA;QACX,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;IACH,CAAC,EACD,CAAC,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,CACnC,CAAA;IAED,OAAO,EAAE,qBAAqB,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;AACpD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignTypedData.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignTypedData.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,
|
|
1
|
+
{"version":3,"file":"useSignTypedData.d.ts","sourceRoot":"","sources":["../../src/hooks/useSignTypedData.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAoCzD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for signing EIP-712 typed structured data (eth_signTypedData_v4).
|
|
5
5
|
*
|
|
@@ -24,16 +24,13 @@ import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
26
|
export function useSignTypedData() {
|
|
27
|
-
const context =
|
|
28
|
-
if (!context) {
|
|
29
|
-
throw new Error('useSignTypedData must be used within a ConnectionProvider');
|
|
30
|
-
}
|
|
27
|
+
const context = useConnectionContext('useSignTypedData');
|
|
31
28
|
const { connector, session } = context;
|
|
32
29
|
const [isLoading, setIsLoading] = useState(false);
|
|
33
30
|
const [signature, setSignature] = useState();
|
|
34
31
|
const [error, setError] = useState();
|
|
35
32
|
const signTypedData = useCallback(async (typedData) => {
|
|
36
|
-
if (!session.activeAddress) {
|
|
33
|
+
if (!connector || !session.activeAddress) {
|
|
37
34
|
throw new Error('No wallet connected');
|
|
38
35
|
}
|
|
39
36
|
setIsLoading(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignTypedData.js","sourceRoot":"","sources":["../../src/hooks/useSignTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useSignTypedData.js","sourceRoot":"","sources":["../../src/hooks/useSignTypedData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAO7D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,CAAA;IACxD,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IACtC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjD,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,EAAsB,CAAA;IAChE,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA2B,CAAA;IAE7D,MAAM,aAAa,GAAG,WAAW,CAC/B,KAAK,EAAE,SAA0B,EAAmB,EAAE;QACpD,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACxC,CAAC;QAED,YAAY,CAAC,IAAI,CAAC,CAAA;QAClB,QAAQ,CAAC,SAAS,CAAC,CAAA;QACnB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;YACpD,YAAY,CAAC,GAAG,CAAC,CAAA;YACjB,OAAO,GAAG,CAAA;QACZ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,WAAW,GAAG,GAAkB,CAAA;YACtC,QAAQ,CAAC,WAAW,CAAC,CAAA;YACrB,MAAM,GAAG,CAAA;QACX,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;IACH,CAAC,EACD,CAAC,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,CACnC,CAAA;IAED,OAAO;QACL,aAAa;QACb,SAAS;QACT,SAAS;QACT,KAAK;KACN,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSwitchNetwork.d.ts","sourceRoot":"","sources":["../../src/hooks/useSwitchNetwork.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,
|
|
1
|
+
{"version":3,"file":"useSwitchNetwork.d.ts","sourceRoot":"","sources":["../../src/hooks/useSwitchNetwork.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAEV,sBAAsB,EAEvB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAoDzD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useState, useEffect } from 'react';
|
|
2
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for switching networks on the connected wallet
|
|
5
5
|
* @returns Network switching function and loading states
|
|
@@ -26,16 +26,16 @@ import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
export function useSwitchNetwork() {
|
|
29
|
-
const context =
|
|
30
|
-
if (!context) {
|
|
31
|
-
throw new Error('useSwitchNetwork must be used within a ConnectionProvider');
|
|
32
|
-
}
|
|
29
|
+
const context = useConnectionContext('useSwitchNetwork');
|
|
33
30
|
const { connector } = context;
|
|
34
31
|
const [isLoading, setIsLoading] = useState(false);
|
|
35
32
|
const [isWaitingForUserApproval, setIsWaitingForUserApproval] = useState(false);
|
|
36
33
|
const [error, setError] = useState();
|
|
37
34
|
// Subscribe to loading state changes from the core
|
|
38
35
|
useEffect(() => {
|
|
36
|
+
// No connector (wallet-less session): no switch state to track.
|
|
37
|
+
if (!connector)
|
|
38
|
+
return;
|
|
39
39
|
const updateLoadingState = () => {
|
|
40
40
|
const state = connector.getNetworkSwitchLoadingState();
|
|
41
41
|
setIsLoading(state.isLoading);
|
|
@@ -48,6 +48,9 @@ export function useSwitchNetwork() {
|
|
|
48
48
|
return unsubscribe;
|
|
49
49
|
}, [connector]);
|
|
50
50
|
const switchNetwork = useCallback(async (networkId) => {
|
|
51
|
+
if (!connector) {
|
|
52
|
+
throw new Error('No wallet connected');
|
|
53
|
+
}
|
|
51
54
|
setError(undefined);
|
|
52
55
|
try {
|
|
53
56
|
await connector.switchNetwork(networkId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSwitchNetwork.js","sourceRoot":"","sources":["../../src/hooks/useSwitchNetwork.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useSwitchNetwork.js","sourceRoot":"","sources":["../../src/hooks/useSwitchNetwork.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAO7D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,gBAAgB;IAC9B,MAAM,OAAO,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,CAAA;IACxD,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAA;IAC7B,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjD,MAAM,CAAC,wBAAwB,EAAE,2BAA2B,CAAC,GAC3D,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA2B,CAAA;IAE7D,mDAAmD;IACnD,SAAS,CAAC,GAAG,EAAE;QACb,gEAAgE;QAChE,IAAI,CAAC,SAAS;YAAE,OAAM;QAEtB,MAAM,kBAAkB,GAAG,GAAG,EAAE;YAC9B,MAAM,KAAK,GAAG,SAAS,CAAC,4BAA4B,EAAE,CAAA;YACtD,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;YAC7B,2BAA2B,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAA;QAC7D,CAAC,CAAA;QAED,sBAAsB;QACtB,kBAAkB,EAAE,CAAA;QAEpB,uBAAuB;QACvB,MAAM,WAAW,GAAG,SAAS,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAA;QAE3D,OAAO,WAAW,CAAA;IACpB,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAA;IAEf,MAAM,aAAa,GAAG,WAAW,CAC/B,KAAK,EAAE,SAAoB,EAAE,EAAE;QAC7B,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACxC,CAAC;QAED,QAAQ,CAAC,SAAS,CAAC,CAAA;QACnB,IAAI,CAAC;YACH,MAAM,SAAS,CAAC,aAAa,CAAC,SAAS,CAAC,CAAA;QAC1C,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,WAAW,GAAG,GAAkB,CAAA;YACtC,QAAQ,CAAC,WAAW,CAAC,CAAA;YACrB,MAAM,GAAG,CAAA;QACX,CAAC;IACH,CAAC,EACD,CAAC,SAAS,CAAC,CACZ,CAAA;IAED,OAAO;QACL,aAAa;QACb,SAAS;QACT,wBAAwB;QACxB,KAAK;KACN,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransaction.d.ts","sourceRoot":"","sources":["../../src/hooks/useTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,oBAAoB,EAErB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,
|
|
1
|
+
{"version":3,"file":"useTransaction.d.ts","sourceRoot":"","sources":["../../src/hooks/useTransaction.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,oBAAoB,EAErB,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CA0CrD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for sending transactions with the connected wallet
|
|
5
5
|
* @returns Object containing sendTransaction function, loading state, and transaction result
|
|
@@ -23,16 +23,13 @@ import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
25
|
export function useTransaction() {
|
|
26
|
-
const context =
|
|
27
|
-
if (!context) {
|
|
28
|
-
throw new Error('useTransaction must be used within a ConnectionProvider');
|
|
29
|
-
}
|
|
26
|
+
const context = useConnectionContext('useTransaction');
|
|
30
27
|
const { connector, session } = context;
|
|
31
28
|
const [isLoading, setIsLoading] = useState(false);
|
|
32
29
|
const [transactionResult, setTransactionResult] = useState();
|
|
33
30
|
const [error, setError] = useState();
|
|
34
31
|
const sendTransaction = useCallback(async (request) => {
|
|
35
|
-
if (!session.activeAddress) {
|
|
32
|
+
if (!connector || !session.activeAddress) {
|
|
36
33
|
throw new Error('No wallet connected');
|
|
37
34
|
}
|
|
38
35
|
if (!request) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTransaction.js","sourceRoot":"","sources":["../../src/hooks/useTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useTransaction.js","sourceRoot":"","sources":["../../src/hooks/useTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAQ7D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,cAAc;IAC5B,MAAM,OAAO,GAAG,oBAAoB,CAAC,gBAAgB,CAAC,CAAA;IACtD,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IACtC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjD,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,QAAQ,EAEvD,CAAA;IACH,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA2B,CAAA;IAE7D,MAAM,eAAe,GAAG,WAAW,CACjC,KAAK,EAAE,OAA2B,EAA8B,EAAE;QAChE,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;YACzC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAA;QACxC,CAAC;QAED,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAA;QACpD,CAAC;QAED,YAAY,CAAC,IAAI,CAAC,CAAA;QAClB,QAAQ,CAAC,SAAS,CAAC,CAAA;QACnB,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;YACvD,oBAAoB,CAAC,MAAM,CAAC,CAAA;YAC5B,OAAO,MAAM,CAAA;QACf,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,WAAW,GAAG,GAAkB,CAAA;YACtC,QAAQ,CAAC,WAAW,CAAC,CAAA;YACrB,MAAM,GAAG,CAAA;QACX,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;IACH,CAAC,EACD,CAAC,SAAS,EAAE,OAAO,CAAC,aAAa,CAAC,CACnC,CAAA;IAED,OAAO;QACL,eAAe;QACf,SAAS;QACT,iBAAiB;QACjB,KAAK;KACN,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWallet.d.ts","sourceRoot":"","sources":["../../src/hooks/useWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useWallet.d.ts","sourceRoot":"","sources":["../../src/hooks/useWallet.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAG7E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CAgB3D"}
|
package/dist/hooks/useWallet.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
1
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
2
|
import { WalletConnectorError } from '@meshconnect/uwc-types';
|
|
4
3
|
/**
|
|
5
4
|
* Hook for accessing a specific wallet configuration
|
|
@@ -16,10 +15,7 @@ import { WalletConnectorError } from '@meshconnect/uwc-types';
|
|
|
16
15
|
* }
|
|
17
16
|
*/
|
|
18
17
|
export function useWallet(walletId) {
|
|
19
|
-
const context =
|
|
20
|
-
if (!context) {
|
|
21
|
-
throw new Error('useWallet must be used within a ConnectionProvider');
|
|
22
|
-
}
|
|
18
|
+
const context = useConnectionContext('useWallet');
|
|
23
19
|
const selectedWallet = context.wallets.find((wallet) => wallet.id === walletId);
|
|
24
20
|
if (!selectedWallet) {
|
|
25
21
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWallet.js","sourceRoot":"","sources":["../../src/hooks/useWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useWallet.js","sourceRoot":"","sources":["../../src/hooks/useWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAE7D;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,SAAS,CAAC,QAAgB;IACxC,MAAM,OAAO,GAAG,oBAAoB,CAAC,WAAW,CAAC,CAAA;IACjD,MAAM,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CACzC,CAAC,MAAsB,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,QAAQ,CACnD,CAAA;IAED,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO;YACL,KAAK,EAAE,IAAI,oBAAoB,CAAC;gBAC9B,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,mBAAmB,QAAQ,aAAa;aAClD,CAAC;SACH,CAAA;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,CAAA;AACnC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWalletCapabilities.d.ts","sourceRoot":"","sources":["../../src/hooks/useWalletCapabilities.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,IAAI,2BAA2B,
|
|
1
|
+
{"version":3,"file":"useWalletCapabilities.d.ts","sourceRoot":"","sources":["../../src/hooks/useWalletCapabilities.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,wBAAwB,CAAA;AAE/B;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,qBAAqB,IAAI,2BAA2B,CA2CnE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
3
|
/**
|
|
4
4
|
* Hook for managing wallet capabilities
|
|
5
5
|
* @returns Wallet capabilities state and a fetch function to manually fetch capabilities
|
|
@@ -22,17 +22,15 @@ import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
export function useWalletCapabilities() {
|
|
25
|
-
const context =
|
|
26
|
-
if (!context) {
|
|
27
|
-
throw new Error('useWalletCapabilities must be used within a ConnectionProvider');
|
|
28
|
-
}
|
|
25
|
+
const context = useConnectionContext('useWalletCapabilities');
|
|
29
26
|
const { connector, session } = context;
|
|
30
27
|
const [isLoading, setIsLoading] = useState(false);
|
|
31
28
|
const [error, setError] = useState();
|
|
32
29
|
// Manual fetch function to be called from the app
|
|
33
30
|
const fetchCapabilities = useCallback(async () => {
|
|
34
|
-
//
|
|
35
|
-
|
|
31
|
+
// No connector (wallet-less session) or no active session/address: nothing
|
|
32
|
+
// to fetch.
|
|
33
|
+
if (!connector || !session?.activeAddress || !session?.connectionMode) {
|
|
36
34
|
return;
|
|
37
35
|
}
|
|
38
36
|
setIsLoading(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWalletCapabilities.js","sourceRoot":"","sources":["../../src/hooks/useWalletCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useWalletCapabilities.js","sourceRoot":"","sources":["../../src/hooks/useWalletCapabilities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAM7D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,qBAAqB;IACnC,MAAM,OAAO,GAAG,oBAAoB,CAAC,uBAAuB,CAAC,CAAA;IAC7D,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,OAAO,CAAA;IAEtC,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,EAA2B,CAAA;IAE7D,kDAAkD;IAClD,MAAM,iBAAiB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC/C,2EAA2E;QAC3E,YAAY;QACZ,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE,aAAa,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,CAAC;YACtE,OAAM;QACR,CAAC;QAED,YAAY,CAAC,IAAI,CAAC,CAAA;QAClB,QAAQ,CAAC,SAAS,CAAC,CAAA;QAEnB,IAAI,CAAC;YACH,+DAA+D;YAC/D,MAAM,YAAY,GAAG,SAAS;iBAC3B,WAAW,EAAE;iBACb,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAA;YAEhD,MAAM,SAAS,CAAC,qBAAqB,CAAC,OAAO,CAAC,aAAa,EAAE,YAAY,CAAC,CAAA;QAC5E,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,WAAW,GAAG,GAAkB,CAAA;YACtC,QAAQ,CAAC,WAAW,CAAC,CAAA;QACvB,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,KAAK,CAAC,CAAA;QACrB,CAAC;IACH,CAAC,EAAE;QACD,OAAO,EAAE,aAAa;QACtB,OAAO,EAAE,cAAc;QACvB,OAAO,EAAE,aAAa;QACtB,SAAS;KACV,CAAC,CAAA;IAEF,OAAO;QACL,SAAS;QACT,KAAK;QACL,iBAAiB;KAClB,CAAA;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWallets.d.ts","sourceRoot":"","sources":["../../src/hooks/useWallets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useWallets.d.ts","sourceRoot":"","sources":["../../src/hooks/useWallets.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAE5D;;;;;;;;;;;;GAYG;AACH,wBAAgB,UAAU,IAAI,cAAc,EAAE,CAG7C"}
|
package/dist/hooks/useWallets.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
1
|
+
import { useConnectionContext } from './useConnectionContext';
|
|
3
2
|
/**
|
|
4
3
|
* Hook for accessing the list of configured wallets
|
|
5
4
|
* @returns Array of wallet metadata including names, IDs, and supported networks
|
|
@@ -14,10 +13,7 @@ import { ConnectionContext } from '../providers/ConnectionProvider';
|
|
|
14
13
|
* ```
|
|
15
14
|
*/
|
|
16
15
|
export function useWallets() {
|
|
17
|
-
const context =
|
|
18
|
-
if (!context) {
|
|
19
|
-
throw new Error('useWallets must be used within a ConnectionProvider');
|
|
20
|
-
}
|
|
16
|
+
const context = useConnectionContext('useWallets');
|
|
21
17
|
return context.wallets;
|
|
22
18
|
}
|
|
23
19
|
//# sourceMappingURL=useWallets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useWallets.js","sourceRoot":"","sources":["../../src/hooks/useWallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useWallets.js","sourceRoot":"","sources":["../../src/hooks/useWallets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAG7D;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,OAAO,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAA;IAClD,OAAO,OAAO,CAAC,OAAO,CAAA;AACxB,CAAC"}
|