@openzeppelin/ui-react 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # @openzeppelin/ui-react
2
+
3
+ Core React context providers and hooks for the OpenZeppelin UI ecosystem.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@openzeppelin/ui-react.svg)](https://www.npmjs.com/package/@openzeppelin/ui-react)
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ # Using npm
11
+ npm install @openzeppelin/ui-react
12
+
13
+ # Using yarn
14
+ yarn add @openzeppelin/ui-react
15
+
16
+ # Using pnpm
17
+ pnpm add @openzeppelin/ui-react
18
+ ```
19
+
20
+ ## Peer Dependencies
21
+
22
+ ```bash
23
+ pnpm add react react-dom @tanstack/react-query
24
+ ```
25
+
26
+ ## Overview
27
+
28
+ This package provides core React context providers and hooks that centralize the management of global wallet state, active network selection, active adapter instances, and the consumption of adapter-specific UI capabilities.
29
+
30
+ It is a foundational package that can be used to ensure consistent wallet and adapter integration patterns across applications.
31
+
32
+ ## Core Responsibilities
33
+
34
+ - **Adapter Instance Management:** Provides `AdapterProvider` which maintains a registry of `ContractAdapter` instances, ensuring only one instance exists per network configuration (singleton pattern).
35
+ - **Global Wallet/Network State Management:** Provides `WalletStateProvider` which manages:
36
+ - The globally selected active network ID and its corresponding `NetworkConfig`.
37
+ - The active `ContractAdapter` instance for this global network and its loading state.
38
+ - The `EcosystemSpecificReactHooks` (facade hooks) provided by the active adapter.
39
+ - Orchestration of rendering the active adapter's UI context provider.
40
+ - **Consistent State Access:** Exports consumer hooks for components to access this managed state and functionality.
41
+
42
+ ## Key Exports
43
+
44
+ ### Providers
45
+
46
+ - `AdapterProvider`: Manages adapter instances. Requires a `resolveAdapter` prop to fetch/create adapters.
47
+ - `WalletStateProvider`: Manages global active network/adapter/wallet state.
48
+
49
+ ### Hooks
50
+
51
+ - `useAdapterContext()`: Access `AdapterProvider`'s `getAdapterForNetwork` function.
52
+ - `useWalletState()`: Access global state like `activeNetworkId`, `activeAdapter`, `walletFacadeHooks`, and `setActiveNetworkId`.
53
+
54
+ ### Derived Hooks
55
+
56
+ These hooks abstract wallet interactions and work with any adapter implementing the facade pattern:
57
+
58
+ - `useDerivedAccountStatus()`: Returns connection status, address, and current chain ID.
59
+ - `useDerivedSwitchChainStatus()`: Returns the `switchChain` function and switching state.
60
+ - `useDerivedChainInfo()`: Returns current chain information.
61
+ - `useDerivedConnectStatus()`: Returns wallet connection functions and state.
62
+ - `useDerivedDisconnect()`: Returns the disconnect function.
63
+ - `useWalletReconnectionHandler()`: Detects wallet reconnection and triggers network switch re-queue.
64
+
65
+ ### UI Components
66
+
67
+ - `WalletConnectionHeader`: Compact wallet connection status display.
68
+ - `WalletConnectionUI`: Full wallet connection interface.
69
+ - `WalletConnectionWithSettings`: Wallet connection UI with settings controls.
70
+ - `NetworkSwitchManager`: Handles automatic wallet network switching for EVM chains.
71
+
72
+ ## Usage
73
+
74
+ ### Application Setup
75
+
76
+ ```tsx
77
+ import { AdapterProvider, WalletStateProvider } from '@openzeppelin/ui-react';
78
+
79
+ import { getAdapter, getNetworkById } from './core/ecosystemManager';
80
+
81
+ function AppRoot() {
82
+ return (
83
+ <AdapterProvider resolveAdapter={getAdapter}>
84
+ <WalletStateProvider
85
+ initialNetworkId="ethereum-mainnet"
86
+ getNetworkConfigById={getNetworkById}
87
+ >
88
+ {/* Your application components */}
89
+ </WalletStateProvider>
90
+ </AdapterProvider>
91
+ );
92
+ }
93
+ ```
94
+
95
+ ### Consuming Global State
96
+
97
+ ```tsx
98
+ import { useWalletState } from '@openzeppelin/ui-react';
99
+
100
+ function MyWalletComponent() {
101
+ const {
102
+ activeNetworkId,
103
+ activeNetworkConfig,
104
+ activeAdapter,
105
+ isAdapterLoading,
106
+ walletFacadeHooks,
107
+ setActiveNetworkId,
108
+ } = useWalletState();
109
+
110
+ if (isAdapterLoading || !activeAdapter) {
111
+ return <p>Loading wallet information...</p>;
112
+ }
113
+
114
+ const accountInfo = walletFacadeHooks?.useAccount ? walletFacadeHooks.useAccount() : null;
115
+ const isConnected = accountInfo?.isConnected;
116
+
117
+ return (
118
+ <div>
119
+ <p>Current Network: {activeNetworkConfig?.name || 'None'}</p>
120
+ <p>Wallet Connected: {isConnected ? 'Yes' : 'No'}</p>
121
+ </div>
122
+ );
123
+ }
124
+ ```
125
+
126
+ ### Using NetworkSwitchManager
127
+
128
+ ```tsx
129
+ import { useState } from 'react';
130
+
131
+ import { NetworkSwitchManager } from '@openzeppelin/ui-react';
132
+
133
+ function MyApp() {
134
+ const [networkToSwitchTo, setNetworkToSwitchTo] = useState<string | null>(null);
135
+ const adapter = useMyAdapter();
136
+
137
+ const handleNetworkSwitchComplete = () => {
138
+ setNetworkToSwitchTo(null);
139
+ };
140
+
141
+ return (
142
+ <>
143
+ {adapter && networkToSwitchTo && (
144
+ <NetworkSwitchManager
145
+ adapter={adapter}
146
+ targetNetworkId={networkToSwitchTo}
147
+ onNetworkSwitchComplete={handleNetworkSwitchComplete}
148
+ />
149
+ )}
150
+ </>
151
+ );
152
+ }
153
+ ```
154
+
155
+ ## Package Structure
156
+
157
+ ```text
158
+ react/
159
+ ├── src/
160
+ │ ├── components/ # UI components (WalletConnection*, NetworkSwitchManager)
161
+ │ ├── hooks/ # Context providers and consumer hooks
162
+ │ └── index.ts # Main package exports
163
+ ├── package.json
164
+ ├── tsconfig.json
165
+ ├── tsdown.config.ts
166
+ └── README.md
167
+ ```
168
+
169
+ ## Dependencies
170
+
171
+ This package has minimal dependencies to maintain a lightweight footprint:
172
+
173
+ - **@openzeppelin/ui-types**: Shared type definitions
174
+ - **@openzeppelin/ui-utils**: Shared utility functions
175
+ - **@openzeppelin/ui-components**: UI components
176
+ - **react**: Peer dependency for React hooks and context
177
+ - **react-dom**: Peer dependency for React DOM utilities
178
+ - **@tanstack/react-query**: Peer dependency for data fetching
179
+
180
+ ## Development
181
+
182
+ ```bash
183
+ # Build the package
184
+ pnpm build
185
+
186
+ # Run tests
187
+ pnpm test
188
+
189
+ # Lint
190
+ pnpm lint
191
+ ```
192
+
193
+ ## License
194
+
195
+ [AGPL-3.0](https://github.com/OpenZeppelin/openzeppelin-ui/blob/main/LICENSE)
@@ -0,0 +1,421 @@
1
+ import * as react0 from "react";
2
+ import React, { ReactNode } from "react";
3
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
4
+ import { Connector, ContractAdapter, EcosystemSpecificReactHooks, NativeConfigLoader, NetworkConfig, UiKitConfiguration } from "@openzeppelin/ui-types";
5
+
6
+ //#region src/hooks/AdapterContext.d.ts
7
+ /**
8
+ * Registry type that maps network IDs to their corresponding adapter instances
9
+ * This is the core data structure for the singleton pattern
10
+ */
11
+ interface AdapterRegistry {
12
+ [networkId: string]: ContractAdapter;
13
+ }
14
+ /**
15
+ * Context value interface defining what's provided through the context
16
+ * The main functionality is getAdapterForNetwork which either returns
17
+ * an existing adapter or initiates loading of a new one
18
+ */
19
+ interface AdapterContextValue {
20
+ getAdapterForNetwork: (networkConfig: NetworkConfig | null) => {
21
+ adapter: ContractAdapter | null;
22
+ isLoading: boolean;
23
+ };
24
+ }
25
+ /**
26
+ * The React Context that provides adapter registry access throughout the app
27
+ * Components can access this through the useAdapterContext hook
28
+ */
29
+ declare const AdapterContext: react0.Context<AdapterContextValue | null>;
30
+ //# sourceMappingURL=AdapterContext.d.ts.map
31
+ //#endregion
32
+ //#region src/hooks/AdapterProvider.d.ts
33
+ interface AdapterProviderProps {
34
+ children: ReactNode;
35
+ /** Function to resolve/create an adapter instance for a given NetworkConfig. */
36
+ resolveAdapter: (networkConfig: NetworkConfig) => Promise<ContractAdapter>;
37
+ }
38
+ /**
39
+ * Provider component that manages adapter instances centrally
40
+ * to avoid creating multiple instances of the same adapter.
41
+ *
42
+ * This component:
43
+ * 1. Maintains a registry of adapter instances by network ID
44
+ * 2. Tracks loading states for adapters being initialized
45
+ * 3. Provides a function to get or load adapters for specific networks
46
+ * 4. Ensures adapter instances are reused when possible
47
+ */
48
+ declare function AdapterProvider({
49
+ children,
50
+ resolveAdapter
51
+ }: AdapterProviderProps): react_jsx_runtime0.JSX.Element;
52
+ //# sourceMappingURL=AdapterProvider.d.ts.map
53
+ //#endregion
54
+ //#region src/hooks/WalletStateContext.d.ts
55
+ interface WalletStateContextValue {
56
+ activeNetworkId: string | null;
57
+ setActiveNetworkId: (networkId: string | null) => void;
58
+ activeNetworkConfig: NetworkConfig | null;
59
+ activeAdapter: ContractAdapter | null;
60
+ isAdapterLoading: boolean;
61
+ walletFacadeHooks: EcosystemSpecificReactHooks | null;
62
+ reconfigureActiveAdapterUiKit: (uiKitConfig?: Partial<UiKitConfiguration>) => void;
63
+ }
64
+ declare const WalletStateContext: React.Context<WalletStateContextValue | undefined>;
65
+ /**
66
+ * Hook to access wallet state from WalletStateProvider.
67
+ * @throws Error if used outside of WalletStateProvider
68
+ */
69
+ declare function useWalletState(): WalletStateContextValue;
70
+ //# sourceMappingURL=WalletStateContext.d.ts.map
71
+ //#endregion
72
+ //#region src/hooks/WalletStateProvider.d.ts
73
+ interface WalletStateProviderProps {
74
+ children: ReactNode;
75
+ /** Optional initial network ID to set as active when the provider mounts. */
76
+ initialNetworkId?: string | null;
77
+ /** Function to retrieve a NetworkConfig object by its ID. */
78
+ getNetworkConfigById: (networkId: string) => Promise<NetworkConfig | null | undefined> | NetworkConfig | null | undefined;
79
+ /**
80
+ * Optional generic function to load configuration modules by relative path.
81
+ * The adapter is responsible for constructing the conventional path (e.g., './config/wallet/[kitName].config').
82
+ * @param relativePath The conventional relative path to the configuration module.
83
+ * @returns A Promise resolving to the configuration object (expected to have a default export) or null.
84
+ */
85
+ loadConfigModule?: NativeConfigLoader;
86
+ }
87
+ /**
88
+ * @name WalletStateProvider
89
+ * @description This provider is a central piece of the application's state management for wallet and network interactions.
90
+ * It is responsible for:
91
+ * 1. Managing the globally selected active network ID (`activeNetworkId`).
92
+ * 2. Deriving the full `NetworkConfig` object (`activeNetworkConfig`) for the active network.
93
+ * 3. Fetching and providing the corresponding `ContractAdapter` instance (`activeAdapter`) for the active network,
94
+ * leveraging the `AdapterProvider` to ensure adapter singletons.
95
+ * 4. Storing and providing the `EcosystemSpecificReactHooks` (`walletFacadeHooks`) from the active adapter.
96
+ * 5. Rendering the adapter-specific UI context provider (e.g., WagmiProvider for EVM) around its children,
97
+ * which is essential for the facade hooks to function correctly.
98
+ * 6. Providing a function (`setActiveNetworkId`) to change the globally active network.
99
+ *
100
+ * Consumers use the `useWalletState()` hook to access this global state.
101
+ * It should be placed high in the component tree, inside an `<AdapterProvider>`.
102
+ */
103
+ declare function WalletStateProvider({
104
+ children,
105
+ initialNetworkId,
106
+ getNetworkConfigById,
107
+ loadConfigModule
108
+ }: WalletStateProviderProps): react_jsx_runtime0.JSX.Element;
109
+ //# sourceMappingURL=WalletStateProvider.d.ts.map
110
+ //#endregion
111
+ //#region src/hooks/AnalyticsContext.d.ts
112
+ /**
113
+ * Analytics context value interface.
114
+ * Provides access to analytics functionality throughout the React component tree.
115
+ */
116
+ interface AnalyticsContextValue {
117
+ /** Google Analytics tag ID */
118
+ tagId?: string;
119
+ /**
120
+ * Check if analytics is enabled via feature flag.
121
+ * Returns fresh state on each call to handle dynamic feature flag changes.
122
+ */
123
+ isEnabled: () => boolean;
124
+ /** Initialize analytics with optional tag ID override */
125
+ initialize: (tagIdOverride?: string) => void;
126
+ /**
127
+ * Track a generic event with custom parameters.
128
+ * Use this for app-specific events.
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * trackEvent('button_clicked', { button_name: 'submit' });
133
+ * ```
134
+ */
135
+ trackEvent: (eventName: string, parameters: Record<string, string | number>) => void;
136
+ /**
137
+ * Track page view event.
138
+ *
139
+ * @example
140
+ * ```typescript
141
+ * trackPageView('Dashboard', '/dashboard');
142
+ * ```
143
+ */
144
+ trackPageView: (pageName: string, pagePath: string) => void;
145
+ /**
146
+ * Track network selection event.
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * trackNetworkSelection('ethereum-mainnet', 'evm');
151
+ * ```
152
+ */
153
+ trackNetworkSelection: (networkId: string, ecosystem: string) => void;
154
+ }
155
+ /**
156
+ * Analytics context for providing analytics functionality to React components.
157
+ * Must be used within an AnalyticsProvider.
158
+ */
159
+ declare const AnalyticsContext: react0.Context<AnalyticsContextValue | null>;
160
+ /**
161
+ * Internal hook to access analytics context.
162
+ * Throws an error if used outside of an AnalyticsProvider.
163
+ *
164
+ * @internal
165
+ * @throws Error if used outside of AnalyticsProvider
166
+ */
167
+ //#endregion
168
+ //#region src/hooks/AnalyticsProvider.d.ts
169
+ /**
170
+ * Props for the AnalyticsProvider component
171
+ */
172
+ interface AnalyticsProviderProps {
173
+ /** Google Analytics tag ID (e.g., 'G-XXXXXXXXXX') */
174
+ tagId?: string;
175
+ /** Whether to automatically initialize analytics on mount (default: true) */
176
+ autoInit?: boolean;
177
+ /** Child components */
178
+ children: ReactNode;
179
+ }
180
+ /**
181
+ * Analytics Provider component.
182
+ * Provides analytics functionality throughout the React component tree.
183
+ *
184
+ * @example
185
+ * ```tsx
186
+ * function App() {
187
+ * return (
188
+ * <AnalyticsProvider tagId={import.meta.env.VITE_GA_TAG_ID} autoInit={true}>
189
+ * <YourApp />
190
+ * </AnalyticsProvider>
191
+ * );
192
+ * }
193
+ * ```
194
+ */
195
+ declare const AnalyticsProvider: React.FC<AnalyticsProviderProps>;
196
+ //# sourceMappingURL=AnalyticsProvider.d.ts.map
197
+
198
+ //#endregion
199
+ //#region src/hooks/useAnalytics.d.ts
200
+ /**
201
+ * Custom hook for accessing analytics functionality.
202
+ *
203
+ * This hook provides a convenient interface for tracking user interactions
204
+ * throughout the application. It must be used within an AnalyticsProvider.
205
+ *
206
+ * For app-specific tracking methods, create a wrapper hook that uses this
207
+ * hook and adds your custom tracking functions.
208
+ *
209
+ * @example
210
+ * ```tsx
211
+ * // Basic usage
212
+ * function MyComponent() {
213
+ * const { trackEvent, trackPageView, isEnabled } = useAnalytics();
214
+ *
215
+ * const handleClick = () => {
216
+ * trackEvent('button_clicked', { button_name: 'submit' });
217
+ * };
218
+ *
219
+ * return (
220
+ * <div>
221
+ * Analytics enabled: {isEnabled().toString()}
222
+ * <button onClick={handleClick}>Submit</button>
223
+ * </div>
224
+ * );
225
+ * }
226
+ * ```
227
+ *
228
+ * @example
229
+ * ```tsx
230
+ * // Creating app-specific wrapper hook
231
+ * function useMyAppAnalytics() {
232
+ * const analytics = useAnalytics();
233
+ *
234
+ * return {
235
+ * ...analytics,
236
+ * trackFormSubmit: (formName: string) => {
237
+ * analytics.trackEvent('form_submitted', { form_name: formName });
238
+ * },
239
+ * };
240
+ * }
241
+ * ```
242
+ *
243
+ * @returns Analytics context with tracking methods and state
244
+ * @throws Error if used outside of AnalyticsProvider
245
+ */
246
+ declare const useAnalytics: () => AnalyticsContextValue;
247
+ //# sourceMappingURL=useAnalytics.d.ts.map
248
+ //#endregion
249
+ //#region src/hooks/useAdapterContext.d.ts
250
+ /**
251
+ * Hook to access the adapter context
252
+ *
253
+ * This hook provides access to the getAdapterForNetwork function which
254
+ * retrieves or creates adapter instances from the singleton registry.
255
+ *
256
+ * Components should typically use useConfiguredAdapterSingleton instead
257
+ * of this hook directly, as it handles React state update timing properly.
258
+ *
259
+ * @throws Error if used outside of an AdapterProvider context
260
+ * @returns The adapter context value
261
+ */
262
+ declare function useAdapterContext(): AdapterContextValue;
263
+ //# sourceMappingURL=useAdapterContext.d.ts.map
264
+ //#endregion
265
+ //#region src/hooks/useDerivedAccountStatus.d.ts
266
+ interface DerivedAccountStatus {
267
+ isConnected: boolean;
268
+ address?: string;
269
+ chainId?: number;
270
+ }
271
+ /**
272
+ * A custom hook that consumes useWalletState to get the walletFacadeHooks,
273
+ * then calls the useAccount facade hook (if available) and returns a structured,
274
+ * safely-accessed account status (isConnected, address, chainId).
275
+ * Provides default values if the hook or its properties are unavailable.
276
+ */
277
+ declare function useDerivedAccountStatus(): DerivedAccountStatus;
278
+ //# sourceMappingURL=useDerivedAccountStatus.d.ts.map
279
+ //#endregion
280
+ //#region src/hooks/useDerivedSwitchChainStatus.d.ts
281
+ interface DerivedSwitchChainStatus {
282
+ /** Function to initiate a network switch. Undefined if not available. */
283
+ switchChain?: (args: {
284
+ chainId: number;
285
+ }) => void;
286
+ /** True if a network switch is currently in progress. */
287
+ isSwitching: boolean;
288
+ /** Error object if the last switch attempt failed, otherwise null. */
289
+ error: Error | null;
290
+ }
291
+ /**
292
+ * A custom hook that consumes `useWalletState` to get `walletFacadeHooks`,
293
+ * then calls the `useSwitchChain` facade hook (if available) and returns a structured,
294
+ * safely-accessed status and control function for network switching.
295
+ * Provides default values if the hook or its properties are unavailable.
296
+ */
297
+ declare function useDerivedSwitchChainStatus(): DerivedSwitchChainStatus;
298
+ //# sourceMappingURL=useDerivedSwitchChainStatus.d.ts.map
299
+ //#endregion
300
+ //#region src/hooks/useDerivedChainInfo.d.ts
301
+ interface DerivedChainInfo {
302
+ /** The current chain ID reported by the wallet's active connection, if available. */
303
+ currentChainId?: number;
304
+ /** Array of chains configured in the underlying wallet library (e.g., wagmi). Type is any[] for generic compatibility. */
305
+ availableChains: unknown[];
306
+ }
307
+ /**
308
+ * A custom hook that consumes `useWalletState` to get `walletFacadeHooks`,
309
+ * then calls the `useChainId` and `useChains` facade hooks (if available)
310
+ * and returns a structured object with this information.
311
+ * Provides default values if the hooks or their properties are unavailable.
312
+ */
313
+ declare function useDerivedChainInfo(): DerivedChainInfo;
314
+ //# sourceMappingURL=useDerivedChainInfo.d.ts.map
315
+ //#endregion
316
+ //#region src/hooks/useDerivedConnectStatus.d.ts
317
+ interface DerivedConnectStatus {
318
+ /** Function to initiate a connection, usually takes a connector. Undefined if not available. */
319
+ connect?: (args?: {
320
+ connector?: Connector;
321
+ }) => void;
322
+ /** Array of available connectors. Type is any[] for broad compatibility until Connector type is fully generic here. */
323
+ connectors: Connector[];
324
+ /** True if a connection attempt is in progress. */
325
+ isConnecting: boolean;
326
+ /** Error object if the last connection attempt failed, otherwise null. */
327
+ error: Error | null;
328
+ /** The connector a connection is pending for, if any. */
329
+ pendingConnector?: Connector;
330
+ }
331
+ /**
332
+ * A custom hook that consumes `useWalletState` to get `walletFacadeHooks`,
333
+ * then calls the `useConnect` facade hook (if available) and returns a structured,
334
+ * safely-accessed status and control functions for wallet connection.
335
+ */
336
+ declare function useDerivedConnectStatus(): DerivedConnectStatus;
337
+ //# sourceMappingURL=useDerivedConnectStatus.d.ts.map
338
+ //#endregion
339
+ //#region src/hooks/useDerivedDisconnect.d.ts
340
+ interface DerivedDisconnectStatus {
341
+ /** Function to initiate disconnection. Undefined if not available. */
342
+ disconnect?: () => void | Promise<void>;
343
+ /** True if a disconnection attempt is in progress (if hook provides this). */
344
+ isDisconnecting: boolean;
345
+ /** Error object if the last disconnection attempt failed (if hook provides this). */
346
+ error: Error | null;
347
+ }
348
+ /**
349
+ * A custom hook that consumes `useWalletState` to get `walletFacadeHooks`,
350
+ * then calls the `useDisconnect` facade hook (if available) and returns a structured,
351
+ * safely-accessed status and control function for wallet disconnection.
352
+ */
353
+ declare function useDerivedDisconnect(): DerivedDisconnectStatus;
354
+ //# sourceMappingURL=useDerivedDisconnect.d.ts.map
355
+ //#endregion
356
+ //#region src/hooks/useWalletReconnectionHandler.d.ts
357
+ /**
358
+ * Hook that detects wallet reconnection and re-queues network switch if needed.
359
+ *
360
+ * When a user disconnects their wallet and then reconnects in the same session,
361
+ * the wallet may connect to a different chain than what's selected in the app.
362
+ * This hook detects that scenario and invokes a callback to re-queue the network switch.
363
+ *
364
+ * @param selectedNetworkConfigId - Currently selected network in the app
365
+ * @param selectedAdapter - Currently active adapter instance
366
+ * @param networkToSwitchTo - Current network switch queue state (null if no switch pending)
367
+ * @param onRequeueSwitch - Callback invoked when a network switch should be re-queued
368
+ */
369
+ declare function useWalletReconnectionHandler(selectedNetworkConfigId: string | null, selectedAdapter: ContractAdapter | null, networkToSwitchTo: string | null, onRequeueSwitch: (networkId: string) => void): void;
370
+ //# sourceMappingURL=useWalletReconnectionHandler.d.ts.map
371
+ //#endregion
372
+ //#region src/components/WalletConnectionHeader.d.ts
373
+ /**
374
+ * Component that renders the wallet connection UI.
375
+ * Uses useWalletState to get its data.
376
+ */
377
+ declare const WalletConnectionHeader: React.FC;
378
+ //# sourceMappingURL=WalletConnectionHeader.d.ts.map
379
+ //#endregion
380
+ //#region src/components/WalletConnectionUI.d.ts
381
+ interface WalletConnectionUIProps {
382
+ className?: string;
383
+ }
384
+ /**
385
+ * Component that displays wallet connection UI components
386
+ * provided by the active adapter.
387
+ */
388
+ declare const WalletConnectionUI: React.FC<WalletConnectionUIProps>;
389
+ //#endregion
390
+ //#region src/components/NetworkSwitchManager.d.ts
391
+ /**
392
+ * Props for the NetworkSwitchManager component.
393
+ */
394
+ interface NetworkSwitchManagerProps {
395
+ /** The adapter instance for the target network */
396
+ adapter: ContractAdapter;
397
+ /** The network ID we want to switch to */
398
+ targetNetworkId: string;
399
+ /** Callback when network switch completes (success or error) */
400
+ onNetworkSwitchComplete?: () => void;
401
+ }
402
+ /**
403
+ * Component that handles wallet network switching based on the selected network.
404
+ *
405
+ * This component manages the lifecycle of network switching operations,
406
+ * coordinating between the wallet's current chain state and the target network.
407
+ * It's designed to be used in any application that needs seamless wallet network switching.
408
+ *
409
+ * Features:
410
+ * - Automatically initiates network switch when mounted with a target network
411
+ * - Handles EVM chain switching gracefully
412
+ * - No-ops for non-EVM networks that don't support chain switching
413
+ * - Tracks switch attempts to prevent duplicate operations
414
+ * - Provides completion callback for parent components to handle state cleanup
415
+ */
416
+ declare const NetworkSwitchManager: React.FC<NetworkSwitchManagerProps>;
417
+ //# sourceMappingURL=NetworkSwitchManager.d.ts.map
418
+
419
+ //#endregion
420
+ export { AdapterContext, type AdapterContextValue, AdapterProvider, type AdapterProviderProps, type AdapterRegistry, AnalyticsContext, type AnalyticsContextValue, AnalyticsProvider, type AnalyticsProviderProps, type DerivedAccountStatus, type DerivedChainInfo, type DerivedConnectStatus, type DerivedDisconnectStatus, type DerivedSwitchChainStatus, NetworkSwitchManager, type NetworkSwitchManagerProps, WalletConnectionHeader, WalletConnectionUI, WalletStateContext, type WalletStateContextValue, WalletStateProvider, type WalletStateProviderProps, useAdapterContext, useAnalytics, useDerivedAccountStatus, useDerivedChainInfo, useDerivedConnectStatus, useDerivedDisconnect, useDerivedSwitchChainStatus, useWalletReconnectionHandler, useWalletState };
421
+ //# sourceMappingURL=index-B_dOGVNW.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-B_dOGVNW.d.ts","names":[],"sources":["../src/hooks/AdapterContext.tsx","../src/hooks/AdapterProvider.tsx","../src/hooks/WalletStateContext.tsx","../src/hooks/WalletStateProvider.tsx","../src/hooks/AnalyticsContext.tsx","../src/hooks/AnalyticsProvider.tsx","../src/hooks/useAnalytics.ts","../src/hooks/useAdapterContext.ts","../src/hooks/useDerivedAccountStatus.ts","../src/hooks/useDerivedSwitchChainStatus.ts","../src/hooks/useDerivedChainInfo.ts","../src/hooks/useDerivedConnectStatus.ts","../src/hooks/useDerivedDisconnect.ts","../src/hooks/useWalletReconnectionHandler.ts","../src/components/WalletConnectionHeader.tsx","../src/components/WalletConnectionUI.tsx","../src/components/NetworkSwitchManager.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;UAmBiB,eAAA;EAAA,CAAA,SAAA,EAAA,MAAe,CAAA,EACT,eAAA;AAQvB;;;;;AAWA;AAA6E,UAX5D,mBAAA,CAW4D;sBAAlD,EAAA,CAAA,aAAA,EAVa,aAUb,GAAA,IAAA,EAAA,GAAA;IAAA,OAAA,EATd,eASc,GAAA,IAAA;IAAA,SAAA,EAAA,OAAA;;;;ACjB3B;;;AAGkC,cDcrB,cCdqB,EDcP,MAAA,CAAA,OCdO,CDcP,mBCdO,GAAA,IAAA,CAAA;;;;UAHjB,oBAAA;YACL;;EADK,cAAA,EAAA,CAAA,aAAoB,EAGH,aAHG,EAAA,GAGe,OAHf,CAGuB,eAHvB,CAAA;;;;;;;AAgBrC;;;;;AAA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