signer-test-sdk-react 0.0.20 → 0.0.22
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/dist/src/AbstraxnProvider.d.ts +2 -2
- package/dist/src/AbstraxnProvider.js +627 -602
- package/dist/src/AbstraxnProvider.js.map +1 -1
- package/dist/src/ConnectButton.css +1 -1
- package/dist/src/ExternalWalletButtons.css +1 -1
- package/dist/src/WalletModal.css +373 -193
- package/dist/src/WalletModal.d.ts +1 -1
- package/dist/src/WalletModal.js +45 -108
- package/dist/src/WalletModal.js.map +1 -1
- package/dist/src/chains.d.ts +3 -4
- package/dist/src/chains.js +84 -154
- package/dist/src/chains.js.map +1 -1
- package/dist/src/components/OnboardingUI/OnboardingUI.css +5 -6
- package/dist/src/components/OnboardingUI/OnboardingUIReact.js +9 -3
- package/dist/src/components/OnboardingUI/OnboardingUIReact.js.map +1 -1
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.js +0 -6
- package/dist/src/components/OnboardingUI/OnboardingUIWeb.js.map +1 -1
- package/dist/src/components/OnboardingUI/hooks/useAuthMethods.js +57 -0
- package/dist/src/components/OnboardingUI/hooks/useAuthMethods.js.map +1 -1
- package/dist/src/components/WalletModal/components/ChainSelector.css +102 -249
- package/dist/src/components/WalletModal/components/ChainSelector.d.ts +6 -7
- package/dist/src/components/WalletModal/components/ChainSelector.js +27 -68
- package/dist/src/components/WalletModal/components/ChainSelector.js.map +1 -1
- package/dist/src/components/WalletModal/components/ExportKeyModal.css +88 -89
- package/dist/src/components/WalletModal/components/ExportKeyModal.d.ts +1 -6
- package/dist/src/components/WalletModal/components/ExportKeyModal.js +11 -6
- package/dist/src/components/WalletModal/components/ExportKeyModal.js.map +1 -1
- package/dist/src/components/WalletModal/components/ExportWarningModal.css +2 -107
- package/dist/src/components/WalletModal/components/ExportWarningModal.d.ts +1 -7
- package/dist/src/components/WalletModal/components/ExportWarningModal.js +3 -5
- package/dist/src/components/WalletModal/components/ExportWarningModal.js.map +1 -1
- package/dist/src/components/WalletModal/components/ManageWalletModal.css +4 -90
- package/dist/src/components/WalletModal/components/ManageWalletModal.d.ts +3 -3
- package/dist/src/components/WalletModal/components/ManageWalletModal.js +13 -28
- package/dist/src/components/WalletModal/components/ManageWalletModal.js.map +1 -1
- package/dist/src/components/WalletModal/components/PreviewTransactionModal.css +4 -3
- package/dist/src/components/WalletModal/components/ReceiveModal.css +58 -93
- package/dist/src/components/WalletModal/components/ReceiveModal.js +1 -1
- package/dist/src/components/WalletModal/components/ReceiveModal.js.map +1 -1
- package/dist/src/components/WalletModal/components/SendModal.css +127 -170
- package/dist/src/components/WalletModal/components/SendModal.d.ts +6 -4
- package/dist/src/components/WalletModal/components/SendModal.js +39 -131
- package/dist/src/components/WalletModal/components/SendModal.js.map +1 -1
- package/dist/src/components/WalletModal/components/SuccessModal.css +8 -7
- package/dist/src/components/WalletModal/components/index.d.ts +0 -2
- package/dist/src/components/WalletModal/components/index.js +0 -1
- package/dist/src/components/WalletModal/components/index.js.map +1 -1
- package/dist/src/hooks.d.ts +4399 -448
- package/dist/src/hooks.js +53 -47
- package/dist/src/hooks.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/components/WalletModal/components/TokenSelectorModal.css +0 -240
- package/dist/src/components/WalletModal/components/TokenSelectorModal.d.ts +0 -21
- package/dist/src/components/WalletModal/components/TokenSelectorModal.js +0 -44
- package/dist/src/components/WalletModal/components/TokenSelectorModal.js.map +0 -1
|
@@ -1,38 +1,9 @@
|
|
|
1
|
-
/* Send Modal Styles -
|
|
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 */
|
|
1
|
+
/* Send Modal Styles - extracted from WalletModal.css */
|
|
30
2
|
.wallet-modal-send-content {
|
|
31
3
|
display: flex;
|
|
32
4
|
flex-direction: column;
|
|
33
|
-
gap:
|
|
34
|
-
padding: 0;
|
|
35
|
-
margin-top: 16px;
|
|
5
|
+
gap: 20px;
|
|
6
|
+
padding: 20px 0;
|
|
36
7
|
}
|
|
37
8
|
|
|
38
9
|
.wallet-modal-send-field {
|
|
@@ -44,7 +15,6 @@
|
|
|
44
15
|
.wallet-modal-send-label {
|
|
45
16
|
font-size: 14px;
|
|
46
17
|
font-weight: 500;
|
|
47
|
-
color: #374151;
|
|
48
18
|
text-align: left;
|
|
49
19
|
}
|
|
50
20
|
|
|
@@ -52,208 +22,175 @@
|
|
|
52
22
|
color: #9ca3af;
|
|
53
23
|
}
|
|
54
24
|
|
|
55
|
-
|
|
56
|
-
|
|
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;
|
|
25
|
+
.wallet-modal-theme-light .wallet-modal-send-label {
|
|
26
|
+
color: #6b7280;
|
|
81
27
|
}
|
|
82
28
|
|
|
83
|
-
.wallet-modal-send-token-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
flex-shrink: 0;
|
|
87
|
-
display: flex;
|
|
88
|
-
align-items: center;
|
|
89
|
-
justify-content: center;
|
|
29
|
+
.wallet-modal-send-token-selector-wrapper {
|
|
30
|
+
position: relative;
|
|
31
|
+
width: 100%;
|
|
90
32
|
}
|
|
91
33
|
|
|
92
|
-
.wallet-modal-send-
|
|
34
|
+
.wallet-modal-send-chain-selector {
|
|
93
35
|
width: 100%;
|
|
94
|
-
height: 100%;
|
|
95
|
-
border-radius: 50%;
|
|
96
|
-
object-fit: cover;
|
|
97
36
|
}
|
|
98
37
|
|
|
99
|
-
.wallet-modal-send-
|
|
100
|
-
width: 100%;
|
|
101
|
-
height: 100%;
|
|
102
|
-
border-radius: 50%;
|
|
103
|
-
background: #e5e7eb;
|
|
38
|
+
.wallet-modal-send-amount-wrapper {
|
|
104
39
|
display: flex;
|
|
105
40
|
align-items: center;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
41
|
+
border-radius: 12px;
|
|
42
|
+
border: 1px solid;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
background: transparent;
|
|
110
45
|
}
|
|
111
46
|
|
|
112
|
-
.wallet-modal-theme-dark .wallet-modal-send-
|
|
47
|
+
.wallet-modal-theme-dark .wallet-modal-send-amount-wrapper {
|
|
48
|
+
border-color: #3a3a3a;
|
|
113
49
|
background: #2a2a2a;
|
|
114
|
-
color: #9ca3af;
|
|
115
50
|
}
|
|
116
51
|
|
|
117
|
-
.wallet-modal-send-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
gap: 2px;
|
|
52
|
+
.wallet-modal-theme-light .wallet-modal-send-amount-wrapper {
|
|
53
|
+
border-color: #e5e7eb;
|
|
54
|
+
background: #f9fafb;
|
|
121
55
|
}
|
|
122
56
|
|
|
123
|
-
.wallet-modal-send-
|
|
124
|
-
|
|
125
|
-
font-weight: 600;
|
|
126
|
-
color: #111827;
|
|
57
|
+
.wallet-modal-send-amount-wrapper.error {
|
|
58
|
+
border-color: #ef4444;
|
|
127
59
|
}
|
|
128
60
|
|
|
129
|
-
.wallet-modal-
|
|
130
|
-
|
|
61
|
+
.wallet-modal-send-amount-prefix {
|
|
62
|
+
padding: 14px 16px;
|
|
63
|
+
font-size: 15px;
|
|
64
|
+
font-weight: 500;
|
|
65
|
+
flex-shrink: 0;
|
|
66
|
+
border-right: 1px solid;
|
|
131
67
|
}
|
|
132
68
|
|
|
133
|
-
.wallet-modal-send-
|
|
134
|
-
|
|
135
|
-
color: #
|
|
69
|
+
.wallet-modal-theme-dark .wallet-modal-send-amount-prefix {
|
|
70
|
+
color: #ffffff;
|
|
71
|
+
border-color: #3a3a3a;
|
|
136
72
|
}
|
|
137
73
|
|
|
138
|
-
.wallet-modal-theme-
|
|
139
|
-
color: #
|
|
74
|
+
.wallet-modal-theme-light .wallet-modal-send-amount-prefix {
|
|
75
|
+
color: #111827;
|
|
76
|
+
border-color: #e5e7eb;
|
|
140
77
|
}
|
|
141
78
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
font-size: 15px;
|
|
79
|
+
.wallet-modal-send-amount-input {
|
|
80
|
+
flex: 1;
|
|
81
|
+
padding: 14px 16px;
|
|
82
|
+
border: none;
|
|
83
|
+
background: transparent;
|
|
84
|
+
font-size: 16px;
|
|
85
|
+
font-weight: 500;
|
|
150
86
|
outline: none;
|
|
151
|
-
|
|
152
|
-
box-sizing: border-box;
|
|
153
|
-
color: #111827;
|
|
87
|
+
min-width: 0;
|
|
154
88
|
}
|
|
155
89
|
|
|
156
|
-
.wallet-modal-send-input
|
|
157
|
-
color: #
|
|
90
|
+
.wallet-modal-theme-dark .wallet-modal-send-amount-input {
|
|
91
|
+
color: #ffffff;
|
|
158
92
|
}
|
|
159
93
|
|
|
160
|
-
.wallet-modal-send-input
|
|
161
|
-
|
|
94
|
+
.wallet-modal-theme-light .wallet-modal-send-amount-input {
|
|
95
|
+
color: #111827;
|
|
162
96
|
}
|
|
163
97
|
|
|
164
|
-
.wallet-modal-send-input
|
|
165
|
-
|
|
98
|
+
.wallet-modal-send-amount-input::placeholder {
|
|
99
|
+
opacity: 0.5;
|
|
166
100
|
}
|
|
167
101
|
|
|
168
|
-
.wallet-modal-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
102
|
+
.wallet-modal-send-amount-suffix {
|
|
103
|
+
padding: 14px 16px;
|
|
104
|
+
font-size: 14px;
|
|
105
|
+
flex-shrink: 0;
|
|
106
|
+
opacity: 0.7;
|
|
172
107
|
}
|
|
173
108
|
|
|
174
|
-
.wallet-modal-theme-dark .wallet-modal-send-
|
|
175
|
-
color: #
|
|
109
|
+
.wallet-modal-theme-dark .wallet-modal-send-amount-suffix {
|
|
110
|
+
color: #9ca3af;
|
|
176
111
|
}
|
|
177
112
|
|
|
178
|
-
.wallet-modal-theme-
|
|
179
|
-
|
|
113
|
+
.wallet-modal-theme-light .wallet-modal-send-amount-suffix {
|
|
114
|
+
color: #6b7280;
|
|
180
115
|
}
|
|
181
116
|
|
|
182
|
-
|
|
183
|
-
.wallet-modal-send-amount-box {
|
|
117
|
+
.wallet-modal-send-balance {
|
|
184
118
|
display: flex;
|
|
185
119
|
align-items: center;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
border-radius: 12px;
|
|
190
|
-
border: 1px solid #e5e7eb;
|
|
191
|
-
background: #ffffff;
|
|
192
|
-
box-sizing: border-box;
|
|
193
|
-
transition: all 0.2s;
|
|
120
|
+
gap: 8px;
|
|
121
|
+
font-size: 12px;
|
|
122
|
+
margin-top: 4px;
|
|
194
123
|
}
|
|
195
124
|
|
|
196
|
-
.wallet-modal-send-
|
|
197
|
-
|
|
125
|
+
.wallet-modal-send-balance-label {
|
|
126
|
+
opacity: 0.7;
|
|
198
127
|
}
|
|
199
128
|
|
|
200
|
-
.wallet-modal-send-
|
|
201
|
-
|
|
129
|
+
.wallet-modal-send-balance-value {
|
|
130
|
+
font-weight: 500;
|
|
202
131
|
}
|
|
203
132
|
|
|
204
|
-
.wallet-modal-theme-dark .wallet-modal-send-
|
|
205
|
-
|
|
206
|
-
background: #1a1a1a;
|
|
133
|
+
.wallet-modal-theme-dark .wallet-modal-send-balance {
|
|
134
|
+
color: #9ca3af;
|
|
207
135
|
}
|
|
208
136
|
|
|
209
|
-
.wallet-modal-theme-
|
|
210
|
-
|
|
137
|
+
.wallet-modal-theme-light .wallet-modal-send-balance {
|
|
138
|
+
color: #6b7280;
|
|
211
139
|
}
|
|
212
140
|
|
|
213
|
-
.wallet-modal-send-
|
|
214
|
-
|
|
215
|
-
|
|
141
|
+
.wallet-modal-send-address-input {
|
|
142
|
+
width: 100%;
|
|
143
|
+
padding: 14px 16px;
|
|
144
|
+
border-radius: 12px;
|
|
145
|
+
border: 1px solid;
|
|
216
146
|
background: transparent;
|
|
217
|
-
font-size:
|
|
147
|
+
font-size: 14px;
|
|
148
|
+
font-family: monospace;
|
|
218
149
|
outline: none;
|
|
219
|
-
|
|
150
|
+
transition: all 0.2s;
|
|
151
|
+
box-sizing: border-box;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.wallet-modal-theme-dark .wallet-modal-send-address-input {
|
|
155
|
+
border-color: #3a3a3a;
|
|
156
|
+
background: #2a2a2a;
|
|
157
|
+
color: #ffffff;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.wallet-modal-theme-light .wallet-modal-send-address-input {
|
|
161
|
+
border-color: #e5e7eb;
|
|
162
|
+
background: #f9fafb;
|
|
220
163
|
color: #111827;
|
|
221
|
-
padding: 0;
|
|
222
164
|
}
|
|
223
165
|
|
|
224
|
-
.wallet-modal-send-
|
|
225
|
-
color: #
|
|
166
|
+
.wallet-modal-send-address-input.error {
|
|
167
|
+
border-color: #ef4444;
|
|
226
168
|
}
|
|
227
169
|
|
|
228
|
-
.wallet-modal-
|
|
229
|
-
color: #
|
|
170
|
+
.wallet-modal-send-address-input:focus {
|
|
171
|
+
border-color: #9333ea;
|
|
230
172
|
}
|
|
231
173
|
|
|
232
|
-
.wallet-modal-theme-dark .wallet-modal-send-
|
|
233
|
-
color: #
|
|
174
|
+
.wallet-modal-theme-dark .wallet-modal-send-address-input:focus {
|
|
175
|
+
border-color: #a855f7;
|
|
234
176
|
}
|
|
235
177
|
|
|
236
|
-
.wallet-modal-send-
|
|
237
|
-
|
|
238
|
-
font-weight: 500;
|
|
239
|
-
color: #6b7280;
|
|
240
|
-
flex-shrink: 0;
|
|
241
|
-
margin-left: 8px;
|
|
178
|
+
.wallet-modal-theme-light .wallet-modal-send-address-input:focus {
|
|
179
|
+
border-color: #9333ea;
|
|
242
180
|
}
|
|
243
181
|
|
|
244
|
-
.wallet-modal-
|
|
245
|
-
|
|
182
|
+
.wallet-modal-send-address-input::placeholder {
|
|
183
|
+
opacity: 0.5;
|
|
246
184
|
}
|
|
247
185
|
|
|
248
|
-
/* Error Message */
|
|
249
186
|
.wallet-modal-send-error {
|
|
250
187
|
font-size: 12px;
|
|
251
188
|
color: #ef4444;
|
|
189
|
+
margin-top: 4px;
|
|
252
190
|
text-align: left;
|
|
253
191
|
}
|
|
254
192
|
|
|
255
|
-
|
|
256
|
-
.wallet-modal-send-btn {
|
|
193
|
+
.wallet-modal-send-preview-btn {
|
|
257
194
|
width: 100%;
|
|
258
195
|
padding: 14px 24px;
|
|
259
196
|
border-radius: 12px;
|
|
@@ -262,16 +199,36 @@
|
|
|
262
199
|
font-weight: 600;
|
|
263
200
|
cursor: pointer;
|
|
264
201
|
transition: all 0.2s;
|
|
265
|
-
|
|
266
|
-
|
|
202
|
+
display: flex;
|
|
203
|
+
align-items: center;
|
|
204
|
+
justify-content: center;
|
|
205
|
+
gap: 8px;
|
|
267
206
|
margin-top: 8px;
|
|
268
207
|
}
|
|
269
208
|
|
|
270
|
-
.wallet-modal-send-btn
|
|
271
|
-
background: #2563eb;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
.wallet-modal-send-btn.disabled {
|
|
209
|
+
.wallet-modal-send-preview-btn.disabled {
|
|
275
210
|
opacity: 0.5;
|
|
276
211
|
cursor: not-allowed;
|
|
277
212
|
}
|
|
213
|
+
|
|
214
|
+
.wallet-modal-theme-dark .wallet-modal-send-preview-btn {
|
|
215
|
+
background: linear-gradient(135deg, #9333ea 0%, #7e22ce 100%);
|
|
216
|
+
color: #ffffff;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.wallet-modal-theme-light .wallet-modal-send-preview-btn {
|
|
220
|
+
background: linear-gradient(135deg, #9333ea 0%, #7e22ce 100%);
|
|
221
|
+
color: #ffffff;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.wallet-modal-theme-dark .wallet-modal-send-preview-btn:hover:not(.disabled) {
|
|
225
|
+
background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
|
|
226
|
+
transform: translateY(-1px);
|
|
227
|
+
box-shadow: 0 4px 12px rgba(147, 51, 234, 0.3);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.wallet-modal-theme-light .wallet-modal-send-preview-btn:hover:not(.disabled) {
|
|
231
|
+
background: linear-gradient(135deg, #a855f7 0%, #9333ea 100%);
|
|
232
|
+
transform: translateY(-1px);
|
|
233
|
+
box-shadow: 0 4px 12px rgba(147, 51, 234, 0.2);
|
|
234
|
+
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { ChainData } from
|
|
2
|
-
import
|
|
1
|
+
import type { ChainData } from '../../../chains';
|
|
2
|
+
import './SendModal.css';
|
|
3
3
|
export interface SendModalProps {
|
|
4
4
|
isOpen: boolean;
|
|
5
5
|
onClose: () => void;
|
|
6
6
|
currentChain: ChainData | null;
|
|
7
|
+
availableChains: ChainData[];
|
|
7
8
|
displayAddress: string | null;
|
|
8
9
|
availableBalance: bigint | null;
|
|
9
10
|
externalWalletBalance: bigint | null;
|
|
@@ -11,6 +12,7 @@ export interface SendModalProps {
|
|
|
11
12
|
sendTransaction?: (tx: any) => Promise<{
|
|
12
13
|
hash: string;
|
|
13
14
|
}>;
|
|
14
|
-
|
|
15
|
+
switchChainEnhanced?: (chainId: number) => Promise<void>;
|
|
16
|
+
theme?: 'light' | 'dark';
|
|
15
17
|
}
|
|
16
|
-
export declare function SendModal({ isOpen, onClose, currentChain, displayAddress, availableBalance, externalWalletBalance, walletBalance, sendTransaction, theme, }: SendModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
18
|
+
export declare function SendModal({ isOpen, onClose, currentChain, availableChains, displayAddress, availableBalance, externalWalletBalance, walletBalance, sendTransaction, switchChainEnhanced, theme, }: SendModalProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -2,114 +2,22 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
/**
|
|
3
3
|
* Send Modal Component
|
|
4
4
|
*/
|
|
5
|
-
import { useState, useCallback, useMemo, useEffect } from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { useAddressValidation } from
|
|
10
|
-
import { useAmountValidation } from
|
|
11
|
-
import { useSendTransaction } from
|
|
12
|
-
import { formatBalanceValue } from
|
|
13
|
-
import
|
|
14
|
-
export function SendModal({ isOpen, onClose, currentChain, displayAddress, availableBalance, externalWalletBalance, walletBalance, sendTransaction, theme =
|
|
15
|
-
const [recipientAddress, setRecipientAddress] = useState(
|
|
16
|
-
const [amount, setAmount] = useState(
|
|
17
|
-
const [addressError, setAddressError] = useState(
|
|
18
|
-
const [amountError, setAmountError] = useState(
|
|
5
|
+
import { useState, useCallback, useMemo, useEffect } from 'react';
|
|
6
|
+
import { ChainSelector } from './ChainSelector';
|
|
7
|
+
import { PreviewTransactionModal } from './PreviewTransactionModal';
|
|
8
|
+
import { SuccessModal } from './SuccessModal';
|
|
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, availableChains, displayAddress, availableBalance, externalWalletBalance, walletBalance, sendTransaction, switchChainEnhanced, theme = 'dark', }) {
|
|
15
|
+
const [recipientAddress, setRecipientAddress] = useState('');
|
|
16
|
+
const [amount, setAmount] = useState('');
|
|
17
|
+
const [addressError, setAddressError] = useState('');
|
|
18
|
+
const [amountError, setAmountError] = useState('');
|
|
19
19
|
const [showPreview, setShowPreview] = useState(false);
|
|
20
|
-
const [showTokenSelector, setShowTokenSelector] = useState(false);
|
|
21
|
-
const [selectedToken, setSelectedToken] = useState(null);
|
|
22
20
|
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
21
|
const { validate: validateAddress } = useAddressValidation(displayAddress, currentChain);
|
|
114
22
|
const { validate: validateAmount } = useAmountValidation(balance, currentChain);
|
|
115
23
|
const { send, isSending, txHash, reset } = useSendTransaction({
|
|
@@ -135,22 +43,22 @@ export function SendModal({ isOpen, onClose, currentChain, displayAddress, avail
|
|
|
135
43
|
setAddressError(error);
|
|
136
44
|
}
|
|
137
45
|
else {
|
|
138
|
-
setAddressError(
|
|
46
|
+
setAddressError('');
|
|
139
47
|
}
|
|
140
48
|
}, [validateAddress]);
|
|
141
49
|
const handleAmountChange = useCallback((value) => {
|
|
142
50
|
// Only allow numbers and decimal point
|
|
143
|
-
const sanitized = value.replace(/[^0-9.]/g,
|
|
51
|
+
const sanitized = value.replace(/[^0-9.]/g, '');
|
|
144
52
|
// Prevent multiple decimal points
|
|
145
|
-
const parts = sanitized.split(
|
|
146
|
-
const finalValue = parts.length > 2 ? parts[0] +
|
|
53
|
+
const parts = sanitized.split('.');
|
|
54
|
+
const finalValue = parts.length > 2 ? parts[0] + '.' + parts.slice(1).join('') : sanitized;
|
|
147
55
|
setAmount(finalValue);
|
|
148
56
|
if (finalValue) {
|
|
149
57
|
const error = validateAmount(finalValue);
|
|
150
58
|
setAmountError(error);
|
|
151
59
|
}
|
|
152
60
|
else {
|
|
153
|
-
setAmountError(
|
|
61
|
+
setAmountError('');
|
|
154
62
|
}
|
|
155
63
|
}, [validateAmount]);
|
|
156
64
|
const handlePreviewTransaction = useCallback(() => {
|
|
@@ -172,18 +80,13 @@ export function SendModal({ isOpen, onClose, currentChain, displayAddress, avail
|
|
|
172
80
|
}
|
|
173
81
|
}, [send, recipientAddress, amount]);
|
|
174
82
|
const handleReset = useCallback(() => {
|
|
175
|
-
setRecipientAddress(
|
|
176
|
-
setAmount(
|
|
177
|
-
setAddressError(
|
|
178
|
-
setAmountError(
|
|
83
|
+
setRecipientAddress('');
|
|
84
|
+
setAmount('');
|
|
85
|
+
setAddressError('');
|
|
86
|
+
setAmountError('');
|
|
179
87
|
setShowPreview(false);
|
|
180
|
-
setShowTokenSelector(false);
|
|
181
88
|
reset();
|
|
182
89
|
}, [reset]);
|
|
183
|
-
const handleTokenSelect = useCallback((token) => {
|
|
184
|
-
setSelectedToken(token);
|
|
185
|
-
setShowTokenSelector(false);
|
|
186
|
-
}, []);
|
|
187
90
|
useEffect(() => {
|
|
188
91
|
if (!isOpen) {
|
|
189
92
|
handleReset();
|
|
@@ -192,12 +95,12 @@ export function SendModal({ isOpen, onClose, currentChain, displayAddress, avail
|
|
|
192
95
|
if (!isOpen)
|
|
193
96
|
return null;
|
|
194
97
|
const availableBalanceValue = useMemo(() => {
|
|
195
|
-
if (!balance || !
|
|
196
|
-
return
|
|
197
|
-
return formatBalanceValue(balance,
|
|
198
|
-
}, [balance,
|
|
199
|
-
const symbol =
|
|
200
|
-
const chainName = currentChain?.displayName ||
|
|
98
|
+
if (!balance || !currentChain)
|
|
99
|
+
return '0';
|
|
100
|
+
return formatBalanceValue(balance, currentChain.nativeCurrency.decimals);
|
|
101
|
+
}, [balance, currentChain]);
|
|
102
|
+
const symbol = currentChain?.nativeCurrency.symbol || 'ETH';
|
|
103
|
+
const chainName = currentChain?.displayName || 'Select Chain';
|
|
201
104
|
const isFormValid = !addressError && !amountError && recipientAddress && amount;
|
|
202
105
|
// Show success modal
|
|
203
106
|
if (txHash && !showPreview) {
|
|
@@ -210,10 +113,15 @@ export function SendModal({ isOpen, onClose, currentChain, displayAddress, avail
|
|
|
210
113
|
if (showPreview) {
|
|
211
114
|
return (_jsx(PreviewTransactionModal, { isOpen: true, onClose: () => setShowPreview(false), onConfirm: handleConfirmSend, recipientAddress: recipientAddress, amount: amount, displayAddress: displayAddress, currentChain: currentChain, isSending: isSending, theme: theme }));
|
|
212
115
|
}
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
116
|
+
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-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: "Send" }), _jsx("div", { style: { width: '40px' } })] }), _jsxs("div", { className: "wallet-modal-send-content", children: [_jsxs("div", { className: "wallet-modal-send-field", children: [_jsx("label", { className: "wallet-modal-send-label", children: "Select any token" }), _jsx("div", { className: "wallet-modal-send-token-selector-wrapper", children: _jsx(ChainSelector, { currentChain: currentChain, availableChains: availableChains, onChainSelect: async (chainId) => {
|
|
117
|
+
if (switchChainEnhanced && chainId !== currentChain?.id) {
|
|
118
|
+
try {
|
|
119
|
+
await switchChainEnhanced(chainId);
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
console.error('Failed to switch chain:', error);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}, theme: theme, className: "wallet-modal-send-chain-selector" }) })] }), _jsxs("div", { className: "wallet-modal-send-field", children: [_jsxs("div", { className: "wallet-modal-send-amount-wrapper", children: [_jsx("div", { className: "wallet-modal-send-amount-prefix", children: symbol }), _jsx("input", { type: "text", className: `wallet-modal-send-amount-input ${amountError ? 'error' : ''}`, placeholder: "Enter amount", value: amount, onChange: (e) => handleAmountChange(e.target.value) }), _jsx("div", { className: "wallet-modal-send-amount-suffix", children: "$ --" })] }), amountError && _jsx("div", { className: "wallet-modal-send-error", children: amountError }), _jsxs("div", { className: "wallet-modal-send-balance", children: [_jsx("span", { className: "wallet-modal-send-balance-label", children: "Available:" }), _jsxs("span", { className: "wallet-modal-send-balance-value", children: [availableBalanceValue, " ", symbol] })] })] }), _jsxs("div", { className: "wallet-modal-send-field", children: [_jsx("label", { className: "wallet-modal-send-label", children: "Recipient Address" }), _jsx("input", { type: "text", className: `wallet-modal-send-address-input ${addressError ? 'error' : ''}`, placeholder: "Address", value: recipientAddress, onChange: (e) => handleRecipientAddressChange(e.target.value) }), addressError && _jsx("div", { className: "wallet-modal-send-error", children: addressError })] }), _jsx("button", { className: `wallet-modal-send-preview-btn wallet-modal-theme-${theme} ${!isFormValid ? 'disabled' : ''}`, onClick: handlePreviewTransaction, disabled: !isFormValid, children: "Preview transaction" })] })] }) }));
|
|
218
126
|
}
|
|
219
127
|
//# sourceMappingURL=SendModal.js.map
|