@tuwaio/nova-connect 0.1.1 → 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.
Files changed (62) hide show
  1. package/dist/ToastError-CSlbvXKT.d.cts +106 -0
  2. package/dist/ToastError-CSlbvXKT.d.ts +106 -0
  3. package/dist/chunk-A2677K5M.cjs +2 -0
  4. package/dist/chunk-A2677K5M.cjs.map +1 -0
  5. package/dist/chunk-LF6FTUUQ.js +2 -0
  6. package/dist/chunk-LF6FTUUQ.js.map +1 -0
  7. package/dist/chunk-MPEJHQKC.js +2 -0
  8. package/dist/chunk-MPEJHQKC.js.map +1 -0
  9. package/dist/{chunk-FNWARYJY.js → chunk-MQGDTFY7.js} +2 -2
  10. package/dist/{chunk-FNWARYJY.js.map → chunk-MQGDTFY7.js.map} +1 -1
  11. package/dist/{chunk-6S5OTERL.cjs → chunk-NMQZA377.cjs} +2 -2
  12. package/dist/{chunk-6S5OTERL.cjs.map → chunk-NMQZA377.cjs.map} +1 -1
  13. package/dist/chunk-OA6MB7CZ.cjs +2 -0
  14. package/dist/chunk-OA6MB7CZ.cjs.map +1 -0
  15. package/dist/chunk-QERPNHKX.cjs +2 -0
  16. package/dist/chunk-QERPNHKX.cjs.map +1 -0
  17. package/dist/chunk-RUYOUU6Q.cjs +6 -0
  18. package/dist/chunk-RUYOUU6Q.cjs.map +1 -0
  19. package/dist/chunk-TAV7EL23.js +2 -0
  20. package/dist/chunk-TAV7EL23.js.map +1 -0
  21. package/dist/chunk-Z2NDRIEI.js +6 -0
  22. package/dist/chunk-Z2NDRIEI.js.map +1 -0
  23. package/dist/components/index.cjs +2 -0
  24. package/dist/components/index.cjs.map +1 -0
  25. package/dist/components/index.d.cts +6430 -0
  26. package/dist/components/index.d.ts +6430 -0
  27. package/dist/components/index.js +2 -0
  28. package/dist/components/index.js.map +1 -0
  29. package/dist/getChainsListByWalletType-CDPECVNS.cjs +2 -0
  30. package/dist/{getChainsListByWalletType-ZU7OPWTP.cjs.map → getChainsListByWalletType-CDPECVNS.cjs.map} +1 -1
  31. package/dist/{getChainsListByWalletType-EO6A7Q5A.js → getChainsListByWalletType-VMQ4BO2B.js} +2 -2
  32. package/dist/{getChainsListByWalletType-EO6A7Q5A.js.map → getChainsListByWalletType-VMQ4BO2B.js.map} +1 -1
  33. package/dist/hooks/index.cjs +2 -0
  34. package/dist/hooks/index.cjs.map +1 -0
  35. package/dist/hooks/index.d.cts +70 -0
  36. package/dist/hooks/index.d.ts +70 -0
  37. package/dist/hooks/index.js +2 -0
  38. package/dist/hooks/index.js.map +1 -0
  39. package/dist/i18n/index.cjs +2 -0
  40. package/dist/i18n/index.cjs.map +1 -0
  41. package/dist/i18n/index.d.cts +15 -0
  42. package/dist/i18n/index.d.ts +15 -0
  43. package/dist/i18n/index.js +2 -0
  44. package/dist/i18n/index.js.map +1 -0
  45. package/dist/index.cjs +1 -5
  46. package/dist/index.cjs.map +1 -1
  47. package/dist/index.d.cts +13 -7009
  48. package/dist/index.d.ts +13 -7009
  49. package/dist/index.js +1 -5
  50. package/dist/index.js.map +1 -1
  51. package/dist/satellite/index.cjs +2 -0
  52. package/dist/satellite/index.cjs.map +1 -0
  53. package/dist/satellite/index.d.cts +1 -0
  54. package/dist/satellite/index.d.ts +1 -0
  55. package/dist/satellite/index.js +2 -0
  56. package/dist/satellite/index.js.map +1 -0
  57. package/dist/types-D4Vti05g.d.cts +98 -0
  58. package/dist/types-D4Vti05g.d.ts +98 -0
  59. package/dist/useWalletNativeBalance-6RVzdGvM.d.ts +312 -0
  60. package/dist/useWalletNativeBalance-D8Ehciju.d.cts +312 -0
  61. package/package.json +21 -1
  62. package/dist/getChainsListByWalletType-ZU7OPWTP.cjs +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.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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuwaio/nova-connect",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "private": false,
5
5
  "author": "Oleksandr Tkach",
6
6
  "license": "Apache-2.0",
@@ -15,6 +15,26 @@
15
15
  "import": "./dist/index.cjs",
16
16
  "default": "./dist/index.js"
17
17
  },
18
+ "./components": {
19
+ "types": "./dist/components/index.d.ts",
20
+ "import": "./dist/components/index.cjs",
21
+ "default": "./dist/components/index.js"
22
+ },
23
+ "./hooks": {
24
+ "types": "./dist/hooks/index.d.ts",
25
+ "import": "./dist/hooks/index.cjs",
26
+ "default": "./dist/hooks/index.js"
27
+ },
28
+ "./i18n": {
29
+ "types": "./dist/i18n/index.d.ts",
30
+ "import": "./dist/i18n/index.cjs",
31
+ "default": "./dist/i18n/index.js"
32
+ },
33
+ "./satellite": {
34
+ "types": "./dist/satellite/index.d.ts",
35
+ "import": "./dist/satellite/index.cjs",
36
+ "default": "./dist/satellite/index.js"
37
+ },
18
38
  "./evm": {
19
39
  "types": "./dist/evm/index.d.ts",
20
40
  "import": "./dist/evm/index.cjs",
@@ -1,2 +0,0 @@
1
- 'use strict';var chunk6S5OTERL_cjs=require('./chunk-6S5OTERL.cjs');Object.defineProperty(exports,"getAdapterStatus",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.k}});Object.defineProperty(exports,"getAllAdaptersStatus",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.l}});Object.defineProperty(exports,"getAvailableSolanaClusters",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.g}});Object.defineProperty(exports,"getChainsListByWalletType",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.a}});Object.defineProperty(exports,"getChainsListByWalletTypeSync",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.b}});Object.defineProperty(exports,"getWalletChains",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.i}});Object.defineProperty(exports,"isEvmChainList",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.c}});Object.defineProperty(exports,"isEvmChainListSync",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.e}});Object.defineProperty(exports,"isSolanaChainList",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.d}});Object.defineProperty(exports,"isSolanaChainListSync",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.f}});Object.defineProperty(exports,"isValidSolanaCluster",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.h}});Object.defineProperty(exports,"preloadChainAdapters",{enumerable:true,get:function(){return chunk6S5OTERL_cjs.j}});//# sourceMappingURL=getChainsListByWalletType-ZU7OPWTP.cjs.map
2
- //# sourceMappingURL=getChainsListByWalletType-ZU7OPWTP.cjs.map