@mintmoney/react 0.1.0-alpha.31 → 0.1.0-alpha.33

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.
Files changed (162) hide show
  1. package/dist/css/styles.css +8 -6
  2. package/dist/esm/api/generated.js +31 -0
  3. package/dist/esm/api/generated.js.map +1 -1
  4. package/dist/esm/api/index.js +1 -0
  5. package/dist/esm/api/index.js.map +1 -1
  6. package/dist/esm/api/payments.js +39 -0
  7. package/dist/esm/api/payments.js.map +1 -1
  8. package/dist/esm/checkout/index.js +41 -19
  9. package/dist/esm/checkout/index.js.map +1 -1
  10. package/dist/esm/checkout/modal.js +4 -3
  11. package/dist/esm/checkout/modal.js.map +1 -1
  12. package/dist/esm/checkout/providers/wagmi-config.js +82 -0
  13. package/dist/esm/checkout/providers/wagmi-config.js.map +1 -0
  14. package/dist/esm/checkout/surplus-refund.js +38 -0
  15. package/dist/esm/checkout/surplus-refund.js.map +1 -0
  16. package/dist/esm/checkout/views/back.js +2 -2
  17. package/dist/esm/checkout/views/back.js.map +1 -1
  18. package/dist/esm/checkout/views/crypto-intent/direct-details.js +945 -96
  19. package/dist/esm/checkout/views/crypto-intent/direct-details.js.map +1 -1
  20. package/dist/esm/checkout/views/crypto-intent/methods.js +84 -31
  21. package/dist/esm/checkout/views/crypto-intent/methods.js.map +1 -1
  22. package/dist/esm/checkout/views/crypto-intent/processing.js +51 -3
  23. package/dist/esm/checkout/views/crypto-intent/processing.js.map +1 -1
  24. package/dist/esm/checkout/views/crypto-intent/success.js +58 -9
  25. package/dist/esm/checkout/views/crypto-intent/success.js.map +1 -1
  26. package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js +641 -282
  27. package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js.map +1 -1
  28. package/dist/esm/checkout/views/crypto-intent/wallet-select.js +104 -20
  29. package/dist/esm/checkout/views/crypto-intent/wallet-select.js.map +1 -1
  30. package/dist/esm/checkout/views/failed.js +83 -1
  31. package/dist/esm/checkout/views/failed.js.map +1 -1
  32. package/dist/esm/checkout/views/initial.js +46 -6
  33. package/dist/esm/checkout/views/initial.js.map +1 -1
  34. package/dist/esm/checkout/views/method-select.js +16 -4
  35. package/dist/esm/checkout/views/method-select.js.map +1 -1
  36. package/dist/esm/checkout/views/restart.js +3 -1
  37. package/dist/esm/checkout/views/restart.js.map +1 -1
  38. package/dist/esm/components/buttons/index.js +4 -1
  39. package/dist/esm/components/buttons/index.js.map +1 -1
  40. package/dist/esm/components/icons/clock.js +4 -0
  41. package/dist/esm/components/icons/clock.js.map +1 -0
  42. package/dist/esm/components/icons/edit.js +6 -0
  43. package/dist/esm/components/icons/edit.js.map +1 -0
  44. package/dist/esm/components/icons/index.js +3 -0
  45. package/dist/esm/components/icons/index.js.map +1 -1
  46. package/dist/esm/components/icons/send.js +6 -0
  47. package/dist/esm/components/icons/send.js.map +1 -0
  48. package/dist/esm/components/index.js +1 -0
  49. package/dist/esm/components/index.js.map +1 -1
  50. package/dist/esm/components/quote-expiry/index.js +2 -0
  51. package/dist/esm/components/quote-expiry/index.js.map +1 -0
  52. package/dist/esm/components/quote-expiry/quote-expiry-countdown.js +35 -0
  53. package/dist/esm/components/quote-expiry/quote-expiry-countdown.js.map +1 -0
  54. package/dist/esm/components/quote-expiry/styles.js +109 -0
  55. package/dist/esm/components/quote-expiry/styles.js.map +1 -0
  56. package/dist/esm/components/quote-expiry/tiers.js +31 -0
  57. package/dist/esm/components/quote-expiry/tiers.js.map +1 -0
  58. package/dist/esm/components/text/index.js +1 -0
  59. package/dist/esm/components/text/index.js.map +1 -1
  60. package/dist/esm/components/wallet-selector/component.js +3 -5
  61. package/dist/esm/components/wallet-selector/component.js.map +1 -1
  62. package/dist/esm/components/wallet-selector/wallets/wagmi/index.js.map +1 -1
  63. package/dist/esm/config.js.map +1 -1
  64. package/dist/esm/index.js +2 -1
  65. package/dist/esm/index.js.map +1 -1
  66. package/dist/esm/integrations/lifi.js +52 -34
  67. package/dist/esm/integrations/lifi.js.map +1 -1
  68. package/dist/esm/refund/index.js +791 -0
  69. package/dist/esm/refund/index.js.map +1 -0
  70. package/dist/esm/state/checkout/payment-attempt.js +3 -0
  71. package/dist/esm/state/checkout/payment-attempt.js.map +1 -1
  72. package/dist/esm/state/checkout/payment-lifecycle.js +66 -0
  73. package/dist/esm/state/checkout/payment-lifecycle.js.map +1 -0
  74. package/dist/esm/state/checkout/store.js +508 -55
  75. package/dist/esm/state/checkout/store.js.map +1 -1
  76. package/dist/esm/state/checkout/wallet-payment-options.js +30 -0
  77. package/dist/esm/state/checkout/wallet-payment-options.js.map +1 -0
  78. package/dist/esm/themes/default.js +6 -0
  79. package/dist/esm/themes/default.js.map +1 -1
  80. package/dist/esm/utils/string.js +1 -0
  81. package/dist/esm/utils/string.js.map +1 -1
  82. package/dist/esm/utils/wallet-errors.js +15 -0
  83. package/dist/esm/utils/wallet-errors.js.map +1 -0
  84. package/dist/types/api/generated.d.ts +207 -4
  85. package/dist/types/api/generated.d.ts.map +1 -1
  86. package/dist/types/api/index.d.ts +2 -1
  87. package/dist/types/api/index.d.ts.map +1 -1
  88. package/dist/types/api/payments.d.ts +36 -1
  89. package/dist/types/api/payments.d.ts.map +1 -1
  90. package/dist/types/api/types.d.ts +4 -0
  91. package/dist/types/api/types.d.ts.map +1 -1
  92. package/dist/types/checkout/index.d.ts +4 -1
  93. package/dist/types/checkout/index.d.ts.map +1 -1
  94. package/dist/types/checkout/modal.d.ts.map +1 -1
  95. package/dist/types/checkout/providers/wagmi-config.d.ts +12 -0
  96. package/dist/types/checkout/providers/wagmi-config.d.ts.map +1 -0
  97. package/dist/types/checkout/surplus-refund.d.ts +10 -0
  98. package/dist/types/checkout/surplus-refund.d.ts.map +1 -0
  99. package/dist/types/checkout/views/back.d.ts +2 -1
  100. package/dist/types/checkout/views/back.d.ts.map +1 -1
  101. package/dist/types/checkout/views/crypto-intent/direct-details.d.ts +10 -1
  102. package/dist/types/checkout/views/crypto-intent/direct-details.d.ts.map +1 -1
  103. package/dist/types/checkout/views/crypto-intent/methods.d.ts.map +1 -1
  104. package/dist/types/checkout/views/crypto-intent/processing.d.ts.map +1 -1
  105. package/dist/types/checkout/views/crypto-intent/success.d.ts.map +1 -1
  106. package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts.map +1 -1
  107. package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts.map +1 -1
  108. package/dist/types/checkout/views/failed.d.ts.map +1 -1
  109. package/dist/types/checkout/views/initial.d.ts +2 -0
  110. package/dist/types/checkout/views/initial.d.ts.map +1 -1
  111. package/dist/types/checkout/views/method-select.d.ts +2 -0
  112. package/dist/types/checkout/views/method-select.d.ts.map +1 -1
  113. package/dist/types/checkout/views/restart.d.ts.map +1 -1
  114. package/dist/types/components/buttons/index.d.ts.map +1 -1
  115. package/dist/types/components/icons/clock.d.ts +6 -0
  116. package/dist/types/components/icons/clock.d.ts.map +1 -0
  117. package/dist/types/components/icons/edit.d.ts +6 -0
  118. package/dist/types/components/icons/edit.d.ts.map +1 -0
  119. package/dist/types/components/icons/index.d.ts +3 -0
  120. package/dist/types/components/icons/index.d.ts.map +1 -1
  121. package/dist/types/components/icons/send.d.ts +6 -0
  122. package/dist/types/components/icons/send.d.ts.map +1 -0
  123. package/dist/types/components/index.d.ts +1 -0
  124. package/dist/types/components/index.d.ts.map +1 -1
  125. package/dist/types/components/quote-expiry/index.d.ts +2 -0
  126. package/dist/types/components/quote-expiry/index.d.ts.map +1 -0
  127. package/dist/types/components/quote-expiry/quote-expiry-countdown.d.ts +15 -0
  128. package/dist/types/components/quote-expiry/quote-expiry-countdown.d.ts.map +1 -0
  129. package/dist/types/components/quote-expiry/styles.d.ts +22 -0
  130. package/dist/types/components/quote-expiry/styles.d.ts.map +1 -0
  131. package/dist/types/components/quote-expiry/tiers.d.ts +10 -0
  132. package/dist/types/components/quote-expiry/tiers.d.ts.map +1 -0
  133. package/dist/types/components/text/index.d.ts.map +1 -1
  134. package/dist/types/components/wallet-selector/component.d.ts +1 -2
  135. package/dist/types/components/wallet-selector/component.d.ts.map +1 -1
  136. package/dist/types/components/wallet-selector/domain.d.ts +3 -2
  137. package/dist/types/components/wallet-selector/domain.d.ts.map +1 -1
  138. package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts +41 -5
  139. package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts.map +1 -1
  140. package/dist/types/config.d.ts +4 -0
  141. package/dist/types/config.d.ts.map +1 -1
  142. package/dist/types/index.d.ts +2 -1
  143. package/dist/types/index.d.ts.map +1 -1
  144. package/dist/types/integrations/lifi.d.ts.map +1 -1
  145. package/dist/types/refund/index.d.ts +82 -0
  146. package/dist/types/refund/index.d.ts.map +1 -0
  147. package/dist/types/state/checkout/payment-attempt.d.ts.map +1 -1
  148. package/dist/types/state/checkout/payment-lifecycle.d.ts +37 -0
  149. package/dist/types/state/checkout/payment-lifecycle.d.ts.map +1 -0
  150. package/dist/types/state/checkout/store.d.ts +40 -2
  151. package/dist/types/state/checkout/store.d.ts.map +1 -1
  152. package/dist/types/state/checkout/wallet-payment-options.d.ts +18 -0
  153. package/dist/types/state/checkout/wallet-payment-options.d.ts.map +1 -0
  154. package/dist/types/themes/default.d.ts.map +1 -1
  155. package/dist/types/themes/types.d.ts +11 -0
  156. package/dist/types/themes/types.d.ts.map +1 -1
  157. package/dist/types/utils/string.d.ts +1 -0
  158. package/dist/types/utils/string.d.ts.map +1 -1
  159. package/dist/types/utils/wallet-errors.d.ts +2 -0
  160. package/dist/types/utils/wallet-errors.d.ts.map +1 -0
  161. package/package.json +25 -18
  162. package/LICENSE +0 -21
