@reown/appkit-react-native 0.0.0-chore-use-theme-hook-20251105184714 → 0.0.0-chore-use-theme-hook-20251105193739
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/lib/commonjs/hooks/useAccount.js +2 -3
- package/lib/commonjs/hooks/useAccount.js.map +1 -1
- package/lib/commonjs/hooks/useAppKit.js +41 -9
- package/lib/commonjs/hooks/useAppKit.js.map +1 -1
- package/lib/commonjs/hooks/useAppKitContext.js +46 -0
- package/lib/commonjs/hooks/useAppKitContext.js.map +1 -0
- package/lib/commonjs/hooks/useAppKitEvents.js +64 -4
- package/lib/commonjs/hooks/useAppKitEvents.js.map +1 -1
- package/lib/commonjs/hooks/useAppKitLogs.js +2 -8
- package/lib/commonjs/hooks/useAppKitLogs.js.map +1 -1
- package/lib/commonjs/hooks/useAppKitState.js +35 -2
- package/lib/commonjs/hooks/useAppKitState.js.map +1 -1
- package/lib/commonjs/hooks/useAppKitTheme.js +2 -2
- package/lib/commonjs/hooks/useAppKitTheme.js.map +1 -1
- package/lib/commonjs/hooks/useProvider.js +3 -4
- package/lib/commonjs/hooks/useProvider.js.map +1 -1
- package/lib/commonjs/hooks/useWalletInfo.js +33 -2
- package/lib/commonjs/hooks/useWalletInfo.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/hooks/useAccount.js +2 -3
- package/lib/module/hooks/useAccount.js.map +1 -1
- package/lib/module/hooks/useAppKit.js +43 -10
- package/lib/module/hooks/useAppKit.js.map +1 -1
- package/lib/module/hooks/useAppKitContext.js +42 -0
- package/lib/module/hooks/useAppKitContext.js.map +1 -0
- package/lib/module/hooks/useAppKitEvents.js +65 -4
- package/lib/module/hooks/useAppKitEvents.js.map +1 -1
- package/lib/module/hooks/useAppKitLogs.js +3 -9
- package/lib/module/hooks/useAppKitLogs.js.map +1 -1
- package/lib/module/hooks/useAppKitState.js +36 -2
- package/lib/module/hooks/useAppKitState.js.map +1 -1
- package/lib/module/hooks/useAppKitTheme.js +2 -2
- package/lib/module/hooks/useAppKitTheme.js.map +1 -1
- package/lib/module/hooks/useProvider.js +3 -4
- package/lib/module/hooks/useProvider.js.map +1 -1
- package/lib/module/hooks/useWalletInfo.js +34 -2
- package/lib/module/hooks/useWalletInfo.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/AppKitContext.d.ts +1 -1
- package/lib/typescript/AppKitContext.d.ts.map +1 -1
- package/lib/typescript/hooks/useAccount.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKit.d.ts +42 -0
- package/lib/typescript/hooks/useAppKit.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKitContext.d.ts +27 -0
- package/lib/typescript/hooks/useAppKitContext.d.ts.map +1 -0
- package/lib/typescript/hooks/useAppKitEvents.d.ts +59 -0
- package/lib/typescript/hooks/useAppKitEvents.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKitLogs.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKitState.d.ts +32 -0
- package/lib/typescript/hooks/useAppKitState.d.ts.map +1 -1
- package/lib/typescript/hooks/useAppKitTheme.d.ts +1 -2
- package/lib/typescript/hooks/useAppKitTheme.d.ts.map +1 -1
- package/lib/typescript/hooks/useProvider.d.ts +1 -4
- package/lib/typescript/hooks/useProvider.d.ts.map +1 -1
- package/lib/typescript/hooks/useWalletInfo.d.ts +31 -0
- package/lib/typescript/hooks/useWalletInfo.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/AppKitContext.tsx +1 -1
- package/src/hooks/useAccount.ts +2 -2
- package/src/hooks/useAppKit.ts +45 -12
- package/src/hooks/useAppKitContext.ts +43 -0
- package/src/hooks/useAppKitEvents.ts +63 -3
- package/src/hooks/useAppKitLogs.ts +3 -11
- package/src/hooks/useAppKitState.ts +35 -2
- package/src/hooks/useAppKitTheme.ts +3 -3
- package/src/hooks/useProvider.ts +3 -4
- package/src/hooks/useWalletInfo.ts +33 -2
- package/src/index.ts +1 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useContext } from 'react';
|
|
4
|
+
import { AppKitContext } from '../AppKitContext';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Hook to access the AppKit context
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* This is an internal hook used by other AppKit hooks to ensure they're used within
|
|
11
|
+
* the AppKitProvider. You typically don't need to use this hook directly - use the
|
|
12
|
+
* higher-level hooks like `useAppKit`, `useAccount`, `useAppKitTheme`, etc. instead.
|
|
13
|
+
*
|
|
14
|
+
* @returns {AppKitContextType} The AppKit context containing the AppKit instance
|
|
15
|
+
*
|
|
16
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
17
|
+
* @throws {Error} If the AppKit instance is not yet available in context
|
|
18
|
+
*
|
|
19
|
+
* @internal
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* // This is typically used internally by other hooks
|
|
24
|
+
* function MyCustomHook() {
|
|
25
|
+
* const context = useAppKitContext();
|
|
26
|
+
* // Use context.appKit...
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
export const useAppKitContext = () => {
|
|
32
|
+
const context = useContext(AppKitContext);
|
|
33
|
+
if (context === undefined) {
|
|
34
|
+
throw new Error('useAppKit must be used within an AppKitProvider');
|
|
35
|
+
}
|
|
36
|
+
if (!context.appKit) {
|
|
37
|
+
// This might happen if the provider is rendered before AppKit is initialized
|
|
38
|
+
throw new Error('AppKit instance is not yet available in context.');
|
|
39
|
+
}
|
|
40
|
+
return context;
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=useAppKitContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useContext","AppKitContext","useAppKitContext","context","undefined","Error","appKit"],"sourceRoot":"../../../src","sources":["hooks/useAppKitContext.ts"],"mappings":";;AAAA,SAASA,UAAU,QAAQ,OAAO;AAElC,SAASC,aAAa,QAAgC,kBAAkB;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAyB;EACvD,MAAMC,OAAO,GAAGH,UAAU,CAACC,aAAa,CAAC;EAEzC,IAAIE,OAAO,KAAKC,SAAS,EAAE;IACzB,MAAM,IAAIC,KAAK,CAAC,iDAAiD,CAAC;EACpE;EAEA,IAAI,CAACF,OAAO,CAACG,MAAM,EAAE;IACnB;IACA,MAAM,IAAID,KAAK,CAAC,kDAAkD,CAAC;EACrE;EAEA,OAAOF,OAAO;AAChB,CAAC","ignoreList":[]}
|
|
@@ -3,9 +3,42 @@
|
|
|
3
3
|
import { useEffect } from 'react';
|
|
4
4
|
import { useSnapshot } from 'valtio';
|
|
5
5
|
import { EventsController } from '@reown/appkit-core-react-native';
|
|
6
|
-
import {
|
|
6
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hook to subscribe to all AppKit events
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This hook provides reactive access to AppKit's event system, allowing you to
|
|
13
|
+
* monitor all events that occur within the AppKit lifecycle (connections, disconnections,
|
|
14
|
+
* network changes, etc.). The callback is invoked whenever a new event is emitted.
|
|
15
|
+
*
|
|
16
|
+
* @param callback - Optional callback function invoked when any event occurs
|
|
17
|
+
*
|
|
18
|
+
* @returns An object containing:
|
|
19
|
+
* - `data`: The most recent event data
|
|
20
|
+
* - `timestamp`: The timestamp of the most recent event
|
|
21
|
+
*
|
|
22
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* function MyComponent() {
|
|
27
|
+
* const { data, timestamp } = useAppKitEvents((event) => {
|
|
28
|
+
* console.log('Event occurred:', event.data.event);
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* return (
|
|
32
|
+
* <View>
|
|
33
|
+
* <Text>Last event: {data?.event}</Text>
|
|
34
|
+
* <Text>Time: {timestamp}</Text>
|
|
35
|
+
* </View>
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
7
40
|
export function useAppKitEvents(callback) {
|
|
8
|
-
|
|
41
|
+
useAppKitContext();
|
|
9
42
|
const {
|
|
10
43
|
data,
|
|
11
44
|
timestamp
|
|
@@ -23,9 +56,37 @@ export function useAppKitEvents(callback) {
|
|
|
23
56
|
timestamp
|
|
24
57
|
};
|
|
25
58
|
}
|
|
26
|
-
export function useAppKitEventSubscription(event, callback) {
|
|
27
|
-
useAppKit(); // Use the hook for checks
|
|
28
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Hook to subscribe to a specific AppKit event
|
|
62
|
+
*
|
|
63
|
+
* @remarks
|
|
64
|
+
* This hook allows you to listen for a specific event type rather than all events.
|
|
65
|
+
* It's more efficient than `useAppKitEvents` when you only care about a particular event.
|
|
66
|
+
*
|
|
67
|
+
* @param event - The specific event name to subscribe to (e.g., 'MODAL_OPEN', 'CONNECT_SUCCESS')
|
|
68
|
+
* @param callback - Callback function invoked when the specified event occurs
|
|
69
|
+
*
|
|
70
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```tsx
|
|
74
|
+
* function MyComponent() {
|
|
75
|
+
* useAppKitEventSubscription('CONNECT_SUCCESS', (event) => {
|
|
76
|
+
* console.log('Wallet connected!', event.data);
|
|
77
|
+
* });
|
|
78
|
+
*
|
|
79
|
+
* useAppKitEventSubscription('DISCONNECT_SUCCESS', (event) => {
|
|
80
|
+
* console.log('Wallet disconnected!', event.data);
|
|
81
|
+
* });
|
|
82
|
+
*
|
|
83
|
+
* return <View>{/ Your component /}</View>;
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
export function useAppKitEventSubscription(event, callback) {
|
|
89
|
+
useAppKitContext();
|
|
29
90
|
useEffect(() => {
|
|
30
91
|
const unsubscribe = EventsController?.subscribeEvent(event, callback);
|
|
31
92
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useSnapshot","EventsController","
|
|
1
|
+
{"version":3,"names":["useEffect","useSnapshot","EventsController","useAppKitContext","useAppKitEvents","callback","data","timestamp","state","unsubscribe","subscribe","newEvent","useAppKitEventSubscription","event","subscribeEvent"],"sourceRoot":"../../../src","sources":["hooks/useAppKitEvents.ts"],"mappings":";;AAAA,SAASA,SAAS,QAAQ,OAAO;AACjC,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,gBAAgB,QAAoC,iCAAiC;AAE9F,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAACC,QAAoD,EAAE;EACpFF,gBAAgB,CAAC,CAAC;EAClB,MAAM;IAAEG,IAAI;IAAEC;EAAU,CAAC,GAAGN,WAAW,CAACC,gBAAgB,CAACM,KAAK,CAAC;EAE/DR,SAAS,CAAC,MAAM;IACd,MAAMS,WAAW,GAAGP,gBAAgB,CAACQ,SAAS,CAACC,QAAQ,IAAI;MACzDN,QAAQ,GAAGM,QAAQ,CAAC;IACtB,CAAC,CAAC;IAEF,OAAO,MAAM;MACXF,WAAW,GAAG,CAAC;IACjB,CAAC;EACH,CAAC,EAAE,CAACJ,QAAQ,CAAC,CAAC;EAEd,OAAO;IAAEC,IAAI;IAAEC;EAAU,CAAC;AAC5B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASK,0BAA0BA,CACxCC,KAAgB,EAChBR,QAAmD,EACnD;EACAF,gBAAgB,CAAC,CAAC;EAElBH,SAAS,CAAC,MAAM;IACd,MAAMS,WAAW,GAAGP,gBAAgB,EAAEY,cAAc,CAACD,KAAK,EAAER,QAAQ,CAAC;IAErE,OAAO,MAAM;MACXI,WAAW,GAAG,CAAC;IACjB,CAAC;EACH,CAAC,EAAE,CAACJ,QAAQ,EAAEQ,KAAK,CAAC,CAAC;AACvB","ignoreList":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
4
|
import { useSnapshot } from 'valtio';
|
|
5
5
|
import { LogController } from '@reown/appkit-core-react-native';
|
|
6
|
-
import {
|
|
6
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
7
7
|
/**
|
|
8
8
|
* React hook for accessing AppKit logs
|
|
9
9
|
*
|
|
@@ -26,13 +26,7 @@ import { AppKitContext } from '../AppKitContext';
|
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
28
|
export const useAppKitLogs = () => {
|
|
29
|
-
|
|
30
|
-
if (context === undefined) {
|
|
31
|
-
throw new Error('useAppKitLogs must be used within an AppKitProvider');
|
|
32
|
-
}
|
|
33
|
-
if (!context.appKit) {
|
|
34
|
-
throw new Error('AppKit instance is not yet available in context.');
|
|
35
|
-
}
|
|
29
|
+
useAppKitContext();
|
|
36
30
|
const {
|
|
37
31
|
logs
|
|
38
32
|
} = useSnapshot(LogController.state);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["useMemo","useSnapshot","LogController","useAppKitContext","useAppKitLogs","logs","state","stableFunctions","getLogsByLevel","level","getRecentLogs","count","exportLogs","getLogsStats","clearLogs","regularArrays","allLogs","errorLogs","warningLogs","infoLogs","debugLogs","log","push"],"sourceRoot":"../../../src","sources":["hooks/useAppKitLogs.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,aAAa,QAAsC,iCAAiC;AAC7F,SAASC,gBAAgB,QAAQ,oBAAoB;AA0CrD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAA2B;EACtDD,gBAAgB,CAAC,CAAC;EAElB,MAAM;IAAEE;EAAK,CAAC,GAAGJ,WAAW,CAACC,aAAa,CAACI,KAAK,CAAC;;EAEjD;EACA,MAAMC,eAAe,GAAGP,OAAO,CAC7B,OAAO;IACLQ,cAAc,EAAGC,KAAe,IAAKP,aAAa,CAACM,cAAc,CAACC,KAAK,CAAC;IACxEC,aAAa,EAAGC,KAAc,IAAKT,aAAa,CAACQ,aAAa,CAACC,KAAK,CAAC;IACrEC,UAAU,EAAEA,CAAA,KAAMV,aAAa,CAACU,UAAU,CAAC,CAAC;IAC5CC,YAAY,EAAEA,CAAA,KAAMX,aAAa,CAACW,YAAY,CAAC,CAAC;IAChDC,SAAS,EAAEA,CAAA,KAAMZ,aAAa,CAACY,SAAS,CAAC;EAC3C,CAAC,CAAC,EACF,EACF,CAAC;EAED,MAAMC,aAAa,GAAGf,OAAO,CAAC,MAAM;IAClC,MAAMgB,OAAO,GAAG,CAAC,GAAGX,IAAI,CAAC,CAAC,CAAC;IAC3B,MAAMY,SAAqB,GAAG,EAAE;IAChC,MAAMC,WAAuB,GAAG,EAAE;IAClC,MAAMC,QAAoB,GAAG,EAAE;IAC/B,MAAMC,SAAqB,GAAG,EAAE;IAEhC,KAAK,MAAMC,GAAG,IAAIL,OAAO,EAAE;MACzB,QAAQK,GAAG,CAACZ,KAAK;QACf,KAAK,OAAO;UACVQ,SAAS,CAACK,IAAI,CAACD,GAAG,CAAC;UACnB;QACF,KAAK,MAAM;UACTH,WAAW,CAACI,IAAI,CAACD,GAAG,CAAC;UACrB;QACF,KAAK,MAAM;UACTF,QAAQ,CAACG,IAAI,CAACD,GAAG,CAAC;UAClB;QACF,KAAK,OAAO;UACVD,SAAS,CAACE,IAAI,CAACD,GAAG,CAAC;UACnB;MACJ;IACF;IAEA,OAAO;MACLhB,IAAI,EAAEW,OAAO;MACbC,SAAS;MACTC,WAAW;MACXC,QAAQ;MACRC;IACF,CAAC;EACH,CAAC,EAAE,CAACf,IAAI,CAAC,CAAC;EAEV,OAAO;IACL,GAAGU,aAAa;IAChB,GAAGR;EACL,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -4,9 +4,43 @@
|
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { useSnapshot } from 'valtio';
|
|
6
6
|
import { ConnectionsController, ModalController } from '@reown/appkit-core-react-native';
|
|
7
|
-
import {
|
|
7
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Hook to access the overall state of the AppKit modal and connection
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* This hook provides a high-level view of the AppKit's current state, including
|
|
14
|
+
* whether the modal is open, if it's loading, connection status, and the active chain.
|
|
15
|
+
* It's useful for coordinating UI elements with the AppKit's state.
|
|
16
|
+
*
|
|
17
|
+
* @returns An object containing:
|
|
18
|
+
* - `isOpen`: Whether the AppKit modal is currently open
|
|
19
|
+
* - `isLoading`: Whether the AppKit is in a loading state
|
|
20
|
+
* - `isConnected`: Whether a wallet is currently connected
|
|
21
|
+
* - `chain`: The currently active blockchain network
|
|
22
|
+
*
|
|
23
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* function MyComponent() {
|
|
28
|
+
* const { isOpen, isLoading, isConnected, chain } = useAppKitState();
|
|
29
|
+
*
|
|
30
|
+
* return (
|
|
31
|
+
* <View>
|
|
32
|
+
* <Text>Modal: {isOpen ? 'Open' : 'Closed'}</Text>
|
|
33
|
+
* <Text>Loading: {isLoading ? 'Yes' : 'No'}</Text>
|
|
34
|
+
* <Text>Connected: {isConnected ? 'Yes' : 'No'}</Text>
|
|
35
|
+
* {chain && <Text>Chain: {chain.name}</Text>}
|
|
36
|
+
* </View>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
|
|
8
42
|
export function useAppKitState() {
|
|
9
|
-
|
|
43
|
+
useAppKitContext();
|
|
10
44
|
const {
|
|
11
45
|
activeAddress: address,
|
|
12
46
|
connection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useSnapshot","ConnectionsController","ModalController","
|
|
1
|
+
{"version":3,"names":["useMemo","useSnapshot","ConnectionsController","ModalController","useAppKitContext","useAppKitState","activeAddress","address","connection","networks","state","open","loading","activeChain","caipNetwork","find","network","caipNetworkId","undefined","isOpen","isLoading","isConnected","chain"],"sourceRoot":"../../../src","sources":["hooks/useAppKitState.ts"],"mappings":";;AAAA;AACA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,qBAAqB,EAAEC,eAAe,QAAQ,iCAAiC;AACxF,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,OAAO,SAASC,cAAcA,CAAA,EAAG;EAC/BD,gBAAgB,CAAC,CAAC;EAClB,MAAM;IAAEE,aAAa,EAAEC,OAAO;IAAEC,UAAU;IAAEC;EAAS,CAAC,GAAGR,WAAW,CAACC,qBAAqB,CAACQ,KAAK,CAAC;EACjG,MAAM;IAAEC,IAAI;IAAEC;EAAQ,CAAC,GAAGX,WAAW,CAACE,eAAe,CAACO,KAAK,CAAC;EAE5D,MAAMG,WAAW,GAAGb,OAAO,CACzB,MACEQ,UAAU,EAAEM,WAAW,GACnBL,QAAQ,CAACM,IAAI,CAACC,OAAO,IAAIA,OAAO,CAACC,aAAa,KAAKT,UAAU,EAAEM,WAAW,CAAC,GAC3EI,SAAS,EACf,CAACV,UAAU,EAAEM,WAAW,EAAEL,QAAQ,CACpC,CAAC;EAED,OAAO;IACLU,MAAM,EAAER,IAAI;IACZS,SAAS,EAAER,OAAO;IAClBS,WAAW,EAAE,CAAC,CAACd,OAAO;IACtBe,KAAK,EAAET;EACT,CAAC;AACH","ignoreList":[]}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { useSnapshot } from 'valtio';
|
|
5
5
|
import { ThemeController } from '@reown/appkit-core-react-native';
|
|
6
|
-
import {
|
|
6
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Interface representing the result of the useAppKitTheme hook
|
|
@@ -53,7 +53,7 @@ import { useAppKit } from './useAppKit';
|
|
|
53
53
|
* ```
|
|
54
54
|
*/
|
|
55
55
|
export function useAppKitTheme() {
|
|
56
|
-
|
|
56
|
+
useAppKitContext();
|
|
57
57
|
const {
|
|
58
58
|
themeMode,
|
|
59
59
|
themeVariables
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useSnapshot","ThemeController","
|
|
1
|
+
{"version":3,"names":["useMemo","useSnapshot","ThemeController","useAppKitContext","useAppKitTheme","themeMode","themeVariables","state","stableFunctions","setThemeMode","bind","setThemeVariables"],"sourceRoot":"../../../src","sources":["hooks/useAppKitTheme.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,WAAW,QAAQ,QAAQ;AAEpC,SAASC,eAAe,QAAQ,iCAAiC;AACjE,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAAA,EAAyB;EACrDD,gBAAgB,CAAC,CAAC;EAClB,MAAM;IAAEE,SAAS;IAAEC;EAAe,CAAC,GAAGL,WAAW,CAACC,eAAe,CAACK,KAAK,CAAC;EAExE,MAAMC,eAAe,GAAGR,OAAO,CAC7B,OAAO;IACLS,YAAY,EAAEP,eAAe,CAACO,YAAY,CAACC,IAAI,CAACR,eAAe,CAAC;IAChES,iBAAiB,EAAET,eAAe,CAACS,iBAAiB,CAACD,IAAI,CAACR,eAAe;EAC3E,CAAC,CAAC,EACF,EACF,CAAC;EAED,OAAO;IACLG,SAAS;IACTC,cAAc;IACd,GAAGE;EACL,CAAC;AACH","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { useMemo } from 'react';
|
|
5
5
|
import { useSnapshot } from 'valtio';
|
|
6
6
|
import { ConnectionsController, LogController } from '@reown/appkit-core-react-native';
|
|
7
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Interface representing the result of the useProvider hook
|
|
@@ -24,14 +25,12 @@ import { ConnectionsController, LogController } from '@reown/appkit-core-react-n
|
|
|
24
25
|
*
|
|
25
26
|
* if (provider) {
|
|
26
27
|
* // Use the provider for blockchain operations
|
|
27
|
-
* const balance = await provider.request({
|
|
28
|
-
* method: 'eth_getBalance',
|
|
29
|
-
* params: [address, 'latest']
|
|
30
|
-
* });
|
|
28
|
+
* const balance = await provider.request({...});
|
|
31
29
|
* }
|
|
32
30
|
* ```
|
|
33
31
|
*/
|
|
34
32
|
export function useProvider() {
|
|
33
|
+
useAppKitContext();
|
|
35
34
|
const {
|
|
36
35
|
connection
|
|
37
36
|
} = useSnapshot(ConnectionsController.state);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useSnapshot","ConnectionsController","LogController","useProvider","connection","state","returnValue","adapter","provider","undefined","providerType","getProvider","getSupportedNamespace","error","sendError"],"sourceRoot":"../../../src","sources":["hooks/useProvider.ts"],"mappings":";;AAAA;AACA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,qBAAqB,EAAEC,aAAa,QAAQ,iCAAiC;;
|
|
1
|
+
{"version":3,"names":["useMemo","useSnapshot","ConnectionsController","LogController","useAppKitContext","useProvider","connection","state","returnValue","adapter","provider","undefined","providerType","getProvider","getSupportedNamespace","error","sendError"],"sourceRoot":"../../../src","sources":["hooks/useProvider.ts"],"mappings":";;AAAA;AACA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,qBAAqB,EAAEC,aAAa,QAAQ,iCAAiC;AAEtF,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAAA,EAAmB;EAC5CD,gBAAgB,CAAC,CAAC;EAClB,MAAM;IAAEE;EAAW,CAAC,GAAGL,WAAW,CAACC,qBAAqB,CAACK,KAAK,CAAC;EAE/D,MAAMC,WAAW,GAAGR,OAAO,CAAC,MAAM;IAChC,IAAI,CAACM,UAAU,IAAI,CAACA,UAAU,CAACG,OAAO,EAAE;MACtC,OAAO;QAAEC,QAAQ,EAAEC,SAAS;QAAEC,YAAY,EAAED;MAAU,CAAC;IACzD;IAEA,IAAI;MACF,OAAO;QACLD,QAAQ,EAAEJ,UAAU,CAACG,OAAO,CAACI,WAAW,CAAC,CAAC;QAC1CD,YAAY,EAAEN,UAAU,CAACG,OAAO,CAACK,qBAAqB,CAAC;MACzD,CAAC;IACH,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdZ,aAAa,CAACa,SAAS,CAACD,KAAK,EAAE,aAAa,EAAE,aAAa,CAAC;;MAE5D;MACA,OAAO;QAAEL,QAAQ,EAAEC,SAAS;QAAEC,YAAY,EAAED;MAAU,CAAC;IACzD;EACF,CAAC,EAAE,CAACL,UAAU,CAAC,CAAC;EAEhB,OAAOE,WAAW;AACpB","ignoreList":[]}
|
|
@@ -3,9 +3,41 @@
|
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { useSnapshot } from 'valtio';
|
|
5
5
|
import { ConnectionsController } from '@reown/appkit-core-react-native';
|
|
6
|
-
import {
|
|
6
|
+
import { useAppKitContext } from './useAppKitContext';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Hook to access information about the currently connected wallet
|
|
10
|
+
*
|
|
11
|
+
* @remarks
|
|
12
|
+
* This hook provides access to metadata about the connected wallet, such as its name,
|
|
13
|
+
* icon, and other identifying information. It automatically subscribes to wallet info
|
|
14
|
+
* changes via valtio.
|
|
15
|
+
*
|
|
16
|
+
* @returns An object containing:
|
|
17
|
+
* - `walletInfo`: Metadata about the currently connected wallet (name, icon, etc.)
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* function MyComponent() {
|
|
22
|
+
* const { walletInfo } = useWalletInfo();
|
|
23
|
+
*
|
|
24
|
+
* return (
|
|
25
|
+
* <View>
|
|
26
|
+
* {walletInfo && (
|
|
27
|
+
* <>
|
|
28
|
+
* <Image source={{ uri: walletInfo.icon }} />
|
|
29
|
+
* <Text>{walletInfo.name}</Text>
|
|
30
|
+
* </>
|
|
31
|
+
* )}
|
|
32
|
+
* </View>
|
|
33
|
+
* );
|
|
34
|
+
* }
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
38
|
+
*/
|
|
7
39
|
export function useWalletInfo() {
|
|
8
|
-
|
|
40
|
+
useAppKitContext();
|
|
9
41
|
const {
|
|
10
42
|
walletInfo: walletInfoSnapshot
|
|
11
43
|
} = useSnapshot(ConnectionsController.state);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useMemo","useSnapshot","ConnectionsController","
|
|
1
|
+
{"version":3,"names":["useMemo","useSnapshot","ConnectionsController","useAppKitContext","useWalletInfo","walletInfo","walletInfoSnapshot","state"],"sourceRoot":"../../../src","sources":["hooks/useWalletInfo.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,WAAW,QAAQ,QAAQ;AACpC,SAASC,qBAAqB,QAAQ,iCAAiC;AACvE,SAASC,gBAAgB,QAAQ,oBAAoB;;AAErD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAAA,EAAG;EAC9BD,gBAAgB,CAAC,CAAC;EAClB,MAAM;IAAEE,UAAU,EAAEC;EAAmB,CAAC,GAAGL,WAAW,CAACC,qBAAqB,CAACK,KAAK,CAAC;EAEnF,MAAMF,UAAU,GAAGL,OAAO,CAAC,OAAO;IAAEK,UAAU,EAAEC;EAAmB,CAAC,CAAC,EAAE,CAACA,kBAAkB,CAAC,CAAC;EAE5F,OAAOD,UAAU;AACnB","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export { AppKit } from './modal/w3m-modal';
|
|
|
15
15
|
export { useAppKit } from './hooks/useAppKit';
|
|
16
16
|
export { useProvider } from './hooks/useProvider';
|
|
17
17
|
export { useAccount } from './hooks/useAccount';
|
|
18
|
+
export { useAppKitTheme } from './hooks/useAppKitTheme';
|
|
18
19
|
export { useWalletInfo } from './hooks/useWalletInfo';
|
|
19
20
|
export { useAppKitEvents, useAppKitEventSubscription } from './hooks/useAppKitEvents';
|
|
20
21
|
export { useAppKitState } from './hooks/useAppKitState';
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["AccountButton","AppKitButton","ConnectButton","NetworkButton","AppKit","useAppKit","useProvider","useAccount","useWalletInfo","useAppKitEvents","useAppKitEventSubscription","useAppKitState","useAppKitLogs","solana","solanaDevnet","solanaTestnet","bitcoin","bitcoinTestnet","ReownAuthentication","createAppKit","AppKitProvider"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,OAAO,oCAAoC;;AAE3C;AACA,SACEA,aAA8B,QAEzB,4BAA4B;AACnC,SAASC,YAAY,QAAgC,oBAAoB;AACzE,SACEC,aAA8B,QAEzB,4BAA4B;AACnC,SACEC,aAA8B,QAEzB,4BAA4B;AACnC,SAASC,MAAM,QAAQ,mBAAmB;;AAE1C;;AAYA;AACA,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAASC,UAAU,QAA0C,oBAAoB;AACjF,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,eAAe,EAAEC,0BAA0B,QAAQ,yBAAyB;AACrF,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,aAAa,QAAkC,uBAAuB;;AAE/E;AACA,SAASC,MAAM,EAAEC,YAAY,EAAEC,aAAa,QAAQ,mCAAmC;AACvF,SAASC,OAAO,EAAEC,cAAc,QAAQ,mCAAmC;;AAE3E;AACA,SAASC,mBAAmB,QAAQ,iCAAiC;;AAErE;AACA,SAASC,YAAY,QAAQ,UAAU;AACvC,SAASC,cAAc,QAAQ,iBAAiB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["AccountButton","AppKitButton","ConnectButton","NetworkButton","AppKit","useAppKit","useProvider","useAccount","useAppKitTheme","useWalletInfo","useAppKitEvents","useAppKitEventSubscription","useAppKitState","useAppKitLogs","solana","solanaDevnet","solanaTestnet","bitcoin","bitcoinTestnet","ReownAuthentication","createAppKit","AppKitProvider"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,OAAO,oCAAoC;;AAE3C;AACA,SACEA,aAA8B,QAEzB,4BAA4B;AACnC,SAASC,YAAY,QAAgC,oBAAoB;AACzE,SACEC,aAA8B,QAEzB,4BAA4B;AACnC,SACEC,aAA8B,QAEzB,4BAA4B;AACnC,SAASC,MAAM,QAAQ,mBAAmB;;AAE1C;;AAYA;AACA,SAASC,SAAS,QAAQ,mBAAmB;AAC7C,SAASC,WAAW,QAAQ,qBAAqB;AACjD,SAASC,UAAU,QAA0C,oBAAoB;AACjF,SAASC,cAAc,QAAmC,wBAAwB;AAClF,SAASC,aAAa,QAAQ,uBAAuB;AACrD,SAASC,eAAe,EAAEC,0BAA0B,QAAQ,yBAAyB;AACrF,SAASC,cAAc,QAAQ,wBAAwB;AACvD,SAASC,aAAa,QAAkC,uBAAuB;;AAE/E;AACA,SAASC,MAAM,EAAEC,YAAY,EAAEC,aAAa,QAAQ,mCAAmC;AACvF,SAASC,OAAO,EAAEC,cAAc,QAAQ,mCAAmC;;AAE3E;AACA,SAASC,mBAAmB,QAAQ,iCAAiC;;AAErE;AACA,SAASC,YAAY,QAAQ,UAAU;AACvC,SAASC,cAAc,QAAQ,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AppKitContext.d.ts","sourceRoot":"","sources":["../../src/AppKitContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,
|
|
1
|
+
{"version":3,"file":"AppKitContext.d.ts","sourceRoot":"","sources":["../../src/AppKitContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAsC,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,kCAAqD,CAAC;AAEhF,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,SAAS,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CAExD,CAAC;AAEF,eAAO,MAAM,iBAAiB;;;;;;;;;CA4B7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAccount.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAccount.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAccount.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAGpF;;GAEG;AACH,MAAM,WAAW,OAAO;IACtB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAC;IAChB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,UAAU;;;;;;;EAsDzB"}
|
|
@@ -1,11 +1,53 @@
|
|
|
1
1
|
import type { ChainNamespace } from '@reown/appkit-common-react-native';
|
|
2
2
|
import type { AppKit } from '../AppKit';
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the return value of the useAppKit hook
|
|
5
|
+
*/
|
|
3
6
|
interface UseAppKitReturn {
|
|
7
|
+
/** Function to open the AppKit modal with optional view configuration */
|
|
4
8
|
open: AppKit['open'];
|
|
9
|
+
/** Function to close the AppKit modal */
|
|
5
10
|
close: AppKit['close'];
|
|
11
|
+
/** Function to disconnect the wallet, optionally scoped to a specific namespace */
|
|
6
12
|
disconnect: (namespace?: ChainNamespace) => void;
|
|
13
|
+
/** Function to switch to a different network */
|
|
7
14
|
switchNetwork: AppKit['switchNetwork'];
|
|
8
15
|
}
|
|
16
|
+
/**
|
|
17
|
+
* Hook to access core AppKit functionality for controlling the modal
|
|
18
|
+
*
|
|
19
|
+
* @remarks
|
|
20
|
+
* This hook provides access to the main AppKit instance methods for opening/closing
|
|
21
|
+
* the modal, disconnecting wallets, and switching networks. All functions are memoized
|
|
22
|
+
* and properly bound to ensure stable references across renders.
|
|
23
|
+
*
|
|
24
|
+
* @returns {UseAppKitReturn} An object containing:
|
|
25
|
+
* - `open`: Opens the AppKit modal, optionally with a specific view
|
|
26
|
+
* - `close`: Closes the AppKit modal
|
|
27
|
+
* - `disconnect`: Disconnects the current wallet connection (optionally for a specific namespace)
|
|
28
|
+
* - `switchNetwork`: Switches to a different blockchain network
|
|
29
|
+
*
|
|
30
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
31
|
+
* @throws {Error} If AppKit instance is not available in context
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```tsx
|
|
35
|
+
* function MyComponent() {
|
|
36
|
+
* const { open, close, disconnect, switchNetwork } = useAppKit();
|
|
37
|
+
*
|
|
38
|
+
* return (
|
|
39
|
+
* <View>
|
|
40
|
+
* <Button onPress={() => open()} title="Connect Wallet" />
|
|
41
|
+
* <Button onPress={() => disconnect()} title="Disconnect" />
|
|
42
|
+
* <Button
|
|
43
|
+
* onPress={() => switchNetwork('eip155:1')}
|
|
44
|
+
* title="Switch to Ethereum"
|
|
45
|
+
* />
|
|
46
|
+
* </View>
|
|
47
|
+
* );
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
9
51
|
export declare const useAppKit: () => UseAppKitReturn;
|
|
10
52
|
export {};
|
|
11
53
|
//# sourceMappingURL=useAppKit.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAppKit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACvB,UAAU,EAAE,CAAC,SAAS,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IACjD,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,SAAS,QAAO,
|
|
1
|
+
{"version":3,"file":"useAppKit.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAExE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAGxC;;GAEG;AACH,UAAU,eAAe;IACvB,yEAAyE;IACzE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACrB,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;IACvB,mFAAmF;IACnF,UAAU,EAAE,CAAC,SAAS,CAAC,EAAE,cAAc,KAAK,IAAI,CAAC;IACjD,gDAAgD;IAChD,aAAa,EAAE,MAAM,CAAC,eAAe,CAAC,CAAC;CACxC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,SAAS,QAAO,eAkB5B,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type AppKitContextType } from '../AppKitContext';
|
|
2
|
+
/**
|
|
3
|
+
* Hook to access the AppKit context
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* This is an internal hook used by other AppKit hooks to ensure they're used within
|
|
7
|
+
* the AppKitProvider. You typically don't need to use this hook directly - use the
|
|
8
|
+
* higher-level hooks like `useAppKit`, `useAccount`, `useAppKitTheme`, etc. instead.
|
|
9
|
+
*
|
|
10
|
+
* @returns {AppKitContextType} The AppKit context containing the AppKit instance
|
|
11
|
+
*
|
|
12
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
13
|
+
* @throws {Error} If the AppKit instance is not yet available in context
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* // This is typically used internally by other hooks
|
|
20
|
+
* function MyCustomHook() {
|
|
21
|
+
* const context = useAppKitContext();
|
|
22
|
+
* // Use context.appKit...
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare const useAppKitContext: () => AppKitContextType;
|
|
27
|
+
//# sourceMappingURL=useAppKitContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAppKitContext.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKitContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,eAAO,MAAM,gBAAgB,QAAO,iBAanC,CAAC"}
|
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
import { type EventsControllerState } from '@reown/appkit-core-react-native';
|
|
2
2
|
import { type EventName } from '@reown/appkit-common-react-native';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to subscribe to all AppKit events
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* This hook provides reactive access to AppKit's event system, allowing you to
|
|
8
|
+
* monitor all events that occur within the AppKit lifecycle (connections, disconnections,
|
|
9
|
+
* network changes, etc.). The callback is invoked whenever a new event is emitted.
|
|
10
|
+
*
|
|
11
|
+
* @param callback - Optional callback function invoked when any event occurs
|
|
12
|
+
*
|
|
13
|
+
* @returns An object containing:
|
|
14
|
+
* - `data`: The most recent event data
|
|
15
|
+
* - `timestamp`: The timestamp of the most recent event
|
|
16
|
+
*
|
|
17
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* function MyComponent() {
|
|
22
|
+
* const { data, timestamp } = useAppKitEvents((event) => {
|
|
23
|
+
* console.log('Event occurred:', event.data.event);
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* return (
|
|
27
|
+
* <View>
|
|
28
|
+
* <Text>Last event: {data?.event}</Text>
|
|
29
|
+
* <Text>Time: {timestamp}</Text>
|
|
30
|
+
* </View>
|
|
31
|
+
* );
|
|
32
|
+
* }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
3
35
|
export declare function useAppKitEvents(callback?: (newEvent: EventsControllerState) => void): {
|
|
4
36
|
data: {
|
|
5
37
|
readonly type: "track";
|
|
@@ -371,5 +403,32 @@ export declare function useAppKitEvents(callback?: (newEvent: EventsControllerSt
|
|
|
371
403
|
};
|
|
372
404
|
timestamp: number;
|
|
373
405
|
};
|
|
406
|
+
/**
|
|
407
|
+
* Hook to subscribe to a specific AppKit event
|
|
408
|
+
*
|
|
409
|
+
* @remarks
|
|
410
|
+
* This hook allows you to listen for a specific event type rather than all events.
|
|
411
|
+
* It's more efficient than `useAppKitEvents` when you only care about a particular event.
|
|
412
|
+
*
|
|
413
|
+
* @param event - The specific event name to subscribe to (e.g., 'MODAL_OPEN', 'CONNECT_SUCCESS')
|
|
414
|
+
* @param callback - Callback function invoked when the specified event occurs
|
|
415
|
+
*
|
|
416
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
417
|
+
*
|
|
418
|
+
* @example
|
|
419
|
+
* ```tsx
|
|
420
|
+
* function MyComponent() {
|
|
421
|
+
* useAppKitEventSubscription('CONNECT_SUCCESS', (event) => {
|
|
422
|
+
* console.log('Wallet connected!', event.data);
|
|
423
|
+
* });
|
|
424
|
+
*
|
|
425
|
+
* useAppKitEventSubscription('DISCONNECT_SUCCESS', (event) => {
|
|
426
|
+
* console.log('Wallet disconnected!', event.data);
|
|
427
|
+
* });
|
|
428
|
+
*
|
|
429
|
+
* return <View>{/ Your component /}</View>;
|
|
430
|
+
* }
|
|
431
|
+
* ```
|
|
432
|
+
*/
|
|
374
433
|
export declare function useAppKitEventSubscription(event: EventName, callback: (newEvent: EventsControllerState) => void): void;
|
|
375
434
|
//# sourceMappingURL=useAppKitEvents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAppKitEvents.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKitEvents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC/F,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAGnE,wBAAgB,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAenF;AAED,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,QAWpD"}
|
|
1
|
+
{"version":3,"file":"useAppKitEvents.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKitEvents.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAC/F,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAGnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAenF;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,CAAC,QAAQ,EAAE,qBAAqB,KAAK,IAAI,QAWpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAppKitLogs.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKitLogs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAG9F,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,QAAQ,EAAE,CAAC;IAEjB;;OAEG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,QAAQ,EAAE,CAAC;IAEhD;;OAEG;IACH,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,QAAQ,EAAE,CAAC;IAE9C;;OAEG;IACH,UAAU,EAAE,MAAM,MAAM,CAAC;IAEzB;;OAEG;IACH,YAAY,EAAE,MAAM,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE7C;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB;;OAEG;IACH,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,WAAW,EAAE,QAAQ,EAAE,CAAC;IACxB,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,QAAO,
|
|
1
|
+
{"version":3,"file":"useAppKitLogs.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKitLogs.ts"],"names":[],"mappings":"AAEA,OAAO,EAAiB,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAG9F,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,IAAI,EAAE,QAAQ,EAAE,CAAC;IAEjB;;OAEG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,QAAQ,KAAK,QAAQ,EAAE,CAAC;IAEhD;;OAEG;IACH,aAAa,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,QAAQ,EAAE,CAAC;IAE9C;;OAEG;IACH,UAAU,EAAE,MAAM,MAAM,CAAC;IAEzB;;OAEG;IACH,YAAY,EAAE,MAAM,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAE7C;;OAEG;IACH,SAAS,EAAE,MAAM,IAAI,CAAC;IAEtB;;OAEG;IACH,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,WAAW,EAAE,QAAQ,EAAE,CAAC;IACxB,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,SAAS,EAAE,QAAQ,EAAE,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,aAAa,QAAO,mBAsDhC,CAAC"}
|
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook to access the overall state of the AppKit modal and connection
|
|
3
|
+
*
|
|
4
|
+
* @remarks
|
|
5
|
+
* This hook provides a high-level view of the AppKit's current state, including
|
|
6
|
+
* whether the modal is open, if it's loading, connection status, and the active chain.
|
|
7
|
+
* It's useful for coordinating UI elements with the AppKit's state.
|
|
8
|
+
*
|
|
9
|
+
* @returns An object containing:
|
|
10
|
+
* - `isOpen`: Whether the AppKit modal is currently open
|
|
11
|
+
* - `isLoading`: Whether the AppKit is in a loading state
|
|
12
|
+
* - `isConnected`: Whether a wallet is currently connected
|
|
13
|
+
* - `chain`: The currently active blockchain network
|
|
14
|
+
*
|
|
15
|
+
* @throws {Error} If used outside of an AppKitProvider
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```tsx
|
|
19
|
+
* function MyComponent() {
|
|
20
|
+
* const { isOpen, isLoading, isConnected, chain } = useAppKitState();
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <View>
|
|
24
|
+
* <Text>Modal: {isOpen ? 'Open' : 'Closed'}</Text>
|
|
25
|
+
* <Text>Loading: {isLoading ? 'Yes' : 'No'}</Text>
|
|
26
|
+
* <Text>Connected: {isConnected ? 'Yes' : 'No'}</Text>
|
|
27
|
+
* {chain && <Text>Chain: {chain.name}</Text>}
|
|
28
|
+
* </View>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
1
33
|
export declare function useAppKitState(): {
|
|
2
34
|
isOpen: boolean;
|
|
3
35
|
isLoading: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAppKitState.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKitState.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmB7B"}
|
|
1
|
+
{"version":3,"file":"useAppKitState.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKitState.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,wBAAgB,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmB7B"}
|
|
@@ -2,7 +2,7 @@ import type { ThemeMode, ThemeVariables } from '@reown/appkit-common-react-nativ
|
|
|
2
2
|
/**
|
|
3
3
|
* Interface representing the result of the useAppKitTheme hook
|
|
4
4
|
*/
|
|
5
|
-
interface UseAppKitThemeReturn {
|
|
5
|
+
export interface UseAppKitThemeReturn {
|
|
6
6
|
/** The current theme mode ('dark' or 'light'), or undefined if using system default */
|
|
7
7
|
themeMode: ThemeMode | undefined;
|
|
8
8
|
/** The current theme variables, currently only supports 'accent' color */
|
|
@@ -56,5 +56,4 @@ interface UseAppKitThemeReturn {
|
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
export declare function useAppKitTheme(): UseAppKitThemeReturn;
|
|
59
|
-
export {};
|
|
60
59
|
//# sourceMappingURL=useAppKitTheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAppKitTheme.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKitTheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAInF;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"useAppKitTheme.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAppKitTheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAInF;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,uFAAuF;IACvF,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IACjC,0EAA0E;IAC1E,cAAc,EAAE,cAAc,GAAG,SAAS,CAAC;IAC3C,qCAAqC;IACrC,YAAY,EAAE,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,KAAK,IAAI,CAAC;IACzD,sCAAsC;IACtC,iBAAiB,EAAE,CAAC,cAAc,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;CACzE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CAiBrD"}
|