@tuwaio/nova-connect 1.0.0-fix-integrate-orbit-alpha.30.3d6b687 → 1.0.0-fix-test-alpha.1.1de2063
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/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -21
- package/dist/index.d.ts +21 -21
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/providers/index.cjs +3 -3
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.d.cts +218 -33
- package/dist/providers/index.d.ts +218 -33
- package/dist/providers/index.js +3 -3
- package/dist/providers/index.js.map +1 -1
- package/package.json +3 -8
- package/dist/hooks/index.cjs +0 -2
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.js +0 -2
- package/dist/hooks/index.js.map +0 -1
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
2
|
import { ComponentPropsWithoutRef, ComponentType, ReactNode } from 'react';
|
|
3
|
-
import { ToastContainer, toast, ToastPosition } from 'react-toastify';
|
|
4
3
|
import { OrbitAdapter } from '@tuwaio/orbit-core';
|
|
5
4
|
import { ISatelliteConnectStore, BaseWallet } from '@tuwaio/satellite-core';
|
|
6
5
|
import { StoreApi } from 'zustand/index';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @description
|
|
10
|
-
* This interface is intentionally left empty.
|
|
11
|
-
* Other packages (@tuwaio/satellite-*) will use module
|
|
12
|
-
* augmentation to add their specific wallet types here.
|
|
13
|
-
*/
|
|
14
|
-
interface AllWallets {
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @description
|
|
18
|
-
* This interface is intentionally left empty.
|
|
19
|
-
* It will be augmented by satellite packages.
|
|
20
|
-
*/
|
|
21
|
-
interface AllConnectors {
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Union type for all supported wallet types.
|
|
25
|
-
* It's created from the values of the AllWallets interface.
|
|
26
|
-
* e.g., { evm: EVMWallet, solana: SolanaWallet } -> EVMWallet | SolanaWallet
|
|
27
|
-
*/
|
|
28
|
-
type Wallet = AllWallets[keyof AllWallets];
|
|
29
|
-
/**
|
|
30
|
-
* Union type for all supported connector types.
|
|
31
|
-
*/
|
|
32
|
-
type Connector = AllConnectors[keyof AllConnectors];
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
import { ToastContainer, toast, ToastPosition } from 'react-toastify';
|
|
33
8
|
|
|
34
9
|
/**
|
|
35
10
|
* Type definitions for NovaConnect component translations
|
|
@@ -128,14 +103,44 @@ type NovaConnectLabels = {
|
|
|
128
103
|
impersonateAddressConnected: string;
|
|
129
104
|
};
|
|
130
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @description
|
|
108
|
+
* This interface is intentionally left empty.
|
|
109
|
+
* Other packages (@tuwaio/satellite-*) will use module
|
|
110
|
+
* augmentation to add their specific wallet types here.
|
|
111
|
+
*/
|
|
112
|
+
interface AllWallets {
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @description
|
|
116
|
+
* This interface is intentionally left empty.
|
|
117
|
+
* It will be augmented by satellite packages.
|
|
118
|
+
*/
|
|
119
|
+
interface AllConnectors {
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Union type for all supported wallet types.
|
|
123
|
+
* It's created from the values of the AllWallets interface.
|
|
124
|
+
* e.g., { evm: EVMWallet, solana: SolanaWallet } -> EVMWallet | SolanaWallet
|
|
125
|
+
*/
|
|
126
|
+
type Wallet = AllWallets[keyof AllWallets];
|
|
127
|
+
/**
|
|
128
|
+
* Union type for all supported connector types.
|
|
129
|
+
*/
|
|
130
|
+
type Connector = AllConnectors[keyof AllConnectors];
|
|
131
|
+
|
|
131
132
|
type ButtonTxStatus = 'idle' | 'loading' | 'succeed' | 'failed' | 'replaced';
|
|
132
133
|
type ConnectContentType = 'network' | 'connectors' | 'about' | 'getWallet' | 'connecting' | 'impersonate';
|
|
133
134
|
type ConnectedContentType = 'main' | 'transactions' | 'chains';
|
|
134
|
-
interface NovaConnectProviderProps
|
|
135
|
+
interface NovaConnectProviderProps {
|
|
135
136
|
store: StoreApi<ISatelliteConnectStore<Connector, Wallet>>;
|
|
136
137
|
children: React.ReactNode;
|
|
137
138
|
labels?: Partial<NovaConnectLabels>;
|
|
138
139
|
}
|
|
140
|
+
interface WalletBalance {
|
|
141
|
+
value: string;
|
|
142
|
+
symbol: string;
|
|
143
|
+
}
|
|
139
144
|
interface NovaConnectProviderType {
|
|
140
145
|
activeWallet: BaseWallet | undefined;
|
|
141
146
|
walletConnectionError: string | undefined;
|
|
@@ -162,6 +167,186 @@ interface NovaConnectProviderType {
|
|
|
162
167
|
impersonatedAddress: string;
|
|
163
168
|
setImpersonatedAddress: (value: string) => void;
|
|
164
169
|
}
|
|
170
|
+
declare class NovaConnectProviderError extends Error {
|
|
171
|
+
constructor(message?: string);
|
|
172
|
+
}
|
|
173
|
+
declare const NovaConnectProviderContext: React$1.Context<NovaConnectProviderType | undefined>;
|
|
174
|
+
/**
|
|
175
|
+
* Hook to access NovaConnect context
|
|
176
|
+
*
|
|
177
|
+
* @throws {NovaConnectProviderError} When used outside of NovaConnectProvider
|
|
178
|
+
* @returns {NovaConnectProviderType} The NovaConnect context value
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* function MyComponent() {
|
|
183
|
+
* const { isConnected, handleConnectButtonClick } = useNovaConnect();
|
|
184
|
+
*
|
|
185
|
+
* return (
|
|
186
|
+
* <button onClick={handleConnectButtonClick}>
|
|
187
|
+
* {isConnected ? 'Connected' : 'Connect Wallet'}
|
|
188
|
+
* </button>
|
|
189
|
+
* );
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare const useNovaConnect: () => NovaConnectProviderType;
|
|
194
|
+
/**
|
|
195
|
+
* Hook to check if NovaConnect context is available
|
|
196
|
+
*
|
|
197
|
+
* @returns {boolean} True if context is available, false otherwise
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* function ConditionalComponent() {
|
|
202
|
+
* const hasContext = useHasNovaConnectContext();
|
|
203
|
+
*
|
|
204
|
+
* if (!hasContext) {
|
|
205
|
+
* return <div>NovaConnect provider not found</div>;
|
|
206
|
+
* }
|
|
207
|
+
*
|
|
208
|
+
* return <ConnectedComponent />;
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
declare const useHasNovaConnectContext: () => boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Optional hook that returns null if provider is not available
|
|
215
|
+
*
|
|
216
|
+
* @returns {NovaConnectProviderType | null} Context value or null if not available
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* function OptionalComponent() {
|
|
221
|
+
* const context = useNovaConnectOptional();
|
|
222
|
+
*
|
|
223
|
+
* if (!context) {
|
|
224
|
+
* return <div>No wallet provider available</div>;
|
|
225
|
+
* }
|
|
226
|
+
*
|
|
227
|
+
* return <div>Connected: {context.isConnected}</div>;
|
|
228
|
+
* }
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
declare const useNovaConnectOptional: () => NovaConnectProviderType | null;
|
|
232
|
+
|
|
233
|
+
interface WalletNameAndAvatarData {
|
|
234
|
+
/** The resolved name from the Name Service (e.g., ENS, like "alice.eth"), or null if not found. */
|
|
235
|
+
ensName: string | null;
|
|
236
|
+
/** The URL of the avatar associated with the name, or null if not found. */
|
|
237
|
+
ensAvatar: string | null;
|
|
238
|
+
/** True while the name service data is being fetched. */
|
|
239
|
+
isLoading: boolean;
|
|
240
|
+
/** A truncated version of the name for display, or the abbreviated address if no name. */
|
|
241
|
+
ensNameAbbreviated: string | undefined;
|
|
242
|
+
/** Error message if the name resolution failed. */
|
|
243
|
+
error: string | null;
|
|
244
|
+
/** Function to retry the name resolution manually. */
|
|
245
|
+
retry: () => void;
|
|
246
|
+
}
|
|
247
|
+
interface UseGetWalletNameAndAvatarOptions extends Pick<NovaConnectProviderProps, 'store'>, Pick<NovaConnectProviderType, 'activeWallet'> {
|
|
248
|
+
/** Number of characters to show on each side when abbreviating (default: 12) */
|
|
249
|
+
abbreviateSymbols?: number;
|
|
250
|
+
/** Maximum length before abbreviation is applied (default: 30) */
|
|
251
|
+
maxNameLength?: number;
|
|
252
|
+
/** Whether to automatically retry on failure (default: false) */
|
|
253
|
+
autoRetry?: boolean;
|
|
254
|
+
/** Retry delay in milliseconds (default: 3000) */
|
|
255
|
+
retryDelay?: number;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* A custom hook to fetch the Name Service (e.g., ENS) name and avatar
|
|
259
|
+
* for the currently active wallet.
|
|
260
|
+
*
|
|
261
|
+
* This hook automatically detects the active wallet and its corresponding
|
|
262
|
+
* adapter via the `useSatelliteConnectStore` and attempts to resolve the
|
|
263
|
+
* wallet address to a human-readable name and avatar.
|
|
264
|
+
*
|
|
265
|
+
* @param options Configuration options for the hook
|
|
266
|
+
* @returns An object containing the resolved name, avatar, loading state, and utility functions
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```typescript
|
|
270
|
+
* import { useGetWalletNameAndAvatar } from './useGetWalletNameAndAvatar';
|
|
271
|
+
*
|
|
272
|
+
* function DisplayWalletInfo() {
|
|
273
|
+
* const { ensName, ensAvatar, isLoading, ensNameAbbreviated, error, retry } = useGetWalletNameAndAvatar({
|
|
274
|
+
* abbreviateSymbols: 8,
|
|
275
|
+
* maxNameLength: 25
|
|
276
|
+
* });
|
|
277
|
+
*
|
|
278
|
+
* if (isLoading) {
|
|
279
|
+
* return <div>Resolving name...</div>;
|
|
280
|
+
* }
|
|
281
|
+
*
|
|
282
|
+
* if (error) {
|
|
283
|
+
* return <div>Error: {error} <button onClick={retry}>Retry</button></div>;
|
|
284
|
+
* }
|
|
285
|
+
*
|
|
286
|
+
* return (
|
|
287
|
+
* <div className="wallet-info">
|
|
288
|
+
* {ensAvatar && <img src={ensAvatar} alt="Wallet Avatar" />}
|
|
289
|
+
* <p title={ensName || ''}>{ensNameAbbreviated || 'No Name Found'}</p>
|
|
290
|
+
* </div>
|
|
291
|
+
* );
|
|
292
|
+
* }
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
declare function useGetWalletNameAndAvatar(options: UseGetWalletNameAndAvatarOptions): WalletNameAndAvatarData;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* @interface NativeBalanceResult
|
|
299
|
+
* Represents the native token balance returned by the adapter.
|
|
300
|
+
* The value is already formatted for human readability.
|
|
301
|
+
* @property {string} value The native token balance formatted to standard decimals (e.g., "1.5").
|
|
302
|
+
* @property {string} symbol The symbol of the native token (e.g., "ETH").
|
|
303
|
+
*/
|
|
304
|
+
interface NativeBalanceResult {
|
|
305
|
+
value: string;
|
|
306
|
+
symbol: string;
|
|
307
|
+
}
|
|
308
|
+
type NativeBalanceState = NativeBalanceResult | null;
|
|
309
|
+
/**
|
|
310
|
+
* @interface NativeBalanceData
|
|
311
|
+
* The object returned by the useWalletNativeBalance hook.
|
|
312
|
+
* @property {NativeBalanceState} balance The native token balance and symbol, or null.
|
|
313
|
+
* @property {boolean} isLoading True while the balance is being fetched for the current wallet/chain combination.
|
|
314
|
+
* @property {() => void} refetch Function to manually trigger a balance refresh.
|
|
315
|
+
*/
|
|
316
|
+
interface NativeBalanceData {
|
|
317
|
+
balance: NativeBalanceState;
|
|
318
|
+
isLoading: boolean;
|
|
319
|
+
refetch: () => void;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Custom hook to fetch the native token balance for the currently connected wallet
|
|
323
|
+
* on the active chain. It includes a local cache layer to prevent redundant network calls
|
|
324
|
+
* when switching between components or on re-renders for the same wallet/chain.
|
|
325
|
+
*
|
|
326
|
+
* @returns {NativeBalanceData} An object containing the balance data and loading state.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```typescript
|
|
330
|
+
* import { useWalletNativeBalance } from './useWalletNativeBalance';
|
|
331
|
+
*
|
|
332
|
+
* function NativeTokenDisplay() {
|
|
333
|
+
* const { balance, isLoading, refetch } = useWalletNativeBalance();
|
|
334
|
+
*
|
|
335
|
+
* if (isLoading) {
|
|
336
|
+
* return <p>Loading balance...</p>;
|
|
337
|
+
* }
|
|
338
|
+
*
|
|
339
|
+
* // Display the formatted balance and symbol
|
|
340
|
+
* return (
|
|
341
|
+
* <div>
|
|
342
|
+
* <p>Balance: {balance ? `${balance.value} ${balance.symbol}` : '0.00'}</p>
|
|
343
|
+
* <button onClick={refetch}>Refresh</button>
|
|
344
|
+
* </div>
|
|
345
|
+
* );
|
|
346
|
+
* }
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function useWalletNativeBalance({ store, activeWallet, }: Pick<NovaConnectProviderProps, 'store'> & Pick<NovaConnectProviderType, 'activeWallet'>): NativeBalanceData;
|
|
165
350
|
|
|
166
351
|
type CustomIconProps = {
|
|
167
352
|
isCopied: boolean;
|
|
@@ -302,7 +487,7 @@ type ErrorsProviderCustomization = {
|
|
|
302
487
|
errorType: 'wallet' | 'switch' | null;
|
|
303
488
|
}) => string | null;
|
|
304
489
|
};
|
|
305
|
-
interface ErrorsProviderProps extends Pick<NovaConnectProviderProps
|
|
490
|
+
interface ErrorsProviderProps extends Pick<NovaConnectProviderProps, 'store'> {
|
|
306
491
|
/** Custom container ID for toast notifications */
|
|
307
492
|
containerId?: string;
|
|
308
493
|
/** Custom position for toast notifications */
|
|
@@ -445,7 +630,7 @@ type NovaConnectProviderCustomization = {
|
|
|
445
630
|
/**
|
|
446
631
|
* Extended props for NovaConnectProvider with full customization capabilities
|
|
447
632
|
*/
|
|
448
|
-
interface
|
|
633
|
+
interface NovaConnectProviderPropsWithCustomization extends NovaConnectProviderProps {
|
|
449
634
|
/** Comprehensive customization options for the provider and its sub-components */
|
|
450
635
|
customization?: NovaConnectProviderCustomization;
|
|
451
636
|
}
|
|
@@ -498,9 +683,9 @@ interface NovaConnectProviderProps extends NovaConnectProviderProps$1 {
|
|
|
498
683
|
*
|
|
499
684
|
* @param props - Provider configuration and customization options
|
|
500
685
|
*/
|
|
501
|
-
declare function NovaConnectProvider({ labels, store, children, customization }:
|
|
686
|
+
declare function NovaConnectProvider({ labels, store, children, customization, }: NovaConnectProviderPropsWithCustomization): react_jsx_runtime.JSX.Element;
|
|
502
687
|
declare namespace NovaConnectProvider {
|
|
503
688
|
var displayName: string;
|
|
504
689
|
}
|
|
505
690
|
|
|
506
|
-
export { ErrorsProvider, type ErrorsProviderCustomization, type ErrorsProviderProps, NovaConnectLabelsProvider, NovaConnectProvider, type NovaConnectProviderCustomization, type NovaConnectProviderProps };
|
|
691
|
+
export { type ButtonTxStatus, type ConnectContentType, type ConnectedContentType, ErrorsProvider, type ErrorsProviderCustomization, type ErrorsProviderProps, type NativeBalanceResult, NovaConnectLabelsProvider, NovaConnectProvider, NovaConnectProviderContext, type NovaConnectProviderCustomization, NovaConnectProviderError, type NovaConnectProviderProps, type NovaConnectProviderPropsWithCustomization, type NovaConnectProviderType, type WalletBalance, type WalletNameAndAvatarData, useGetWalletNameAndAvatar, useHasNovaConnectContext, useNovaConnect, useNovaConnectOptional, useWalletNativeBalance };
|
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
2
|
import { ComponentPropsWithoutRef, ComponentType, ReactNode } from 'react';
|
|
3
|
-
import { ToastContainer, toast, ToastPosition } from 'react-toastify';
|
|
4
3
|
import { OrbitAdapter } from '@tuwaio/orbit-core';
|
|
5
4
|
import { ISatelliteConnectStore, BaseWallet } from '@tuwaio/satellite-core';
|
|
6
5
|
import { StoreApi } from 'zustand/index';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* @description
|
|
10
|
-
* This interface is intentionally left empty.
|
|
11
|
-
* Other packages (@tuwaio/satellite-*) will use module
|
|
12
|
-
* augmentation to add their specific wallet types here.
|
|
13
|
-
*/
|
|
14
|
-
interface AllWallets {
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* @description
|
|
18
|
-
* This interface is intentionally left empty.
|
|
19
|
-
* It will be augmented by satellite packages.
|
|
20
|
-
*/
|
|
21
|
-
interface AllConnectors {
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Union type for all supported wallet types.
|
|
25
|
-
* It's created from the values of the AllWallets interface.
|
|
26
|
-
* e.g., { evm: EVMWallet, solana: SolanaWallet } -> EVMWallet | SolanaWallet
|
|
27
|
-
*/
|
|
28
|
-
type Wallet = AllWallets[keyof AllWallets];
|
|
29
|
-
/**
|
|
30
|
-
* Union type for all supported connector types.
|
|
31
|
-
*/
|
|
32
|
-
type Connector = AllConnectors[keyof AllConnectors];
|
|
6
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
|
+
import { ToastContainer, toast, ToastPosition } from 'react-toastify';
|
|
33
8
|
|
|
34
9
|
/**
|
|
35
10
|
* Type definitions for NovaConnect component translations
|
|
@@ -128,14 +103,44 @@ type NovaConnectLabels = {
|
|
|
128
103
|
impersonateAddressConnected: string;
|
|
129
104
|
};
|
|
130
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @description
|
|
108
|
+
* This interface is intentionally left empty.
|
|
109
|
+
* Other packages (@tuwaio/satellite-*) will use module
|
|
110
|
+
* augmentation to add their specific wallet types here.
|
|
111
|
+
*/
|
|
112
|
+
interface AllWallets {
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* @description
|
|
116
|
+
* This interface is intentionally left empty.
|
|
117
|
+
* It will be augmented by satellite packages.
|
|
118
|
+
*/
|
|
119
|
+
interface AllConnectors {
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Union type for all supported wallet types.
|
|
123
|
+
* It's created from the values of the AllWallets interface.
|
|
124
|
+
* e.g., { evm: EVMWallet, solana: SolanaWallet } -> EVMWallet | SolanaWallet
|
|
125
|
+
*/
|
|
126
|
+
type Wallet = AllWallets[keyof AllWallets];
|
|
127
|
+
/**
|
|
128
|
+
* Union type for all supported connector types.
|
|
129
|
+
*/
|
|
130
|
+
type Connector = AllConnectors[keyof AllConnectors];
|
|
131
|
+
|
|
131
132
|
type ButtonTxStatus = 'idle' | 'loading' | 'succeed' | 'failed' | 'replaced';
|
|
132
133
|
type ConnectContentType = 'network' | 'connectors' | 'about' | 'getWallet' | 'connecting' | 'impersonate';
|
|
133
134
|
type ConnectedContentType = 'main' | 'transactions' | 'chains';
|
|
134
|
-
interface NovaConnectProviderProps
|
|
135
|
+
interface NovaConnectProviderProps {
|
|
135
136
|
store: StoreApi<ISatelliteConnectStore<Connector, Wallet>>;
|
|
136
137
|
children: React.ReactNode;
|
|
137
138
|
labels?: Partial<NovaConnectLabels>;
|
|
138
139
|
}
|
|
140
|
+
interface WalletBalance {
|
|
141
|
+
value: string;
|
|
142
|
+
symbol: string;
|
|
143
|
+
}
|
|
139
144
|
interface NovaConnectProviderType {
|
|
140
145
|
activeWallet: BaseWallet | undefined;
|
|
141
146
|
walletConnectionError: string | undefined;
|
|
@@ -162,6 +167,186 @@ interface NovaConnectProviderType {
|
|
|
162
167
|
impersonatedAddress: string;
|
|
163
168
|
setImpersonatedAddress: (value: string) => void;
|
|
164
169
|
}
|
|
170
|
+
declare class NovaConnectProviderError extends Error {
|
|
171
|
+
constructor(message?: string);
|
|
172
|
+
}
|
|
173
|
+
declare const NovaConnectProviderContext: React$1.Context<NovaConnectProviderType | undefined>;
|
|
174
|
+
/**
|
|
175
|
+
* Hook to access NovaConnect context
|
|
176
|
+
*
|
|
177
|
+
* @throws {NovaConnectProviderError} When used outside of NovaConnectProvider
|
|
178
|
+
* @returns {NovaConnectProviderType} The NovaConnect context value
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* function MyComponent() {
|
|
183
|
+
* const { isConnected, handleConnectButtonClick } = useNovaConnect();
|
|
184
|
+
*
|
|
185
|
+
* return (
|
|
186
|
+
* <button onClick={handleConnectButtonClick}>
|
|
187
|
+
* {isConnected ? 'Connected' : 'Connect Wallet'}
|
|
188
|
+
* </button>
|
|
189
|
+
* );
|
|
190
|
+
* }
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
declare const useNovaConnect: () => NovaConnectProviderType;
|
|
194
|
+
/**
|
|
195
|
+
* Hook to check if NovaConnect context is available
|
|
196
|
+
*
|
|
197
|
+
* @returns {boolean} True if context is available, false otherwise
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* function ConditionalComponent() {
|
|
202
|
+
* const hasContext = useHasNovaConnectContext();
|
|
203
|
+
*
|
|
204
|
+
* if (!hasContext) {
|
|
205
|
+
* return <div>NovaConnect provider not found</div>;
|
|
206
|
+
* }
|
|
207
|
+
*
|
|
208
|
+
* return <ConnectedComponent />;
|
|
209
|
+
* }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
declare const useHasNovaConnectContext: () => boolean;
|
|
213
|
+
/**
|
|
214
|
+
* Optional hook that returns null if provider is not available
|
|
215
|
+
*
|
|
216
|
+
* @returns {NovaConnectProviderType | null} Context value or null if not available
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* ```typescript
|
|
220
|
+
* function OptionalComponent() {
|
|
221
|
+
* const context = useNovaConnectOptional();
|
|
222
|
+
*
|
|
223
|
+
* if (!context) {
|
|
224
|
+
* return <div>No wallet provider available</div>;
|
|
225
|
+
* }
|
|
226
|
+
*
|
|
227
|
+
* return <div>Connected: {context.isConnected}</div>;
|
|
228
|
+
* }
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
declare const useNovaConnectOptional: () => NovaConnectProviderType | null;
|
|
232
|
+
|
|
233
|
+
interface WalletNameAndAvatarData {
|
|
234
|
+
/** The resolved name from the Name Service (e.g., ENS, like "alice.eth"), or null if not found. */
|
|
235
|
+
ensName: string | null;
|
|
236
|
+
/** The URL of the avatar associated with the name, or null if not found. */
|
|
237
|
+
ensAvatar: string | null;
|
|
238
|
+
/** True while the name service data is being fetched. */
|
|
239
|
+
isLoading: boolean;
|
|
240
|
+
/** A truncated version of the name for display, or the abbreviated address if no name. */
|
|
241
|
+
ensNameAbbreviated: string | undefined;
|
|
242
|
+
/** Error message if the name resolution failed. */
|
|
243
|
+
error: string | null;
|
|
244
|
+
/** Function to retry the name resolution manually. */
|
|
245
|
+
retry: () => void;
|
|
246
|
+
}
|
|
247
|
+
interface UseGetWalletNameAndAvatarOptions extends Pick<NovaConnectProviderProps, 'store'>, Pick<NovaConnectProviderType, 'activeWallet'> {
|
|
248
|
+
/** Number of characters to show on each side when abbreviating (default: 12) */
|
|
249
|
+
abbreviateSymbols?: number;
|
|
250
|
+
/** Maximum length before abbreviation is applied (default: 30) */
|
|
251
|
+
maxNameLength?: number;
|
|
252
|
+
/** Whether to automatically retry on failure (default: false) */
|
|
253
|
+
autoRetry?: boolean;
|
|
254
|
+
/** Retry delay in milliseconds (default: 3000) */
|
|
255
|
+
retryDelay?: number;
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* A custom hook to fetch the Name Service (e.g., ENS) name and avatar
|
|
259
|
+
* for the currently active wallet.
|
|
260
|
+
*
|
|
261
|
+
* This hook automatically detects the active wallet and its corresponding
|
|
262
|
+
* adapter via the `useSatelliteConnectStore` and attempts to resolve the
|
|
263
|
+
* wallet address to a human-readable name and avatar.
|
|
264
|
+
*
|
|
265
|
+
* @param options Configuration options for the hook
|
|
266
|
+
* @returns An object containing the resolved name, avatar, loading state, and utility functions
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```typescript
|
|
270
|
+
* import { useGetWalletNameAndAvatar } from './useGetWalletNameAndAvatar';
|
|
271
|
+
*
|
|
272
|
+
* function DisplayWalletInfo() {
|
|
273
|
+
* const { ensName, ensAvatar, isLoading, ensNameAbbreviated, error, retry } = useGetWalletNameAndAvatar({
|
|
274
|
+
* abbreviateSymbols: 8,
|
|
275
|
+
* maxNameLength: 25
|
|
276
|
+
* });
|
|
277
|
+
*
|
|
278
|
+
* if (isLoading) {
|
|
279
|
+
* return <div>Resolving name...</div>;
|
|
280
|
+
* }
|
|
281
|
+
*
|
|
282
|
+
* if (error) {
|
|
283
|
+
* return <div>Error: {error} <button onClick={retry}>Retry</button></div>;
|
|
284
|
+
* }
|
|
285
|
+
*
|
|
286
|
+
* return (
|
|
287
|
+
* <div className="wallet-info">
|
|
288
|
+
* {ensAvatar && <img src={ensAvatar} alt="Wallet Avatar" />}
|
|
289
|
+
* <p title={ensName || ''}>{ensNameAbbreviated || 'No Name Found'}</p>
|
|
290
|
+
* </div>
|
|
291
|
+
* );
|
|
292
|
+
* }
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
declare function useGetWalletNameAndAvatar(options: UseGetWalletNameAndAvatarOptions): WalletNameAndAvatarData;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* @interface NativeBalanceResult
|
|
299
|
+
* Represents the native token balance returned by the adapter.
|
|
300
|
+
* The value is already formatted for human readability.
|
|
301
|
+
* @property {string} value The native token balance formatted to standard decimals (e.g., "1.5").
|
|
302
|
+
* @property {string} symbol The symbol of the native token (e.g., "ETH").
|
|
303
|
+
*/
|
|
304
|
+
interface NativeBalanceResult {
|
|
305
|
+
value: string;
|
|
306
|
+
symbol: string;
|
|
307
|
+
}
|
|
308
|
+
type NativeBalanceState = NativeBalanceResult | null;
|
|
309
|
+
/**
|
|
310
|
+
* @interface NativeBalanceData
|
|
311
|
+
* The object returned by the useWalletNativeBalance hook.
|
|
312
|
+
* @property {NativeBalanceState} balance The native token balance and symbol, or null.
|
|
313
|
+
* @property {boolean} isLoading True while the balance is being fetched for the current wallet/chain combination.
|
|
314
|
+
* @property {() => void} refetch Function to manually trigger a balance refresh.
|
|
315
|
+
*/
|
|
316
|
+
interface NativeBalanceData {
|
|
317
|
+
balance: NativeBalanceState;
|
|
318
|
+
isLoading: boolean;
|
|
319
|
+
refetch: () => void;
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Custom hook to fetch the native token balance for the currently connected wallet
|
|
323
|
+
* on the active chain. It includes a local cache layer to prevent redundant network calls
|
|
324
|
+
* when switching between components or on re-renders for the same wallet/chain.
|
|
325
|
+
*
|
|
326
|
+
* @returns {NativeBalanceData} An object containing the balance data and loading state.
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* ```typescript
|
|
330
|
+
* import { useWalletNativeBalance } from './useWalletNativeBalance';
|
|
331
|
+
*
|
|
332
|
+
* function NativeTokenDisplay() {
|
|
333
|
+
* const { balance, isLoading, refetch } = useWalletNativeBalance();
|
|
334
|
+
*
|
|
335
|
+
* if (isLoading) {
|
|
336
|
+
* return <p>Loading balance...</p>;
|
|
337
|
+
* }
|
|
338
|
+
*
|
|
339
|
+
* // Display the formatted balance and symbol
|
|
340
|
+
* return (
|
|
341
|
+
* <div>
|
|
342
|
+
* <p>Balance: {balance ? `${balance.value} ${balance.symbol}` : '0.00'}</p>
|
|
343
|
+
* <button onClick={refetch}>Refresh</button>
|
|
344
|
+
* </div>
|
|
345
|
+
* );
|
|
346
|
+
* }
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
declare function useWalletNativeBalance({ store, activeWallet, }: Pick<NovaConnectProviderProps, 'store'> & Pick<NovaConnectProviderType, 'activeWallet'>): NativeBalanceData;
|
|
165
350
|
|
|
166
351
|
type CustomIconProps = {
|
|
167
352
|
isCopied: boolean;
|
|
@@ -302,7 +487,7 @@ type ErrorsProviderCustomization = {
|
|
|
302
487
|
errorType: 'wallet' | 'switch' | null;
|
|
303
488
|
}) => string | null;
|
|
304
489
|
};
|
|
305
|
-
interface ErrorsProviderProps extends Pick<NovaConnectProviderProps
|
|
490
|
+
interface ErrorsProviderProps extends Pick<NovaConnectProviderProps, 'store'> {
|
|
306
491
|
/** Custom container ID for toast notifications */
|
|
307
492
|
containerId?: string;
|
|
308
493
|
/** Custom position for toast notifications */
|
|
@@ -445,7 +630,7 @@ type NovaConnectProviderCustomization = {
|
|
|
445
630
|
/**
|
|
446
631
|
* Extended props for NovaConnectProvider with full customization capabilities
|
|
447
632
|
*/
|
|
448
|
-
interface
|
|
633
|
+
interface NovaConnectProviderPropsWithCustomization extends NovaConnectProviderProps {
|
|
449
634
|
/** Comprehensive customization options for the provider and its sub-components */
|
|
450
635
|
customization?: NovaConnectProviderCustomization;
|
|
451
636
|
}
|
|
@@ -498,9 +683,9 @@ interface NovaConnectProviderProps extends NovaConnectProviderProps$1 {
|
|
|
498
683
|
*
|
|
499
684
|
* @param props - Provider configuration and customization options
|
|
500
685
|
*/
|
|
501
|
-
declare function NovaConnectProvider({ labels, store, children, customization }:
|
|
686
|
+
declare function NovaConnectProvider({ labels, store, children, customization, }: NovaConnectProviderPropsWithCustomization): react_jsx_runtime.JSX.Element;
|
|
502
687
|
declare namespace NovaConnectProvider {
|
|
503
688
|
var displayName: string;
|
|
504
689
|
}
|
|
505
690
|
|
|
506
|
-
export { ErrorsProvider, type ErrorsProviderCustomization, type ErrorsProviderProps, NovaConnectLabelsProvider, NovaConnectProvider, type NovaConnectProviderCustomization, type NovaConnectProviderProps };
|
|
691
|
+
export { type ButtonTxStatus, type ConnectContentType, type ConnectedContentType, ErrorsProvider, type ErrorsProviderCustomization, type ErrorsProviderProps, type NativeBalanceResult, NovaConnectLabelsProvider, NovaConnectProvider, NovaConnectProviderContext, type NovaConnectProviderCustomization, NovaConnectProviderError, type NovaConnectProviderProps, type NovaConnectProviderPropsWithCustomization, type NovaConnectProviderType, type WalletBalance, type WalletNameAndAvatarData, useGetWalletNameAndAvatar, useHasNovaConnectContext, useNovaConnect, useNovaConnectOptional, useWalletNativeBalance };
|