@mintmoney/react 0.1.0-alpha.34 → 0.1.0-alpha.36
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 +252 -252
- package/dist/esm/checkout/views/crypto-intent/direct-details.js.map +1 -1
- package/dist/esm/refund/index.js +78 -224
- 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 +29 -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 +17 -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;
|
|
@@ -649,11 +581,27 @@ const RefundError = styled.div `
|
|
|
649
581
|
color: #b91c1c;
|
|
650
582
|
`;
|
|
651
583
|
const isEvmAddress = (value) => /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
const
|
|
655
|
-
|
|
656
|
-
|
|
584
|
+
const isValidRefundAddressForSource = (value, _source) => isEvmAddress(value);
|
|
585
|
+
const shouldResetManualRefundWalletForSource = (value, source) => {
|
|
586
|
+
const trimmedValue = value.trim();
|
|
587
|
+
return (trimmedValue.length > 0 &&
|
|
588
|
+
!isValidRefundAddressForSource(trimmedValue, source));
|
|
589
|
+
};
|
|
590
|
+
const getManualAttemptErrorMessage = (error) => {
|
|
591
|
+
const responseError = typeof error === "object" && error !== null && "error" in error
|
|
592
|
+
? error.error
|
|
593
|
+
: null;
|
|
594
|
+
const apiError = typeof responseError === "object" &&
|
|
595
|
+
responseError !== null &&
|
|
596
|
+
"error" in responseError
|
|
597
|
+
? responseError.error
|
|
598
|
+
: null;
|
|
599
|
+
const apiMessage = typeof apiError === "string" ? apiError : "";
|
|
600
|
+
const message = error instanceof Error
|
|
601
|
+
? error.message
|
|
602
|
+
: apiMessage || (typeof error === "string" ? error : "");
|
|
603
|
+
return message || "We couldn't generate payment details. Please try again.";
|
|
604
|
+
};
|
|
657
605
|
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
606
|
const getMonogram = (value) => {
|
|
659
607
|
const parts = value
|
|
@@ -676,6 +624,22 @@ const getChainAbbreviation = (chainName) => {
|
|
|
676
624
|
return "ETH";
|
|
677
625
|
return getMonogram(chainName);
|
|
678
626
|
};
|
|
627
|
+
const getManualChainIconUrl = (source) => {
|
|
628
|
+
const normalizedChain = source.chain.toLowerCase();
|
|
629
|
+
const normalizedChainName = source.chain_name.toLowerCase();
|
|
630
|
+
if (normalizedChain === "eip155:1" || normalizedChainName === "ethereum") {
|
|
631
|
+
return ETHEREUM_ICON_URL;
|
|
632
|
+
}
|
|
633
|
+
return source.chain_logo_url ?? null;
|
|
634
|
+
};
|
|
635
|
+
const SelectionIconView = ({ iconUrl, fallback, }) => {
|
|
636
|
+
const [failedIconUrl, setFailedIconUrl] = useState(null);
|
|
637
|
+
const resolvedIconUrl = iconUrl && iconUrl !== failedIconUrl ? iconUrl : null;
|
|
638
|
+
useEffect(() => {
|
|
639
|
+
setFailedIconUrl(null);
|
|
640
|
+
}, [iconUrl]);
|
|
641
|
+
return (_jsx(SelectionIcon, { children: resolvedIconUrl ? (_jsx(SelectionIconImage, { src: resolvedIconUrl, alt: "", "aria-hidden": "true", onError: () => setFailedIconUrl(resolvedIconUrl) })) : (_jsx(SelectionIconFallback, { children: fallback })) }));
|
|
642
|
+
};
|
|
679
643
|
const formatManualPaymentAmount = (amount, currency) => {
|
|
680
644
|
const amountText = String(amount);
|
|
681
645
|
return `${amountText} ${currency}`;
|
|
@@ -689,8 +653,7 @@ const shouldUseRawManualAmount = (chainName, currency) => {
|
|
|
689
653
|
};
|
|
690
654
|
const isTestnetOrMockCurrency = (currency) => shouldUseRawManualAmount(currency.chain_name, currency.asset_name) ||
|
|
691
655
|
shouldUseRawManualAmount(currency.chain, currency.asset);
|
|
692
|
-
const shouldLoadManualPaymentOptions = (currency) => !currency
|
|
693
|
-
!isTestnetOrMockCurrency(currency);
|
|
656
|
+
const shouldLoadManualPaymentOptions = (currency) => !isTestnetOrMockCurrency(currency);
|
|
694
657
|
const sourceKey = (source) => `${source.chain}__${source.asset}`;
|
|
695
658
|
const normalizeOptionalAddress = (address) => address?.trim().toLowerCase() || null;
|
|
696
659
|
const uniqueSourceOptions = (settlementCurrency, configuredSources) => {
|
|
@@ -811,8 +774,7 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
811
774
|
const [selectedSourceKey, setSelectedSourceKey] = useState(sourceOptions[0] ? sourceKey(sourceOptions[0]) : "");
|
|
812
775
|
const [selectedTokenKey, setSelectedTokenKey] = useState("");
|
|
813
776
|
const [manualSetupStep, setManualSetupStep] = useState("token");
|
|
814
|
-
const [
|
|
815
|
-
const [refundDetailsExpanded, setRefundDetailsExpanded] = useState(false);
|
|
777
|
+
const [refundEditorExpanded, setRefundEditorExpanded] = useState(false);
|
|
816
778
|
const [showQrCode, setShowQrCode] = useState(false);
|
|
817
779
|
const [refundWalletError, setRefundWalletError] = useState(null);
|
|
818
780
|
const [isCreatingAttempt, setIsCreatingAttempt] = useState(false);
|
|
@@ -932,6 +894,19 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
932
894
|
hasAcknowledged,
|
|
933
895
|
sourceOptions,
|
|
934
896
|
]);
|
|
897
|
+
useEffect(() => {
|
|
898
|
+
if (hasAcknowledged || refundWallet)
|
|
899
|
+
return;
|
|
900
|
+
const attemptRefundTo = cryptoPaymentAttempt?.refund_to?.trim();
|
|
901
|
+
if (attemptRefundTo) {
|
|
902
|
+
setRefundWallet(attemptRefundTo);
|
|
903
|
+
}
|
|
904
|
+
}, [cryptoPaymentAttempt?.refund_to, hasAcknowledged, refundWallet]);
|
|
905
|
+
useEffect(() => {
|
|
906
|
+
if (!refundEditorExpanded)
|
|
907
|
+
return;
|
|
908
|
+
refundWalletInputRef.current?.focus();
|
|
909
|
+
}, [refundEditorExpanded]);
|
|
935
910
|
const handleConfirm = async () => {
|
|
936
911
|
if (!payment?.id) {
|
|
937
912
|
goToView("failed", { reason: "confirm_payment" });
|
|
@@ -946,16 +921,6 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
946
921
|
goToView("failed", { reason: "confirm_payment" });
|
|
947
922
|
}
|
|
948
923
|
};
|
|
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
924
|
if (!cryptoCurrency) {
|
|
960
925
|
return null;
|
|
961
926
|
}
|
|
@@ -990,14 +955,17 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
990
955
|
const sourceCurrency = selectedSource?.asset_name ?? currency;
|
|
991
956
|
const sourceChain = selectedSource?.chain_name ?? chain;
|
|
992
957
|
const trimmedRefundWallet = refundWallet.trim();
|
|
993
|
-
const
|
|
958
|
+
const issuedPaymentAddress = instructions?.payment_address ?? cryptoPaymentAttempt?.destination_address;
|
|
959
|
+
const manualRefundWallet = trimmedRefundWallet;
|
|
960
|
+
const refundPreferenceChanged = normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) !==
|
|
961
|
+
normalizeOptionalAddress(manualRefundWallet);
|
|
994
962
|
const sourceMatchesSettlementCurrency = (source) => source.asset.toLowerCase() === settlementCurrency.asset.toLowerCase() &&
|
|
995
963
|
source.chain.toLowerCase() === settlementCurrency.chain.toLowerCase();
|
|
996
|
-
const canReuseAttemptForSource = (source) => Boolean(instructionSource &&
|
|
964
|
+
const canReuseAttemptForSource = (source, sourceRefundWallet = manualRefundWallet) => Boolean(instructionSource &&
|
|
997
965
|
instructionSource.token.toLowerCase() === source.asset.toLowerCase() &&
|
|
998
966
|
instructionSource.chain.toLowerCase() === source.chain.toLowerCase() &&
|
|
999
967
|
normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) ===
|
|
1000
|
-
normalizeOptionalAddress(
|
|
968
|
+
normalizeOptionalAddress(sourceRefundWallet) &&
|
|
1001
969
|
!attemptIsStale);
|
|
1002
970
|
const tokenHasFastManualRoute = (token) => sourceOptions.some((option) => getSourceTokenGroupKey(option, manualPaymentOptions) ===
|
|
1003
971
|
getSourceTokenGroupKey(token, manualPaymentOptions) &&
|
|
@@ -1005,7 +973,7 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1005
973
|
manualPaymentOptions.some((manualOption) => manualPaymentOptionKey(manualOption).toLowerCase() ===
|
|
1006
974
|
manualOptionLookupKey(option) && manualOption.kind === "direct")));
|
|
1007
975
|
const tokenIconUrl = selectedSource?.logo_url ?? settlementCurrency.logo_url ?? null;
|
|
1008
|
-
const chainIconUrl = selectedSource
|
|
976
|
+
const chainIconUrl = getManualChainIconUrl(selectedSource ?? settlementCurrency);
|
|
1009
977
|
const rawAmount = cryptoPaymentAttempt?.amount === undefined
|
|
1010
978
|
? null
|
|
1011
979
|
: String(cryptoPaymentAttempt.amount);
|
|
@@ -1016,9 +984,6 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1016
984
|
? instructions.source_amount
|
|
1017
985
|
: (instructions?.amount ?? rawAmount);
|
|
1018
986
|
const sourceTokenSymbol = getSourceTokenSymbol(selectedSource, manualPaymentOptions);
|
|
1019
|
-
const refundSummary = currentRefundWallet
|
|
1020
|
-
? `${currentRefundWallet.slice(0, 6)}...${currentRefundWallet.slice(-4)}`
|
|
1021
|
-
: "Sender wallet";
|
|
1022
987
|
const formattedAmount = sourceAmountFormatted === undefined
|
|
1023
988
|
? null
|
|
1024
989
|
: formatManualPaymentAmount(sourceAmountFormatted, sourceCurrency);
|
|
@@ -1031,10 +996,25 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1031
996
|
: sourceAmountFormatted === undefined
|
|
1032
997
|
? null
|
|
1033
998
|
: String(sourceAmountFormatted);
|
|
1034
|
-
const paymentAddress =
|
|
999
|
+
const paymentAddress = issuedPaymentAddress;
|
|
1035
1000
|
const qrPayload = instructions?.type === "token_transfer"
|
|
1036
1001
|
? instructions.qr_payload
|
|
1037
1002
|
: paymentAddress;
|
|
1003
|
+
const handleBackToSourceSetup = () => {
|
|
1004
|
+
dismissedAttemptKeyRef.current = manualAttemptKey(cryptoPaymentAttempt);
|
|
1005
|
+
setCopiedAddress(false);
|
|
1006
|
+
setCopiedAmount(false);
|
|
1007
|
+
setShowQrCode(false);
|
|
1008
|
+
setRefundWalletError(null);
|
|
1009
|
+
setRefundEditorExpanded(false);
|
|
1010
|
+
if (selectedSource &&
|
|
1011
|
+
shouldResetManualRefundWalletForSource(refundWallet, selectedSource)) {
|
|
1012
|
+
setRefundWallet("");
|
|
1013
|
+
}
|
|
1014
|
+
setIsCreatingAttempt(false);
|
|
1015
|
+
setHasAcknowledged(false);
|
|
1016
|
+
setManualSetupStep("network");
|
|
1017
|
+
};
|
|
1038
1018
|
const goBackInSetup = () => {
|
|
1039
1019
|
setRefundWalletError(null);
|
|
1040
1020
|
if (manualSetupStep === "network") {
|
|
@@ -1043,11 +1023,6 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1043
1023
|
}
|
|
1044
1024
|
return;
|
|
1045
1025
|
};
|
|
1046
|
-
const openRefundEditor = () => {
|
|
1047
|
-
setPaymentDetailsExpanded(true);
|
|
1048
|
-
setRefundDetailsExpanded(true);
|
|
1049
|
-
window.setTimeout(() => refundWalletInputRef.current?.focus(), 0);
|
|
1050
|
-
};
|
|
1051
1026
|
const selectToken = (token) => {
|
|
1052
1027
|
const nextTokenKey = getSourceTokenGroupKey(token, manualPaymentOptions);
|
|
1053
1028
|
const firstNetworkForToken = sourceOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === nextTokenKey) ?? token;
|
|
@@ -1057,27 +1032,22 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1057
1032
|
setRefundWalletError(null);
|
|
1058
1033
|
};
|
|
1059
1034
|
const generateManualPaymentForSource = async (source, options = {}) => {
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
setRefundDetailsExpanded(true);
|
|
1067
|
-
return;
|
|
1035
|
+
const sourceRefundWallet = options.refundWallet ?? manualRefundWallet;
|
|
1036
|
+
if (sourceRefundWallet &&
|
|
1037
|
+
!isValidRefundAddressForSource(sourceRefundWallet, source)) {
|
|
1038
|
+
setRefundWalletError("Enter a valid EVM refund wallet address.");
|
|
1039
|
+
setRefundEditorExpanded(true);
|
|
1040
|
+
return false;
|
|
1068
1041
|
}
|
|
1069
|
-
if (canReuseAttemptForSource(source)) {
|
|
1042
|
+
if (canReuseAttemptForSource(source, sourceRefundWallet)) {
|
|
1070
1043
|
dismissedAttemptKeyRef.current = null;
|
|
1071
1044
|
configureManualQuoteRefresh();
|
|
1072
1045
|
setAcknowledgedWithTransition(true);
|
|
1073
|
-
|
|
1074
|
-
setRefundDetailsExpanded(false);
|
|
1075
|
-
}
|
|
1076
|
-
return;
|
|
1046
|
+
return true;
|
|
1077
1047
|
}
|
|
1078
1048
|
setIsCreatingAttempt(true);
|
|
1079
1049
|
try {
|
|
1080
|
-
await createManualDirectPaymentAttempt("", 1,
|
|
1050
|
+
await createManualDirectPaymentAttempt("", 1, sourceRefundWallet || null, {
|
|
1081
1051
|
mode: sourceMatchesSettlementCurrency(source)
|
|
1082
1052
|
? undefined
|
|
1083
1053
|
: getManualPaymentAttemptMode(source, settlementCurrency),
|
|
@@ -1085,26 +1055,67 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1085
1055
|
});
|
|
1086
1056
|
configureManualQuoteRefresh();
|
|
1087
1057
|
setAcknowledgedWithTransition(true);
|
|
1088
|
-
|
|
1089
|
-
setRefundDetailsExpanded(false);
|
|
1090
|
-
}
|
|
1058
|
+
return true;
|
|
1091
1059
|
}
|
|
1092
1060
|
catch (error) {
|
|
1093
1061
|
console.error("Failed to create manual payment attempt:", error);
|
|
1094
|
-
goToView("failed");
|
|
1062
|
+
goToView("failed", { reason: getManualAttemptErrorMessage(error) });
|
|
1063
|
+
return false;
|
|
1095
1064
|
}
|
|
1096
1065
|
finally {
|
|
1097
1066
|
setIsCreatingAttempt(false);
|
|
1098
1067
|
}
|
|
1099
1068
|
};
|
|
1100
1069
|
const selectNetwork = (network) => {
|
|
1070
|
+
const shouldResetRefundWallet = shouldResetManualRefundWalletForSource(refundWallet, network);
|
|
1071
|
+
const nextRefundWallet = shouldResetRefundWallet ? "" : manualRefundWallet;
|
|
1101
1072
|
setSelectedSourceKey(sourceKey(network));
|
|
1102
1073
|
setRefundWalletError(null);
|
|
1103
|
-
|
|
1074
|
+
if (shouldResetRefundWallet) {
|
|
1075
|
+
setRefundWallet("");
|
|
1076
|
+
setRefundEditorExpanded(false);
|
|
1077
|
+
}
|
|
1104
1078
|
setCopiedAddress(false);
|
|
1105
1079
|
setCopiedAmount(false);
|
|
1106
1080
|
setShowQrCode(false);
|
|
1107
|
-
void generateManualPaymentForSource(network
|
|
1081
|
+
void generateManualPaymentForSource(network, {
|
|
1082
|
+
refundWallet: nextRefundWallet,
|
|
1083
|
+
});
|
|
1084
|
+
};
|
|
1085
|
+
const renderRefundPreference = () => {
|
|
1086
|
+
const refundLabel = manualRefundWallet
|
|
1087
|
+
? `${manualRefundWallet.slice(0, 6)}...${manualRefundWallet.slice(-4)}`
|
|
1088
|
+
: "Sender wallet";
|
|
1089
|
+
const refundActionLabel = refundEditorExpanded
|
|
1090
|
+
? "Confirm refund address"
|
|
1091
|
+
: "Edit refund address";
|
|
1092
|
+
const applyRefundPreference = async () => {
|
|
1093
|
+
if (!refundPreferenceChanged) {
|
|
1094
|
+
setRefundEditorExpanded(false);
|
|
1095
|
+
setRefundWalletError(null);
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
const updated = await generateManualPaymentForSource(selectedSource);
|
|
1099
|
+
if (updated) {
|
|
1100
|
+
setRefundEditorExpanded(false);
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
return (_jsxs(RefundPreferenceCard, { children: [_jsxs(RefundPreferenceSummary, { type: "button", onClick: () => {
|
|
1104
|
+
if (refundEditorExpanded) {
|
|
1105
|
+
void applyRefundPreference();
|
|
1106
|
+
}
|
|
1107
|
+
else {
|
|
1108
|
+
setRefundEditorExpanded(true);
|
|
1109
|
+
}
|
|
1110
|
+
}, "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) => {
|
|
1111
|
+
setRefundWallet(event.target.value);
|
|
1112
|
+
setRefundWalletError(null);
|
|
1113
|
+
}, onKeyDown: (event) => {
|
|
1114
|
+
if (event.key === "Enter") {
|
|
1115
|
+
event.preventDefault();
|
|
1116
|
+
void applyRefundPreference();
|
|
1117
|
+
}
|
|
1118
|
+
}, 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
1119
|
};
|
|
1109
1120
|
const copyToClipboard = async (value, setCopied) => {
|
|
1110
1121
|
try {
|
|
@@ -1116,44 +1127,33 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1116
1127
|
console.error("Failed to copy to clipboard:", error);
|
|
1117
1128
|
}
|
|
1118
1129
|
};
|
|
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 &&
|
|
1130
|
+
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
1131
|
paymentAddress &&
|
|
1130
1132
|
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) => {
|
|
1133
|
+
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
1134
|
console.error("Failed to copy address:", error);
|
|
1140
1135
|
}), 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
1136
|
console.error("Failed to copy address:", error);
|
|
1142
|
-
}), children: [copiedAddress ? (_jsx(ClipboardCheckIcon, { size: 16 })) : (_jsx(ClipboardAddIcon, { size: 16 })), copiedAddress ? "Copied address" : "Copy address"] })
|
|
1137
|
+
}), 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) => {
|
|
1138
|
+
console.error("Failed to copy amount:", error);
|
|
1139
|
+
}), title: "Click to copy amount", children: [_jsx(PaymentInstructionValue, { theme: config.theme, children: sendAmount }), _jsx(CopyButton, { isCopied: copiedAmount, onClick: (e) => {
|
|
1140
|
+
e.stopPropagation();
|
|
1141
|
+
copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
|
|
1142
|
+
console.error("Failed to copy amount:", error);
|
|
1143
|
+
});
|
|
1144
|
+
}, title: "Copy amount", children: copiedAmount ? (_jsx(ClipboardCheckIcon, { size: 15 })) : (_jsx(ClipboardAddIcon, { size: 15 })) })] })] })] })) : null] }));
|
|
1143
1145
|
if (!hasAcknowledged) {
|
|
1144
1146
|
if (manualSetupStep === "token") {
|
|
1145
1147
|
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select token" }), _jsx(OptionList, { children: tokenOptions.map((option) => {
|
|
1146
1148
|
const hasFastRoute = tokenHasFastManualRoute(option);
|
|
1147
1149
|
const tokenSymbol = getSourceTokenSymbol(option, manualPaymentOptions);
|
|
1148
1150
|
const showTokenName = option.asset_name.toLowerCase() !== tokenSymbol.toLowerCase();
|
|
1149
|
-
return (_jsxs(SelectionRow, { type: "button", onClick: () => selectToken(option), children: [_jsxs(SelectionRowLeft, { children: [_jsx(
|
|
1151
|
+
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
1152
|
}) }), _jsx(SetupActions, { children: _jsx(ModalBackButton, { view: "cryptoIntent" }) })] }));
|
|
1151
1153
|
}
|
|
1152
1154
|
if (manualSetupStep === "network") {
|
|
1153
1155
|
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 &&
|
|
1156
|
+
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
1157
|
sourceKey(option) === selectedSourceKey ? (_jsx(SelectionMeta, { children: "Generating..." })) : null] }, sourceKey(option)))) }), _jsx(SetupActions, { children: _jsx(StyledButton, { onClick: goBackInSetup, variant: "secondary", children: "Back" }) })] }));
|
|
1158
1158
|
}
|
|
1159
1159
|
return null;
|
|
@@ -1163,5 +1163,5 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
1163
1163
|
}
|
|
1164
1164
|
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
1165
|
};
|
|
1166
|
-
export { CryptoIntentDirectDetailsViewContent, getManualPaymentAttemptMode, getManualInstructionSource, shouldLoadManualPaymentOptions, uniqueSourceOptions, };
|
|
1166
|
+
export { CryptoIntentDirectDetailsViewContent, getManualPaymentAttemptMode, getManualChainIconUrl, getManualInstructionSource, shouldResetManualRefundWalletForSource, shouldLoadManualPaymentOptions, uniqueSourceOptions, };
|
|
1167
1167
|
//# sourceMappingURL=direct-details.js.map
|