@@ -1,70 +1,78 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
- import { 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 { useModalWithView, StyledButton, Text, ClipboardAddIcon, ClipboardCheckIcon, } 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 { useCheckoutStore } from "../../../state/checkout/store.js";
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 StepContainer = styled.div `
13
- margin-bottom: 16px;
14
- `;
15
- const StepHeader = styled.div `
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
- margin-bottom: 8px;
22
+ justify-content: center;
23
+ margin: 8px 0 0;
19
24
  `;
20
- const StepNumber = styled.div `
21
- background: ${({ theme }) => theme.btn.primary.default.backgroundColor || "#3b82f6"};
22
- color: white;
23
- min-width: 24px;
24
- height: 24px;
25
- border-radius: 50%;
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: center;
38
+ justify-content: space-between;
39
+ gap: 8px;
40
+ `;
41
+ const PaymentInstructionLabel = styled.div `
29
42
  font-size: 12px;
30
- font-weight: 600;
31
- margin-right: 8px;
32
- flex-shrink: 0;
43
+ line-height: 1.3;
44
+ font-weight: 500;
45
+ color: ${({ theme }) => theme.font.color.tertiary};
33
46
  `;
34
- const StepTitle = styled.div `
35
- font-size: 14px;
36
- font-weight: 400;
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
- line-height: 1.3;
52
+ min-width: 0;
53
+ overflow-wrap: anywhere;
39
54
  `;
40
- const QRCard = styled.div `
41
- background: #f3f7fa;
42
- border-radius: 12px;
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: #f3f7fa;
53
- border-radius: 12px;
54
- padding: 4px 8px;
55
- margin: 4px 0 0 0;
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: 2px solid transparent;
68
+ border: 0;
59
69
 
60
70
  &:hover {
61
- background: #e8f2f7;
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: 12px;
86
- color: ${({ theme }) => theme.font.color.tertiary};
87
- flex: 1;
88
- text-overflow: ellipsis;
89
- white-space: nowrap;
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 WarningCard = styled.div `
130
- background: #fef3c7;
131
- border: 1px solid #f59e0b;
132
- border-radius: 12px;
133
- padding: 16px;
134
- margin: 8px 0;
135
- text-align: center;
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
+ }
196
+ `;
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
+ }
136
210
  `;
