@mintmoney/react 0.1.0-alpha.34 → 0.1.0-alpha.35
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/esm/api/payments.js +2 -0
- package/dist/esm/api/payments.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/direct-details.js +249 -242
- package/dist/esm/checkout/views/crypto-intent/direct-details.js.map +1 -1
- package/dist/esm/refund/index.js +75 -111
- package/dist/esm/refund/index.js.map +1 -1
- package/dist/esm/refund/prepare-guard.js +13 -0
- package/dist/esm/refund/prepare-guard.js.map +1 -0
- package/dist/esm/refund/prepare-signing.js +98 -0
- package/dist/esm/refund/prepare-signing.js.map +1 -0
- package/dist/types/api/payments.d.ts +2 -0
- package/dist/types/api/payments.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/direct-details.d.ts +3 -1
- package/dist/types/checkout/views/crypto-intent/direct-details.d.ts.map +1 -1
- package/dist/types/refund/index.d.ts +0 -56
- package/dist/types/refund/index.d.ts.map +1 -1
- package/dist/types/refund/prepare-guard.d.ts +10 -0
- package/dist/types/refund/prepare-guard.d.ts.map +1 -0
- package/dist/types/refund/prepare-signing.d.ts +82 -0
- package/dist/types/refund/prepare-signing.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
//@ts-expect-error import error
|
|
4
4
|
import { QRCode } from "react-qr-code";
|
|
5
5
|
import { keyframes, styled } from "styled-components";
|
|
6
6
|
import { confirmPayment, getManualPaymentOptions, } from "../../../api/payments.js";
|
|
7
|
-
import { AlertCircleIcon, ClipboardAddIcon, ClipboardCheckIcon, EditIcon, QuoteExpiryCountdown, StyledButton, Text, useModalWithView, } from "../../../components/index.js";
|
|
7
|
+
import { AlertCircleIcon, CheckMarkIcon, ClipboardAddIcon, ClipboardCheckIcon, EditIcon, QuoteExpiryCountdown, StyledButton, Text, useModalWithView, } from "../../../components/index.js";
|
|
8
8
|
import { useMintMoneyConfig } from "../../../context.js";
|
|
9
9
|
import { getAttemptQuoteTiming, isAttemptStale, } from "../../../state/checkout/payment-lifecycle.js";
|
|
10
10
|
import { clearQuoteRefresh, configureManualQuoteRefresh, createManualDirectPaymentAttempt, refreshQuote, useCheckoutStore, } from "../../../state/checkout/store.js";
|
|
11
11
|
import { ModalViewContainer } from "../../container.js";
|
|
12
12
|
import { ModalBackButton } from "../back.js";
|
|
13
13
|
const QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO = 0.25;
|
|
14
|
+
const ETHEREUM_ICON_URL = "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628";
|
|
14
15
|
const QRCard = styled.div `
|
|
15
16
|
background: #ffffff;
|
|
16
17
|
border: 1px solid #111827;
|
|
@@ -24,12 +25,12 @@ const QRCard = styled.div `
|
|
|
24
25
|
`;
|
|
25
26
|
const PaymentInstructionCard = styled.div `
|
|
26
27
|
background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
|
|
27
|
-
border: 1px solid #
|
|
28
|
-
border-radius:
|
|
29
|
-
padding:
|
|
28
|
+
border: 1px solid #e2e8f0;
|
|
29
|
+
border-radius: 16px;
|
|
30
|
+
padding: 16px;
|
|
30
31
|
display: flex;
|
|
31
32
|
flex-direction: column;
|
|
32
|
-
gap:
|
|
33
|
+
gap: 14px;
|
|
33
34
|
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
|
|
34
35
|
`;
|
|
35
36
|
const PaymentInstructionHeader = styled.div `
|
|
@@ -39,9 +40,9 @@ const PaymentInstructionHeader = styled.div `
|
|
|
39
40
|
gap: 8px;
|
|
40
41
|
`;
|
|
41
42
|
const PaymentInstructionLabel = styled.div `
|
|
42
|
-
font-size:
|
|
43
|
+
font-size: 13px;
|
|
43
44
|
line-height: 1.3;
|
|
44
|
-
font-weight:
|
|
45
|
+
font-weight: 600;
|
|
45
46
|
color: ${({ theme }) => theme.font.color.tertiary};
|
|
46
47
|
`;
|
|
47
48
|
const PaymentInstructionValue = styled.div `
|
|
@@ -91,31 +92,46 @@ const InfoRow = styled.div `
|
|
|
91
92
|
const AddressInfoRow = styled(InfoRow) `
|
|
92
93
|
align-items: flex-start;
|
|
93
94
|
width: 100%;
|
|
95
|
+
margin-top: 4px;
|
|
94
96
|
`;
|
|
95
97
|
const AddressText = styled.div `
|
|
96
98
|
font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
|
|
97
|
-
font-size:
|
|
98
|
-
line-height: 1.
|
|
99
|
-
font-weight:
|
|
99
|
+
font-size: 14px;
|
|
100
|
+
line-height: 1.55;
|
|
101
|
+
font-weight: 600;
|
|
100
102
|
color: ${({ theme }) => theme.font.color.primary};
|
|
101
103
|
width: 100%;
|
|
102
104
|
flex: 1 1 auto;
|
|
103
105
|
min-width: 0;
|
|
104
106
|
overflow-wrap: anywhere;
|
|
105
107
|
`;
|
|
108
|
+
const AmountInfoRow = styled(InfoRow) `
|
|
109
|
+
align-items: center;
|
|
110
|
+
gap: 8px;
|
|
111
|
+
width: fit-content;
|
|
112
|
+
max-width: 100%;
|
|
113
|
+
margin-top: 4px;
|
|
114
|
+
`;
|
|
106
115
|
const CopyButton = styled.button `
|
|
107
116
|
display: flex;
|
|
108
117
|
align-items: center;
|
|
109
118
|
justify-content: center;
|
|
110
|
-
|
|
119
|
+
width: 28px;
|
|
120
|
+
height: 28px;
|
|
121
|
+
flex: 0 0 28px;
|
|
122
|
+
background: ${({ isCopied }) => (isCopied ? "#ecfdf5" : "#f1f3fb")};
|
|
123
|
+
color: ${({ isCopied }) => (isCopied ? "#047857" : "#374151")};
|
|
111
124
|
border: none;
|
|
112
125
|
cursor: pointer;
|
|
113
|
-
padding:
|
|
114
|
-
border-radius:
|
|
115
|
-
transition:
|
|
126
|
+
padding: 0;
|
|
127
|
+
border-radius: 999px;
|
|
128
|
+
transition:
|
|
129
|
+
background 0.15s ease,
|
|
130
|
+
color 0.15s ease,
|
|
131
|
+
transform 0.15s ease;
|
|
116
132
|
|
|
117
133
|
&:hover {
|
|
118
|
-
background
|
|
134
|
+
background: ${({ isCopied }) => (isCopied ? "#dcfce7" : "#e8edf7")};
|
|
119
135
|
}
|
|
120
136
|
|
|
121
137
|
${({ isCopied }) => isCopied &&
|
|
@@ -165,7 +181,7 @@ const IconButton = styled.button `
|
|
|
165
181
|
`;
|
|
166
182
|
const CopyAddressCta = styled.button `
|
|
167
183
|
width: 100%;
|
|
168
|
-
min-height:
|
|
184
|
+
min-height: 44px;
|
|
169
185
|
border: 0;
|
|
170
186
|
border-radius: 8px;
|
|
171
187
|
background: ${({ isCopied }) => (isCopied ? "#ecfdf5" : "#f1f3fb")};
|
|
@@ -255,6 +271,7 @@ const SelectionRowLeft = styled.div `
|
|
|
255
271
|
min-width: 0;
|
|
256
272
|
`;
|
|
257
273
|
const SelectionIcon = styled.div `
|
|
274
|
+
position: relative;
|
|
258
275
|
width: 40px;
|
|
259
276
|
height: 40px;
|
|
260
277
|
border-radius: 999px;
|
|
@@ -266,12 +283,20 @@ const SelectionIcon = styled.div `
|
|
|
266
283
|
font-weight: 700;
|
|
267
284
|
color: #1f2937;
|
|
268
285
|
background: #eef2f7;
|
|
269
|
-
background-image: ${({ $iconUrl }) => $iconUrl ? `url(${$iconUrl})` : "none"};
|
|
270
|
-
background-size: cover;
|
|
271
|
-
background-position: center;
|
|
272
|
-
background-repeat: no-repeat;
|
|
273
286
|
overflow: hidden;
|
|
274
287
|
`;
|
|
288
|
+
const SelectionIconFallback = styled.span `
|
|
289
|
+
position: relative;
|
|
290
|
+
z-index: 0;
|
|
291
|
+
`;
|
|
292
|
+
const SelectionIconImage = styled.img `
|
|
293
|
+
position: absolute;
|
|
294
|
+
inset: 6px;
|
|
295
|
+
z-index: 1;
|
|
296
|
+
width: calc(100% - 12px);
|
|
297
|
+
height: calc(100% - 12px);
|
|
298
|
+
object-fit: contain;
|
|
299
|
+
`;
|
|
275
300
|
const SelectionText = styled.div `
|
|
276
301
|
display: flex;
|
|
277
302
|
flex-direction: column;
|
|
@@ -317,161 +342,19 @@ const SelectionBadge = styled.span `
|
|
|
317
342
|
flex-shrink: 0;
|
|
318
343
|
`;
|
|
319
344
|
const SelectedSummary = styled.div `
|
|
320
|
-
border: 1px solid #
|
|
321
|
-
border-radius:
|
|
345
|
+
border: 1px solid #e2e8f0;
|
|
346
|
+
border-radius: 16px;
|
|
322
347
|
background: #ffffff;
|
|
323
348
|
overflow: hidden;
|
|
324
349
|
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
|
325
350
|
`;
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
border: 0;
|
|
329
|
-
background: transparent;
|
|
330
|
-
color: inherit;
|
|
331
|
-
padding: 12px;
|
|
351
|
+
const SelectedSummaryHeader = styled.div `
|
|
352
|
+
padding: 14px 16px;
|
|
332
353
|
display: flex;
|
|
333
354
|
align-items: center;
|
|
334
355
|
justify-content: space-between;
|
|
335
356
|
gap: 12px;
|
|
336
|
-
cursor: pointer;
|
|
337
357
|
text-align: left;
|
|
338
|
-
|
|
339
|
-
&:focus-visible {
|
|
340
|
-
outline: 2px solid #93c5fd;
|
|
341
|
-
outline-offset: -2px;
|
|
342
|
-
}
|
|
343
|
-
`;
|
|
344
|
-
const SelectedSummaryBody = styled.div `
|
|
345
|
-
border-top: 1px solid #edf1f5;
|
|
346
|
-
padding: 0 12px 12px;
|
|
347
|
-
`;
|
|
348
|
-
const SelectedSummaryNote = styled.div `
|
|
349
|
-
padding: 0 12px 12px;
|
|
350
|
-
`;
|
|
351
|
-
const ManualWarning = styled.div `
|
|
352
|
-
display: flex;
|
|
353
|
-
align-items: flex-start;
|
|
354
|
-
gap: 8px;
|
|
355
|
-
border-radius: 8px;
|
|
356
|
-
background: #f8fafc;
|
|
357
|
-
color: #4b5563;
|
|
358
|
-
font-size: 12px;
|
|
359
|
-
line-height: 1.45;
|
|
360
|
-
padding: 10px;
|
|
361
|
-
`;
|
|
362
|
-
const DetailRows = styled.div `
|
|
363
|
-
display: flex;
|
|
364
|
-
flex-direction: column;
|
|
365
|
-
margin-bottom: 12px;
|
|
366
|
-
`;
|
|
367
|
-
const DetailRow = styled.div `
|
|
368
|
-
display: flex;
|
|
369
|
-
align-items: center;
|
|
370
|
-
justify-content: space-between;
|
|
371
|
-
gap: 12px;
|
|
372
|
-
border-bottom: 1px solid #e5e7eb;
|
|
373
|
-
padding: 10px 0;
|
|
374
|
-
|
|
375
|
-
&:last-child {
|
|
376
|
-
border-bottom: 0;
|
|
377
|
-
padding-bottom: 0;
|
|
378
|
-
}
|
|
379
|
-
`;
|
|
380
|
-
const DetailLabel = styled.span `
|
|
381
|
-
font-size: 13px;
|
|
382
|
-
line-height: 1.3;
|
|
383
|
-
color: #374151;
|
|
384
|
-
`;
|
|
385
|
-
const DetailValue = styled.span `
|
|
386
|
-
display: inline-flex;
|
|
387
|
-
align-items: center;
|
|
388
|
-
justify-content: flex-end;
|
|
389
|
-
gap: 6px;
|
|
390
|
-
min-width: 0;
|
|
391
|
-
font-size: 13px;
|
|
392
|
-
line-height: 1.3;
|
|
393
|
-
font-weight: 600;
|
|
394
|
-
color: #111827;
|
|
395
|
-
text-align: right;
|
|
396
|
-
`;
|
|
397
|
-
const DetailAction = styled.button `
|
|
398
|
-
width: 24px;
|
|
399
|
-
height: 24px;
|
|
400
|
-
border: 0;
|
|
401
|
-
border-radius: 6px;
|
|
402
|
-
background: transparent;
|
|
403
|
-
color: #7c83a5;
|
|
404
|
-
display: inline-flex;
|
|
405
|
-
align-items: center;
|
|
406
|
-
justify-content: center;
|
|
407
|
-
padding: 0;
|
|
408
|
-
cursor: pointer;
|
|
409
|
-
|
|
410
|
-
&:hover,
|
|
411
|
-
&:focus-visible {
|
|
412
|
-
background: #f3f4f6;
|
|
413
|
-
color: #374151;
|
|
414
|
-
outline: none;
|
|
415
|
-
}
|
|
416
|
-
`;
|
|
417
|
-
const WarningIconWrap = styled.span `
|
|
418
|
-
color: #7c83a5;
|
|
419
|
-
line-height: 1;
|
|
420
|
-
flex-shrink: 0;
|
|
421
|
-
margin-top: 1px;
|
|
422
|
-
`;
|
|
423
|
-
const RefundDetails = styled.div `
|
|
424
|
-
margin: 0;
|
|
425
|
-
`;
|
|
426
|
-
const RefundDetailsCaret = styled.span `
|
|
427
|
-
width: 24px;
|
|
428
|
-
height: 24px;
|
|
429
|
-
border-radius: 999px;
|
|
430
|
-
background: #f1f3fb;
|
|
431
|
-
display: inline-flex;
|
|
432
|
-
align-items: center;
|
|
433
|
-
justify-content: center;
|
|
434
|
-
font-size: 13px;
|
|
435
|
-
line-height: 1;
|
|
436
|
-
color: #6b7280;
|
|
437
|
-
transform: rotate(${({ $expanded }) => ($expanded ? "180deg" : "0deg")});
|
|
438
|
-
transition:
|
|
439
|
-
transform 0.15s ease,
|
|
440
|
-
background 0.15s ease;
|
|
441
|
-
flex-shrink: 0;
|
|
442
|
-
`;
|
|
443
|
-
const RefundDetailsBody = styled.div `
|
|
444
|
-
padding: 12px 0 0;
|
|
445
|
-
`;
|
|
446
|
-
const RefundWarning = styled.div `
|
|
447
|
-
display: flex;
|
|
448
|
-
gap: 8px;
|
|
449
|
-
align-items: flex-start;
|
|
450
|
-
border-radius: 8px;
|
|
451
|
-
background: #fffbeb;
|
|
452
|
-
color: #92400e;
|
|
453
|
-
font-size: 12px;
|
|
454
|
-
line-height: 1.45;
|
|
455
|
-
padding: 10px 12px;
|
|
456
|
-
margin-bottom: 10px;
|
|
457
|
-
`;
|
|
458
|
-
const RefundWarningAction = styled.button `
|
|
459
|
-
border: 0;
|
|
460
|
-
background: transparent;
|
|
461
|
-
color: #92400e;
|
|
462
|
-
display: inline-flex;
|
|
463
|
-
align-items: center;
|
|
464
|
-
gap: 4px;
|
|
465
|
-
padding: 0;
|
|
466
|
-
font: inherit;
|
|
467
|
-
font-weight: 700;
|
|
468
|
-
text-decoration: underline;
|
|
469
|
-
cursor: pointer;
|
|
470
|
-
|
|
471
|
-
&:focus-visible {
|
|
472
|
-
outline: 2px solid #fbbf24;
|
|
473
|
-
outline-offset: 2px;
|
|
474
|
-
}
|
|
475
358
|
`;
|
|
476
359
|
const OptionHeader = styled.div `
|
|
477
360
|
display: flex;
|
|
@@ -489,8 +372,8 @@ const OptionHeaderLeft = styled.div `
|
|
|
489
372
|
`;
|
|
490
373
|
const TokenIconWrap = styled.div `
|
|
491
374
|
position: relative;
|
|
492
|
-
width:
|
|
493
|
-
height:
|
|
375
|
+
width: 42px;
|
|
376
|
+
height: 42px;
|
|
494
377
|
flex-shrink: 0;
|
|
495
378
|
`;
|
|
496
379
|
const TokenIcon = styled.div `
|
|
@@ -511,15 +394,15 @@ const TokenIcon = styled.div `
|
|
|
511
394
|
`;
|
|
512
395
|
const ChainBadge = styled.div `
|
|
513
396
|
position: absolute;
|
|
514
|
-
right: -
|
|
515
|
-
bottom: -
|
|
516
|
-
width:
|
|
517
|
-
height:
|
|
397
|
+
right: -1px;
|
|
398
|
+
bottom: -1px;
|
|
399
|
+
width: 20px;
|
|
400
|
+
height: 20px;
|
|
518
401
|
border-radius: 999px;
|
|
519
|
-
border:
|
|
520
|
-
background:
|
|
402
|
+
border: 2px solid #ffffff;
|
|
403
|
+
background: #ffffff;
|
|
521
404
|
background-image: ${({ $iconUrl }) => $iconUrl ? `url(${$iconUrl})` : "none"};
|
|
522
|
-
background-size:
|
|
405
|
+
background-size: 72%;
|
|
523
406
|
background-position: center;
|
|
524
407
|
background-repeat: no-repeat;
|
|
525
408
|
box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
|
|
@@ -638,6 +521,55 @@ const RefundWalletInput = styled.input `
|
|
|
638
521
|
border-color: #3b82f6;
|
|
639
522
|
}
|
|
640
523
|
`;
|
|
524
|
+
const RefundPreferenceCard = styled.div `
|
|
525
|
+
display: flex;
|
|
526
|
+
flex-direction: column;
|
|
527
|
+
gap: 10px;
|
|
528
|
+
border: 1px solid #eef2f6;
|
|
529
|
+
border-radius: 12px;
|
|
530
|
+
background: #ffffff;
|
|
531
|
+
padding: 12px;
|
|
532
|
+
text-align: left;
|
|
533
|
+
`;
|
|
534
|
+
const RefundPreferenceSummary = styled.button `
|
|
535
|
+
width: 100%;
|
|
536
|
+
border: 0;
|
|
537
|
+
background: transparent;
|
|
538
|
+
color: inherit;
|
|
539
|
+
padding: 0;
|
|
540
|
+
display: flex;
|
|
541
|
+
align-items: center;
|
|
542
|
+
justify-content: space-between;
|
|
543
|
+
gap: 12px;
|
|
544
|
+
text-align: left;
|
|
545
|
+
cursor: pointer;
|
|
546
|
+
|
|
547
|
+
&:focus-visible {
|
|
548
|
+
outline: 2px solid #93c5fd;
|
|
549
|
+
outline-offset: 4px;
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
&:disabled {
|
|
553
|
+
cursor: default;
|
|
554
|
+
}
|
|
555
|
+
`;
|
|
556
|
+
const RefundPreferenceText = styled.div `
|
|
557
|
+
display: flex;
|
|
558
|
+
flex-direction: column;
|
|
559
|
+
gap: 2px;
|
|
560
|
+
min-width: 0;
|
|
561
|
+
`;
|
|
562
|
+
const RefundPreferenceAction = styled.span `
|
|
563
|
+
width: 28px;
|
|
564
|
+
height: 28px;
|
|
565
|
+
border-radius: 999px;
|
|
566
|
+
background: #f1f3fb;
|
|
567
|
+
color: #6b7280;
|
|
568
|
+
display: inline-flex;
|
|
569
|
+
align-items: center;
|
|
570
|
+
justify-content: center;
|
|
571
|
+
flex-shrink: 0;
|
|
572
|
+
`;
|
|
641
573
|
const RefundCopy = styled.div `
|
|
642
574
|
font-size: 11px;
|
|
643
575
|
line-height: 1.35;
|
|
@@ -654,6 +586,26 @@ const isTronAddress = (value) => /^T[1-9A-HJ-NP-Za-km-z]{33}$/.test(value) ||
|
|
|
654
586
|
const isValidRefundAddressForSource = (value, source) => source.chain.toLowerCase().startsWith("tron:")
|
|
655
587
|
? isTronAddress(value)
|
|
656
588
|
: isEvmAddress(value);
|
|
589
|
+
const shouldResetManualRefundWalletForSource = (value, source) => {
|
|
590
|
+
const trimmedValue = value.trim();
|
|
591
|
+
return (trimmedValue.length > 0 &&
|
|
592
|
+
!isValidRefundAddressForSource(trimmedValue, source));
|
|
593
|
+
};
|
|
594
|
+
const getManualAttemptErrorMessage = (error) => {
|
|
595
|
+
const responseError = typeof error === "object" && error !== null && "error" in error
|
|
596
|
+
? error.error
|
|
597
|
+
: null;
|
|
598
|
+
const apiError = typeof responseError === "object" &&
|
|
599
|
+
responseError !== null &&
|
|
600
|
+
"error" in responseError
|
|
601
|
+
? responseError.error
|
|
602
|
+
: null;
|
|
603
|
+
const apiMessage = typeof apiError === "string" ? apiError : "";
|
|
604
|
+
const message = error instanceof Error
|
|
605
|
+
? error.message
|
|
606
|
+
: apiMessage || (typeof error === "string" ? error : "");
|
|
607
|
+
return message || "We couldn't generate payment details. Please try again.";
|
|
608
|
+
};
|
|
657
609
|
const QrCodeIcon = ({ size = 16 }) => (_jsxs("svg", { "aria-hidden": "true", width: size, height: size, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("path", { d: "M4 4h6v6H4V4ZM14 4h6v6h-6V4ZM4 14h6v6H4v-6Z", stroke: "currentColor", strokeWidth: "1.8", strokeLinejoin: "round" }), _jsx("path", { d: "M15 14h2v2h-2v-2ZM19 14h1v3h-3v-1h2v-2ZM14 18h3v2h-3v-2ZM19 19h1v1h-1v-1Z", fill: "currentColor" })] }));
|
|
658
610
|
const getMonogram = (value) => {
|
|
659
611
|
const parts = value
|
|
@@ -676,6 +628,22 @@ const getChainAbbreviation = (chainName) => {
|
|
|
676
628
|
return "ETH";
|
|
677
629
|
return getMonogram(chainName);
|
|
678
630
|
};
|
|
631
|
+
const getManualChainIconUrl = (source) => {
|
|
632
|
+
const normalizedChain = source.chain.toLowerCase();
|
|
633
|
+
const normalizedChainName = source.chain_name.toLowerCase();
|
|
634
|
+
if (normalizedChain === "eip155:1" || normalizedChainName === "ethereum") {
|
|
635
|
+
return ETHEREUM_ICON_URL;
|
|
636
|
+
}
|
|
637
|
+
return source.chain_logo_url ?? null;
|
|
638
|
+
};
|
|
639
|
+
const SelectionIconView = ({ iconUrl, fallback, }) => {
|
|
640
|
+
const [failedIconUrl, setFailedIconUrl] = useState(null);
|
|
641
|
+
const resolvedIconUrl = iconUrl && iconUrl !== failedIconUrl ? iconUrl : null;
|
|
642
|
+
useEffect(() => {
|
|
643
|
+
setFailedIconUrl(null);
|
|
644
|
+
}, [iconUrl]);
|
|
645
|
+
return (_jsx(SelectionIcon, { children: resolvedIconUrl ? (_jsx(SelectionIconImage, { src: resolvedIconUrl, alt: "", "aria-hidden": "true", onError: () => setFailedIconUrl(resolvedIconUrl) })) : (_jsx(SelectionIconFallback, { children: fallback })) }));
|
|
646
|
+
};
|
|
679
647
|
const formatManualPaymentAmount = (amount, currency) => {
|
|
680
648
|
const amountText = String(amount);
|
|
681
649
|
return `${amountText} ${currency}`;
|
|
@@ -811,8 +779,7 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
811
779
|
const [selectedSourceKey, setSelectedSourceKey] = useState(sourceOptions[0] ? sourceKey(sourceOptions[0]) : "");
|
|
812
780
|
const [selectedTokenKey, setSelectedTokenKey] = useState("");
|
|
813
781
|
const [manualSetupStep, setManualSetupStep] = useState("token");
|
|
814
|
-
const [
|
|
815
|
-
const [refundDetailsExpanded, setRefundDetailsExpanded] = useState(false);
|
|
782
|
+
const [refundEditorExpanded, setRefundEditorExpanded] = useState(false);
|
|
816
783
|
const [showQrCode, setShowQrCode] = useState(false);
|
|
817
784
|
const [refundWalletError, setRefundWalletError] = useState(null);
|
|
818
785
|
const [isCreatingAttempt, setIsCreatingAttempt] = useState(false);
|
|
@@ -932,6 +899,19 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
932
899
|
hasAcknowledged,
|
|
933
900
|
sourceOptions,
|
|
934
901
|
]);
|
|
902
|
+
useEffect(() => {
|
|
903
|
+
if (hasAcknowledged || refundWallet)
|
|
904
|
+
return;
|
|
905
|
+
const attemptRefundTo = cryptoPaymentAttempt?.refund_to?.trim();
|
|
906
|
+
if (attemptRefundTo) {
|
|
907
|
+
setRefundWallet(attemptRefundTo);
|
|
908
|
+
}
|
|
909
|
+
}, [cryptoPaymentAttempt?.refund_to, hasAcknowledged, refundWallet]);
|
|
910
|
+
useEffect(() => {
|
|
911
|
+
if (!refundEditorExpanded)
|
|
912
|
+
return;
|
|
913
|
+
refundWalletInputRef.current?.focus();
|
|
914
|
+
}, [refundEditorExpanded]);
|
|
935
915
|
const handleConfirm = async () => {
|
|
936
916
|
if (!payment?.id) {
|
|
937
917
|
goToView("failed", { reason: "confirm_payment" });
|
|
@@ -946,16 +926,6 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
946
926
|
goToView("failed", { reason: "confirm_payment" });
|
|
947
927
|
}
|
|
948
928
|
};
|
|
949
|
-
const handleBackToSourceSetup = () => {
|
|
950
|
-
dismissedAttemptKeyRef.current = manualAttemptKey(cryptoPaymentAttempt);
|
|
951
|
-
setCopiedAddress(false);
|
|
952
|
-
setCopiedAmount(false);
|
|
953
|
-
setShowQrCode(false);
|
|
954
|
-
setRefundWalletError(null);
|
|
955
|
-
setIsCreatingAttempt(false);
|
|
956
|
-
setHasAcknowledged(false);
|
|
957
|
-
setManualSetupStep("network");
|
|
958
|
-
};
|
|
959
929
|
if (!cryptoCurrency) {
|
|
960
930
|
return null;
|
|
961
931
|
}
|
|
@@ -990,14 +960,17 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
990
960
|
const sourceCurrency = selectedSource?.asset_name ?? currency;
|
|
991
961
|
const sourceChain = selectedSource?.chain_name ?? chain;
|
|
992
962
|
const trimmedRefundWallet = refundWallet.trim();
|
|
993
|
-
const
|
|
963
|
+
const issuedPaymentAddress = instructions?.payment_address ?? cryptoPaymentAttempt?.destination_address;
|
|
964
|
+
const manualRefundWallet = trimmedRefundWallet;
|
|
965
|
+
const refundPreferenceChanged = normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) !==
|
|
966
|
+
normalizeOptionalAddress(manualRefundWallet);
|
|
994
967
|
const sourceMatchesSettlementCurrency = (source) => source.asset.toLowerCase() === settlementCurrency.asset.toLowerCase() &&
|
|
995
968
|
source.chain.toLowerCase() === settlementCurrency.chain.toLowerCase();
|
|
996
|
-
const canReuseAttemptForSource = (source) => Boolean(instructionSource &&
|
|
969
|
+
const canReuseAttemptForSource = (source, sourceRefundWallet = manualRefundWallet) => Boolean(instructionSource &&
|
|
997
970
|
instructionSource.token.toLowerCase() === source.asset.toLowerCase() &&
|
|
998
971
|
instructionSource.chain.toLowerCase() === source.chain.toLowerCase() &&
|
|
999
972
|
normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) ===
|
|
1000
|
-
normalizeOptionalAddress(
|
|
973
|
+
normalizeOptionalAddress(sourceRefundWallet) &&
|
|
1001
974
|
!attemptIsStale);
|
|
1002
975
|
const tokenHasFastManualRoute = (token) => sourceOptions.some((option) => getSourceTokenGroupKey(option, manualPaymentOptions) ===
|
|
1003
976
|
getSourceTokenGroupKey(token, manualPaymentOptions) &&
|
|
@@ -1005,7 +978,7 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1005
978
|
manualPaymentOptions.some((manualOption) => manualPaymentOptionKey(manualOption).toLowerCase() ===
|
|
1006
979
|
manualOptionLookupKey(option) && manualOption.kind === "direct")));
|
|
1007
980
|
const tokenIconUrl = selectedSource?.logo_url ?? settlementCurrency.logo_url ?? null;
|
|
1008
|
-
const chainIconUrl = selectedSource
|
|
981
|
+
const chainIconUrl = getManualChainIconUrl(selectedSource ?? settlementCurrency);
|
|
1009
982
|
const rawAmount = cryptoPaymentAttempt?.amount === undefined
|
|
1010
983
|
? null
|
|
1011
984
|
: String(cryptoPaymentAttempt.amount);
|
|
@@ -1016,9 +989,6 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1016
989
|
? instructions.source_amount
|
|
1017
990
|
: (instructions?.amount ?? rawAmount);
|
|
1018
991
|
const sourceTokenSymbol = getSourceTokenSymbol(selectedSource, manualPaymentOptions);
|
|
1019
|
-
const refundSummary = currentRefundWallet
|
|
1020
|
-
? `${currentRefundWallet.slice(0, 6)}...${currentRefundWallet.slice(-4)}`
|
|
1021
|
-
: "Sender wallet";
|
|
1022
992
|
const formattedAmount = sourceAmountFormatted === undefined
|
|
1023
993
|
? null
|
|
1024
994
|
: formatManualPaymentAmount(sourceAmountFormatted, sourceCurrency);
|
|
@@ -1031,10 +1001,25 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1031
1001
|
: sourceAmountFormatted === undefined
|
|
1032
1002
|
? null
|
|
1033
1003
|
: String(sourceAmountFormatted);
|
|
1034
|
-
const paymentAddress =
|
|
1004
|
+
const paymentAddress = issuedPaymentAddress;
|
|
1035
1005
|
const qrPayload = instructions?.type === "token_transfer"
|
|
1036
1006
|
? instructions.qr_payload
|
|
1037
1007
|
: paymentAddress;
|
|
1008
|
+
const handleBackToSourceSetup = () => {
|
|
1009
|
+
dismissedAttemptKeyRef.current = manualAttemptKey(cryptoPaymentAttempt);
|
|
1010
|
+
setCopiedAddress(false);
|
|
1011
|
+
setCopiedAmount(false);
|
|
1012
|
+
setShowQrCode(false);
|
|
1013
|
+
setRefundWalletError(null);
|
|
1014
|
+
setRefundEditorExpanded(false);
|
|
1015
|
+
if (selectedSource &&
|
|
1016
|
+
shouldResetManualRefundWalletForSource(refundWallet, selectedSource)) {
|
|
1017
|
+
setRefundWallet("");
|
|
1018
|
+
}
|
|
1019
|
+
setIsCreatingAttempt(false);
|
|
1020
|
+
setHasAcknowledged(false);
|
|
1021
|
+
setManualSetupStep("network");
|
|
1022
|
+
};
|
|
1038
1023
|
const goBackInSetup = () => {
|
|
1039
1024
|
setRefundWalletError(null);
|
|
1040
1025
|
if (manualSetupStep === "network") {
|
|
@@ -1043,11 +1028,6 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1043
1028
|
}
|
|
1044
1029
|
return;
|
|
1045
1030
|
};
|
|
1046
|
-
const openRefundEditor = () => {
|
|
1047
|
-
setPaymentDetailsExpanded(true);
|
|
1048
|
-
setRefundDetailsExpanded(true);
|
|
1049
|
-
window.setTimeout(() => refundWalletInputRef.current?.focus(), 0);
|
|
1050
|
-
};
|
|
1051
1031
|
const selectToken = (token) => {
|
|
1052
1032
|
const nextTokenKey = getSourceTokenGroupKey(token, manualPaymentOptions);
|
|
1053
1033
|
const firstNetworkForToken = sourceOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === nextTokenKey) ?? token;
|
|
@@ -1057,27 +1037,24 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1057
1037
|
setRefundWalletError(null);
|
|
1058
1038
|
};
|
|
1059
1039
|
const generateManualPaymentForSource = async (source, options = {}) => {
|
|
1060
|
-
|
|
1061
|
-
|
|
1040
|
+
const sourceRefundWallet = options.refundWallet ?? manualRefundWallet;
|
|
1041
|
+
if (sourceRefundWallet &&
|
|
1042
|
+
!isValidRefundAddressForSource(sourceRefundWallet, source)) {
|
|
1062
1043
|
setRefundWalletError(source.chain.toLowerCase().startsWith("tron:")
|
|
1063
1044
|
? "Enter a valid TRON refund wallet address."
|
|
1064
1045
|
: "Enter a valid EVM refund wallet address.");
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
return;
|
|
1046
|
+
setRefundEditorExpanded(true);
|
|
1047
|
+
return false;
|
|
1068
1048
|
}
|
|
1069
|
-
if (canReuseAttemptForSource(source)) {
|
|
1049
|
+
if (canReuseAttemptForSource(source, sourceRefundWallet)) {
|
|
1070
1050
|
dismissedAttemptKeyRef.current = null;
|
|
1071
1051
|
configureManualQuoteRefresh();
|
|
1072
1052
|
setAcknowledgedWithTransition(true);
|
|
1073
|
-
|
|
1074
|
-
setRefundDetailsExpanded(false);
|
|
1075
|
-
}
|
|
1076
|
-
return;
|
|
1053
|
+
return true;
|
|
1077
1054
|
}
|
|
1078
1055
|
setIsCreatingAttempt(true);
|
|
1079
1056
|
try {
|
|
1080
|
-
await createManualDirectPaymentAttempt("", 1,
|
|
1057
|
+
await createManualDirectPaymentAttempt("", 1, sourceRefundWallet || null, {
|
|
1081
1058
|
mode: sourceMatchesSettlementCurrency(source)
|
|
1082
1059
|
? undefined
|
|
1083
1060
|
: getManualPaymentAttemptMode(source, settlementCurrency),
|
|
@@ -1085,26 +1062,67 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1085
1062
|
});
|
|
1086
1063
|
configureManualQuoteRefresh();
|
|
1087
1064
|
setAcknowledgedWithTransition(true);
|
|
1088
|
-
|
|
1089
|
-
setRefundDetailsExpanded(false);
|
|
1090
|
-
}
|
|
1065
|
+
return true;
|
|
1091
1066
|
}
|
|
1092
1067
|
catch (error) {
|
|
1093
1068
|
console.error("Failed to create manual payment attempt:", error);
|
|
1094
|
-
goToView("failed");
|
|
1069
|
+
goToView("failed", { reason: getManualAttemptErrorMessage(error) });
|
|
1070
|
+
return false;
|
|
1095
1071
|
}
|
|
1096
1072
|
finally {
|
|
1097
1073
|
setIsCreatingAttempt(false);
|
|
1098
1074
|
}
|
|
1099
1075
|
};
|
|
1100
1076
|
const selectNetwork = (network) => {
|
|
1077
|
+
const shouldResetRefundWallet = shouldResetManualRefundWalletForSource(refundWallet, network);
|
|
1078
|
+
const nextRefundWallet = shouldResetRefundWallet ? "" : manualRefundWallet;
|
|
1101
1079
|
setSelectedSourceKey(sourceKey(network));
|
|
1102
1080
|
setRefundWalletError(null);
|
|
1103
|
-
|
|
1081
|
+
if (shouldResetRefundWallet) {
|
|
1082
|
+
setRefundWallet("");
|
|
1083
|
+
setRefundEditorExpanded(false);
|
|
1084
|
+
}
|
|
1104
1085
|
setCopiedAddress(false);
|
|
1105
1086
|
setCopiedAmount(false);
|
|
1106
1087
|
setShowQrCode(false);
|
|
1107
|
-
void generateManualPaymentForSource(network
|
|
1088
|
+
void generateManualPaymentForSource(network, {
|
|
1089
|
+
refundWallet: nextRefundWallet,
|
|
1090
|
+
});
|
|
1091
|
+
};
|
|
1092
|
+
const renderRefundPreference = () => {
|
|
1093
|
+
const refundLabel = manualRefundWallet
|
|
1094
|
+
? `${manualRefundWallet.slice(0, 6)}...${manualRefundWallet.slice(-4)}`
|
|
1095
|
+
: "Sender wallet";
|
|
1096
|
+
const refundActionLabel = refundEditorExpanded
|
|
1097
|
+
? "Confirm refund address"
|
|
1098
|
+
: "Edit refund address";
|
|
1099
|
+
const applyRefundPreference = async () => {
|
|
1100
|
+
if (!refundPreferenceChanged) {
|
|
1101
|
+
setRefundEditorExpanded(false);
|
|
1102
|
+
setRefundWalletError(null);
|
|
1103
|
+
return;
|
|
1104
|
+
}
|
|
1105
|
+
const updated = await generateManualPaymentForSource(selectedSource);
|
|
1106
|
+
if (updated) {
|
|
1107
|
+
setRefundEditorExpanded(false);
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
return (_jsxs(RefundPreferenceCard, { children: [_jsxs(RefundPreferenceSummary, { type: "button", onClick: () => {
|
|
1111
|
+
if (refundEditorExpanded) {
|
|
1112
|
+
void applyRefundPreference();
|
|
1113
|
+
}
|
|
1114
|
+
else {
|
|
1115
|
+
setRefundEditorExpanded(true);
|
|
1116
|
+
}
|
|
1117
|
+
}, "aria-expanded": refundEditorExpanded, "aria-label": refundActionLabel, disabled: isCreatingAttempt, children: [_jsxs(RefundPreferenceText, { children: [_jsx(Text, { size: "xs", weight: "normal", color: config.theme.font.color.tertiary, children: "Refund address" }), _jsx(Text, { size: "sm", weight: "semibold", color: config.theme.font.color.primary, children: refundLabel })] }), _jsx(RefundPreferenceAction, { children: refundEditorExpanded ? (_jsx(CheckMarkIcon, { size: 14 })) : (_jsx(EditIcon, { size: 14 })) })] }), refundEditorExpanded ? (_jsxs(RefundWalletPanel, { children: [_jsx(RefundWalletInput, { ref: refundWalletInputRef, value: refundWallet, onChange: (event) => {
|
|
1118
|
+
setRefundWallet(event.target.value);
|
|
1119
|
+
setRefundWalletError(null);
|
|
1120
|
+
}, onKeyDown: (event) => {
|
|
1121
|
+
if (event.key === "Enter") {
|
|
1122
|
+
event.preventDefault();
|
|
1123
|
+
void applyRefundPreference();
|
|
1124
|
+
}
|
|
1125
|
+
}, placeholder: "Refund wallet address", autoComplete: "off", spellCheck: false, disabled: isCreatingAttempt }), refundWalletError ? (_jsx(RefundError, { children: refundWalletError })) : null, _jsx(RefundCopy, { children: "Optional. Updating this refreshes the payment details." })] })) : null] }));
|
|
1108
1126
|
};
|
|
1109
1127
|
const copyToClipboard = async (value, setCopied) => {
|
|
1110
1128
|
try {
|
|
@@ -1116,44 +1134,33 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1116
1134
|
console.error("Failed to copy to clipboard:", error);
|
|
1117
1135
|
}
|
|
1118
1136
|
};
|
|
1119
|
-
const renderManualPaymentPanel = (options) => (_jsxs(PaymentDetailsStack, { children: [options.showPaymentDetails ? (_jsx(QuoteExpiryCountdown, { remainingMs: countdownRemainingMs, totalDurationMs: countdownTotalDurationMs, primaryColor: config.theme.btn.primary.default.backgroundColor, urgentThresholdRatio: QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO })) : null,
|
|
1120
|
-
setRefundWallet(event.target.value);
|
|
1121
|
-
setRefundWalletError(null);
|
|
1122
|
-
}, placeholder: "Refund wallet address", autoComplete: "off", spellCheck: false, disabled: isCreatingAttempt }), refundWalletError ? (_jsx(RefundError, { children: refundWalletError })) : null, _jsx(RefundCopy, { children: "Leave blank to refund the sender address." }), options.showPaymentDetails && trimmedRefundWallet ? (_jsx(StyledButton, { type: "button", variant: "secondary", size: "small", onClick: () => {
|
|
1123
|
-
void generateManualPaymentForSource(selectedSource, {
|
|
1124
|
-
collapseRefundEditor: true,
|
|
1125
|
-
});
|
|
1126
|
-
}, disabled: isCreatingAttempt, children: isCreatingAttempt
|
|
1127
|
-
? "Updating..."
|
|
1128
|
-
: "Update refund address" })) : null] })] })) : null })] })) : null] }), options.showPaymentDetails &&
|
|
1137
|
+
const renderManualPaymentPanel = (options) => (_jsxs(PaymentDetailsStack, { children: [options.showPaymentDetails ? (_jsx(QuoteExpiryCountdown, { remainingMs: countdownRemainingMs, totalDurationMs: countdownTotalDurationMs, primaryColor: config.theme.btn.primary.default.backgroundColor, urgentThresholdRatio: QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO })) : null, _jsx(SelectedSummary, { children: _jsx(SelectedSummaryHeader, { children: _jsx(OptionHeader, { children: _jsxs(OptionHeaderLeft, { children: [_jsxs(TokenIconWrap, { children: [_jsx(TokenIcon, { "$iconUrl": tokenIconUrl, children: tokenIconUrl ? null : getMonogram(sourceCurrency) }), _jsx(ChainBadge, { "$iconUrl": chainIconUrl, children: chainIconUrl ? null : getChainAbbreviation(sourceChain) })] }), _jsxs(OptionIdentity, { children: [_jsx(Text, { size: "xs", weight: "normal", color: config.theme.font.color.tertiary, children: "You send" }), _jsxs(Text, { size: "sm", weight: "semibold", color: config.theme.font.color.primary, children: [sourceTokenSymbol, " on ", sourceChain] })] })] }) }) }) }), options.showPaymentDetails ? renderRefundPreference() : null, options.showPaymentDetails &&
|
|
1129
1138
|
paymentAddress &&
|
|
1130
1139
|
sendAmount &&
|
|
1131
|
-
copyAmount ? (_jsxs(PaymentInstructionCard, { children: [_jsxs("div", { children: [
|
|
1132
|
-
console.error("Failed to copy amount:", error);
|
|
1133
|
-
}), title: "Click to copy amount", children: [_jsx(PaymentInstructionValue, { theme: config.theme, children: sendAmount }), _jsx("span", { style: { marginLeft: 8 }, children: _jsx(CopyButton, { isCopied: copiedAmount, onClick: (e) => {
|
|
1134
|
-
e.stopPropagation();
|
|
1135
|
-
copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
|
|
1136
|
-
console.error("Failed to copy amount:", error);
|
|
1137
|
-
});
|
|
1138
|
-
}, title: "Copy amount", children: copiedAmount ? (_jsx(ClipboardCheckIcon, { size: 16 })) : (_jsx(ClipboardAddIcon, { size: 16 })) }) })] })] }), _jsx(PaymentInstructionDivider, {}), _jsxs("div", { children: [_jsxs(PaymentInstructionHeader, { children: [_jsx(PaymentInstructionLabel, { theme: config.theme, children: "Payment address" }), _jsx(IconButton, { type: "button", "$active": showQrCode, onClick: () => setShowQrCode((visible) => !visible), title: showQrCode ? "Hide QR code" : "Show QR code", "aria-label": showQrCode ? "Hide QR code" : "Show QR code", children: _jsx(QrCodeIcon, { size: 16 }) })] }), showQrCode ? (_jsx(QRCard, { children: _jsx(QRCode, { value: qrPayload ?? paymentAddress, size: 236 }) })) : (_jsx(AddressInfoRow, { isCopied: copiedAddress, onClick: () => copyToClipboard(paymentAddress, setCopiedAddress).catch((error) => {
|
|
1140
|
+
copyAmount ? (_jsxs(PaymentInstructionCard, { children: [_jsxs("div", { children: [_jsxs(PaymentInstructionHeader, { children: [_jsx(PaymentInstructionLabel, { theme: config.theme, children: "Payment address" }), _jsx(IconButton, { type: "button", "$active": showQrCode, onClick: () => setShowQrCode((visible) => !visible), title: showQrCode ? "Hide QR code" : "Show QR code", "aria-label": showQrCode ? "Hide QR code" : "Show QR code", children: _jsx(QrCodeIcon, { size: 16 }) })] }), showQrCode ? (_jsx(QRCard, { children: _jsx(QRCode, { value: qrPayload ?? paymentAddress, size: 236 }) })) : (_jsx(AddressInfoRow, { isCopied: copiedAddress, onClick: () => copyToClipboard(paymentAddress, setCopiedAddress).catch((error) => {
|
|
1139
1141
|
console.error("Failed to copy address:", error);
|
|
1140
1142
|
}), title: "Click to copy address", children: _jsx(AddressText, { theme: config.theme, children: paymentAddress }) }))] }), _jsxs(CopyAddressCta, { type: "button", isCopied: copiedAddress, onClick: () => copyToClipboard(paymentAddress, setCopiedAddress).catch((error) => {
|
|
1141
1143
|
console.error("Failed to copy address:", error);
|
|
1142
|
-
}), children: [copiedAddress ? (_jsx(ClipboardCheckIcon, { size: 16 })) : (_jsx(ClipboardAddIcon, { size: 16 })), copiedAddress ? "Copied address" : "Copy address"] })
|
|
1144
|
+
}), children: [copiedAddress ? (_jsx(ClipboardCheckIcon, { size: 16 })) : (_jsx(ClipboardAddIcon, { size: 16 })), copiedAddress ? "Copied address" : "Copy address"] }), _jsx(PaymentInstructionDivider, {}), _jsxs("div", { children: [_jsx(PaymentInstructionHeader, { children: _jsx(PaymentInstructionLabel, { theme: config.theme, children: "Amount to send" }) }), _jsxs(AmountInfoRow, { isCopied: copiedAmount, onClick: () => copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
|
|
1145
|
+
console.error("Failed to copy amount:", error);
|
|
1146
|
+
}), title: "Click to copy amount", children: [_jsx(PaymentInstructionValue, { theme: config.theme, children: sendAmount }), _jsx(CopyButton, { isCopied: copiedAmount, onClick: (e) => {
|
|
1147
|
+
e.stopPropagation();
|
|
1148
|
+
copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
|
|
1149
|
+
console.error("Failed to copy amount:", error);
|
|
1150
|
+
});
|
|
1151
|
+
}, title: "Copy amount", children: copiedAmount ? (_jsx(ClipboardCheckIcon, { size: 15 })) : (_jsx(ClipboardAddIcon, { size: 15 })) })] })] })] })) : null] }));
|
|
1143
1152
|
if (!hasAcknowledged) {
|
|
1144
1153
|
if (manualSetupStep === "token") {
|
|
1145
1154
|
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select token" }), _jsx(OptionList, { children: tokenOptions.map((option) => {
|
|
1146
1155
|
const hasFastRoute = tokenHasFastManualRoute(option);
|
|
1147
1156
|
const tokenSymbol = getSourceTokenSymbol(option, manualPaymentOptions);
|
|
1148
1157
|
const showTokenName = option.asset_name.toLowerCase() !== tokenSymbol.toLowerCase();
|
|
1149
|
-
return (_jsxs(SelectionRow, { type: "button", onClick: () => selectToken(option), children: [_jsxs(SelectionRowLeft, { children: [_jsx(
|
|
1158
|
+
return (_jsxs(SelectionRow, { type: "button", onClick: () => selectToken(option), children: [_jsxs(SelectionRowLeft, { children: [_jsx(SelectionIconView, { iconUrl: option.logo_url, fallback: getMonogram(option.asset_name) }), _jsxs(SelectionText, { children: [_jsx(SelectionTitle, { children: tokenSymbol }), showTokenName ? (_jsx(SelectionSubtitle, { children: option.asset_name })) : null] })] }), hasFastRoute ? (_jsxs(SelectionBadge, { children: [_jsx("span", { children: "\u26A1" }), _jsx("span", { children: "Fast" })] })) : null] }, getSourceTokenGroupKey(option, manualPaymentOptions)));
|
|
1150
1159
|
}) }), _jsx(SetupActions, { children: _jsx(ModalBackButton, { view: "cryptoIntent" }) })] }));
|
|
1151
1160
|
}
|
|
1152
1161
|
if (manualSetupStep === "network") {
|
|
1153
1162
|
const selectedTokenLabel = selectedTokenOption?.asset_name ?? sourceCurrency;
|
|
1154
|
-
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select network" }), _jsx(OptionList, { children: uniqueNetworkOptions.map((option) => (_jsxs(SelectionRow, { type: "button", onClick: () => selectNetwork(option), disabled: isCreatingAttempt, children: [_jsxs(SelectionRowLeft, { children: [_jsx(
|
|
1155
|
-
? null
|
|
1156
|
-
: getChainAbbreviation(option.chain_name) }), _jsxs(SelectionText, { children: [_jsx(SelectionTitle, { children: option.chain_name }), _jsx(SelectionSubtitle, { children: selectedTokenLabel })] })] }), isCreatingAttempt &&
|
|
1163
|
+
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select network" }), _jsx(OptionList, { children: uniqueNetworkOptions.map((option) => (_jsxs(SelectionRow, { type: "button", onClick: () => selectNetwork(option), disabled: isCreatingAttempt, children: [_jsxs(SelectionRowLeft, { children: [_jsx(SelectionIconView, { iconUrl: getManualChainIconUrl(option), fallback: getChainAbbreviation(option.chain_name) }), _jsxs(SelectionText, { children: [_jsx(SelectionTitle, { children: option.chain_name }), _jsx(SelectionSubtitle, { children: selectedTokenLabel })] })] }), isCreatingAttempt &&
|
|
1157
1164
|
sourceKey(option) === selectedSourceKey ? (_jsx(SelectionMeta, { children: "Generating..." })) : null] }, sourceKey(option)))) }), _jsx(SetupActions, { children: _jsx(StyledButton, { onClick: goBackInSetup, variant: "secondary", children: "Back" }) })] }));
|
|
1158
1165
|
}
|
|
1159
1166
|
return null;
|
|
@@ -1163,5 +1170,5 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1163
1170
|
}
|
|
1164
1171
|
return (_jsxs(ManualPaymentLayout, { ref: modalRef, children: [_jsx(ManualPaymentScrollArea, { children: renderManualPaymentPanel({ showPaymentDetails: true }) }), _jsxs(ManualPaymentActions, { children: [_jsx(StyledButton, { onClick: handleConfirm, variant: "primary", children: "I've sent the funds" }), _jsx(StyledButton, { onClick: handleBackToSourceSetup, variant: "secondary", children: "Back" })] })] }));
|
|
1165
1172
|
};
|
|
1166
|
-
export { CryptoIntentDirectDetailsViewContent, getManualPaymentAttemptMode, getManualInstructionSource, shouldLoadManualPaymentOptions, uniqueSourceOptions, };
|
|
1173
|
+
export { CryptoIntentDirectDetailsViewContent, getManualPaymentAttemptMode, getManualChainIconUrl, getManualInstructionSource, shouldResetManualRefundWalletForSource, shouldLoadManualPaymentOptions, uniqueSourceOptions, };
|
|
1167
1174
|
//# sourceMappingURL=direct-details.js.map
|