@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
|
@@ -0,0 +1,918 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default, { ComponentPropsWithoutRef, ComponentType, ReactNode } from 'react';
|
|
3
|
+
import { OrbitAdapter } from '@tuwaio/orbit-core';
|
|
4
|
+
import { TransactionPool, Transaction, TxAdapter } from '@tuwaio/pulsar-core';
|
|
5
|
+
import { N as NovaConnectLabels } from './types-CnOiSyvZ.js';
|
|
6
|
+
import { SatelliteSiwxFieldOptions, UseSiwxSignInOptions } from '@tuwaio/siwx-react';
|
|
7
|
+
import { Variants, Easing } from 'framer-motion';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Chain configuration types of the networks the app imports. Importing `@tuwaio/nova-connect/evm` adds `appChains`
|
|
11
|
+
* (the viem chains of your wagmi config, `readonly [Chain, ...Chain[]]`); importing `@tuwaio/nova-connect/solana` adds
|
|
12
|
+
* `solanaRPCUrls` (`Partial<Record<SolanaClusterMoniker, string>>` from `@tuwaio/orbit-solana`). Read the resulting
|
|
13
|
+
* types through {@link NovaConnectAppChains} and {@link NovaConnectSolanaRPCUrls}.
|
|
14
|
+
*/
|
|
15
|
+
interface NovaConnectChainConfigTypes {
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Type of `appChains`: the viem chains (`readonly [Chain, ...Chain[]]`) when `@tuwaio/nova-connect/evm` is imported,
|
|
19
|
+
* otherwise a list of objects with a numeric `id` (a list of viem chains fits too).
|
|
20
|
+
*/
|
|
21
|
+
type NovaConnectAppChains = NovaConnectChainConfigTypes extends {
|
|
22
|
+
appChains: infer T;
|
|
23
|
+
} ? T : readonly {
|
|
24
|
+
readonly id: number;
|
|
25
|
+
}[];
|
|
26
|
+
/**
|
|
27
|
+
* Type of `solanaRPCUrls`: an RPC URL for each cluster moniker (`Partial<Record<SolanaClusterMoniker, string>>`) when
|
|
28
|
+
* `@tuwaio/nova-connect/solana` is imported, otherwise an RPC URL for each cluster name.
|
|
29
|
+
*/
|
|
30
|
+
type NovaConnectSolanaRPCUrls = NovaConnectChainConfigTypes extends {
|
|
31
|
+
solanaRPCUrls: infer T;
|
|
32
|
+
} ? T : Readonly<Partial<Record<string, string>>>;
|
|
33
|
+
/**
|
|
34
|
+
* Chain configuration of the app, passed to `NovaConnectProvider` as `appChains` and `solanaRPCUrls`. The provider
|
|
35
|
+
* renders the connect and connected modals only when at least one of them is set, and a wallet connects to the first
|
|
36
|
+
* EVM chain or the first Solana cluster of these lists.
|
|
37
|
+
*/
|
|
38
|
+
interface AllChainConfigs {
|
|
39
|
+
/** EVM chains of the app, the viem chains of your wagmi config. See {@link NovaConnectAppChains}. */
|
|
40
|
+
appChains?: NovaConnectAppChains;
|
|
41
|
+
/**
|
|
42
|
+
* Solana RPC URL for each cluster moniker, for example `{ devnet: 'https://api.devnet.solana.com' }`. See
|
|
43
|
+
* {@link NovaConnectSolanaRPCUrls}.
|
|
44
|
+
*/
|
|
45
|
+
solanaRPCUrls?: NovaConnectSolanaRPCUrls;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Alias of {@link AllChainConfigs}.
|
|
49
|
+
*/
|
|
50
|
+
type InitialChains = AllChainConfigs;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @file ConnectedModalTxHistory component with comprehensive customization options for transaction history display.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Local mirror of TxInMemoryPagination from @tuwaio/pulsar-core.
|
|
58
|
+
* Defined inline because pulsar-core is an optional peer dependency in nova-connect.
|
|
59
|
+
*/
|
|
60
|
+
type LocalTxPagination = {
|
|
61
|
+
/** Indicates whether the store is currently loading transaction history. */
|
|
62
|
+
isLoading: boolean;
|
|
63
|
+
/** Indicates whether the last loading request ended with an error. */
|
|
64
|
+
isError: boolean;
|
|
65
|
+
/** Indicates whether more history pages are available. */
|
|
66
|
+
hasMore: boolean;
|
|
67
|
+
/** The current page number in the paginated history. */
|
|
68
|
+
currentPage: number;
|
|
69
|
+
/**
|
|
70
|
+
* Loads the next page of transaction history and appends it to the pool.
|
|
71
|
+
*
|
|
72
|
+
* @param walletAddress - The address whose history is loaded.
|
|
73
|
+
* @returns Resolves when the page is loaded.
|
|
74
|
+
*/
|
|
75
|
+
fetchNextPage: (walletAddress: string) => Promise<void>;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Local customization options for TransactionsHistory component.
|
|
79
|
+
* This is a copy of the type from @tuwaio/nova-transactions to avoid
|
|
80
|
+
* breaking dynamic import logic.
|
|
81
|
+
*/
|
|
82
|
+
type LocalTransactionsHistoryCustomization = {
|
|
83
|
+
/** Custom title for the transactions history section */
|
|
84
|
+
title?: string;
|
|
85
|
+
/** Custom class name generators */
|
|
86
|
+
classNames?: {
|
|
87
|
+
/** Classes for the outer container */
|
|
88
|
+
container?: string;
|
|
89
|
+
/** Classes for the title element */
|
|
90
|
+
titleText?: string;
|
|
91
|
+
/** Classes for the list wrapper container */
|
|
92
|
+
listWrapper?: string;
|
|
93
|
+
/** Classes for the placeholder container */
|
|
94
|
+
placeholderContainer?: string;
|
|
95
|
+
/** Classes for the placeholder title */
|
|
96
|
+
placeholderTitle?: string;
|
|
97
|
+
/** Classes for the placeholder message */
|
|
98
|
+
placeholderMessage?: string;
|
|
99
|
+
/** Classes for the infinite scroll loader container */
|
|
100
|
+
loaderContainer?: string;
|
|
101
|
+
/** Classes for the infinite scroll loader icon (spinner) */
|
|
102
|
+
loaderIcon?: string;
|
|
103
|
+
/** Classes for the error indicator container */
|
|
104
|
+
errorContainer?: string;
|
|
105
|
+
/** Classes for the error indicator icon */
|
|
106
|
+
errorIcon?: string;
|
|
107
|
+
/** Classes for individual transaction item container */
|
|
108
|
+
itemContainer?: string;
|
|
109
|
+
/** Classes for the icon wrapper */
|
|
110
|
+
itemIconWrapper?: string;
|
|
111
|
+
/** Classes for the icon itself */
|
|
112
|
+
itemIcon?: string;
|
|
113
|
+
/** Classes for the content wrapper */
|
|
114
|
+
itemContentWrapper?: string;
|
|
115
|
+
/** Classes for the title text */
|
|
116
|
+
itemTitle?: string;
|
|
117
|
+
/** Classes for the timestamp text */
|
|
118
|
+
itemTimestamp?: string;
|
|
119
|
+
/** Classes for the description text */
|
|
120
|
+
itemDescription?: string;
|
|
121
|
+
/** Classes for the status badge container */
|
|
122
|
+
itemStatusBadge?: string;
|
|
123
|
+
/** Classes for the status badge icon */
|
|
124
|
+
itemStatusBadgeIcon?: string;
|
|
125
|
+
/** Classes for the status badge label */
|
|
126
|
+
itemStatusBadgeLabel?: string;
|
|
127
|
+
/** Classes for the transaction key container */
|
|
128
|
+
itemTxKeyContainer?: string;
|
|
129
|
+
/** Classes for the default hash link label */
|
|
130
|
+
itemHashLabel?: string;
|
|
131
|
+
/** Classes for the default hash link */
|
|
132
|
+
itemHashLink?: string;
|
|
133
|
+
/** Classes for the default hash copy button */
|
|
134
|
+
itemHashCopyButton?: string;
|
|
135
|
+
/** Classes for the original hash link label (replaced transactions) */
|
|
136
|
+
itemOriginalHashLabel?: string;
|
|
137
|
+
/** Classes for the original hash link (replaced transactions) */
|
|
138
|
+
itemOriginalHashLink?: string;
|
|
139
|
+
/** Classes for the original hash copy button (replaced transactions) */
|
|
140
|
+
itemOriginalHashCopyButton?: string;
|
|
141
|
+
};
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Props for a custom loading state (shown while `@tuwaio/nova-transactions` loads).
|
|
145
|
+
*/
|
|
146
|
+
type ConnectedModalTxHistoryLoadingContainerProps = {
|
|
147
|
+
/** The Nova Connect labels */
|
|
148
|
+
labels: Record<string, string>;
|
|
149
|
+
/** Classes from `classNames.loadingContainer` */
|
|
150
|
+
className?: string;
|
|
151
|
+
/** Granular classNames for sub-elements */
|
|
152
|
+
classNames?: {
|
|
153
|
+
/** From `classNames.loadingSpinner` */
|
|
154
|
+
spinner?: string;
|
|
155
|
+
/** From `classNames.loadingText` */
|
|
156
|
+
text?: string;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* Props for a custom error state (shown when `@tuwaio/nova-transactions` cannot be loaded or its component throws).
|
|
161
|
+
*/
|
|
162
|
+
type ConnectedModalTxHistoryErrorContainerProps = {
|
|
163
|
+
/** Classes from `classNames.errorContainer` */
|
|
164
|
+
className?: string;
|
|
165
|
+
/** Granular classNames for sub-elements */
|
|
166
|
+
classNames?: {
|
|
167
|
+
/** From `classNames.errorIconContainer` */
|
|
168
|
+
iconContainer?: string;
|
|
169
|
+
/** From `classNames.errorIcon` */
|
|
170
|
+
icon?: string;
|
|
171
|
+
/** From `classNames.errorContent` */
|
|
172
|
+
content?: string;
|
|
173
|
+
/** From `classNames.errorTitle` */
|
|
174
|
+
title?: string;
|
|
175
|
+
/** From `classNames.errorDescription` */
|
|
176
|
+
description?: string;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
/**
|
|
180
|
+
* Props for a custom state without a connected wallet.
|
|
181
|
+
*/
|
|
182
|
+
type ConnectedModalTxHistoryNoWalletContainerProps = {
|
|
183
|
+
/** Classes from `classNames.noWalletContainer` */
|
|
184
|
+
className?: string;
|
|
185
|
+
/** Granular classNames for sub-elements */
|
|
186
|
+
classNames?: {
|
|
187
|
+
/** From `classNames.noWalletText` */
|
|
188
|
+
text?: string;
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Props for a custom wrapper of the `TransactionsHistory` of `@tuwaio/nova-transactions`.
|
|
193
|
+
*/
|
|
194
|
+
type ConnectedModalTxHistoryTransactionsHistoryWrapperProps = {
|
|
195
|
+
/** The transaction history */
|
|
196
|
+
children: ReactNode;
|
|
197
|
+
/** The active address */
|
|
198
|
+
activeConnectionAddress: string;
|
|
199
|
+
/** The `transactionPool` prop */
|
|
200
|
+
transactionPool: NonNullable<NovaConnectProviderProps['transactionPool']>;
|
|
201
|
+
/** The `pulsarAdapter` prop */
|
|
202
|
+
pulsarAdapter: NonNullable<NovaConnectProviderProps['pulsarAdapter']>;
|
|
203
|
+
/** The Nova Connect labels */
|
|
204
|
+
labels: Record<string, string>;
|
|
205
|
+
/** Classes from `classNames.transactionsHistoryWrapper` */
|
|
206
|
+
className?: string;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
209
|
+
* Customization options of {@link ConnectedModalTxHistory}.
|
|
210
|
+
*/
|
|
211
|
+
type ConnectedModalTxHistoryCustomization = {
|
|
212
|
+
/** Props of the container (the component props, `className` and `aria-label` take precedence) */
|
|
213
|
+
containerProps?: Partial<Omit<ComponentPropsWithoutRef<'div'>, 'popover' | 'onDrag' | 'onDragEnd' | 'onDragExit' | 'onDragStart' | 'onDragStartCapture' | 'onAnimationStart' | 'onAnimationEnd' | 'onAnimationStartCapture' | 'onAnimationEndCapture' | 'onAnimationIteration' | 'onAnimationIterationCapture'>>;
|
|
214
|
+
/** Custom components */
|
|
215
|
+
components?: {
|
|
216
|
+
/** Custom loading container component */
|
|
217
|
+
LoadingContainer?: ComponentType<ConnectedModalTxHistoryLoadingContainerProps>;
|
|
218
|
+
/** Custom error container component */
|
|
219
|
+
ErrorContainer?: ComponentType<ConnectedModalTxHistoryErrorContainerProps>;
|
|
220
|
+
/** Custom no wallet container component */
|
|
221
|
+
NoWalletContainer?: ComponentType<ConnectedModalTxHistoryNoWalletContainerProps>;
|
|
222
|
+
/** Custom transactions history wrapper component */
|
|
223
|
+
TransactionsHistoryWrapper?: ComponentType<ConnectedModalTxHistoryTransactionsHistoryWrapperProps>;
|
|
224
|
+
};
|
|
225
|
+
/** Custom class name generators */
|
|
226
|
+
classNames?: {
|
|
227
|
+
/**
|
|
228
|
+
* Returns the classes of the container, instead of the default ones and the `className` prop.
|
|
229
|
+
*
|
|
230
|
+
* @param params - The state.
|
|
231
|
+
* @param params.hasActiveWallet - Whether a wallet is connected.
|
|
232
|
+
* @param params.hasValidAdapter - Whether `transactionPool` and `pulsarAdapter` are set.
|
|
233
|
+
* @returns The classes.
|
|
234
|
+
*/
|
|
235
|
+
container?: (params: {
|
|
236
|
+
hasActiveWallet: boolean;
|
|
237
|
+
hasValidAdapter: boolean;
|
|
238
|
+
}) => string;
|
|
239
|
+
/**
|
|
240
|
+
* Returns classes of the loading state, added to the default ones.
|
|
241
|
+
*
|
|
242
|
+
* @returns The classes.
|
|
243
|
+
*/
|
|
244
|
+
loadingContainer?: () => string;
|
|
245
|
+
/**
|
|
246
|
+
* Returns classes of the loading spinner, added to the default ones.
|
|
247
|
+
*
|
|
248
|
+
* @returns The classes.
|
|
249
|
+
*/
|
|
250
|
+
loadingSpinner?: () => string;
|
|
251
|
+
/**
|
|
252
|
+
* Returns classes of the loading text, added to the default ones.
|
|
253
|
+
*
|
|
254
|
+
* @returns The classes.
|
|
255
|
+
*/
|
|
256
|
+
loadingText?: () => string;
|
|
257
|
+
/**
|
|
258
|
+
* Returns classes of the error state, added to the default ones.
|
|
259
|
+
*
|
|
260
|
+
* @returns The classes.
|
|
261
|
+
*/
|
|
262
|
+
errorContainer?: () => string;
|
|
263
|
+
/**
|
|
264
|
+
* Returns classes of the error icon container, added to the default ones.
|
|
265
|
+
*
|
|
266
|
+
* @returns The classes.
|
|
267
|
+
*/
|
|
268
|
+
errorIconContainer?: () => string;
|
|
269
|
+
/**
|
|
270
|
+
* Returns classes of the error icon, added to the default ones.
|
|
271
|
+
*
|
|
272
|
+
* @returns The classes.
|
|
273
|
+
*/
|
|
274
|
+
errorIcon?: () => string;
|
|
275
|
+
/**
|
|
276
|
+
* Returns classes of the error texts, added to the default ones.
|
|
277
|
+
*
|
|
278
|
+
* @returns The classes.
|
|
279
|
+
*/
|
|
280
|
+
errorContent?: () => string;
|
|
281
|
+
/**
|
|
282
|
+
* Returns classes of the error title, added to the default ones.
|
|
283
|
+
*
|
|
284
|
+
* @returns The classes.
|
|
285
|
+
*/
|
|
286
|
+
errorTitle?: () => string;
|
|
287
|
+
/**
|
|
288
|
+
* Returns classes of the error description, added to the default ones.
|
|
289
|
+
*
|
|
290
|
+
* @returns The classes.
|
|
291
|
+
*/
|
|
292
|
+
errorDescription?: () => string;
|
|
293
|
+
/**
|
|
294
|
+
* Returns classes of the state without a wallet, added to the default ones.
|
|
295
|
+
*
|
|
296
|
+
* @returns The classes.
|
|
297
|
+
*/
|
|
298
|
+
noWalletContainer?: () => string;
|
|
299
|
+
/**
|
|
300
|
+
* Returns classes of the text without a wallet, added to the default ones.
|
|
301
|
+
*
|
|
302
|
+
* @returns The classes.
|
|
303
|
+
*/
|
|
304
|
+
noWalletText?: () => string;
|
|
305
|
+
/**
|
|
306
|
+
* Returns classes of the "Pulsar adapter required" state, instead of the default ones.
|
|
307
|
+
*
|
|
308
|
+
* @returns The classes.
|
|
309
|
+
*/
|
|
310
|
+
pulsarRequiredContainer?: () => string;
|
|
311
|
+
/**
|
|
312
|
+
* Returns classes of its icon container, instead of the default ones.
|
|
313
|
+
*
|
|
314
|
+
* @returns The classes.
|
|
315
|
+
*/
|
|
316
|
+
pulsarRequiredIconContainer?: () => string;
|
|
317
|
+
/**
|
|
318
|
+
* Returns classes of its icon, instead of the default ones.
|
|
319
|
+
*
|
|
320
|
+
* @returns The classes.
|
|
321
|
+
*/
|
|
322
|
+
pulsarRequiredIcon?: () => string;
|
|
323
|
+
/**
|
|
324
|
+
* Returns classes of its texts, instead of the default ones.
|
|
325
|
+
*
|
|
326
|
+
* @returns The classes.
|
|
327
|
+
*/
|
|
328
|
+
pulsarRequiredContent?: () => string;
|
|
329
|
+
/**
|
|
330
|
+
* Returns classes of its title, instead of the default ones.
|
|
331
|
+
*
|
|
332
|
+
* @returns The classes.
|
|
333
|
+
*/
|
|
334
|
+
pulsarRequiredTitle?: () => string;
|
|
335
|
+
/**
|
|
336
|
+
* Returns classes of its description, instead of the default ones.
|
|
337
|
+
*
|
|
338
|
+
* @returns The classes.
|
|
339
|
+
*/
|
|
340
|
+
pulsarRequiredDescription?: () => string;
|
|
341
|
+
/**
|
|
342
|
+
* Returns classes of the transaction history wrapper, added to the default ones.
|
|
343
|
+
*
|
|
344
|
+
* @returns The classes.
|
|
345
|
+
*/
|
|
346
|
+
transactionsHistoryWrapper?: () => string;
|
|
347
|
+
};
|
|
348
|
+
/** Custom animation variants */
|
|
349
|
+
variants?: {
|
|
350
|
+
/** Container animation variants (`initial`, `animate`, `exit`) */
|
|
351
|
+
container?: Variants;
|
|
352
|
+
/** Variants of the "Pulsar adapter required" state */
|
|
353
|
+
error?: Variants;
|
|
354
|
+
};
|
|
355
|
+
/** Custom animation configuration */
|
|
356
|
+
animation?: {
|
|
357
|
+
/** Container animation configuration */
|
|
358
|
+
container?: {
|
|
359
|
+
/** Animation duration in seconds */
|
|
360
|
+
duration?: number;
|
|
361
|
+
/** Animation easing curve */
|
|
362
|
+
ease?: Easing | Easing[];
|
|
363
|
+
/** Animation delay in seconds */
|
|
364
|
+
delay?: number;
|
|
365
|
+
};
|
|
366
|
+
/** Animation of the "Pulsar adapter required" state */
|
|
367
|
+
error?: {
|
|
368
|
+
/** Animation duration in seconds */
|
|
369
|
+
duration?: number;
|
|
370
|
+
/** Animation easing curve */
|
|
371
|
+
ease?: Easing | Easing[];
|
|
372
|
+
/** Animation delay in seconds */
|
|
373
|
+
delay?: number;
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
/** Custom event handlers */
|
|
377
|
+
handlers?: {
|
|
378
|
+
/**
|
|
379
|
+
* Called when `@tuwaio/nova-transactions` fails to load or its `TransactionsHistory` throws.
|
|
380
|
+
*
|
|
381
|
+
* @param packageName - `config.packageName`.
|
|
382
|
+
* @param error - The error.
|
|
383
|
+
*/
|
|
384
|
+
onPackageLoadingFailure?: (packageName: string, error: Error) => void;
|
|
385
|
+
};
|
|
386
|
+
/** Configuration options */
|
|
387
|
+
config?: {
|
|
388
|
+
/** Renders without Framer Motion (default: `false`) */
|
|
389
|
+
disableAnimation?: boolean;
|
|
390
|
+
/** Same as `disableAnimation` (default: `false`) */
|
|
391
|
+
reduceMotion?: boolean;
|
|
392
|
+
/** Name passed to `handlers.onPackageLoadingFailure` (default: `@tuwaio/nova-transactions`) */
|
|
393
|
+
packageName?: string;
|
|
394
|
+
/** Custom aria labels for different states */
|
|
395
|
+
ariaLabels?: {
|
|
396
|
+
/** ARIA label of the container, after the `aria-label` prop (default: the `transactionsInApp` label) */
|
|
397
|
+
transactionsHistory?: string;
|
|
398
|
+
};
|
|
399
|
+
};
|
|
400
|
+
/**
|
|
401
|
+
* Customization for the TransactionsHistory component (from @tuwaio/nova-transactions).
|
|
402
|
+
* Passed through to the dynamically loaded component.
|
|
403
|
+
*/
|
|
404
|
+
transactionsHistory?: LocalTransactionsHistoryCustomization;
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* Props for the {@link ConnectedModalTxHistory} component. Without `transactionPool` and `pulsarAdapter` (Pulsar)
|
|
408
|
+
* the "Pulsar adapter required" state is shown. Other props are passed to the container.
|
|
409
|
+
*/
|
|
410
|
+
interface ConnectedModalTxHistoryProps extends Pick<NovaConnectProviderProps, 'transactionPool' | 'pulsarAdapter'> {
|
|
411
|
+
/** Classes added to the default container classes (ignored when `classNames.container` is set) */
|
|
412
|
+
className?: string;
|
|
413
|
+
/** ARIA label of the container (default: the `transactionsInApp` label) */
|
|
414
|
+
'aria-label'?: string;
|
|
415
|
+
/** Customization options */
|
|
416
|
+
customization?: ConnectedModalTxHistoryCustomization;
|
|
417
|
+
/** Pagination state for infinite scroll, forwarded to TransactionsHistory. */
|
|
418
|
+
pagination?: LocalTxPagination;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* The transaction history screen of the connected modal: the `TransactionsHistory` of `@tuwaio/nova-transactions`
|
|
422
|
+
* for the active address (loaded with a dynamic import, without the details view). Shows a loading state while the
|
|
423
|
+
* package loads, an error state when it cannot be loaded, a "Pulsar adapter required" state without
|
|
424
|
+
* `transactionPool` and `pulsarAdapter`, and a message without a connected wallet.
|
|
425
|
+
*
|
|
426
|
+
* Props: {@link ConnectedModalTxHistoryProps}; the ref is forwarded to the container.
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* ```tsx
|
|
430
|
+
* import { ConnectedModalTxHistory } from '@tuwaio/nova-connect/components';
|
|
431
|
+
* import type { NovaConnectProviderProps } from '@tuwaio/nova-connect/hooks';
|
|
432
|
+
*
|
|
433
|
+
* type HistoryProps = Pick<NovaConnectProviderProps, 'transactionPool' | 'pulsarAdapter'>;
|
|
434
|
+
*
|
|
435
|
+
* export function History({ transactionPool, pulsarAdapter }: HistoryProps) {
|
|
436
|
+
* return (
|
|
437
|
+
* <ConnectedModalTxHistory
|
|
438
|
+
* transactionPool={transactionPool}
|
|
439
|
+
* pulsarAdapter={pulsarAdapter}
|
|
440
|
+
* customization={{
|
|
441
|
+
* classNames: { loadingContainer: () => 'bg-blue-100' },
|
|
442
|
+
* handlers: {
|
|
443
|
+
* onPackageLoadingFailure: (packageName, error) => console.error(packageName, error),
|
|
444
|
+
* },
|
|
445
|
+
* }}
|
|
446
|
+
* />
|
|
447
|
+
* );
|
|
448
|
+
* }
|
|
449
|
+
* ```
|
|
450
|
+
*/
|
|
451
|
+
declare const ConnectedModalTxHistory: React__default.ForwardRefExoticComponent<ConnectedModalTxHistoryProps & React__default.RefAttributes<HTMLDivElement>>;
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* @file Headless SIWX auto-authentication watcher for NovaConnect.
|
|
455
|
+
* Monitors active wallet connections and automatically triggers SIWX signing prompts.
|
|
456
|
+
*/
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Props of {@link NovaSiwxWatcher} (the `siwx` prop of `NovaConnectProvider`): the sign-in callbacks and the SIWX
|
|
460
|
+
* message fields of `getSatelliteSiwxFields` from `@tuwaio/siwx-react` (`domain`, `uri`, `statement`, and so on).
|
|
461
|
+
*/
|
|
462
|
+
interface NovaSiwxWatcherProps extends SatelliteSiwxFieldOptions {
|
|
463
|
+
/** Whether to ask connected wallets to sign in (default: `true`) */
|
|
464
|
+
enabled?: boolean;
|
|
465
|
+
/** Fetches the nonce of the SIWX message from your backend */
|
|
466
|
+
getNonce?: () => Promise<string>;
|
|
467
|
+
/** Verifies the signed message on your backend (required for the sign-in) */
|
|
468
|
+
verifier?: UseSiwxSignInOptions['verifier'];
|
|
469
|
+
/**
|
|
470
|
+
* Optional callback triggered when the wallet disconnects or when `signOut` is called.
|
|
471
|
+
* Useful for hitting a `/logout` endpoint to clear the backend cookie.
|
|
472
|
+
*/
|
|
473
|
+
destroyer?: () => Promise<void>;
|
|
474
|
+
/** Optional callback triggered immediately after successful SIWX authentication */
|
|
475
|
+
onSuccess?: UseSiwxSignInOptions['onSuccess'];
|
|
476
|
+
/** Optional callback triggered if SIWX signing or verification fails */
|
|
477
|
+
onError?: UseSiwxSignInOptions['onError'];
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Signs the connected wallet in with SIWX. `NovaConnectProvider` renders it with its `siwx` prop, so apps do not
|
|
481
|
+
* render it themselves. It renders nothing.
|
|
482
|
+
*
|
|
483
|
+
* - When a wallet connects (or the account changes), it asks the wallet to sign a SIWX message once per address
|
|
484
|
+
* (`signIn` of `useSiwx` from `@tuwaio/siwx-react`: a wallet prompt, then `getNonce` and `verifier` requests to your
|
|
485
|
+
* backend). A rejected or failed sign-in disconnects that wallet (if it is still the active one) and calls
|
|
486
|
+
* `onError`. Without `verifier` it logs a warning and does not sign in.
|
|
487
|
+
* - When no wallet is connected, it clears the SIWX session and calls `destroyer`. After a page load it waits until
|
|
488
|
+
* Satellite Connect has finished reconnecting (`isAutoConnectFinished`), so the session restored by
|
|
489
|
+
* `@tuwaio/siwx-react` is kept.
|
|
490
|
+
*
|
|
491
|
+
* @param props - See {@link NovaSiwxWatcherProps}.
|
|
492
|
+
* @returns `null`.
|
|
493
|
+
*/
|
|
494
|
+
declare function NovaSiwxWatcher(props: NovaSiwxWatcherProps): null;
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Status of the latest transaction of the active wallet, shown by the connect button: `loading` while it is pending,
|
|
498
|
+
* then `succeed`, `failed` or `replaced`, and `idle` otherwise.
|
|
499
|
+
*/
|
|
500
|
+
type ButtonTxStatus = 'idle' | 'loading' | 'succeed' | 'failed' | 'replaced';
|
|
501
|
+
/**
|
|
502
|
+
* Screen of the connect modal: `connectors` (wallet list), `network` (network choice of a multi-network wallet),
|
|
503
|
+
* `connecting`, `about` ("About wallets"), `getWallet` ("Get a wallet") or `impersonate` (impersonation form).
|
|
504
|
+
*/
|
|
505
|
+
type ConnectContentType = 'network' | 'connectors' | 'about' | 'getWallet' | 'connecting' | 'impersonate';
|
|
506
|
+
/**
|
|
507
|
+
* Screen of the connected modal: `main`, `transactions` (history), `chains` (network switch) or `connections`
|
|
508
|
+
* (connected and recent wallets).
|
|
509
|
+
*/
|
|
510
|
+
type ConnectedContentType = 'main' | 'transactions' | 'chains' | 'connections';
|
|
511
|
+
/** Legal configuration for Terms of Service and Privacy Policy links */
|
|
512
|
+
interface LegalConfig {
|
|
513
|
+
/** URL of the terms of service */
|
|
514
|
+
termsUrl?: string;
|
|
515
|
+
/** URL of the privacy policy */
|
|
516
|
+
privacyUrl?: string;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Props of `NovaConnectProvider`. `appChains` and `solanaRPCUrls` give the chains of the app; without both, the
|
|
520
|
+
* modals are not rendered.
|
|
521
|
+
*/
|
|
522
|
+
interface NovaConnectProviderProps extends InitialChains {
|
|
523
|
+
/** Transaction pool of Pulsar: the connect button shows the status of the latest transaction of the wallet */
|
|
524
|
+
transactionPool?: TransactionPool<Transaction>;
|
|
525
|
+
/** Pulsar adapter(s); with `transactionPool`, the connected modal shows the transaction history */
|
|
526
|
+
pulsarAdapter?: TxAdapter<Transaction> | TxAdapter<Transaction>[];
|
|
527
|
+
/** Whether the connect button shows the native balance */
|
|
528
|
+
withBalance?: boolean;
|
|
529
|
+
/** Whether the connect button shows a chain selector */
|
|
530
|
+
withChain?: boolean;
|
|
531
|
+
/** Whether the wallet list offers the impersonated wallet (a read-only address, for development) */
|
|
532
|
+
withImpersonated?: boolean;
|
|
533
|
+
/** Wallet names of the "Popular" group, in order (default: WalletConnect, Porto, Coinbase, Gemini) */
|
|
534
|
+
popularConnectors?: string[];
|
|
535
|
+
/** Extra wallet groups of the wallet list: group title → wallet names, in order */
|
|
536
|
+
customConnectorGroups?: Record<string, string[]>;
|
|
537
|
+
/** Legal configuration for Terms of Service and Privacy Policy links */
|
|
538
|
+
legal?: LegalConfig;
|
|
539
|
+
/**
|
|
540
|
+
* SIWX sign-in of the connected wallet (see `NovaSiwxWatcher`). Without it, Nova Connect does not sign in and does
|
|
541
|
+
* not touch the SIWX session.
|
|
542
|
+
*/
|
|
543
|
+
siwx?: NovaSiwxWatcherProps;
|
|
544
|
+
/**
|
|
545
|
+
* Pagination state for infinite scroll, forwarded to ConnectedModalTxHistory and TransactionsHistory.
|
|
546
|
+
* Mirrors TxInMemoryPagination from @tuwaio/pulsar-core (optional peer dependency).
|
|
547
|
+
*/
|
|
548
|
+
pagination?: LocalTxPagination;
|
|
549
|
+
/** The app */
|
|
550
|
+
children: React.ReactNode;
|
|
551
|
+
/** Texts to override, merged over the English defaults */
|
|
552
|
+
labels?: Partial<NovaConnectLabels>;
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* A native balance.
|
|
556
|
+
*/
|
|
557
|
+
interface WalletBalance {
|
|
558
|
+
/** Formatted amount */
|
|
559
|
+
value: string;
|
|
560
|
+
/** Currency symbol */
|
|
561
|
+
symbol: string;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* State of `NovaConnectProvider`, returned by {@link useNovaConnect}: the provider props (without `siwx` and
|
|
565
|
+
* `pagination`, which are not set) and the UI state of the modals, kept in React state of the provider.
|
|
566
|
+
*/
|
|
567
|
+
interface NovaConnectProviderType extends Omit<NovaConnectProviderProps, 'pulsarAdapter' | 'children' | 'labels' | 'transactionPool'> {
|
|
568
|
+
/** Whether the connect modal is open */
|
|
569
|
+
isConnectModalOpen: boolean;
|
|
570
|
+
/**
|
|
571
|
+
* Opens or closes the connect modal (opening resets it to the wallet list).
|
|
572
|
+
*
|
|
573
|
+
* @param value - Whether the modal is open.
|
|
574
|
+
*/
|
|
575
|
+
setIsConnectModalOpen: (value: boolean) => void;
|
|
576
|
+
/** Whether the connected modal is open */
|
|
577
|
+
isConnectedModalOpen: boolean;
|
|
578
|
+
/**
|
|
579
|
+
* Opens or closes the connected modal (opening shows the main screen).
|
|
580
|
+
*
|
|
581
|
+
* @param value - Whether the modal is open.
|
|
582
|
+
*/
|
|
583
|
+
setIsConnectedModalOpen: (value: boolean) => void;
|
|
584
|
+
/** Whether the chain list of `ChainSelector` is open (desktop) */
|
|
585
|
+
isChainsListOpen: boolean;
|
|
586
|
+
/**
|
|
587
|
+
* Opens or closes the chain list of `ChainSelector` (desktop).
|
|
588
|
+
*
|
|
589
|
+
* @param value - Whether the list is open.
|
|
590
|
+
*/
|
|
591
|
+
setIsChainsListOpen: (value: boolean) => void;
|
|
592
|
+
/** Whether the chain dialog of `ChainSelector` is open (mobile) */
|
|
593
|
+
isChainsListOpenMobile: boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Opens or closes the chain dialog of `ChainSelector` (mobile).
|
|
596
|
+
*
|
|
597
|
+
* @param value - Whether the dialog is open.
|
|
598
|
+
*/
|
|
599
|
+
setIsChainsListOpenMobile: (value: boolean) => void;
|
|
600
|
+
/** Status of the latest transaction shown by the connect button */
|
|
601
|
+
connectedButtonStatus: ButtonTxStatus;
|
|
602
|
+
/**
|
|
603
|
+
* Sets the transaction status of the connect button.
|
|
604
|
+
*
|
|
605
|
+
* @param value - The status.
|
|
606
|
+
*/
|
|
607
|
+
setConnectedButtonStatus: (value: ButtonTxStatus) => void;
|
|
608
|
+
/** Whether a wallet has just connected in the connect modal (`true` for 500 ms before the modal closes) */
|
|
609
|
+
isConnected: boolean;
|
|
610
|
+
/**
|
|
611
|
+
* Sets the "just connected" state of the connect modal.
|
|
612
|
+
*
|
|
613
|
+
* @param value - The state.
|
|
614
|
+
*/
|
|
615
|
+
setIsConnected: (value: boolean) => void;
|
|
616
|
+
/** Screen of the connected modal */
|
|
617
|
+
connectedModalContentType: ConnectedContentType;
|
|
618
|
+
/**
|
|
619
|
+
* Shows a screen of the connected modal.
|
|
620
|
+
*
|
|
621
|
+
* @param value - The screen.
|
|
622
|
+
*/
|
|
623
|
+
setConnectedModalContentType: (value: ConnectedContentType) => void;
|
|
624
|
+
/** Screen of the connect modal */
|
|
625
|
+
connectModalContentType: ConnectContentType;
|
|
626
|
+
/**
|
|
627
|
+
* Shows a screen of the connect modal.
|
|
628
|
+
*
|
|
629
|
+
* @param value - The screen.
|
|
630
|
+
*/
|
|
631
|
+
setConnectModalContentType: (value: ConnectContentType) => void;
|
|
632
|
+
/** Network selected in the connect modal (`undefined` for all networks) */
|
|
633
|
+
selectedAdapter: OrbitAdapter | undefined;
|
|
634
|
+
/**
|
|
635
|
+
* Selects a network in the connect modal.
|
|
636
|
+
*
|
|
637
|
+
* @param value - The network, or `undefined` for all networks.
|
|
638
|
+
*/
|
|
639
|
+
setSelectedAdapter: (value: OrbitAdapter | undefined) => void;
|
|
640
|
+
/** Wallet selected in the connect modal, as `formatConnectorName` of `@tuwaio/orbit-core` returns it */
|
|
641
|
+
activeConnector: string | undefined;
|
|
642
|
+
/**
|
|
643
|
+
* Selects a wallet in the connect modal.
|
|
644
|
+
*
|
|
645
|
+
* @param value - The formatted wallet name.
|
|
646
|
+
*/
|
|
647
|
+
setActiveConnector: (value: string | undefined) => void;
|
|
648
|
+
/** Address entered in the impersonation form */
|
|
649
|
+
impersonatedAddress: string;
|
|
650
|
+
/**
|
|
651
|
+
* Sets the impersonated address of the connect modal (it is saved to `localStorage` only on connect).
|
|
652
|
+
*
|
|
653
|
+
* @param value - The address.
|
|
654
|
+
*/
|
|
655
|
+
setImpersonatedAddress: (value: string) => void;
|
|
656
|
+
/** The `legal` prop */
|
|
657
|
+
legal?: LegalConfig;
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Thrown by {@link useNovaConnect} outside `NovaConnectProvider`.
|
|
661
|
+
*/
|
|
662
|
+
declare class NovaConnectProviderError extends Error {
|
|
663
|
+
/**
|
|
664
|
+
* @param message - The error message (default: `useNovaConnect must be used within NovaConnectProvider`).
|
|
665
|
+
*/
|
|
666
|
+
constructor(message?: string);
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* React context of `NovaConnectProvider` (`undefined` outside the provider). Read it with {@link useNovaConnect}.
|
|
670
|
+
*/
|
|
671
|
+
declare const NovaConnectProviderContext: React$1.Context<NovaConnectProviderType | undefined>;
|
|
672
|
+
/**
|
|
673
|
+
* Returns the state of `NovaConnectProvider`: the modal states and their setters, the selected network and wallet,
|
|
674
|
+
* and the provider options.
|
|
675
|
+
*
|
|
676
|
+
* @returns The provider state.
|
|
677
|
+
* @throws {@link NovaConnectProviderError} When used outside `NovaConnectProvider`.
|
|
678
|
+
*
|
|
679
|
+
* @example
|
|
680
|
+
* ```tsx
|
|
681
|
+
* import { useNovaConnect } from '@tuwaio/nova-connect/hooks';
|
|
682
|
+
*
|
|
683
|
+
* export function OpenWalletButton() {
|
|
684
|
+
* const { setIsConnectModalOpen } = useNovaConnect();
|
|
685
|
+
*
|
|
686
|
+
* return <button onClick={() => setIsConnectModalOpen(true)}>Connect Wallet</button>;
|
|
687
|
+
* }
|
|
688
|
+
* ```
|
|
689
|
+
*/
|
|
690
|
+
declare const useNovaConnect: () => NovaConnectProviderType;
|
|
691
|
+
/**
|
|
692
|
+
* Checks whether the component is inside `NovaConnectProvider`.
|
|
693
|
+
*
|
|
694
|
+
* @returns `true` inside the provider.
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
* ```tsx
|
|
698
|
+
* import { useHasNovaConnectContext } from '@tuwaio/nova-connect/hooks';
|
|
699
|
+
*
|
|
700
|
+
* export function ProviderCheck() {
|
|
701
|
+
* const hasContext = useHasNovaConnectContext();
|
|
702
|
+
*
|
|
703
|
+
* return <p>{hasContext ? 'Nova Connect is ready' : 'NovaConnectProvider not found'}</p>;
|
|
704
|
+
* }
|
|
705
|
+
* ```
|
|
706
|
+
*/
|
|
707
|
+
declare const useHasNovaConnectContext: () => boolean;
|
|
708
|
+
/**
|
|
709
|
+
* Like {@link useNovaConnect}, but returns `null` outside `NovaConnectProvider` instead of throwing.
|
|
710
|
+
*
|
|
711
|
+
* @returns The provider state, or `null`.
|
|
712
|
+
*
|
|
713
|
+
* @example
|
|
714
|
+
* ```tsx
|
|
715
|
+
* import { useNovaConnectOptional } from '@tuwaio/nova-connect/hooks';
|
|
716
|
+
*
|
|
717
|
+
* export function OptionalOpenButton() {
|
|
718
|
+
* const context = useNovaConnectOptional();
|
|
719
|
+
*
|
|
720
|
+
* if (!context) return null;
|
|
721
|
+
* return <button onClick={() => context.setIsConnectModalOpen(true)}>Connect Wallet</button>;
|
|
722
|
+
* }
|
|
723
|
+
* ```
|
|
724
|
+
*/
|
|
725
|
+
declare const useNovaConnectOptional: () => NovaConnectProviderType | null;
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* React context of the Nova Connect labels. Its default value is the English `defaultLabels`, so components work
|
|
729
|
+
* without a labels provider. `NovaConnectProvider` provides the merged labels.
|
|
730
|
+
*/
|
|
731
|
+
declare const NovaConnectLabelsContext: React$1.Context<NovaConnectLabels>;
|
|
732
|
+
/**
|
|
733
|
+
* Returns the Nova Connect labels: the ones of the nearest labels provider (`NovaConnectProvider` provides the
|
|
734
|
+
* `labels` prop merged into the defaults), or the English defaults.
|
|
735
|
+
*
|
|
736
|
+
* @returns All labels.
|
|
737
|
+
*
|
|
738
|
+
* @example
|
|
739
|
+
* ```tsx
|
|
740
|
+
* import { useNovaConnectLabels } from '@tuwaio/nova-connect/hooks';
|
|
741
|
+
*
|
|
742
|
+
* export function Title() {
|
|
743
|
+
* const labels = useNovaConnectLabels();
|
|
744
|
+
*
|
|
745
|
+
* return <h2>{labels.connectWallet}</h2>;
|
|
746
|
+
* }
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
declare const useNovaConnectLabels: () => NovaConnectLabels;
|
|
750
|
+
/**
|
|
751
|
+
* Returns one label.
|
|
752
|
+
*
|
|
753
|
+
* @param key - The label key.
|
|
754
|
+
* @returns The label text.
|
|
755
|
+
*
|
|
756
|
+
* @example
|
|
757
|
+
* ```tsx
|
|
758
|
+
* import { useNovaConnectLabel } from '@tuwaio/nova-connect/hooks';
|
|
759
|
+
*
|
|
760
|
+
* export function ConnectText() {
|
|
761
|
+
* return <span>{useNovaConnectLabel('connectWallet')}</span>;
|
|
762
|
+
* }
|
|
763
|
+
* ```
|
|
764
|
+
*/
|
|
765
|
+
declare const useNovaConnectLabel: <K extends keyof NovaConnectLabels>(key: K) => NovaConnectLabels[K];
|
|
766
|
+
/**
|
|
767
|
+
* Returns the given labels. It reads all labels, so it re-renders like {@link useNovaConnectLabels}.
|
|
768
|
+
*
|
|
769
|
+
* @param keys - The label keys.
|
|
770
|
+
* @returns An object with the requested labels.
|
|
771
|
+
*
|
|
772
|
+
* @example
|
|
773
|
+
* ```tsx
|
|
774
|
+
* import { useNovaConnectLabelsSubset } from '@tuwaio/nova-connect/hooks';
|
|
775
|
+
*
|
|
776
|
+
* export function Actions() {
|
|
777
|
+
* const { connect, disconnect } = useNovaConnectLabelsSubset(['connect', 'disconnect']);
|
|
778
|
+
*
|
|
779
|
+
* return (
|
|
780
|
+
* <p>
|
|
781
|
+
* {connect} / {disconnect}
|
|
782
|
+
* </p>
|
|
783
|
+
* );
|
|
784
|
+
* }
|
|
785
|
+
* ```
|
|
786
|
+
*/
|
|
787
|
+
declare const useNovaConnectLabelsSubset: <K extends keyof NovaConnectLabels>(keys: K[]) => Pick<NovaConnectLabels, K>;
|
|
788
|
+
/**
|
|
789
|
+
* Checks whether a label is set and not blank.
|
|
790
|
+
*
|
|
791
|
+
* @param labels - The labels.
|
|
792
|
+
* @param key - The label key.
|
|
793
|
+
* @returns `true` when the trimmed label is not empty.
|
|
794
|
+
*/
|
|
795
|
+
declare const hasLabel: (labels: NovaConnectLabels, key: keyof NovaConnectLabels) => boolean;
|
|
796
|
+
/**
|
|
797
|
+
* Label keys by category, used by {@link useLabelsByCategory}.
|
|
798
|
+
*/
|
|
799
|
+
type LabelCategory = {
|
|
800
|
+
/** Action texts such as `connectWallet` and `disconnect` */
|
|
801
|
+
actions: Extract<keyof NovaConnectLabels, 'connectWallet' | 'disconnect' | 'connecting' | 'connected' | 'tryAgain' | 'back' | 'connect'>;
|
|
802
|
+
/** State texts such as `success` and `loading` */
|
|
803
|
+
states: Extract<keyof NovaConnectLabels, 'success' | 'error' | 'replaced' | 'loading'>;
|
|
804
|
+
/** ARIA labels such as `closeModal` */
|
|
805
|
+
accessibility: Extract<keyof NovaConnectLabels, 'chainSelector' | 'closeModal' | 'selectChain' | 'walletControls' | 'openWalletModal'>;
|
|
806
|
+
/** Transaction status texts */
|
|
807
|
+
transactions: Extract<keyof NovaConnectLabels, 'transactionLoading' | 'transactionSuccess' | 'transactionError' | 'transactionReplaced' | 'recent'>;
|
|
808
|
+
};
|
|
809
|
+
/**
|
|
810
|
+
* Returns the labels of a category of {@link LabelCategory}.
|
|
811
|
+
*
|
|
812
|
+
* @param category - The category.
|
|
813
|
+
* @returns An object with the labels of the category.
|
|
814
|
+
*
|
|
815
|
+
* @example
|
|
816
|
+
* ```tsx
|
|
817
|
+
* import { useLabelsByCategory } from '@tuwaio/nova-connect/hooks';
|
|
818
|
+
*
|
|
819
|
+
* export function StateText() {
|
|
820
|
+
* const { loading } = useLabelsByCategory('states');
|
|
821
|
+
*
|
|
822
|
+
* return <span>{loading}</span>;
|
|
823
|
+
* }
|
|
824
|
+
* ```
|
|
825
|
+
*/
|
|
826
|
+
declare const useLabelsByCategory: <T extends keyof LabelCategory>(category: T) => Pick<NovaConnectLabels, LabelCategory[T]>;
|
|
827
|
+
/**
|
|
828
|
+
* Checks whether an object is the `defaultLabels` object itself (a copy with the same texts returns `false`).
|
|
829
|
+
*
|
|
830
|
+
* @param labels - The labels.
|
|
831
|
+
* @returns `true` for the `defaultLabels` object.
|
|
832
|
+
*/
|
|
833
|
+
declare const isDefaultLabels: (labels: NovaConnectLabels) => boolean;
|
|
834
|
+
/**
|
|
835
|
+
* Returns a label, or a fallback when it is blank: the `fallback` argument, the English default, then the key.
|
|
836
|
+
*
|
|
837
|
+
* @param labels - The labels.
|
|
838
|
+
* @param key - The label key.
|
|
839
|
+
* @param fallback - Text used when the label is blank.
|
|
840
|
+
* @returns The text.
|
|
841
|
+
*
|
|
842
|
+
* @example
|
|
843
|
+
* ```ts
|
|
844
|
+
* import { defaultLabels } from '@tuwaio/nova-connect/i18n';
|
|
845
|
+
* import { getLabelWithFallback } from '@tuwaio/nova-connect/hooks';
|
|
846
|
+
*
|
|
847
|
+
* getLabelWithFallback({ ...defaultLabels, connectWallet: '' }, 'connectWallet', 'Connect'); // 'Connect'
|
|
848
|
+
* ```
|
|
849
|
+
*/
|
|
850
|
+
declare const getLabelWithFallback: (labels: NovaConnectLabels, key: keyof NovaConnectLabels, fallback?: string) => string;
|
|
851
|
+
/**
|
|
852
|
+
* Returns the given labels of a labels object (usable outside React components).
|
|
853
|
+
*
|
|
854
|
+
* @param labels - The labels.
|
|
855
|
+
* @param keys - The label keys.
|
|
856
|
+
* @returns An object with the requested labels.
|
|
857
|
+
*
|
|
858
|
+
* @example
|
|
859
|
+
* ```ts
|
|
860
|
+
* import { defaultLabels } from '@tuwaio/nova-connect/i18n';
|
|
861
|
+
* import { createLabelsSubset } from '@tuwaio/nova-connect/hooks';
|
|
862
|
+
*
|
|
863
|
+
* const actionLabels = createLabelsSubset(defaultLabels, ['connect', 'disconnect', 'tryAgain']);
|
|
864
|
+
* ```
|
|
865
|
+
*/
|
|
866
|
+
declare const createLabelsSubset: <K extends keyof NovaConnectLabels>(labels: NovaConnectLabels, keys: K[]) => Pick<NovaConnectLabels, K>;
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* A native balance returned by `getBalance` of a Satellite adapter.
|
|
870
|
+
*/
|
|
871
|
+
interface NativeBalanceResult {
|
|
872
|
+
/** The balance formatted with the decimals of the token (for example `1.5`) */
|
|
873
|
+
value: string;
|
|
874
|
+
/** The token symbol (for example `ETH`) */
|
|
875
|
+
symbol: string;
|
|
876
|
+
}
|
|
877
|
+
/**
|
|
878
|
+
* The balance of {@link useWalletNativeBalance}, or `null` when it is not known.
|
|
879
|
+
*/
|
|
880
|
+
type UseWalletNativeBalanceState = NativeBalanceResult | null;
|
|
881
|
+
/**
|
|
882
|
+
* Result of {@link useWalletNativeBalance}.
|
|
883
|
+
*/
|
|
884
|
+
interface UseWalletNativeBalanceData {
|
|
885
|
+
/** The balance, or `null` without a wallet, without `getBalance` or before it resolves */
|
|
886
|
+
balance: UseWalletNativeBalanceState;
|
|
887
|
+
/** Whether the balance is being requested */
|
|
888
|
+
isLoading: boolean;
|
|
889
|
+
/** Requests the balance again (a failed refresh clears the kept balance) */
|
|
890
|
+
refetch: () => void;
|
|
891
|
+
}
|
|
892
|
+
/**
|
|
893
|
+
* Returns the native balance of the active wallet on its chain, from `getBalance` of its Satellite adapter (an RPC
|
|
894
|
+
* request). Each balance is kept in memory for the address and chain while the component is mounted, so switching
|
|
895
|
+
* back does not request it again; `refetch` requests it again.
|
|
896
|
+
*
|
|
897
|
+
* @returns See {@link UseWalletNativeBalanceData}.
|
|
898
|
+
*
|
|
899
|
+
* @example
|
|
900
|
+
* ```tsx
|
|
901
|
+
* import { useWalletNativeBalance } from '@tuwaio/nova-connect/hooks';
|
|
902
|
+
*
|
|
903
|
+
* export function NativeBalance() {
|
|
904
|
+
* const { balance, isLoading, refetch } = useWalletNativeBalance();
|
|
905
|
+
*
|
|
906
|
+
* if (isLoading) return <p>Loading balance...</p>;
|
|
907
|
+
*
|
|
908
|
+
* return (
|
|
909
|
+
* <p>
|
|
910
|
+
* {balance ? `${balance.value} ${balance.symbol}` : 'n/a'} <button onClick={refetch}>Refresh</button>
|
|
911
|
+
* </p>
|
|
912
|
+
* );
|
|
913
|
+
* }
|
|
914
|
+
* ```
|
|
915
|
+
*/
|
|
916
|
+
declare function useWalletNativeBalance(): UseWalletNativeBalanceData;
|
|
917
|
+
|
|
918
|
+
export { type AllChainConfigs as A, type ButtonTxStatus as B, type ConnectContentType as C, ConnectedModalTxHistory as D, type ConnectedModalTxHistoryErrorContainerProps as E, type ConnectedModalTxHistoryLoadingContainerProps as F, type ConnectedModalTxHistoryNoWalletContainerProps as G, type ConnectedModalTxHistoryProps as H, type InitialChains as I, type ConnectedModalTxHistoryTransactionsHistoryWrapperProps as J, type LocalTransactionsHistoryCustomization as K, type LabelCategory as L, type LocalTxPagination as M, type NovaConnectProviderProps as N, type UseWalletNativeBalanceData as U, type WalletBalance as W, type ConnectedContentType as a, type NovaConnectProviderType as b, type LegalConfig as c, type NativeBalanceResult as d, type NovaConnectAppChains as e, type NovaConnectChainConfigTypes as f, NovaConnectLabelsContext as g, NovaConnectProviderContext as h, NovaConnectProviderError as i, type NovaConnectSolanaRPCUrls as j, NovaSiwxWatcher as k, type NovaSiwxWatcherProps as l, type UseWalletNativeBalanceState as m, createLabelsSubset as n, getLabelWithFallback as o, hasLabel as p, isDefaultLabels as q, useLabelsByCategory as r, useNovaConnect as s, useNovaConnectLabel as t, useHasNovaConnectContext as u, useNovaConnectLabels as v, useNovaConnectLabelsSubset as w, useNovaConnectOptional as x, useWalletNativeBalance as y, type ConnectedModalTxHistoryCustomization as z };
|