@tuwaio/nova-transactions 1.0.0-alpha.3.78a2a23 → 1.0.0-alpha.4.a67b545
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 +81 -84
- package/dist/{TransactionsHistory-Bz0XaDda.d.cts → WalletInfoModal-DP-qlvYl.d.cts} +203 -253
- package/dist/{TransactionsHistory-Bz0XaDda.d.ts → WalletInfoModal-DP-qlvYl.d.ts} +203 -253
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -21
- package/dist/index.d.cts +32 -126
- package/dist/index.d.ts +32 -126
- 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 +4 -4
- package/dist/providers/index.d.ts +4 -4
- package/dist/providers/index.js +1 -1
- package/dist/providers/index.js.map +1 -1
- package/package.json +13 -15
package/dist/index.css
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! tailwindcss v4.1.
|
1
|
+
/*! tailwindcss v4.1.13 | MIT License | https://tailwindcss.com */
|
2
2
|
@layer properties;
|
3
3
|
@layer theme, base, components, utilities;
|
4
4
|
@layer utilities {
|
@@ -71,12 +71,6 @@
|
|
71
71
|
.-mt-1 {
|
72
72
|
margin-top: calc(0.25rem * -1);
|
73
73
|
}
|
74
|
-
.-mt-2 {
|
75
|
-
margin-top: calc(0.25rem * -2);
|
76
|
-
}
|
77
|
-
.mt-0 {
|
78
|
-
margin-top: calc(0.25rem * 0);
|
79
|
-
}
|
80
74
|
.mt-1 {
|
81
75
|
margin-top: calc(0.25rem * 1);
|
82
76
|
}
|
@@ -499,9 +493,6 @@
|
|
499
493
|
.text-center {
|
500
494
|
text-align: center;
|
501
495
|
}
|
502
|
-
.text-right {
|
503
|
-
text-align: right;
|
504
|
-
}
|
505
496
|
.font-mono {
|
506
497
|
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
|
507
498
|
monospace;
|
@@ -585,12 +576,6 @@
|
|
585
576
|
.text-white {
|
586
577
|
color: #fff;
|
587
578
|
}
|
588
|
-
.opacity-0 {
|
589
|
-
opacity: 0%;
|
590
|
-
}
|
591
|
-
.opacity-100 {
|
592
|
-
opacity: 100%;
|
593
|
-
}
|
594
579
|
.\!shadow-none {
|
595
580
|
--tw-shadow: 0 0 #0000 !important;
|
596
581
|
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow) !important;
|
@@ -612,7 +597,7 @@
|
|
612
597
|
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
613
598
|
}
|
614
599
|
.transition {
|
615
|
-
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter, display,
|
600
|
+
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, backdrop-filter, display, content-visibility, overlay, pointer-events;
|
616
601
|
transition-timing-function: var(--tw-ease, cubic-bezier(0.4, 0, 0.2, 1));
|
617
602
|
transition-duration: var(--tw-duration, 150ms);
|
618
603
|
}
|
@@ -635,10 +620,6 @@
|
|
635
620
|
--tw-duration: 200ms;
|
636
621
|
transition-duration: 200ms;
|
637
622
|
}
|
638
|
-
.duration-300 {
|
639
|
-
--tw-duration: 300ms;
|
640
|
-
transition-duration: 300ms;
|
641
|
-
}
|
642
623
|
.ease-in-out {
|
643
624
|
--tw-ease: cubic-bezier(0.4, 0, 0.2, 1);
|
644
625
|
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
package/dist/index.d.cts
CHANGED
@@ -1,152 +1,58 @@
|
|
1
|
-
import { T as TuwaLabels } from './
|
2
|
-
export {
|
3
|
-
import
|
4
|
-
import { Transaction,
|
5
|
-
import 'react
|
6
|
-
import 'react/jsx-runtime';
|
1
|
+
import { T as TuwaLabels } from './WalletInfoModal-DP-qlvYl.cjs';
|
2
|
+
export { a as HashLink, H as HashLinkProps, b as StatusAwareText, S as StatusAwareTextProps, o as StepProps, n as StepStatus, e as ToastTransaction, c as ToastTransactionCustomization, d as ToastTransactionProps, h as TrackingTxModal, f as TrackingTxModalCustomization, g as TrackingTxModalProps, v as TransactionHistoryItem, t as TransactionHistoryItemCustomization, u as TransactionHistoryItemProps, x as TransactionKey, w as TransactionKeyProps, C as TransactionStatusBadge, B as TransactionStatusBadgeProps, A as TransactionsHistory, y as TransactionsHistoryCustomization, z as TransactionsHistoryProps, j as TxErrorBlock, i as TxErrorBlockProps, m as TxInfoBlock, k as TxInfoBlockCustomization, l as TxInfoBlockProps, q as TxProgressIndicator, p as TxProgressIndicatorProps, s as TxStatusVisual, r as TxStatusVisualProps, D as WalletAddressDisplay, W as WalletAddressDisplayProps, F as WalletAvatar, E as WalletAvatarProps, I as WalletHeader, G as WalletHeaderProps, L as WalletInfoModal, J as WalletInfoModalCustomization, K as WalletInfoModalProps } from './WalletInfoModal-DP-qlvYl.cjs';
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
|
+
import { Transaction, TransactionPool } from '@tuwaio/pulsar-core';
|
5
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
7
6
|
import '@radix-ui/react-dialog';
|
8
7
|
import 'framer-motion';
|
8
|
+
import 'react-toastify';
|
9
9
|
|
10
10
|
/**
|
11
|
-
* @file This file contains a reusable close button component,
|
11
|
+
* @file This file contains a reusable close button component, designed primarily for toast notifications.
|
12
|
+
*/
|
13
|
+
/**
|
14
|
+
* Defines the props for the ToastCloseButton component.
|
12
15
|
*/
|
13
|
-
|
14
16
|
type ToastCloseButtonProps = {
|
15
17
|
/**
|
16
|
-
* The function to call when the button is clicked.
|
17
|
-
*
|
18
|
+
* The function to call when the button is clicked. This is typically provided by the
|
19
|
+
* toast library (e.g., react-toastify) to dismiss the notification.
|
18
20
|
*/
|
19
21
|
closeToast?: (e: React.MouseEvent<HTMLElement>) => void;
|
20
22
|
};
|
21
23
|
/**
|
22
|
-
* A simple, styled close button component (X icon)
|
23
|
-
*
|
24
|
-
* @param {ToastCloseButtonProps} props - The component props.
|
25
|
-
* @returns {JSX.Element} The rendered close button.
|
26
|
-
*/
|
27
|
-
declare function ToastCloseButton({ closeToast }: ToastCloseButtonProps): JSX.Element;
|
28
|
-
|
29
|
-
/**
|
30
|
-
* @file This file contains the `WalletAddressDisplay` component, a UI element for showing a wallet address.
|
31
|
-
*/
|
32
|
-
|
33
|
-
type WalletAddressDisplayProps = {
|
34
|
-
/** The wallet address to display. */
|
35
|
-
address: string;
|
36
|
-
explorerUrl: string;
|
37
|
-
/** Optional additional CSS classes for the container. */
|
38
|
-
className?: string;
|
39
|
-
};
|
40
|
-
/**
|
41
|
-
* A component that renders a wallet address in a styled "pill" format,
|
42
|
-
* including a copy button and a link to the appropriate block explorer.
|
43
|
-
*
|
44
|
-
* @param {WalletAddressDisplayProps} props - The component props.
|
45
|
-
* @returns {JSX.Element} The rendered component.
|
46
|
-
*/
|
47
|
-
declare function WalletAddressDisplay({ address, explorerUrl, className }: WalletAddressDisplayProps): JSX.Element;
|
48
|
-
|
49
|
-
/**
|
50
|
-
* @file This file contains the `WalletAvatar` component for displaying a user's avatar.
|
51
|
-
*/
|
52
|
-
|
53
|
-
type WalletAvatarProps = {
|
54
|
-
/** The user's wallet address. Used for the blockie fallback and background color generation. */
|
55
|
-
address: string;
|
56
|
-
/** An optional URL for the user's ENS avatar image. */
|
57
|
-
ensAvatar?: string;
|
58
|
-
/** Optional additional CSS classes for the container. */
|
59
|
-
className?: string;
|
60
|
-
};
|
61
|
-
/**
|
62
|
-
* A component that displays a user's avatar.
|
63
|
-
* It prioritizes showing the provided `ensAvatar`. If unavailable, it falls back
|
64
|
-
* to a procedurally generated "blockie" based on the user's address.
|
65
|
-
* It also generates a unique background color from the address as a placeholder.
|
66
|
-
*
|
67
|
-
* @param {WalletAvatarProps} props - The component props.
|
68
|
-
* @returns {JSX.Element} The rendered avatar component.
|
24
|
+
* A simple, styled close button component ('X' icon) intended for use within toast notifications.
|
25
|
+
* It uses theme-aware CSS variables for styling and i18n labels for accessibility.
|
69
26
|
*/
|
70
|
-
declare function
|
27
|
+
declare function ToastCloseButton({ closeToast }: ToastCloseButtonProps): react_jsx_runtime.JSX.Element;
|
71
28
|
|
72
|
-
type
|
73
|
-
|
74
|
-
ensAvatar?: string;
|
75
|
-
};
|
76
|
-
type NameRenderProps = {
|
77
|
-
ensName?: string;
|
78
|
-
isLoading: boolean;
|
79
|
-
address: string;
|
80
|
-
};
|
81
|
-
type AddressRenderProps = {
|
82
|
-
address: string;
|
83
|
-
explorerUrl: string;
|
84
|
-
};
|
85
|
-
/**
|
86
|
-
* Defines the props for the `WalletHeader` component, including extensive customization options.
|
87
|
-
*/
|
88
|
-
interface WalletHeaderProps {
|
89
|
-
/** The user's wallet address. If undefined, the 'not connected' state is shown. */
|
90
|
-
walletAddress?: string;
|
91
|
-
explorerUrl: string;
|
92
|
-
/** Optional additional CSS classes for the container. */
|
93
|
-
className?: string;
|
94
|
-
/** A render prop to replace the default `WalletAvatar` component. */
|
95
|
-
renderAvatar?: (props: AvatarRenderProps) => ReactNode;
|
96
|
-
/** A render prop to replace the default ENS name display. */
|
97
|
-
renderName?: (props: NameRenderProps) => ReactNode;
|
98
|
-
/** A render prop to replace the default `WalletAddressDisplay` component. */
|
99
|
-
renderAddressDisplay?: (props: AddressRenderProps) => ReactNode;
|
100
|
-
/** A render prop to replace the default content shown when no wallet is connected. */
|
101
|
-
renderNoWalletContent?: () => ReactNode;
|
102
|
-
}
|
103
|
-
/**
|
104
|
-
* A component that displays the header for the wallet modal, including the user's avatar,
|
105
|
-
* ENS name (if available), and address. It handles loading states for ENS data and
|
106
|
-
* provides a "not connected" view.
|
107
|
-
*
|
108
|
-
* @param {WalletHeaderProps} props - The component props.
|
109
|
-
* @returns {JSX.Element} The rendered wallet header.
|
110
|
-
*/
|
111
|
-
declare function WalletHeader({ walletAddress, className, renderAvatar, renderName, renderAddressDisplay, renderNoWalletContent, explorerUrl, }: WalletHeaderProps): JSX.Element;
|
112
|
-
|
113
|
-
/**
|
114
|
-
* @file This file contains the `TxActionButton`, a stateful button for initiating and tracking transactions.
|
115
|
-
* It provides users with immediate visual feedback throughout the lifecycle of a transaction,
|
116
|
-
* from initiation to success, failure, or replacement.
|
117
|
-
*/
|
118
|
-
|
119
|
-
interface TxActionButtonProps<TR, T extends Transaction<TR>> extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'>, Pick<IInitializeTxTrackingStore<TR, T>, 'transactionsPool'> {
|
120
|
-
/** The default content to display when the button is in its 'idle' state. Typically the button's primary call to action text. */
|
29
|
+
type TxActionButtonProps<TR, T extends Transaction<TR>> = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> & {
|
30
|
+
/** The default content to display when the button is 'idle'. */
|
121
31
|
children: ReactNode;
|
122
|
-
/** The
|
32
|
+
/** The async function to execute when the button is clicked to initiate the transaction. */
|
123
33
|
action: () => Promise<void>;
|
124
|
-
/** A function that returns the unique key
|
34
|
+
/** A function that returns the unique key of the most recently initiated transaction. */
|
125
35
|
getLastTxKey: () => string | undefined;
|
126
|
-
/**
|
36
|
+
/** The global transaction pool from the Pulsar store. */
|
37
|
+
transactionsPool: TransactionPool<TR, T>;
|
38
|
+
/** Optional active wallet address. If provided, the button will only track transactions from this address. */
|
39
|
+
walletAddress?: string;
|
40
|
+
/** Optional custom content for the 'loading' state. */
|
127
41
|
loadingContent?: ReactNode;
|
128
|
-
/** Optional custom content
|
42
|
+
/** Optional custom content for the 'succeed' state. */
|
129
43
|
succeedContent?: ReactNode;
|
130
|
-
/** Optional custom content
|
44
|
+
/** Optional custom content for the 'failed' state. */
|
131
45
|
failedContent?: ReactNode;
|
132
|
-
/** Optional custom content
|
46
|
+
/** Optional custom content for the 'replaced' state. */
|
133
47
|
replacedContent?: ReactNode;
|
134
|
-
/** The duration (in
|
48
|
+
/** The duration (in ms) to display a final state before resetting to 'idle'. Defaults to 2500ms. */
|
135
49
|
resetTimeout?: number;
|
136
|
-
|
137
|
-
walletAddress?: string;
|
138
|
-
}
|
50
|
+
};
|
139
51
|
/**
|
140
52
|
* A stateful button that provides real-time feedback for a transaction's lifecycle.
|
141
|
-
* It listens for changes in
|
142
|
-
* visual state, showing loading, success, failure, and replaced statuses.
|
143
|
-
*
|
144
|
-
* @template TR - The generic type for the transaction tracker registry.
|
145
|
-
* @template T - The generic type for the transaction object.
|
146
|
-
* @param {TxActionButtonProps<TR, T>} props - The component props.
|
147
|
-
* @returns {JSX.Element} The rendered stateful action button.
|
53
|
+
* It listens for changes in `transactionsPool` to automatically update its visual state.
|
148
54
|
*/
|
149
|
-
declare function TxActionButton<TR, T extends Transaction<TR>>({ children, action, getLastTxKey, loadingContent, succeedContent, failedContent, replacedContent, resetTimeout,
|
55
|
+
declare function TxActionButton<TR, T extends Transaction<TR>>({ children, action, getLastTxKey, transactionsPool, walletAddress, loadingContent, succeedContent, failedContent, replacedContent, resetTimeout, className, ...props }: TxActionButtonProps<TR, T>): react_jsx_runtime.JSX.Element;
|
150
56
|
|
151
57
|
/**
|
152
58
|
* @file This file contains the default English labels for all UI components.
|
@@ -160,4 +66,4 @@ declare function TxActionButton<TR, T extends Transaction<TR>>({ children, actio
|
|
160
66
|
*/
|
161
67
|
declare const defaultLabels: TuwaLabels;
|
162
68
|
|
163
|
-
export { ToastCloseButton,
|
69
|
+
export { ToastCloseButton, type ToastCloseButtonProps, TuwaLabels, TxActionButton, type TxActionButtonProps, defaultLabels };
|
package/dist/index.d.ts
CHANGED
@@ -1,152 +1,58 @@
|
|
1
|
-
import { T as TuwaLabels } from './
|
2
|
-
export {
|
3
|
-
import
|
4
|
-
import { Transaction,
|
5
|
-
import 'react
|
6
|
-
import 'react/jsx-runtime';
|
1
|
+
import { T as TuwaLabels } from './WalletInfoModal-DP-qlvYl.js';
|
2
|
+
export { a as HashLink, H as HashLinkProps, b as StatusAwareText, S as StatusAwareTextProps, o as StepProps, n as StepStatus, e as ToastTransaction, c as ToastTransactionCustomization, d as ToastTransactionProps, h as TrackingTxModal, f as TrackingTxModalCustomization, g as TrackingTxModalProps, v as TransactionHistoryItem, t as TransactionHistoryItemCustomization, u as TransactionHistoryItemProps, x as TransactionKey, w as TransactionKeyProps, C as TransactionStatusBadge, B as TransactionStatusBadgeProps, A as TransactionsHistory, y as TransactionsHistoryCustomization, z as TransactionsHistoryProps, j as TxErrorBlock, i as TxErrorBlockProps, m as TxInfoBlock, k as TxInfoBlockCustomization, l as TxInfoBlockProps, q as TxProgressIndicator, p as TxProgressIndicatorProps, s as TxStatusVisual, r as TxStatusVisualProps, D as WalletAddressDisplay, W as WalletAddressDisplayProps, F as WalletAvatar, E as WalletAvatarProps, I as WalletHeader, G as WalletHeaderProps, L as WalletInfoModal, J as WalletInfoModalCustomization, K as WalletInfoModalProps } from './WalletInfoModal-DP-qlvYl.js';
|
3
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
4
|
+
import { Transaction, TransactionPool } from '@tuwaio/pulsar-core';
|
5
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
7
6
|
import '@radix-ui/react-dialog';
|
8
7
|
import 'framer-motion';
|
8
|
+
import 'react-toastify';
|
9
9
|
|
10
10
|
/**
|
11
|
-
* @file This file contains a reusable close button component,
|
11
|
+
* @file This file contains a reusable close button component, designed primarily for toast notifications.
|
12
|
+
*/
|
13
|
+
/**
|
14
|
+
* Defines the props for the ToastCloseButton component.
|
12
15
|
*/
|
13
|
-
|
14
16
|
type ToastCloseButtonProps = {
|
15
17
|
/**
|
16
|
-
* The function to call when the button is clicked.
|
17
|
-
*
|
18
|
+
* The function to call when the button is clicked. This is typically provided by the
|
19
|
+
* toast library (e.g., react-toastify) to dismiss the notification.
|
18
20
|
*/
|
19
21
|
closeToast?: (e: React.MouseEvent<HTMLElement>) => void;
|
20
22
|
};
|
21
23
|
/**
|
22
|
-
* A simple, styled close button component (X icon)
|
23
|
-
*
|
24
|
-
* @param {ToastCloseButtonProps} props - The component props.
|
25
|
-
* @returns {JSX.Element} The rendered close button.
|
26
|
-
*/
|
27
|
-
declare function ToastCloseButton({ closeToast }: ToastCloseButtonProps): JSX.Element;
|
28
|
-
|
29
|
-
/**
|
30
|
-
* @file This file contains the `WalletAddressDisplay` component, a UI element for showing a wallet address.
|
31
|
-
*/
|
32
|
-
|
33
|
-
type WalletAddressDisplayProps = {
|
34
|
-
/** The wallet address to display. */
|
35
|
-
address: string;
|
36
|
-
explorerUrl: string;
|
37
|
-
/** Optional additional CSS classes for the container. */
|
38
|
-
className?: string;
|
39
|
-
};
|
40
|
-
/**
|
41
|
-
* A component that renders a wallet address in a styled "pill" format,
|
42
|
-
* including a copy button and a link to the appropriate block explorer.
|
43
|
-
*
|
44
|
-
* @param {WalletAddressDisplayProps} props - The component props.
|
45
|
-
* @returns {JSX.Element} The rendered component.
|
46
|
-
*/
|
47
|
-
declare function WalletAddressDisplay({ address, explorerUrl, className }: WalletAddressDisplayProps): JSX.Element;
|
48
|
-
|
49
|
-
/**
|
50
|
-
* @file This file contains the `WalletAvatar` component for displaying a user's avatar.
|
51
|
-
*/
|
52
|
-
|
53
|
-
type WalletAvatarProps = {
|
54
|
-
/** The user's wallet address. Used for the blockie fallback and background color generation. */
|
55
|
-
address: string;
|
56
|
-
/** An optional URL for the user's ENS avatar image. */
|
57
|
-
ensAvatar?: string;
|
58
|
-
/** Optional additional CSS classes for the container. */
|
59
|
-
className?: string;
|
60
|
-
};
|
61
|
-
/**
|
62
|
-
* A component that displays a user's avatar.
|
63
|
-
* It prioritizes showing the provided `ensAvatar`. If unavailable, it falls back
|
64
|
-
* to a procedurally generated "blockie" based on the user's address.
|
65
|
-
* It also generates a unique background color from the address as a placeholder.
|
66
|
-
*
|
67
|
-
* @param {WalletAvatarProps} props - The component props.
|
68
|
-
* @returns {JSX.Element} The rendered avatar component.
|
24
|
+
* A simple, styled close button component ('X' icon) intended for use within toast notifications.
|
25
|
+
* It uses theme-aware CSS variables for styling and i18n labels for accessibility.
|
69
26
|
*/
|
70
|
-
declare function
|
27
|
+
declare function ToastCloseButton({ closeToast }: ToastCloseButtonProps): react_jsx_runtime.JSX.Element;
|
71
28
|
|
72
|
-
type
|
73
|
-
|
74
|
-
ensAvatar?: string;
|
75
|
-
};
|
76
|
-
type NameRenderProps = {
|
77
|
-
ensName?: string;
|
78
|
-
isLoading: boolean;
|
79
|
-
address: string;
|
80
|
-
};
|
81
|
-
type AddressRenderProps = {
|
82
|
-
address: string;
|
83
|
-
explorerUrl: string;
|
84
|
-
};
|
85
|
-
/**
|
86
|
-
* Defines the props for the `WalletHeader` component, including extensive customization options.
|
87
|
-
*/
|
88
|
-
interface WalletHeaderProps {
|
89
|
-
/** The user's wallet address. If undefined, the 'not connected' state is shown. */
|
90
|
-
walletAddress?: string;
|
91
|
-
explorerUrl: string;
|
92
|
-
/** Optional additional CSS classes for the container. */
|
93
|
-
className?: string;
|
94
|
-
/** A render prop to replace the default `WalletAvatar` component. */
|
95
|
-
renderAvatar?: (props: AvatarRenderProps) => ReactNode;
|
96
|
-
/** A render prop to replace the default ENS name display. */
|
97
|
-
renderName?: (props: NameRenderProps) => ReactNode;
|
98
|
-
/** A render prop to replace the default `WalletAddressDisplay` component. */
|
99
|
-
renderAddressDisplay?: (props: AddressRenderProps) => ReactNode;
|
100
|
-
/** A render prop to replace the default content shown when no wallet is connected. */
|
101
|
-
renderNoWalletContent?: () => ReactNode;
|
102
|
-
}
|
103
|
-
/**
|
104
|
-
* A component that displays the header for the wallet modal, including the user's avatar,
|
105
|
-
* ENS name (if available), and address. It handles loading states for ENS data and
|
106
|
-
* provides a "not connected" view.
|
107
|
-
*
|
108
|
-
* @param {WalletHeaderProps} props - The component props.
|
109
|
-
* @returns {JSX.Element} The rendered wallet header.
|
110
|
-
*/
|
111
|
-
declare function WalletHeader({ walletAddress, className, renderAvatar, renderName, renderAddressDisplay, renderNoWalletContent, explorerUrl, }: WalletHeaderProps): JSX.Element;
|
112
|
-
|
113
|
-
/**
|
114
|
-
* @file This file contains the `TxActionButton`, a stateful button for initiating and tracking transactions.
|
115
|
-
* It provides users with immediate visual feedback throughout the lifecycle of a transaction,
|
116
|
-
* from initiation to success, failure, or replacement.
|
117
|
-
*/
|
118
|
-
|
119
|
-
interface TxActionButtonProps<TR, T extends Transaction<TR>> extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'>, Pick<IInitializeTxTrackingStore<TR, T>, 'transactionsPool'> {
|
120
|
-
/** The default content to display when the button is in its 'idle' state. Typically the button's primary call to action text. */
|
29
|
+
type TxActionButtonProps<TR, T extends Transaction<TR>> = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onClick'> & {
|
30
|
+
/** The default content to display when the button is 'idle'. */
|
121
31
|
children: ReactNode;
|
122
|
-
/** The
|
32
|
+
/** The async function to execute when the button is clicked to initiate the transaction. */
|
123
33
|
action: () => Promise<void>;
|
124
|
-
/** A function that returns the unique key
|
34
|
+
/** A function that returns the unique key of the most recently initiated transaction. */
|
125
35
|
getLastTxKey: () => string | undefined;
|
126
|
-
/**
|
36
|
+
/** The global transaction pool from the Pulsar store. */
|
37
|
+
transactionsPool: TransactionPool<TR, T>;
|
38
|
+
/** Optional active wallet address. If provided, the button will only track transactions from this address. */
|
39
|
+
walletAddress?: string;
|
40
|
+
/** Optional custom content for the 'loading' state. */
|
127
41
|
loadingContent?: ReactNode;
|
128
|
-
/** Optional custom content
|
42
|
+
/** Optional custom content for the 'succeed' state. */
|
129
43
|
succeedContent?: ReactNode;
|
130
|
-
/** Optional custom content
|
44
|
+
/** Optional custom content for the 'failed' state. */
|
131
45
|
failedContent?: ReactNode;
|
132
|
-
/** Optional custom content
|
46
|
+
/** Optional custom content for the 'replaced' state. */
|
133
47
|
replacedContent?: ReactNode;
|
134
|
-
/** The duration (in
|
48
|
+
/** The duration (in ms) to display a final state before resetting to 'idle'. Defaults to 2500ms. */
|
135
49
|
resetTimeout?: number;
|
136
|
-
|
137
|
-
walletAddress?: string;
|
138
|
-
}
|
50
|
+
};
|
139
51
|
/**
|
140
52
|
* A stateful button that provides real-time feedback for a transaction's lifecycle.
|
141
|
-
* It listens for changes in
|
142
|
-
* visual state, showing loading, success, failure, and replaced statuses.
|
143
|
-
*
|
144
|
-
* @template TR - The generic type for the transaction tracker registry.
|
145
|
-
* @template T - The generic type for the transaction object.
|
146
|
-
* @param {TxActionButtonProps<TR, T>} props - The component props.
|
147
|
-
* @returns {JSX.Element} The rendered stateful action button.
|
53
|
+
* It listens for changes in `transactionsPool` to automatically update its visual state.
|
148
54
|
*/
|
149
|
-
declare function TxActionButton<TR, T extends Transaction<TR>>({ children, action, getLastTxKey, loadingContent, succeedContent, failedContent, replacedContent, resetTimeout,
|
55
|
+
declare function TxActionButton<TR, T extends Transaction<TR>>({ children, action, getLastTxKey, transactionsPool, walletAddress, loadingContent, succeedContent, failedContent, replacedContent, resetTimeout, className, ...props }: TxActionButtonProps<TR, T>): react_jsx_runtime.JSX.Element;
|
150
56
|
|
151
57
|
/**
|
152
58
|
* @file This file contains the default English labels for all UI components.
|
@@ -160,4 +66,4 @@ declare function TxActionButton<TR, T extends Transaction<TR>>({ children, actio
|
|
160
66
|
*/
|
161
67
|
declare const defaultLabels: TuwaLabels;
|
162
68
|
|
163
|
-
export { ToastCloseButton,
|
69
|
+
export { ToastCloseButton, type ToastCloseButtonProps, TuwaLabels, TxActionButton, type TxActionButtonProps, defaultLabels };
|
package/dist/index.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
import {ArrowTopRightOnSquareIcon,CheckIcon,DocumentDuplicateIcon,XMarkIcon,ArrowPathIcon,XCircleIcon,CheckCircleIcon,ExclamationTriangleIcon,ExclamationCircleIcon,ClockIcon}from'@heroicons/react/24/solid';import {useCopyToClipboard,cn,textCenterEllipsis}from'@tuwaio/nova-core';import {createContext,useContext,useState,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {TransactionStatus,TransactionAdapter,selectAdapterByKey,selectAllTransactionsByActiveWallet}from'@tuwaio/pulsar-core';import'react-toastify';import {Web3Icon}from'@bgd-labs/react-web3-icons';import {getChainName}from'@bgd-labs/react-web3-icons/dist/utils';import {TransactionTracker,getName,getAvatar}from'@tuwaio/pulsar-evm';import*as g from'@radix-ui/react-dialog';import {AnimatePresence,motion}from'framer-motion';import Wt from'dayjs';import Ve from'dayjs/plugin/relativeTime';import Ut from'ethereum-blockies-base64';import {zeroAddress,isHex}from'viem';var Z={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 Zt=createContext(Z);var u=()=>useContext(Zt);({[TransactionStatus.Success]:"success",[TransactionStatus.Failed]:"error",[TransactionStatus.Replaced]:"info"});function gt({label:t,hash:e,explorerUrl:o,variant:a="default",className:s}){let{isCopied:r,copy:n}=useCopyToClipboard(),d=u(),l=cn("flex items-center justify-between",a==="default"&&"text-sm",a==="compact"&&"text-xs",s),p=cn("pr-1",a==="default"&&"font-bold text-[var(--tuwa-text-primary)]",a==="compact"&&"font-medium text-[var(--tuwa-text-secondary)]"),c=jsx("span",{className:"font-mono",children:textCenterEllipsis(e,5,5)});return jsxs("div",{className:l,children:[t&&jsxs("span",{className:p,children:[t,":"]}),jsxs("div",{className:"flex items-center gap-x-2",children:[o?jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-x-1 text-[var(--tuwa-text-accent)] hover:underline",title:d.actions.viewOnExplorer,"aria-label":d.actions.viewOnExplorer,children:[c,jsx(ArrowTopRightOnSquareIcon,{className:"h-4 w-4"})]}):c,jsx("button",{type:"button",onClick:()=>n(e),className:"cursor-pointer text-[var(--tuwa-text-tertiary)] transition-colors hover:text-[var(--tuwa-text-secondary)]",title:r?d.txError.copied:d.actions.copy,"aria-label":r?d.txError.copied:d.actions.copy,children:r?jsx(CheckIcon,{className:"h-4 w-4 text-[var(--tuwa-success-icon)]"}):jsx(DocumentDuplicateIcon,{className:"h-4 w-4"})})]})]})}var bt={[TransactionStatus.Success]:{index:1,colorClass:"text-[var(--tuwa-success-text)]"},[TransactionStatus.Failed]:{index:2,colorClass:"text-[var(--tuwa-error-text)]"},[TransactionStatus.Replaced]:{index:3,colorClass:"text-[var(--tuwa-text-secondary)]"},default:{index:0,colorClass:"text-[var(--tuwa-text-primary)]"}};function N({txStatus:t,source:e,fallback:o,variant:a,className:s,applyColor:r=false}){let n=a==="title"?"text-sm font-semibold text-[var(--tuwa-text-primary)]":"mt-1 text-xs text-[var(--tuwa-text-secondary)]";if(typeof e=="string")return jsx("div",{className:cn(n,s),children:e});if(Array.isArray(e)){let l=bt[t||"default"]||bt.default,p=e[l.index],c=r?l.colorClass:"";return jsx("div",{className:cn(n,c,s),children:p})}return o?jsx("div",{className:cn(n,s),children:o}):null}function te({closeToast:t}){let e=u();return jsx("button",{type:"button",onClick:t,"aria-label":e.actions.close,title:e.actions.close,className:"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:jsx(XMarkIcon,{className:"h-5 w-5"})})}function O({tx:t,adapters:e,transactionsPool:o,variant:a="toast",className:s,renderHashLink:r}){let n=u();if(t?.adapter!==TransactionAdapter.EVM)return null;let d=!!t.replacedTxHash,l=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",p=m=>r?r(m):jsx(gt,{...m}),c=selectAdapterByKey({adapterKey:t.adapter,adapters:e});return jsxs("div",{className:cn(l,s),children:[t.tracker===TransactionTracker.Gelato&&p({label:n.hashLabels.gelato,hash:t.txKey,variant:"compact"}),t.tracker===TransactionTracker.Safe&&p({label:n.hashLabels.safe,hash:t.txKey,variant:"compact"}),d?jsxs(Fragment,{children:[t.hash&&p({label:n.hashLabels.original,hash:t.hash,variant:"compact"}),t.replacedTxHash&&c?.getExplorerTxUrl&&p({label:n.hashLabels.replaced,hash:t.replacedTxHash,explorerUrl:c.getExplorerTxUrl(o,t.txKey,t.replacedTxHash)})]}):t.hash&&c?.getExplorerTxUrl&&p({label:n.hashLabels.default,hash:t.hash,explorerUrl:c?.getExplorerTxUrl(o,t.txKey)})]})}function $({tx:t,className:e}){let o=u(),a={Pending:{label:o.statuses.pending,Icon:ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-pending-bg)] text-[var(--tuwa-pending-text)]",iconClasses:"animate-spin text-[var(--tuwa-pending-icon)]"},[TransactionStatus.Success]:{label:o.statuses.success,Icon:CheckCircleIcon,badgeClasses:"bg-[var(--tuwa-success-bg)] text-[var(--tuwa-success-text)]",iconClasses:"text-[var(--tuwa-success-icon)]"},[TransactionStatus.Failed]:{label:o.statuses.failed,Icon:XCircleIcon,badgeClasses:"bg-[var(--tuwa-error-bg)] text-[var(--tuwa-error-text)]",iconClasses:"text-[var(--tuwa-error-icon)]"},[TransactionStatus.Replaced]:{label:o.statuses.replaced,Icon:ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",iconClasses:"text-[var(--tuwa-info-icon)]"}},s="inline-flex items-center gap-x-1.5 rounded-full px-2 py-1 text-xs font-medium",r=t.pending?"Pending":t.status,n=r?a[r]:null;if(!n)return jsx("div",{className:cn(s,"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",e),children:t.status??o.statuses.unknown});let{label:d,Icon:l,badgeClasses:p,iconClasses:c}=n;return jsxs("div",{className:cn(s,p,e),children:[jsx(l,{className:cn("h-4 w-4",c)}),d]})}function ee({openWalletInfoModal:t,tx:e,transactionsPool:o,icon:a,className:s,customization:r,connectedWalletAddress:n,adapters:d}){let l=u(),p=r?.components,c=selectAdapterByKey({adapterKey:e.adapter??TransactionAdapter.EVM,adapters:d}),m=n&&e?.adapter===TransactionAdapter.EVM&&e.nonce!==void 0&&e.pending&&e.maxFeePerGas&&e.maxPriorityFeePerGas,i=async()=>{m&&c?.cancelTxAction&&await c.cancelTxAction(e);},x=async()=>{m&&c?.speedUpTxAction&&await c.speedUpTxAction(e);};return jsxs("div",{className:cn("flex w-full flex-col gap-3 rounded-lg bg-[var(--tuwa-bg-primary)] p-4 shadow-md",s),children:[jsxs("div",{className:"flex items-start gap-3",children:[jsx("div",{className:"w-[40px] flex-shrink-0",title:getChainName(e.chainId),children:a??jsx(Web3Icon,{chainId:e.chainId})}),jsxs("div",{className:"flex-1",children:[p?.statusAwareText?p.statusAwareText({txStatus:e.status,source:e.title,fallback:e.type,variant:"title",applyColor:true}):jsx(N,{txStatus:e.status,source:e.title,fallback:e.type,variant:"title",applyColor:true}),p?.statusAwareText?p.statusAwareText({txStatus:e.status,source:e.description,variant:"description"}):jsx(N,{txStatus:e.status,source:e.description,variant:"description"})]})]}),jsxs("div",{children:[p?.transactionKey?p.transactionKey({transactionsPool:o,adapters:d,tx:e,variant:"toast"}):jsx(O,{transactionsPool:o,adapters:d,tx:e,variant:"toast"}),jsxs("div",{className:"mt-3 flex items-center justify-between",children:[p?.statusBadge?p.statusBadge({tx:e}):jsx($,{tx:e}),m?jsxs("div",{className:"flex items-center gap-4",children:[p?.speedUpButton?p.speedUpButton({onClick:x,children:l.actions.speedUp}):jsx("button",{onClick:x,type:"button",className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-accent)] transition-opacity hover:opacity-80",children:l.actions.speedUp}),p?.cancelButton?p.cancelButton({onClick:i,children:l.actions.cancel}):jsx("button",{onClick:i,type:"button",className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-secondary)] transition-opacity hover:opacity-80",children:l.actions.cancel})]}):n&&t&&(p?.walletInfoButton?p.walletInfoButton({onClick:()=>t(true),children:l.toast.openWalletInfo}):jsx("button",{className:"cursor-pointer bg-gradient-to-r from-[var(--tuwa-button-gradient-from)] to-[var(--tuwa-button-gradient-to)] text-[var(--tuwa-text-on-accent)] font-bold text-xs py-1 px-3 rounded-md shadow-lg hover:shadow-xl hover:from-[var(--tuwa-button-gradient-from-hover)] hover:to-[var(--tuwa-button-gradient-to-hover)] active:scale-95 transition-all duration-200 ease-in-out",onClick:()=>t(true),type:"button",children:l.toast.openWalletInfo}))]})]})]})}function kt({error:t,className:e}){let{isCopied:o,copy:a}=useCopyToClipboard(),s=u();return t?jsxs("div",{className:cn("rounded-lg border border-[var(--tuwa-error-icon)]/30 bg-[var(--tuwa-error-bg)] p-3 text-sm",e),children:[jsxs("div",{className:"mb-2 flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2 font-bold text-[var(--tuwa-error-icon)]",children:[jsx(ExclamationTriangleIcon,{className:"h-5 w-5"}),jsx("span",{children:s.txError.title})]}),jsx("button",{type:"button",onClick:()=>a(t),title:s.actions.copy,"aria-label":s.actions.copy,className:"cursor-pointer text-[var(--tuwa-error-icon)]/50 transition-colors hover:text-[var(--tuwa-error-icon)]",children:jsx(DocumentDuplicateIcon,{className:"h-5 w-5"})})]}),jsx("div",{className:"max-h-24 overflow-y-auto rounded bg-[var(--tuwa-bg-primary)] p-2",children:jsx("p",{className:"font-mono text-xs text-[var(--tuwa-error-text)] break-all",children:t})}),jsx("div",{className:"mt-1 h-5 text-right",children:jsx("p",{className:cn("text-xs text-[var(--tuwa-success-icon)] transition-opacity duration-300 ease-in-out",o?"opacity-100":"opacity-0"),children:s.txError.copied})})]}):null}function Se({label:t,value:e}){return jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsx("span",{className:"text-[var(--tuwa-text-secondary)]",children:t}),jsx("span",{className:"font-medium text-[var(--tuwa-text-primary)]",children:e})]})}function St({tx:t,adapters:e,transactionsPool:o,className:a,customization:s}){let r=u(),n=d=>s?.components?.infoRow?s.components.infoRow(d):jsx(Se,{...d});return jsxs("div",{className:cn("flex flex-col gap-3 rounded-lg border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)] p-3",a),children:[n({label:r.txInfo.network,value:jsxs("div",{className:"flex items-center justify-end gap-2",children:[jsx("div",{className:"h-4 w-4",children:jsx(Web3Icon,{chainId:t.chainId??t?.desiredChainID??1})}),jsx("span",{children:getChainName(t.chainId??t?.desiredChainID??1)})]})}),t.localTimestamp&&n({label:r.txInfo.started,value:Wt.unix(t.localTimestamp).format("MMM D, HH:mm:ss")}),jsx("div",{className:"border-t border-[var(--tuwa-border-primary)] pt-3",children:jsx(O,{tx:t,adapters:e,transactionsPool:o,variant:"history",renderHashLink:s?.components?.transactionKey})})]})}function Be({status:t,label:e,isFirst:o=false}){let a={isCompleted:t==="completed",isError:t==="error",isReplaced:t==="replaced",isActive:t==="active"},s={line:cn({"bg-[var(--tuwa-success-icon)]":a.isCompleted,"bg-[var(--tuwa-error-icon)]":a.isError,"bg-[var(--tuwa-info-icon)]":a.isReplaced,"bg-[var(--tuwa-pending-icon)]":a.isActive,"bg-[var(--tuwa-border-primary)]":t==="inactive"}),border:cn({"border-[var(--tuwa-success-icon)]":a.isCompleted,"border-[var(--tuwa-error-icon)]":a.isError,"border-[var(--tuwa-info-icon)]":a.isReplaced,"border-[var(--tuwa-pending-icon)]":a.isActive,"border-[var(--tuwa-border-primary)]":t==="inactive"}),fill:cn({"bg-[var(--tuwa-success-icon)]":a.isCompleted,"bg-[var(--tuwa-error-icon)]":a.isError,"bg-[var(--tuwa-info-icon)]":a.isReplaced}),pulse:cn({"bg-[var(--tuwa-pending-icon)]":a.isActive})};return jsxs("div",{className:"relative flex flex-1 flex-col items-center min-w-[80px]",children:[!o&&jsx("div",{className:cn("absolute right-1/2 top-[10px] h-0.5 w-full",s.line)}),jsxs("div",{className:cn("relative z-10 flex h-5 w-5 items-center justify-center rounded-full border-2",s.border,s.fill),children:[a.isCompleted&&jsx(CheckIcon,{className:"h-3 w-3 text-white"}),a.isError&&jsx(ExclamationTriangleIcon,{className:"h-3 w-3 text-white"}),a.isReplaced&&jsx(ArrowPathIcon,{className:"h-3 w-3 text-white"}),a.isActive&&jsx("div",{className:cn("h-2 w-2 animate-pulse rounded-full",s.pulse)})]}),jsx("span",{className:cn("mt-2 text-center text-xs",t!=="inactive"?"font-semibold text-[var(--tuwa-text-primary)]":"text-[var(--tuwa-text-secondary)]"),children:e})]})}function Mt({isProcessing:t,isSucceed:e,isFailed:o,isReplaced:a,className:s,StepComponent:r=Be}){let n=u(),d=c=>{if(c===1)return "completed";if(c===2){if(e||o||a)return "completed";if(t)return "active"}if(c===3){if(e)return "completed";if(o)return "error";if(a)return "replaced";if(t)return "active"}return "inactive"},l=c=>c===1?n.trackingModal.progressIndicator.created:c===2?n.trackingModal.progressIndicator.processing:o?n.statuses.failed:a?n.statuses.replaced:n.trackingModal.progressIndicator.succeed,p=[{status:d(1),label:l(1),isFirst:true},{status:d(2),label:l(2)},{status:d(3),label:l(3),isLast:true}];return jsx("div",{className:cn("flex w-full items-start px-4 pt-2 pb-1",s),children:p.map((c,m)=>jsx(r,{...c},m))})}function Bt({isProcessing:t,isSucceed:e,isFailed:o,isReplaced:a}){let s;return e?s=jsx(CheckCircleIcon,{className:"h-16 w-16 text-[var(--tuwa-success-icon)]"}):o?s=jsx(ExclamationCircleIcon,{className:"h-16 w-16 text-[var(--tuwa-error-icon)]"}):a?s=jsx(ArrowPathIcon,{className:"h-16 w-16 text-[var(--tuwa-info-icon)]"}):t?s=jsx(ArrowPathIcon,{className:"h-16 w-16 animate-spin text-[var(--tuwa-text-accent)]"}):s=jsx(ClockIcon,{className:"h-16 w-16 animate-pulse text-[var(--tuwa-pending-icon)]"}),jsx("div",{className:"flex justify-center py-4",children:s})}function ae({adapters:t,onClose:e,onOpenWalletInfo:o,className:a,customization:s,transactionsPool:r,actions:n,handleTransaction:d,initialTx:l,connectedAdapterType:p}){let c=u(),m=s?.components,[i,x]=useState(void 0);useEffect(()=>{let D;r&&(l?.lastTxKey?D=r[l.lastTxKey]:i&&(D=r[i.txKey])),x(D);},[r,l,i]);let f=i??l,v=i?.status,P=l?.isInitializing??false,F=i?.pending??true,C=P||F,H=i?.isError||!!l?.errorMessage,V=f?.actionKey&&n?.[f.actionKey]&&d&&!!p,h=!!p&&i?.adapter===TransactionAdapter.EVM&&i?.nonce!==void 0&&i.pending&&i.maxFeePerGas&&i.maxPriorityFeePerGas,S=selectAdapterByKey({adapterKey:i?.adapter??TransactionAdapter.EVM,adapters:t}),I={initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2,ease:"easeOut"},...s?.motionProps},ft=async()=>{if(!V||!f?.actionKey)return;let D={adapter:TransactionAdapter.EVM,type:f.type,desiredChainID:i?.chainId||l?.desiredChainID||1,actionKey:f.actionKey,title:f.title,description:f.description,payload:f.payload,withTrackedModal:true};S?.retryTxAction&&await S.retryTxAction({tx:D,txKey:i?.txKey??"",actions:n,onClose:e,handleTransaction:d});},Tt=async()=>{h&&i&&S?.cancelTxAction&&await S.cancelTxAction(i);},xt=async()=>{console.log("handleSpeedUp: trackedTx",i),h&&i&&S?.speedUpTxAction&&await S.speedUpTxAction(i);},vt=(i?.isTrackedModalOpen||l?.withTrackedModal)??false;return jsx(g.Root,{open:vt,onOpenChange:D=>!D&&e(i?.txKey),children:jsx(g.Portal,{children:jsx(AnimatePresence,{children:vt&&jsxs(Fragment,{children:[jsx(g.Overlay,{asChild:true,children:jsx(motion.div,{className:"fixed inset-0 bg-black/60 z-50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}})}),jsx(g.Content,{className:"fixed left-1/2 top-1/2 w-full max-w-md -translate-x-1/2 -translate-y-1/2 outline-none z-50",onOpenAutoFocus:()=>x(void 0),...s?.modalProps,asChild:true,children:jsx(motion.div,{...I,children:jsxs("div",{className:cn("relative flex flex-col gap-3 rounded-2xl bg-[var(--tuwa-bg-primary)] p-5 pt-0 shadow-2xl max-h-[98dvh] overflow-y-auto",a),children:[m?.header?m.header({onClose:()=>e(i?.txKey)}):jsxs("header",{className:"flex items-start justify-between sticky top-0 w-full z-10 pt-5 pb-2 bg-[var(--tuwa-bg-primary)]",children:[jsx(g.Title,{className:"text-lg font-bold text-[var(--tuwa-text-primary)]",children:c.trackingModal.title}),jsx(g.Close,{asChild:true,children:jsx("button",{type:"button",onClick:()=>e(i?.txKey),"aria-label":c.actions.close,className:"cursor-pointer ml-2 -mt-1 rounded-full p-1 text-[var(--tuwa-text-tertiary)] transition-colors hover:bg-[var(--tuwa-bg-muted)] hover:text-[var(--tuwa-text-primary)]",children:jsx(XMarkIcon,{className:"h-5 w-5"})})})]}),jsxs("main",{className:"flex flex-col gap-3",children:[m?.statusVisual?m.statusVisual({isProcessing:C,isSucceed:v===TransactionStatus.Success,isFailed:H,isReplaced:v===TransactionStatus.Replaced}):jsx(Bt,{isProcessing:C,isSucceed:v===TransactionStatus.Success,isFailed:H,isReplaced:v===TransactionStatus.Replaced}),jsxs("div",{className:"flex flex-col items-center text-center -mt-2",children:[jsx(N,{txStatus:v,source:f?.title,fallback:f?.type,variant:"title",applyColor:true,className:"text-xl"}),jsx(N,{txStatus:v,source:f?.description,variant:"description",className:"mt-0"})]}),m?.progressIndicator?m.progressIndicator({isProcessing:C,isSucceed:v===TransactionStatus.Success,isFailed:H,isReplaced:v===TransactionStatus.Replaced}):jsx(Mt,{isProcessing:C,isSucceed:v===TransactionStatus.Success,isFailed:H,isReplaced:v===TransactionStatus.Replaced}),m?.infoBlock?m.infoBlock({tx:f,adapters:t,transactionsPool:r}):jsx(St,{tx:f,adapters:t,transactionsPool:r}),m?.errorBlock?m.errorBlock({error:i?.errorMessage||l?.errorMessage}):jsx(kt,{error:i?.errorMessage||l?.errorMessage})]}),m?.footer?m.footer({onClose:()=>e(i?.txKey),onOpenWalletInfo:o,isProcessing:C,onRetry:V?ft:void 0,onSpeedUp:h?xt:void 0,onCancel:h?Tt:void 0}):jsxs("footer",{className:"mt-2 flex w-full items-center justify-between border-t border-[var(--tuwa-border-primary)] pt-4",children:[jsx("div",{className:"flex items-center gap-4",children:h&&jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:xt,className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-accent)] transition-opacity hover:opacity-80",children:c.actions.speedUp}),jsx("button",{type:"button",onClick:Tt,className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-secondary)] transition-opacity hover:opacity-80",children:c.actions.cancel})]})}),jsxs("div",{className:"flex items-center gap-3",children:[H&&V?jsx("button",{type:"button",onClick:ft,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.trackingModal.retry}):!h&&jsx("button",{type:"button",onClick:o,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.trackingModal.walletInfo}),jsx("button",{type:"button",onClick:()=>e(i?.txKey),disabled:C&&!h,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:C&&!h?c.trackingModal.processing:c.trackingModal.close})]})]})]})})})]})})})})}Wt.extend(Ve);function Ht({tx:t,adapters:e,transactionsPool:o,className:a,customization:s}){let r=s?.components;return jsxs("div",{className: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:[jsxs("div",{className:"flex items-start justify-between",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full bg-[var(--tuwa-bg-muted)]",children:r?.icon?r.icon({chainId:t.chainId}):jsx("div",{className:"h-8 w-8 text-[var(--tuwa-text-secondary)]",children:jsx(Web3Icon,{chainId:t.chainId})})}),jsxs("div",{children:[r?.title?r.title({txStatus:t.status,source:t.title,fallback:t.type,variant:"title",applyColor:true}):jsx(N,{txStatus:t.status,source:t.title,fallback:t.type,variant:"title",applyColor:true}),r?.timestamp?r.timestamp({timestamp:t.localTimestamp}):jsx("span",{className:"mb-1 block text-xs text-[var(--tuwa-text-secondary)]",children:t.localTimestamp?Wt.unix(t.localTimestamp).fromNow():"..."}),r?.description?r.description({txStatus:t.status,source:t.description,variant:"description"}):jsx(N,{txStatus:t.status,source:t.description,variant:"description"})]})]}),r?.statusBadge?r.statusBadge({tx:t}):jsx($,{tx:t})]}),r?.transactionKey?r.transactionKey({tx:t,adapters:e,transactionsPool:o,variant:"history"}):jsx(O,{tx:t,adapters:e,transactionsPool:o,variant:"history"})]})}function _e({title:t,message:e,className:o}){return jsxs("div",{className:cn("rounded-lg bg-[var(--tuwa-bg-muted)] p-8 text-center",o),children:[jsx("h4",{className:"font-semibold text-[var(--tuwa-text-primary)]",children:t}),jsx("p",{className:"mt-1 text-sm text-[var(--tuwa-text-secondary)]",children:e})]})}function Dt({adapters:t,connectedWalletAddress:e,transactionsPool:o,className:a,customization:s}){let r=u(),n=s?.components,l=[...e?selectAllTransactionsByActiveWallet(o,e):[]].sort((m,i)=>(i.localTimestamp??0)-(m.localTimestamp??0)),p=(m,i)=>n?.placeholder?n.placeholder({title:m,message:i}):jsx(_e,{title:m,message:i}),c=n?.HistoryItem||Ht;return jsxs("div",{className:cn("flex flex-col gap-y-3",a),children:[jsx("h3",{className:"text-lg font-bold text-[var(--tuwa-text-primary)]",children:r.walletModal.history.title}),e?l.length>0?jsx("div",{className:cn("max-h-[400px] overflow-y-auto rounded-lg border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)]",s?.classNames?.listWrapper),children:l.map(m=>jsx(c,{tx:m,transactionsPool:o,adapters:t},m.txKey))}):p(r.walletModal.history.noTransactionsTitle,r.walletModal.history.noTransactionsMessage):p(r.walletModal.history.connectWalletTitle,r.walletModal.history.connectWalletMessage)]})}function Cs({children:t,action:e,getLastTxKey:o,loadingContent:a,succeedContent:s,failedContent:r,replacedContent:n,resetTimeout:d=2500,transactionsPool:l,className:p,walletAddress:c,...m}){let i=u(),[x,f]=useState("idle"),[v,P]=useState(void 0);useEffect(()=>{c||(f("idle"),P(void 0));},[c]),useEffect(()=>{if(v){let I=l[v];if(I?.status)switch(I.status){case TransactionStatus.Success:f("succeed");break;case TransactionStatus.Replaced:f("replaced");break;case TransactionStatus.Failed:f("failed");break}}},[l,v]),useEffect(()=>{if(x==="succeed"||x==="failed"||x==="replaced"){let I=setTimeout(()=>{f("idle"),P(void 0);},d);return ()=>clearTimeout(I)}},[x,d]);let F=async()=>{f("loading");try{await e(),P(o());}catch(I){console.error("Transaction initiation failed:",I),f("failed");}},C=jsxs(Fragment,{children:[jsx(ArrowPathIcon,{className:"h-4 w-4"}),jsx("span",{children:i.trackedTxButton.replaced})]}),H=jsxs(Fragment,{children:[jsx(ArrowPathIcon,{className:"h-4 w-4 animate-spin"}),jsx("span",{children:i.trackedTxButton.loading})]}),V=jsxs(Fragment,{children:[jsx(CheckCircleIcon,{className:"h-4 w-4"}),jsx("span",{children:i.trackedTxButton.succeed})]}),h=jsxs(Fragment,{children:[jsx(ExclamationCircleIcon,{className:"h-4 w-4"}),jsx("span",{children:i.trackedTxButton.failed})]}),S=()=>{switch(x){case "loading":return a??H;case "succeed":return s??V;case "failed":return r??h;case "replaced":return n??C;case "idle":default:return t}};return jsx("button",{...m,disabled:x!=="idle"||m.disabled,onClick:F,className:cn("cursor-pointer flex 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",x==="idle"&&"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",x==="loading"&&"bg-gray-400 text-white",x==="replaced"&&"bg-gray-500 text-white",x==="succeed"&&"bg-[var(--tuwa-success-bg)] text-[var(--tuwa-success-text)]",x==="failed"&&"bg-[var(--tuwa-error-bg)] text-[var(--tuwa-error-text)]",p),children:S()})}function mt({address:t,explorerUrl:e,className:o}){let{isCopied:a,copy:s}=useCopyToClipboard(),r=u(),n=e?`${e}/address/${t}`:void 0;return jsxs("div",{className: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:[jsx("span",{children:textCenterEllipsis(t,6,6)}),jsx("button",{type:"button",title:a?r.txError.copied:r.actions.copy,"aria-label":a?r.txError.copied:r.actions.copy,onClick:()=>s(t),className:"cursor-pointer transition-colors hover:text-[var(--tuwa-text-primary)]",children:a?jsx(CheckIcon,{className:"h-4 w-4 text-[var(--tuwa-success-icon)]"}):jsx(DocumentDuplicateIcon,{className:"h-4 w-4"})}),n&&jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"transition-colors hover:text-[var(--tuwa-text-accent)]",title:r.actions.viewOnExplorer,"aria-label":r.actions.viewOnExplorer,children:jsx(ArrowTopRightOnSquareIcon,{className:"h-4 w-4"})})]})}function Gt({address:t,ensAvatar:e,className:o}){let a=u(),s=`#${t.slice(2,8)}`,[r,n]=useState(void 0);return useEffect(()=>{n(e??Ut(isHex(t)?t:zeroAddress));},[e,t]),jsx("div",{className:cn("h-12 w-12 flex-shrink-0 rounded-full",o),style:{backgroundColor:s},children:jsx("img",{className:"h-full w-full rounded-full object-cover",src:r,alt:`${a.walletModal.header.avatarAlt} ${t}`,onError:()=>n(Ut(isHex(t)?t:zeroAddress))})})}function qt({walletAddress:t,className:e,renderAvatar:o,renderName:a,renderAddressDisplay:s,renderNoWalletContent:r,explorerUrl:n}){let d=u(),[l,p]=useState(void 0),[c,m]=useState(void 0),[i,x]=useState(true);if(useEffect(()=>{(async()=>{if(t){x(true),p(void 0),m(void 0);try{let P=await getName(t);if(P){p(P);let F=await getAvatar(P);m(F);}}finally{x(false);}}})();},[t]),!t)return r?jsx(Fragment,{children:r()}):jsx("div",{className:cn("flex h-20 items-center justify-center rounded-lg bg-[var(--tuwa-bg-muted)] text-[var(--tuwa-text-secondary)]",e),children:d.walletModal.header.notConnected});let f=l?l.length>30?textCenterEllipsis(l,12,12):l:void 0;return jsxs("div",{className:cn("flex items-center gap-4 min-h-[4rem]",e),children:[jsx("div",{children:o?o({address:t,ensAvatar:c}):jsx(Gt,{address:t,ensAvatar:c})}),jsx("div",{className:"flex flex-col justify-center min-h-[3.5rem] min-w-[200px]",children:a?a({ensName:f,isLoading:i,address:t}):jsxs("div",{className:"flex flex-col",children:[jsx("div",{className:"h-7 flex items-center mb-1.5",children:i?jsx("div",{className:"h-full w-48 animate-pulse rounded-md bg-[var(--tuwa-bg-muted)]"}):f?jsx("h2",{className:"text-xl font-bold text-[var(--tuwa-text-primary)]",children:f}):jsx(mt,{address:t,explorerUrl:n,className:"text-xl font-bold text-[var(--tuwa-text-primary)] bg-transparent px-0 py-0 rounded-none"})}),jsx("div",{className:"h-5 flex items-center",children:!i&&f&&(s?s({address:t,explorerUrl:n}):jsx(mt,{address:t,explorerUrl:n}))})]})})]})}function oe({isOpen:t,setIsOpen:e,customization:o,...a}){let s=u(),n={...{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.95},transition:{duration:.2,ease:"easeOut"}},...o?.motionProps},d=()=>e&&e(false);return jsx(g.Root,{open:t,onOpenChange:l=>!l&&d(),children:jsx(g.Portal,{children:jsx(AnimatePresence,{children:t&&jsxs(Fragment,{children:[jsx(g.Overlay,{asChild:true,children:jsx(motion.div,{className:"fixed inset-0 bg-black/45 flex items-center justify-center p-2 z-50",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15}})}),jsx(g.Content,{className:"fixed left-1/2 top-1/2 w-full max-w-2xl -translate-x-1/2 -translate-y-1/2 outline-none z-50",...o?.modalProps,asChild:true,children:jsx(motion.div,{...n,children:jsxs("div",{className:cn("relative w-full max-w-2xl outline-none rounded-2xl bg-[var(--tuwa-bg-secondary)] shadow-xl max-h-[98dvh] overflow-y-auto",o?.classNames?.contentWrapper),children:[o?.components?.header?o.components.header({closeModal:d}):jsxs("div",{className:"flex items-center justify-between border-b border-[var(--tuwa-border-primary)] p-4 sticky top-0 left-0 w-full bg-[var(--tuwa-bg-secondary)] z-10",children:[jsx(g.Title,{className:"text-lg font-bold text-[var(--tuwa-text-primary)]",children:s.walletModal.title}),jsx(g.Close,{asChild:true,children:jsx("button",{type:"button",onClick:d,"aria-label":s.actions.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:jsx(XMarkIcon,{className:"h-6 w-6"})})})]}),jsxs("div",{className:"flex flex-col gap-4 p-4 sm:p-6 sm:gap-6",children:[o?.components?.walletInfo?o.components.walletInfo(a):jsx(qt,{explorerUrl:selectAdapterByKey({adapterKey:a.connectedAdapterType??TransactionAdapter.EVM,adapters:a.adapters})?.getExplorerUrl()??"",walletAddress:a.connectedWalletAddress}),o?.components?.history?o.components.history(a):jsx(Dt,{...a})]})]})})})]})})})})}export{gt as HashLink,N as StatusAwareText,te as ToastCloseButton,ee as ToastTransaction,ae as TrackingTxModal,Ht as TransactionHistoryItem,O as TransactionKey,$ as TransactionStatusBadge,Dt as TransactionsHistory,Cs as TxActionButton,kt as TxErrorBlock,St as TxInfoBlock,Mt as TxProgressIndicator,Bt as TxStatusVisual,mt as WalletAddressDisplay,Gt as WalletAvatar,qt as WalletHeader,oe as WalletInfoModal,Z as defaultLabels};//# sourceMappingURL=index.js.map
|
1
|
+
import {ArrowTopRightOnSquareIcon,CheckIcon,DocumentDuplicateIcon,XMarkIcon,ArrowPathIcon,XCircleIcon,CheckCircleIcon,ExclamationTriangleIcon,ClockIcon,ExclamationCircleIcon}from'@heroicons/react/24/solid';import {useCopyToClipboard,cn,textCenterEllipsis}from'@tuwaio/nova-core';import {createContext,useContext,useMemo,useState,useEffect}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';import {TransactionStatus,selectAdapterByKey,selectAllTransactionsByActiveWallet}from'@tuwaio/pulsar-core';import'react-toastify';import {Web3Icon}from'@bgd-labs/react-web3-icons';import {getChainName}from'@bgd-labs/react-web3-icons/dist/utils';import*as P from'@radix-ui/react-dialog';import {AnimatePresence,motion}from'framer-motion';import Mt from'dayjs';import eo from'dayjs/plugin/relativeTime';import Co from'ethereum-blockies-base64';import {zeroAddress,isHex}from'viem';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=createContext(q);var u=()=>useContext(Yt);({[TransactionStatus.Success]:"success",[TransactionStatus.Failed]:"error",[TransactionStatus.Replaced]:"info"});function Tt({label:t,hash:e,explorerUrl:o,variant:a="default",className:r}){let{isCopied:n,copy:i}=useCopyToClipboard(),{actions:c,txError:p}=u(),l=cn("flex items-center justify-between",{"text-sm":a==="default","text-xs":a==="compact"},r),s=cn("pr-1",{"font-bold text-[var(--tuwa-text-primary)]":a==="default","font-medium text-[var(--tuwa-text-secondary)]":a==="compact"}),f=jsx("span",{className:"font-mono",children:textCenterEllipsis(e,5,5)});return jsxs("div",{className:l,children:[t&&jsxs("span",{className:s,children:[t,":"]}),jsxs("div",{className:"flex items-center gap-x-2",children:[o?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:c.viewOnExplorer,"aria-label":c.viewOnExplorer,children:[f,jsx(ArrowTopRightOnSquareIcon,{className:"h-4 w-4"})]}):jsx("span",{className:"text-[var(--tuwa-text-primary)]",children:f}),jsx("button",{type:"button",onClick:()=>i(e),className:"cursor-pointer text-[var(--tuwa-text-tertiary)] transition-colors hover:text-[var(--tuwa-text-secondary)]",title:n?p.copied:c.copy,"aria-label":n?p.copied:c.copy,children:n?jsx(CheckIcon,{className:"h-4 w-4 text-[var(--tuwa-success-icon)]"}):jsx(DocumentDuplicateIcon,{className:"h-4 w-4"})})]})]})}var xt={[TransactionStatus.Success]:{index:1,colorClass:"text-[var(--tuwa-success-text)]"},[TransactionStatus.Failed]:{index:2,colorClass:"text-[var(--tuwa-error-text)]"},[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:n=false}){let i,c="";if(typeof e=="string")i=e;else if(Array.isArray(e)){let s=xt[t||"default"]??xt.default;i=e[s.index],n&&(c=s.colorClass);}else i=o;return i?jsx("div",{className:cn(a==="title"?"text-sm font-semibold text-[var(--tuwa-text-primary)]":"mt-1 text-xs text-[var(--tuwa-text-secondary)]",c,r),children:i}):null}function qt({closeToast:t}){let{actions:e}=u();return jsx("button",{type:"button",onClick:t,"aria-label":e.close,title:e.close,className: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:jsx(XMarkIcon,{className:"h-5 w-5"})})}function O({tx:t,adapters:e,transactionsPool:o,variant:a="toast",className:r,renderHashLink:n}){let{hashLabels:i}=u(),c=selectAdapterByKey({adapterKey:t.adapter,adapters:e});if(!c)return null;let p=d=>n?n(d):jsx(Tt,{...d}),l=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",s=i[t.tracker],f=s?p({label:s,hash:t.txKey,variant:"compact"}):null,y=(()=>{let d=t.hash,x=t.replacedTxHash;return !d&&!x?null:x?jsxs(Fragment,{children:[d&&p({label:i.original,hash:d,variant:"compact"}),c.getExplorerTxUrl&&p({label:i.replaced,hash:x,explorerUrl:c.getExplorerTxUrl(o,t.txKey,x)})]}):d&&c.getExplorerTxUrl&&p({label:i.default,hash:d,explorerUrl:c.getExplorerTxUrl(o,t.txKey)})})(),T=s&&s!==i.default&&t.txKey!==t.hash;return jsxs("div",{className:cn(l,r),children:[T&&f,y]})}var xe=t=>({Pending:{label:t.pending,Icon:ArrowPathIcon,badgeClasses:"bg-[var(--tuwa-pending-bg)] text-[var(--tuwa-pending-text)]",iconClasses:"animate-spin text-[var(--tuwa-pending-icon)]"},[TransactionStatus.Success]:{label:t.success,Icon:CheckCircleIcon,badgeClasses:"bg-[var(--tuwa-success-bg)] text-[var(--tuwa-success-text)]",iconClasses:"text-[var(--tuwa-success-icon)]"},[TransactionStatus.Failed]:{label:t.failed,Icon:XCircleIcon,badgeClasses:"bg-[var(--tuwa-error-bg)] text-[var(--tuwa-error-text)]",iconClasses:"text-[var(--tuwa-error-icon)]"},[TransactionStatus.Replaced]:{label:t.replaced,Icon: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}=u(),a=useMemo(()=>xe(o),[o]),r="inline-flex items-center gap-x-1.5 rounded-full px-2 py-1 text-xs font-medium",n=t.pending?"Pending":t.status,i=n?a[n]:null;if(!i)return jsx("div",{className:cn(r,"bg-[var(--tuwa-info-bg)] text-[var(--tuwa-info-text)]",e),children:t.status??o.unknown});let{label:c,Icon:p,badgeClasses:l,iconClasses:s}=i;return jsxs("div",{className:cn(r,l,e),children:[jsx(p,{className:cn("h-4 w-4",s)}),c]})}var Ce=({onClick:t,children:e})=>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})=>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})=>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:n,connectedWalletAddress:i,adapters:c}){let{actions:p,toast:l}=u(),s=selectAdapterByKey({adapterKey:e.adapter,adapters:c}),f=!!(e.pending&&s?.speedUpTxAction&&s?.cancelTxAction&&e.from.toLowerCase()===i?.toLowerCase()),y=()=>{f&&s.cancelTxAction(e);},T=()=>{f&&s.speedUpTxAction(e);},{StatusAwareText:d=H,TransactionKey:x=O,StatusBadge:b=X,SpeedUpButton:R=Ce,CancelButton:v=Pe,WalletInfoButton:M=he}=n?.components??{};return jsxs("div",{className:cn("flex w-full flex-col gap-3 rounded-lg bg-[var(--tuwa-bg-primary)] p-4 shadow-md",r),children:[jsxs("div",{className:"flex items-start gap-3",children:[jsx("div",{className:"w-[40px] flex-shrink-0",title:getChainName(e.chainId),children:a??jsx(Web3Icon,{chainId:e.chainId})}),jsxs("div",{className:"flex-1",children:[jsx(d,{txStatus:e.status,source:e.title,fallback:e.type,variant:"title",applyColor:true}),jsx(d,{txStatus:e.status,source:e.description,variant:"description"})]})]}),jsxs("div",{children:[jsx(x,{transactionsPool:o,adapters:c,tx:e,variant:"toast"}),jsxs("div",{className:"mt-3 flex items-center justify-between",children:[jsx(b,{tx:e}),f?jsxs("div",{className:"flex items-center gap-4",children:[jsx(R,{onClick:T,children:p.speedUp}),jsx(v,{onClick:y,children:p.cancel})]}):t&&jsx(M,{onClick:t,children:l.openWalletInfo})]})]})]})}function wt({error:t,className:e}){let{isCopied:o,copy:a}=useCopyToClipboard(),{actions:r,txError:n}=u();return t?jsxs("div",{className:cn("rounded-lg border border-[var(--tuwa-error-icon)]/30 bg-[var(--tuwa-error-bg)] p-3 text-sm",e),children:[jsxs("div",{className:"mb-2 flex items-center justify-between",children:[jsxs("div",{className:"flex items-center gap-2 font-bold text-[var(--tuwa-error-icon)]",children:[jsx(ExclamationTriangleIcon,{className:"h-5 w-5"}),jsx("span",{children:n.title})]}),jsx("button",{type:"button",onClick:()=>a(t),title:o?n.copied:r.copy,"aria-label":o?n.copied:`${r.copy} error message`,className:"cursor-pointer text-[var(--tuwa-error-icon)]/50 transition-colors hover:text-[var(--tuwa-error-icon)]",children:o?jsx(CheckIcon,{className:"h-5 w-5 text-[var(--tuwa-success-icon)]"}):jsx(DocumentDuplicateIcon,{className:"h-5 w-5"})})]}),jsx("div",{className:"max-h-24 overflow-y-auto rounded bg-[var(--tuwa-bg-primary)] p-2",children:jsx("p",{className:"font-mono text-xs text-[var(--tuwa-error-text)] break-all",children:t})})]}):null}function Le({label:t,value:e}){return jsxs("div",{className:"flex items-center justify-between text-sm",children:[jsx("span",{className:"text-[var(--tuwa-text-secondary)]",children:t}),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:n}=u(),{InfoRow:i=Le}=r?.components??{},c="chainId"in t?t.chainId:t.desiredChainID;return jsxs("div",{className:cn("flex flex-col gap-3 rounded-lg border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)] p-3",a),children:[jsx(i,{label:n.network,value:jsxs("div",{className:"flex items-center justify-end gap-2",children:[jsx("div",{className:"h-4 w-4",children:jsx(Web3Icon,{chainId:c})}),jsx("span",{children:getChainName(c)})]})}),t.localTimestamp&&jsx(i,{label:n.started,value:Mt.unix(t.localTimestamp).format("MMM D, HH:mm:ss")}),"txKey"in t&&t.txKey&&jsx("div",{className:"border-t border-[var(--tuwa-border-primary)] pt-3",children: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 jsx(CheckIcon,{className:"h-3 w-3 text-white"});case "error":return jsx(ExclamationTriangleIcon,{className:"h-3 w-3 text-white"});case "replaced":return jsx(ArrowPathIcon,{className:"h-3 w-3 text-white"});case "active":return jsx("div",{className:cn("h-2 w-2 animate-pulse rounded-full",a.pulse)});default:return null}};return jsxs("div",{className:"relative flex min-w-[80px] flex-1 flex-col items-center",children:[!o&&jsx("div",{className:cn("absolute right-1/2 top-[10px] h-0.5 w-full",a.line)}),jsx("div",{className:cn("relative z-10 flex h-5 w-5 items-center justify-center rounded-full border-2",a.border,a.fill),children:r()}),jsx("span",{className: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:n=Ue}){let{trackingModal:i,statuses:c}=u(),p=useMemo(()=>{let l=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"},s=f=>f===1?i.progressIndicator.created:f===2?i.progressIndicator.processing:o?c.failed:a?c.replaced:i.progressIndicator.succeed;return [{status:l(1),label:s(1),isFirst:true},{status:l(2),label:s(2)},{status:l(3),label:s(3),isLast:true}]},[t,e,o,a,i,c]);return jsx("div",{className:cn("flex w-full items-start px-4 pt-2 pb-1",r),children:p.map((l,s)=>jsx(n,{...l},s))})}var $e={succeed:{Icon:CheckCircleIcon,className:"text-[var(--tuwa-success-icon)]"},failed:{Icon:ExclamationCircleIcon,className:"text-[var(--tuwa-error-icon)]"},replaced:{Icon:ArrowPathIcon,className:"text-[var(--tuwa-info-icon)]"},processing:{Icon:ArrowPathIcon,className:"animate-spin text-[var(--tuwa-text-accent)]"},initializing:{Icon: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:n,className:i}=$e[r];return jsx("div",{className:"flex justify-center py-4",children:jsx(n,{className:cn("h-16 w-16",i)})})}function Zt({adapters:t,onClose:e,onOpenWalletInfo:o,className:a,customization:r,transactionsPool:n,actions:i,handleTransaction:c,initialTx:p}){let l=useMemo(()=>p?.lastTxKey?n[p.lastTxKey]:void 0,[n,p]),s=l??p,f=p?.withTrackedModal&&!l||(l?.isTrackedModalOpen??false),{isProcessing:y,isSucceed:T,isFailed:d,isReplaced:x}=useMemo(()=>{let W=l?.status,Xt=p?.isInitializing??false,$t=l?.pending??false;return {isProcessing:Xt||$t,isSucceed:W===TransactionStatus.Success,isFailed:l?.isError||!!p?.errorMessage,isReplaced:W===TransactionStatus.Replaced}},[l,p]),b=useMemo(()=>s?selectAdapterByKey({adapterKey:s.adapter,adapters:t}):void 0,[s,t]),R=!!(d&&s?.actionKey&&i?.[s.actionKey]&&c),v=!!(b?.speedUpTxAction&&b?.cancelTxAction&&l?.pending),M=()=>{if(!R||!s?.actionKey||!b?.retryTxAction)return;let W={adapter:s.adapter,type:s.type,desiredChainID:"desiredChainID"in s?s.desiredChainID:s.chainId,actionKey:s.actionKey,title:s.title,description:s.description,payload:s.payload,withTrackedModal:true};b.retryTxAction({tx:W,txKey:l?.txKey??"",actions:i,onClose:e,handleTransaction:c});},w=()=>{v&&l&&b.cancelTxAction(l);},B=()=>{v&&l&&b.speedUpTxAction(l);},V=r?.components?.Header,ct=r?.components?.Footer,pt=r?.components?.StatusVisual,dt=r?.components?.ProgressIndicator,mt=r?.components?.InfoBlock,ut=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 s?jsx(P.Root,{open:f,onOpenChange:W=>!W&&e(l?.txKey),children:jsx(P.Portal,{children:jsx(AnimatePresence,{children:f&&jsxs(Fragment,{children:[jsx(P.Overlay,{asChild:true,children:jsx(motion.div,{className:"fixed inset-0 z-50 bg-black/60",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0}})}),jsx(P.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:jsx(motion.div,{..._t,children:jsxs("div",{className: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?jsx(V,{onClose:()=>e(l?.txKey),title:jsx(kt,{tx:s})}):jsx(Qe,{onClose:()=>e(l?.txKey),title:jsx(kt,{tx:s})}),jsxs("main",{className:"flex flex-col gap-3",children:[pt?jsx(pt,{isProcessing:y,isSucceed:T,isFailed:d,isReplaced:x}):jsx(Rt,{isProcessing:y,isSucceed:T,isFailed:d,isReplaced:x}),dt?jsx(dt,{isProcessing:y,isSucceed:T,isFailed:d,isReplaced:x}):jsx(Pt,{isProcessing:y,isSucceed:T,isFailed:d,isReplaced:x}),mt?jsx(mt,{tx:s,adapters:t,transactionsPool:n}):jsx(Ct,{tx:s,adapters:t,transactionsPool:n}),ut?jsx(ut,{error:l?.errorMessage||p?.errorMessage}):jsx(wt,{error:l?.errorMessage||p?.errorMessage})]}),ct?jsx(ct,{onClose:()=>e(l?.txKey),onOpenWalletInfo:o,isProcessing:y,isFailed:d,canReplace:v,onRetry:R?M:void 0,onSpeedUp:v?B:void 0,onCancel:v?w:void 0}):jsx(Ze,{onClose:()=>e(l?.txKey),onOpenWalletInfo:o,isProcessing:y,isFailed:d,canReplace:v,onRetry:R?M:void 0,onSpeedUp:v?B:void 0,onCancel:v?w:void 0})]})})})]})})})}):null}var kt=({tx:t})=>jsx(H,{txStatus:"status"in t?t.status:void 0,source:t.title,fallback:t.type,variant:"title",className:"text-lg"}),Qe=({onClose:t,title:e})=>{let{actions:o}=u();return 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:[jsx(P.Title,{asChild:true,children:e}),jsx(P.Close,{asChild:true,children: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:jsx(XMarkIcon,{className:"h-5 w-5"})})})]})},Ze=({onClose:t,onOpenWalletInfo:e,isProcessing:o,onRetry:a,onSpeedUp:r,onCancel:n,canReplace:i,isFailed:c})=>{let{trackingModal:p,actions:l}=u(),s=()=>c&&a?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:p.retry}):!o&&!i?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:p.walletInfo}):null;return jsxs("footer",{className:"mt-2 flex w-full items-center justify-between border-t border-[var(--tuwa-border-primary)] pt-4",children:[jsx("div",{className:"flex items-center gap-4",children:i&&r&&n&&jsxs(Fragment,{children:[jsx("button",{type:"button",onClick:r,className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-accent)] transition-opacity hover:opacity-80",children:l.speedUp}),jsx("button",{type:"button",onClick:n,className:"cursor-pointer text-sm font-medium text-[var(--tuwa-text-secondary)] transition-opacity hover:opacity-80",children:l.cancel})]})}),jsxs("div",{className:"flex items-center gap-3",children:[jsx(s,{}),jsx("button",{type:"button",onClick:t,disabled:o&&!i,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&&!i?p.processing:p.close})]})]})};Mt.extend(eo);var oo=({chainId:t})=>jsx("div",{className:"h-8 w-8 text-[var(--tuwa-text-secondary)]",children:jsx(Web3Icon,{chainId:t})}),ao=({timestamp:t})=>jsx("span",{className:"mb-1 block text-xs text-[var(--tuwa-text-secondary)]",children:t?Mt.unix(t).fromNow():"..."});function Bt({tx:t,adapters:e,transactionsPool:o,className:a,customization:r}){let{Icon:n=oo,Title:i=H,Description:c=H,Timestamp:p=ao,StatusBadge:l=X,TransactionKey:s=O}=r?.components??{};return jsxs("div",{className: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:[jsxs("div",{className:"flex items-start justify-between",children:[jsxs("div",{className:"flex items-center gap-4",children:[jsx("div",{className:"flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full bg-[var(--tuwa-bg-muted)]",children:jsx(n,{chainId:t.chainId})}),jsxs("div",{children:[jsx(i,{txStatus:t.status,source:t.title,fallback:t.type,variant:"title",applyColor:true}),jsx(p,{timestamp:t.localTimestamp}),jsx(c,{txStatus:t.status,source:t.description,variant:"description"})]})]}),jsx(l,{tx:t})]}),jsx(s,{tx:t,adapters:e,transactionsPool:o,variant:"history"})]})}function no({title:t,message:e,className:o}){return jsxs("div",{className:cn("rounded-lg bg-[var(--tuwa-bg-muted)] p-8 text-center",o),children:[jsx("h4",{className:"font-semibold text-[var(--tuwa-text-primary)]",children:t}),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:n}=u(),i=useMemo(()=>e?selectAllTransactionsByActiveWallet(o,e).sort((f,y)=>(y.localTimestamp??0)-(f.localTimestamp??0)):[],[o,e]),{Placeholder:c=no,HistoryItem:p=Bt}=r?.components??{},l=()=>e?i.length>0?jsx("div",{className:cn("max-h-[400px] overflow-y-auto rounded-lg border border-[var(--tuwa-border-primary)] bg-[var(--tuwa-bg-primary)]",r?.classNames?.listWrapper),children:i.map(s=>jsx(p,{tx:s,transactionsPool:o,adapters:t},s.txKey))}):jsx(c,{title:n.history.noTransactionsTitle,message:n.history.noTransactionsMessage}):jsx(c,{title:n.history.connectWalletTitle,message:n.history.connectWalletMessage});return jsxs("div",{className:cn("flex flex-col gap-y-3",a),children:[jsx("h3",{className:"text-lg font-bold text-[var(--tuwa-text-primary)]",children:n.history.title}),l()]})}var mo=t=>({replaced:jsxs(Fragment,{children:[jsx(ArrowPathIcon,{className:"h-4 w-4"}),jsx("span",{children:t.replaced})]}),loading:jsxs(Fragment,{children:[jsx(ArrowPathIcon,{className:"h-4 w-4 animate-spin"}),jsx("span",{children:t.loading})]}),succeed:jsxs(Fragment,{children:[jsx(CheckCircleIcon,{className:"h-4 w-4"}),jsx("span",{children:t.succeed})]}),failed:jsxs(Fragment,{children:[jsx(ExclamationCircleIcon,{className:"h-4 w-4"}),jsx("span",{children:t.failed})]})});function en({children:t,action:e,getLastTxKey:o,transactionsPool:a,walletAddress:r,loadingContent:n,succeedContent:i,failedContent:c,replacedContent:p,resetTimeout:l=2500,className:s,...f}){let{trackedTxButton:y}=u(),[T,d]=useState("idle"),[x,b]=useState(void 0),R=useMemo(()=>mo(y),[y]);useEffect(()=>{d("idle"),b(void 0);},[r]),useEffect(()=>{if(!x)return;let w=a[x];if(w&&w.from.toLowerCase()===r?.toLowerCase())switch(w.status){case TransactionStatus.Success:d("succeed");break;case TransactionStatus.Replaced:d("replaced");break;case TransactionStatus.Failed:d("failed");break}},[a,x,r]),useEffect(()=>{if(["succeed","failed","replaced"].includes(T)){let w=setTimeout(()=>{d("idle"),b(void 0);},l);return ()=>clearTimeout(w)}},[T,l]);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 n??R.loading;case "succeed":return i??R.succeed;case "failed":return c??R.failed;case "replaced":return p??R.replaced;default:return t}};return jsx("button",{...f,disabled:T!=="idle"||f.disabled,onClick:v,className: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:M()})}function it({address:t,explorerUrl:e,className:o}){let{isCopied:a,copy:r}=useCopyToClipboard(),{actions:n,txError:i}=u(),c=useMemo(()=>e&&t?`${e}/address/${t}`:void 0,[e,t]);return jsxs("div",{className: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:[jsx("span",{children:textCenterEllipsis(t,6,6)}),jsx("button",{type:"button",title:a?i.copied:n.copy,"aria-label":a?i.copied:`${n.copy} address`,onClick:()=>r(t),className:"cursor-pointer transition-colors hover:text-[var(--tuwa-text-primary)]",children:a?jsx(CheckIcon,{className:"h-4 w-4 text-[var(--tuwa-success-icon)]"}):jsx(DocumentDuplicateIcon,{className:"h-4 w-4"})}),c&&jsx("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"transition-colors hover:text-[var(--tuwa-text-accent)]",title:n.viewOnExplorer,"aria-label":n.viewOnExplorer,children:jsx(ArrowTopRightOnSquareIcon,{className:"h-4 w-4"})})]})}function Ot({address:t,ensAvatar:e,className:o}){let{walletModal:a}=u(),[r,n]=useState(e),i=useMemo(()=>Co(isHex(t)?t:zeroAddress),[t]),c=useMemo(()=>`#${t.slice(2,8)}`,[t]);useEffect(()=>{n(e);},[e]);let p=()=>{n(i);};return jsx("div",{className:cn("h-12 w-12 flex-shrink-0 rounded-full",o),style:{backgroundColor:c},children:jsx("img",{className:"h-full w-full rounded-full object-cover",src:r||i,alt:`${a.header.avatarAlt} ${t}`,onError:p},e)})}var So=({isLoading:t,ensName:e,walletAddress:o,explorerUrl:a,renderAddressDisplay:r})=>jsxs("div",{className:"flex flex-col",children:[jsx("div",{className:"mb-1.5 flex h-7 items-center",children:t?jsx("div",{className:"h-full w-48 animate-pulse rounded-md bg-[var(--tuwa-bg-muted)]"}):e?jsx("h2",{className:"text-xl font-bold text-[var(--tuwa-text-primary)]",children:e}):jsx(it,{address:o,explorerUrl:a,className:"rounded-none bg-transparent px-0 py-0 text-xl font-bold text-[var(--tuwa-text-primary)]"})}),jsx("div",{className:"flex h-5 items-center",children:!t&&e&&(r?r({address:o,explorerUrl:a}):jsx(it,{address:o,explorerUrl:a}))})]});function Ft({walletAddress:t,adapters:e,connectedAdapterType:o,className:a,renderAvatar:r,renderName:n,renderAddressDisplay:i,renderNoWalletContent:c,explorerUrl:p}){let{walletModal:l}=u(),[s,f]=useState(null),[y,T]=useState(null),[d,x]=useState(true);if(useEffect(()=>{(async()=>{if(!t||!o){x(false);return}let v=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 c?jsx(Fragment,{children:c()}):jsx("div",{className:cn("flex h-20 items-center justify-center rounded-lg bg-[var(--tuwa-bg-muted)] text-[var(--tuwa-text-secondary)]",a),children:l.header.notConnected});let b=s?s.length>30?textCenterEllipsis(s,12,12):s:void 0;return jsxs("div",{className:cn("flex min-h-[4rem] items-center gap-4",a),children:[jsx("div",{children:r?r({address:t,ensAvatar:y}):jsx(Ot,{address:t,ensAvatar:y})}),jsx("div",{className:"flex min-h-[3.5rem] min-w-[200px] flex-col justify-center",children:n?n({ensName:b,isLoading:d,address:t}):jsx(So,{isLoading:d,ensName:b,walletAddress:t,explorerUrl:p,renderAddressDisplay:i})})]})}var Wo=({closeModal:t,title:e})=>{let{actions:o}=u();return 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:[jsx(P.Title,{className:"text-lg font-bold text-[var(--tuwa-text-primary)]",children:e}),jsx(P.Close,{asChild:true,children: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:jsx(XMarkIcon,{className:"h-6 w-6"})})})]})};function jt({isOpen:t,setIsOpen:e,customization:o,adapters:a,connectedAdapterType:r,connectedWalletAddress:n,transactionsPool:i}){let{walletModal:c}=u(),{explorerUrl:p}=useMemo(()=>r?{explorerUrl:selectAdapterByKey({adapterKey:r,adapters:a})?.getExplorerUrl()}:{explorerUrl:void 0},[r,a]),l=()=>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 jsx(P.Root,{open:t,onOpenChange:x=>!x&&l(),children:jsx(P.Portal,{children:jsx(AnimatePresence,{children:t&&jsxs(Fragment,{children:[jsx(P.Overlay,{asChild:true,children:jsx(motion.div,{className:"fixed inset-0 z-50 bg-black/45",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.15}})}),jsx(P.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:jsx(motion.div,{...f,children:jsxs("div",{className: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?jsx(y,{closeModal:l}):jsx(Wo,{closeModal:l,title:c.title}),jsxs("div",{className:"flex flex-col gap-4 p-4 sm:gap-6 sm:p-6",children:[T?jsx(T,{adapters:a,connectedAdapterType:r,walletAddress:n,explorerUrl:p}):jsx(Ft,{adapters:a,connectedAdapterType:r,walletAddress:n,explorerUrl:p}),d?jsx(d,{adapters:a,transactionsPool:i,connectedWalletAddress:n}):jsx(Ht,{adapters:a,transactionsPool:i,connectedWalletAddress:n})]})]})})})]})})})})}export{Tt as HashLink,H as StatusAwareText,qt as ToastCloseButton,Qt as ToastTransaction,Zt as TrackingTxModal,Bt as TransactionHistoryItem,O as TransactionKey,X as TransactionStatusBadge,Ht as TransactionsHistory,en as TxActionButton,wt as TxErrorBlock,Ct as TxInfoBlock,Pt as TxProgressIndicator,Rt as TxStatusVisual,it as WalletAddressDisplay,Ot as WalletAvatar,Ft as WalletHeader,jt as WalletInfoModal,q as defaultLabels};//# sourceMappingURL=index.js.map
|
2
2
|
//# sourceMappingURL=index.js.map
|