@tuwaio/nova-transactions 0.0.18 → 0.0.19
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 +1 -2
- package/dist/{WalletInfoModal-CLj_wBQ8.d.cts → WalletInfoModal-BMSFI1JW.d.cts} +64 -55
- package/dist/{WalletInfoModal-CLj_wBQ8.d.ts → WalletInfoModal-BMSFI1JW.d.ts} +64 -55
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/providers/index.cjs +1 -1
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.d.cts +2 -2
- package/dist/providers/index.d.ts +2 -2
- package/dist/providers/index.js +1 -1
- package/dist/providers/index.js.map +1 -1
- package/package.json +5 -5
@@ -62,7 +62,8 @@ declare function StatusAwareText({ txStatus, source, fallback, variant, classNam
|
|
62
62
|
* It provides a strict structure for all text used in the UI components, ensuring type safety for different languages.
|
63
63
|
*/
|
64
64
|
/**
|
65
|
-
*
|
65
|
+
* Represents the set of labels used for various UI elements and features in a Tuwa-based application.
|
66
|
+
* This type defines structured labels for wallet modals, transaction statuses, toast notifications, and more.
|
66
67
|
*/
|
67
68
|
type TuwaLabels = {
|
68
69
|
/** Labels for the main wallet information modal. */
|
@@ -107,6 +108,8 @@ type TuwaLabels = {
|
|
107
108
|
replaced: string;
|
108
109
|
/** Text for an unknown or indeterminate status. */
|
109
110
|
unknown: string;
|
111
|
+
/** Text for a confirmation count label, e.g., "1 confirmation" or "10 confirmations" */
|
112
|
+
confirmationsLabel: string;
|
110
113
|
};
|
111
114
|
/** Labels for different types of transaction hashes/keys. */
|
112
115
|
hashLabels: {
|
@@ -120,6 +123,10 @@ type TuwaLabels = {
|
|
120
123
|
replaced: string;
|
121
124
|
/** Default label for a standard transaction hash. */
|
122
125
|
default: string;
|
126
|
+
/** Special label for the most recent blockhash. This is used for the "Recent Blockhash" field in the transaction details modal. */
|
127
|
+
recentBlockhash: string;
|
128
|
+
/** Special label for the Solana signature. This is used for the "Signature" field in the transaction details modal. */
|
129
|
+
solana: string;
|
123
130
|
};
|
124
131
|
/** Labels for the transaction information block. */
|
125
132
|
txInfo: {
|
@@ -127,6 +134,8 @@ type TuwaLabels = {
|
|
127
134
|
started: string;
|
128
135
|
/** Label for the network name. */
|
129
136
|
network: string;
|
137
|
+
/** Slot number for the transaction. This is used for the "Slot" field in the transaction details modal. */
|
138
|
+
slot: string;
|
130
139
|
};
|
131
140
|
/** Labels for the transaction error block. */
|
132
141
|
txError: {
|
@@ -186,11 +195,11 @@ type TuwaLabels = {
|
|
186
195
|
/**
|
187
196
|
* Defines the props for the NovaProvider component.
|
188
197
|
*/
|
189
|
-
type NovaProviderProps<
|
190
|
-
|
198
|
+
type NovaProviderProps<T extends Transaction> = {
|
199
|
+
adapter: TxAdapter<T> | TxAdapter<T>[];
|
191
200
|
connectedWalletAddress?: string;
|
192
201
|
connectedAdapterType?: TransactionAdapter;
|
193
|
-
transactionsPool: TransactionPool<
|
202
|
+
transactionsPool: TransactionPool<T>;
|
194
203
|
labels?: Partial<TuwaLabels>;
|
195
204
|
features?: {
|
196
205
|
toasts?: boolean;
|
@@ -198,16 +207,16 @@ type NovaProviderProps<TR, T extends Transaction<TR>, A> = {
|
|
198
207
|
trackingTxModal?: boolean;
|
199
208
|
};
|
200
209
|
customization?: {
|
201
|
-
toast?: ToastTransactionCustomization<
|
202
|
-
walletInfoModal?: WalletInfoModalCustomization<
|
203
|
-
trackingTxModal?: TrackingTxModalCustomization<
|
210
|
+
toast?: ToastTransactionCustomization<T>;
|
211
|
+
walletInfoModal?: WalletInfoModalCustomization<T>;
|
212
|
+
trackingTxModal?: TrackingTxModalCustomization<T>;
|
204
213
|
};
|
205
|
-
} & Pick<ITxTrackingStore<
|
214
|
+
} & Pick<ITxTrackingStore<T>, 'closeTxTrackedModal' | 'handleTransaction' | 'initialTx'> & ToastContainerProps;
|
206
215
|
/**
|
207
216
|
* The main component for the Nova UI ecosystem. It renders and orchestrates all
|
208
217
|
* UI elements like toasts and modals, and provides the i18n context.
|
209
218
|
*/
|
210
|
-
declare function NovaProvider<
|
219
|
+
declare function NovaProvider<T extends Transaction>({ adapter, connectedWalletAddress, connectedAdapterType, transactionsPool, initialTx, handleTransaction, closeTxTrackedModal, labels, features, customization, ...toastProps }: NovaProviderProps<T>): react_jsx_runtime.JSX.Element;
|
211
220
|
|
212
221
|
/**
|
213
222
|
* Defines the props for the TransactionKey component.
|
@@ -215,7 +224,7 @@ declare function NovaProvider<TR, T extends Transaction<TR>, A>({ adapters, conn
|
|
215
224
|
* @template T - The transaction type.
|
216
225
|
* @template A - The type of the key returned by an action function.
|
217
226
|
*/
|
218
|
-
type TransactionKeyProps<
|
227
|
+
type TransactionKeyProps<T extends Transaction> = Pick<NovaProviderProps<T>, 'adapter' | 'transactionsPool'> & {
|
219
228
|
/** The transaction object to display identifiers for. */
|
220
229
|
tx: T;
|
221
230
|
/** The visual variant, which applies different container styles. */
|
@@ -227,19 +236,21 @@ type TransactionKeyProps<TR, T extends Transaction<TR>, A> = Pick<NovaProviderPr
|
|
227
236
|
* If not provided, the default `HashLink` component will be used.
|
228
237
|
*/
|
229
238
|
renderHashLink?: (props: HashLinkProps) => ReactNode;
|
239
|
+
/** Optional number of confirmations for a transaction. */
|
240
|
+
confirmations?: number;
|
230
241
|
};
|
231
242
|
/**
|
232
243
|
* A component that intelligently displays the relevant keys and hashes for a transaction.
|
233
244
|
* It leverages the adapter system to show chain-specific identifiers and explorer links.
|
234
245
|
*/
|
235
|
-
declare function TransactionKey<
|
246
|
+
declare function TransactionKey<T extends Transaction>({ tx, adapter, transactionsPool, variant, className, renderHashLink, confirmations, }: TransactionKeyProps<T>): react_jsx_runtime.JSX.Element | null;
|
236
247
|
|
237
248
|
/**
|
238
249
|
* Defines the props for the TransactionStatusBadge component.
|
239
250
|
* @template TR - The type of the tracker identifier.
|
240
251
|
* @template T - The transaction type.
|
241
252
|
*/
|
242
|
-
type TransactionStatusBadgeProps<
|
253
|
+
type TransactionStatusBadgeProps<T extends Transaction> = {
|
243
254
|
/** The transaction object whose status will be displayed. */
|
244
255
|
tx: T;
|
245
256
|
/** Optional additional CSS classes to apply to the badge container. */
|
@@ -249,7 +260,7 @@ type TransactionStatusBadgeProps<TR, T extends Transaction<TR>> = {
|
|
249
260
|
* A component that displays a transaction's status as a styled badge
|
250
261
|
* with a corresponding icon, color, and label.
|
251
262
|
*/
|
252
|
-
declare function TransactionStatusBadge<
|
263
|
+
declare function TransactionStatusBadge<T extends Transaction>({ tx, className }: TransactionStatusBadgeProps<T>): react_jsx_runtime.JSX.Element;
|
253
264
|
|
254
265
|
/**
|
255
266
|
* @file This file contains the `ToastTransaction` component, which serves as the main body for a transaction notification toast.
|
@@ -259,30 +270,30 @@ type CustomActionButtonProps = {
|
|
259
270
|
onClick: () => void;
|
260
271
|
children: ReactNode;
|
261
272
|
};
|
262
|
-
type ToastTransactionCustomization<
|
273
|
+
type ToastTransactionCustomization<T extends Transaction> = {
|
263
274
|
components?: {
|
264
275
|
StatusAwareText?: ComponentType<StatusAwareTextProps>;
|
265
|
-
TransactionKey?: ComponentType<TransactionKeyProps<
|
266
|
-
StatusBadge?: ComponentType<TransactionStatusBadgeProps<
|
276
|
+
TransactionKey?: ComponentType<TransactionKeyProps<T>>;
|
277
|
+
StatusBadge?: ComponentType<TransactionStatusBadgeProps<T>>;
|
267
278
|
WalletInfoButton?: ComponentType<CustomActionButtonProps>;
|
268
279
|
SpeedUpButton?: ComponentType<CustomActionButtonProps>;
|
269
280
|
CancelButton?: ComponentType<CustomActionButtonProps>;
|
270
281
|
};
|
271
282
|
};
|
272
|
-
type ToastTransactionProps<
|
283
|
+
type ToastTransactionProps<T extends Transaction> = {
|
273
284
|
tx: T;
|
274
285
|
openWalletInfoModal?: () => void;
|
275
286
|
icon?: ReactNode;
|
276
287
|
className?: string;
|
277
|
-
customization?: ToastTransactionCustomization<
|
288
|
+
customization?: ToastTransactionCustomization<T>;
|
278
289
|
closeToast?: ToastContentProps['closeToast'];
|
279
290
|
toastProps?: ToastContainerProps;
|
280
|
-
} & Pick<NovaProviderProps<
|
291
|
+
} & Pick<NovaProviderProps<T>, 'transactionsPool' | 'adapter' | 'connectedWalletAddress'>;
|
281
292
|
/**
|
282
293
|
* A composite component that renders the content for a transaction toast notification.
|
283
294
|
* It is highly customizable and leverages the adapter to show relevant actions like "Speed Up".
|
284
295
|
*/
|
285
|
-
declare function ToastTransaction<
|
296
|
+
declare function ToastTransaction<T extends Transaction>({ openWalletInfoModal, tx, transactionsPool, icon, className, customization, connectedWalletAddress, adapter, }: ToastTransactionProps<T>): JSX.Element;
|
286
297
|
|
287
298
|
/**
|
288
299
|
* @file This file contains the `TxErrorBlock` component for displaying transaction error messages.
|
@@ -304,23 +315,23 @@ type CustomInfoRowProps = {
|
|
304
315
|
label: ReactNode;
|
305
316
|
value: ReactNode;
|
306
317
|
};
|
307
|
-
type TxInfoBlockCustomization<
|
318
|
+
type TxInfoBlockCustomization<T extends Transaction> = {
|
308
319
|
components?: {
|
309
320
|
InfoRow?: ComponentType<CustomInfoRowProps>;
|
310
|
-
transactionKey?: TransactionKeyProps<
|
321
|
+
transactionKey?: TransactionKeyProps<T>['renderHashLink'];
|
311
322
|
};
|
312
323
|
};
|
313
|
-
type TxInfoBlockProps<
|
324
|
+
type TxInfoBlockProps<T extends Transaction> = {
|
314
325
|
/** The transaction object to display, which can be a full transaction or an initial one. */
|
315
|
-
tx: T | InitialTransaction
|
326
|
+
tx: T | InitialTransaction;
|
316
327
|
className?: string;
|
317
|
-
customization?: TxInfoBlockCustomization<
|
318
|
-
} & Pick<NovaProviderProps<
|
328
|
+
customization?: TxInfoBlockCustomization<T>;
|
329
|
+
} & Pick<NovaProviderProps<T>, 'adapter' | 'transactionsPool'>;
|
319
330
|
/**
|
320
331
|
* A component that displays a block of essential transaction details,
|
321
|
-
* such as network,
|
332
|
+
* such as network, timestamps, Solana-specific details, and relevant hashes/keys.
|
322
333
|
*/
|
323
|
-
declare function TxInfoBlock<
|
334
|
+
declare function TxInfoBlock<T extends Transaction>({ tx, adapter, transactionsPool, className, customization, }: TxInfoBlockProps<T>): react_jsx_runtime.JSX.Element | null;
|
324
335
|
|
325
336
|
type StepStatus = 'active' | 'completed' | 'error' | 'inactive' | 'replaced';
|
326
337
|
type StepProps = {
|
@@ -376,7 +387,7 @@ type CustomFooterProps = {
|
|
376
387
|
canReplace?: boolean;
|
377
388
|
connectedWalletAddress?: string;
|
378
389
|
};
|
379
|
-
type TrackingTxModalCustomization<
|
390
|
+
type TrackingTxModalCustomization<T extends Transaction> = {
|
380
391
|
modalProps?: Partial<ComponentPropsWithoutRef<typeof Dialog.Content>>;
|
381
392
|
motionProps?: MotionProps;
|
382
393
|
components?: {
|
@@ -384,21 +395,21 @@ type TrackingTxModalCustomization<TR, T extends Transaction<TR>, A> = {
|
|
384
395
|
Footer?: ComponentType<CustomFooterProps>;
|
385
396
|
StatusVisual?: ComponentType<TxStatusVisualProps>;
|
386
397
|
ProgressIndicator?: ComponentType<TxProgressIndicatorProps>;
|
387
|
-
InfoBlock?: ComponentType<TxInfoBlockProps<
|
398
|
+
InfoBlock?: ComponentType<TxInfoBlockProps<T>>;
|
388
399
|
ErrorBlock?: ComponentType<TxErrorBlockProps>;
|
389
400
|
};
|
390
401
|
};
|
391
|
-
type TrackingTxModalProps<
|
402
|
+
type TrackingTxModalProps<T extends Transaction> = Pick<NovaProviderProps<T>, 'handleTransaction' | 'initialTx' | 'transactionsPool' | 'adapter' | 'connectedWalletAddress'> & {
|
392
403
|
onClose: (txKey?: string) => void;
|
393
404
|
onOpenWalletInfo: () => void;
|
394
405
|
className?: string;
|
395
|
-
customization?: TrackingTxModalCustomization<
|
406
|
+
customization?: TrackingTxModalCustomization<T>;
|
396
407
|
};
|
397
408
|
/**
|
398
409
|
* A detailed modal that displays the real-time status and lifecycle of a transaction.
|
399
410
|
* It opens automatically for transactions initiated with `withTrackedModal: true`.
|
400
411
|
*/
|
401
|
-
declare function TrackingTxModal<
|
412
|
+
declare function TrackingTxModal<T extends Transaction>({ adapter, onClose, onOpenWalletInfo, className, customization, transactionsPool, handleTransaction, initialTx, connectedWalletAddress, }: TrackingTxModalProps<T>): react_jsx_runtime.JSX.Element | null;
|
402
413
|
|
403
414
|
/**
|
404
415
|
* @file This file contains the `TransactionHistoryItem` component, which renders a single transaction
|
@@ -415,30 +426,30 @@ type CustomTimestampProps = {
|
|
415
426
|
* Defines the structure for the `customization` prop, allowing users to override
|
416
427
|
* default sub-components with their own implementations for a history item.
|
417
428
|
*/
|
418
|
-
type TransactionHistoryItemCustomization<
|
429
|
+
type TransactionHistoryItemCustomization<T extends Transaction> = {
|
419
430
|
components?: {
|
420
431
|
Icon?: ComponentType<CustomIconProps>;
|
421
432
|
Title?: ComponentType<StatusAwareTextProps>;
|
422
433
|
Description?: ComponentType<StatusAwareTextProps>;
|
423
434
|
Timestamp?: ComponentType<CustomTimestampProps>;
|
424
|
-
StatusBadge?: ComponentType<TransactionStatusBadgeProps<
|
425
|
-
TransactionKey?: ComponentType<TransactionKeyProps<
|
435
|
+
StatusBadge?: ComponentType<TransactionStatusBadgeProps<T>>;
|
436
|
+
TransactionKey?: ComponentType<TransactionKeyProps<T>>;
|
426
437
|
};
|
427
438
|
};
|
428
|
-
type TransactionHistoryItemProps<
|
439
|
+
type TransactionHistoryItemProps<T extends Transaction> = {
|
429
440
|
/** The transaction object to display. */
|
430
441
|
tx: T;
|
431
442
|
/** An object to customize and override the default internal components. */
|
432
|
-
customization?: TransactionHistoryItemCustomization<
|
443
|
+
customization?: TransactionHistoryItemCustomization<T>;
|
433
444
|
/** Optional additional CSS classes for the container. */
|
434
445
|
className?: string;
|
435
|
-
} & Pick<NovaProviderProps<
|
446
|
+
} & Pick<NovaProviderProps<T>, 'adapter' | 'transactionsPool'>;
|
436
447
|
/**
|
437
448
|
* A component that renders a single row in the transaction history list.
|
438
449
|
* It is highly customizable via the `customization` prop, allowing developers
|
439
450
|
* to override any of its internal parts with their own components.
|
440
451
|
*/
|
441
|
-
declare function TransactionHistoryItem<
|
452
|
+
declare function TransactionHistoryItem<T extends Transaction>({ tx, adapter, transactionsPool, className, customization, }: TransactionHistoryItemProps<T>): JSX.Element;
|
442
453
|
|
443
454
|
type CustomPlaceholderProps = {
|
444
455
|
title: string;
|
@@ -447,30 +458,28 @@ type CustomPlaceholderProps = {
|
|
447
458
|
/**
|
448
459
|
* Defines the customization options for the TransactionsHistory component.
|
449
460
|
*/
|
450
|
-
type TransactionsHistoryCustomization<
|
461
|
+
type TransactionsHistoryCustomization<T extends Transaction> = {
|
451
462
|
classNames?: {
|
452
463
|
listWrapper?: string;
|
453
464
|
};
|
454
465
|
components?: {
|
455
466
|
Placeholder?: ComponentType<CustomPlaceholderProps>;
|
456
|
-
HistoryItem?: ComponentType<TransactionHistoryItemProps<
|
467
|
+
HistoryItem?: ComponentType<TransactionHistoryItemProps<T>>;
|
457
468
|
};
|
458
469
|
};
|
459
470
|
/**
|
460
471
|
* Defines the props for the TransactionsHistory component.
|
461
|
-
* @template TR - The type of the tracker identifier.
|
462
472
|
* @template T - The transaction type.
|
463
|
-
* @template A - The type of the key returned by an action function.
|
464
473
|
*/
|
465
|
-
type TransactionsHistoryProps<
|
474
|
+
type TransactionsHistoryProps<T extends Transaction> = Pick<NovaProviderProps<T>, 'adapter' | 'transactionsPool' | 'connectedWalletAddress'> & {
|
466
475
|
className?: string;
|
467
|
-
customization?: TransactionsHistoryCustomization<
|
476
|
+
customization?: TransactionsHistoryCustomization<T>;
|
468
477
|
};
|
469
478
|
/**
|
470
479
|
* A component that displays a scrollable list of transactions for the connected wallet.
|
471
480
|
* It handles states for when a wallet is not connected or when the history is empty.
|
472
481
|
*/
|
473
|
-
declare function TransactionsHistory<
|
482
|
+
declare function TransactionsHistory<T extends Transaction>({ adapter, connectedWalletAddress, transactionsPool, className, customization, }: TransactionsHistoryProps<T>): react_jsx_runtime.JSX.Element;
|
474
483
|
|
475
484
|
/**
|
476
485
|
* @file This file contains the `WalletAddressDisplay` component, a UI element for showing a wallet address.
|
@@ -517,7 +526,7 @@ type NameRenderProps = {
|
|
517
526
|
/**
|
518
527
|
* Defines the props for the `WalletHeader` component, including extensive customization options.
|
519
528
|
*/
|
520
|
-
type WalletHeaderProps<
|
529
|
+
type WalletHeaderProps<T extends Transaction> = Pick<NovaProviderProps<T>, 'adapter' | 'connectedAdapterType'> & {
|
521
530
|
walletAddress?: string;
|
522
531
|
explorerUrl?: string;
|
523
532
|
className?: string;
|
@@ -530,7 +539,7 @@ type WalletHeaderProps<TR, T extends Transaction<TR>, A> = Pick<NovaProviderProp
|
|
530
539
|
* A component that displays the header for the wallet modal, including the user's avatar,
|
531
540
|
* name (if available), and address. It leverages the active adapter to fetch name service data.
|
532
541
|
*/
|
533
|
-
declare function WalletHeader<
|
542
|
+
declare function WalletHeader<T extends Transaction>({ walletAddress, adapter, connectedAdapterType, className, renderAvatar, renderName, renderAddressDisplay, renderNoWalletContent, explorerUrl, }: WalletHeaderProps<T>): react_jsx_runtime.JSX.Element;
|
534
543
|
|
535
544
|
type CustomHeaderProps = {
|
536
545
|
closeModal: () => void;
|
@@ -538,7 +547,7 @@ type CustomHeaderProps = {
|
|
538
547
|
/**
|
539
548
|
* Defines the customization options for the WalletInfoModal.
|
540
549
|
*/
|
541
|
-
type WalletInfoModalCustomization<
|
550
|
+
type WalletInfoModalCustomization<T extends Transaction> = {
|
542
551
|
modalProps?: Partial<ComponentPropsWithoutRef<typeof Dialog.Content>>;
|
543
552
|
motionProps?: MotionProps;
|
544
553
|
classNames?: {
|
@@ -546,22 +555,22 @@ type WalletInfoModalCustomization<TR, T extends Transaction<TR>, A> = {
|
|
546
555
|
};
|
547
556
|
components?: {
|
548
557
|
Header?: ComponentType<CustomHeaderProps>;
|
549
|
-
WalletInfo?: ComponentType<WalletHeaderProps<
|
550
|
-
History?: ComponentType<TransactionsHistoryProps<
|
558
|
+
WalletInfo?: ComponentType<WalletHeaderProps<T>>;
|
559
|
+
History?: ComponentType<TransactionsHistoryProps<T>>;
|
551
560
|
};
|
552
561
|
};
|
553
562
|
/**
|
554
563
|
* Defines the core props for the WalletInfoModal.
|
555
564
|
*/
|
556
|
-
type WalletInfoModalProps<
|
565
|
+
type WalletInfoModalProps<T extends Transaction> = Pick<NovaProviderProps<T>, 'adapter' | 'connectedAdapterType' | 'connectedWalletAddress' | 'transactionsPool'> & {
|
557
566
|
isOpen?: boolean;
|
558
567
|
setIsOpen: (value: boolean) => void;
|
559
|
-
customization?: WalletInfoModalCustomization<
|
568
|
+
customization?: WalletInfoModalCustomization<T>;
|
560
569
|
};
|
561
570
|
/**
|
562
571
|
* The main modal component for displaying wallet information and transaction history.
|
563
572
|
* It is highly customizable and built with accessibility in mind using Radix UI.
|
564
573
|
*/
|
565
|
-
declare function WalletInfoModal<
|
574
|
+
declare function WalletInfoModal<T extends Transaction>({ isOpen, setIsOpen, customization, adapter, connectedAdapterType, connectedWalletAddress, transactionsPool, }: WalletInfoModalProps<T>): react_jsx_runtime.JSX.Element;
|
566
575
|
|
567
576
|
export { TransactionsHistory as A, type TransactionStatusBadgeProps as B, TransactionStatusBadge as C, WalletAddressDisplay as D, type WalletAvatarProps as E, WalletAvatar as F, type WalletHeaderProps as G, type HashLinkProps as H, WalletHeader as I, type WalletInfoModalCustomization as J, type WalletInfoModalProps as K, WalletInfoModal as L, NovaProvider as M, type NovaProviderProps as N, type StatusAwareTextProps as S, type TuwaLabels as T, type WalletAddressDisplayProps as W, HashLink as a, StatusAwareText as b, type ToastTransactionCustomization as c, type ToastTransactionProps as d, ToastTransaction as e, type TrackingTxModalCustomization as f, type TrackingTxModalProps as g, TrackingTxModal as h, type TxErrorBlockProps as i, TxErrorBlock as j, type TxInfoBlockCustomization as k, type TxInfoBlockProps as l, TxInfoBlock as m, type StepStatus as n, type StepProps as o, type TxProgressIndicatorProps as p, TxProgressIndicator as q, type TxStatusVisualProps as r, TxStatusVisual as s, type TransactionHistoryItemCustomization as t, type TransactionHistoryItemProps as u, TransactionHistoryItem as v, type TransactionKeyProps as w, TransactionKey as x, type TransactionsHistoryCustomization as y, type TransactionsHistoryProps as z };
|
package/dist/index.cjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
'use strict';var solid=require('@heroicons/react/24/solid'),novaCore=require('@tuwaio/nova-core'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),pulsarCore=require('@tuwaio/pulsar-core');require('react-toastify');var reactWeb3Icons=require('@bgd-labs/react-web3-icons'),utils=require('@bgd-labs/react-web3-icons/dist/utils'),P=require('@radix-ui/react-dialog'),framerMotion=require('framer-motion'),Mt=require('dayjs'),eo=require('dayjs/plugin/relativeTime'),Co=require('ethereum-blockies-base64'),viem=require('viem');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var P__namespace=/*#__PURE__*/_interopNamespace(P);var Mt__default=/*#__PURE__*/_interopDefault(Mt);var eo__default=/*#__PURE__*/_interopDefault(eo);var Co__default=/*#__PURE__*/_interopDefault(Co);var q={walletModal:{title:"Wallet & Transactions",header:{notConnected:"Wallet not connected",avatarAlt:"Avatar for"},history:{title:"Transactions History",connectWalletTitle:"Connect Wallet",connectWalletMessage:"Please connect your wallet to see your past activity.",noTransactionsTitle:"No Transactions Yet",noTransactionsMessage:"Once you interact with the app, your transaction history will appear here."}},toast:{openWalletInfo:"Open wallet info"},statuses:{pending:"Pending",success:"Success",failed:"Failed",reverted:"Reverted",replaced:"Replaced",unknown:"Unknown"},hashLabels:{gelato:"Gelato Task ID",safe:"Safe Tx Hash",original:"Original Tx Hash",replaced:"Replaced Tx Hash",default:"Tx Hash"},txInfo:{started:"Started",network:"Network"},txError:{title:"Error",copied:"Copied!"},trackingModal:{title:"Transaction Overview",processing:"Processing...",close:"Close",walletInfo:"Wallet Info",retry:"Retry",progressIndicator:{created:"Created",processing:"Processing",succeed:"Succeed"}},trackedTxButton:{loading:"Processing...",succeed:"Success",failed:"Failed",replaced:"Replaced"},actions:{copy:"Copy address",viewOnExplorer:"View on explorer",close:"Close",cancel:"Cancel",speedUp:"Speed up"}};var Yt=react.createContext(q);var m=()=>react.useContext(Yt);({[pulsarCore.TransactionStatus.Success]:"success",[pulsarCore.TransactionStatus.Failed]:"error",[pulsarCore.TransactionStatus.Replaced]:"info"});function Tt({label:t,hash:e,explorerUrl:o,variant:a="default",className:r}){let{isCopied:s,copy:l}=novaCore.useCopyToClipboard(),{actions:n,txError:p}=m(),c=novaCore.cn("flex items-center justify-between",{"text-sm":a==="default","text-xs":a==="compact"},r),i=novaCore.cn("pr-1",{"font-bold text-[var(--tuwa-text-primary)]":a==="default","font-medium text-[var(--tuwa-text-secondary)]":a==="compact"}),f=jsxRuntime.jsx("span",{className:"font-mono",children:novaCore.textCenterEllipsis(e,5,5)});return jsxRuntime.jsxs("div",{className:c,children:[t&&jsxRuntime.jsxs("span",{className:i,children:[t,":"]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[o?jsxRuntime.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-x-1 text-[var(--tuwa-text-accent)] transition-colors hover:underline",title:n.viewOnExplorer,"aria-label":n.viewOnExplorer,children:[f,jsxRuntime.jsx(solid.ArrowTopRightOnSquareIcon,{className:"h-4 w-4"})]}):jsxRuntime.jsx("span",{className:"text-[var(--tuwa-text-primary)]",children:f}),jsxRuntime.jsx("button",{type:"button",onClick:()=>l(e),className:"cursor-pointer text-[var(--tuwa-text-tertiary)] transition-colors hover:text-[var(--tuwa-text-secondary)]",title:s?p.copied:n.copy,"aria-label":s?p.copied:n.copy,children:s?jsxRuntime.jsx(solid.CheckIcon,{className:"h-4 w-4 text-[var(--tuwa-success-icon)]"}):jsxRuntime.jsx(solid.DocumentDuplicateIcon,{className:"h-4 w-4"})})]})]})}var xt={[pulsarCore.TransactionStatus.Success]:{index:1,colorClass:"text-[var(--tuwa-success-text)]"},[pulsarCore.TransactionStatus.Failed]:{index:2,colorClass:"text-[var(--tuwa-error-text)]"},[pulsarCore.TransactionStatus.Replaced]:{index:3,colorClass:"text-[var(--tuwa-text-secondary)]"},default:{index:0,colorClass:"text-[var(--tuwa-text-primary)]"}};function H({txStatus:t,source:e,fallback:o,variant:a,className:r,applyColor:s=false}){let l,n="";if(typeof e=="string")l=e;else if(Array.isArray(e)){let i=xt[t||"default"]??xt.default;l=e[i.index],s&&(n=i.colorClass);}else l=o;return l?jsxRuntime.jsx("div",{className:novaCore.cn(a==="title"?"text-sm font-semibold text-[var(--tuwa-text-primary)]":"mt-1 text-xs text-[var(--tuwa-text-secondary)]",n,r),children:l}):null}function qt({closeToast:t}){let{actions:e}=m();return jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":e.close,title:e.close,className:novaCore.cn("absolute top-2 right-2 cursor-pointer rounded-full p-1","text-[var(--tuwa-text-tertiary)] transition-colors","hover:bg-[var(--tuwa-bg-muted)] hover:text-[var(--tuwa-text-primary)]"),children:jsxRuntime.jsx(solid.XMarkIcon,{className:"h-5 w-5"})})}function O({tx:t,adapters:e,transactionsPool:o,variant:a="toast",className:r,renderHashLink:s}){let{hashLabels:l}=m(),n=pulsarCore.selectAdapterByKey({adapterKey:t.adapter,adapters:e});if(!n)return null;let p=d=>s?s(d):jsxRuntime.jsx(Tt,{...d}),c=a==="toast"?"mt-2 flex w-full flex-col gap-y-2 border-t border-[var(--tuwa-border-primary)] pt-2":"flex w-full flex-col gap-y-2",i=l[t.tracker],f=i?p({label:i,hash:t.txKey,variant:"compact"}):null,y=(()=>{let d=t.hash,x=t.replacedTxHash;return !d&&!x?null:x?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[d&&p({label:l.original,hash:d,variant:"compact"}),n.getExplorerTxUrl&&p({label:l.replaced,hash:x,explorerUrl:n.getExplorerTxUrl(o,t.txKey,x)})]}):d&&n.getExplorerTxUrl&&p({label:l.default,hash:d,explorerUrl:n.getExplorerTxUrl(o,t.txKey)})})(),T=i&&i!==l.default&&t.txKey!==t.hash;return jsxRuntime.jsxs("div",{className:novaCore.cn(c,r),children:[T&&f,y]})}var xe=t=>({Pending:{label:t.pending,Icon:solid.ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-pending-bg)] text-[var(--tuwa-pending-text)]",iconClasses:"animate-spin text-[var(--tuwa-pending-icon)]"},[pulsarCore.TransactionStatus.Success]:{label:t.success,Icon:solid.CheckCircleIcon,badgeClasses:"bg-[var(--tuwa-success-bg)] text-[var(--tuwa-success-text)]",iconClasses:"text-[var(--tuwa-success-icon)]"},[pulsarCore.TransactionStatus.Failed]:{label:t.failed,Icon:solid.XCircleIcon,badgeClasses:"bg-[var(--tuwa-error-bg)] text-[var(--tuwa-error-text)]",iconClasses:"text-[var(--tuwa-error-icon)]"},[pulsarCore.TransactionStatus.Replaced]:{label:t.replaced,Icon:solid.ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",iconClasses:"text-[var(--tuwa-info-icon)]"}});function X({tx:t,className:e}){let{statuses:o}=m(),a=react.useMemo(()=>xe(o),[o]),r="inline-flex items-center gap-x-1.5 rounded-full px-2 py-1 text-xs font-medium",s=t.pending?"Pending":t.status,l=s?a[s]:null;if(!l)return jsxRuntime.jsx("div",{className:novaCore.cn(r,"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",e),children:t.status??o.unknown});let{label:n,Icon:p,badgeClasses:c,iconClasses:i}=l;return jsxRuntime.jsxs("div",{className:novaCore.cn(r,c,e),children:[jsxRuntime.jsx(p,{className:novaCore.cn("h-4 w-4",i)}),n]})}var Ce=({onClick:t,children:e})=>jsxRuntime.jsx("button",{onClick:t,type:"button",className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-accent)] transition-opacity hover:opacity-80",children:e}),Pe=({onClick:t,children:e})=>jsxRuntime.jsx("button",{onClick:t,type:"button",className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-secondary)] transition-opacity hover:opacity-80",children:e}),he=({onClick:t,children:e})=>jsxRuntime.jsx("button",{className:"cursor-pointer rounded-md bg-gradient-to-r from-[var(--tuwa-button-gradient-from)] to-[var(--tuwa-button-gradient-to)] px-3 py-1 text-xs font-bold text-[var(--tuwa-text-on-accent)] shadow-lg transition-all duration-200 ease-in-out hover:shadow-xl hover:from-[var(--tuwa-button-gradient-from-hover)] hover:to-[var(--tuwa-button-gradient-to-hover)] active:scale-95",onClick:t,type:"button",children:e});function Qt({openWalletInfoModal:t,tx:e,transactionsPool:o,icon:a,className:r,customization:s,connectedWalletAddress:l,adapters:n}){let{actions:p,toast:c}=m(),i=pulsarCore.selectAdapterByKey({adapterKey:e.adapter,adapters:n}),f=!!(e.tracker==="ethereum"&&e.pending&&i?.speedUpTxAction&&i?.cancelTxAction&&e.from.toLowerCase()===l?.toLowerCase()),y=()=>{f&&i.cancelTxAction(e);},T=()=>{f&&i.speedUpTxAction(e);},{StatusAwareText:d=H,TransactionKey:x=O,StatusBadge:b=X,SpeedUpButton:R=Ce,CancelButton:v=Pe,WalletInfoButton:M=he}=s?.components??{};return jsxRuntime.jsxs("div",{className:novaCore.cn("flex w-full flex-col gap-3 rounded-lg bg-[var(--tuwa-bg-primary)] p-4 shadow-md",r),children:[jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[jsxRuntime.jsx("div",{className:"w-[40px] flex-shrink-0",title:utils.getChainName(e.chainId),children:a??jsxRuntime.jsx(reactWeb3Icons.Web3Icon,{chainId:e.chainId})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(d,{txStatus:e.status,source:e.title,fallback:e.type,variant:"title",applyColor:true}),jsxRuntime.jsx(d,{txStatus:e.status,source:e.description,variant:"description"})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(x,{transactionsPool:o,adapters:n,tx:e,variant:"toast"}),jsxRuntime.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[jsxRuntime.jsx(b,{tx:e}),f?jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(R,{onClick:T,children:p.speedUp}),jsxRuntime.jsx(v,{onClick:y,children:p.cancel})]}):t&&!!l&&jsxRuntime.jsx(M,{onClick:t,children:c.openWalletInfo})]})]})]})}function wt({error:t,className:e}){let{isCopied:o,copy:a}=novaCore.useCopyToClipboard(),{actions:r,txError:s}=m();return t?jsxRuntime.jsxs("div",{className:novaCore.cn("rounded-lg border border-[var(--tuwa-error-icon)]/30 bg-[var(--tuwa-error-bg)] p-3 text-sm",e),children:[jsxRuntime.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 font-bold text-[var(--tuwa-error-icon)]",children:[jsxRuntime.jsx(solid.ExclamationTriangleIcon,{className:"h-5 w-5"}),jsxRuntime.jsx("span",{children:s.title})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>a(t),title:o?s.copied:r.copy,"aria-label":o?s.copied:`${r.copy} error message`,className:"cursor-pointer text-[var(--tuwa-error-icon)]/50 transition-colors hover:text-[var(--tuwa-error-icon)]",children:o?jsxRuntime.jsx(solid.CheckIcon,{className:"h-5 w-5 text-[var(--tuwa-success-icon)]"}):jsxRuntime.jsx(solid.DocumentDuplicateIcon,{className:"h-5 w-5"})})]}),jsxRuntime.jsx("div",{className:"max-h-24 overflow-y-auto rounded bg-[var(--tuwa-bg-primary)] p-2",children:jsxRuntime.jsx("p",{className:"font-mono text-xs text-[var(--tuwa-error-text)] break-all",children:t})})]}):null}function Le({label:t,value:e}){return jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsx("span",{className:"text-[var(--tuwa-text-secondary)]",children:t}),jsxRuntime.jsx("span",{className:"font-medium text-[var(--tuwa-text-primary)]",children:e})]})}function Ct({tx:t,adapters:e,transactionsPool:o,className:a,customization:r}){let{txInfo:s}=m(),{InfoRow:l=Le}=r?.components??{},n="chainId"in t?t.chainId:t.desiredChainID;return jsxRuntime.jsxs("div",{className:novaCore.cn("flex flex-col gap-3 rounded-lg border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)] p-3",a),children:[jsxRuntime.jsx(l,{label:s.network,value:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4",children:jsxRuntime.jsx(reactWeb3Icons.Web3Icon,{chainId:n})}),jsxRuntime.jsx("span",{children:utils.getChainName(n)})]})}),t.localTimestamp&&jsxRuntime.jsx(l,{label:s.started,value:Mt__default.default.unix(t.localTimestamp).format("MMM D, HH:mm:ss")}),"txKey"in t&&t.txKey&&jsxRuntime.jsx("div",{className:"border-t border-[var(--tuwa-border-primary)] pt-3",children:jsxRuntime.jsx(O,{tx:t,adapters:e,transactionsPool:o,variant:"history",renderHashLink:r?.components?.transactionKey})})]})}var Oe={completed:{line:"bg-[var(--tuwa-success-icon)]",border:"border-[var(--tuwa-success-icon)]",fill:"bg-[var(--tuwa-success-icon)]"},error:{line:"bg-[var(--tuwa-error-icon)]",border:"border-[var(--tuwa-error-icon)]",fill:"bg-[var(--tuwa-error-icon)]"},replaced:{line:"bg-[var(--tuwa-info-icon)]",border:"border-[var(--tuwa-info-icon)]",fill:"bg-[var(--tuwa-info-icon)]"},active:{line:"bg-[var(--tuwa-pending-icon)]",border:"border-[var(--tuwa-pending-icon)]",fill:"bg-transparent",pulse:"bg-[var(--tuwa-pending-icon)]"},inactive:{line:"bg-[var(--tuwa-border-primary)]",border:"border-[var(--tuwa-border-primary)]",fill:"bg-transparent"}};function Ue({status:t,label:e,isFirst:o=false}){let a=Oe[t],r=()=>{switch(t){case "completed":return jsxRuntime.jsx(solid.CheckIcon,{className:"h-3 w-3 text-white"});case "error":return jsxRuntime.jsx(solid.ExclamationTriangleIcon,{className:"h-3 w-3 text-white"});case "replaced":return jsxRuntime.jsx(solid.ArrowPathIcon,{className:"h-3 w-3 text-white"});case "active":return jsxRuntime.jsx("div",{className:novaCore.cn("h-2 w-2 animate-pulse rounded-full",a.pulse)});default:return null}};return jsxRuntime.jsxs("div",{className:"relative flex min-w-[80px] flex-1 flex-col items-center",children:[!o&&jsxRuntime.jsx("div",{className:novaCore.cn("absolute right-1/2 top-[10px] h-0.5 w-full",a.line)}),jsxRuntime.jsx("div",{className:novaCore.cn("relative z-10 flex h-5 w-5 items-center justify-center rounded-full border-2",a.border,a.fill),children:r()}),jsxRuntime.jsx("span",{className:novaCore.cn("mt-2 text-center text-xs",t!=="inactive"?"font-semibold text-[var(--tuwa-text-primary)]":"text-[var(--tuwa-text-secondary)]"),children:e})]})}function Pt({isProcessing:t,isSucceed:e,isFailed:o,isReplaced:a,className:r,StepComponent:s=Ue}){let{trackingModal:l,statuses:n}=m(),p=react.useMemo(()=>{let c=f=>{if(f===1)return "completed";if(f===2){if(e||o||a)return "completed";if(t)return "active"}if(f===3){if(e)return "completed";if(o)return "error";if(a)return "replaced";if(t)return "active"}return "inactive"},i=f=>f===1?l.progressIndicator.created:f===2?l.progressIndicator.processing:o?n.failed:a?n.replaced:l.progressIndicator.succeed;return [{status:c(1),label:i(1),isFirst:true},{status:c(2),label:i(2)},{status:c(3),label:i(3),isLast:true}]},[t,e,o,a,l,n]);return jsxRuntime.jsx("div",{className:novaCore.cn("flex w-full items-start px-4 pt-2 pb-1",r),children:p.map((c,i)=>jsxRuntime.jsx(s,{...c},i))})}var $e={succeed:{Icon:solid.CheckCircleIcon,className:"text-[var(--tuwa-success-icon)]"},failed:{Icon:solid.ExclamationCircleIcon,className:"text-[var(--tuwa-error-icon)]"},replaced:{Icon:solid.ArrowPathIcon,className:"text-[var(--tuwa-info-icon)]"},processing:{Icon:solid.ArrowPathIcon,className:"animate-spin text-[var(--tuwa-text-accent)]"},initializing:{Icon:solid.ClockIcon,className:"animate-pulse text-[var(--tuwa-pending-icon)]"}};function Rt({isProcessing:t,isSucceed:e,isFailed:o,isReplaced:a}){let r=e&&"succeed"||o&&"failed"||a&&"replaced"||t&&"processing"||"initializing",{Icon:s,className:l}=$e[r];return jsxRuntime.jsx("div",{className:"flex justify-center py-4",children:jsxRuntime.jsx(s,{className:novaCore.cn("h-16 w-16",l)})})}function jt({adapters:t,onClose:e,onOpenWalletInfo:o,className:a,customization:r,transactionsPool:s,handleTransaction:l,initialTx:n,connectedWalletAddress:p}){let c=react.useMemo(()=>n?.lastTxKey?s[n.lastTxKey]:void 0,[s,n]),i=c??n,f=n?.withTrackedModal&&!c||(c?.isTrackedModalOpen??false),{isProcessing:y,isSucceed:T,isFailed:d,isReplaced:x}=react.useMemo(()=>{let K=c?.status,Xt=n?.isInitializing??false,$t=c?.pending??false;return {isProcessing:Xt||$t,isSucceed:K===pulsarCore.TransactionStatus.Success,isFailed:c?.isError||!!n?.errorMessage,isReplaced:K===pulsarCore.TransactionStatus.Replaced}},[c,n]),b=react.useMemo(()=>i?pulsarCore.selectAdapterByKey({adapterKey:i.adapter,adapters:t}):void 0,[i,t]),R=!!(d&&i&&n?.actionFunction&&l),v=!!(b?.speedUpTxAction&&b?.cancelTxAction&&c?.pending&&c.tracker==="ethereum"),M=()=>{if(!R||!b?.retryTxAction)return;let K={adapter:i.adapter,type:i.type,desiredChainID:"desiredChainID"in i?i.desiredChainID:i.chainId,actionFunction:n?.actionFunction,title:i.title,description:i.description,payload:i.payload,withTrackedModal:true};b.retryTxAction({tx:K,txKey:c?.txKey??"",onClose:e,handleTransaction:l});},w=()=>{v&&c&&b.cancelTxAction(c);},B=()=>{v&&c&&b.speedUpTxAction(c);},V=r?.components?.Header,ct=r?.components?.Footer,pt=r?.components?.StatusVisual,dt=r?.components?.ProgressIndicator,ut=r?.components?.InfoBlock,mt=r?.components?.ErrorBlock,_t={initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2,ease:"easeOut"},...r?.motionProps};return i?jsxRuntime.jsx(P__namespace.Root,{open:f,onOpenChange:K=>!K&&e(c?.txKey),children:jsxRuntime.jsx(P__namespace.Portal,{children:jsxRuntime.jsx(framerMotion.AnimatePresence,{children:f&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(P__namespace.Overlay,{asChild:true,children:jsxRuntime.jsx(framerMotion.motion.div,{className:"fixed inset-0 z-50 bg-black/60",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}})}),jsxRuntime.jsx(P__namespace.Content,{className:"fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 outline-none",...r?.modalProps,asChild:true,children:jsxRuntime.jsx(framerMotion.motion.div,{..._t,children:jsxRuntime.jsxs("div",{className:novaCore.cn("relative flex max-h-[98dvh] w-full flex-col gap-3 overflow-y-auto rounded-2xl bg-[var(--tuwa-bg-primary)] p-5 pt-0 shadow-2xl",a),children:[V?jsxRuntime.jsx(V,{onClose:()=>e(c?.txKey),title:jsxRuntime.jsx(kt,{tx:i})}):jsxRuntime.jsx(Qe,{onClose:()=>e(c?.txKey),title:jsxRuntime.jsx(kt,{tx:i})}),jsxRuntime.jsxs("main",{className:"flex flex-col gap-3",children:[pt?jsxRuntime.jsx(pt,{isProcessing:y,isSucceed:T,isFailed:d,isReplaced:x}):jsxRuntime.jsx(Rt,{isProcessing:y,isSucceed:T,isFailed:d,isReplaced:x}),dt?jsxRuntime.jsx(dt,{isProcessing:y,isSucceed:T,isFailed:d,isReplaced:x}):jsxRuntime.jsx(Pt,{isProcessing:y,isSucceed:T,isFailed:d,isReplaced:x}),ut?jsxRuntime.jsx(ut,{tx:i,adapters:t,transactionsPool:s}):jsxRuntime.jsx(Ct,{tx:i,adapters:t,transactionsPool:s}),mt?jsxRuntime.jsx(mt,{error:c?.errorMessage||n?.errorMessage}):jsxRuntime.jsx(wt,{error:c?.errorMessage||n?.errorMessage})]}),ct?jsxRuntime.jsx(ct,{onClose:()=>e(c?.txKey),onOpenWalletInfo:o,isProcessing:y,isFailed:d,canReplace:v,onRetry:R?M:void 0,onSpeedUp:v?B:void 0,onCancel:v?w:void 0,connectedWalletAddress:p}):jsxRuntime.jsx(je,{onClose:()=>e(c?.txKey),onOpenWalletInfo:o,isProcessing:y,isFailed:d,canReplace:v,onRetry:R?M:void 0,onSpeedUp:v?B:void 0,onCancel:v?w:void 0,connectedWalletAddress:p})]})})})]})})})}):null}function kt({tx:t}){return jsxRuntime.jsx(H,{txStatus:"status"in t?t.status:void 0,source:t.title,fallback:t.type,variant:"title",className:"text-lg"})}var Qe=({onClose:t,title:e})=>{let{actions:o}=m();return jsxRuntime.jsxs("header",{className:"sticky top-0 z-10 flex w-full items-start justify-between bg-[var(--tuwa-bg-primary)] pt-5 pb-2",children:[jsxRuntime.jsx(P__namespace.Title,{children:e}),jsxRuntime.jsx(P__namespace.Close,{asChild:true,children:jsxRuntime.jsx("button",{type:"button",onClick:()=>t(),"aria-label":o.close,className:"cursor-pointer -mt-1 ml-2 rounded-full p-1 text-[var(--tuwa-text-tertiary)] transition-colors hover:bg-[var(--tuwa-bg-muted)] hover:text-[var(--tuwa-text-primary)]",children:jsxRuntime.jsx(solid.XMarkIcon,{className:"h-5 w-5"})})})]})},je=({onClose:t,onOpenWalletInfo:e,isProcessing:o,onRetry:a,onSpeedUp:r,onCancel:s,canReplace:l,isFailed:n,connectedWalletAddress:p})=>{let{trackingModal:c,actions:i}=m(),f=()=>n&&a?jsxRuntime.jsx("button",{type:"button",onClick:a,className:"cursor-pointer rounded-md bg-[var(--tuwa-button-gradient-from)] px-4 py-2 text-sm font-semibold text-[var(--tuwa-text-on-accent)] transition-opacity hover:opacity-90",children:c.retry}):!o&&!l&&p?jsxRuntime.jsx("button",{type:"button",onClick:e,className:"cursor-pointer rounded-md bg-[var(--tuwa-bg-muted)] px-4 py-2 text-sm font-semibold text-[var(--tuwa-text-primary)] transition-colors hover:bg-[var(--tuwa-border-primary)]",children:c.walletInfo}):null;return jsxRuntime.jsxs("footer",{className:"mt-2 flex w-full items-center justify-between border-t border-[var(--tuwa-border-primary)] pt-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:l&&r&&s&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:r,className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-accent)] transition-opacity hover:opacity-80",children:i.speedUp}),jsxRuntime.jsx("button",{type:"button",onClick:s,className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-secondary)] transition-opacity hover:opacity-80",children:i.cancel})]})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(f,{}),jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:o&&!l,className:"cursor-pointer rounded-md bg-[var(--tuwa-bg-muted)] px-4 py-2 text-sm font-semibold text-[var(--tuwa-text-primary)] transition-colors hover:bg-[var(--tuwa-border-primary)] disabled:cursor-not-allowed disabled:opacity-50",children:o&&!l?c.processing:c.close})]})]})};Mt__default.default.extend(eo__default.default);var oo=({chainId:t})=>jsxRuntime.jsx("div",{className:"h-8 w-8 text-[var(--tuwa-text-secondary)]",children:jsxRuntime.jsx(reactWeb3Icons.Web3Icon,{chainId:t})}),ao=({timestamp:t})=>jsxRuntime.jsx("span",{className:"mb-1 block text-xs text-[var(--tuwa-text-secondary)]",children:t?Mt__default.default.unix(t).fromNow():"..."});function Bt({tx:t,adapters:e,transactionsPool:o,className:a,customization:r}){let{Icon:s=oo,Title:l=H,Description:n=H,Timestamp:p=ao,StatusBadge:c=X,TransactionKey:i=O}=r?.components??{};return jsxRuntime.jsxs("div",{className:novaCore.cn("flex flex-col gap-2 border-b border-[var(--tuwa-border-secondary)] p-3 transition-colors hover:bg-[var(--tuwa-bg-secondary)]",a),children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full bg-[var(--tuwa-bg-muted)]",children:jsxRuntime.jsx(s,{chainId:t.chainId})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(l,{txStatus:t.status,source:t.title,fallback:t.type,variant:"title",applyColor:true}),jsxRuntime.jsx(p,{timestamp:t.localTimestamp}),jsxRuntime.jsx(n,{txStatus:t.status,source:t.description,variant:"description"})]})]}),jsxRuntime.jsx(c,{tx:t})]}),jsxRuntime.jsx(i,{tx:t,adapters:e,transactionsPool:o,variant:"history"})]})}function no({title:t,message:e,className:o}){return jsxRuntime.jsxs("div",{className:novaCore.cn("rounded-lg bg-[var(--tuwa-bg-muted)] p-8 text-center",o),children:[jsxRuntime.jsx("h4",{className:"font-semibold text-[var(--tuwa-text-primary)]",children:t}),jsxRuntime.jsx("p",{className:"mt-1 text-sm text-[var(--tuwa-text-secondary)]",children:e})]})}function Ht({adapters:t,connectedWalletAddress:e,transactionsPool:o,className:a,customization:r}){let{walletModal:s}=m(),l=react.useMemo(()=>e?pulsarCore.selectAllTransactionsByActiveWallet(o,e).sort((f,y)=>(y.localTimestamp??0)-(f.localTimestamp??0)):[],[o,e]),{Placeholder:n=no,HistoryItem:p=Bt}=r?.components??{},c=()=>e?l.length>0?jsxRuntime.jsx("div",{className:novaCore.cn("max-h-[400px] overflow-y-auto rounded-lg border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)]",r?.classNames?.listWrapper),children:l.map(i=>jsxRuntime.jsx(p,{tx:i,transactionsPool:o,adapters:t},i.txKey))}):jsxRuntime.jsx(n,{title:s.history.noTransactionsTitle,message:s.history.noTransactionsMessage}):jsxRuntime.jsx(n,{title:s.history.connectWalletTitle,message:s.history.connectWalletMessage});return jsxRuntime.jsxs("div",{className:novaCore.cn("flex flex-col gap-y-3",a),children:[jsxRuntime.jsx("h3",{className:"text-lg font-bold text-[var(--tuwa-text-primary)]",children:s.history.title}),c()]})}var uo=t=>({replaced:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(solid.ArrowPathIcon,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.replaced})]}),loading:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(solid.ArrowPathIcon,{className:"h-4 w-4 animate-spin"}),jsxRuntime.jsx("span",{children:t.loading})]}),succeed:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(solid.CheckCircleIcon,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.succeed})]}),failed:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(solid.ExclamationCircleIcon,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.failed})]})});function en({children:t,action:e,getLastTxKey:o,transactionsPool:a,walletAddress:r,loadingContent:s,succeedContent:l,failedContent:n,replacedContent:p,resetTimeout:c=2500,className:i,...f}){let{trackedTxButton:y}=m(),[T,d]=react.useState("idle"),[x,b]=react.useState(void 0),R=react.useMemo(()=>uo(y),[y]);react.useEffect(()=>{d("idle"),b(void 0);},[r]),react.useEffect(()=>{if(!x)return;let w=a[x];if(w&&w.from.toLowerCase()===r?.toLowerCase())switch(w.status){case pulsarCore.TransactionStatus.Success:d("succeed");break;case pulsarCore.TransactionStatus.Replaced:d("replaced");break;case pulsarCore.TransactionStatus.Failed:d("failed");break}},[a,x,r]),react.useEffect(()=>{if(["succeed","failed","replaced"].includes(T)){let w=setTimeout(()=>{d("idle"),b(void 0);},c);return ()=>clearTimeout(w)}},[T,c]);let v=async()=>{d("loading");try{await e(),b(o());}catch(w){console.error("Transaction initiation failed:",w),d("failed");}},M=()=>{switch(T){case "loading":return s??R.loading;case "succeed":return l??R.succeed;case "failed":return n??R.failed;case "replaced":return p??R.replaced;default:return t}};return jsxRuntime.jsx("button",{...f,disabled:T!=="idle"||f.disabled,onClick:v,className:novaCore.cn("flex cursor-pointer items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-70",{"bg-gradient-to-r from-[var(--tuwa-button-gradient-from)] to-[var(--tuwa-button-gradient-to)] text-[var(--tuwa-text-on-accent)] hover:opacity-90":T==="idle","bg-gray-400 text-white":T==="loading","bg-gray-500 text-white":T==="replaced","bg-[var(--tuwa-success-bg)] text-[var(--tuwa-success-text)]":T==="succeed","bg-[var(--tuwa-error-bg)] text-[var(--tuwa-error-text)]":T==="failed"},i),children:M()})}function it({address:t,explorerUrl:e,className:o}){let{isCopied:a,copy:r}=novaCore.useCopyToClipboard(),{actions:s,txError:l}=m(),n=react.useMemo(()=>e&&t?`${e}/address/${t}`:void 0,[e,t]);return jsxRuntime.jsxs("div",{className:novaCore.cn("flex items-center gap-x-3 rounded-full bg-[var(--tuwa-bg-muted)] px-3 py-1 font-mono text-xs text-[var(--tuwa-text-secondary)]",o),children:[jsxRuntime.jsx("span",{children:novaCore.textCenterEllipsis(t,6,6)}),jsxRuntime.jsx("button",{type:"button",title:a?l.copied:s.copy,"aria-label":a?l.copied:`${s.copy} address`,onClick:()=>r(t),className:"cursor-pointer transition-colors hover:text-[var(--tuwa-text-primary)]",children:a?jsxRuntime.jsx(solid.CheckIcon,{className:"h-4 w-4 text-[var(--tuwa-success-icon)]"}):jsxRuntime.jsx(solid.DocumentDuplicateIcon,{className:"h-4 w-4"})}),n&&jsxRuntime.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"transition-colors hover:text-[var(--tuwa-text-accent)]",title:s.viewOnExplorer,"aria-label":s.viewOnExplorer,children:jsxRuntime.jsx(solid.ArrowTopRightOnSquareIcon,{className:"h-4 w-4"})})]})}function Ot({address:t,ensAvatar:e,className:o}){let{walletModal:a}=m(),[r,s]=react.useState(e),l=react.useMemo(()=>Co__default.default(viem.isHex(t)?t:viem.zeroAddress),[t]),n=react.useMemo(()=>`#${t.slice(2,8)}`,[t]);react.useEffect(()=>{s(e);},[e]);let p=()=>{s(l);};return jsxRuntime.jsx("div",{className:novaCore.cn("h-12 w-12 flex-shrink-0 rounded-full",o),style:{backgroundColor:n},children:jsxRuntime.jsx("img",{className:"h-full w-full rounded-full object-cover",src:r||l,alt:`${a.header.avatarAlt} ${t}`,onError:p},e)})}var So=({isLoading:t,ensName:e,walletAddress:o,explorerUrl:a,renderAddressDisplay:r})=>jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("div",{className:"mb-1.5 flex h-7 items-center",children:t?jsxRuntime.jsx("div",{className:"h-full w-48 animate-pulse rounded-md bg-[var(--tuwa-bg-muted)]"}):e?jsxRuntime.jsx("h2",{className:"text-xl font-bold text-[var(--tuwa-text-primary)]",children:e}):jsxRuntime.jsx(it,{address:o,explorerUrl:a,className:"rounded-none bg-transparent px-0 py-0 text-xl font-bold text-[var(--tuwa-text-primary)]"})}),jsxRuntime.jsx("div",{className:"flex h-5 items-center",children:!t&&e&&(r?r({address:o,explorerUrl:a}):jsxRuntime.jsx(it,{address:o,explorerUrl:a}))})]});function Ft({walletAddress:t,adapters:e,connectedAdapterType:o,className:a,renderAvatar:r,renderName:s,renderAddressDisplay:l,renderNoWalletContent:n,explorerUrl:p}){let{walletModal:c}=m(),[i,f]=react.useState(null),[y,T]=react.useState(null),[d,x]=react.useState(true);if(react.useEffect(()=>{(async()=>{if(!t||!o){x(false);return}let v=pulsarCore.selectAdapterByKey({adapterKey:o,adapters:e}),M=v&&"getName"in v&&typeof v.getName=="function",w=v&&"getAvatar"in v&&typeof v.getAvatar=="function";if(!M){x(false);return}x(true),f(null),T(null);try{let B=v?.getName?await v.getName(t):null;if(B&&(f(B),w)){let V=v?.getAvatar?await v.getAvatar(B):null;T(V);}}catch(B){console.error("Failed to fetch name service data:",B);}finally{x(false);}})();},[t,e,o]),!t)return n?jsxRuntime.jsx(jsxRuntime.Fragment,{children:n()}):jsxRuntime.jsx("div",{className:novaCore.cn("flex h-20 items-center justify-center rounded-lg bg-[var(--tuwa-bg-muted)] text-[var(--tuwa-text-secondary)]",a),children:c.header.notConnected});let b=i?i.length>30?novaCore.textCenterEllipsis(i,12,12):i:void 0;return jsxRuntime.jsxs("div",{className:novaCore.cn("flex min-h-[4rem] items-center gap-4",a),children:[jsxRuntime.jsx("div",{children:r?r({address:t,ensAvatar:y}):jsxRuntime.jsx(Ot,{address:t,ensAvatar:y})}),jsxRuntime.jsx("div",{className:"flex min-h-[3.5rem] min-w-[200px] flex-col justify-center",children:s?s({ensName:b,isLoading:d,address:t}):jsxRuntime.jsx(So,{isLoading:d,ensName:b,walletAddress:t,explorerUrl:p,renderAddressDisplay:l})})]})}var Ko=({closeModal:t,title:e})=>{let{actions:o}=m();return jsxRuntime.jsxs("div",{className:"sticky top-0 left-0 z-10 flex w-full items-center justify-between border-b border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-secondary)] p-4",children:[jsxRuntime.jsx(P__namespace.Title,{className:"text-lg font-bold text-[var(--tuwa-text-primary)]",children:e}),jsxRuntime.jsx(P__namespace.Close,{asChild:true,children:jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":o.close,className:"cursor-pointer rounded-full p-1 text-[var(--tuwa-text-tertiary)] transition-colors hover:bg-[var(--tuwa-bg-muted)] hover:text-[var(--tuwa-text-primary)]",children:jsxRuntime.jsx(solid.XMarkIcon,{className:"h-6 w-6"})})})]})};function Zt({isOpen:t,setIsOpen:e,customization:o,adapters:a,connectedAdapterType:r,connectedWalletAddress:s,transactionsPool:l}){let{walletModal:n}=m(),{explorerUrl:p}=react.useMemo(()=>r?{explorerUrl:pulsarCore.selectAdapterByKey({adapterKey:r,adapters:a})?.getExplorerUrl()}:{explorerUrl:void 0},[r,a]),c=()=>e(false),f={...{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2,ease:"easeOut"}},...o?.motionProps},y=o?.components?.Header,T=o?.components?.WalletInfo,d=o?.components?.History;return jsxRuntime.jsx(P__namespace.Root,{open:t,onOpenChange:x=>!x&&c(),children:jsxRuntime.jsx(P__namespace.Portal,{children:jsxRuntime.jsx(framerMotion.AnimatePresence,{children:t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(P__namespace.Overlay,{asChild:true,children:jsxRuntime.jsx(framerMotion.motion.div,{className:"fixed inset-0 z-50 bg-black/45",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15}})}),jsxRuntime.jsx(P__namespace.Content,{className:"fixed left-1/2 top-1/2 z-50 w-full max-w-2xl -translate-x-1/2 -translate-y-1/2 outline-none",...o?.modalProps,asChild:true,children:jsxRuntime.jsx(framerMotion.motion.div,{...f,children:jsxRuntime.jsxs("div",{className:novaCore.cn("relative max-h-[98dvh] w-full max-w-2xl overflow-y-auto rounded-2xl bg-[var(--tuwa-bg-secondary)] shadow-xl outline-none",o?.classNames?.contentWrapper),children:[y?jsxRuntime.jsx(y,{closeModal:c}):jsxRuntime.jsx(Ko,{closeModal:c,title:n.title}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:gap-6 sm:p-6",children:[T?jsxRuntime.jsx(T,{adapters:a,connectedAdapterType:r,walletAddress:s,explorerUrl:p}):jsxRuntime.jsx(Ft,{adapters:a,connectedAdapterType:r,walletAddress:s,explorerUrl:p}),d?jsxRuntime.jsx(d,{adapters:a,transactionsPool:l,connectedWalletAddress:s}):jsxRuntime.jsx(Ht,{adapters:a,transactionsPool:l,connectedWalletAddress:s})]})]})})})]})})})})}exports.HashLink=Tt;exports.StatusAwareText=H;exports.ToastCloseButton=qt;exports.ToastTransaction=Qt;exports.TrackingTxModal=jt;exports.TransactionHistoryItem=Bt;exports.TransactionKey=O;exports.TransactionStatusBadge=X;exports.TransactionsHistory=Ht;exports.TxActionButton=en;exports.TxErrorBlock=wt;exports.TxInfoBlock=Ct;exports.TxProgressIndicator=Pt;exports.TxStatusVisual=Rt;exports.WalletAddressDisplay=it;exports.WalletAvatar=Ot;exports.WalletHeader=Ft;exports.WalletInfoModal=Zt;exports.defaultLabels=q;//# sourceMappingURL=index.cjs.map
|
1
|
+
'use strict';var solid=require('@heroicons/react/24/solid'),novaCore=require('@tuwaio/nova-core'),react=require('react'),jsxRuntime=require('react/jsx-runtime'),pulsarCore=require('@tuwaio/pulsar-core');require('react-toastify');var reactWeb3Icons=require('@bgd-labs/react-web3-icons'),utils=require('@bgd-labs/react-web3-icons/dist/utils'),P=require('@radix-ui/react-dialog'),framerMotion=require('framer-motion'),Rt=require('dayjs'),so=require('dayjs/plugin/relativeTime'),ko=require('ethereum-blockies-base64'),viem=require('viem');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var P__namespace=/*#__PURE__*/_interopNamespace(P);var Rt__default=/*#__PURE__*/_interopDefault(Rt);var so__default=/*#__PURE__*/_interopDefault(so);var ko__default=/*#__PURE__*/_interopDefault(ko);var j={walletModal:{title:"Wallet & Transactions",header:{notConnected:"Wallet not connected",avatarAlt:"Avatar for"},history:{title:"Transactions History",connectWalletTitle:"Connect Wallet",connectWalletMessage:"Please connect your wallet to see your past activity.",noTransactionsTitle:"No Transactions Yet",noTransactionsMessage:"Once you interact with the app, your transaction history will appear here."}},toast:{openWalletInfo:"Open wallet info"},statuses:{pending:"Pending",success:"Success",failed:"Failed",reverted:"Reverted",replaced:"Replaced",unknown:"Unknown",confirmationsLabel:"Confirmations"},hashLabels:{gelato:"Gelato Task ID",safe:"Safe Tx Hash",original:"Original Tx Hash",replaced:"Replaced Tx Hash",default:"Tx Hash",recentBlockhash:"Recent Blockhash",solana:"Signature"},txInfo:{started:"Started",network:"Network",slot:"Slot"},txError:{title:"Error",copied:"Copied!"},trackingModal:{title:"Transaction Overview",processing:"Processing...",close:"Close",walletInfo:"Wallet Info",retry:"Retry",progressIndicator:{created:"Created",processing:"Processing",succeed:"Succeed"}},trackedTxButton:{loading:"Processing...",succeed:"Success",failed:"Failed",replaced:"Replaced"},actions:{copy:"Copy address",viewOnExplorer:"View on explorer",close:"Close",cancel:"Cancel",speedUp:"Speed up"}};var qt=react.createContext(j);var f=()=>react.useContext(qt);({[pulsarCore.TransactionStatus.Success]:"success",[pulsarCore.TransactionStatus.Failed]:"error",[pulsarCore.TransactionStatus.Replaced]:"info"});function z({label:t,hash:e,explorerUrl:o,variant:r="default",className:i}){let{isCopied:n,copy:c}=novaCore.useCopyToClipboard(),{actions:l,txError:p}=f(),a=novaCore.cn("flex items-center justify-between",{"text-sm":r==="default","text-xs":r==="compact"},i),s=novaCore.cn("pr-1",{"font-bold text-[var(--tuwa-text-primary)]":r==="default","font-medium text-[var(--tuwa-text-secondary)]":r==="compact"}),d=jsxRuntime.jsx("span",{className:"font-mono",children:novaCore.textCenterEllipsis(e,5,5)});return jsxRuntime.jsxs("div",{className:a,children:[t&&jsxRuntime.jsxs("span",{className:s,children:[t,":"]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-x-2",children:[o?jsxRuntime.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-x-1 text-[var(--tuwa-text-accent)] transition-colors hover:underline",title:l.viewOnExplorer,"aria-label":l.viewOnExplorer,children:[d,jsxRuntime.jsx(solid.ArrowTopRightOnSquareIcon,{className:"h-4 w-4"})]}):jsxRuntime.jsx("span",{className:"text-[var(--tuwa-text-primary)]",children:d}),jsxRuntime.jsx("button",{type:"button",onClick:()=>c(e),className:"cursor-pointer text-[var(--tuwa-text-tertiary)] transition-colors hover:text-[var(--tuwa-text-secondary)]",title:n?p.copied:l.copy,"aria-label":n?p.copied:l.copy,children:n?jsxRuntime.jsx(solid.CheckIcon,{className:"h-4 w-4 text-[var(--tuwa-success-icon)]"}):jsxRuntime.jsx(solid.DocumentDuplicateIcon,{className:"h-4 w-4"})})]})]})}var vt={[pulsarCore.TransactionStatus.Success]:{index:1,colorClass:"text-[var(--tuwa-success-text)]"},[pulsarCore.TransactionStatus.Failed]:{index:2,colorClass:"text-[var(--tuwa-error-text)]"},[pulsarCore.TransactionStatus.Replaced]:{index:3,colorClass:"text-[var(--tuwa-text-secondary)]"},default:{index:0,colorClass:"text-[var(--tuwa-text-primary)]"}};function L({txStatus:t,source:e,fallback:o,variant:r,className:i,applyColor:n=false}){let c,l="";if(typeof e=="string")c=e;else if(Array.isArray(e)){let s=vt[t||"default"]??vt.default;c=e[s.index],n&&(l=s.colorClass);}else c=o;return c?jsxRuntime.jsx("div",{className:novaCore.cn(r==="title"?"text-sm font-semibold text-[var(--tuwa-text-primary)]":"mt-1 text-xs text-[var(--tuwa-text-secondary)]",l,i),children:c}):null}function Qt({closeToast:t}){let{actions:e}=f();return jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":e.close,title:e.close,className:novaCore.cn("absolute top-2 right-2 cursor-pointer rounded-full p-1","text-[var(--tuwa-text-tertiary)] transition-colors","hover:bg-[var(--tuwa-bg-muted)] hover:text-[var(--tuwa-text-primary)]"),children:jsxRuntime.jsx(solid.XMarkIcon,{className:"h-5 w-5"})})}function O({tx:t,adapter:e,transactionsPool:o,variant:r="toast",className:i,renderHashLink:n,confirmations:c}){let{hashLabels:l,statuses:p}=f(),a=pulsarCore.selectAdapterByKey({adapterKey:t.adapter,adapter:e});if(!a)return null;let s=v=>n?n(v):jsxRuntime.jsx(z,{...v}),d=r==="toast"?"mt-2 flex w-full flex-col gap-y-2 border-t border-[var(--tuwa-border-primary)] pt-2":"flex w-full flex-col gap-y-2",m=l[String(t.tracker)],T=m?s({label:m,hash:t.txKey,variant:t.tracker!==pulsarCore.TransactionTracker.Solana?"compact":"default",explorerUrl:a.getExplorerTxUrl&&t.tracker===pulsarCore.TransactionTracker.Solana?a?.getExplorerTxUrl(o,t.txKey):void 0}):null,x=(()=>{let v=t.hash,w=t.replacedTxHash;return !v&&!w?null:w?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[v&&s({label:l.original,hash:v,variant:"compact"}),typeof a.getExplorerTxUrl<"u"&&s({label:l.replaced,hash:w,explorerUrl:a.getExplorerTxUrl(o,t.txKey,w)})]}):v&&typeof a.getExplorerTxUrl<"u"&&s({label:l.default,hash:v,explorerUrl:a.getExplorerTxUrl(o,t.txKey)})})(),g=m&&m!==l.default&&t.txKey!==t.hash;return jsxRuntime.jsxs("div",{className:novaCore.cn(d,i),children:[g&&T,x,typeof c=="number"&&jsxRuntime.jsxs("p",{className:"text-xs text-[var(--tuwa-text-tertiary)]",children:[p.confirmationsLabel,": ",c]})]})}var ve=t=>({Pending:{label:t.pending,Icon:solid.ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-pending-bg)] text-[var(--tuwa-pending-text)]",iconClasses:"animate-spin text-[var(--tuwa-pending-icon)]"},[pulsarCore.TransactionStatus.Success]:{label:t.success,Icon:solid.CheckCircleIcon,badgeClasses:"bg-[var(--tuwa-success-bg)] text-[var(--tuwa-success-text)]",iconClasses:"text-[var(--tuwa-success-icon)]"},[pulsarCore.TransactionStatus.Failed]:{label:t.failed,Icon:solid.XCircleIcon,badgeClasses:"bg-[var(--tuwa-error-bg)] text-[var(--tuwa-error-text)]",iconClasses:"text-[var(--tuwa-error-icon)]"},[pulsarCore.TransactionStatus.Replaced]:{label:t.replaced,Icon:solid.ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",iconClasses:"text-[var(--tuwa-info-icon)]"}});function X({tx:t,className:e}){let{statuses:o}=f(),r=react.useMemo(()=>ve(o),[o]),i="inline-flex items-center gap-x-1.5 rounded-full px-2 py-1 text-xs font-medium",n=t.pending?"Pending":t.status,c=n?r[n]:null;if(!c)return jsxRuntime.jsx("div",{className:novaCore.cn(i,"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",e),children:t.status??o.unknown});let{label:l,Icon:p,badgeClasses:a,iconClasses:s}=c;return jsxRuntime.jsxs("div",{className:novaCore.cn(i,a,e),children:[jsxRuntime.jsx(p,{className:novaCore.cn("h-4 w-4",s)}),l]})}var he=({onClick:t,children:e})=>jsxRuntime.jsx("button",{onClick:t,type:"button",className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-accent)] transition-opacity hover:opacity-80",children:e}),Pe=({onClick:t,children:e})=>jsxRuntime.jsx("button",{onClick:t,type:"button",className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-secondary)] transition-opacity hover:opacity-80",children:e}),Ne=({onClick:t,children:e})=>jsxRuntime.jsx("button",{className:"cursor-pointer rounded-md bg-gradient-to-r from-[var(--tuwa-button-gradient-from)] to-[var(--tuwa-button-gradient-to)] px-3 py-1 text-xs font-bold text-[var(--tuwa-text-on-accent)] shadow-lg transition-all duration-200 ease-in-out hover:shadow-xl hover:from-[var(--tuwa-button-gradient-from-hover)] hover:to-[var(--tuwa-button-gradient-to-hover)] active:scale-95",onClick:t,type:"button",children:e});function jt({openWalletInfoModal:t,tx:e,transactionsPool:o,icon:r,className:i,customization:n,connectedWalletAddress:c,adapter:l}){let{actions:p,toast:a}=f(),s=pulsarCore.selectAdapterByKey({adapterKey:e.adapter,adapter:l}),d=!!(e.tracker==="ethereum"&&e.pending&&s?.speedUpTxAction&&s?.cancelTxAction&&e.from.toLowerCase()===c?.toLowerCase()),m=()=>{d&&s.cancelTxAction(e);},T=()=>{d&&s.speedUpTxAction(e);},{StatusAwareText:x=L,TransactionKey:g=O,StatusBadge:v=X,SpeedUpButton:w=he,CancelButton:y=Pe,WalletInfoButton:B=Ne}=n?.components??{};return jsxRuntime.jsxs("div",{className:novaCore.cn("flex w-full flex-col gap-3 rounded-lg bg-[var(--tuwa-bg-primary)] p-4 shadow-md",i),children:[jsxRuntime.jsxs("div",{className:"flex items-start gap-3",children:[jsxRuntime.jsx("div",{className:"w-[40px] flex-shrink-0",title:utils.getChainName(e.chainId),children:r??jsxRuntime.jsx(reactWeb3Icons.Web3Icon,{chainId:e.chainId})}),jsxRuntime.jsxs("div",{className:"flex-1",children:[jsxRuntime.jsx(x,{txStatus:e.status,source:e.title,fallback:e.type,variant:"title",applyColor:true}),jsxRuntime.jsx(x,{txStatus:e.status,source:e.description,variant:"description"})]})]}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(g,{transactionsPool:o,adapter:l,tx:e,variant:"toast"}),jsxRuntime.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[jsxRuntime.jsx(v,{tx:e}),d?jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx(w,{onClick:T,children:p.speedUp}),jsxRuntime.jsx(y,{onClick:m,children:p.cancel})]}):t&&!!c&&jsxRuntime.jsx(B,{onClick:t,children:a.openWalletInfo})]})]})]})}function Ct({error:t,className:e}){let{isCopied:o,copy:r}=novaCore.useCopyToClipboard(),{actions:i,txError:n}=f();return t?jsxRuntime.jsxs("div",{className:novaCore.cn("rounded-lg border border-[var(--tuwa-error-icon)]/30 bg-[var(--tuwa-error-bg)] p-3 text-sm",e),children:[jsxRuntime.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2 font-bold text-[var(--tuwa-error-icon)]",children:[jsxRuntime.jsx(solid.ExclamationTriangleIcon,{className:"h-5 w-5"}),jsxRuntime.jsx("span",{children:n.title})]}),jsxRuntime.jsx("button",{type:"button",onClick:()=>r(t),title:o?n.copied:i.copy,"aria-label":o?n.copied:`${i.copy} error message`,className:"cursor-pointer text-[var(--tuwa-error-icon)]/50 transition-colors hover:text-[var(--tuwa-error-icon)]",children:o?jsxRuntime.jsx(solid.CheckIcon,{className:"h-5 w-5 text-[var(--tuwa-success-icon)]"}):jsxRuntime.jsx(solid.DocumentDuplicateIcon,{className:"h-5 w-5"})})]}),jsxRuntime.jsx("div",{className:"max-h-24 overflow-y-auto rounded bg-[var(--tuwa-bg-primary)] p-2",children:jsxRuntime.jsx("p",{className:"font-mono text-xs text-[var(--tuwa-error-text)] break-all",children:t})})]}):null}function We({label:t,value:e}){return jsxRuntime.jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsxRuntime.jsx("span",{className:"text-[var(--tuwa-text-secondary)]",children:t}),jsxRuntime.jsx("span",{className:"font-medium text-[var(--tuwa-text-primary)]",children:e})]})}function ht({tx:t,adapter:e,transactionsPool:o,className:r,customization:i}){let{txInfo:n,statuses:c,hashLabels:l}=f(),p=pulsarCore.selectAdapterByKey({adapterKey:t.adapter,adapter:e});if(!p)return null;let{InfoRow:a=We}=i?.components??{},s="chainId"in t?t.chainId:t.desiredChainID,d=t.adapter===pulsarCore.TransactionAdapter.SOLANA,m=d?t:void 0;return jsxRuntime.jsxs("div",{className:novaCore.cn("flex flex-col gap-3 rounded-lg border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)] p-3",r),children:[jsxRuntime.jsx(a,{label:n.network,value:jsxRuntime.jsxs("div",{className:"flex items-center justify-end gap-2",children:[jsxRuntime.jsx("div",{className:"h-4 w-4",children:jsxRuntime.jsx(reactWeb3Icons.Web3Icon,{chainId:s})}),jsxRuntime.jsx("span",{children:utils.getChainName(s)})]})}),t.localTimestamp&&jsxRuntime.jsx(a,{label:n.started,value:Rt__default.default.unix(t.localTimestamp).format("MMM D, HH:mm:ss")}),d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[m?.slot&&jsxRuntime.jsx(a,{label:n.slot,value:jsxRuntime.jsx(z,{hash:m.slot.toString(),explorerUrl:p?.getExplorerUrl?`${p?.getExplorerUrl()}/block/${m.slot}`:void 0})}),typeof m?.confirmations=="number"&&jsxRuntime.jsx(a,{label:c.confirmationsLabel,value:m.confirmations}),m?.recentBlockhash&&jsxRuntime.jsx(a,{label:l.recentBlockhash,value:jsxRuntime.jsx(z,{hash:m.recentBlockhash})})]}),"txKey"in t&&t.txKey&&jsxRuntime.jsx("div",{className:"border-t border-[var(--tuwa-border-primary)] pt-3",children:jsxRuntime.jsx(O,{tx:t,adapter:e,transactionsPool:o,variant:"history",renderHashLink:i?.components?.transactionKey})})]})}var Ve={completed:{line:"bg-[var(--tuwa-success-icon)]",border:"border-[var(--tuwa-success-icon)]",fill:"bg-[var(--tuwa-success-icon)]"},error:{line:"bg-[var(--tuwa-error-icon)]",border:"border-[var(--tuwa-error-icon)]",fill:"bg-[var(--tuwa-error-icon)]"},replaced:{line:"bg-[var(--tuwa-info-icon)]",border:"border-[var(--tuwa-info-icon)]",fill:"bg-[var(--tuwa-info-icon)]"},active:{line:"bg-[var(--tuwa-pending-icon)]",border:"border-[var(--tuwa-pending-icon)]",fill:"bg-transparent",pulse:"bg-[var(--tuwa-pending-icon)]"},inactive:{line:"bg-[var(--tuwa-border-primary)]",border:"border-[var(--tuwa-border-primary)]",fill:"bg-transparent"}};function _e({status:t,label:e,isFirst:o=false}){let r=Ve[t],i=()=>{switch(t){case "completed":return jsxRuntime.jsx(solid.CheckIcon,{className:"h-3 w-3 text-white"});case "error":return jsxRuntime.jsx(solid.ExclamationTriangleIcon,{className:"h-3 w-3 text-white"});case "replaced":return jsxRuntime.jsx(solid.ArrowPathIcon,{className:"h-3 w-3 text-white"});case "active":return jsxRuntime.jsx("div",{className:novaCore.cn("h-2 w-2 animate-pulse rounded-full",r.pulse)});default:return null}};return jsxRuntime.jsxs("div",{className:"relative flex min-w-[80px] flex-1 flex-col items-center",children:[!o&&jsxRuntime.jsx("div",{className:novaCore.cn("absolute right-1/2 top-[10px] h-0.5 w-full",r.line)}),jsxRuntime.jsx("div",{className:novaCore.cn("relative z-10 flex h-5 w-5 items-center justify-center rounded-full border-2",r.border,r.fill),children:i()}),jsxRuntime.jsx("span",{className:novaCore.cn("mt-2 text-center text-xs",t!=="inactive"?"font-semibold text-[var(--tuwa-text-primary)]":"text-[var(--tuwa-text-secondary)]"),children:e})]})}function Pt({isProcessing:t,isSucceed:e,isFailed:o,isReplaced:r,className:i,StepComponent:n=_e}){let{trackingModal:c,statuses:l}=f(),p=react.useMemo(()=>{let a=d=>{if(d===1)return "completed";if(d===2){if(e||o||r)return "completed";if(t)return "active"}if(d===3){if(e)return "completed";if(o)return "error";if(r)return "replaced";if(t)return "active"}return "inactive"},s=d=>d===1?c.progressIndicator.created:d===2?c.progressIndicator.processing:o?l.failed:r?l.replaced:c.progressIndicator.succeed;return [{status:a(1),label:s(1),isFirst:true},{status:a(2),label:s(2)},{status:a(3),label:s(3),isLast:true}]},[t,e,o,r,c,l]);return jsxRuntime.jsx("div",{className:novaCore.cn("flex w-full items-start px-4 pt-2 pb-1",i),children:p.map((a,s)=>jsxRuntime.jsx(n,{...a},s))})}var qe={succeed:{Icon:solid.CheckCircleIcon,className:"text-[var(--tuwa-success-icon)]"},failed:{Icon:solid.ExclamationCircleIcon,className:"text-[var(--tuwa-error-icon)]"},replaced:{Icon:solid.ArrowPathIcon,className:"text-[var(--tuwa-info-icon)]"},processing:{Icon:solid.ArrowPathIcon,className:"animate-spin text-[var(--tuwa-text-accent)]"},initializing:{Icon:solid.ClockIcon,className:"animate-pulse text-[var(--tuwa-pending-icon)]"}};function It({isProcessing:t,isSucceed:e,isFailed:o,isReplaced:r}){let i=e&&"succeed"||o&&"failed"||r&&"replaced"||t&&"processing"||"initializing",{Icon:n,className:c}=qe[i];return jsxRuntime.jsx("div",{className:"flex justify-center py-4",children:jsxRuntime.jsx(n,{className:novaCore.cn("h-16 w-16",c)})})}function Zt({adapter:t,onClose:e,onOpenWalletInfo:o,className:r,customization:i,transactionsPool:n,handleTransaction:c,initialTx:l,connectedWalletAddress:p}){let a=react.useMemo(()=>l?.lastTxKey?n[l.lastTxKey]:void 0,[n,l]),s=a??l,d=l?.withTrackedModal&&!a||(a?.isTrackedModalOpen??false),{isProcessing:m,isSucceed:T,isFailed:x,isReplaced:g}=react.useMemo(()=>{let W=a?.status,Xt=l?.isInitializing??false,Jt=a?.pending??false;return {isProcessing:Xt||Jt,isSucceed:W===pulsarCore.TransactionStatus.Success,isFailed:a?.isError||!!l?.errorMessage,isReplaced:W===pulsarCore.TransactionStatus.Replaced}},[a,l]),v=react.useMemo(()=>s?pulsarCore.selectAdapterByKey({adapterKey:s.adapter,adapter:t}):void 0,[s,t]),w=!!(x&&s&&l?.actionFunction&&c),y=!!(v?.speedUpTxAction&&v?.cancelTxAction&&a?.pending&&a.tracker==="ethereum"),B=()=>{if(!w||!v?.retryTxAction)return;let W={adapter:s.adapter,type:s.type,desiredChainID:"desiredChainID"in s?s.desiredChainID:s.chainId,actionFunction:l?.actionFunction,title:s.title,description:s.description,payload:s.payload,withTrackedModal:true};v.retryTxAction({tx:W,txKey:a?.txKey??"",onClose:e,handleTransaction:c});},I=()=>{y&&a&&v.cancelTxAction(a);},R=()=>{y&&a&&v.speedUpTxAction(a);},_=i?.components?.Header,dt=i?.components?.Footer,ut=i?.components?.StatusVisual,mt=i?.components?.ProgressIndicator,ft=i?.components?.InfoBlock,xt=i?.components?.ErrorBlock,$t={initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2,ease:"easeOut"},...i?.motionProps};return s?jsxRuntime.jsx(P__namespace.Root,{open:d,onOpenChange:W=>!W&&e(a?.txKey),children:jsxRuntime.jsx(P__namespace.Portal,{children:jsxRuntime.jsx(framerMotion.AnimatePresence,{children:d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(P__namespace.Overlay,{asChild:true,children:jsxRuntime.jsx(framerMotion.motion.div,{className:"fixed inset-0 z-50 bg-black/60",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}})}),jsxRuntime.jsx(P__namespace.Content,{className:"fixed left-1/2 top-1/2 z-50 w-full max-w-md -translate-x-1/2 -translate-y-1/2 outline-none",...i?.modalProps,asChild:true,children:jsxRuntime.jsx(framerMotion.motion.div,{...$t,children:jsxRuntime.jsxs("div",{className:novaCore.cn("relative flex max-h-[98dvh] w-full flex-col gap-3 overflow-y-auto rounded-2xl bg-[var(--tuwa-bg-primary)] p-5 pt-0 shadow-2xl",r),children:[_?jsxRuntime.jsx(_,{onClose:()=>e(a?.txKey),title:jsxRuntime.jsx(Mt,{tx:s})}):jsxRuntime.jsx(eo,{onClose:()=>e(a?.txKey),title:jsxRuntime.jsx(Mt,{tx:s})}),jsxRuntime.jsxs("main",{className:"flex flex-col gap-3",children:[ut?jsxRuntime.jsx(ut,{isProcessing:m,isSucceed:T,isFailed:x,isReplaced:g}):jsxRuntime.jsx(It,{isProcessing:m,isSucceed:T,isFailed:x,isReplaced:g}),mt?jsxRuntime.jsx(mt,{isProcessing:m,isSucceed:T,isFailed:x,isReplaced:g}):jsxRuntime.jsx(Pt,{isProcessing:m,isSucceed:T,isFailed:x,isReplaced:g}),ft?jsxRuntime.jsx(ft,{tx:s,adapter:t,transactionsPool:n}):jsxRuntime.jsx(ht,{tx:s,adapter:t,transactionsPool:n}),xt?jsxRuntime.jsx(xt,{error:a?.errorMessage||l?.errorMessage}):jsxRuntime.jsx(Ct,{error:a?.errorMessage||l?.errorMessage})]}),dt?jsxRuntime.jsx(dt,{onClose:()=>e(a?.txKey),onOpenWalletInfo:o,isProcessing:m,isFailed:x,canReplace:y,onRetry:w?B:void 0,onSpeedUp:y?R:void 0,onCancel:y?I:void 0,connectedWalletAddress:p}):jsxRuntime.jsx(oo,{onClose:()=>e(a?.txKey),onOpenWalletInfo:o,isProcessing:m,isFailed:x,canReplace:y,onRetry:w?B:void 0,onSpeedUp:y?R:void 0,onCancel:y?I:void 0,connectedWalletAddress:p})]})})})]})})})}):null}function Mt({tx:t}){return jsxRuntime.jsx(L,{txStatus:"status"in t?t.status:void 0,source:t.title,fallback:t.type,variant:"title",className:"text-lg"})}var eo=({onClose:t,title:e})=>{let{actions:o}=f();return jsxRuntime.jsxs("header",{className:"sticky top-0 z-10 flex w-full items-start justify-between bg-[var(--tuwa-bg-primary)] pt-5 pb-2",children:[jsxRuntime.jsx(P__namespace.Title,{children:e}),jsxRuntime.jsx(P__namespace.Close,{asChild:true,children:jsxRuntime.jsx("button",{type:"button",onClick:()=>t(),"aria-label":o.close,className:"cursor-pointer -mt-1 ml-2 rounded-full p-1 text-[var(--tuwa-text-tertiary)] transition-colors hover:bg-[var(--tuwa-bg-muted)] hover:text-[var(--tuwa-text-primary)]",children:jsxRuntime.jsx(solid.XMarkIcon,{className:"h-5 w-5"})})})]})},oo=({onClose:t,onOpenWalletInfo:e,isProcessing:o,onRetry:r,onSpeedUp:i,onCancel:n,canReplace:c,isFailed:l,connectedWalletAddress:p})=>{let{trackingModal:a,actions:s}=f(),d=()=>l&&r?jsxRuntime.jsx("button",{type:"button",onClick:r,className:"cursor-pointer rounded-md bg-[var(--tuwa-button-gradient-from)] px-4 py-2 text-sm font-semibold text-[var(--tuwa-text-on-accent)] transition-opacity hover:opacity-90",children:a.retry}):!o&&!c&&p?jsxRuntime.jsx("button",{type:"button",onClick:e,className:"cursor-pointer rounded-md bg-[var(--tuwa-bg-muted)] px-4 py-2 text-sm font-semibold text-[var(--tuwa-text-primary)] transition-colors hover:bg-[var(--tuwa-border-primary)]",children:a.walletInfo}):null;return jsxRuntime.jsxs("footer",{className:"mt-2 flex w-full items-center justify-between border-t border-[var(--tuwa-border-primary)] pt-4",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-4",children:c&&i&&n&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{type:"button",onClick:i,className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-accent)] transition-opacity hover:opacity-80",children:s.speedUp}),jsxRuntime.jsx("button",{type:"button",onClick:n,className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-secondary)] transition-opacity hover:opacity-80",children:s.cancel})]})}),jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx(d,{}),jsxRuntime.jsx("button",{type:"button",onClick:t,disabled:o&&!c,className:"cursor-pointer rounded-md bg-[var(--tuwa-bg-muted)] px-4 py-2 text-sm font-semibold text-[var(--tuwa-text-primary)] transition-colors hover:bg-[var(--tuwa-border-primary)] disabled:cursor-not-allowed disabled:opacity-50",children:o&&!c?a.processing:a.close})]})]})};Rt__default.default.extend(so__default.default);var no=({chainId:t})=>jsxRuntime.jsx("div",{className:"h-8 w-8 text-[var(--tuwa-text-secondary)]",children:jsxRuntime.jsx(reactWeb3Icons.Web3Icon,{chainId:t})}),io=({timestamp:t})=>jsxRuntime.jsx("span",{className:"mb-1 block text-xs text-[var(--tuwa-text-secondary)]",children:t?Rt__default.default.unix(t).fromNow():"..."});function Lt({tx:t,adapter:e,transactionsPool:o,className:r,customization:i}){let{Icon:n=no,Title:c=L,Description:l=L,Timestamp:p=io,StatusBadge:a=X,TransactionKey:s=O}=i?.components??{};return jsxRuntime.jsxs("div",{className:novaCore.cn("flex flex-col gap-2 border-b border-[var(--tuwa-border-secondary)] p-3 transition-colors hover:bg-[var(--tuwa-bg-secondary)]",r),children:[jsxRuntime.jsxs("div",{className:"flex items-start justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-4",children:[jsxRuntime.jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full bg-[var(--tuwa-bg-muted)]",children:jsxRuntime.jsx(n,{chainId:t.chainId})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(c,{txStatus:t.status,source:t.title,fallback:t.type,variant:"title",applyColor:true}),jsxRuntime.jsx(p,{timestamp:t.localTimestamp}),jsxRuntime.jsx(l,{txStatus:t.status,source:t.description,variant:"description"})]})]}),jsxRuntime.jsx(a,{tx:t})]}),jsxRuntime.jsx(s,{tx:t,adapter:e,transactionsPool:o,variant:"history"})]})}function po({title:t,message:e,className:o}){return jsxRuntime.jsxs("div",{className:novaCore.cn("rounded-lg bg-[var(--tuwa-bg-muted)] p-8 text-center",o),children:[jsxRuntime.jsx("h4",{className:"font-semibold text-[var(--tuwa-text-primary)]",children:t}),jsxRuntime.jsx("p",{className:"mt-1 text-sm text-[var(--tuwa-text-secondary)]",children:e})]})}function Ht({adapter:t,connectedWalletAddress:e,transactionsPool:o,className:r,customization:i}){let{walletModal:n}=f(),c=react.useMemo(()=>e?pulsarCore.selectAllTransactionsByActiveWallet(o,e).sort((d,m)=>(m.localTimestamp??0)-(d.localTimestamp??0)):[],[o,e]),{Placeholder:l=po,HistoryItem:p=Lt}=i?.components??{},a=()=>e?c.length>0?jsxRuntime.jsx("div",{className:novaCore.cn("max-h-[400px] overflow-y-auto rounded-lg border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)]",i?.classNames?.listWrapper),children:c.map(s=>jsxRuntime.jsx(p,{tx:s,transactionsPool:o,adapter:t},s.txKey))}):jsxRuntime.jsx(l,{title:n.history.noTransactionsTitle,message:n.history.noTransactionsMessage}):jsxRuntime.jsx(l,{title:n.history.connectWalletTitle,message:n.history.connectWalletMessage});return jsxRuntime.jsxs("div",{className:novaCore.cn("flex flex-col gap-y-3",r),children:[jsxRuntime.jsx("h3",{className:"text-lg font-bold text-[var(--tuwa-text-primary)]",children:n.history.title}),a()]})}var To=t=>({replaced:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(solid.ArrowPathIcon,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.replaced})]}),loading:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(solid.ArrowPathIcon,{className:"h-4 w-4 animate-spin"}),jsxRuntime.jsx("span",{children:t.loading})]}),succeed:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(solid.CheckCircleIcon,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.succeed})]}),failed:jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(solid.ExclamationCircleIcon,{className:"h-4 w-4"}),jsxRuntime.jsx("span",{children:t.failed})]})});function dn({children:t,action:e,getLastTxKey:o,transactionsPool:r,walletAddress:i,loadingContent:n,succeedContent:c,failedContent:l,replacedContent:p,resetTimeout:a=2500,className:s,...d}){let{trackedTxButton:m}=f(),[T,x]=react.useState("idle"),[g,v]=react.useState(void 0),w=react.useMemo(()=>To(m),[m]);react.useEffect(()=>{x("idle"),v(void 0);},[i]),react.useEffect(()=>{if(!g)return;let I=r[g];if(I)switch(I.status){case pulsarCore.TransactionStatus.Success:x("succeed");break;case pulsarCore.TransactionStatus.Replaced:x("replaced");break;case pulsarCore.TransactionStatus.Failed:x("failed");break}},[r,g,i]),react.useEffect(()=>{if(["succeed","failed","replaced"].includes(T)){let I=setTimeout(()=>{x("idle"),v(void 0);},a);return ()=>clearTimeout(I)}},[T,a]);let y=async()=>{x("loading");try{await e(),v(o());}catch(I){console.error("Transaction initiation failed:",I),x("failed");}},B=()=>{switch(T){case "loading":return n??w.loading;case "succeed":return c??w.succeed;case "failed":return l??w.failed;case "replaced":return p??w.replaced;default:return t}};return jsxRuntime.jsx("button",{...d,disabled:T!=="idle"||d.disabled,onClick:y,className:novaCore.cn("flex cursor-pointer items-center justify-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-all duration-200 disabled:cursor-not-allowed disabled:opacity-70",{"bg-gradient-to-r from-[var(--tuwa-button-gradient-from)] to-[var(--tuwa-button-gradient-to)] text-[var(--tuwa-text-on-accent)] hover:opacity-90":T==="idle","bg-gray-400 text-white":T==="loading","bg-gray-500 text-white":T==="replaced","bg-[var(--tuwa-success-bg)] text-[var(--tuwa-success-text)]":T==="succeed","bg-[var(--tuwa-error-bg)] text-[var(--tuwa-error-text)]":T==="failed"},s),children:B()})}function ct({address:t,explorerUrl:e,className:o}){let{isCopied:r,copy:i}=novaCore.useCopyToClipboard(),{actions:n,txError:c}=f(),l=react.useMemo(()=>e&&t?`${e}/address/${t}`:void 0,[e,t]);return jsxRuntime.jsxs("div",{className:novaCore.cn("flex items-center gap-x-3 rounded-full bg-[var(--tuwa-bg-muted)] px-3 py-1 font-mono text-xs text-[var(--tuwa-text-secondary)]",o),children:[jsxRuntime.jsx("span",{children:novaCore.textCenterEllipsis(t,6,6)}),jsxRuntime.jsx("button",{type:"button",title:r?c.copied:n.copy,"aria-label":r?c.copied:`${n.copy} address`,onClick:()=>i(t),className:"cursor-pointer transition-colors hover:text-[var(--tuwa-text-primary)]",children:r?jsxRuntime.jsx(solid.CheckIcon,{className:"h-4 w-4 text-[var(--tuwa-success-icon)]"}):jsxRuntime.jsx(solid.DocumentDuplicateIcon,{className:"h-4 w-4"})}),l&&jsxRuntime.jsx("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"transition-colors hover:text-[var(--tuwa-text-accent)]",title:n.viewOnExplorer,"aria-label":n.viewOnExplorer,children:jsxRuntime.jsx(solid.ArrowTopRightOnSquareIcon,{className:"h-4 w-4"})})]})}function Ut({address:t,ensAvatar:e,className:o}){let{walletModal:r}=f(),[i,n]=react.useState(e),c=react.useMemo(()=>ko__default.default(viem.isHex(t)?t:viem.zeroAddress),[t]),l=react.useMemo(()=>`#${t.slice(2,8)}`,[t]);react.useEffect(()=>{n(e);},[e]);let p=()=>{n(c);};return jsxRuntime.jsx("div",{className:novaCore.cn("h-12 w-12 flex-shrink-0 rounded-full",o),style:{backgroundColor:l},children:jsxRuntime.jsx("img",{className:"h-full w-full rounded-full object-cover",src:i||c,alt:`${r.header.avatarAlt} ${t}`,onError:p},e)})}var Ho=({isLoading:t,ensName:e,walletAddress:o,explorerUrl:r,renderAddressDisplay:i})=>jsxRuntime.jsxs("div",{className:"flex flex-col",children:[jsxRuntime.jsx("div",{className:"mb-1.5 flex h-7 items-center",children:t?jsxRuntime.jsx("div",{className:"h-full w-48 animate-pulse rounded-md bg-[var(--tuwa-bg-muted)]"}):e?jsxRuntime.jsx("h2",{className:"text-xl font-bold text-[var(--tuwa-text-primary)]",children:e}):jsxRuntime.jsx(ct,{address:o,explorerUrl:r,className:"rounded-none bg-transparent px-0 py-0 text-xl font-bold text-[var(--tuwa-text-primary)]"})}),jsxRuntime.jsx("div",{className:"flex h-5 items-center",children:!t&&e&&(i?i({address:o,explorerUrl:r}):jsxRuntime.jsx(ct,{address:o,explorerUrl:r}))})]});function zt({walletAddress:t,adapter:e,connectedAdapterType:o,className:r,renderAvatar:i,renderName:n,renderAddressDisplay:c,renderNoWalletContent:l,explorerUrl:p}){let{walletModal:a}=f(),[s,d]=react.useState(null),[m,T]=react.useState(null),[x,g]=react.useState(true);if(react.useEffect(()=>{(async()=>{if(!t||!o){g(false);return}let y=pulsarCore.selectAdapterByKey({adapterKey:o,adapter:e}),B=y&&"getName"in y&&typeof y.getName=="function",I=y&&"getAvatar"in y&&typeof y.getAvatar=="function";if(!B){g(false);return}g(true),d(null),T(null);try{let R=y?.getName?await y.getName(t):null;if(R&&(d(R),I)){let _=y?.getAvatar?await y.getAvatar(R):null;T(_);}}catch(R){console.error("Failed to fetch name service data:",R);}finally{g(false);}})();},[t,e,o]),!t)return l?jsxRuntime.jsx(jsxRuntime.Fragment,{children:l()}):jsxRuntime.jsx("div",{className:novaCore.cn("flex h-20 items-center justify-center rounded-lg bg-[var(--tuwa-bg-muted)] text-[var(--tuwa-text-secondary)]",r),children:a.header.notConnected});let v=s?s.length>30?novaCore.textCenterEllipsis(s,12,12):s:void 0;return jsxRuntime.jsxs("div",{className:novaCore.cn("flex min-h-[4rem] items-center gap-4",r),children:[jsxRuntime.jsx("div",{children:i?i({address:t,ensAvatar:m}):jsxRuntime.jsx(Ut,{address:t,ensAvatar:m})}),jsxRuntime.jsx("div",{className:"flex min-h-[3.5rem] min-w-[200px] flex-col justify-center",children:n?n({ensName:v,isLoading:x,address:t}):jsxRuntime.jsx(Ho,{isLoading:x,ensName:v,walletAddress:t,explorerUrl:p,renderAddressDisplay:c})})]})}var Fo=({closeModal:t,title:e})=>{let{actions:o}=f();return jsxRuntime.jsxs("div",{className:"sticky top-0 left-0 z-10 flex w-full items-center justify-between border-b border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-secondary)] p-4",children:[jsxRuntime.jsx(P__namespace.Title,{className:"text-lg font-bold text-[var(--tuwa-text-primary)]",children:e}),jsxRuntime.jsx(P__namespace.Close,{asChild:true,children:jsxRuntime.jsx("button",{type:"button",onClick:t,"aria-label":o.close,className:"cursor-pointer rounded-full p-1 text-[var(--tuwa-text-tertiary)] transition-colors hover:bg-[var(--tuwa-bg-muted)] hover:text-[var(--tuwa-text-primary)]",children:jsxRuntime.jsx(solid.XMarkIcon,{className:"h-6 w-6"})})})]})};function te({isOpen:t,setIsOpen:e,customization:o,adapter:r,connectedAdapterType:i,connectedWalletAddress:n,transactionsPool:c}){let{walletModal:l}=f(),{explorerUrl:p}=react.useMemo(()=>i?{explorerUrl:pulsarCore.selectAdapterByKey({adapterKey:i,adapter:r})?.getExplorerUrl()}:{explorerUrl:void 0},[i,r]),a=()=>e(false),d={...{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2,ease:"easeOut"}},...o?.motionProps},m=o?.components?.Header,T=o?.components?.WalletInfo,x=o?.components?.History;return jsxRuntime.jsx(P__namespace.Root,{open:t,onOpenChange:g=>!g&&a(),children:jsxRuntime.jsx(P__namespace.Portal,{children:jsxRuntime.jsx(framerMotion.AnimatePresence,{children:t&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(P__namespace.Overlay,{asChild:true,children:jsxRuntime.jsx(framerMotion.motion.div,{className:"fixed inset-0 z-50 bg-black/45",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15}})}),jsxRuntime.jsx(P__namespace.Content,{className:"fixed left-1/2 top-1/2 z-50 w-full max-w-2xl -translate-x-1/2 -translate-y-1/2 outline-none",...o?.modalProps,asChild:true,children:jsxRuntime.jsx(framerMotion.motion.div,{...d,children:jsxRuntime.jsxs("div",{className:novaCore.cn("relative max-h-[98dvh] w-full max-w-2xl overflow-y-auto rounded-2xl bg-[var(--tuwa-bg-secondary)] shadow-xl outline-none",o?.classNames?.contentWrapper),children:[m?jsxRuntime.jsx(m,{closeModal:a}):jsxRuntime.jsx(Fo,{closeModal:a,title:l.title}),jsxRuntime.jsxs("div",{className:"flex flex-col gap-4 p-4 sm:gap-6 sm:p-6",children:[T?jsxRuntime.jsx(T,{adapter:r,connectedAdapterType:i,walletAddress:n,explorerUrl:p}):jsxRuntime.jsx(zt,{adapter:r,connectedAdapterType:i,walletAddress:n,explorerUrl:p}),x?jsxRuntime.jsx(x,{adapter:r,transactionsPool:c,connectedWalletAddress:n}):jsxRuntime.jsx(Ht,{adapter:r,transactionsPool:c,connectedWalletAddress:n})]})]})})})]})})})})}exports.HashLink=z;exports.StatusAwareText=L;exports.ToastCloseButton=Qt;exports.ToastTransaction=jt;exports.TrackingTxModal=Zt;exports.TransactionHistoryItem=Lt;exports.TransactionKey=O;exports.TransactionStatusBadge=X;exports.TransactionsHistory=Ht;exports.TxActionButton=dn;exports.TxErrorBlock=Ct;exports.TxInfoBlock=ht;exports.TxProgressIndicator=Pt;exports.TxStatusVisual=It;exports.WalletAddressDisplay=ct;exports.WalletAvatar=Ut;exports.WalletHeader=zt;exports.WalletInfoModal=te;exports.defaultLabels=j;//# sourceMappingURL=index.cjs.map
|
2
2
|
//# sourceMappingURL=index.cjs.map
|