@tuwaio/nova-connect 0.6.0 → 0.7.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 +93 -155
- package/dist/chunk-3LWAAUG4.js +1 -0
- package/dist/chunk-6EDQ7JRZ.js +1 -0
- package/dist/chunk-AGE6EFTV.js +1 -0
- package/dist/chunk-ENXSDTRV.js +2 -0
- package/dist/chunk-Q4FCNEIJ.cjs +2 -0
- package/dist/chunk-R5V3K52O.cjs +1 -0
- package/dist/chunk-YJRNNNR6.cjs +1 -0
- package/dist/chunk-ZVUCC2QP.cjs +1 -0
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.d.cts +5140 -2914
- package/dist/components/index.d.ts +5140 -2914
- package/dist/components/index.js +1 -1
- package/dist/evm/index.cjs +1 -1
- package/dist/evm/index.d.cts +15 -9
- package/dist/evm/index.d.ts +15 -9
- package/dist/evm/index.js +1 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.d.cts +76 -51
- package/dist/hooks/index.d.ts +76 -51
- package/dist/hooks/index.js +1 -1
- package/dist/i18n/index.cjs +1 -1
- package/dist/i18n/index.d.cts +1 -1
- package/dist/i18n/index.d.ts +1 -1
- package/dist/i18n/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +0 -22
- package/dist/index.d.cts +271 -879
- package/dist/index.d.ts +271 -879
- package/dist/index.js +1 -1
- package/dist/satellite/index.cjs +1 -1
- package/dist/satellite/index.d.cts +1 -1
- package/dist/satellite/index.d.ts +1 -1
- package/dist/satellite/index.js +1 -1
- package/dist/solana/index.cjs +1 -1
- package/dist/solana/index.d.cts +16 -9
- package/dist/solana/index.d.ts +16 -9
- package/dist/solana/index.js +1 -1
- package/dist/types-CnOiSyvZ.d.cts +400 -0
- package/dist/types-CnOiSyvZ.d.ts +400 -0
- package/dist/useWalletNativeBalance-CPK-PoXG.d.ts +918 -0
- package/dist/useWalletNativeBalance-DMPPRldX.d.cts +918 -0
- package/package.json +28 -68
- package/dist/chunk-5MOVHUHI.js +0 -2
- package/dist/chunk-7K4ENNWO.cjs +0 -2
- package/dist/chunk-7TYZT7ZD.cjs +0 -1
- package/dist/chunk-ARBYH7CW.js +0 -1
- package/dist/chunk-K44IHM6B.cjs +0 -1
- package/dist/chunk-MGBN4EIT.cjs +0 -1
- package/dist/chunk-NQ5AECZQ.js +0 -1
- package/dist/chunk-S3IRVZMG.js +0 -1
- package/dist/evm-DUQXCW22.js +0 -1
- package/dist/evm-KSA7PJIK.cjs +0 -1
- package/dist/getChainsListByConnectorType-QCNOPM6I.cjs +0 -1
- package/dist/getChainsListByConnectorType-YZZUYC6D.js +0 -1
- package/dist/solana-CVUSQUPL.cjs +0 -1
- package/dist/solana-GDE2KIT6.js +0 -1
- package/dist/types-DxUn8qmU.d.cts +0 -108
- package/dist/types-DxUn8qmU.d.ts +0 -108
- package/dist/useWalletNativeBalance-BuiJip3d.d.cts +0 -743
- package/dist/useWalletNativeBalance-DrgdoQa-.d.ts +0 -743
- /package/dist/{chunk-V6XDFRWV.cjs → chunk-EGATOYHY.cjs} +0 -0
- /package/dist/{chunk-EYP534IS.js → chunk-ZVADGOGQ.js} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { A as AllChainConfigs, L as LabelCategory, c as LegalConfig, d as NativeBalanceResult, e as NovaConnectLabelsContext, f as NovaConnectProviderContext, g as NovaConnectProviderError, h as NovaSiwxWatcher, i as NovaSiwxWatcherProps, W as WalletBalance, j as createLabelsSubset, k as getLabelWithFallback, l as hasLabel, m as isDefaultLabels, u as useHasNovaConnectContext, n as useLabelsByCategory, o as useNovaConnect, p as useNovaConnectLabel, q as useNovaConnectLabels, r as useNovaConnectLabelsSubset, s as useNovaConnectOptional, t as useWalletNativeBalance } from './useWalletNativeBalance-BuiJip3d.cjs';
|
|
1
|
+
export { UseGetWalletNameAndAvatarOptions, UseNovaSiwxOptions, UseWalletChainsListProps, WalletNameAndAvatarData, useGetWalletNameAndAvatar, useNovaSiwx, useWalletChainsList } from './hooks/index.cjs';
|
|
2
|
+
import { N as NovaConnectProviderProps, C as ConnectContentType, a as ConnectedContentType, B as ButtonTxStatus, b as NovaConnectProviderType, I as InitialChains } from './useWalletNativeBalance-DMPPRldX.cjs';
|
|
3
|
+
export { A as AllChainConfigs, L as LabelCategory, c as LegalConfig, d as NativeBalanceResult, e as NovaConnectAppChains, f as NovaConnectChainConfigTypes, g as NovaConnectLabelsContext, h as NovaConnectProviderContext, i as NovaConnectProviderError, j as NovaConnectSolanaRPCUrls, k as NovaSiwxWatcher, l as NovaSiwxWatcherProps, U as UseWalletNativeBalanceData, m as UseWalletNativeBalanceState, W as WalletBalance, n as createLabelsSubset, o as getLabelWithFallback, p as hasLabel, q as isDefaultLabels, u as useHasNovaConnectContext, r as useLabelsByCategory, s as useNovaConnect, t as useNovaConnectLabel, v as useNovaConnectLabels, w as useNovaConnectLabelsSubset, x as useNovaConnectOptional, y as useWalletNativeBalance } from './useWalletNativeBalance-DMPPRldX.cjs';
|
|
5
4
|
import * as React from 'react';
|
|
6
5
|
import { ComponentPropsWithoutRef, ComponentType, ReactNode } from 'react';
|
|
7
6
|
import { ToastCloseButtonProps } from '@tuwaio/nova-core';
|
|
7
|
+
import { TuwaErrorState, ConnectorType, ChainIdentifierArray, OrbitAdapter } from '@tuwaio/orbit-core';
|
|
8
8
|
import { ToastPosition, ToastContainer, toast } from 'react-toastify';
|
|
9
9
|
import { ToastErrorCustomization, ConnectModalCustomization, ConnectedModalCustomization } from './components/index.cjs';
|
|
10
|
-
import { N as NovaConnectLabels } from './types-
|
|
10
|
+
import { N as NovaConnectLabels } from './types-CnOiSyvZ.cjs';
|
|
11
11
|
import { BaseConnector } from '@tuwaio/satellite-core';
|
|
12
12
|
import { Connector } from '@tuwaio/satellite-react';
|
|
13
13
|
import '@tuwaio/siwx-react';
|
|
@@ -15,14 +15,25 @@ import '@tuwaio/pulsar-core';
|
|
|
15
15
|
import 'framer-motion';
|
|
16
16
|
import '@radix-ui/react-select';
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
/** Props of the toast content of {@link ErrorsProvider} (`customization.components.ToastError`). */
|
|
19
|
+
type ErrorsProviderToastErrorProps = {
|
|
20
|
+
/** The toast title (from `errorTitle`, by default the label of the error type). */
|
|
19
21
|
title: string;
|
|
22
|
+
/** The error: `connectionError` or `switchNetworkError` of the Satellite Connect store. */
|
|
20
23
|
rawError: string | TuwaErrorState;
|
|
24
|
+
/**
|
|
25
|
+
* Called after the error was copied (or not).
|
|
26
|
+
*
|
|
27
|
+
* @param success - Whether the error was copied.
|
|
28
|
+
*/
|
|
21
29
|
onCopyComplete?: (success: boolean) => void;
|
|
30
|
+
/** `'wallet'` for `connectionError`, `'switch'` for `switchNetworkError`. */
|
|
22
31
|
errorType: 'wallet' | 'switch' | null;
|
|
32
|
+
/** Whether a wallet is connected. */
|
|
23
33
|
isConnected: boolean;
|
|
24
34
|
};
|
|
25
|
-
|
|
35
|
+
/** Props of the toast container of {@link ErrorsProvider}: the props of `ToastContainer` from `react-toastify`. */
|
|
36
|
+
type ErrorsProviderContainerProps = ComponentPropsWithoutRef<typeof ToastContainer>;
|
|
26
37
|
/**
|
|
27
38
|
* Customization options for ErrorsProvider component
|
|
28
39
|
*/
|
|
@@ -32,9 +43,9 @@ type ErrorsProviderCustomization = {
|
|
|
32
43
|
/** Custom components */
|
|
33
44
|
components?: {
|
|
34
45
|
/** Custom ToastError component */
|
|
35
|
-
ToastError?: ComponentType<
|
|
46
|
+
ToastError?: ComponentType<ErrorsProviderToastErrorProps>;
|
|
36
47
|
/** Custom ToastContainer component */
|
|
37
|
-
Container?: ComponentType<
|
|
48
|
+
Container?: ComponentType<ErrorsProviderContainerProps>;
|
|
38
49
|
};
|
|
39
50
|
/** Default ToastError customization (only used with default ToastError component) */
|
|
40
51
|
toastErrorCustomization?: ToastErrorCustomization;
|
|
@@ -42,7 +53,14 @@ type ErrorsProviderCustomization = {
|
|
|
42
53
|
toastCloseButton?: Omit<ToastCloseButtonProps, 'closeToast'>;
|
|
43
54
|
/** Custom class name generators */
|
|
44
55
|
classNames?: {
|
|
45
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* Returns the classes of the toasts, instead of the default ones.
|
|
58
|
+
*
|
|
59
|
+
* @param params - The error state.
|
|
60
|
+
* @param params.hasErrors - Whether the store has a connection or network switch error.
|
|
61
|
+
* @param params.errorType - `'wallet'`, `'switch'`, or `null` without error.
|
|
62
|
+
* @returns The classes.
|
|
63
|
+
*/
|
|
46
64
|
container?: (params: {
|
|
47
65
|
hasErrors: boolean;
|
|
48
66
|
errorType: 'wallet' | 'switch' | null;
|
|
@@ -50,7 +68,17 @@ type ErrorsProviderCustomization = {
|
|
|
50
68
|
};
|
|
51
69
|
/** Custom toast options generators */
|
|
52
70
|
toastOptions?: {
|
|
53
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Returns options of `toast.error` of `react-toastify`, merged over the default ones (`containerId`, `toastId`,
|
|
73
|
+
* `onClose`).
|
|
74
|
+
*
|
|
75
|
+
* @param params - The error to show.
|
|
76
|
+
* @param params.title - The toast title.
|
|
77
|
+
* @param params.rawError - The error.
|
|
78
|
+
* @param params.errorType - `'wallet'` or `'switch'`.
|
|
79
|
+
* @param params.isConnected - Whether a wallet is connected.
|
|
80
|
+
* @returns The toast options.
|
|
81
|
+
*/
|
|
54
82
|
error?: (params: {
|
|
55
83
|
title: string;
|
|
56
84
|
rawError: string | TuwaErrorState;
|
|
@@ -60,28 +88,65 @@ type ErrorsProviderCustomization = {
|
|
|
60
88
|
};
|
|
61
89
|
/** Custom logic handlers */
|
|
62
90
|
handlers?: {
|
|
63
|
-
/**
|
|
91
|
+
/**
|
|
92
|
+
* Wraps the display of an error toast: call `originalHandler(title, rawError, errorKey)` to show it.
|
|
93
|
+
*
|
|
94
|
+
* @param originalHandler - Shows the toast (once per `errorKey`), after dismissing the previous one.
|
|
95
|
+
* @param params - The error to show.
|
|
96
|
+
* @param params.title - The toast title.
|
|
97
|
+
* @param params.rawError - The error.
|
|
98
|
+
* @param params.errorKey - Key of the error (from `errorHash`), used to show it only once.
|
|
99
|
+
* @param params.errorType - `'wallet'` or `'switch'`.
|
|
100
|
+
*/
|
|
64
101
|
showError?: (originalHandler: (title: string, rawError: string | TuwaErrorState, errorKey: string) => void, params: {
|
|
65
102
|
title: string;
|
|
66
103
|
rawError: string | TuwaErrorState;
|
|
67
104
|
errorKey: string;
|
|
68
105
|
errorType: 'wallet' | 'switch' | null;
|
|
69
106
|
}) => void;
|
|
70
|
-
/**
|
|
107
|
+
/**
|
|
108
|
+
* Wraps the dismissal of the error toasts: call `originalHandler()` to dismiss them.
|
|
109
|
+
*
|
|
110
|
+
* @param originalHandler - Dismisses the toasts of the container.
|
|
111
|
+
*/
|
|
71
112
|
dismissError?: (originalHandler: () => void) => void;
|
|
72
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Called after the copy button of a toast tried to copy the error. By default, logs the copied message in
|
|
115
|
+
* development.
|
|
116
|
+
*
|
|
117
|
+
* @param success - Whether the error was copied.
|
|
118
|
+
* @param rawError - The error.
|
|
119
|
+
* @param errorType - `'wallet'` or `'switch'`.
|
|
120
|
+
*/
|
|
73
121
|
onCopyComplete?: (success: boolean, rawError: string | TuwaErrorState, errorType: 'wallet' | 'switch' | null) => void;
|
|
74
122
|
};
|
|
75
|
-
/**
|
|
123
|
+
/**
|
|
124
|
+
* Returns the toast title. It does not change the labels, only the title of this toast.
|
|
125
|
+
*
|
|
126
|
+
* @param defaultTitle - The label of the error type (`connectionError`, `errorWhenChainSwitching` or
|
|
127
|
+
* `somethingWentWrong`).
|
|
128
|
+
* @param params - The error.
|
|
129
|
+
* @param params.errorType - `'wallet'`, `'switch'`, or `null`.
|
|
130
|
+
* @returns The title.
|
|
131
|
+
*/
|
|
76
132
|
errorTitle?: (defaultTitle: string, params: {
|
|
77
133
|
errorType: 'wallet' | 'switch' | null;
|
|
78
134
|
}) => string;
|
|
79
|
-
/**
|
|
135
|
+
/**
|
|
136
|
+
* Returns the key used to show an error only once.
|
|
137
|
+
*
|
|
138
|
+
* @param defaultHash - The error type and the first 50 characters of the message, or `null` without error.
|
|
139
|
+
* @param params - The error.
|
|
140
|
+
* @param params.primaryError - The error of the store (`connectionError` first).
|
|
141
|
+
* @param params.errorType - `'wallet'`, `'switch'`, or `null`.
|
|
142
|
+
* @returns The key, or `null` to show nothing.
|
|
143
|
+
*/
|
|
80
144
|
errorHash?: (defaultHash: string | null, params: {
|
|
81
145
|
primaryError: TuwaErrorState | null;
|
|
82
146
|
errorType: 'wallet' | 'switch' | null;
|
|
83
147
|
}) => string | null;
|
|
84
148
|
};
|
|
149
|
+
/** Props of {@link ErrorsProvider}. */
|
|
85
150
|
interface ErrorsProviderProps {
|
|
86
151
|
/** Custom container ID for toast notifications */
|
|
87
152
|
containerId?: string;
|
|
@@ -95,39 +160,46 @@ interface ErrorsProviderProps {
|
|
|
95
160
|
customization?: ErrorsProviderCustomization;
|
|
96
161
|
}
|
|
97
162
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
163
|
+
* Shows the connection and network switch errors of the Satellite Connect store (`connectionError`,
|
|
164
|
+
* `switchNetworkError`) as `react-toastify` toasts ({@link ToastError}) in its own `ToastContainer` (id
|
|
165
|
+
* `nova-connect-errors`, top center, closed after 7 seconds by default). Each error is shown once; the toasts are
|
|
166
|
+
* dismissed when a wallet connects without error. `NovaConnectProvider` renders it.
|
|
167
|
+
*
|
|
168
|
+
* @param props - See {@link ErrorsProviderProps}.
|
|
169
|
+
* @returns The toast container.
|
|
100
170
|
*/
|
|
101
171
|
declare function ErrorsProvider({ containerId, position, autoClose, draggable, customization, }: ErrorsProviderProps): React.JSX.Element;
|
|
102
172
|
declare namespace ErrorsProvider {
|
|
103
173
|
var displayName: string;
|
|
104
174
|
}
|
|
105
175
|
|
|
176
|
+
/**
|
|
177
|
+
* Props for the {@link NovaConnectLabelsProvider} component.
|
|
178
|
+
*/
|
|
106
179
|
interface NovaConnectLabelsProviderProps {
|
|
107
|
-
/**
|
|
180
|
+
/** All labels (spread `defaultLabels` of `@tuwaio/nova-connect/i18n` to change only some) */
|
|
108
181
|
labels: NovaConnectLabels;
|
|
109
182
|
/** The child components to render */
|
|
110
183
|
children: ReactNode;
|
|
111
184
|
}
|
|
112
185
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
186
|
+
* Provides labels to the Nova Connect components below it. `NovaConnectProvider` already renders it with the `labels`
|
|
187
|
+
* prop merged into the defaults, so use it directly only to give a part of the tree other texts. In development it
|
|
188
|
+
* warns about missing basic labels.
|
|
115
189
|
*
|
|
116
|
-
*
|
|
190
|
+
* @param props - See {@link NovaConnectLabelsProviderProps}.
|
|
191
|
+
* @returns The labels context provider.
|
|
117
192
|
*
|
|
118
193
|
* @example
|
|
119
|
-
* ```
|
|
120
|
-
* import { NovaConnectLabelsProvider } from '
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
* const customLabels = {
|
|
124
|
-
* connectWallet: 'Подключить кошелек',
|
|
125
|
-
* disconnect: 'Отключиться',
|
|
126
|
-
* };
|
|
194
|
+
* ```tsx
|
|
195
|
+
* import { NovaConnectLabelsProvider } from '@tuwaio/nova-connect';
|
|
196
|
+
* import { defaultLabels } from '@tuwaio/nova-connect/i18n';
|
|
197
|
+
* import type { ReactNode } from 'react';
|
|
127
198
|
*
|
|
199
|
+
* export function CustomTexts({ children }: { children: ReactNode }) {
|
|
128
200
|
* return (
|
|
129
|
-
* <NovaConnectLabelsProvider labels={
|
|
130
|
-
*
|
|
201
|
+
* <NovaConnectLabelsProvider labels={{ ...defaultLabels, connectWallet: 'Link wallet' }}>
|
|
202
|
+
* {children}
|
|
131
203
|
* </NovaConnectLabelsProvider>
|
|
132
204
|
* );
|
|
133
205
|
* }
|
|
@@ -139,22 +211,25 @@ declare namespace NovaConnectLabelsProvider {
|
|
|
139
211
|
}
|
|
140
212
|
|
|
141
213
|
/**
|
|
142
|
-
* Props for custom NovaConnectLabelsProvider
|
|
214
|
+
* Props for a custom labels provider (the default one is `NovaConnectLabelsProvider`).
|
|
143
215
|
*/
|
|
144
|
-
type
|
|
216
|
+
type NovaConnectProviderLabelsProviderProps = {
|
|
217
|
+
/** The final labels (after `labels.merge` and `labels.transform`) */
|
|
145
218
|
labels?: Partial<NovaConnectLabels>;
|
|
219
|
+
/** The app */
|
|
146
220
|
children: ReactNode;
|
|
147
221
|
};
|
|
148
222
|
/**
|
|
149
|
-
* Props for custom ErrorsProvider
|
|
223
|
+
* Props for a custom errors provider (the default one is `ErrorsProvider`).
|
|
150
224
|
*/
|
|
151
|
-
type
|
|
225
|
+
type NovaConnectProviderErrorsProviderProps = {
|
|
226
|
+
/** `customization.errors` */
|
|
152
227
|
customization?: ErrorsProviderCustomization;
|
|
153
228
|
};
|
|
154
229
|
/**
|
|
155
230
|
* Context data passed to custom provider components
|
|
156
231
|
*/
|
|
157
|
-
type
|
|
232
|
+
type NovaConnectProviderCustomizationContext = {
|
|
158
233
|
/** Current wallet connection state */
|
|
159
234
|
isConnected: boolean;
|
|
160
235
|
/** Active wallet instance */
|
|
@@ -163,18 +238,25 @@ type ProviderContext = {
|
|
|
163
238
|
connectionError: TuwaErrorState | undefined;
|
|
164
239
|
/** All modal and UI states */
|
|
165
240
|
modalStates: {
|
|
241
|
+
/** Whether the connect modal is open */
|
|
166
242
|
isConnectModalOpen: boolean;
|
|
243
|
+
/** Whether the connected modal is open */
|
|
167
244
|
isConnectedModalOpen: boolean;
|
|
245
|
+
/** Whether the desktop chain list is open */
|
|
168
246
|
isChainsListOpen: boolean;
|
|
247
|
+
/** Whether the mobile chain dialog is open */
|
|
169
248
|
isChainsListOpenMobile: boolean;
|
|
170
249
|
};
|
|
171
250
|
/** Current content types for modals */
|
|
172
251
|
contentTypes: {
|
|
252
|
+
/** Screen of the connect modal */
|
|
173
253
|
connectModal: ConnectContentType;
|
|
254
|
+
/** Screen of the connected modal */
|
|
174
255
|
connectedModal: ConnectedContentType;
|
|
175
256
|
};
|
|
176
257
|
/** Button and transaction statuses */
|
|
177
258
|
statuses: {
|
|
259
|
+
/** Transaction status of the connect button */
|
|
178
260
|
connectedButton: ButtonTxStatus;
|
|
179
261
|
};
|
|
180
262
|
};
|
|
@@ -185,34 +267,66 @@ type NovaConnectProviderCustomization = {
|
|
|
185
267
|
/** Custom components */
|
|
186
268
|
components?: {
|
|
187
269
|
/** Custom labels provider component */
|
|
188
|
-
LabelsProvider?: ComponentType<
|
|
270
|
+
LabelsProvider?: ComponentType<NovaConnectProviderLabelsProviderProps>;
|
|
189
271
|
/** Custom errors provider component */
|
|
190
|
-
ErrorsProvider?: ComponentType<
|
|
272
|
+
ErrorsProvider?: ComponentType<NovaConnectProviderErrorsProviderProps>;
|
|
191
273
|
};
|
|
192
274
|
/** Labels customization and merging strategy */
|
|
193
275
|
labels?: {
|
|
194
|
-
/**
|
|
276
|
+
/**
|
|
277
|
+
* Merges the `labels` prop into the defaults, instead of a deep merge.
|
|
278
|
+
*
|
|
279
|
+
* @param defaultLabels - The English defaults.
|
|
280
|
+
* @param userLabels - The `labels` prop (an empty object without it).
|
|
281
|
+
* @returns The merged labels.
|
|
282
|
+
*/
|
|
195
283
|
merge?: (defaultLabels: NovaConnectLabels, userLabels: Partial<NovaConnectLabels>) => NovaConnectLabels;
|
|
196
|
-
/**
|
|
197
|
-
|
|
284
|
+
/**
|
|
285
|
+
* Transforms the merged labels before they are provided.
|
|
286
|
+
*
|
|
287
|
+
* @param mergedLabels - The merged labels.
|
|
288
|
+
* @param context - State of the provider.
|
|
289
|
+
* @returns The final labels.
|
|
290
|
+
*/
|
|
291
|
+
transform?: (mergedLabels: NovaConnectLabels, context: NovaConnectProviderCustomizationContext) => NovaConnectLabels;
|
|
198
292
|
};
|
|
199
293
|
/** ErrorsProvider customization - passed through to ErrorsProvider */
|
|
200
294
|
errors?: ErrorsProviderCustomization;
|
|
201
295
|
/** Custom context value transformation */
|
|
202
296
|
contextValue?: {
|
|
203
|
-
/**
|
|
204
|
-
|
|
297
|
+
/**
|
|
298
|
+
* Transforms the value of the context before it is provided.
|
|
299
|
+
*
|
|
300
|
+
* @param defaultValue - The state of the provider.
|
|
301
|
+
* @param context - State of the provider for customization.
|
|
302
|
+
* @returns The context value.
|
|
303
|
+
*/
|
|
304
|
+
transform?: (defaultValue: NovaConnectProviderType, context: NovaConnectProviderCustomizationContext) => NovaConnectProviderType;
|
|
205
305
|
};
|
|
206
306
|
/** Custom rendering logic */
|
|
207
307
|
rendering?: {
|
|
208
|
-
/**
|
|
308
|
+
/**
|
|
309
|
+
* Returns the rendered tree, instead of the default one. Keep the elements inside the context provider (the
|
|
310
|
+
* default tree and `MainContent` include it).
|
|
311
|
+
*
|
|
312
|
+
* @param defaultTree - The default tree: the context provider with the SIWX watcher, the errors provider, the
|
|
313
|
+
* labels provider with the app, and the two modals.
|
|
314
|
+
* @param components - The parts of the tree.
|
|
315
|
+
* @param components.ErrorsProvider - The errors provider element.
|
|
316
|
+
* @param components.LabelsProvider - The labels provider element with the app.
|
|
317
|
+
* @param components.MainContent - The same tree as `defaultTree`.
|
|
318
|
+
* @param components.ConnectModal - The connect modal (an empty fragment without chains).
|
|
319
|
+
* @param components.ConnectedModal - The connected modal (an empty fragment without chains).
|
|
320
|
+
* @param context - State of the provider.
|
|
321
|
+
* @returns The tree to render.
|
|
322
|
+
*/
|
|
209
323
|
providerTree?: (defaultTree: ReactNode, components: {
|
|
210
324
|
ErrorsProvider: ReactNode;
|
|
211
325
|
LabelsProvider: ReactNode;
|
|
212
326
|
MainContent: ReactNode;
|
|
213
327
|
ConnectModal: ReactNode;
|
|
214
328
|
ConnectedModal: ReactNode;
|
|
215
|
-
}, context:
|
|
329
|
+
}, context: NovaConnectProviderCustomizationContext) => ReactNode;
|
|
216
330
|
};
|
|
217
331
|
/** Modal customizations */
|
|
218
332
|
modals?: {
|
|
@@ -223,71 +337,45 @@ type NovaConnectProviderCustomization = {
|
|
|
223
337
|
};
|
|
224
338
|
};
|
|
225
339
|
/**
|
|
226
|
-
*
|
|
340
|
+
* Props for the {@link NovaConnectProvider} component: `NovaConnectProviderProps` with `customization`.
|
|
227
341
|
*/
|
|
228
342
|
interface NovaConnectProviderPropsWithCustomization extends NovaConnectProviderProps {
|
|
229
343
|
/** Comprehensive customization options for the provider and its sub-components */
|
|
230
344
|
customization?: NovaConnectProviderCustomization;
|
|
231
345
|
}
|
|
232
346
|
/**
|
|
233
|
-
*
|
|
347
|
+
* The provider of Nova Connect. Place it inside `SatelliteConnectProvider` (from `@tuwaio/nova-connect/satellite`): it
|
|
348
|
+
* reads the Satellite store. It keeps the UI state of the modals (read it with `useNovaConnect`), provides the labels
|
|
349
|
+
* (the `labels` prop merged into the English defaults), shows connection and network switch errors as toasts
|
|
350
|
+
* (`ErrorsProvider`), signs in with SIWX when `siwx` is set (`NovaSiwxWatcher`), and renders the connect and connected
|
|
351
|
+
* modals when `appChains` or `solanaRPCUrls` is set.
|
|
234
352
|
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
* customization options for all sub-components and behaviors.
|
|
353
|
+
* @param props - See {@link NovaConnectProviderPropsWithCustomization}.
|
|
354
|
+
* @returns The provider tree.
|
|
238
355
|
*
|
|
239
|
-
*
|
|
240
|
-
* - Complete wallet connection state management
|
|
241
|
-
* - Centralized modal rendering and state management
|
|
242
|
-
* - Customizable error handling through ErrorsProvider
|
|
243
|
-
* - Flexible internationalization system
|
|
244
|
-
* - Modal and UI state coordination
|
|
245
|
-
* - Extensive customization API for all aspects
|
|
246
|
-
* - Custom component replacement capabilities
|
|
247
|
-
*
|
|
248
|
-
* @example Basic usage
|
|
356
|
+
* @example
|
|
249
357
|
* ```tsx
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* solanaRPCUrls={{
|
|
254
|
-
* 'mainnet': 'https://api.mainnet-beta.solana.com'
|
|
255
|
-
* }}
|
|
256
|
-
* >
|
|
257
|
-
* <App />
|
|
258
|
-
* </NovaConnectProvider>
|
|
259
|
-
* ```
|
|
358
|
+
* import { NovaConnectProvider } from '@tuwaio/nova-connect';
|
|
359
|
+
* import type { ReactNode } from 'react';
|
|
360
|
+
* import { mainnet, polygon } from 'viem/chains';
|
|
260
361
|
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
*
|
|
266
|
-
*
|
|
267
|
-
*
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
* modals: {
|
|
278
|
-
* connectModal: {
|
|
279
|
-
* classNames: {
|
|
280
|
-
* container: () => 'custom-modal-style'
|
|
281
|
-
* }
|
|
282
|
-
* }
|
|
283
|
-
* }
|
|
284
|
-
* }}
|
|
285
|
-
* >
|
|
286
|
-
* <App />
|
|
287
|
-
* </NovaConnectProvider>
|
|
362
|
+
* export function WalletUI({ children }: { children: ReactNode }) {
|
|
363
|
+
* return (
|
|
364
|
+
* <NovaConnectProvider
|
|
365
|
+
* appChains={[mainnet, polygon]}
|
|
366
|
+
* solanaRPCUrls={{ devnet: 'https://api.devnet.solana.com' }}
|
|
367
|
+
* withBalance
|
|
368
|
+
* withChain
|
|
369
|
+
* legal={{ termsUrl: 'https://example.com/terms', privacyUrl: 'https://example.com/privacy' }}
|
|
370
|
+
* customization={{
|
|
371
|
+
* modals: { connectModal: { classNames: { title: () => 'custom-title' } } },
|
|
372
|
+
* }}
|
|
373
|
+
* >
|
|
374
|
+
* {children}
|
|
375
|
+
* </NovaConnectProvider>
|
|
376
|
+
* );
|
|
377
|
+
* }
|
|
288
378
|
* ```
|
|
289
|
-
*
|
|
290
|
-
* @param props - Provider configuration and customization options
|
|
291
379
|
*/
|
|
292
380
|
declare function NovaConnectProvider({ labels, children, appChains, solanaRPCUrls, transactionPool, pulsarAdapter, withImpersonated, withBalance, withChain, popularConnectors, customConnectorGroups, legal, siwx, customization, pagination, }: NovaConnectProviderPropsWithCustomization): React.JSX.Element;
|
|
293
381
|
declare namespace NovaConnectProvider {
|
|
@@ -295,546 +383,70 @@ declare namespace NovaConnectProvider {
|
|
|
295
383
|
}
|
|
296
384
|
|
|
297
385
|
/**
|
|
298
|
-
* Parameters
|
|
299
|
-
*
|
|
300
|
-
* Combines chain configuration with wallet-specific requirements to determine
|
|
301
|
-
* which chains should be available for a given wallet type.
|
|
302
|
-
*
|
|
303
|
-
* @interface GetChainsListParams
|
|
304
|
-
* @extends InitialChains
|
|
305
|
-
* @since 1.0.0
|
|
306
|
-
*
|
|
307
|
-
* @example
|
|
308
|
-
* ```typescript
|
|
309
|
-
* const params: GetChainsListParams = {
|
|
310
|
-
* connectorType: WalletType.EVM_METAMASK,
|
|
311
|
-
* appChains: [
|
|
312
|
-
* { id: 1, name: 'Ethereum' },
|
|
313
|
-
* { id: 137, name: 'Polygon' }
|
|
314
|
-
* ],
|
|
315
|
-
* chains: [1, 137] // Optional filter
|
|
316
|
-
* };
|
|
317
|
-
* ```
|
|
386
|
+
* Parameters of {@link getChainsListByConnectorType}.
|
|
318
387
|
*/
|
|
319
|
-
interface
|
|
320
|
-
/**
|
|
388
|
+
interface GetChainsListByConnectorTypeParams extends InitialChains {
|
|
389
|
+
/** Connector type whose network is used, for example `evm:metamask` */
|
|
321
390
|
connectorType: ConnectorType;
|
|
322
|
-
/**
|
|
391
|
+
/** Solana only: keeps the clusters of these chain identifiers (for example `solana:devnet`) */
|
|
323
392
|
chains?: ChainIdentifierArray;
|
|
324
393
|
}
|
|
325
394
|
/**
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
* This is the primary function for getting blockchain-compatible chains based on
|
|
329
|
-
* wallet type and configuration. It automatically determines the correct adapter,
|
|
330
|
-
* loads it if necessary, and falls back to safe defaults if loading fails.
|
|
331
|
-
*
|
|
332
|
-
* The function supports all major blockchain types:
|
|
333
|
-
* - EVM chains: Returns numeric chain IDs from app configuration
|
|
334
|
-
* - Solana clusters: Returns string cluster names from RPC configuration
|
|
335
|
-
* - Future blockchains: Extensible through the adapter pattern
|
|
336
|
-
*
|
|
337
|
-
* @param params - Configuration object with connectorType type and chain data
|
|
338
|
-
* @returns Promise resolving to array of chain identifiers
|
|
339
|
-
*
|
|
340
|
-
* @example
|
|
341
|
-
* ```typescript
|
|
342
|
-
* // Get EVM chains for MetaMask
|
|
343
|
-
* const evmChains = await getChainsListByConnectorType({
|
|
344
|
-
* connectorType: ConnectorType.EVM_METAMASK,
|
|
345
|
-
* appChains: [
|
|
346
|
-
* { id: 1, name: 'Ethereum' },
|
|
347
|
-
* { id: 137, name: 'Polygon' }
|
|
348
|
-
* ]
|
|
349
|
-
* });
|
|
350
|
-
* // Returns: [1, 137]
|
|
351
|
-
*
|
|
352
|
-
* // Get Solana clusters for Phantom
|
|
353
|
-
* const solanaClusters = await getChainsListByConnectorType({
|
|
354
|
-
* connectorType: ConnectorType.SOLANA_PHANTOM,
|
|
355
|
-
* solanaRPCUrls: {
|
|
356
|
-
* 'mainnet-beta': 'https://api.mainnet-beta.solana.com',
|
|
357
|
-
* 'devnet': 'https://api.devnet.solana.com'
|
|
358
|
-
* }
|
|
359
|
-
* });
|
|
360
|
-
* // Returns: ['mainnet-beta', 'devnet']
|
|
361
|
-
* ```
|
|
362
|
-
*
|
|
363
|
-
* @since 1.0.0
|
|
364
|
-
*/
|
|
365
|
-
declare function getChainsListByConnectorType(params: GetChainsListParams): Promise<(string | number)[]>;
|
|
366
|
-
/**
|
|
367
|
-
* Synchronous version that only works with pre-loaded adapters.
|
|
368
|
-
*
|
|
369
|
-
* This function provides immediate results by using only adapters that have
|
|
370
|
-
* already been loaded into the registry cache. It will not trigger new
|
|
371
|
-
* loading operations, making it safe for synchronous contexts but potentially
|
|
372
|
-
* less complete than the async version.
|
|
373
|
-
*
|
|
374
|
-
* Use this function when:
|
|
375
|
-
* - You've pre-loaded adapters during app initialization
|
|
376
|
-
* - You need immediate results without async overhead
|
|
377
|
-
* - You're in a synchronous context where async calls aren't feasible
|
|
378
|
-
*
|
|
379
|
-
* @param params - Configuration object with wallet type and chain data
|
|
380
|
-
* @returns Array of chain identifiers (empty if adapter not loaded)
|
|
381
|
-
*
|
|
382
|
-
* @example
|
|
383
|
-
* ```typescript
|
|
384
|
-
* // Pre-load adapters first
|
|
385
|
-
* await preloadChainAdapters([OrbitAdapter.EVM, OrbitAdapter.SOLANA]);
|
|
386
|
-
*
|
|
387
|
-
* // Now safe to use sync version
|
|
388
|
-
* const chains = getChainsListByWalletTypeSync({
|
|
389
|
-
* connectorType: ConnectorType.EVM_METAMASK,
|
|
390
|
-
* appChains: evmConfiguration
|
|
391
|
-
* });
|
|
392
|
-
* ```
|
|
393
|
-
*
|
|
394
|
-
* @since 1.0.0
|
|
395
|
-
*/
|
|
396
|
-
declare function getChainsListByConnectorTypeSync(params: GetChainsListParams): (string | number)[];
|
|
397
|
-
/**
|
|
398
|
-
* Validates if a chain list conforms to EVM format (with adapter loading).
|
|
399
|
-
*
|
|
400
|
-
* Uses the EVM adapter to perform comprehensive validation, falling back to
|
|
401
|
-
* basic type checking if the adapter isn't available. EVM chains typically
|
|
402
|
-
* use numeric identifiers.
|
|
403
|
-
*
|
|
404
|
-
* @param chains - Array of chain identifiers to validate
|
|
405
|
-
* @returns Promise resolving to true if chains are valid for EVM
|
|
406
|
-
*
|
|
407
|
-
* @example
|
|
408
|
-
* ```typescript
|
|
409
|
-
* const isEvm = await isEvmChainList([1, 137, 56]); // true
|
|
410
|
-
* const notEvm = await isEvmChainList(['mainnet-beta']); // false
|
|
411
|
-
* ```
|
|
412
|
-
*
|
|
413
|
-
* @since 1.0.0
|
|
414
|
-
*/
|
|
415
|
-
declare function isEvmChainList(chains: (string | number)[]): Promise<boolean>;
|
|
416
|
-
/**
|
|
417
|
-
* Validates if a chain list conforms to Solana format (with adapter loading).
|
|
418
|
-
*
|
|
419
|
-
* Uses the Solana adapter to perform comprehensive validation, falling back to
|
|
420
|
-
* basic type checking if the adapter isn't available. Solana chains typically
|
|
421
|
-
* use string cluster names.
|
|
422
|
-
*
|
|
423
|
-
* @param chains - Array of chain identifiers to validate
|
|
424
|
-
* @returns Promise resolving to true if chains are valid for Solana
|
|
425
|
-
*
|
|
426
|
-
* @example
|
|
427
|
-
* ```typescript
|
|
428
|
-
* const isSolana = await isSolanaChainList(['mainnet-beta', 'devnet']); // true
|
|
429
|
-
* const notSolana = await isSolanaChainList([1, 137]); // false
|
|
430
|
-
* ```
|
|
431
|
-
*
|
|
432
|
-
* @since 1.0.0
|
|
433
|
-
*/
|
|
434
|
-
declare function isSolanaChainList(chains: (string | number)[]): Promise<boolean>;
|
|
435
|
-
/**
|
|
436
|
-
* Synchronous EVM chain list validation using pre-loaded adapters.
|
|
437
|
-
*
|
|
438
|
-
* Provides immediate validation results without triggering adapter loading.
|
|
439
|
-
* Falls back to basic type checking if adapter isn't pre-loaded.
|
|
440
|
-
*
|
|
441
|
-
* @param chains - Array of chain identifiers to validate
|
|
442
|
-
* @returns True if chains are valid for EVM
|
|
443
|
-
*
|
|
444
|
-
* @example
|
|
445
|
-
* ```typescript
|
|
446
|
-
* const isEvm = isEvmChainListSync([1, 137, 56]); // true (immediate result)
|
|
447
|
-
* ```
|
|
448
|
-
*
|
|
449
|
-
* @since 1.0.0
|
|
450
|
-
*/
|
|
451
|
-
declare function isEvmChainListSync(chains: (string | number)[]): boolean;
|
|
452
|
-
/**
|
|
453
|
-
* Synchronous Solana chain list validation using pre-loaded adapters.
|
|
395
|
+
* Returns the chains of the app for the network of a connector type.
|
|
454
396
|
*
|
|
455
|
-
*
|
|
456
|
-
*
|
|
397
|
+
* - EVM: the IDs of `appChains` (`getEvmChains` of `@tuwaio/orbit-evm` when `@tuwaio/nova-connect/evm` is imported).
|
|
398
|
+
* - Solana: when `@tuwaio/nova-connect/solana` is imported, `getSolanaClusters` of `@tuwaio/orbit-solana`: the cluster
|
|
399
|
+
* monikers of `solanaRPCUrls` (every cluster with a public RPC URL without it), filtered by `chains` when set.
|
|
400
|
+
* Otherwise the keys of `solanaRPCUrls`.
|
|
457
401
|
*
|
|
458
|
-
* @param
|
|
459
|
-
* @returns
|
|
402
|
+
* @param params - See {@link GetChainsListByConnectorTypeParams}.
|
|
403
|
+
* @returns The chain IDs or cluster monikers (empty without `connectorType`, with a warning).
|
|
460
404
|
*
|
|
461
405
|
* @example
|
|
462
|
-
* ```
|
|
463
|
-
*
|
|
406
|
+
* ```ts
|
|
407
|
+
* import { getChainsListByConnectorType } from '@tuwaio/nova-connect';
|
|
408
|
+
* import { mainnet, polygon } from 'viem/chains';
|
|
409
|
+
*
|
|
410
|
+
* getChainsListByConnectorType({ connectorType: 'evm:metamask', appChains: [mainnet, polygon] }); // [1, 137]
|
|
411
|
+
* getChainsListByConnectorType({
|
|
412
|
+
* connectorType: 'solana:phantom',
|
|
413
|
+
* solanaRPCUrls: { devnet: 'https://api.devnet.solana.com' },
|
|
414
|
+
* }); // ['devnet']
|
|
464
415
|
* ```
|
|
465
|
-
*
|
|
466
|
-
* @since 1.0.0
|
|
467
|
-
*/
|
|
468
|
-
declare function isSolanaChainListSync(chains: (string | number)[]): boolean;
|
|
469
|
-
/**
|
|
470
|
-
* Retrieves all available Solana clusters from the current configuration.
|
|
471
|
-
*
|
|
472
|
-
* This function loads the Solana adapter and queries it for all configured
|
|
473
|
-
* cluster names. Useful for populating UI dropdowns or validating cluster
|
|
474
|
-
* availability before connection attempts.
|
|
475
|
-
*
|
|
476
|
-
* @returns Promise resolving to array of available cluster names
|
|
477
|
-
*
|
|
478
|
-
* @example
|
|
479
|
-
* ```typescript
|
|
480
|
-
* const clusters = await getAvailableSolanaClusters();
|
|
481
|
-
* console.log('Available clusters:', clusters);
|
|
482
|
-
* // Might log: ['mainnet-beta', 'devnet', 'testnet', 'localnet']
|
|
483
|
-
*
|
|
484
|
-
* // Use for UI population
|
|
485
|
-
* const clusterOptions = clusters.map(cluster => ({
|
|
486
|
-
* value: cluster,
|
|
487
|
-
* label: cluster.replace('-', ' ').toUpperCase()
|
|
488
|
-
* }));
|
|
489
|
-
* ```
|
|
490
|
-
*
|
|
491
|
-
* @since 1.0.0
|
|
492
416
|
*/
|
|
493
|
-
declare function
|
|
417
|
+
declare function getChainsListByConnectorType(params: GetChainsListByConnectorTypeParams): (string | number)[];
|
|
494
418
|
/**
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
* This function loads the Solana adapter and uses it to validate cluster
|
|
498
|
-
* names against known Solana cluster monikers and custom configurations.
|
|
499
|
-
*
|
|
500
|
-
* @param cluster - Cluster name to validate
|
|
501
|
-
* @returns Promise resolving to true if cluster is valid
|
|
502
|
-
*
|
|
503
|
-
* @example
|
|
504
|
-
* ```typescript
|
|
505
|
-
* const isValid = await isValidSolanaCluster('mainnet-beta'); // true
|
|
506
|
-
* const isInvalid = await isValidSolanaCluster('invalid-cluster'); // false
|
|
419
|
+
* Checks whether a chain list has only EVM chain IDs (numbers), with `isEvmChainList` of `@tuwaio/orbit-evm` when
|
|
420
|
+
* `@tuwaio/nova-connect/evm` is imported.
|
|
507
421
|
*
|
|
508
|
-
*
|
|
509
|
-
*
|
|
510
|
-
* // Proceed with connection
|
|
511
|
-
* } else {
|
|
512
|
-
* // Show error message
|
|
513
|
-
* }
|
|
514
|
-
* ```
|
|
515
|
-
*
|
|
516
|
-
* @since 1.0.0
|
|
422
|
+
* @param chains - Chain identifiers.
|
|
423
|
+
* @returns `true` when the list is not empty and has only numbers.
|
|
517
424
|
*/
|
|
518
|
-
declare function
|
|
425
|
+
declare function isEvmChainList(chains: (string | number)[]): boolean;
|
|
519
426
|
/**
|
|
520
|
-
*
|
|
521
|
-
*
|
|
522
|
-
* This utility function handles the complex nested structure of wallet objects
|
|
523
|
-
* and safely extracts chain information without throwing errors. It performs
|
|
524
|
-
* comprehensive type checking to ensure data integrity.
|
|
427
|
+
* Checks whether a chain list has only Solana cluster monikers (strings), with `isSolanaChainList` of
|
|
428
|
+
* `@tuwaio/orbit-solana` when `@tuwaio/nova-connect/solana` is imported.
|
|
525
429
|
*
|
|
526
|
-
*
|
|
527
|
-
*
|
|
528
|
-
* {
|
|
529
|
-
* connectedWallet: {
|
|
530
|
-
* chains: [chain1, chain2, ...]
|
|
531
|
-
* }
|
|
532
|
-
* }
|
|
533
|
-
* ```
|
|
534
|
-
*
|
|
535
|
-
* @param activeWallet - Wallet object to extract chains from
|
|
536
|
-
* @returns Array of chain identifiers or undefined if not found/invalid
|
|
537
|
-
*
|
|
538
|
-
* @example
|
|
539
|
-
* ```typescript
|
|
540
|
-
* // With valid wallet structure
|
|
541
|
-
* const wallet = {
|
|
542
|
-
* connectedWallet: {
|
|
543
|
-
* chains: [1, 137, 56]
|
|
544
|
-
* }
|
|
545
|
-
* };
|
|
546
|
-
* const chains = getWalletChains(wallet); // [1, 137, 56]
|
|
547
|
-
*
|
|
548
|
-
* // With invalid/missing structure
|
|
549
|
-
* const invalidWallet = { someOtherProperty: true };
|
|
550
|
-
* const noChains = getWalletChains(invalidWallet); // undefined
|
|
551
|
-
*
|
|
552
|
-
* // Use in conditional logic
|
|
553
|
-
* const walletChains = getWalletChains(activeWallet);
|
|
554
|
-
* if (walletChains) {
|
|
555
|
-
* console.log('Wallet supports chains:', walletChains);
|
|
556
|
-
* }
|
|
557
|
-
* ```
|
|
558
|
-
*
|
|
559
|
-
* @since 1.0.0
|
|
430
|
+
* @param chains - Chain identifiers.
|
|
431
|
+
* @returns `true` when the list is not empty and has only strings.
|
|
560
432
|
*/
|
|
561
|
-
declare function
|
|
433
|
+
declare function isSolanaChainList(chains: (string | number)[]): boolean;
|
|
562
434
|
/**
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
* This function should be called during application initialization to load
|
|
566
|
-
* commonly used adapters ahead of time. This eliminates loading delays when
|
|
567
|
-
* users first interact with wallet connections.
|
|
435
|
+
* Reads `connectedWallet.chains` of a connection (the Wallet Standard wallet of a Solana connection).
|
|
568
436
|
*
|
|
569
|
-
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* @param types - Array of adapter types to preload (defaults to EVM and Solana)
|
|
573
|
-
* @returns Promise that resolves when all loading attempts complete
|
|
437
|
+
* @param connection - A connection, or any other value.
|
|
438
|
+
* @returns The chains, or `undefined` when the value has no such array.
|
|
574
439
|
*
|
|
575
440
|
* @example
|
|
576
|
-
* ```
|
|
577
|
-
*
|
|
578
|
-
* export async function initializeApp() {
|
|
579
|
-
* // Preload common adapters
|
|
580
|
-
* await preloadChainAdapters([OrbitAdapter.EVM, OrbitAdapter.SOLANA]);
|
|
441
|
+
* ```ts
|
|
442
|
+
* import { getWalletChains } from '@tuwaio/nova-connect';
|
|
581
443
|
*
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
* }
|
|
585
|
-
*
|
|
586
|
-
* // Later usage will be instant for loaded adapters
|
|
587
|
-
* const evmChains = getChainsListByWalletTypeSync({
|
|
588
|
-
* walletType: WalletType.EVM_METAMASK,
|
|
589
|
-
* appChains: configuration
|
|
590
|
-
* }); // Instant result since adapter is pre-loaded
|
|
444
|
+
* getWalletChains({ connectedWallet: { chains: ['solana:mainnet', 'solana:devnet'] } });
|
|
445
|
+
* // ['solana:mainnet', 'solana:devnet']
|
|
446
|
+
* getWalletChains({}); // undefined
|
|
591
447
|
* ```
|
|
592
|
-
*
|
|
593
|
-
* @since 1.0.0
|
|
594
448
|
*/
|
|
595
|
-
declare function
|
|
596
|
-
/**
|
|
597
|
-
* Gets the current loading status of a specific adapter.
|
|
598
|
-
*
|
|
599
|
-
* Returns the current state of an adapter in the loading lifecycle. Useful
|
|
600
|
-
* for UI indicators, debugging, or conditional logic based on adapter
|
|
601
|
-
* availability.
|
|
602
|
-
*
|
|
603
|
-
* @param type - The adapter type to check
|
|
604
|
-
* @returns Current loading status of the adapter
|
|
605
|
-
*
|
|
606
|
-
* @example
|
|
607
|
-
* ```typescript
|
|
608
|
-
* const evmStatus = getAdapterStatus(OrbitAdapter.EVM);
|
|
609
|
-
*
|
|
610
|
-
* switch (evmStatus) {
|
|
611
|
-
* case 'idle':
|
|
612
|
-
* console.log('EVM adapter not yet requested');
|
|
613
|
-
* break;
|
|
614
|
-
* case 'loading':
|
|
615
|
-
* // Show loading spinner
|
|
616
|
-
* break;
|
|
617
|
-
* case 'loaded':
|
|
618
|
-
* // Enable EVM features
|
|
619
|
-
* break;
|
|
620
|
-
* case 'error':
|
|
621
|
-
* // Show fallback UI
|
|
622
|
-
* break;
|
|
623
|
-
* }
|
|
624
|
-
* ```
|
|
625
|
-
*
|
|
626
|
-
* @since 1.0.0
|
|
627
|
-
*/
|
|
628
|
-
declare function getAdapterStatus(type: OrbitAdapter): AdapterLoadStatus;
|
|
629
|
-
/**
|
|
630
|
-
* Gets comprehensive status information for all registered adapters.
|
|
631
|
-
*
|
|
632
|
-
* Returns a complete overview of all adapter states, useful for debugging,
|
|
633
|
-
* monitoring, or displaying system status in admin interfaces.
|
|
634
|
-
*
|
|
635
|
-
* @returns Record mapping adapter types to their current loading status
|
|
636
|
-
*
|
|
637
|
-
* @example
|
|
638
|
-
* ```typescript
|
|
639
|
-
* const allStatuses = getAllAdaptersStatus();
|
|
640
|
-
* console.log('System overview:', allStatuses);
|
|
641
|
-
* // Output: { "evm": "loaded", "solana": "loading", "starknet": "idle" }
|
|
642
|
-
*
|
|
643
|
-
* // Use for system health monitoring
|
|
644
|
-
* const loadedAdapters = Object.entries(allStatuses)
|
|
645
|
-
* .filter(([_, status]) => status === 'loaded')
|
|
646
|
-
* .map(([type, _]) => type);
|
|
647
|
-
*
|
|
648
|
-
* console.log('Available blockchain support:', loadedAdapters);
|
|
649
|
-
* ```
|
|
650
|
-
*
|
|
651
|
-
* @since 1.0.0
|
|
652
|
-
*/
|
|
653
|
-
declare function getAllAdaptersStatus(): Record<string, AdapterLoadStatus>;
|
|
654
|
-
|
|
655
|
-
/**
|
|
656
|
-
* Generic chain adapter interface that provides blockchain-specific functionality.
|
|
657
|
-
*
|
|
658
|
-
* This interface abstracts the differences between various blockchain architectures
|
|
659
|
-
* (EVM, Solana, Starknet, etc.) while providing a consistent API for chain operations.
|
|
660
|
-
* Each adapter implementation handles the specifics of its blockchain type.
|
|
661
|
-
*
|
|
662
|
-
* @interface ChainAdapter
|
|
663
|
-
* @since 1.0.0
|
|
664
|
-
*
|
|
665
|
-
* @example
|
|
666
|
-
* ```typescript
|
|
667
|
-
* // EVM adapter usage
|
|
668
|
-
* const evmAdapter = await createEvmAdapter();
|
|
669
|
-
* const evmChains = evmAdapter.getChains([
|
|
670
|
-
* { id: 1, name: 'Ethereum' },
|
|
671
|
-
* { id: 137, name: 'Polygon' }
|
|
672
|
-
* ]);
|
|
673
|
-
*
|
|
674
|
-
* // Solana adapter usage
|
|
675
|
-
* const solanaAdapter = await createSolanaAdapter();
|
|
676
|
-
* const solanaClusters = solanaAdapter.getChains({
|
|
677
|
-
* 'mainnet-beta': 'https://api.mainnet-beta.solana.com'
|
|
678
|
-
* });
|
|
679
|
-
* ```
|
|
680
|
-
*/
|
|
681
|
-
interface ChainAdapter {
|
|
682
|
-
/**
|
|
683
|
-
* Extracts chain identifiers from the provided configuration.
|
|
684
|
-
*
|
|
685
|
-
* The exact behavior depends on the blockchain type:
|
|
686
|
-
* - EVM: Extracts numeric chain IDs from chain objects or arrays
|
|
687
|
-
* - Solana: Extracts cluster names from RPC URL configurations
|
|
688
|
-
* - Others: Implementation-specific logic
|
|
689
|
-
*
|
|
690
|
-
* @param config Chain configuration data (format varies by blockchain)
|
|
691
|
-
* @param chains Optional array of specific chains to filter or process
|
|
692
|
-
* @returns Promise resolving to array of chain identifiers (numbers for EVM, strings for Solana)
|
|
693
|
-
*
|
|
694
|
-
* @example
|
|
695
|
-
* ```typescript
|
|
696
|
-
* // EVM chains
|
|
697
|
-
* const evmChains = await adapter.getChains([
|
|
698
|
-
* { id: 1, name: 'Ethereum' },
|
|
699
|
-
* { id: 56, name: 'BSC' }
|
|
700
|
-
* ]);
|
|
701
|
-
* // Returns: [1, 56]
|
|
702
|
-
*
|
|
703
|
-
* // Solana clusters
|
|
704
|
-
* const solanaClusters = await adapter.getChains({
|
|
705
|
-
* 'mainnet-beta': 'https://api.mainnet-beta.solana.com',
|
|
706
|
-
* devnet: 'https://api.devnet.solana.com'
|
|
707
|
-
* });
|
|
708
|
-
* // Returns: ['mainnet-beta', 'devnet']
|
|
709
|
-
* ```
|
|
710
|
-
*/
|
|
711
|
-
getChains(config: any, chains?: any): (string | number)[];
|
|
712
|
-
/**
|
|
713
|
-
* Validates whether a chain identifier array conforms to this adapter's expected format.
|
|
714
|
-
*
|
|
715
|
-
* Different blockchains use different identifier formats:
|
|
716
|
-
* - EVM: Typically numeric chain IDs (e.g., 1, 137, 56)
|
|
717
|
-
* - Solana: String cluster names (e.g., 'mainnet-beta', 'devnet')
|
|
718
|
-
* - Others: Implementation-specific validation rules
|
|
719
|
-
*
|
|
720
|
-
* @param chains Array of chain identifiers to validate
|
|
721
|
-
* @returns True if the chain list format is valid for this blockchain type
|
|
722
|
-
*
|
|
723
|
-
* @example
|
|
724
|
-
* ```typescript
|
|
725
|
-
* // EVM validation
|
|
726
|
-
* const evmValid = evmAdapter.isChainList([1, 137, 56]); // true
|
|
727
|
-
* const evmInvalid = evmAdapter.isChainList(['mainnet']); // false
|
|
728
|
-
*
|
|
729
|
-
* // Solana validation
|
|
730
|
-
* const solanaValid = solanaAdapter.isChainList(['mainnet-beta', 'devnet']); // true
|
|
731
|
-
* const solanaInvalid = solanaAdapter.isChainList([1, 2]); // false
|
|
732
|
-
* ```
|
|
733
|
-
*/
|
|
734
|
-
isChainList(chains: (string | number)[]): boolean;
|
|
735
|
-
/**
|
|
736
|
-
* Gets all available clusters for Solana-based adapters.
|
|
737
|
-
*
|
|
738
|
-
* This method is specific to Solana and returns the configured cluster names
|
|
739
|
-
* that can be used for connections. Not applicable to other blockchain types.
|
|
740
|
-
*
|
|
741
|
-
* @returns Promise resolving to array of available cluster names
|
|
742
|
-
* @optional This method is only available on Solana adapters
|
|
743
|
-
*
|
|
744
|
-
* @example
|
|
745
|
-
* ```typescript
|
|
746
|
-
* const solanaAdapter = await createSolanaAdapter();
|
|
747
|
-
* const clusters = await solanaAdapter.getAvailableClusters?.();
|
|
748
|
-
* // Might return: ['mainnet-beta', 'devnet', 'testnet', 'localnet']
|
|
749
|
-
* ```
|
|
750
|
-
*/
|
|
751
|
-
getAvailableClusters?(): string[];
|
|
752
|
-
/**
|
|
753
|
-
* Validates whether a cluster name is valid for Solana.
|
|
754
|
-
*
|
|
755
|
-
* This method is specific to Solana and checks if the provided cluster name
|
|
756
|
-
* is a known/valid Solana cluster moniker. Not applicable to other blockchain types.
|
|
757
|
-
*
|
|
758
|
-
* @param cluster Cluster name to validate
|
|
759
|
-
* @returns Promise resolving to true if the cluster name is valid for Solana
|
|
760
|
-
* @optional This method is only available on Solana adapters
|
|
761
|
-
*
|
|
762
|
-
* @example
|
|
763
|
-
* ```typescript
|
|
764
|
-
* const solanaAdapter = await createSolanaAdapter();
|
|
765
|
-
* const isValid = await solanaAdapter.isValidCluster?.('mainnet-beta'); // true
|
|
766
|
-
* const isInvalid = await solanaAdapter.isValidCluster?.('invalid-cluster'); // false
|
|
767
|
-
* ```
|
|
768
|
-
*/
|
|
769
|
-
isValidCluster?(cluster: string): boolean;
|
|
770
|
-
}
|
|
771
|
-
/**
|
|
772
|
-
* Represents the current loading state of a blockchain adapter.
|
|
773
|
-
*
|
|
774
|
-
* The adapter lifecycle progresses through these states:
|
|
775
|
-
* - `idle`: Adapter hasn't been requested yet
|
|
776
|
-
* - `loading`: Adapter is currently being loaded/initialized
|
|
777
|
-
* - `loaded`: Adapter is successfully loaded and ready for use
|
|
778
|
-
* - `error`: Adapter failed to load due to missing dependencies or errors
|
|
779
|
-
*
|
|
780
|
-
* @type AdapterLoadStatus
|
|
781
|
-
* @since 1.0.0
|
|
782
|
-
*
|
|
783
|
-
* @example
|
|
784
|
-
* ```typescript
|
|
785
|
-
* import { adapterRegistry } from './registry';
|
|
786
|
-
*
|
|
787
|
-
* const status = adapterRegistry.getAdapterStatus(OrbitAdapter.EVM);
|
|
788
|
-
*
|
|
789
|
-
* switch (status) {
|
|
790
|
-
* case 'idle':
|
|
791
|
-
* console.log('EVM adapter not yet requested');
|
|
792
|
-
* break;
|
|
793
|
-
* case 'loading':
|
|
794
|
-
* console.log('EVM adapter is loading...');
|
|
795
|
-
* break;
|
|
796
|
-
* case 'loaded':
|
|
797
|
-
* console.log('EVM adapter ready for use');
|
|
798
|
-
* break;
|
|
799
|
-
* case 'error':
|
|
800
|
-
* console.log('EVM adapter failed to load');
|
|
801
|
-
* break;
|
|
802
|
-
* }
|
|
803
|
-
* ```
|
|
804
|
-
*/
|
|
805
|
-
type AdapterLoadStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
|
806
|
-
/**
|
|
807
|
-
* Complete information about an adapter's loading state and instance.
|
|
808
|
-
*
|
|
809
|
-
* This interface tracks both the loading status and the actual adapter instance
|
|
810
|
-
* (if successfully loaded), along with any error information if loading failed.
|
|
811
|
-
*
|
|
812
|
-
* @interface AdapterInfo
|
|
813
|
-
* @since 1.0.0
|
|
814
|
-
*
|
|
815
|
-
* @example
|
|
816
|
-
* ```typescript
|
|
817
|
-
* // Internal registry usage (not typically used directly)
|
|
818
|
-
* const adapterInfo: AdapterInfo = {
|
|
819
|
-
* status: 'loaded',
|
|
820
|
-
* adapter: evmAdapterInstance
|
|
821
|
-
* };
|
|
822
|
-
*
|
|
823
|
-
* // Error case
|
|
824
|
-
* const errorInfo: AdapterInfo = {
|
|
825
|
-
* status: 'error',
|
|
826
|
-
* error: new Error('EVM utilities not available')
|
|
827
|
-
* };
|
|
828
|
-
* ```
|
|
829
|
-
*/
|
|
830
|
-
interface AdapterInfo {
|
|
831
|
-
/** Current loading status of the adapter */
|
|
832
|
-
status: AdapterLoadStatus;
|
|
833
|
-
/** The loaded adapter instance (only present when status is 'loaded') */
|
|
834
|
-
adapter?: ChainAdapter;
|
|
835
|
-
/** Error information (only present when status is 'error') */
|
|
836
|
-
error?: Error;
|
|
837
|
-
}
|
|
449
|
+
declare function getWalletChains(connection: unknown): ChainIdentifierArray | undefined;
|
|
838
450
|
|
|
839
451
|
/**
|
|
840
452
|
* Gets the appropriate chain ID for connecting based on the selected adapter.
|
|
@@ -850,302 +462,82 @@ declare function getConnectChainId({ selectedAdapter, appChains, solanaRPCUrls,
|
|
|
850
462
|
selectedAdapter: OrbitAdapter;
|
|
851
463
|
} & InitialChains): number | string;
|
|
852
464
|
/**
|
|
853
|
-
*
|
|
465
|
+
* Returns the chains of the app for a network.
|
|
466
|
+
*
|
|
467
|
+
* @param params - The network and the chains of the app.
|
|
468
|
+
* @param params.selectedAdapter - The network.
|
|
469
|
+
* @returns The IDs of `appChains` (EVM) or the cluster monikers of `solanaRPCUrls` (Solana); the default chain of the
|
|
470
|
+
* network (Ethereum Mainnet, Solana Mainnet) when the list is empty.
|
|
854
471
|
*/
|
|
855
472
|
declare function getAvailableChainIds({ selectedAdapter, appChains, solanaRPCUrls, }: {
|
|
856
473
|
selectedAdapter: OrbitAdapter;
|
|
857
474
|
} & InitialChains): Array<number | string>;
|
|
858
475
|
|
|
476
|
+
/**
|
|
477
|
+
* A wallet with its connectors on each network, returned by {@link getGroupedConnectors}.
|
|
478
|
+
*/
|
|
859
479
|
interface GroupedConnector {
|
|
480
|
+
/** Name of the first connector of the wallet */
|
|
860
481
|
name: string;
|
|
482
|
+
/** Icon of the first connector that has one (a data URL or URL) */
|
|
861
483
|
icon?: string;
|
|
484
|
+
/** Adapters on which the wallet has a connector */
|
|
862
485
|
adapters: OrbitAdapter[];
|
|
486
|
+
/** The connectors of the wallet, each with its adapter */
|
|
863
487
|
connectors: (Connector & {
|
|
488
|
+
/** Adapter of the connector */
|
|
864
489
|
adapter: OrbitAdapter;
|
|
865
490
|
})[];
|
|
866
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* Parameters of {@link getGroupedConnectors}.
|
|
494
|
+
*/
|
|
867
495
|
interface GetGroupedConnectorsParams {
|
|
496
|
+
/** Connectors by adapter, as `getConnectors()` of the Satellite store returns them */
|
|
868
497
|
connectors: Partial<Record<OrbitAdapter, Connector[]>>;
|
|
498
|
+
/** Names of connectors to leave out, compared after `formatConnectorName` (default: `['injected']`) */
|
|
869
499
|
excludeConnectors?: string[];
|
|
870
500
|
}
|
|
871
501
|
/**
|
|
872
|
-
* Groups
|
|
873
|
-
*
|
|
502
|
+
* Groups connectors of all adapters by wallet: connectors whose names give the same `formatConnectorName` (from
|
|
503
|
+
* `@tuwaio/orbit-core`) belong to one wallet. Connectors without a name are skipped.
|
|
504
|
+
*
|
|
505
|
+
* @param params - See {@link GetGroupedConnectorsParams} (default: no connectors).
|
|
506
|
+
* @returns The wallets sorted by name (case-insensitive).
|
|
874
507
|
*/
|
|
875
508
|
declare function getGroupedConnectors({ connectors, excludeConnectors }?: GetGroupedConnectorsParams): GroupedConnector[];
|
|
876
509
|
/**
|
|
877
|
-
*
|
|
510
|
+
* Checks whether any adapter has at least one connector.
|
|
511
|
+
*
|
|
512
|
+
* @param connectors - Connectors by adapter.
|
|
513
|
+
* @returns `true` when one of the arrays is not empty.
|
|
878
514
|
*/
|
|
879
515
|
declare function hasAvailableConnectors(connectors: Partial<Record<OrbitAdapter, Connector[]>>): boolean;
|
|
880
516
|
|
|
517
|
+
/**
|
|
518
|
+
* Parameters of {@link getFilteredConnectors}.
|
|
519
|
+
*/
|
|
881
520
|
interface GetFilteredConnectorsParams {
|
|
521
|
+
/** Connectors by adapter, as `getConnectors()` of the Satellite store returns them */
|
|
882
522
|
connectors: Partial<Record<OrbitAdapter, Connector[]>>;
|
|
523
|
+
/** Keeps only the wallets (and their connectors) of this adapter */
|
|
883
524
|
selectedAdapter?: OrbitAdapter;
|
|
884
525
|
}
|
|
885
526
|
/**
|
|
886
|
-
*
|
|
887
|
-
*
|
|
888
|
-
* that support the specified adapter if one is provided.
|
|
527
|
+
* Groups the connectors by wallet with {@link getGroupedConnectors} (without the generic `injected` connector) and
|
|
528
|
+
* keeps the wallets of the selected adapter, with only the connectors of that adapter.
|
|
889
529
|
*
|
|
890
|
-
* @param params
|
|
891
|
-
* @returns
|
|
530
|
+
* @param params - See {@link GetFilteredConnectorsParams}.
|
|
531
|
+
* @returns The wallets sorted by name (all of them when `selectedAdapter` is not set).
|
|
892
532
|
*/
|
|
893
533
|
declare function getFilteredConnectors({ connectors, selectedAdapter, }: GetFilteredConnectorsParams): GroupedConnector[];
|
|
894
534
|
/**
|
|
895
|
-
*
|
|
896
|
-
*/
|
|
897
|
-
declare function hasConnectorsForAdapter(connectors: Partial<Record<OrbitAdapter, Connector[]>>, adapter: OrbitAdapter): boolean;
|
|
898
|
-
|
|
899
|
-
/**
|
|
900
|
-
* @fileoverview Central export hub for blockchain utility functions and types.
|
|
901
|
-
*
|
|
902
|
-
* This module provides a unified interface for accessing blockchain-related utilities,
|
|
903
|
-
* offering both synchronous and asynchronous versions of functions to support different
|
|
904
|
-
* usage patterns and performance requirements.
|
|
535
|
+
* Checks whether an adapter has at least one connector.
|
|
905
536
|
*
|
|
906
|
-
*
|
|
907
|
-
*
|
|
908
|
-
*
|
|
909
|
-
* - Adapter management functions for system control
|
|
910
|
-
* - Type exports for TypeScript integration
|
|
911
|
-
*
|
|
912
|
-
* @example
|
|
913
|
-
* ```typescript
|
|
914
|
-
* // Import synchronous version (backward compatible)
|
|
915
|
-
* import { getChainsListByConnectorType, isEvmChainList } from './utils';
|
|
916
|
-
*
|
|
917
|
-
* // Import asynchronous version (better performance)
|
|
918
|
-
* import {
|
|
919
|
-
* getChainsListByWalletTypeAsync,
|
|
920
|
-
* isEvmChainListAsync
|
|
921
|
-
* } from './utils';
|
|
922
|
-
*
|
|
923
|
-
* // Import adapter management
|
|
924
|
-
* import { preloadChainAdapters, getAdapterStatus } from './utils';
|
|
925
|
-
*
|
|
926
|
-
* // Import types
|
|
927
|
-
* import type { ChainAdapter, AdapterLoadStatus } from './utils';
|
|
928
|
-
* ```
|
|
929
|
-
*
|
|
930
|
-
* @since 1.0.0
|
|
931
|
-
*/
|
|
932
|
-
/**
|
|
933
|
-
* Re-export all functions from the main chain utilities module.
|
|
934
|
-
* This includes both sync and async versions with proper naming.
|
|
537
|
+
* @param connectors - Connectors by adapter.
|
|
538
|
+
* @param adapter - The adapter to check.
|
|
539
|
+
* @returns `true` when `connectors[adapter]` is a non-empty array.
|
|
935
540
|
*/
|
|
541
|
+
declare function hasConnectorsForAdapter(connectors: Partial<Record<OrbitAdapter, Connector[]>>, adapter: OrbitAdapter): boolean;
|
|
936
542
|
|
|
937
|
-
|
|
938
|
-
* Synchronous fallback for getting available Solana clusters.
|
|
939
|
-
*
|
|
940
|
-
* This function provides immediate results but with limited functionality.
|
|
941
|
-
* It serves as a compatibility layer for synchronous contexts where the
|
|
942
|
-
* async version cannot be used.
|
|
943
|
-
*
|
|
944
|
-
* @returns Empty array with warning (use async version for real results)
|
|
945
|
-
*
|
|
946
|
-
* @example
|
|
947
|
-
* ```typescript
|
|
948
|
-
* // Synchronous fallback (limited functionality)
|
|
949
|
-
* const clusters = getAvailableSolanaClusters(); // []
|
|
950
|
-
*
|
|
951
|
-
* // Preferred async version (full functionality)
|
|
952
|
-
* const clustersAsync = await getAvailableSolanaClustersAsync();
|
|
953
|
-
* ```
|
|
954
|
-
*
|
|
955
|
-
* @since 1.0.0
|
|
956
|
-
* @deprecated Use getAvailableSolanaClustersAsync for full functionality
|
|
957
|
-
*/
|
|
958
|
-
declare function getAvailableSolanaClusters(): string[];
|
|
959
|
-
/**
|
|
960
|
-
* Synchronous fallback for Solana cluster validation.
|
|
961
|
-
*
|
|
962
|
-
* This function provides basic validation against known cluster names but
|
|
963
|
-
* lacks the comprehensive validation logic of the async version. It performs
|
|
964
|
-
* a simple lookup against standard Solana cluster monikers.
|
|
965
|
-
*
|
|
966
|
-
* @param cluster - Cluster name to validate
|
|
967
|
-
* @returns True if cluster name matches known standard clusters
|
|
968
|
-
*
|
|
969
|
-
* @example
|
|
970
|
-
* ```typescript
|
|
971
|
-
* // Synchronous fallback (basic validation)
|
|
972
|
-
* const isValid = isValidSolanaCluster('mainnet-beta'); // true
|
|
973
|
-
* const isCustom = isValidSolanaCluster('custom-cluster'); // false
|
|
974
|
-
*
|
|
975
|
-
* // Preferred async version (comprehensive validation)
|
|
976
|
-
* const isValidAsync = await isValidSolanaClusterAsync('custom-cluster');
|
|
977
|
-
* ```
|
|
978
|
-
*
|
|
979
|
-
* @since 1.0.0
|
|
980
|
-
* @deprecated Use isValidSolanaClusterAsync for comprehensive validation
|
|
981
|
-
*/
|
|
982
|
-
declare function isValidSolanaCluster(cluster: string): boolean;
|
|
983
|
-
|
|
984
|
-
/**
|
|
985
|
-
* Information about available blockchain-specific utilities and their status.
|
|
986
|
-
*
|
|
987
|
-
* @interface BlockchainUtilities
|
|
988
|
-
* @since 1.0.0
|
|
989
|
-
*
|
|
990
|
-
* @example
|
|
991
|
-
* ```typescript
|
|
992
|
-
* const utilities = await getBlockchainUtilities();
|
|
993
|
-
*
|
|
994
|
-
* if (utilities.hasEvmUtils) {
|
|
995
|
-
* console.log('EVM utilities are available');
|
|
996
|
-
* }
|
|
997
|
-
*
|
|
998
|
-
* console.log('Adapter statuses:', utilities.adaptersStatus);
|
|
999
|
-
* ```
|
|
1000
|
-
*/
|
|
1001
|
-
interface BlockchainUtilities {
|
|
1002
|
-
/** Whether EVM utilities are available and loaded */
|
|
1003
|
-
hasEvmUtils: boolean;
|
|
1004
|
-
/** Whether Solana utilities are available and loaded */
|
|
1005
|
-
hasSolanaUtils: boolean;
|
|
1006
|
-
/** Current loading status of all registered adapters */
|
|
1007
|
-
adaptersStatus: Record<string, string>;
|
|
1008
|
-
}
|
|
1009
|
-
/**
|
|
1010
|
-
* Gets comprehensive information about available blockchain utilities and their loading status.
|
|
1011
|
-
* This function dynamically checks which blockchain adapters are available and their current state.
|
|
1012
|
-
*
|
|
1013
|
-
* @returns Promise resolving to blockchain utilities information
|
|
1014
|
-
*
|
|
1015
|
-
* @example
|
|
1016
|
-
* ```typescript
|
|
1017
|
-
* // Check what's available in your current setup
|
|
1018
|
-
* const info = await getBlockchainUtilities();
|
|
1019
|
-
*
|
|
1020
|
-
* if (info.hasEvmUtils && info.hasSolanaUtils) {
|
|
1021
|
-
* console.log('Full multi-chain support available');
|
|
1022
|
-
* } else {
|
|
1023
|
-
* console.log('Limited blockchain support:', info.adaptersStatus);
|
|
1024
|
-
* }
|
|
1025
|
-
* ```
|
|
1026
|
-
*
|
|
1027
|
-
* @since 1.0.0
|
|
1028
|
-
*/
|
|
1029
|
-
declare function getBlockchainUtilities(): Promise<BlockchainUtilities>;
|
|
1030
|
-
/**
|
|
1031
|
-
* Result type for blockchain utility loading operations.
|
|
1032
|
-
*
|
|
1033
|
-
* @template T The type of utilities being loaded
|
|
1034
|
-
*
|
|
1035
|
-
* @since 1.0.0
|
|
1036
|
-
*/
|
|
1037
|
-
type BlockchainUtilityResult<T = any> = ({
|
|
1038
|
-
available: true;
|
|
1039
|
-
} & T) | {
|
|
1040
|
-
available: false;
|
|
1041
|
-
error: string;
|
|
1042
|
-
};
|
|
1043
|
-
/**
|
|
1044
|
-
* Dynamically loads EVM utilities if available in the current environment.
|
|
1045
|
-
* Returns the utilities along with their availability status.
|
|
1046
|
-
*
|
|
1047
|
-
* @returns Promise resolving to EVM utilities or error information
|
|
1048
|
-
*
|
|
1049
|
-
* @example
|
|
1050
|
-
* ```typescript
|
|
1051
|
-
* const evmUtils = await getEvmUtils();
|
|
1052
|
-
*
|
|
1053
|
-
* if (evmUtils.available) {
|
|
1054
|
-
* // Use EVM-specific functions
|
|
1055
|
-
* const chains = evmUtils.getEvmChains(appChains);
|
|
1056
|
-
* console.log('Available EVM chains:', chains);
|
|
1057
|
-
* } else {
|
|
1058
|
-
* console.warn('EVM not supported:', evmUtils.error);
|
|
1059
|
-
* }
|
|
1060
|
-
* ```
|
|
1061
|
-
*
|
|
1062
|
-
* @since 1.0.0
|
|
1063
|
-
*/
|
|
1064
|
-
declare function getEvmUtils(): Promise<BlockchainUtilityResult>;
|
|
1065
|
-
/**
|
|
1066
|
-
* Dynamically loads Solana utilities if available in the current environment.
|
|
1067
|
-
* Returns the utilities along with their availability status.
|
|
1068
|
-
*
|
|
1069
|
-
* @returns Promise resolving to Solana utilities or error information
|
|
1070
|
-
*
|
|
1071
|
-
* @example
|
|
1072
|
-
* ```typescript
|
|
1073
|
-
* const solanaUtils = await getSolanaUtils();
|
|
1074
|
-
*
|
|
1075
|
-
* if (solanaUtils.available) {
|
|
1076
|
-
* // Use Solana-specific functions
|
|
1077
|
-
* const clusters = solanaUtils.getSolanaClusters(rpcUrls);
|
|
1078
|
-
* console.log('Available Solana clusters:', clusters);
|
|
1079
|
-
* } else {
|
|
1080
|
-
* console.warn('Solana not supported:', solanaUtils.error);
|
|
1081
|
-
* }
|
|
1082
|
-
* ```
|
|
1083
|
-
*
|
|
1084
|
-
* @since 1.0.0
|
|
1085
|
-
*/
|
|
1086
|
-
declare function getSolanaUtils(): Promise<BlockchainUtilityResult>;
|
|
1087
|
-
/**
|
|
1088
|
-
* Result of blockchain support initialization.
|
|
1089
|
-
*
|
|
1090
|
-
* @interface InitializationResult
|
|
1091
|
-
* @since 1.0.0
|
|
1092
|
-
*/
|
|
1093
|
-
interface InitializationResult {
|
|
1094
|
-
/** Whether EVM support was successfully initialized */
|
|
1095
|
-
evm: boolean;
|
|
1096
|
-
/** Whether Solana support was successfully initialized */
|
|
1097
|
-
solana: boolean;
|
|
1098
|
-
/** Array of error messages encountered during initialization */
|
|
1099
|
-
errors: string[];
|
|
1100
|
-
}
|
|
1101
|
-
/**
|
|
1102
|
-
* Preloads and initializes all available blockchain adapters.
|
|
1103
|
-
* This function should be called during application startup for optimal performance.
|
|
1104
|
-
* It attempts to load both EVM and Solana adapters and reports which ones are available.
|
|
1105
|
-
*
|
|
1106
|
-
* @returns Promise resolving to initialization results
|
|
1107
|
-
*
|
|
1108
|
-
* @example
|
|
1109
|
-
* ```typescript
|
|
1110
|
-
* // Call during app initialization
|
|
1111
|
-
* const initResult = await initializeBlockchainSupport();
|
|
1112
|
-
*
|
|
1113
|
-
* if (initResult.evm && initResult.solana) {
|
|
1114
|
-
* console.log('Full blockchain support initialized');
|
|
1115
|
-
* } else {
|
|
1116
|
-
* console.log('Partial support:', initResult);
|
|
1117
|
-
* if (initResult.errors.length > 0) {
|
|
1118
|
-
* console.warn('Initialization errors:', initResult.errors);
|
|
1119
|
-
* }
|
|
1120
|
-
* }
|
|
1121
|
-
* ```
|
|
1122
|
-
*
|
|
1123
|
-
* @since 1.0.0
|
|
1124
|
-
*/
|
|
1125
|
-
declare function initializeBlockchainSupport(): Promise<InitializationResult>;
|
|
1126
|
-
/**
|
|
1127
|
-
* Checks whether a specific blockchain adapter is supported in the current environment.
|
|
1128
|
-
* This function performs runtime checks to determine adapter availability.
|
|
1129
|
-
*
|
|
1130
|
-
* @param adapter The blockchain adapter to check for support
|
|
1131
|
-
* @returns Promise resolving to true if the adapter is supported
|
|
1132
|
-
*
|
|
1133
|
-
* @example
|
|
1134
|
-
* ```typescript
|
|
1135
|
-
* // Check individual adapter support
|
|
1136
|
-
* const evmSupported = await isAdapterSupported(OrbitAdapter.EVM);
|
|
1137
|
-
* const solanaSupported = await isAdapterSupported(OrbitAdapter.SOLANA);
|
|
1138
|
-
* const starknetSupported = await isAdapterSupported(OrbitAdapter.Starknet);
|
|
1139
|
-
*
|
|
1140
|
-
* console.log('Adapter support:', {
|
|
1141
|
-
* evm: evmSupported,
|
|
1142
|
-
* solana: solanaSupported,
|
|
1143
|
-
* starknet: starknetSupported, // Currently always false
|
|
1144
|
-
* });
|
|
1145
|
-
* ```
|
|
1146
|
-
*
|
|
1147
|
-
* @since 1.0.0
|
|
1148
|
-
*/
|
|
1149
|
-
declare function isAdapterSupported(adapter: OrbitAdapter): Promise<boolean>;
|
|
1150
|
-
|
|
1151
|
-
export { type AdapterInfo, type AdapterLoadStatus, type BlockchainUtilities, type BlockchainUtilityResult, ButtonTxStatus, type ChainAdapter, ConnectContentType, ConnectedContentType, ErrorsProvider, type ErrorsProviderCustomization, type ErrorsProviderProps, type GroupedConnector, InitialChains, type InitializationResult, NovaConnectLabelsProvider, NovaConnectProvider, type NovaConnectProviderCustomization, NovaConnectProviderProps, type NovaConnectProviderPropsWithCustomization, NovaConnectProviderType, getAdapterStatus, getAllAdaptersStatus, getAvailableChainIds, getAvailableSolanaClusters, getAvailableSolanaClusters$1 as getAvailableSolanaClustersAsync, getBlockchainUtilities, getChainsListByConnectorTypeSync as getChainsListByConnectorType, getChainsListByConnectorType as getChainsListByConnectorTypeAsync, getChainsListByConnectorTypeSync, getConnectChainId, getEvmUtils, getFilteredConnectors, getGroupedConnectors, getSolanaUtils, getWalletChains, hasAvailableConnectors, hasConnectorsForAdapter, initializeBlockchainSupport, isAdapterSupported, isEvmChainListSync as isEvmChainList, isEvmChainList as isEvmChainListAsync, isEvmChainListSync, isSolanaChainListSync as isSolanaChainList, isSolanaChainList as isSolanaChainListAsync, isSolanaChainListSync, isValidSolanaCluster, isValidSolanaCluster$1 as isValidSolanaClusterAsync, preloadChainAdapters };
|
|
543
|
+
export { ButtonTxStatus, ConnectContentType, ConnectedContentType, ErrorsProvider, type ErrorsProviderContainerProps, type ErrorsProviderCustomization, type ErrorsProviderProps, type ErrorsProviderToastErrorProps, type GetChainsListByConnectorTypeParams, type GetFilteredConnectorsParams, type GetGroupedConnectorsParams, type GroupedConnector, InitialChains, NovaConnectLabelsProvider, type NovaConnectLabelsProviderProps, NovaConnectProvider, type NovaConnectProviderCustomization, type NovaConnectProviderCustomizationContext, type NovaConnectProviderErrorsProviderProps, type NovaConnectProviderLabelsProviderProps, NovaConnectProviderProps, type NovaConnectProviderPropsWithCustomization, NovaConnectProviderType, getAvailableChainIds, getChainsListByConnectorType, getConnectChainId, getFilteredConnectors, getGroupedConnectors, getWalletChains, hasAvailableConnectors, hasConnectorsForAdapter, isEvmChainList, isSolanaChainList };
|