@tuwaio/nova-connect 0.1.0 → 0.1.2
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 +21 -96
- package/dist/ToastError-CSlbvXKT.d.cts +106 -0
- package/dist/ToastError-CSlbvXKT.d.ts +106 -0
- package/dist/chunk-A2677K5M.cjs +2 -0
- package/dist/chunk-A2677K5M.cjs.map +1 -0
- package/dist/chunk-CEGEQMI2.cjs +2 -0
- package/dist/chunk-CEGEQMI2.cjs.map +1 -0
- package/dist/chunk-DYDY3FCT.cjs +2 -0
- package/dist/chunk-DYDY3FCT.cjs.map +1 -0
- package/dist/{chunk-KKCRUSJT.js → chunk-J4TY3CJF.js} +2 -2
- package/dist/{chunk-KKCRUSJT.js.map → chunk-J4TY3CJF.js.map} +1 -1
- package/dist/chunk-LF6FTUUQ.js +2 -0
- package/dist/chunk-LF6FTUUQ.js.map +1 -0
- package/dist/chunk-MPEJHQKC.js +2 -0
- package/dist/chunk-MPEJHQKC.js.map +1 -0
- package/dist/{chunk-NJDPFYUJ.js → chunk-MQGDTFY7.js} +2 -2
- package/dist/{chunk-NJDPFYUJ.js.map → chunk-MQGDTFY7.js.map} +1 -1
- package/dist/chunk-NMQZA377.cjs +2 -0
- package/dist/chunk-NMQZA377.cjs.map +1 -0
- package/dist/chunk-OA6MB7CZ.cjs +2 -0
- package/dist/chunk-OA6MB7CZ.cjs.map +1 -0
- package/dist/chunk-QERPNHKX.cjs +2 -0
- package/dist/chunk-QERPNHKX.cjs.map +1 -0
- package/dist/chunk-RUYOUU6Q.cjs +6 -0
- package/dist/chunk-RUYOUU6Q.cjs.map +1 -0
- package/dist/chunk-TAV7EL23.js +2 -0
- package/dist/chunk-TAV7EL23.js.map +1 -0
- package/dist/chunk-Z2NDRIEI.js +6 -0
- package/dist/chunk-Z2NDRIEI.js.map +1 -0
- package/dist/components/index.cjs +2 -0
- package/dist/components/index.cjs.map +1 -0
- package/dist/components/index.d.cts +6430 -0
- package/dist/components/index.d.ts +6430 -0
- package/dist/components/index.js +2 -0
- package/dist/components/index.js.map +1 -0
- package/dist/evm/index.cjs +1 -1
- package/dist/evm/index.cjs.map +1 -1
- package/dist/evm/index.d.cts +24 -0
- package/dist/evm/index.d.ts +24 -0
- package/dist/evm/index.js +1 -1
- package/dist/evm/index.js.map +1 -1
- package/dist/evm-7NHOTSAK.cjs +2 -0
- package/dist/evm-7NHOTSAK.cjs.map +1 -0
- package/dist/getChainsListByWalletType-CDPECVNS.cjs +2 -0
- package/dist/getChainsListByWalletType-CDPECVNS.cjs.map +1 -0
- package/dist/{getChainsListByWalletType-KXWMBNB4.js → getChainsListByWalletType-VMQ4BO2B.js} +2 -2
- package/dist/{getChainsListByWalletType-KXWMBNB4.js.map → getChainsListByWalletType-VMQ4BO2B.js.map} +1 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.d.cts +70 -0
- package/dist/hooks/index.d.ts +70 -0
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/i18n/index.cjs +2 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/index.d.cts +15 -0
- package/dist/i18n/index.d.ts +15 -0
- package/dist/i18n/index.js +2 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.cjs +1 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +791 -7818
- package/dist/index.d.ts +791 -7818
- package/dist/index.js +1 -5
- package/dist/index.js.map +1 -1
- package/dist/satellite/index.cjs +2 -0
- package/dist/satellite/index.cjs.map +1 -0
- package/dist/satellite/index.d.cts +1 -0
- package/dist/satellite/index.d.ts +1 -0
- package/dist/satellite/index.js +2 -0
- package/dist/satellite/index.js.map +1 -0
- package/dist/solana/index.cjs +1 -1
- package/dist/solana/index.cjs.map +1 -1
- package/dist/solana/index.d.cts +33 -0
- package/dist/solana/index.d.ts +33 -0
- package/dist/solana/index.js +1 -1
- package/dist/solana/index.js.map +1 -1
- package/dist/{providers/solana-WHT5KTOF.js → solana-GLHHYZDQ.js} +2 -2
- package/dist/{solana-2MXIY6UT.js.map → solana-GLHHYZDQ.js.map} +1 -1
- package/dist/solana-JUU54KQ3.cjs +2 -0
- package/dist/solana-JUU54KQ3.cjs.map +1 -0
- package/dist/types-D4Vti05g.d.cts +98 -0
- package/dist/types-D4Vti05g.d.ts +98 -0
- package/dist/types-DGsiEwne.d.cts +50 -0
- package/dist/types-DGsiEwne.d.ts +50 -0
- package/dist/useWalletNativeBalance-6RVzdGvM.d.ts +312 -0
- package/dist/useWalletNativeBalance-D8Ehciju.d.cts +312 -0
- package/dist/utils-DZB4ZTS4.cjs +2 -0
- package/dist/utils-DZB4ZTS4.cjs.map +1 -0
- package/dist/utils-H5O25MTI.cjs +2 -0
- package/dist/utils-H5O25MTI.cjs.map +1 -0
- package/dist/utils-SUIRQJIA.js +2 -0
- package/dist/{utils-72MDY3OH.js.map → utils-SUIRQJIA.js.map} +1 -1
- package/package.json +20 -12
- package/dist/evm-F7OJEDX3.js +0 -2
- package/dist/evm-F7OJEDX3.js.map +0 -1
- package/dist/providers/evm-5323YCLC.js +0 -2
- package/dist/providers/evm-5323YCLC.js.map +0 -1
- package/dist/providers/index.cjs +0 -6
- package/dist/providers/index.cjs.map +0 -1
- package/dist/providers/index.d.cts +0 -506
- package/dist/providers/index.d.ts +0 -506
- package/dist/providers/index.js +0 -6
- package/dist/providers/index.js.map +0 -1
- package/dist/providers/solana-WHT5KTOF.js.map +0 -1
- package/dist/providers/utils-FHHKXQ5Z.js +0 -2
- package/dist/providers/utils-FHHKXQ5Z.js.map +0 -1
- package/dist/providers/utils-L6CFHW4B.js +0 -2
- package/dist/providers/utils-L6CFHW4B.js.map +0 -1
- package/dist/solana-2MXIY6UT.js +0 -2
- package/dist/solana-EV65GS7Q.js +0 -2
- package/dist/solana-EV65GS7Q.js.map +0 -1
- package/dist/utils-72MDY3OH.js +0 -2
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { OrbitAdapter } from '@tuwaio/orbit-core';
|
|
3
|
+
import { N as NovaConnectLabels } from './types-D4Vti05g.js';
|
|
4
|
+
|
|
5
|
+
type ButtonTxStatus = 'idle' | 'loading' | 'succeed' | 'failed' | 'replaced';
|
|
6
|
+
type ConnectContentType = 'network' | 'connectors' | 'about' | 'getWallet' | 'connecting' | 'impersonate';
|
|
7
|
+
type ConnectedContentType = 'main' | 'transactions' | 'chains';
|
|
8
|
+
interface NovaConnectProviderProps {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
labels?: Partial<NovaConnectLabels>;
|
|
11
|
+
}
|
|
12
|
+
interface WalletBalance {
|
|
13
|
+
value: string;
|
|
14
|
+
symbol: string;
|
|
15
|
+
}
|
|
16
|
+
interface NovaConnectProviderType {
|
|
17
|
+
isConnectModalOpen: boolean;
|
|
18
|
+
setIsConnectModalOpen: (value: boolean) => void;
|
|
19
|
+
isConnectedModalOpen: boolean;
|
|
20
|
+
setIsConnectedModalOpen: (value: boolean) => void;
|
|
21
|
+
isChainsListOpen: boolean;
|
|
22
|
+
setIsChainsListOpen: (value: boolean) => void;
|
|
23
|
+
isChainsListOpenMobile: boolean;
|
|
24
|
+
setIsChainsListOpenMobile: (value: boolean) => void;
|
|
25
|
+
connectedButtonStatus: ButtonTxStatus;
|
|
26
|
+
setConnectedButtonStatus: (value: ButtonTxStatus) => void;
|
|
27
|
+
isConnected: boolean;
|
|
28
|
+
setIsConnected: (value: boolean) => void;
|
|
29
|
+
connectedModalContentType: ConnectedContentType;
|
|
30
|
+
setConnectedModalContentType: (value: ConnectedContentType) => void;
|
|
31
|
+
connectModalContentType: ConnectContentType;
|
|
32
|
+
setConnectModalContentType: (value: ConnectContentType) => void;
|
|
33
|
+
selectedAdapter: OrbitAdapter | undefined;
|
|
34
|
+
setSelectedAdapter: (value: OrbitAdapter | undefined) => void;
|
|
35
|
+
activeConnector: string | undefined;
|
|
36
|
+
setActiveConnector: (value: string | undefined) => void;
|
|
37
|
+
impersonatedAddress: string;
|
|
38
|
+
setImpersonatedAddress: (value: string) => void;
|
|
39
|
+
}
|
|
40
|
+
declare class NovaConnectProviderError extends Error {
|
|
41
|
+
constructor(message?: string);
|
|
42
|
+
}
|
|
43
|
+
declare const NovaConnectProviderContext: React$1.Context<NovaConnectProviderType | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Hook to access NovaConnect context
|
|
46
|
+
*
|
|
47
|
+
* @throws {NovaConnectProviderError} When used outside of NovaConnectProvider
|
|
48
|
+
* @returns {NovaConnectProviderType} The NovaConnect context value
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* function MyComponent() {
|
|
53
|
+
* const { isConnected, handleConnectButtonClick } = useNovaConnect();
|
|
54
|
+
*
|
|
55
|
+
* return (
|
|
56
|
+
* <button onClick={handleConnectButtonClick}>
|
|
57
|
+
* {isConnected ? 'Connected' : 'Connect Wallet'}
|
|
58
|
+
* </button>
|
|
59
|
+
* );
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
declare const useNovaConnect: () => NovaConnectProviderType;
|
|
64
|
+
/**
|
|
65
|
+
* Hook to check if NovaConnect context is available
|
|
66
|
+
*
|
|
67
|
+
* @returns {boolean} True if context is available, false otherwise
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* function ConditionalComponent() {
|
|
72
|
+
* const hasContext = useHasNovaConnectContext();
|
|
73
|
+
*
|
|
74
|
+
* if (!hasContext) {
|
|
75
|
+
* return <div>NovaConnect provider not found</div>;
|
|
76
|
+
* }
|
|
77
|
+
*
|
|
78
|
+
* return <ConnectedComponent />;
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare const useHasNovaConnectContext: () => boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Optional hook that returns null if provider is not available
|
|
85
|
+
*
|
|
86
|
+
* @returns {NovaConnectProviderType | null} Context value or null if not available
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* function OptionalComponent() {
|
|
91
|
+
* const context = useNovaConnectOptional();
|
|
92
|
+
*
|
|
93
|
+
* if (!context) {
|
|
94
|
+
* return <div>No wallet provider available</div>;
|
|
95
|
+
* }
|
|
96
|
+
*
|
|
97
|
+
* return <div>Connected: {context.isConnected}</div>;
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare const useNovaConnectOptional: () => NovaConnectProviderType | null;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* React Context for storing and providing the UI labels.
|
|
105
|
+
* It is initialized with the default English labels, ensuring that components
|
|
106
|
+
* work even without an explicit provider.
|
|
107
|
+
*/
|
|
108
|
+
declare const NovaConnectLabelsContext: React$1.Context<NovaConnectLabels>;
|
|
109
|
+
/**
|
|
110
|
+
* A custom hook to easily access the i18n labels from any component
|
|
111
|
+
* within the `NovaConnectLabelsProvider` tree.
|
|
112
|
+
*
|
|
113
|
+
* This hook provides type-safe access to all UI labels and automatically
|
|
114
|
+
* falls back to default English labels if no provider is found.
|
|
115
|
+
*
|
|
116
|
+
* @returns {NovaConnectLabels} The complete object of UI labels for the current locale.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* import { useNovaConnectLabels } from './hooks/useNovaConnectLabels';
|
|
121
|
+
*
|
|
122
|
+
* function MyComponent() {
|
|
123
|
+
* const labels = useNovaConnectLabels();
|
|
124
|
+
*
|
|
125
|
+
* return (
|
|
126
|
+
* <div>
|
|
127
|
+
* <h1>{labels.connectWallet}</h1>
|
|
128
|
+
* <button>{labels.connect}</button>
|
|
129
|
+
* <p aria-label={labels.walletBalance}>{formattedBalance}</p>
|
|
130
|
+
* </div>
|
|
131
|
+
* );
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* // Destructuring specific labels for better performance
|
|
138
|
+
* function ConnectButton() {
|
|
139
|
+
* const { connectWallet, connecting, connected } = useNovaConnectLabels();
|
|
140
|
+
*
|
|
141
|
+
* return (
|
|
142
|
+
* <button>
|
|
143
|
+
* {isConnecting ? connecting : isConnected ? connected : connectWallet}
|
|
144
|
+
* </button>
|
|
145
|
+
* );
|
|
146
|
+
* }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
declare const useNovaConnectLabels: () => NovaConnectLabels;
|
|
150
|
+
/**
|
|
151
|
+
* Hook to get a specific label by key path with type safety
|
|
152
|
+
*
|
|
153
|
+
* @param key The label key to retrieve
|
|
154
|
+
* @returns The specific label value
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* function MyComponent() {
|
|
159
|
+
* const connectLabel = useNovaConnectLabel('connectWallet');
|
|
160
|
+
* const errorLabel = useNovaConnectLabel('connectionError');
|
|
161
|
+
*
|
|
162
|
+
* return <button>{connectLabel}</button>;
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
declare const useNovaConnectLabel: <K extends keyof NovaConnectLabels>(key: K) => NovaConnectLabels[K];
|
|
167
|
+
/**
|
|
168
|
+
* Hook to get multiple specific labels for better performance
|
|
169
|
+
*
|
|
170
|
+
* @param keys Array of label keys to retrieve
|
|
171
|
+
* @returns Object with only the requested labels
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* function ConnectModal() {
|
|
176
|
+
* const { connectWallet, connecting, disconnect } = useNovaConnectLabelsSubset(['connectWallet', 'connecting', 'disconnect']);
|
|
177
|
+
*
|
|
178
|
+
* return (
|
|
179
|
+
* <div>
|
|
180
|
+
* <h2>{connectWallet}</h2>
|
|
181
|
+
* <span>{connecting}</span>
|
|
182
|
+
* <button>{disconnect}</button>
|
|
183
|
+
* </div>
|
|
184
|
+
* );
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare const useNovaConnectLabelsSubset: <K extends keyof NovaConnectLabels>(keys: K[]) => Pick<NovaConnectLabels, K>;
|
|
189
|
+
/**
|
|
190
|
+
* Type-safe helper to check if a label exists
|
|
191
|
+
*
|
|
192
|
+
* @param labels The labels object
|
|
193
|
+
* @param key The key to check
|
|
194
|
+
* @returns Whether the key exists and has a non-empty value
|
|
195
|
+
*/
|
|
196
|
+
declare const hasLabel: (labels: NovaConnectLabels, key: keyof NovaConnectLabels) => boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Utility type for extracting label keys by category
|
|
199
|
+
*/
|
|
200
|
+
type LabelCategory = {
|
|
201
|
+
actions: Extract<keyof NovaConnectLabels, 'connectWallet' | 'disconnect' | 'connecting' | 'connected' | 'tryAgain' | 'back' | 'connect' | 'close'>;
|
|
202
|
+
states: Extract<keyof NovaConnectLabels, 'success' | 'error' | 'replaced' | 'loading' | 'idle'>;
|
|
203
|
+
accessibility: Extract<keyof NovaConnectLabels, 'chainSelector' | 'closeModal' | 'selectChain' | 'walletControls' | 'openWalletModal'>;
|
|
204
|
+
transactions: Extract<keyof NovaConnectLabels, 'transactionLoading' | 'transactionSuccess' | 'transactionError' | 'transactionReplaced' | 'recent'>;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Hook to get labels by category for better organization
|
|
208
|
+
*
|
|
209
|
+
* @param category The category of labels to retrieve
|
|
210
|
+
* @returns Object with labels from the specified category
|
|
211
|
+
*/
|
|
212
|
+
declare const useLabelsByCategory: <T extends keyof LabelCategory>(category: T) => Pick<NovaConnectLabels, LabelCategory[T]>;
|
|
213
|
+
/**
|
|
214
|
+
* Utility function to check if labels are default ones (for external use)
|
|
215
|
+
* This is a regular function, not a hook, so it can be used anywhere
|
|
216
|
+
*
|
|
217
|
+
* @param labels The labels to check
|
|
218
|
+
* @returns Whether the labels are the default English labels
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* function SomeUtilityFunction(labels: NovaConnectLabels) {
|
|
223
|
+
* if (isDefaultLabels(labels)) {
|
|
224
|
+
* console.log('Using default English labels');
|
|
225
|
+
* }
|
|
226
|
+
* }
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
declare const isDefaultLabels: (labels: NovaConnectLabels) => boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Utility function to get a formatted label with fallback
|
|
232
|
+
*
|
|
233
|
+
* @param labels The labels object
|
|
234
|
+
* @param key The label key
|
|
235
|
+
* @param fallback Optional fallback text
|
|
236
|
+
* @returns The label value or fallback
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* const buttonText = getLabelWithFallback(labels, 'connectWallet', 'Connect');
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
declare const getLabelWithFallback: (labels: NovaConnectLabels, key: keyof NovaConnectLabels, fallback?: string) => string;
|
|
244
|
+
/**
|
|
245
|
+
* Utility function to create a labels subset (for use outside of React components)
|
|
246
|
+
*
|
|
247
|
+
* @param labels The source labels object
|
|
248
|
+
* @param keys Array of keys to extract
|
|
249
|
+
* @returns Object with only the requested labels
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* const actionLabels = createLabelsSubset(labels, ['connect', 'disconnect', 'tryAgain']);
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
declare const createLabelsSubset: <K extends keyof NovaConnectLabels>(labels: NovaConnectLabels, keys: K[]) => Pick<NovaConnectLabels, K>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @interface NativeBalanceResult
|
|
260
|
+
* Represents the native token balance returned by the adapter.
|
|
261
|
+
* The value is already formatted for human readability.
|
|
262
|
+
* @property {string} value The native token balance formatted to standard decimals (e.g., "1.5").
|
|
263
|
+
* @property {string} symbol The symbol of the native token (e.g., "ETH").
|
|
264
|
+
*/
|
|
265
|
+
interface NativeBalanceResult {
|
|
266
|
+
value: string;
|
|
267
|
+
symbol: string;
|
|
268
|
+
}
|
|
269
|
+
type NativeBalanceState = NativeBalanceResult | null;
|
|
270
|
+
/**
|
|
271
|
+
* @interface NativeBalanceData
|
|
272
|
+
* The object returned by the useWalletNativeBalance hook.
|
|
273
|
+
* @property {NativeBalanceState} balance The native token balance and symbol, or null.
|
|
274
|
+
* @property {boolean} isLoading True while the balance is being fetched for the current wallet/chain combination.
|
|
275
|
+
* @property {() => void} refetch Function to manually trigger a balance refresh.
|
|
276
|
+
*/
|
|
277
|
+
interface NativeBalanceData {
|
|
278
|
+
balance: NativeBalanceState;
|
|
279
|
+
isLoading: boolean;
|
|
280
|
+
refetch: () => void;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Custom hook to fetch the native token balance for the currently connected wallet
|
|
284
|
+
* on the active chain. It includes a local cache layer to prevent redundant network calls
|
|
285
|
+
* when switching between components or on re-renders for the same wallet/chain.
|
|
286
|
+
*
|
|
287
|
+
* @returns {NativeBalanceData} An object containing the balance data and loading state.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* import { useWalletNativeBalance } from './useWalletNativeBalance';
|
|
292
|
+
*
|
|
293
|
+
* function NativeTokenDisplay() {
|
|
294
|
+
* const { balance, isLoading, refetch } = useWalletNativeBalance();
|
|
295
|
+
*
|
|
296
|
+
* if (isLoading) {
|
|
297
|
+
* return <p>Loading balance...</p>;
|
|
298
|
+
* }
|
|
299
|
+
*
|
|
300
|
+
* // Display the formatted balance and symbol
|
|
301
|
+
* return (
|
|
302
|
+
* <div>
|
|
303
|
+
* <p>Balance: {balance ? `${balance.value} ${balance.symbol}` : '0.00'}</p>
|
|
304
|
+
* <button onClick={refetch}>Refresh</button>
|
|
305
|
+
* </div>
|
|
306
|
+
* );
|
|
307
|
+
* }
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
declare function useWalletNativeBalance(): NativeBalanceData;
|
|
311
|
+
|
|
312
|
+
export { type ButtonTxStatus as B, type ConnectContentType as C, type LabelCategory as L, type NovaConnectProviderType as N, type WalletBalance as W, type ConnectedContentType as a, type NovaConnectProviderProps as b, NovaConnectProviderError as c, NovaConnectProviderContext as d, useHasNovaConnectContext as e, useNovaConnectOptional as f, NovaConnectLabelsContext as g, useNovaConnectLabels as h, useNovaConnectLabel as i, useNovaConnectLabelsSubset as j, hasLabel as k, useLabelsByCategory as l, isDefaultLabels as m, getLabelWithFallback as n, createLabelsSubset as o, type NativeBalanceResult as p, useWalletNativeBalance as q, useNovaConnect as u };
|
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import { OrbitAdapter } from '@tuwaio/orbit-core';
|
|
3
|
+
import { N as NovaConnectLabels } from './types-D4Vti05g.cjs';
|
|
4
|
+
|
|
5
|
+
type ButtonTxStatus = 'idle' | 'loading' | 'succeed' | 'failed' | 'replaced';
|
|
6
|
+
type ConnectContentType = 'network' | 'connectors' | 'about' | 'getWallet' | 'connecting' | 'impersonate';
|
|
7
|
+
type ConnectedContentType = 'main' | 'transactions' | 'chains';
|
|
8
|
+
interface NovaConnectProviderProps {
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
labels?: Partial<NovaConnectLabels>;
|
|
11
|
+
}
|
|
12
|
+
interface WalletBalance {
|
|
13
|
+
value: string;
|
|
14
|
+
symbol: string;
|
|
15
|
+
}
|
|
16
|
+
interface NovaConnectProviderType {
|
|
17
|
+
isConnectModalOpen: boolean;
|
|
18
|
+
setIsConnectModalOpen: (value: boolean) => void;
|
|
19
|
+
isConnectedModalOpen: boolean;
|
|
20
|
+
setIsConnectedModalOpen: (value: boolean) => void;
|
|
21
|
+
isChainsListOpen: boolean;
|
|
22
|
+
setIsChainsListOpen: (value: boolean) => void;
|
|
23
|
+
isChainsListOpenMobile: boolean;
|
|
24
|
+
setIsChainsListOpenMobile: (value: boolean) => void;
|
|
25
|
+
connectedButtonStatus: ButtonTxStatus;
|
|
26
|
+
setConnectedButtonStatus: (value: ButtonTxStatus) => void;
|
|
27
|
+
isConnected: boolean;
|
|
28
|
+
setIsConnected: (value: boolean) => void;
|
|
29
|
+
connectedModalContentType: ConnectedContentType;
|
|
30
|
+
setConnectedModalContentType: (value: ConnectedContentType) => void;
|
|
31
|
+
connectModalContentType: ConnectContentType;
|
|
32
|
+
setConnectModalContentType: (value: ConnectContentType) => void;
|
|
33
|
+
selectedAdapter: OrbitAdapter | undefined;
|
|
34
|
+
setSelectedAdapter: (value: OrbitAdapter | undefined) => void;
|
|
35
|
+
activeConnector: string | undefined;
|
|
36
|
+
setActiveConnector: (value: string | undefined) => void;
|
|
37
|
+
impersonatedAddress: string;
|
|
38
|
+
setImpersonatedAddress: (value: string) => void;
|
|
39
|
+
}
|
|
40
|
+
declare class NovaConnectProviderError extends Error {
|
|
41
|
+
constructor(message?: string);
|
|
42
|
+
}
|
|
43
|
+
declare const NovaConnectProviderContext: React$1.Context<NovaConnectProviderType | undefined>;
|
|
44
|
+
/**
|
|
45
|
+
* Hook to access NovaConnect context
|
|
46
|
+
*
|
|
47
|
+
* @throws {NovaConnectProviderError} When used outside of NovaConnectProvider
|
|
48
|
+
* @returns {NovaConnectProviderType} The NovaConnect context value
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* function MyComponent() {
|
|
53
|
+
* const { isConnected, handleConnectButtonClick } = useNovaConnect();
|
|
54
|
+
*
|
|
55
|
+
* return (
|
|
56
|
+
* <button onClick={handleConnectButtonClick}>
|
|
57
|
+
* {isConnected ? 'Connected' : 'Connect Wallet'}
|
|
58
|
+
* </button>
|
|
59
|
+
* );
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
declare const useNovaConnect: () => NovaConnectProviderType;
|
|
64
|
+
/**
|
|
65
|
+
* Hook to check if NovaConnect context is available
|
|
66
|
+
*
|
|
67
|
+
* @returns {boolean} True if context is available, false otherwise
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* function ConditionalComponent() {
|
|
72
|
+
* const hasContext = useHasNovaConnectContext();
|
|
73
|
+
*
|
|
74
|
+
* if (!hasContext) {
|
|
75
|
+
* return <div>NovaConnect provider not found</div>;
|
|
76
|
+
* }
|
|
77
|
+
*
|
|
78
|
+
* return <ConnectedComponent />;
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare const useHasNovaConnectContext: () => boolean;
|
|
83
|
+
/**
|
|
84
|
+
* Optional hook that returns null if provider is not available
|
|
85
|
+
*
|
|
86
|
+
* @returns {NovaConnectProviderType | null} Context value or null if not available
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* function OptionalComponent() {
|
|
91
|
+
* const context = useNovaConnectOptional();
|
|
92
|
+
*
|
|
93
|
+
* if (!context) {
|
|
94
|
+
* return <div>No wallet provider available</div>;
|
|
95
|
+
* }
|
|
96
|
+
*
|
|
97
|
+
* return <div>Connected: {context.isConnected}</div>;
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
declare const useNovaConnectOptional: () => NovaConnectProviderType | null;
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* React Context for storing and providing the UI labels.
|
|
105
|
+
* It is initialized with the default English labels, ensuring that components
|
|
106
|
+
* work even without an explicit provider.
|
|
107
|
+
*/
|
|
108
|
+
declare const NovaConnectLabelsContext: React$1.Context<NovaConnectLabels>;
|
|
109
|
+
/**
|
|
110
|
+
* A custom hook to easily access the i18n labels from any component
|
|
111
|
+
* within the `NovaConnectLabelsProvider` tree.
|
|
112
|
+
*
|
|
113
|
+
* This hook provides type-safe access to all UI labels and automatically
|
|
114
|
+
* falls back to default English labels if no provider is found.
|
|
115
|
+
*
|
|
116
|
+
* @returns {NovaConnectLabels} The complete object of UI labels for the current locale.
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* import { useNovaConnectLabels } from './hooks/useNovaConnectLabels';
|
|
121
|
+
*
|
|
122
|
+
* function MyComponent() {
|
|
123
|
+
* const labels = useNovaConnectLabels();
|
|
124
|
+
*
|
|
125
|
+
* return (
|
|
126
|
+
* <div>
|
|
127
|
+
* <h1>{labels.connectWallet}</h1>
|
|
128
|
+
* <button>{labels.connect}</button>
|
|
129
|
+
* <p aria-label={labels.walletBalance}>{formattedBalance}</p>
|
|
130
|
+
* </div>
|
|
131
|
+
* );
|
|
132
|
+
* }
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @example
|
|
136
|
+
* ```typescript
|
|
137
|
+
* // Destructuring specific labels for better performance
|
|
138
|
+
* function ConnectButton() {
|
|
139
|
+
* const { connectWallet, connecting, connected } = useNovaConnectLabels();
|
|
140
|
+
*
|
|
141
|
+
* return (
|
|
142
|
+
* <button>
|
|
143
|
+
* {isConnecting ? connecting : isConnected ? connected : connectWallet}
|
|
144
|
+
* </button>
|
|
145
|
+
* );
|
|
146
|
+
* }
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
declare const useNovaConnectLabels: () => NovaConnectLabels;
|
|
150
|
+
/**
|
|
151
|
+
* Hook to get a specific label by key path with type safety
|
|
152
|
+
*
|
|
153
|
+
* @param key The label key to retrieve
|
|
154
|
+
* @returns The specific label value
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```typescript
|
|
158
|
+
* function MyComponent() {
|
|
159
|
+
* const connectLabel = useNovaConnectLabel('connectWallet');
|
|
160
|
+
* const errorLabel = useNovaConnectLabel('connectionError');
|
|
161
|
+
*
|
|
162
|
+
* return <button>{connectLabel}</button>;
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
declare const useNovaConnectLabel: <K extends keyof NovaConnectLabels>(key: K) => NovaConnectLabels[K];
|
|
167
|
+
/**
|
|
168
|
+
* Hook to get multiple specific labels for better performance
|
|
169
|
+
*
|
|
170
|
+
* @param keys Array of label keys to retrieve
|
|
171
|
+
* @returns Object with only the requested labels
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```typescript
|
|
175
|
+
* function ConnectModal() {
|
|
176
|
+
* const { connectWallet, connecting, disconnect } = useNovaConnectLabelsSubset(['connectWallet', 'connecting', 'disconnect']);
|
|
177
|
+
*
|
|
178
|
+
* return (
|
|
179
|
+
* <div>
|
|
180
|
+
* <h2>{connectWallet}</h2>
|
|
181
|
+
* <span>{connecting}</span>
|
|
182
|
+
* <button>{disconnect}</button>
|
|
183
|
+
* </div>
|
|
184
|
+
* );
|
|
185
|
+
* }
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare const useNovaConnectLabelsSubset: <K extends keyof NovaConnectLabels>(keys: K[]) => Pick<NovaConnectLabels, K>;
|
|
189
|
+
/**
|
|
190
|
+
* Type-safe helper to check if a label exists
|
|
191
|
+
*
|
|
192
|
+
* @param labels The labels object
|
|
193
|
+
* @param key The key to check
|
|
194
|
+
* @returns Whether the key exists and has a non-empty value
|
|
195
|
+
*/
|
|
196
|
+
declare const hasLabel: (labels: NovaConnectLabels, key: keyof NovaConnectLabels) => boolean;
|
|
197
|
+
/**
|
|
198
|
+
* Utility type for extracting label keys by category
|
|
199
|
+
*/
|
|
200
|
+
type LabelCategory = {
|
|
201
|
+
actions: Extract<keyof NovaConnectLabels, 'connectWallet' | 'disconnect' | 'connecting' | 'connected' | 'tryAgain' | 'back' | 'connect' | 'close'>;
|
|
202
|
+
states: Extract<keyof NovaConnectLabels, 'success' | 'error' | 'replaced' | 'loading' | 'idle'>;
|
|
203
|
+
accessibility: Extract<keyof NovaConnectLabels, 'chainSelector' | 'closeModal' | 'selectChain' | 'walletControls' | 'openWalletModal'>;
|
|
204
|
+
transactions: Extract<keyof NovaConnectLabels, 'transactionLoading' | 'transactionSuccess' | 'transactionError' | 'transactionReplaced' | 'recent'>;
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Hook to get labels by category for better organization
|
|
208
|
+
*
|
|
209
|
+
* @param category The category of labels to retrieve
|
|
210
|
+
* @returns Object with labels from the specified category
|
|
211
|
+
*/
|
|
212
|
+
declare const useLabelsByCategory: <T extends keyof LabelCategory>(category: T) => Pick<NovaConnectLabels, LabelCategory[T]>;
|
|
213
|
+
/**
|
|
214
|
+
* Utility function to check if labels are default ones (for external use)
|
|
215
|
+
* This is a regular function, not a hook, so it can be used anywhere
|
|
216
|
+
*
|
|
217
|
+
* @param labels The labels to check
|
|
218
|
+
* @returns Whether the labels are the default English labels
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* function SomeUtilityFunction(labels: NovaConnectLabels) {
|
|
223
|
+
* if (isDefaultLabels(labels)) {
|
|
224
|
+
* console.log('Using default English labels');
|
|
225
|
+
* }
|
|
226
|
+
* }
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
declare const isDefaultLabels: (labels: NovaConnectLabels) => boolean;
|
|
230
|
+
/**
|
|
231
|
+
* Utility function to get a formatted label with fallback
|
|
232
|
+
*
|
|
233
|
+
* @param labels The labels object
|
|
234
|
+
* @param key The label key
|
|
235
|
+
* @param fallback Optional fallback text
|
|
236
|
+
* @returns The label value or fallback
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
* ```typescript
|
|
240
|
+
* const buttonText = getLabelWithFallback(labels, 'connectWallet', 'Connect');
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
declare const getLabelWithFallback: (labels: NovaConnectLabels, key: keyof NovaConnectLabels, fallback?: string) => string;
|
|
244
|
+
/**
|
|
245
|
+
* Utility function to create a labels subset (for use outside of React components)
|
|
246
|
+
*
|
|
247
|
+
* @param labels The source labels object
|
|
248
|
+
* @param keys Array of keys to extract
|
|
249
|
+
* @returns Object with only the requested labels
|
|
250
|
+
*
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* const actionLabels = createLabelsSubset(labels, ['connect', 'disconnect', 'tryAgain']);
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
declare const createLabelsSubset: <K extends keyof NovaConnectLabels>(labels: NovaConnectLabels, keys: K[]) => Pick<NovaConnectLabels, K>;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @interface NativeBalanceResult
|
|
260
|
+
* Represents the native token balance returned by the adapter.
|
|
261
|
+
* The value is already formatted for human readability.
|
|
262
|
+
* @property {string} value The native token balance formatted to standard decimals (e.g., "1.5").
|
|
263
|
+
* @property {string} symbol The symbol of the native token (e.g., "ETH").
|
|
264
|
+
*/
|
|
265
|
+
interface NativeBalanceResult {
|
|
266
|
+
value: string;
|
|
267
|
+
symbol: string;
|
|
268
|
+
}
|
|
269
|
+
type NativeBalanceState = NativeBalanceResult | null;
|
|
270
|
+
/**
|
|
271
|
+
* @interface NativeBalanceData
|
|
272
|
+
* The object returned by the useWalletNativeBalance hook.
|
|
273
|
+
* @property {NativeBalanceState} balance The native token balance and symbol, or null.
|
|
274
|
+
* @property {boolean} isLoading True while the balance is being fetched for the current wallet/chain combination.
|
|
275
|
+
* @property {() => void} refetch Function to manually trigger a balance refresh.
|
|
276
|
+
*/
|
|
277
|
+
interface NativeBalanceData {
|
|
278
|
+
balance: NativeBalanceState;
|
|
279
|
+
isLoading: boolean;
|
|
280
|
+
refetch: () => void;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* Custom hook to fetch the native token balance for the currently connected wallet
|
|
284
|
+
* on the active chain. It includes a local cache layer to prevent redundant network calls
|
|
285
|
+
* when switching between components or on re-renders for the same wallet/chain.
|
|
286
|
+
*
|
|
287
|
+
* @returns {NativeBalanceData} An object containing the balance data and loading state.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* import { useWalletNativeBalance } from './useWalletNativeBalance';
|
|
292
|
+
*
|
|
293
|
+
* function NativeTokenDisplay() {
|
|
294
|
+
* const { balance, isLoading, refetch } = useWalletNativeBalance();
|
|
295
|
+
*
|
|
296
|
+
* if (isLoading) {
|
|
297
|
+
* return <p>Loading balance...</p>;
|
|
298
|
+
* }
|
|
299
|
+
*
|
|
300
|
+
* // Display the formatted balance and symbol
|
|
301
|
+
* return (
|
|
302
|
+
* <div>
|
|
303
|
+
* <p>Balance: {balance ? `${balance.value} ${balance.symbol}` : '0.00'}</p>
|
|
304
|
+
* <button onClick={refetch}>Refresh</button>
|
|
305
|
+
* </div>
|
|
306
|
+
* );
|
|
307
|
+
* }
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
declare function useWalletNativeBalance(): NativeBalanceData;
|
|
311
|
+
|
|
312
|
+
export { type ButtonTxStatus as B, type ConnectContentType as C, type LabelCategory as L, type NovaConnectProviderType as N, type WalletBalance as W, type ConnectedContentType as a, type NovaConnectProviderProps as b, NovaConnectProviderError as c, NovaConnectProviderContext as d, useHasNovaConnectContext as e, useNovaConnectOptional as f, NovaConnectLabelsContext as g, useNovaConnectLabels as h, useNovaConnectLabel as i, useNovaConnectLabelsSubset as j, hasLabel as k, useLabelsByCategory as l, isDefaultLabels as m, getLabelWithFallback as n, createLabelsSubset as o, type NativeBalanceResult as p, useWalletNativeBalance as q, useNovaConnect as u };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkCEGEQMI2_cjs=require('./chunk-CEGEQMI2.cjs');Object.defineProperty(exports,"getEvmChains",{enumerable:true,get:function(){return chunkCEGEQMI2_cjs.a}});Object.defineProperty(exports,"isEvmChainList",{enumerable:true,get:function(){return chunkCEGEQMI2_cjs.b}});//# sourceMappingURL=utils-DZB4ZTS4.cjs.map
|
|
2
|
+
//# sourceMappingURL=utils-DZB4ZTS4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils-DZB4ZTS4.cjs"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var chunkDYDY3FCT_cjs=require('./chunk-DYDY3FCT.cjs');Object.defineProperty(exports,"getAvailableSolanaClusters",{enumerable:true,get:function(){return chunkDYDY3FCT_cjs.c}});Object.defineProperty(exports,"getSolanaClusters",{enumerable:true,get:function(){return chunkDYDY3FCT_cjs.a}});Object.defineProperty(exports,"isSolanaChainList",{enumerable:true,get:function(){return chunkDYDY3FCT_cjs.b}});Object.defineProperty(exports,"isValidSolanaCluster",{enumerable:true,get:function(){return chunkDYDY3FCT_cjs.d}});//# sourceMappingURL=utils-H5O25MTI.cjs.map
|
|
2
|
+
//# sourceMappingURL=utils-H5O25MTI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils-H5O25MTI.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"utils-SUIRQJIA.js"}
|