137
- const OptionCard = styled.div `
138
- border: 1px solid #e5e7eb;
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 OptionBalance = styled.div `
540
+ const SetupActions = styled.div `
207
541
  display: flex;
208
542
  flex-direction: column;
209
- align-items: flex-end;
210
- gap: 2px;
211
- flex-shrink: 0;
543
+ gap: 10px;
544
+ margin-top: 8px;
212
545
  `;
213
- const FastBadge = styled.span `
214
- display: inline-flex;
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;
215
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;
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
- gap: 4px;
218
- background: #ecfdf5;
219
- color: #047857;
220
- font-size: 12px;
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 WarningActions = styled.div `
613
+ const RefreshTitle = styled.div `
227
614
  display: flex;
228
615
  flex-direction: column;
229
- gap: 10px;
230
- margin-top: 8px;
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,21 +678,260 @@ const getChainAbbreviation = (chainName) => {
252
678
  };
253
679
  const formatManualPaymentAmount = (amount, currency) => {
254
680
  const amountText = String(amount);
255
- if (currency.toLowerCase().includes("usd")) {
256
- return `$${amountText}`;
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
- if (currency.toLowerCase() === "eth") {
259
- return `ETH ${amountText}`;
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 `${amountText} ${currency}`;
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 } = useCheckoutStore();
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);
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]);
861
+ useEffect(() => {
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
+ });
885
+ return () => {
886
+ cancelled = true;
887
+ };
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
+ ]);
270
935
  const handleConfirm = async () => {
271
936
  if (!payment?.id) {
272
937
  goToView("failed", { reason: "confirm_payment" });
@@ -281,16 +946,166 @@ const CryptoIntentDirectDetailsViewContent = () => {
281
946
  goToView("failed", { reason: "confirm_payment" });
282
947
  }
283
948
  };
284
- if (!cryptoPaymentAttempt || !cryptoCurrency) {
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) {
285
960
  return null;
286
961
  }
287
- const settlementCurrency = cryptoPaymentAttempt.settlement_config;
288
- const amount = cryptoPaymentAttempt.amount_formatted;
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" })] })] }));
969
+ }
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;
289
988
  const currency = settlementCurrency.asset_name;
290
989
  const chain = settlementCurrency.chain_name;
291
- const tokenIconUrl = settlementCurrency.logo_url ?? null;
292
- const chainIconUrl = settlementCurrency.chain_logo_url ?? null;
293
- const displayAmount = formatManualPaymentAmount(amount, currency);
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
+ };
294
1109
  const copyToClipboard = async (value, setCopied) => {
295
1110
  try {
296
1111
  await navigator.clipboard.writeText(value);
@@ -301,18 +1116,52 @@ const CryptoIntentDirectDetailsViewContent = () => {
301
1116
  console.error("Failed to copy to clipboard:", error);
302
1117
  }
303
1118
  };
304
- // Show initial warning state
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] }));
305
1143
  if (!hasAcknowledged) {
306
- return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsxs(WarningCard, { children: [_jsxs(Text, { size: "base", weight: "medium", color: config.theme.font.color.primary, style: { marginBottom: 12 }, children: ["\u26A0\uFE0F ", currency, " on ", chain, " only"] }), _jsxs(Text, { size: "sm", weight: "normal", color: config.theme.font.color.secondary, style: { lineHeight: 1.5 }, children: ["Send ", _jsx("strong", { children: currency }), " on ", _jsx("strong", { children: chain }), " only. If you send it on another chain, the funds may be lost and may not be recoverable."] })] }), _jsxs(WarningActions, { children: [_jsxs(StyledButton, { onClick: () => setHasAcknowledged(true), variant: "primary", style: { marginTop: 8 }, children: ["I'm sending on ", chain] }), _jsx(ModalBackButton, { view: "cryptoIntent" })] })] }));
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;
307
1160
  }
308
- return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsxs(StepContainer, { children: [_jsxs(StepHeader, { children: [_jsx(StepNumber, { theme: config.theme, children: "1" }), _jsx(StepTitle, { theme: config.theme, children: "Review the payment option" })] }), _jsx(OptionCard, { children: _jsxs(OptionHeader, { children: [_jsxs(OptionHeaderLeft, { children: [_jsxs(TokenIconWrap, { children: [_jsx(TokenIcon, { "$iconUrl": tokenIconUrl, children: tokenIconUrl ? null : getMonogram(currency) }), _jsx(ChainBadge, { "$iconUrl": chainIconUrl, children: chainIconUrl ? null : getChainAbbreviation(chain) })] }), _jsxs(OptionIdentity, { children: [_jsx(Text, { size: "base", weight: "semibold", color: config.theme.font.color.primary, children: currency }), _jsxs(Text, { size: "sm", color: config.theme.font.color.secondary, children: ["On ", chain] })] })] }), _jsxs(OptionBalance, { children: [_jsx(Text, { size: "base", weight: "semibold", color: config.theme.font.color.primary, children: displayAmount }), _jsxs(FastBadge, { children: [_jsx("span", { children: "\u26A1" }), _jsx("span", { children: "Fast" })] })] })] }) })] }), _jsxs(StepContainer, { children: [_jsxs(StepHeader, { children: [_jsx(StepNumber, { theme: config.theme, children: "2" }), _jsx(StepTitle, { theme: config.theme, children: "Scan QR code or copy wallet address" })] }), _jsx(QRCard, { children: _jsx(QRCode, { value: cryptoPaymentAttempt.destination_address, size: 120 }) }), _jsxs(InfoRow, { isCopied: copiedAddress, onClick: () => copyToClipboard(cryptoPaymentAttempt.destination_address, setCopiedAddress).catch((error) => {
309
- console.error("Failed to copy address:", error);
310
- }), title: "Click to copy address", children: [_jsx(AddressText, { theme: config.theme, children: cryptoPaymentAttempt.destination_address }), _jsx("span", { style: { marginLeft: 8 }, children: _jsx(CopyButton, { isCopied: copiedAddress, onClick: (e) => {
311
- e.stopPropagation();
312
- copyToClipboard(cryptoPaymentAttempt.destination_address, setCopiedAddress).catch((error) => {
313
- console.error("Failed to copy address:", error);
314
- });
315
- }, 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" })] })] }));
316
1165
  };
317
- export { CryptoIntentDirectDetailsViewContent };
1166
+ export { CryptoIntentDirectDetailsViewContent, getManualPaymentAttemptMode, getManualInstructionSource, shouldLoadManualPaymentOptions, uniqueSourceOptions, };
318
1167
  //# sourceMappingURL=direct-details.js.map