@mintmoney/react 0.1.0-alpha.32 → 0.1.0-alpha.34
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/css/styles.css +41 -13
- package/dist/esm/api/generated.js +31 -0
- package/dist/esm/api/generated.js.map +1 -1
- package/dist/esm/api/index.js +1 -0
- package/dist/esm/api/index.js.map +1 -1
- package/dist/esm/api/payments.js +39 -0
- package/dist/esm/api/payments.js.map +1 -1
- package/dist/esm/checkout/index.js +22 -18
- package/dist/esm/checkout/index.js.map +1 -1
- package/dist/esm/checkout/modal.js +24 -4
- package/dist/esm/checkout/modal.js.map +1 -1
- package/dist/esm/checkout/providers/wagmi-config.js +108 -0
- package/dist/esm/checkout/providers/wagmi-config.js.map +1 -0
- package/dist/esm/checkout/providers/wallet-connect-resume.js +129 -0
- package/dist/esm/checkout/providers/wallet-connect-resume.js.map +1 -0
- package/dist/esm/checkout/resume-state.js +82 -0
- package/dist/esm/checkout/resume-state.js.map +1 -0
- package/dist/esm/checkout/surplus-refund.js +38 -0
- package/dist/esm/checkout/surplus-refund.js.map +1 -0
- package/dist/esm/checkout/views/back.js +2 -2
- package/dist/esm/checkout/views/back.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/direct-details.js +941 -102
- package/dist/esm/checkout/views/crypto-intent/direct-details.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/methods.js +153 -31
- package/dist/esm/checkout/views/crypto-intent/methods.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/processing.js +51 -3
- package/dist/esm/checkout/views/crypto-intent/processing.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/success.js +60 -9
- package/dist/esm/checkout/views/crypto-intent/success.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js +848 -222
- package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js.map +1 -1
- package/dist/esm/checkout/views/crypto-intent/wallet-select.js +151 -20
- package/dist/esm/checkout/views/crypto-intent/wallet-select.js.map +1 -1
- package/dist/esm/checkout/views/failed.js +83 -1
- package/dist/esm/checkout/views/failed.js.map +1 -1
- package/dist/esm/checkout/views/initial.js +61 -6
- package/dist/esm/checkout/views/initial.js.map +1 -1
- package/dist/esm/checkout/views/method-select.js +16 -4
- package/dist/esm/checkout/views/method-select.js.map +1 -1
- package/dist/esm/checkout/views/restart.js +1 -1
- package/dist/esm/checkout/views/restart.js.map +1 -1
- package/dist/esm/components/buttons/index.js +4 -1
- package/dist/esm/components/buttons/index.js.map +1 -1
- package/dist/esm/components/icons/clock.js +4 -0
- package/dist/esm/components/icons/clock.js.map +1 -0
- package/dist/esm/components/icons/edit.js +6 -0
- package/dist/esm/components/icons/edit.js.map +1 -0
- package/dist/esm/components/icons/index.js +4 -0
- package/dist/esm/components/icons/index.js.map +1 -1
- package/dist/esm/components/icons/log-out.js +6 -0
- package/dist/esm/components/icons/log-out.js.map +1 -0
- package/dist/esm/components/icons/send.js +6 -0
- package/dist/esm/components/icons/send.js.map +1 -0
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/components/modals/modal-with-views.js +5 -2
- package/dist/esm/components/modals/modal-with-views.js.map +1 -1
- package/dist/esm/components/modals/modal.js +1 -1
- package/dist/esm/components/modals/modal.js.map +1 -1
- package/dist/esm/components/modals/use-modal-with-views.js +0 -1
- package/dist/esm/components/modals/use-modal-with-views.js.map +1 -1
- package/dist/esm/components/quote-expiry/index.js +2 -0
- package/dist/esm/components/quote-expiry/index.js.map +1 -0
- package/dist/esm/components/quote-expiry/quote-expiry-countdown.js +35 -0
- package/dist/esm/components/quote-expiry/quote-expiry-countdown.js.map +1 -0
- package/dist/esm/components/quote-expiry/styles.js +109 -0
- package/dist/esm/components/quote-expiry/styles.js.map +1 -0
- package/dist/esm/components/quote-expiry/tiers.js +31 -0
- package/dist/esm/components/quote-expiry/tiers.js.map +1 -0
- package/dist/esm/components/wallet-selector/component.js +3 -5
- package/dist/esm/components/wallet-selector/component.js.map +1 -1
- package/dist/esm/components/wallet-selector/provider.js +1 -1
- package/dist/esm/components/wallet-selector/provider.js.map +1 -1
- package/dist/esm/components/wallet-selector/wallets/wagmi/index.js.map +1 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/integrations/lifi.js +52 -34
- package/dist/esm/integrations/lifi.js.map +1 -1
- package/dist/esm/refund/index.js +791 -0
- package/dist/esm/refund/index.js.map +1 -0
- package/dist/esm/state/checkout/payment-attempt.js +3 -0
- package/dist/esm/state/checkout/payment-attempt.js.map +1 -1
- package/dist/esm/state/checkout/payment-lifecycle.js +43 -35
- package/dist/esm/state/checkout/payment-lifecycle.js.map +1 -1
- package/dist/esm/state/checkout/store.js +318 -198
- package/dist/esm/state/checkout/store.js.map +1 -1
- package/dist/esm/state/checkout/wallet-payment-options.js +44 -0
- package/dist/esm/state/checkout/wallet-payment-options.js.map +1 -0
- package/dist/esm/themes/default.js +6 -0
- package/dist/esm/themes/default.js.map +1 -1
- package/dist/esm/utils/string.js +1 -0
- package/dist/esm/utils/string.js.map +1 -1
- package/dist/esm/utils/wallet-errors.js +15 -0
- package/dist/esm/utils/wallet-errors.js.map +1 -0
- package/dist/types/api/generated.d.ts +207 -4
- package/dist/types/api/generated.d.ts.map +1 -1
- package/dist/types/api/index.d.ts +2 -1
- package/dist/types/api/index.d.ts.map +1 -1
- package/dist/types/api/payments.d.ts +36 -1
- package/dist/types/api/payments.d.ts.map +1 -1
- package/dist/types/api/types.d.ts +4 -0
- package/dist/types/api/types.d.ts.map +1 -1
- package/dist/types/checkout/index.d.ts +4 -1
- package/dist/types/checkout/index.d.ts.map +1 -1
- package/dist/types/checkout/modal.d.ts.map +1 -1
- package/dist/types/checkout/providers/wagmi-config.d.ts +18 -0
- package/dist/types/checkout/providers/wagmi-config.d.ts.map +1 -0
- package/dist/types/checkout/providers/wallet-connect-resume.d.ts +9 -0
- package/dist/types/checkout/providers/wallet-connect-resume.d.ts.map +1 -0
- package/dist/types/checkout/resume-state.d.ts +13 -0
- package/dist/types/checkout/resume-state.d.ts.map +1 -0
- package/dist/types/checkout/surplus-refund.d.ts +10 -0
- package/dist/types/checkout/surplus-refund.d.ts.map +1 -0
- package/dist/types/checkout/views/back.d.ts +2 -1
- package/dist/types/checkout/views/back.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/direct-details.d.ts +10 -1
- package/dist/types/checkout/views/crypto-intent/direct-details.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/methods.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/processing.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/success.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts.map +1 -1
- package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts.map +1 -1
- package/dist/types/checkout/views/failed.d.ts.map +1 -1
- package/dist/types/checkout/views/initial.d.ts +4 -0
- package/dist/types/checkout/views/initial.d.ts.map +1 -1
- package/dist/types/checkout/views/method-select.d.ts +2 -0
- package/dist/types/checkout/views/method-select.d.ts.map +1 -1
- package/dist/types/components/buttons/index.d.ts.map +1 -1
- package/dist/types/components/icons/clock.d.ts +6 -0
- package/dist/types/components/icons/clock.d.ts.map +1 -0
- package/dist/types/components/icons/edit.d.ts +6 -0
- package/dist/types/components/icons/edit.d.ts.map +1 -0
- package/dist/types/components/icons/index.d.ts +4 -0
- package/dist/types/components/icons/index.d.ts.map +1 -1
- package/dist/types/components/icons/log-out.d.ts +6 -0
- package/dist/types/components/icons/log-out.d.ts.map +1 -0
- package/dist/types/components/icons/send.d.ts +6 -0
- package/dist/types/components/icons/send.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/dist/types/components/modals/modal-with-views.d.ts +1 -0
- package/dist/types/components/modals/modal-with-views.d.ts.map +1 -1
- package/dist/types/components/modals/modal.d.ts.map +1 -1
- package/dist/types/components/modals/use-modal-with-views.d.ts.map +1 -1
- package/dist/types/components/quote-expiry/index.d.ts +2 -0
- package/dist/types/components/quote-expiry/index.d.ts.map +1 -0
- package/dist/types/components/quote-expiry/quote-expiry-countdown.d.ts +15 -0
- package/dist/types/components/quote-expiry/quote-expiry-countdown.d.ts.map +1 -0
- package/dist/types/components/quote-expiry/styles.d.ts +22 -0
- package/dist/types/components/quote-expiry/styles.d.ts.map +1 -0
- package/dist/types/components/quote-expiry/tiers.d.ts +10 -0
- package/dist/types/components/quote-expiry/tiers.d.ts.map +1 -0
- package/dist/types/components/wallet-selector/component.d.ts +1 -2
- package/dist/types/components/wallet-selector/component.d.ts.map +1 -1
- package/dist/types/components/wallet-selector/domain.d.ts +3 -2
- package/dist/types/components/wallet-selector/domain.d.ts.map +1 -1
- package/dist/types/components/wallet-selector/provider.d.ts +3 -3
- package/dist/types/components/wallet-selector/provider.d.ts.map +1 -1
- package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts +41 -5
- package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/integrations/lifi.d.ts.map +1 -1
- package/dist/types/refund/index.d.ts +82 -0
- package/dist/types/refund/index.d.ts.map +1 -0
- package/dist/types/state/checkout/payment-attempt.d.ts.map +1 -1
- package/dist/types/state/checkout/payment-lifecycle.d.ts +27 -10
- package/dist/types/state/checkout/payment-lifecycle.d.ts.map +1 -1
- package/dist/types/state/checkout/store.d.ts +35 -16
- package/dist/types/state/checkout/store.d.ts.map +1 -1
- package/dist/types/state/checkout/wallet-payment-options.d.ts +24 -0
- package/dist/types/state/checkout/wallet-payment-options.d.ts.map +1 -0
- package/dist/types/themes/default.d.ts.map +1 -1
- package/dist/types/themes/types.d.ts +11 -0
- package/dist/types/themes/types.d.ts.map +1 -1
- package/dist/types/utils/string.d.ts +1 -0
- package/dist/types/utils/string.d.ts.map +1 -1
- package/dist/types/utils/wallet-errors.d.ts +2 -0
- package/dist/types/utils/wallet-errors.d.ts.map +1 -0
- package/package.json +25 -18
- package/LICENSE +0 -21
|
@@ -1,70 +1,78 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useRef, useState } from "react";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
//@ts-expect-error import error
|
|
4
4
|
import { QRCode } from "react-qr-code";
|
|
5
|
-
import { styled } from "styled-components";
|
|
6
|
-
import { confirmPayment } from "../../../api/payments.js";
|
|
7
|
-
import { ClipboardAddIcon, ClipboardCheckIcon, StyledButton, Text, useModalWithView, } from "../../../components/index.js";
|
|
5
|
+
import { keyframes, styled } from "styled-components";
|
|
6
|
+
import { confirmPayment, getManualPaymentOptions, } from "../../../api/payments.js";
|
|
7
|
+
import { AlertCircleIcon, ClipboardAddIcon, ClipboardCheckIcon, EditIcon, QuoteExpiryCountdown, StyledButton, Text, useModalWithView, } from "../../../components/index.js";
|
|
8
8
|
import { useMintMoneyConfig } from "../../../context.js";
|
|
9
|
-
import {
|
|
9
|
+
import { getAttemptQuoteTiming, isAttemptStale, } from "../../../state/checkout/payment-lifecycle.js";
|
|
10
|
+
import { clearQuoteRefresh, configureManualQuoteRefresh, createManualDirectPaymentAttempt, refreshQuote, useCheckoutStore, } from "../../../state/checkout/store.js";
|
|
10
11
|
import { ModalViewContainer } from "../../container.js";
|
|
11
12
|
import { ModalBackButton } from "../back.js";
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO = 0.25;
|
|
14
|
+
const QRCard = styled.div `
|
|
15
|
+
background: #ffffff;
|
|
16
|
+
border: 1px solid #111827;
|
|
17
|
+
border-radius: 10px;
|
|
18
|
+
padding: 10px;
|
|
16
19
|
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
17
21
|
align-items: center;
|
|
18
|
-
|
|
22
|
+
justify-content: center;
|
|
23
|
+
margin: 8px 0 0;
|
|
19
24
|
`;
|
|
20
|
-
const
|
|
21
|
-
background:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const PaymentInstructionCard = styled.div `
|
|
26
|
+
background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
|
|
27
|
+
border: 1px solid #eef2f6;
|
|
28
|
+
border-radius: 18px;
|
|
29
|
+
padding: 18px;
|
|
30
|
+
display: flex;
|
|
31
|
+
flex-direction: column;
|
|
32
|
+
gap: 16px;
|
|
33
|
+
box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
|
|
34
|
+
`;
|
|
35
|
+
const PaymentInstructionHeader = styled.div `
|
|
26
36
|
display: flex;
|
|
27
37
|
align-items: center;
|
|
28
|
-
justify-content:
|
|
38
|
+
justify-content: space-between;
|
|
39
|
+
gap: 8px;
|
|
40
|
+
`;
|
|
41
|
+
const PaymentInstructionLabel = styled.div `
|
|
29
42
|
font-size: 12px;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
line-height: 1.3;
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
color: ${({ theme }) => theme.font.color.tertiary};
|
|
33
46
|
`;
|
|
34
|
-
const
|
|
35
|
-
font-size:
|
|
36
|
-
|
|
47
|
+
const PaymentInstructionValue = styled.div `
|
|
48
|
+
font-size: 16px;
|
|
49
|
+
line-height: 1.45;
|
|
50
|
+
font-weight: 700;
|
|
37
51
|
color: ${({ theme }) => theme.font.color.primary};
|
|
38
|
-
|
|
52
|
+
min-width: 0;
|
|
53
|
+
overflow-wrap: anywhere;
|
|
39
54
|
`;
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
padding: 16px 12px;
|
|
44
|
-
display: flex;
|
|
45
|
-
flex-direction: column;
|
|
46
|
-
align-items: center;
|
|
47
|
-
margin: 8px 0;
|
|
55
|
+
const PaymentInstructionDivider = styled.div `
|
|
56
|
+
height: 1px;
|
|
57
|
+
background: #eef2f6;
|
|
48
58
|
`;
|
|
49
59
|
const InfoRow = styled.div `
|
|
50
60
|
display: flex;
|
|
51
61
|
align-items: center;
|
|
52
|
-
background:
|
|
53
|
-
border-radius:
|
|
54
|
-
padding:
|
|
55
|
-
margin:
|
|
62
|
+
background: transparent;
|
|
63
|
+
border-radius: 8px;
|
|
64
|
+
padding: 0;
|
|
65
|
+
margin: 0;
|
|
56
66
|
cursor: pointer;
|
|
57
67
|
transition: all 0.2s ease-in-out;
|
|
58
|
-
border:
|
|
68
|
+
border: 0;
|
|
59
69
|
|
|
60
70
|
&:hover {
|
|
61
|
-
|
|
71
|
+
opacity: 0.78;
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
${({ isCopied }) => isCopied &&
|
|
65
75
|
`
|
|
66
|
-
border-color: #10b981;
|
|
67
|
-
background: #f0fdf4;
|
|
68
76
|
animation: copySuccess 0.6s ease-in-out;
|
|
69
77
|
`}
|
|
70
78
|
|
|
@@ -80,13 +88,20 @@ const InfoRow = styled.div `
|
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
`;
|
|
91
|
+
const AddressInfoRow = styled(InfoRow) `
|
|
92
|
+
align-items: flex-start;
|
|
93
|
+
width: 100%;
|
|
94
|
+
`;
|
|
83
95
|
const AddressText = styled.div `
|
|
84
96
|
font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
|
|
85
|
-
font-size:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
97
|
+
font-size: 16px;
|
|
98
|
+
line-height: 1.45;
|
|
99
|
+
font-weight: 700;
|
|
100
|
+
color: ${({ theme }) => theme.font.color.primary};
|
|
101
|
+
width: 100%;
|
|
102
|
+
flex: 1 1 auto;
|
|
103
|
+
min-width: 0;
|
|
104
|
+
overflow-wrap: anywhere;
|
|
90
105
|
`;
|
|
91
106
|
const CopyButton = styled.button `
|
|
92
107
|
display: flex;
|
|
@@ -126,25 +141,344 @@ const CopyButton = styled.button `
|
|
|
126
141
|
}
|
|
127
142
|
}
|
|
128
143
|
`;
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
border
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
const IconButton = styled.button `
|
|
145
|
+
width: 28px;
|
|
146
|
+
height: 28px;
|
|
147
|
+
border: 0;
|
|
148
|
+
border-radius: 8px;
|
|
149
|
+
background: ${({ $active }) => ($active ? "#e0f2fe" : "transparent")};
|
|
150
|
+
color: ${({ $active }) => ($active ? "#0369a1" : "#374151")};
|
|
151
|
+
display: inline-flex;
|
|
152
|
+
align-items: center;
|
|
153
|
+
justify-content: center;
|
|
154
|
+
padding: 0;
|
|
155
|
+
cursor: pointer;
|
|
156
|
+
transition:
|
|
157
|
+
background 0.15s ease,
|
|
158
|
+
color 0.15s ease;
|
|
159
|
+
|
|
160
|
+
&:hover,
|
|
161
|
+
&:focus-visible {
|
|
162
|
+
background: #eef2f7;
|
|
163
|
+
outline: none;
|
|
164
|
+
}
|
|
165
|
+
`;
|
|
166
|
+
const CopyAddressCta = styled.button `
|
|
167
|
+
width: 100%;
|
|
168
|
+
min-height: 48px;
|
|
169
|
+
border: 0;
|
|
170
|
+
border-radius: 8px;
|
|
171
|
+
background: ${({ isCopied }) => (isCopied ? "#ecfdf5" : "#f1f3fb")};
|
|
172
|
+
color: ${({ isCopied }) => (isCopied ? "#047857" : "#111827")};
|
|
173
|
+
display: inline-flex;
|
|
174
|
+
align-items: center;
|
|
175
|
+
justify-content: center;
|
|
176
|
+
gap: 8px;
|
|
177
|
+
padding: 0 14px;
|
|
178
|
+
font-size: 15px;
|
|
179
|
+
line-height: 1.2;
|
|
180
|
+
font-weight: 700;
|
|
181
|
+
cursor: pointer;
|
|
182
|
+
transition:
|
|
183
|
+
background 0.15s ease,
|
|
184
|
+
color 0.15s ease,
|
|
185
|
+
transform 0.15s ease;
|
|
186
|
+
|
|
187
|
+
&:hover,
|
|
188
|
+
&:focus-visible {
|
|
189
|
+
background: ${({ isCopied }) => (isCopied ? "#dcfce7" : "#e8edf7")};
|
|
190
|
+
outline: none;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
&:active {
|
|
194
|
+
transform: translateY(1px);
|
|
195
|
+
}
|
|
136
196
|
`;
|
|
137
|
-
const
|
|
138
|
-
|
|
197
|
+
const OptionList = styled.div `
|
|
198
|
+
display: flex;
|
|
199
|
+
flex-direction: column;
|
|
200
|
+
gap: 8px;
|
|
201
|
+
min-height: 0;
|
|
202
|
+
max-height: min(34vh, 300px);
|
|
203
|
+
overflow-y: auto;
|
|
204
|
+
overscroll-behavior: contain;
|
|
205
|
+
scrollbar-width: none;
|
|
206
|
+
|
|
207
|
+
&::-webkit-scrollbar {
|
|
208
|
+
display: none;
|
|
209
|
+
}
|
|
210
|
+
`;
|
|
211
|
+
const SelectionSectionLabel = styled.div `
|
|
212
|
+
font-size: 12px;
|
|
213
|
+
font-weight: 600;
|
|
214
|
+
line-height: 1.3;
|
|
215
|
+
color: #94a3b8;
|
|
216
|
+
padding: 0 2px;
|
|
217
|
+
`;
|
|
218
|
+
const SelectionRow = styled.button `
|
|
219
|
+
width: 100%;
|
|
220
|
+
min-height: 72px;
|
|
221
|
+
border: 1px solid #eef2f6;
|
|
139
222
|
border-radius: 16px;
|
|
140
|
-
padding: 14px;
|
|
141
223
|
background: #ffffff;
|
|
224
|
+
display: flex;
|
|
225
|
+
align-items: center;
|
|
226
|
+
justify-content: space-between;
|
|
227
|
+
gap: 12px;
|
|
228
|
+
padding: 12px 14px;
|
|
229
|
+
cursor: pointer;
|
|
230
|
+
text-align: left;
|
|
231
|
+
color: inherit;
|
|
232
|
+
transition:
|
|
233
|
+
border-color 140ms ease,
|
|
234
|
+
box-shadow 140ms ease,
|
|
235
|
+
transform 140ms ease,
|
|
236
|
+
background-color 140ms ease;
|
|
237
|
+
|
|
238
|
+
&:hover,
|
|
239
|
+
&:focus-visible {
|
|
240
|
+
border-color: #cdd9e3;
|
|
241
|
+
box-shadow: 0 6px 14px rgba(15, 23, 42, 0.05);
|
|
242
|
+
transform: translateY(-1px);
|
|
243
|
+
outline: none;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
&:disabled {
|
|
247
|
+
cursor: not-allowed;
|
|
248
|
+
opacity: 0.65;
|
|
249
|
+
}
|
|
250
|
+
`;
|
|
251
|
+
const SelectionRowLeft = styled.div `
|
|
252
|
+
display: flex;
|
|
253
|
+
align-items: center;
|
|
254
|
+
gap: 12px;
|
|
255
|
+
min-width: 0;
|
|
256
|
+
`;
|
|
257
|
+
const SelectionIcon = styled.div `
|
|
258
|
+
width: 40px;
|
|
259
|
+
height: 40px;
|
|
260
|
+
border-radius: 999px;
|
|
261
|
+
flex-shrink: 0;
|
|
262
|
+
display: inline-flex;
|
|
263
|
+
align-items: center;
|
|
264
|
+
justify-content: center;
|
|
265
|
+
font-size: 11px;
|
|
266
|
+
font-weight: 700;
|
|
267
|
+
color: #1f2937;
|
|
268
|
+
background: #eef2f7;
|
|
269
|
+
background-image: ${({ $iconUrl }) => $iconUrl ? `url(${$iconUrl})` : "none"};
|
|
270
|
+
background-size: cover;
|
|
271
|
+
background-position: center;
|
|
272
|
+
background-repeat: no-repeat;
|
|
273
|
+
overflow: hidden;
|
|
274
|
+
`;
|
|
275
|
+
const SelectionText = styled.div `
|
|
276
|
+
display: flex;
|
|
277
|
+
flex-direction: column;
|
|
278
|
+
gap: 2px;
|
|
279
|
+
min-width: 0;
|
|
280
|
+
`;
|
|
281
|
+
const SelectionTitle = styled.span `
|
|
282
|
+
font-size: 14px;
|
|
283
|
+
line-height: 1.3;
|
|
284
|
+
font-weight: 600;
|
|
285
|
+
color: #111827;
|
|
286
|
+
overflow: hidden;
|
|
287
|
+
text-overflow: ellipsis;
|
|
288
|
+
white-space: nowrap;
|
|
289
|
+
`;
|
|
290
|
+
const SelectionSubtitle = styled.span `
|
|
291
|
+
font-size: 12px;
|
|
292
|
+
line-height: 1.3;
|
|
293
|
+
color: #6b7280;
|
|
294
|
+
overflow: hidden;
|
|
295
|
+
text-overflow: ellipsis;
|
|
296
|
+
white-space: nowrap;
|
|
297
|
+
`;
|
|
298
|
+
const SelectionMeta = styled.span `
|
|
299
|
+
font-size: 12px;
|
|
300
|
+
line-height: 1.3;
|
|
301
|
+
color: #7c83a5;
|
|
302
|
+
white-space: nowrap;
|
|
303
|
+
flex-shrink: 0;
|
|
304
|
+
`;
|
|
305
|
+
const SelectionBadge = styled.span `
|
|
306
|
+
display: inline-flex;
|
|
307
|
+
align-items: center;
|
|
308
|
+
border-radius: 999px;
|
|
309
|
+
gap: 4px;
|
|
310
|
+
background: #ecfdf5;
|
|
311
|
+
color: #047857;
|
|
312
|
+
font-size: 11px;
|
|
313
|
+
font-weight: 600;
|
|
314
|
+
line-height: 1;
|
|
315
|
+
padding: 4px 8px;
|
|
316
|
+
white-space: nowrap;
|
|
317
|
+
flex-shrink: 0;
|
|
318
|
+
`;
|
|
319
|
+
const SelectedSummary = styled.div `
|
|
320
|
+
border: 1px solid #dbe2ea;
|
|
321
|
+
border-radius: 14px;
|
|
322
|
+
background: #ffffff;
|
|
323
|
+
overflow: hidden;
|
|
324
|
+
box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
|
|
325
|
+
`;
|
|
326
|
+
const SelectedSummaryToggle = styled.button `
|
|
327
|
+
width: 100%;
|
|
328
|
+
border: 0;
|
|
329
|
+
background: transparent;
|
|
330
|
+
color: inherit;
|
|
331
|
+
padding: 12px;
|
|
332
|
+
display: flex;
|
|
333
|
+
align-items: center;
|
|
334
|
+
justify-content: space-between;
|
|
335
|
+
gap: 12px;
|
|
336
|
+
cursor: pointer;
|
|
337
|
+
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
|
+
}
|
|
142
475
|
`;
|
|
143
476
|
const OptionHeader = styled.div `
|
|
144
477
|
display: flex;
|
|
145
478
|
align-items: center;
|
|
146
479
|
justify-content: space-between;
|
|
147
480
|
gap: 12px;
|
|
481
|
+
min-width: 0;
|
|
148
482
|
`;
|
|
149
483
|
const OptionHeaderLeft = styled.div `
|
|
150
484
|
display: flex;
|
|
@@ -203,32 +537,124 @@ const OptionIdentity = styled.div `
|
|
|
203
537
|
min-width: 0;
|
|
204
538
|
flex: 1;
|
|
205
539
|
`;
|
|
206
|
-
const
|
|
540
|
+
const SetupActions = styled.div `
|
|
207
541
|
display: flex;
|
|
208
542
|
flex-direction: column;
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
flex-shrink: 0;
|
|
543
|
+
gap: 10px;
|
|
544
|
+
margin-top: 8px;
|
|
212
545
|
`;
|
|
213
|
-
const
|
|
214
|
-
display:
|
|
546
|
+
const PaymentDetailsStack = styled.div `
|
|
547
|
+
display: flex;
|
|
548
|
+
flex-direction: column;
|
|
549
|
+
gap: 12px;
|
|
550
|
+
margin: 8px 0;
|
|
551
|
+
text-align: left;
|
|
552
|
+
`;
|
|
553
|
+
const ManualPaymentLayout = styled(ModalViewContainer) `
|
|
554
|
+
min-height: 0;
|
|
555
|
+
gap: 0;
|
|
556
|
+
`;
|
|
557
|
+
const ManualPaymentScrollArea = styled.div `
|
|
558
|
+
min-height: 0;
|
|
559
|
+
flex: 1 1 auto;
|
|
560
|
+
overflow-y: auto;
|
|
561
|
+
overflow-x: hidden;
|
|
562
|
+
padding-bottom: 16px;
|
|
563
|
+
scrollbar-width: none;
|
|
564
|
+
|
|
565
|
+
&::-webkit-scrollbar {
|
|
566
|
+
width: 0;
|
|
567
|
+
height: 0;
|
|
568
|
+
}
|
|
569
|
+
`;
|
|
570
|
+
const ManualPaymentActions = styled.div `
|
|
571
|
+
flex: 0 0 auto;
|
|
572
|
+
display: flex;
|
|
573
|
+
flex-direction: column;
|
|
574
|
+
gap: 10px;
|
|
575
|
+
padding-top: 14px;
|
|
576
|
+
background: #ffffff;
|
|
577
|
+
`;
|
|
578
|
+
const ErrorCard = styled.div `
|
|
579
|
+
background: #fef2f2;
|
|
580
|
+
border: 1px solid #fecaca;
|
|
581
|
+
border-radius: 12px;
|
|
582
|
+
padding: 16px;
|
|
583
|
+
margin: 8px 0;
|
|
584
|
+
text-align: center;
|
|
585
|
+
display: flex;
|
|
586
|
+
flex-direction: column;
|
|
587
|
+
align-items: center;
|
|
588
|
+
gap: 8px;
|
|
589
|
+
`;
|
|
590
|
+
const spin = keyframes `
|
|
591
|
+
to { transform: rotate(360deg); }
|
|
592
|
+
`;
|
|
593
|
+
const RefreshCard = styled.div `
|
|
594
|
+
background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
|
|
595
|
+
border: 1px solid #e8eef3;
|
|
596
|
+
border-radius: 14px;
|
|
597
|
+
padding: 18px;
|
|
598
|
+
margin: 8px 0;
|
|
599
|
+
display: flex;
|
|
215
600
|
align-items: center;
|
|
601
|
+
gap: 12px;
|
|
602
|
+
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
|
|
603
|
+
`;
|
|
604
|
+
const RefreshSpinner = styled.div `
|
|
605
|
+
width: 30px;
|
|
606
|
+
height: 30px;
|
|
216
607
|
border-radius: 999px;
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
font-weight: 600;
|
|
222
|
-
line-height: 1;
|
|
223
|
-
padding: 6px 9px;
|
|
224
|
-
white-space: nowrap;
|
|
608
|
+
border: 3px solid #d1fae5;
|
|
609
|
+
border-top-color: #10b981;
|
|
610
|
+
flex-shrink: 0;
|
|
611
|
+
animation: ${spin} 0.8s linear infinite;
|
|
225
612
|
`;
|
|
226
|
-
const
|
|
613
|
+
const RefreshTitle = styled.div `
|
|
227
614
|
display: flex;
|
|
228
615
|
flex-direction: column;
|
|
229
|
-
gap:
|
|
230
|
-
|
|
616
|
+
gap: 2px;
|
|
617
|
+
min-width: 0;
|
|
618
|
+
`;
|
|
619
|
+
const RefundWalletPanel = styled.div `
|
|
620
|
+
display: flex;
|
|
621
|
+
flex-direction: column;
|
|
622
|
+
gap: 6px;
|
|
623
|
+
text-align: left;
|
|
624
|
+
`;
|
|
625
|
+
const RefundWalletInput = styled.input `
|
|
626
|
+
width: 100%;
|
|
627
|
+
border: 1px solid #d1d5db;
|
|
628
|
+
border-radius: 8px;
|
|
629
|
+
padding: 8px 10px;
|
|
630
|
+
font-size: 13px;
|
|
631
|
+
line-height: 1.4;
|
|
632
|
+
color: #111827;
|
|
633
|
+
background: #ffffff;
|
|
634
|
+
box-sizing: border-box;
|
|
635
|
+
|
|
636
|
+
&:focus {
|
|
637
|
+
outline: 2px solid #93c5fd;
|
|
638
|
+
border-color: #3b82f6;
|
|
639
|
+
}
|
|
640
|
+
`;
|
|
641
|
+
const RefundCopy = styled.div `
|
|
642
|
+
font-size: 11px;
|
|
643
|
+
line-height: 1.35;
|
|
644
|
+
color: #6b7280;
|
|
645
|
+
`;
|
|
646
|
+
const RefundError = styled.div `
|
|
647
|
+
font-size: 12px;
|
|
648
|
+
line-height: 1.4;
|
|
649
|
+
color: #b91c1c;
|
|
231
650
|
`;
|
|
651
|
+
const isEvmAddress = (value) => /^0x[0-9a-fA-F]{40}$/.test(value);
|
|
652
|
+
const isTronAddress = (value) => /^T[1-9A-HJ-NP-Za-km-z]{33}$/.test(value) ||
|
|
653
|
+
/^41[0-9a-fA-F]{40}$/.test(value);
|
|
654
|
+
const isValidRefundAddressForSource = (value, source) => source.chain.toLowerCase().startsWith("tron:")
|
|
655
|
+
? isTronAddress(value)
|
|
656
|
+
: isEvmAddress(value);
|
|
657
|
+
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" })] }));
|
|
232
658
|
const getMonogram = (value) => {
|
|
233
659
|
const parts = value
|
|
234
660
|
.split(/\s+/)
|
|
@@ -252,28 +678,260 @@ const getChainAbbreviation = (chainName) => {
|
|
|
252
678
|
};
|
|
253
679
|
const formatManualPaymentAmount = (amount, currency) => {
|
|
254
680
|
const amountText = String(amount);
|
|
255
|
-
|
|
256
|
-
|
|
681
|
+
return `${amountText} ${currency}`;
|
|
682
|
+
};
|
|
683
|
+
const shouldUseRawManualAmount = (chainName, currency) => {
|
|
684
|
+
const normalizedChain = chainName.toLowerCase();
|
|
685
|
+
const normalizedCurrency = currency.toLowerCase();
|
|
686
|
+
return (normalizedChain.includes("sepolia") ||
|
|
687
|
+
normalizedChain.includes("testnet") ||
|
|
688
|
+
normalizedCurrency.includes("mock"));
|
|
689
|
+
};
|
|
690
|
+
const isTestnetOrMockCurrency = (currency) => shouldUseRawManualAmount(currency.chain_name, currency.asset_name) ||
|
|
691
|
+
shouldUseRawManualAmount(currency.chain, currency.asset);
|
|
692
|
+
const shouldLoadManualPaymentOptions = (currency) => !currency.chain.toLowerCase().startsWith("tron:") &&
|
|
693
|
+
!isTestnetOrMockCurrency(currency);
|
|
694
|
+
const sourceKey = (source) => `${source.chain}__${source.asset}`;
|
|
695
|
+
const normalizeOptionalAddress = (address) => address?.trim().toLowerCase() || null;
|
|
696
|
+
const uniqueSourceOptions = (settlementCurrency, configuredSources) => {
|
|
697
|
+
const options = [settlementCurrency, ...(configuredSources ?? [])];
|
|
698
|
+
const seen = new Set();
|
|
699
|
+
return options.filter((option) => {
|
|
700
|
+
const key = sourceKey(option);
|
|
701
|
+
if (seen.has(key))
|
|
702
|
+
return false;
|
|
703
|
+
seen.add(key);
|
|
704
|
+
return true;
|
|
705
|
+
});
|
|
706
|
+
};
|
|
707
|
+
const getManualPaymentAttemptMode = (source, settlementCurrency) => source.asset.toLowerCase() === settlementCurrency.asset.toLowerCase() &&
|
|
708
|
+
source.chain.toLowerCase() === settlementCurrency.chain.toLowerCase()
|
|
709
|
+
? undefined
|
|
710
|
+
: "relay_deposit";
|
|
711
|
+
const manualPaymentOptionToCurrency = (option) => ({
|
|
712
|
+
chain: option.from_chain.caip2,
|
|
713
|
+
asset: option.from_token.caip21,
|
|
714
|
+
chain_name: option.from_chain.name,
|
|
715
|
+
asset_name: option.from_token.name,
|
|
716
|
+
asset_id: option.id,
|
|
717
|
+
logo_url: option.from_token.logo_url,
|
|
718
|
+
chain_logo_url: option.from_chain.logo_url,
|
|
719
|
+
});
|
|
720
|
+
const manualPaymentOptionKey = (option) => `${option.from_chain.caip2}__${option.from_token.caip21}`;
|
|
721
|
+
const manualOptionLookupKey = (source) => `${source.chain}__${source.asset}`.toLowerCase();
|
|
722
|
+
const getSourceTokenSymbol = (source, manualOptions) => manualOptions.find((option) => manualPaymentOptionKey(option).toLowerCase() ===
|
|
723
|
+
manualOptionLookupKey(source))?.from_token.symbol ?? source.asset_name;
|
|
724
|
+
const getSourceTokenGroupKey = (source, manualOptions) => getSourceTokenSymbol(source, manualOptions).toLowerCase();
|
|
725
|
+
const uniqueSourceTokens = (options, manualOptions) => {
|
|
726
|
+
const seen = new Set();
|
|
727
|
+
return options.filter((option) => {
|
|
728
|
+
const key = getSourceTokenGroupKey(option, manualOptions);
|
|
729
|
+
if (seen.has(key))
|
|
730
|
+
return false;
|
|
731
|
+
seen.add(key);
|
|
732
|
+
return true;
|
|
733
|
+
});
|
|
734
|
+
};
|
|
735
|
+
const uniqueSourceChains = (options) => {
|
|
736
|
+
const seen = new Set();
|
|
737
|
+
return options.filter((option) => {
|
|
738
|
+
if (seen.has(option.chain))
|
|
739
|
+
return false;
|
|
740
|
+
seen.add(option.chain);
|
|
741
|
+
return true;
|
|
742
|
+
});
|
|
743
|
+
};
|
|
744
|
+
const getManualInstructionSource = (instructions) => {
|
|
745
|
+
if (!instructions)
|
|
746
|
+
return null;
|
|
747
|
+
if ("source_chain" in instructions &&
|
|
748
|
+
"source_token" in instructions &&
|
|
749
|
+
typeof instructions.source_chain === "string" &&
|
|
750
|
+
typeof instructions.source_token === "string") {
|
|
751
|
+
return {
|
|
752
|
+
chain: instructions.source_chain,
|
|
753
|
+
token: instructions.source_token,
|
|
754
|
+
};
|
|
257
755
|
}
|
|
258
|
-
|
|
259
|
-
|
|
756
|
+
const tokenTransferInstructions = instructions;
|
|
757
|
+
if (typeof tokenTransferInstructions.chain === "string" &&
|
|
758
|
+
typeof tokenTransferInstructions.token === "string") {
|
|
759
|
+
return {
|
|
760
|
+
chain: tokenTransferInstructions.chain,
|
|
761
|
+
token: tokenTransferInstructions.token,
|
|
762
|
+
};
|
|
260
763
|
}
|
|
261
|
-
return
|
|
764
|
+
return null;
|
|
765
|
+
};
|
|
766
|
+
const manualAttemptKey = (attempt) => {
|
|
767
|
+
const instructions = attempt?.payment_instructions;
|
|
768
|
+
if (!instructions)
|
|
769
|
+
return null;
|
|
770
|
+
const instructionSource = getManualInstructionSource(instructions);
|
|
771
|
+
const requestId = "request_id" in instructions ? instructions.request_id : null;
|
|
772
|
+
return [
|
|
773
|
+
requestId,
|
|
774
|
+
instructionSource?.chain,
|
|
775
|
+
instructionSource?.token,
|
|
776
|
+
instructions.payment_address ?? attempt.destination_address,
|
|
777
|
+
]
|
|
778
|
+
.filter(Boolean)
|
|
779
|
+
.join(":");
|
|
262
780
|
};
|
|
263
781
|
const CryptoIntentDirectDetailsViewContent = () => {
|
|
264
782
|
const modalRef = useRef(null);
|
|
783
|
+
const refundWalletInputRef = useRef(null);
|
|
784
|
+
const dismissedAttemptKeyRef = useRef(null);
|
|
265
785
|
const { goToView } = useModalWithView();
|
|
266
|
-
const { cryptoPaymentAttempt, cryptoCurrency, payment,
|
|
786
|
+
const { cryptoPaymentAttempt, cryptoCurrency, payment, quote } = useCheckoutStore();
|
|
267
787
|
const config = useMintMoneyConfig();
|
|
788
|
+
const fallbackSourceOptions = useMemo(() => cryptoCurrency
|
|
789
|
+
? uniqueSourceOptions(cryptoCurrency, config.cryptoCheckoutConfig.directPaymentSources)
|
|
790
|
+
: [], [cryptoCurrency, config.cryptoCheckoutConfig.directPaymentSources]);
|
|
791
|
+
const [manualPaymentOptions, setManualPaymentOptions] = useState([]);
|
|
792
|
+
const [manualPaymentOptionsStatus, setManualPaymentOptionsStatus] = useState("idle");
|
|
793
|
+
const manualOptionSources = useMemo(() => manualPaymentOptions.map(manualPaymentOptionToCurrency), [manualPaymentOptions]);
|
|
794
|
+
const sourceOptions = useMemo(() => {
|
|
795
|
+
if (cryptoCurrency &&
|
|
796
|
+
manualPaymentOptionsStatus === "ready" &&
|
|
797
|
+
manualOptionSources.length > 0) {
|
|
798
|
+
return uniqueSourceOptions(cryptoCurrency, manualOptionSources);
|
|
799
|
+
}
|
|
800
|
+
return fallbackSourceOptions;
|
|
801
|
+
}, [
|
|
802
|
+
cryptoCurrency,
|
|
803
|
+
fallbackSourceOptions,
|
|
804
|
+
manualOptionSources,
|
|
805
|
+
manualPaymentOptionsStatus,
|
|
806
|
+
]);
|
|
268
807
|
const [copiedAddress, setCopiedAddress] = useState(false);
|
|
808
|
+
const [copiedAmount, setCopiedAmount] = useState(false);
|
|
269
809
|
const [hasAcknowledged, setHasAcknowledged] = useState(false);
|
|
270
|
-
const
|
|
810
|
+
const [refundWallet, setRefundWallet] = useState("");
|
|
811
|
+
const [selectedSourceKey, setSelectedSourceKey] = useState(sourceOptions[0] ? sourceKey(sourceOptions[0]) : "");
|
|
812
|
+
const [selectedTokenKey, setSelectedTokenKey] = useState("");
|
|
813
|
+
const [manualSetupStep, setManualSetupStep] = useState("token");
|
|
814
|
+
const [paymentDetailsExpanded, setPaymentDetailsExpanded] = useState(false);
|
|
815
|
+
const [refundDetailsExpanded, setRefundDetailsExpanded] = useState(false);
|
|
816
|
+
const [showQrCode, setShowQrCode] = useState(false);
|
|
817
|
+
const [refundWalletError, setRefundWalletError] = useState(null);
|
|
818
|
+
const [isCreatingAttempt, setIsCreatingAttempt] = useState(false);
|
|
819
|
+
const [manualQuoteTick, setManualQuoteTick] = useState(0);
|
|
820
|
+
const attemptIsStale = isAttemptStale(cryptoPaymentAttempt);
|
|
821
|
+
const attemptQuoteTiming = useMemo(() => getAttemptQuoteTiming(cryptoPaymentAttempt), [cryptoPaymentAttempt, manualQuoteTick]);
|
|
822
|
+
const countdownRemainingMs = quote.remainingMs ?? attemptQuoteTiming.remainingMs;
|
|
823
|
+
const countdownTotalDurationMs = quote.totalDurationMs ?? attemptQuoteTiming.totalDurationMs;
|
|
824
|
+
const setAcknowledgedWithTransition = (value) => {
|
|
825
|
+
if (document.startViewTransition) {
|
|
826
|
+
document.startViewTransition(() => {
|
|
827
|
+
setHasAcknowledged(value);
|
|
828
|
+
});
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
setHasAcknowledged(value);
|
|
832
|
+
};
|
|
833
|
+
useEffect(() => {
|
|
834
|
+
if (!hasAcknowledged) {
|
|
835
|
+
clearQuoteRefresh();
|
|
836
|
+
return undefined;
|
|
837
|
+
}
|
|
838
|
+
configureManualQuoteRefresh();
|
|
839
|
+
return () => {
|
|
840
|
+
clearQuoteRefresh();
|
|
841
|
+
};
|
|
842
|
+
}, [hasAcknowledged]);
|
|
843
|
+
useEffect(() => {
|
|
844
|
+
if (!hasAcknowledged || !cryptoPaymentAttempt)
|
|
845
|
+
return;
|
|
846
|
+
configureManualQuoteRefresh();
|
|
847
|
+
}, [cryptoPaymentAttempt, hasAcknowledged]);
|
|
848
|
+
useEffect(() => {
|
|
849
|
+
if (!hasAcknowledged ||
|
|
850
|
+
quote.remainingMs !== null ||
|
|
851
|
+
attemptQuoteTiming.expiresAt === null) {
|
|
852
|
+
return undefined;
|
|
853
|
+
}
|
|
854
|
+
const interval = window.setInterval(() => {
|
|
855
|
+
setManualQuoteTick((tick) => tick + 1);
|
|
856
|
+
}, 1000);
|
|
857
|
+
return () => {
|
|
858
|
+
window.clearInterval(interval);
|
|
859
|
+
};
|
|
860
|
+
}, [attemptQuoteTiming.expiresAt, hasAcknowledged, quote.remainingMs]);
|
|
271
861
|
useEffect(() => {
|
|
272
|
-
|
|
862
|
+
if (!payment?.id ||
|
|
863
|
+
!cryptoCurrency ||
|
|
864
|
+
!shouldLoadManualPaymentOptions(cryptoCurrency)) {
|
|
865
|
+
setManualPaymentOptions([]);
|
|
866
|
+
setManualPaymentOptionsStatus("idle");
|
|
867
|
+
return undefined;
|
|
868
|
+
}
|
|
869
|
+
let cancelled = false;
|
|
870
|
+
setManualPaymentOptionsStatus("loading");
|
|
871
|
+
getManualPaymentOptions(payment.id)
|
|
872
|
+
.then((options) => {
|
|
873
|
+
if (cancelled)
|
|
874
|
+
return;
|
|
875
|
+
setManualPaymentOptions(options);
|
|
876
|
+
setManualPaymentOptionsStatus("ready");
|
|
877
|
+
})
|
|
878
|
+
.catch((error) => {
|
|
879
|
+
if (cancelled)
|
|
880
|
+
return;
|
|
881
|
+
console.error("Failed to load manual payment options:", error);
|
|
882
|
+
setManualPaymentOptions([]);
|
|
883
|
+
setManualPaymentOptionsStatus("failed");
|
|
884
|
+
});
|
|
273
885
|
return () => {
|
|
274
|
-
|
|
886
|
+
cancelled = true;
|
|
275
887
|
};
|
|
276
|
-
}, []);
|
|
888
|
+
}, [cryptoCurrency, payment?.id]);
|
|
889
|
+
useEffect(() => {
|
|
890
|
+
const selectedSourceIsAvailable = sourceOptions.some((option) => sourceKey(option) === selectedSourceKey);
|
|
891
|
+
if (!selectedSourceIsAvailable && sourceOptions[0]) {
|
|
892
|
+
setSelectedSourceKey(sourceKey(sourceOptions[0]));
|
|
893
|
+
}
|
|
894
|
+
}, [selectedSourceKey, sourceOptions]);
|
|
895
|
+
useEffect(() => {
|
|
896
|
+
const currentSource = sourceOptions.find((option) => sourceKey(option) === selectedSourceKey);
|
|
897
|
+
const nextTokenKey = currentSource
|
|
898
|
+
? getSourceTokenGroupKey(currentSource, manualPaymentOptions)
|
|
899
|
+
: "";
|
|
900
|
+
const selectedTokenIsAvailable = sourceOptions.some((option) => getSourceTokenGroupKey(option, manualPaymentOptions) ===
|
|
901
|
+
selectedTokenKey);
|
|
902
|
+
if (nextTokenKey && (!selectedTokenKey || !selectedTokenIsAvailable)) {
|
|
903
|
+
setSelectedTokenKey(nextTokenKey);
|
|
904
|
+
}
|
|
905
|
+
}, [
|
|
906
|
+
manualPaymentOptions,
|
|
907
|
+
selectedSourceKey,
|
|
908
|
+
selectedTokenKey,
|
|
909
|
+
sourceOptions,
|
|
910
|
+
]);
|
|
911
|
+
useEffect(() => {
|
|
912
|
+
if (!hasAcknowledged)
|
|
913
|
+
return;
|
|
914
|
+
const instructions = cryptoPaymentAttempt?.payment_instructions;
|
|
915
|
+
if (!instructions)
|
|
916
|
+
return;
|
|
917
|
+
const attemptKey = manualAttemptKey(cryptoPaymentAttempt);
|
|
918
|
+
if (!attemptKey || dismissedAttemptKeyRef.current === attemptKey)
|
|
919
|
+
return;
|
|
920
|
+
const instructionSource = getManualInstructionSource(instructions);
|
|
921
|
+
if (!instructionSource)
|
|
922
|
+
return;
|
|
923
|
+
const attemptSource = sourceOptions.find((option) => option.asset.toLowerCase() === instructionSource.token.toLowerCase() &&
|
|
924
|
+
option.chain.toLowerCase() === instructionSource.chain.toLowerCase());
|
|
925
|
+
if (attemptSource) {
|
|
926
|
+
setSelectedSourceKey(sourceKey(attemptSource));
|
|
927
|
+
}
|
|
928
|
+
setHasAcknowledged(true);
|
|
929
|
+
}, [
|
|
930
|
+
cryptoPaymentAttempt,
|
|
931
|
+
cryptoPaymentAttempt?.payment_instructions,
|
|
932
|
+
hasAcknowledged,
|
|
933
|
+
sourceOptions,
|
|
934
|
+
]);
|
|
277
935
|
const handleConfirm = async () => {
|
|
278
936
|
if (!payment?.id) {
|
|
279
937
|
goToView("failed", { reason: "confirm_payment" });
|
|
@@ -288,19 +946,166 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
288
946
|
goToView("failed", { reason: "confirm_payment" });
|
|
289
947
|
}
|
|
290
948
|
};
|
|
291
|
-
|
|
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
|
+
if (!cryptoCurrency) {
|
|
292
960
|
return null;
|
|
293
961
|
}
|
|
294
|
-
|
|
295
|
-
|
|
962
|
+
// Action needed: the quote refresh failed. No funds have been sent under a
|
|
963
|
+
// stale address, so the recovery is simply to fetch a fresh amount again.
|
|
964
|
+
if (quote.status === "failed") {
|
|
965
|
+
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsxs(ErrorCard, { children: [_jsx(AlertCircleIcon, { size: 28, color: "#ef4444" }), _jsx(Text, { size: "base", weight: "medium", color: config.theme.font.color.primary, children: "Something went wrong" }), _jsx(Text, { size: "sm", color: config.theme.font.color.secondary, children: quote.error ??
|
|
966
|
+
"We couldn't get a fresh payment amount. Please try again." })] }), _jsxs(SetupActions, { children: [_jsx(StyledButton, { onClick: () => {
|
|
967
|
+
void refreshQuote();
|
|
968
|
+
}, variant: "primary", style: { marginTop: 8 }, children: "Try again" }), _jsx(ModalBackButton, { view: "cryptoIntent" })] })] }));
|
|
296
969
|
}
|
|
297
|
-
|
|
298
|
-
|
|
970
|
+
// Quote refreshing: the address/route was stale or missing, so Mint is
|
|
971
|
+
// fetching a fresh payable amount — no expiry dead-end.
|
|
972
|
+
if (quote.status === "refreshing") {
|
|
973
|
+
return (_jsx(ModalViewContainer, { ref: modalRef, children: _jsxs(RefreshCard, { children: [_jsx(RefreshSpinner, { "aria-hidden": "true" }), _jsxs(RefreshTitle, { children: [_jsx(Text, { size: "base", weight: "semibold", color: config.theme.font.color.primary, children: "Updating quote" }), _jsx(Text, { size: "sm", color: config.theme.font.color.secondary, children: "Getting the latest amount..." })] })] }) }));
|
|
974
|
+
}
|
|
975
|
+
const settlementCurrency = cryptoPaymentAttempt?.settlement_config ?? cryptoCurrency;
|
|
976
|
+
const selectedSource = sourceOptions.find((option) => sourceKey(option) === selectedSourceKey) ??
|
|
977
|
+
sourceOptions[0] ??
|
|
978
|
+
cryptoCurrency;
|
|
979
|
+
const tokenOptions = uniqueSourceTokens(sourceOptions, manualPaymentOptions);
|
|
980
|
+
const activeTokenKey = selectedTokenKey ||
|
|
981
|
+
getSourceTokenGroupKey(selectedSource, manualPaymentOptions);
|
|
982
|
+
const networkOptions = sourceOptions.filter((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === activeTokenKey);
|
|
983
|
+
const uniqueNetworkOptions = uniqueSourceChains(networkOptions);
|
|
984
|
+
const selectedTokenOption = tokenOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === activeTokenKey);
|
|
985
|
+
const instructions = cryptoPaymentAttempt?.payment_instructions ?? null;
|
|
986
|
+
const instructionSource = getManualInstructionSource(instructions);
|
|
987
|
+
const amount = cryptoPaymentAttempt?.amount_formatted;
|
|
299
988
|
const currency = settlementCurrency.asset_name;
|
|
300
989
|
const chain = settlementCurrency.chain_name;
|
|
301
|
-
const
|
|
302
|
-
const
|
|
303
|
-
const
|
|
990
|
+
const sourceCurrency = selectedSource?.asset_name ?? currency;
|
|
991
|
+
const sourceChain = selectedSource?.chain_name ?? chain;
|
|
992
|
+
const trimmedRefundWallet = refundWallet.trim();
|
|
993
|
+
const currentRefundWallet = trimmedRefundWallet || cryptoPaymentAttempt?.refund_to?.trim() || "";
|
|
994
|
+
const sourceMatchesSettlementCurrency = (source) => source.asset.toLowerCase() === settlementCurrency.asset.toLowerCase() &&
|
|
995
|
+
source.chain.toLowerCase() === settlementCurrency.chain.toLowerCase();
|
|
996
|
+
const canReuseAttemptForSource = (source) => Boolean(instructionSource &&
|
|
997
|
+
instructionSource.token.toLowerCase() === source.asset.toLowerCase() &&
|
|
998
|
+
instructionSource.chain.toLowerCase() === source.chain.toLowerCase() &&
|
|
999
|
+
normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) ===
|
|
1000
|
+
normalizeOptionalAddress(trimmedRefundWallet) &&
|
|
1001
|
+
!attemptIsStale);
|
|
1002
|
+
const tokenHasFastManualRoute = (token) => sourceOptions.some((option) => getSourceTokenGroupKey(option, manualPaymentOptions) ===
|
|
1003
|
+
getSourceTokenGroupKey(token, manualPaymentOptions) &&
|
|
1004
|
+
(sourceMatchesSettlementCurrency(option) ||
|
|
1005
|
+
manualPaymentOptions.some((manualOption) => manualPaymentOptionKey(manualOption).toLowerCase() ===
|
|
1006
|
+
manualOptionLookupKey(option) && manualOption.kind === "direct")));
|
|
1007
|
+
const tokenIconUrl = selectedSource?.logo_url ?? settlementCurrency.logo_url ?? null;
|
|
1008
|
+
const chainIconUrl = selectedSource?.chain_logo_url ?? settlementCurrency.chain_logo_url ?? null;
|
|
1009
|
+
const rawAmount = cryptoPaymentAttempt?.amount === undefined
|
|
1010
|
+
? null
|
|
1011
|
+
: String(cryptoPaymentAttempt.amount);
|
|
1012
|
+
const sourceAmountFormatted = instructions?.type === "relay_deposit_address"
|
|
1013
|
+
? instructions.source_amount_formatted
|
|
1014
|
+
: (instructions?.amount_formatted ?? amount);
|
|
1015
|
+
const sourceAmountRaw = instructions?.type === "relay_deposit_address"
|
|
1016
|
+
? instructions.source_amount
|
|
1017
|
+
: (instructions?.amount ?? rawAmount);
|
|
1018
|
+
const sourceTokenSymbol = getSourceTokenSymbol(selectedSource, manualPaymentOptions);
|
|
1019
|
+
const refundSummary = currentRefundWallet
|
|
1020
|
+
? `${currentRefundWallet.slice(0, 6)}...${currentRefundWallet.slice(-4)}`
|
|
1021
|
+
: "Sender wallet";
|
|
1022
|
+
const formattedAmount = sourceAmountFormatted === undefined
|
|
1023
|
+
? null
|
|
1024
|
+
: formatManualPaymentAmount(sourceAmountFormatted, sourceCurrency);
|
|
1025
|
+
const useRawAmount = Boolean(sourceAmountRaw) &&
|
|
1026
|
+
sourceAmountRaw !== String(sourceAmountFormatted) &&
|
|
1027
|
+
shouldUseRawManualAmount(sourceChain, sourceCurrency);
|
|
1028
|
+
const sendAmount = useRawAmount ? sourceAmountRaw : formattedAmount;
|
|
1029
|
+
const copyAmount = useRawAmount
|
|
1030
|
+
? sourceAmountRaw
|
|
1031
|
+
: sourceAmountFormatted === undefined
|
|
1032
|
+
? null
|
|
1033
|
+
: String(sourceAmountFormatted);
|
|
1034
|
+
const paymentAddress = instructions?.payment_address ?? cryptoPaymentAttempt?.destination_address;
|
|
1035
|
+
const qrPayload = instructions?.type === "token_transfer"
|
|
1036
|
+
? instructions.qr_payload
|
|
1037
|
+
: paymentAddress;
|
|
1038
|
+
const goBackInSetup = () => {
|
|
1039
|
+
setRefundWalletError(null);
|
|
1040
|
+
if (manualSetupStep === "network") {
|
|
1041
|
+
setManualSetupStep("token");
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
return;
|
|
1045
|
+
};
|
|
1046
|
+
const openRefundEditor = () => {
|
|
1047
|
+
setPaymentDetailsExpanded(true);
|
|
1048
|
+
setRefundDetailsExpanded(true);
|
|
1049
|
+
window.setTimeout(() => refundWalletInputRef.current?.focus(), 0);
|
|
1050
|
+
};
|
|
1051
|
+
const selectToken = (token) => {
|
|
1052
|
+
const nextTokenKey = getSourceTokenGroupKey(token, manualPaymentOptions);
|
|
1053
|
+
const firstNetworkForToken = sourceOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === nextTokenKey) ?? token;
|
|
1054
|
+
setSelectedTokenKey(nextTokenKey);
|
|
1055
|
+
setSelectedSourceKey(sourceKey(firstNetworkForToken));
|
|
1056
|
+
setManualSetupStep("network");
|
|
1057
|
+
setRefundWalletError(null);
|
|
1058
|
+
};
|
|
1059
|
+
const generateManualPaymentForSource = async (source, options = {}) => {
|
|
1060
|
+
if (trimmedRefundWallet &&
|
|
1061
|
+
!isValidRefundAddressForSource(trimmedRefundWallet, source)) {
|
|
1062
|
+
setRefundWalletError(source.chain.toLowerCase().startsWith("tron:")
|
|
1063
|
+
? "Enter a valid TRON refund wallet address."
|
|
1064
|
+
: "Enter a valid EVM refund wallet address.");
|
|
1065
|
+
setPaymentDetailsExpanded(true);
|
|
1066
|
+
setRefundDetailsExpanded(true);
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
if (canReuseAttemptForSource(source)) {
|
|
1070
|
+
dismissedAttemptKeyRef.current = null;
|
|
1071
|
+
configureManualQuoteRefresh();
|
|
1072
|
+
setAcknowledgedWithTransition(true);
|
|
1073
|
+
if (options.collapseRefundEditor) {
|
|
1074
|
+
setRefundDetailsExpanded(false);
|
|
1075
|
+
}
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
setIsCreatingAttempt(true);
|
|
1079
|
+
try {
|
|
1080
|
+
await createManualDirectPaymentAttempt("", 1, trimmedRefundWallet || null, {
|
|
1081
|
+
mode: sourceMatchesSettlementCurrency(source)
|
|
1082
|
+
? undefined
|
|
1083
|
+
: getManualPaymentAttemptMode(source, settlementCurrency),
|
|
1084
|
+
source,
|
|
1085
|
+
});
|
|
1086
|
+
configureManualQuoteRefresh();
|
|
1087
|
+
setAcknowledgedWithTransition(true);
|
|
1088
|
+
if (options.collapseRefundEditor) {
|
|
1089
|
+
setRefundDetailsExpanded(false);
|
|
1090
|
+
}
|
|
1091
|
+
}
|
|
1092
|
+
catch (error) {
|
|
1093
|
+
console.error("Failed to create manual payment attempt:", error);
|
|
1094
|
+
goToView("failed");
|
|
1095
|
+
}
|
|
1096
|
+
finally {
|
|
1097
|
+
setIsCreatingAttempt(false);
|
|
1098
|
+
}
|
|
1099
|
+
};
|
|
1100
|
+
const selectNetwork = (network) => {
|
|
1101
|
+
setSelectedSourceKey(sourceKey(network));
|
|
1102
|
+
setRefundWalletError(null);
|
|
1103
|
+
setRefundDetailsExpanded(false);
|
|
1104
|
+
setCopiedAddress(false);
|
|
1105
|
+
setCopiedAmount(false);
|
|
1106
|
+
setShowQrCode(false);
|
|
1107
|
+
void generateManualPaymentForSource(network);
|
|
1108
|
+
};
|
|
304
1109
|
const copyToClipboard = async (value, setCopied) => {
|
|
305
1110
|
try {
|
|
306
1111
|
await navigator.clipboard.writeText(value);
|
|
@@ -311,18 +1116,52 @@ const CryptoIntentDirectDetailsViewContent = () => {
|
|
|
311
1116
|
console.error("Failed to copy to clipboard:", error);
|
|
312
1117
|
}
|
|
313
1118
|
};
|
|
314
|
-
|
|
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, _jsxs(SelectedSummary, { children: [_jsxs(SelectedSummaryToggle, { type: "button", onClick: () => setPaymentDetailsExpanded((expanded) => !expanded), "aria-expanded": paymentDetailsExpanded, 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] })] })] }) }), _jsx(RefundDetailsCaret, { "$expanded": paymentDetailsExpanded, children: "\u25BE" })] }), _jsxs(SelectedSummaryNote, { children: [_jsxs(ManualWarning, { children: [_jsx(WarningIconWrap, { children: _jsx(AlertCircleIcon, { size: 16 }) }), _jsxs("span", { children: ["Send", " ", sendAmount ? (_jsxs(_Fragment, { children: ["at least ", _jsx("strong", { children: sendAmount }), " "] })) : null, "in ", _jsx("strong", { children: sourceTokenSymbol }), " on", " ", _jsx("strong", { children: sourceChain }), ". Use the amount shown here."] })] }), !currentRefundWallet && !refundDetailsExpanded ? (_jsxs(RefundWarning, { style: { margin: "10px 0 0" }, children: [_jsx(WarningIconWrap, { children: _jsx(AlertCircleIcon, { size: 16 }) }), _jsxs("span", { children: ["No refund address is set.", " ", _jsxs(RefundWarningAction, { type: "button", onClick: openRefundEditor, children: [_jsx(EditIcon, { size: 13 }), "Add refund address"] }), " ", "or refunds will use the sending wallet when possible."] })] })) : null] }), paymentDetailsExpanded ? (_jsxs(SelectedSummaryBody, { children: [_jsxs(DetailRows, { children: [sendAmount ? (_jsxs(DetailRow, { children: [_jsx(DetailLabel, { children: "Amount to send" }), _jsx(DetailValue, { children: sendAmount })] })) : null, currentRefundWallet ? (_jsxs(DetailRow, { children: [_jsx(DetailLabel, { children: "Refund address" }), _jsxs(DetailValue, { children: [refundSummary, _jsx(DetailAction, { type: "button", title: "Edit refund address", "aria-label": "Edit refund address", onClick: openRefundEditor, children: _jsx(EditIcon, { size: 14 }) })] })] })) : null] }), _jsx(RefundDetails, { children: refundDetailsExpanded ? (_jsxs(RefundDetailsBody, { children: [!currentRefundWallet ? (_jsxs(RefundWarning, { children: [_jsx(WarningIconWrap, { children: _jsx(AlertCircleIcon, { size: 16 }) }), _jsx("span", { children: "Leave blank to use the sender wallet as the refund recipient." })] })) : null, _jsxs(RefundWalletPanel, { children: [_jsx(RefundWalletInput, { ref: refundWalletInputRef, value: refundWallet, onChange: (event) => {
|
|
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 &&
|
|
1129
|
+
paymentAddress &&
|
|
1130
|
+
sendAmount &&
|
|
1131
|
+
copyAmount ? (_jsxs(PaymentInstructionCard, { children: [_jsxs("div", { children: [_jsx(PaymentInstructionHeader, { children: _jsx(PaymentInstructionLabel, { theme: config.theme, children: "Amount to send" }) }), _jsxs(InfoRow, { isCopied: copiedAmount, onClick: () => copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
|
|
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) => {
|
|
1139
|
+
console.error("Failed to copy address:", error);
|
|
1140
|
+
}), 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
|
+
console.error("Failed to copy address:", error);
|
|
1142
|
+
}), children: [copiedAddress ? (_jsx(ClipboardCheckIcon, { size: 16 })) : (_jsx(ClipboardAddIcon, { size: 16 })), copiedAddress ? "Copied address" : "Copy address"] })] })) : null] }));
|
|
315
1143
|
if (!hasAcknowledged) {
|
|
316
|
-
|
|
1144
|
+
if (manualSetupStep === "token") {
|
|
1145
|
+
return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select token" }), _jsx(OptionList, { children: tokenOptions.map((option) => {
|
|
1146
|
+
const hasFastRoute = tokenHasFastManualRoute(option);
|
|
1147
|
+
const tokenSymbol = getSourceTokenSymbol(option, manualPaymentOptions);
|
|
1148
|
+
const showTokenName = option.asset_name.toLowerCase() !== tokenSymbol.toLowerCase();
|
|
1149
|
+
return (_jsxs(SelectionRow, { type: "button", onClick: () => selectToken(option), children: [_jsxs(SelectionRowLeft, { children: [_jsx(SelectionIcon, { "$iconUrl": option.logo_url, children: option.logo_url ? null : 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
|
+
}) }), _jsx(SetupActions, { children: _jsx(ModalBackButton, { view: "cryptoIntent" }) })] }));
|
|
1151
|
+
}
|
|
1152
|
+
if (manualSetupStep === "network") {
|
|
1153
|
+
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(SelectionIcon, { "$iconUrl": option.chain_logo_url, children: option.chain_logo_url
|
|
1155
|
+
? null
|
|
1156
|
+
: getChainAbbreviation(option.chain_name) }), _jsxs(SelectionText, { children: [_jsx(SelectionTitle, { children: option.chain_name }), _jsx(SelectionSubtitle, { children: selectedTokenLabel })] })] }), isCreatingAttempt &&
|
|
1157
|
+
sourceKey(option) === selectedSourceKey ? (_jsx(SelectionMeta, { children: "Generating..." })) : null] }, sourceKey(option)))) }), _jsx(SetupActions, { children: _jsx(StyledButton, { onClick: goBackInSetup, variant: "secondary", children: "Back" }) })] }));
|
|
1158
|
+
}
|
|
1159
|
+
return null;
|
|
317
1160
|
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
copyToClipboard(cryptoPaymentAttempt.destination_address, setCopiedAddress).catch((error) => {
|
|
323
|
-
console.error("Failed to copy address:", error);
|
|
324
|
-
});
|
|
325
|
-
}, title: "Copy address", children: copiedAddress ? (_jsx(ClipboardCheckIcon, { size: 16 })) : (_jsx(ClipboardAddIcon, { size: 16 })) }) })] })] }), _jsx(StyledButton, { onClick: handleConfirm, variant: "primary", style: { marginTop: 8 }, children: "I've sent the funds" }), _jsx(ModalBackButton, { view: "cryptoIntent" })] }));
|
|
1161
|
+
if (!cryptoPaymentAttempt || !sendAmount || !copyAmount || !paymentAddress) {
|
|
1162
|
+
return null;
|
|
1163
|
+
}
|
|
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" })] })] }));
|
|
326
1165
|
};
|
|
327
|
-
export { CryptoIntentDirectDetailsViewContent };
|
|
1166
|
+
export { CryptoIntentDirectDetailsViewContent, getManualPaymentAttemptMode, getManualInstructionSource, shouldLoadManualPaymentOptions, uniqueSourceOptions, };
|
|
328
1167
|
//# sourceMappingURL=direct-details.js.map
|