@abstraxn/signer-react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +114 -0
- package/dist/src/AbstraxnProvider.d.ts +9 -0
- package/dist/src/AbstraxnProvider.js +21 -0
- package/dist/src/AbstraxnProvider.js.map +1 -0
- package/dist/src/ConnectButton.css +217 -0
- package/dist/src/ConnectButton.d.ts +71 -0
- package/dist/src/ConnectButton.js +102 -0
- package/dist/src/ConnectButton.js.map +1 -0
- package/dist/src/ExternalWalletButtons.css +319 -0
- package/dist/src/ExternalWalletButtons.d.ts +56 -0
- package/dist/src/ExternalWalletButtons.js +272 -0
- package/dist/src/ExternalWalletButtons.js.map +1 -0
- package/dist/src/OnboardingUI.d.ts +63 -0
- package/dist/src/OnboardingUI.js +66 -0
- package/dist/src/OnboardingUI.js.map +1 -0
- package/dist/src/WalletModal.css +2319 -0
- package/dist/src/WalletModal.d.ts +7 -0
- package/dist/src/WalletModal.js +322 -0
- package/dist/src/WalletModal.js.map +1 -0
- package/dist/src/chains.d.ts +56 -0
- package/dist/src/chains.js +291 -0
- package/dist/src/chains.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProvider.d.ts +12 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProvider.js +146 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProvider.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderInner.d.ts +25 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderInner.js +3086 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderInner.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderWithWagmi.d.ts +8 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderWithWagmi.js +46 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderWithWagmi.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderWithoutWagmi.d.ts +8 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderWithoutWagmi.js +12 -0
- package/dist/src/components/AbstraxnProvider/AbstraxnProviderWithoutWagmi.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/context.d.ts +2 -0
- package/dist/src/components/AbstraxnProvider/context.js +6 -0
- package/dist/src/components/AbstraxnProvider/context.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/index.d.ts +6 -0
- package/dist/src/components/AbstraxnProvider/index.js +7 -0
- package/dist/src/components/AbstraxnProvider/index.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/useAbstraxnProviderBase.d.ts +30 -0
- package/dist/src/components/AbstraxnProvider/useAbstraxnProviderBase.js +49 -0
- package/dist/src/components/AbstraxnProvider/useAbstraxnProviderBase.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/useAbstraxnWallet.d.ts +2 -0
- package/dist/src/components/AbstraxnProvider/useAbstraxnWallet.js +13 -0
- package/dist/src/components/AbstraxnProvider/useAbstraxnWallet.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/useOAuthCallbacks.d.ts +22 -0
- package/dist/src/components/AbstraxnProvider/useOAuthCallbacks.js +242 -0
- package/dist/src/components/AbstraxnProvider/useOAuthCallbacks.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/useWalletInitialization.d.ts +25 -0
- package/dist/src/components/AbstraxnProvider/useWalletInitialization.js +539 -0
- package/dist/src/components/AbstraxnProvider/useWalletInitialization.js.map +1 -0
- package/dist/src/components/AbstraxnProvider/utils.d.ts +41 -0
- package/dist/src/components/AbstraxnProvider/utils.js +139 -0
- package/dist/src/components/AbstraxnProvider/utils.js.map +1 -0
- package/dist/src/components/OnboardingUI/OnboardingUI.css +1062 -0
- package/dist/src/components/OnboardingUI/OnboardingUIReact.d.ts +15 -0
- package/dist/src/components/OnboardingUI/OnboardingUIReact.js +318 -0
- package/dist/src/components/OnboardingUI/OnboardingUIReact.js.map +1 -0
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.d.ts +265 -0
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.js +3782 -0
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/EmailForm.d.ts +16 -0
- package/dist/src/components/OnboardingUI/components/EmailForm.js +27 -0
- package/dist/src/components/OnboardingUI/components/EmailForm.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/Modal.d.ts +14 -0
- package/dist/src/components/OnboardingUI/components/Modal.js +61 -0
- package/dist/src/components/OnboardingUI/components/Modal.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/OtpForm.d.ts +20 -0
- package/dist/src/components/OnboardingUI/components/OtpForm.js +72 -0
- package/dist/src/components/OnboardingUI/components/OtpForm.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/PasskeyButton.d.ts +14 -0
- package/dist/src/components/OnboardingUI/components/PasskeyButton.js +22 -0
- package/dist/src/components/OnboardingUI/components/PasskeyButton.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/SocialButtons.d.ts +15 -0
- package/dist/src/components/OnboardingUI/components/SocialButtons.js +20 -0
- package/dist/src/components/OnboardingUI/components/SocialButtons.js.map +1 -0
- package/dist/src/components/OnboardingUI/components/index.d.ts +13 -0
- package/dist/src/components/OnboardingUI/components/index.js +9 -0
- package/dist/src/components/OnboardingUI/components/index.js.map +1 -0
- package/dist/src/components/OnboardingUI/hooks/index.d.ts +7 -0
- package/dist/src/components/OnboardingUI/hooks/index.js +6 -0
- package/dist/src/components/OnboardingUI/hooks/index.js.map +1 -0
- package/dist/src/components/OnboardingUI/hooks/useAuthMethods.d.ts +11 -0
- package/dist/src/components/OnboardingUI/hooks/useAuthMethods.js +243 -0
- package/dist/src/components/OnboardingUI/hooks/useAuthMethods.js.map +1 -0
- package/dist/src/components/OnboardingUI/hooks/useOnboarding.d.ts +21 -0
- package/dist/src/components/OnboardingUI/hooks/useOnboarding.js +153 -0
- package/dist/src/components/OnboardingUI/hooks/useOnboarding.js.map +1 -0
- package/dist/src/components/OnboardingUI/index.d.ts +12 -0
- package/dist/src/components/OnboardingUI/index.js +15 -0
- package/dist/src/components/OnboardingUI/index.js.map +1 -0
- package/dist/src/components/QRCode.d.ts +13 -0
- package/dist/src/components/QRCode.js +6 -0
- package/dist/src/components/QRCode.js.map +1 -0
- package/dist/src/components/WalletModal/components/ChainSelector.css +327 -0
- package/dist/src/components/WalletModal/components/ChainSelector.d.ts +11 -0
- package/dist/src/components/WalletModal/components/ChainSelector.js +75 -0
- package/dist/src/components/WalletModal/components/ChainSelector.js.map +1 -0
- package/dist/src/components/WalletModal/components/ExportKeyModal.css +134 -0
- package/dist/src/components/WalletModal/components/ExportKeyModal.d.ts +14 -0
- package/dist/src/components/WalletModal/components/ExportKeyModal.js +26 -0
- package/dist/src/components/WalletModal/components/ExportKeyModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/ExportWarningModal.css +107 -0
- package/dist/src/components/WalletModal/components/ExportWarningModal.d.ts +17 -0
- package/dist/src/components/WalletModal/components/ExportWarningModal.js +20 -0
- package/dist/src/components/WalletModal/components/ExportWarningModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/ManageWalletModal.css +246 -0
- package/dist/src/components/WalletModal/components/ManageWalletModal.d.ts +12 -0
- package/dist/src/components/WalletModal/components/ManageWalletModal.js +36 -0
- package/dist/src/components/WalletModal/components/ManageWalletModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/PreviewTransactionModal.css +127 -0
- package/dist/src/components/WalletModal/components/PreviewTransactionModal.d.ts +17 -0
- package/dist/src/components/WalletModal/components/PreviewTransactionModal.js +10 -0
- package/dist/src/components/WalletModal/components/PreviewTransactionModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/ReceiveModal.css +136 -0
- package/dist/src/components/WalletModal/components/ReceiveModal.d.ts +8 -0
- package/dist/src/components/WalletModal/components/ReceiveModal.js +22 -0
- package/dist/src/components/WalletModal/components/ReceiveModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/SendModal.css +277 -0
- package/dist/src/components/WalletModal/components/SendModal.d.ts +16 -0
- package/dist/src/components/WalletModal/components/SendModal.js +219 -0
- package/dist/src/components/WalletModal/components/SendModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/SuccessModal.css +85 -0
- package/dist/src/components/WalletModal/components/SuccessModal.d.ts +13 -0
- package/dist/src/components/WalletModal/components/SuccessModal.js +8 -0
- package/dist/src/components/WalletModal/components/SuccessModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/TokenSelectorModal.css +240 -0
- package/dist/src/components/WalletModal/components/TokenSelectorModal.d.ts +21 -0
- package/dist/src/components/WalletModal/components/TokenSelectorModal.js +44 -0
- package/dist/src/components/WalletModal/components/TokenSelectorModal.js.map +1 -0
- package/dist/src/components/WalletModal/components/UserAvatar.d.ts +9 -0
- package/dist/src/components/WalletModal/components/UserAvatar.js +31 -0
- package/dist/src/components/WalletModal/components/UserAvatar.js.map +1 -0
- package/dist/src/components/WalletModal/components/index.d.ts +23 -0
- package/dist/src/components/WalletModal/components/index.js +14 -0
- package/dist/src/components/WalletModal/components/index.js.map +1 -0
- package/dist/src/components/WalletModal/hooks/index.d.ts +6 -0
- package/dist/src/components/WalletModal/hooks/index.js +7 -0
- package/dist/src/components/WalletModal/hooks/index.js.map +1 -0
- package/dist/src/components/WalletModal/hooks/useAddressValidation.d.ts +4 -0
- package/dist/src/components/WalletModal/hooks/useAddressValidation.js +17 -0
- package/dist/src/components/WalletModal/hooks/useAddressValidation.js.map +1 -0
- package/dist/src/components/WalletModal/hooks/useAmountValidation.d.ts +4 -0
- package/dist/src/components/WalletModal/hooks/useAmountValidation.js +29 -0
- package/dist/src/components/WalletModal/hooks/useAmountValidation.js.map +1 -0
- package/dist/src/components/WalletModal/hooks/useSendTransaction.d.ts +20 -0
- package/dist/src/components/WalletModal/hooks/useSendTransaction.js +55 -0
- package/dist/src/components/WalletModal/hooks/useSendTransaction.js.map +1 -0
- package/dist/src/components/WalletModal/index.d.ts +5 -0
- package/dist/src/components/WalletModal/index.js +7 -0
- package/dist/src/components/WalletModal/index.js.map +1 -0
- package/dist/src/components/WalletModal/utils/addressUtils.d.ts +19 -0
- package/dist/src/components/WalletModal/utils/addressUtils.js +62 -0
- package/dist/src/components/WalletModal/utils/addressUtils.js.map +1 -0
- package/dist/src/components/WalletModal/utils/formatUtils.d.ts +20 -0
- package/dist/src/components/WalletModal/utils/formatUtils.js +47 -0
- package/dist/src/components/WalletModal/utils/formatUtils.js.map +1 -0
- package/dist/src/components/WalletModal/utils/index.d.ts +5 -0
- package/dist/src/components/WalletModal/utils/index.js +6 -0
- package/dist/src/components/WalletModal/utils/index.js.map +1 -0
- package/dist/src/connectors.d.ts +27 -0
- package/dist/src/connectors.js +70 -0
- package/dist/src/connectors.js.map +1 -0
- package/dist/src/hooks.d.ts +13136 -0
- package/dist/src/hooks.js +1358 -0
- package/dist/src/hooks.js.map +1 -0
- package/dist/src/index.d.ts +17 -0
- package/dist/src/index.js +14 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/types.d.ts +224 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/wagmiConfig.d.ts +16 -0
- package/dist/src/wagmiConfig.js +103 -0
- package/dist/src/wagmiConfig.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/* Receive Funds modal - styled to match the provided design screenshot */
|
|
2
|
+
|
|
3
|
+
/* Modal padding */
|
|
4
|
+
.wallet-modal-content.wallet-modal-receive {
|
|
5
|
+
padding: 20px;
|
|
6
|
+
gap: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Header */
|
|
10
|
+
.wallet-modal-content.wallet-modal-receive .wallet-modal-receive-header {
|
|
11
|
+
margin-bottom: 16px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.wallet-modal-content.wallet-modal-receive .wallet-modal-receive-title {
|
|
15
|
+
font-size: 18px;
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
margin: 0;
|
|
18
|
+
flex: 1;
|
|
19
|
+
text-align: center;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Content */
|
|
23
|
+
.wallet-modal-receive-content {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: 18px;
|
|
28
|
+
padding: 0;
|
|
29
|
+
margin-top: 12px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* QR */
|
|
33
|
+
.wallet-modal-receive-qr-card {
|
|
34
|
+
position: relative;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.wallet-modal-receive-qr {
|
|
38
|
+
width: 100%;
|
|
39
|
+
padding: 18px;
|
|
40
|
+
background: #ffffff;
|
|
41
|
+
border-radius: 18px;
|
|
42
|
+
border: 1px solid #e5e7eb;
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
box-shadow: 0 10px 25px -15px rgba(0, 0, 0, 0.25);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.wallet-modal-receive-qr-badge {
|
|
50
|
+
position: absolute;
|
|
51
|
+
left: 50%;
|
|
52
|
+
top: 50%;
|
|
53
|
+
transform: translate(-50%, -50%);
|
|
54
|
+
pointer-events: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.wallet-modal-receive-qr-badge-inner {
|
|
58
|
+
width: 56px;
|
|
59
|
+
height: 56px;
|
|
60
|
+
border-radius: 16px;
|
|
61
|
+
background: #ffffff;
|
|
62
|
+
border: 1px solid #e5e7eb;
|
|
63
|
+
display: flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
color: #2563eb;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Address "input" row */
|
|
70
|
+
.wallet-modal-receive-address-row {
|
|
71
|
+
width: 100%;
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
justify-content: space-between;
|
|
75
|
+
gap: 12px;
|
|
76
|
+
padding: 14px 16px;
|
|
77
|
+
border-radius: 12px;
|
|
78
|
+
border: 1px solid;
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
transition: all 0.2s ease;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.wallet-modal-receive-address-text {
|
|
84
|
+
flex: 1;
|
|
85
|
+
text-align: left;
|
|
86
|
+
font-size: 15px;
|
|
87
|
+
font-weight: 600;
|
|
88
|
+
font-family: 'GeistMono', 'SF Mono', 'Monaco', 'Roboto Mono', monospace;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.wallet-modal-receive-copy-icon {
|
|
92
|
+
display: flex;
|
|
93
|
+
align-items: center;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
flex-shrink: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.wallet-modal-theme-light .wallet-modal-receive-address-row {
|
|
99
|
+
background: #ffffff;
|
|
100
|
+
border-color: #e5e7eb;
|
|
101
|
+
color: #111827;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.wallet-modal-theme-light .wallet-modal-receive-address-row:hover {
|
|
105
|
+
background: #f9fafb;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.wallet-modal-theme-dark .wallet-modal-receive-address-row {
|
|
109
|
+
background: #1a1a1a;
|
|
110
|
+
border-color: #3a3a3a;
|
|
111
|
+
color: #ffffff;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.wallet-modal-theme-dark .wallet-modal-receive-address-row:hover {
|
|
115
|
+
background: #202020;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.wallet-modal-receive-address-row.copied {
|
|
119
|
+
border-color: rgba(16, 185, 129, 0.55);
|
|
120
|
+
box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* Helper text */
|
|
124
|
+
.wallet-modal-receive-helper {
|
|
125
|
+
font-size: 12px;
|
|
126
|
+
text-align: center;
|
|
127
|
+
margin: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.wallet-modal-theme-light .wallet-modal-receive-helper {
|
|
131
|
+
color: #6b7280;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.wallet-modal-theme-dark .wallet-modal-receive-helper {
|
|
135
|
+
color: #9ca3af;
|
|
136
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import './ReceiveModal.css';
|
|
2
|
+
export interface ReceiveModalProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
address: string | null;
|
|
6
|
+
theme?: 'light' | 'dark';
|
|
7
|
+
}
|
|
8
|
+
export declare function ReceiveModal({ isOpen, onClose, address, theme, }: ReceiveModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Receive Modal Component
|
|
4
|
+
*/
|
|
5
|
+
import { useState, useCallback } from 'react';
|
|
6
|
+
import { QRCode } from '../../QRCode';
|
|
7
|
+
import { formatAddress } from '../utils/formatUtils';
|
|
8
|
+
import './ReceiveModal.css';
|
|
9
|
+
export function ReceiveModal({ isOpen, onClose, address, theme = 'dark', }) {
|
|
10
|
+
const [copied, setCopied] = useState(false);
|
|
11
|
+
const handleCopy = useCallback(() => {
|
|
12
|
+
if (address) {
|
|
13
|
+
navigator.clipboard.writeText(address);
|
|
14
|
+
setCopied(true);
|
|
15
|
+
setTimeout(() => setCopied(false), 2000);
|
|
16
|
+
}
|
|
17
|
+
}, [address]);
|
|
18
|
+
if (!isOpen)
|
|
19
|
+
return null;
|
|
20
|
+
return (_jsx("div", { className: `wallet-modal-overlay wallet-modal-theme-${theme}`, onClick: onClose, children: _jsxs("div", { className: `wallet-modal-content wallet-modal-theme-${theme} wallet-modal-receive`, onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "wallet-modal-receive-header", children: [_jsx("button", { className: "wallet-modal-back", onClick: onClose, children: _jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: _jsx("path", { d: "M12.5 15L7.5 10L12.5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), _jsx("h2", { className: "wallet-modal-receive-title", children: "Receive Funds" }), _jsx("button", { className: "wallet-modal-close", onClick: onClose, "aria-label": "Close", children: _jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", children: _jsx("path", { d: "M15 5L5 15M5 5L15 15", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) })] }), _jsx("div", { className: "wallet-modal-receive-content", children: address && (_jsxs(_Fragment, { children: [_jsxs("div", { className: "wallet-modal-receive-qr-card", children: [_jsx("div", { className: "wallet-modal-receive-qr", children: _jsx(QRCode, { value: address, size: 260 }) }), _jsx("div", { className: "wallet-modal-receive-qr-badge", "aria-hidden": "true", children: _jsx("div", { className: "wallet-modal-receive-qr-badge-inner", children: _jsxs("svg", { width: "26", height: "26", viewBox: "0 0 24 24", fill: "none", children: [_jsx("path", { d: "M4 7.5C4 6.67157 4.67157 6 5.5 6H18.5C19.3284 6 20 6.67157 20 7.5V16.5C20 17.3284 19.3284 18 18.5 18H5.5C4.67157 18 4 17.3284 4 16.5V7.5Z", stroke: "currentColor", strokeWidth: "2", strokeLinejoin: "round" }), _jsx("path", { d: "M5.5 7.5L12 12L18.5 7.5", stroke: "currentColor", strokeWidth: "2", strokeLinejoin: "round", strokeLinecap: "round" })] }) }) })] }), _jsxs("button", { type: "button", className: `wallet-modal-receive-address-row wallet-modal-theme-${theme} ${copied ? 'copied' : ''}`, onClick: handleCopy, "aria-label": "Copy wallet address", children: [_jsx("span", { className: "wallet-modal-receive-address-text", children: formatAddress(address) }), _jsx("span", { className: "wallet-modal-receive-copy-icon", "aria-hidden": "true", children: copied ? (_jsx("svg", { width: "18", height: "18", viewBox: "0 0 16 16", fill: "none", children: _jsx("path", { d: "M13.5 4L6 11.5L2.5 8", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })) : (_jsx("svg", { width: "18", height: "18", viewBox: "0 0 16 16", fill: "none", children: _jsx("path", { d: "M5.5 4.5H3.5C2.67157 4.5 2 5.17157 2 6V12.5C2 13.3284 2.67157 14 3.5 14H10C10.8284 14 11.5 13.3284 11.5 12.5V10.5M5.5 4.5C5.5 3.67157 6.17157 3 7 3H10.5C11.3284 3 12 3.67157 12 4.5V8M5.5 4.5C5.5 5.32843 6.17157 6 7 6H10.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) })) })] }), _jsx("p", { className: "wallet-modal-receive-helper", children: "Copy the address to send funds to this wallet" })] })) })] }) }));
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ReceiveModal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReceiveModal.js","sourceRoot":"","sources":["../../../../../src/components/WalletModal/components/ReceiveModal.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/* Send Modal Styles - Clean minimal design */
|
|
2
|
+
|
|
3
|
+
/* Override modal padding for send modal */
|
|
4
|
+
.wallet-modal-content.wallet-modal-send {
|
|
5
|
+
padding: 20px;
|
|
6
|
+
gap: 0;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Header */
|
|
10
|
+
.wallet-modal-send-header {
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
padding: 0;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.wallet-modal-send-title {
|
|
18
|
+
font-size: 18px;
|
|
19
|
+
font-weight: 600;
|
|
20
|
+
margin: 0;
|
|
21
|
+
color: #111827;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.wallet-modal-theme-dark .wallet-modal-send-title {
|
|
25
|
+
color: #ffffff;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/* Content */
|
|
30
|
+
.wallet-modal-send-content {
|
|
31
|
+
display: flex;
|
|
32
|
+
flex-direction: column;
|
|
33
|
+
gap: 16px;
|
|
34
|
+
padding: 0;
|
|
35
|
+
margin-top: 16px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.wallet-modal-send-field {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
gap: 8px;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.wallet-modal-send-label {
|
|
45
|
+
font-size: 14px;
|
|
46
|
+
font-weight: 500;
|
|
47
|
+
color: #374151;
|
|
48
|
+
text-align: left;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.wallet-modal-theme-dark .wallet-modal-send-label {
|
|
52
|
+
color: #9ca3af;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Token Card */
|
|
56
|
+
.wallet-modal-send-token-card {
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
gap: 12px;
|
|
60
|
+
width: 100%;
|
|
61
|
+
padding: 12px;
|
|
62
|
+
border-radius: 12px;
|
|
63
|
+
border: 1px solid #e5e7eb;
|
|
64
|
+
background: #ffffff;
|
|
65
|
+
cursor: pointer;
|
|
66
|
+
transition: all 0.2s;
|
|
67
|
+
text-align: left;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.wallet-modal-send-token-card:hover {
|
|
71
|
+
border-color: #3b82f6;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.wallet-modal-theme-dark .wallet-modal-send-token-card {
|
|
75
|
+
border-color: #3a3a3a;
|
|
76
|
+
background: #1a1a1a;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.wallet-modal-theme-dark .wallet-modal-send-token-card:hover {
|
|
80
|
+
border-color: #3b82f6;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.wallet-modal-send-token-icon {
|
|
84
|
+
width: 40px;
|
|
85
|
+
height: 40px;
|
|
86
|
+
flex-shrink: 0;
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
justify-content: center;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.wallet-modal-send-token-icon img {
|
|
93
|
+
width: 100%;
|
|
94
|
+
height: 100%;
|
|
95
|
+
border-radius: 50%;
|
|
96
|
+
object-fit: cover;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.wallet-modal-send-token-icon-placeholder {
|
|
100
|
+
width: 100%;
|
|
101
|
+
height: 100%;
|
|
102
|
+
border-radius: 50%;
|
|
103
|
+
background: #e5e7eb;
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
font-weight: 600;
|
|
108
|
+
font-size: 16px;
|
|
109
|
+
color: #6b7280;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.wallet-modal-theme-dark .wallet-modal-send-token-icon-placeholder {
|
|
113
|
+
background: #2a2a2a;
|
|
114
|
+
color: #9ca3af;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.wallet-modal-send-token-details {
|
|
118
|
+
display: flex;
|
|
119
|
+
flex-direction: column;
|
|
120
|
+
gap: 2px;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.wallet-modal-send-token-name {
|
|
124
|
+
font-size: 16px;
|
|
125
|
+
font-weight: 600;
|
|
126
|
+
color: #111827;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.wallet-modal-theme-dark .wallet-modal-send-token-name {
|
|
130
|
+
color: #ffffff;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.wallet-modal-send-token-balance {
|
|
134
|
+
font-size: 13px;
|
|
135
|
+
color: #6b7280;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.wallet-modal-theme-dark .wallet-modal-send-token-balance {
|
|
139
|
+
color: #9ca3af;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* Input Fields */
|
|
143
|
+
.wallet-modal-send-input {
|
|
144
|
+
width: 100%;
|
|
145
|
+
padding: 12px 14px;
|
|
146
|
+
border-radius: 12px;
|
|
147
|
+
border: 1px solid #e5e7eb;
|
|
148
|
+
background: #ffffff;
|
|
149
|
+
font-size: 15px;
|
|
150
|
+
outline: none;
|
|
151
|
+
transition: all 0.2s;
|
|
152
|
+
box-sizing: border-box;
|
|
153
|
+
color: #111827;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.wallet-modal-send-input::placeholder {
|
|
157
|
+
color: #9ca3af;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.wallet-modal-send-input:focus {
|
|
161
|
+
border-color: #3b82f6;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.wallet-modal-send-input.error {
|
|
165
|
+
border-color: #ef4444;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.wallet-modal-theme-dark .wallet-modal-send-input {
|
|
169
|
+
border-color: #3a3a3a;
|
|
170
|
+
background: #1a1a1a;
|
|
171
|
+
color: #ffffff;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.wallet-modal-theme-dark .wallet-modal-send-input::placeholder {
|
|
175
|
+
color: #6b7280;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.wallet-modal-theme-dark .wallet-modal-send-input:focus {
|
|
179
|
+
border-color: #3b82f6;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* Amount Box */
|
|
183
|
+
.wallet-modal-send-amount-box {
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
justify-content: space-between;
|
|
187
|
+
width: 100%;
|
|
188
|
+
padding: 12px 14px;
|
|
189
|
+
border-radius: 12px;
|
|
190
|
+
border: 1px solid #e5e7eb;
|
|
191
|
+
background: #ffffff;
|
|
192
|
+
box-sizing: border-box;
|
|
193
|
+
transition: all 0.2s;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.wallet-modal-send-amount-box:focus-within {
|
|
197
|
+
border-color: #3b82f6;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.wallet-modal-send-amount-box.error {
|
|
201
|
+
border-color: #ef4444;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.wallet-modal-theme-dark .wallet-modal-send-amount-box {
|
|
205
|
+
border-color: #3a3a3a;
|
|
206
|
+
background: #1a1a1a;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.wallet-modal-theme-dark .wallet-modal-send-amount-box:focus-within {
|
|
210
|
+
border-color: #3b82f6;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.wallet-modal-send-amount-input {
|
|
214
|
+
flex: 1;
|
|
215
|
+
border: none;
|
|
216
|
+
background: transparent;
|
|
217
|
+
font-size: 15px;
|
|
218
|
+
outline: none;
|
|
219
|
+
min-width: 0;
|
|
220
|
+
color: #111827;
|
|
221
|
+
padding: 0;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.wallet-modal-send-amount-input::placeholder {
|
|
225
|
+
color: #9ca3af;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.wallet-modal-theme-dark .wallet-modal-send-amount-input {
|
|
229
|
+
color: #ffffff;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.wallet-modal-theme-dark .wallet-modal-send-amount-input::placeholder {
|
|
233
|
+
color: #6b7280;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.wallet-modal-send-amount-symbol {
|
|
237
|
+
font-size: 15px;
|
|
238
|
+
font-weight: 500;
|
|
239
|
+
color: #6b7280;
|
|
240
|
+
flex-shrink: 0;
|
|
241
|
+
margin-left: 8px;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.wallet-modal-theme-dark .wallet-modal-send-amount-symbol {
|
|
245
|
+
color: #9ca3af;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* Error Message */
|
|
249
|
+
.wallet-modal-send-error {
|
|
250
|
+
font-size: 12px;
|
|
251
|
+
color: #ef4444;
|
|
252
|
+
text-align: left;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/* Send Button */
|
|
256
|
+
.wallet-modal-send-btn {
|
|
257
|
+
width: 100%;
|
|
258
|
+
padding: 14px 24px;
|
|
259
|
+
border-radius: 12px;
|
|
260
|
+
border: none;
|
|
261
|
+
font-size: 16px;
|
|
262
|
+
font-weight: 600;
|
|
263
|
+
cursor: pointer;
|
|
264
|
+
transition: all 0.2s;
|
|
265
|
+
background: #3b82f6;
|
|
266
|
+
color: #ffffff;
|
|
267
|
+
margin-top: 8px;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.wallet-modal-send-btn:hover:not(.disabled) {
|
|
271
|
+
background: #2563eb;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.wallet-modal-send-btn.disabled {
|
|
275
|
+
opacity: 0.5;
|
|
276
|
+
cursor: not-allowed;
|
|
277
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ChainData } from "../../../chains";
|
|
2
|
+
import "./SendModal.css";
|
|
3
|
+
export interface SendModalProps {
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
currentChain: ChainData | null;
|
|
7
|
+
displayAddress: string | null;
|
|
8
|
+
availableBalance: bigint | null;
|
|
9
|
+
externalWalletBalance: bigint | null;
|
|
10
|
+
walletBalance: bigint | null;
|
|
11
|
+
sendTransaction?: (tx: any) => Promise<{
|
|
12
|
+
hash: string;
|
|
13
|
+
}>;
|
|
14
|
+
theme?: "light" | "dark";
|
|
15
|
+
}
|
|
16
|
+
export declare function SendModal({ isOpen, onClose, currentChain, displayAddress, availableBalance, externalWalletBalance, walletBalance, sendTransaction, theme, }: SendModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* Send Modal Component
|
|
4
|
+
*/
|
|
5
|
+
import { useState, useCallback, useMemo, useEffect } from "react";
|
|
6
|
+
import { PreviewTransactionModal } from "./PreviewTransactionModal";
|
|
7
|
+
import { SuccessModal } from "./SuccessModal";
|
|
8
|
+
import { TokenSelectorModal } from "./TokenSelectorModal";
|
|
9
|
+
import { useAddressValidation } from "../hooks/useAddressValidation";
|
|
10
|
+
import { useAmountValidation } from "../hooks/useAmountValidation";
|
|
11
|
+
import { useSendTransaction } from "../hooks/useSendTransaction";
|
|
12
|
+
import { formatBalanceValue } from "../utils/formatUtils";
|
|
13
|
+
import "./SendModal.css";
|
|
14
|
+
export function SendModal({ isOpen, onClose, currentChain, displayAddress, availableBalance, externalWalletBalance, walletBalance, sendTransaction, theme = "dark", }) {
|
|
15
|
+
const [recipientAddress, setRecipientAddress] = useState("");
|
|
16
|
+
const [amount, setAmount] = useState("");
|
|
17
|
+
const [addressError, setAddressError] = useState("");
|
|
18
|
+
const [amountError, setAmountError] = useState("");
|
|
19
|
+
const [showPreview, setShowPreview] = useState(false);
|
|
20
|
+
const [showTokenSelector, setShowTokenSelector] = useState(false);
|
|
21
|
+
const [selectedToken, setSelectedToken] = useState(null);
|
|
22
|
+
const balance = externalWalletBalance || walletBalance || availableBalance;
|
|
23
|
+
// Get available tokens for the current chain
|
|
24
|
+
const availableTokens = useMemo(() => {
|
|
25
|
+
if (!currentChain)
|
|
26
|
+
return [];
|
|
27
|
+
const nativeToken = {
|
|
28
|
+
address: "0x0",
|
|
29
|
+
symbol: currentChain.nativeCurrency.symbol,
|
|
30
|
+
name: currentChain.nativeCurrency.name,
|
|
31
|
+
decimals: currentChain.nativeCurrency.decimals,
|
|
32
|
+
iconUrl: currentChain.iconUrl,
|
|
33
|
+
balance: balance || 0n,
|
|
34
|
+
isNative: true,
|
|
35
|
+
};
|
|
36
|
+
// Example tokens for Ethereum (you can expand this for other chains)
|
|
37
|
+
const tokensByChain = {
|
|
38
|
+
1: [
|
|
39
|
+
// Ethereum Mainnet
|
|
40
|
+
nativeToken,
|
|
41
|
+
{
|
|
42
|
+
address: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
|
|
43
|
+
symbol: "WETH",
|
|
44
|
+
name: "Wrapped Ether",
|
|
45
|
+
decimals: 18,
|
|
46
|
+
iconUrl: "https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/128/color/eth.png",
|
|
47
|
+
balance: 0n,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
address: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
|
|
51
|
+
symbol: "USDT",
|
|
52
|
+
name: "Tether USD",
|
|
53
|
+
decimals: 6,
|
|
54
|
+
iconUrl: "https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/128/color/usdt.png",
|
|
55
|
+
balance: 0n,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
59
|
+
symbol: "USDC",
|
|
60
|
+
name: "USD Coin",
|
|
61
|
+
decimals: 6,
|
|
62
|
+
iconUrl: "https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/128/color/usdc.png",
|
|
63
|
+
balance: 0n,
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
address: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599",
|
|
67
|
+
symbol: "WBTC",
|
|
68
|
+
name: "Wrapped Bitcoin",
|
|
69
|
+
decimals: 8,
|
|
70
|
+
iconUrl: "https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/128/color/btc.png",
|
|
71
|
+
balance: 0n,
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
137: [
|
|
75
|
+
// Polygon Mainnet
|
|
76
|
+
nativeToken,
|
|
77
|
+
{
|
|
78
|
+
address: "0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270",
|
|
79
|
+
symbol: "WMATIC",
|
|
80
|
+
name: "Wrapped Matic",
|
|
81
|
+
decimals: 18,
|
|
82
|
+
iconUrl: "https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/128/color/matic.png",
|
|
83
|
+
balance: 0n,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
address: "0xc2132D05D31c914a87C6611C10748AEb04B58e8F",
|
|
87
|
+
symbol: "USDT",
|
|
88
|
+
name: "Tether USD",
|
|
89
|
+
decimals: 6,
|
|
90
|
+
iconUrl: "https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/128/color/usdt.png",
|
|
91
|
+
balance: 0n,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
address: "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
|
|
95
|
+
symbol: "USDC",
|
|
96
|
+
name: "USD Coin",
|
|
97
|
+
decimals: 6,
|
|
98
|
+
iconUrl: "https://raw.githubusercontent.com/spothq/cryptocurrency-icons/master/128/color/usdc.png",
|
|
99
|
+
balance: 0n,
|
|
100
|
+
},
|
|
101
|
+
],
|
|
102
|
+
};
|
|
103
|
+
return tokensByChain[currentChain.id] || [nativeToken];
|
|
104
|
+
}, [currentChain, balance]);
|
|
105
|
+
// Initialize selected token when chain changes
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (currentChain && availableTokens.length > 0) {
|
|
108
|
+
// Set native token as default
|
|
109
|
+
const nativeToken = availableTokens.find((t) => t.isNative);
|
|
110
|
+
setSelectedToken(nativeToken || availableTokens[0]);
|
|
111
|
+
}
|
|
112
|
+
}, [currentChain, availableTokens]);
|
|
113
|
+
const { validate: validateAddress } = useAddressValidation(displayAddress, currentChain);
|
|
114
|
+
const { validate: validateAmount } = useAmountValidation(balance, currentChain);
|
|
115
|
+
const { send, isSending, txHash, reset } = useSendTransaction({
|
|
116
|
+
sendTransaction,
|
|
117
|
+
currentChain,
|
|
118
|
+
fromAddress: displayAddress,
|
|
119
|
+
onSuccess: () => {
|
|
120
|
+
setShowPreview(false);
|
|
121
|
+
setTimeout(() => {
|
|
122
|
+
handleReset();
|
|
123
|
+
onClose();
|
|
124
|
+
}, 3000);
|
|
125
|
+
},
|
|
126
|
+
onError: (error) => {
|
|
127
|
+
setAmountError(error.message);
|
|
128
|
+
setShowPreview(false);
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
const handleRecipientAddressChange = useCallback((value) => {
|
|
132
|
+
setRecipientAddress(value);
|
|
133
|
+
if (value) {
|
|
134
|
+
const error = validateAddress(value);
|
|
135
|
+
setAddressError(error);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
setAddressError("");
|
|
139
|
+
}
|
|
140
|
+
}, [validateAddress]);
|
|
141
|
+
const handleAmountChange = useCallback((value) => {
|
|
142
|
+
// Only allow numbers and decimal point
|
|
143
|
+
const sanitized = value.replace(/[^0-9.]/g, "");
|
|
144
|
+
// Prevent multiple decimal points
|
|
145
|
+
const parts = sanitized.split(".");
|
|
146
|
+
const finalValue = parts.length > 2 ? parts[0] + "." + parts.slice(1).join("") : sanitized;
|
|
147
|
+
setAmount(finalValue);
|
|
148
|
+
if (finalValue) {
|
|
149
|
+
const error = validateAmount(finalValue);
|
|
150
|
+
setAmountError(error);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
setAmountError("");
|
|
154
|
+
}
|
|
155
|
+
}, [validateAmount]);
|
|
156
|
+
const handlePreviewTransaction = useCallback(() => {
|
|
157
|
+
const addrError = validateAddress(recipientAddress);
|
|
158
|
+
const amtError = validateAmount(amount);
|
|
159
|
+
if (addrError || amtError) {
|
|
160
|
+
setAddressError(addrError);
|
|
161
|
+
setAmountError(amtError);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
setShowPreview(true);
|
|
165
|
+
}, [recipientAddress, amount, validateAddress, validateAmount]);
|
|
166
|
+
const handleConfirmSend = useCallback(async () => {
|
|
167
|
+
try {
|
|
168
|
+
await send(recipientAddress, amount);
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
// Error handled in useSendTransaction
|
|
172
|
+
}
|
|
173
|
+
}, [send, recipientAddress, amount]);
|
|
174
|
+
const handleReset = useCallback(() => {
|
|
175
|
+
setRecipientAddress("");
|
|
176
|
+
setAmount("");
|
|
177
|
+
setAddressError("");
|
|
178
|
+
setAmountError("");
|
|
179
|
+
setShowPreview(false);
|
|
180
|
+
setShowTokenSelector(false);
|
|
181
|
+
reset();
|
|
182
|
+
}, [reset]);
|
|
183
|
+
const handleTokenSelect = useCallback((token) => {
|
|
184
|
+
setSelectedToken(token);
|
|
185
|
+
setShowTokenSelector(false);
|
|
186
|
+
}, []);
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
if (!isOpen) {
|
|
189
|
+
handleReset();
|
|
190
|
+
}
|
|
191
|
+
}, [isOpen, handleReset]);
|
|
192
|
+
if (!isOpen)
|
|
193
|
+
return null;
|
|
194
|
+
const availableBalanceValue = useMemo(() => {
|
|
195
|
+
if (!balance || !selectedToken)
|
|
196
|
+
return "0";
|
|
197
|
+
return formatBalanceValue(balance, selectedToken.decimals);
|
|
198
|
+
}, [balance, selectedToken]);
|
|
199
|
+
const symbol = selectedToken?.symbol || currentChain?.nativeCurrency.symbol || "ETH";
|
|
200
|
+
const chainName = currentChain?.displayName || "Select Chain";
|
|
201
|
+
const isFormValid = !addressError && !amountError && recipientAddress && amount;
|
|
202
|
+
// Show success modal
|
|
203
|
+
if (txHash && !showPreview) {
|
|
204
|
+
return (_jsx(SuccessModal, { isOpen: true, onClose: () => {
|
|
205
|
+
reset();
|
|
206
|
+
onClose();
|
|
207
|
+
}, txHash: txHash, currentChain: currentChain, theme: theme }));
|
|
208
|
+
}
|
|
209
|
+
// Show preview modal
|
|
210
|
+
if (showPreview) {
|
|
211
|
+
return (_jsx(PreviewTransactionModal, { isOpen: true, onClose: () => setShowPreview(false), onConfirm: handleConfirmSend, recipientAddress: recipientAddress, amount: amount, displayAddress: displayAddress, currentChain: currentChain, isSending: isSending, theme: theme }));
|
|
212
|
+
}
|
|
213
|
+
// Show token selector modal
|
|
214
|
+
if (showTokenSelector) {
|
|
215
|
+
return (_jsx(TokenSelectorModal, { isOpen: true, onClose: () => setShowTokenSelector(false), onTokenSelect: handleTokenSelect, currentChain: currentChain, tokens: availableTokens, selectedToken: selectedToken || undefined, theme: theme }));
|
|
216
|
+
}
|
|
217
|
+
return (_jsx("div", { className: `wallet-modal-overlay wallet-modal-theme-${theme}`, onClick: onClose, children: _jsxs("div", { className: `wallet-modal-content wallet-modal-theme-${theme} wallet-modal-send`, onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "wallet-modal-send-header", children: [_jsx("button", { className: "wallet-modal-back", onClick: onClose, "aria-label": "Go back", children: _jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M12.5 15L7.5 10L12.5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), _jsx("h2", { className: "wallet-modal-send-title", children: "Send Funds" }), _jsx("button", { className: "wallet-modal-close", onClick: onClose, "aria-label": "Close", children: _jsx("svg", { width: "20", height: "20", viewBox: "0 0 20 20", fill: "none", "aria-hidden": "true", children: _jsx("path", { d: "M15 5L5 15M5 5L15 15", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) })] }), _jsxs("div", { className: "wallet-modal-send-content", children: [_jsxs("div", { className: "wallet-modal-send-field", children: [_jsx("label", { className: "wallet-modal-send-label", children: "Token" }), _jsxs("button", { className: "wallet-modal-send-token-card", onClick: () => setShowTokenSelector(true), type: "button", children: [_jsx("div", { className: "wallet-modal-send-token-icon", children: selectedToken?.iconUrl ? (_jsx("img", { src: selectedToken.iconUrl, alt: selectedToken.name })) : (_jsx("div", { className: "wallet-modal-send-token-icon-placeholder", children: selectedToken?.symbol?.charAt(0) || "?" })) }), _jsxs("div", { className: "wallet-modal-send-token-details", children: [_jsx("span", { className: "wallet-modal-send-token-name", children: selectedToken?.name || "Ether" }), _jsxs("span", { className: "wallet-modal-send-token-balance", children: [availableBalanceValue, " ", symbol] })] })] })] }), _jsxs("div", { className: "wallet-modal-send-field", children: [_jsx("label", { className: "wallet-modal-send-label", children: "Send to" }), _jsx("input", { type: "text", className: `wallet-modal-send-input ${addressError ? "error" : ""}`, placeholder: "0x... or ENS name", value: recipientAddress, onChange: (e) => handleRecipientAddressChange(e.target.value) }), addressError && (_jsx("div", { className: "wallet-modal-send-error", children: addressError }))] }), _jsxs("div", { className: "wallet-modal-send-field", children: [_jsx("label", { className: "wallet-modal-send-label", children: "Amount" }), _jsxs("div", { className: `wallet-modal-send-amount-box ${amountError ? "error" : ""}`, children: [_jsx("input", { type: "text", className: "wallet-modal-send-amount-input", placeholder: "0", value: amount, onChange: (e) => handleAmountChange(e.target.value) }), _jsx("span", { className: "wallet-modal-send-amount-symbol", children: symbol })] }), amountError && (_jsx("div", { className: "wallet-modal-send-error", children: amountError }))] }), _jsx("button", { className: `wallet-modal-send-btn ${!isFormValid ? "disabled" : ""}`, onClick: handlePreviewTransaction, disabled: !isFormValid, children: "Send" })] })] }) }));
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=SendModal.js.map
|