@mintmoney/react 0.2.0-alpha.2 → 0.2.0-alpha.4

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 (312) hide show
  1. package/dist/css/styles.css +12 -1
  2. package/dist/docs/customisation.md +4 -0
  3. package/dist/docs/quickstart.md +2 -0
  4. package/dist/esm/api/errors.js +89 -0
  5. package/dist/esm/api/errors.js.map +1 -0
  6. package/dist/esm/api/generated.js +825 -65
  7. package/dist/esm/api/generated.js.map +1 -1
  8. package/dist/esm/api/payments.js +36 -2
  9. package/dist/esm/api/payments.js.map +1 -1
  10. package/dist/esm/api/tokens.js +34 -0
  11. package/dist/esm/api/tokens.js.map +1 -0
  12. package/dist/esm/api/types.js.map +1 -1
  13. package/dist/esm/checkout/claimable-funds.js +19 -10
  14. package/dist/esm/checkout/claimable-funds.js.map +1 -1
  15. package/dist/esm/checkout/creation-error-modal.js +2 -2
  16. package/dist/esm/checkout/creation-error-modal.js.map +1 -1
  17. package/dist/esm/checkout/index.js +54 -13
  18. package/dist/esm/checkout/index.js.map +1 -1
  19. package/dist/esm/checkout/modal.js +52 -23
  20. package/dist/esm/checkout/modal.js.map +1 -1
  21. package/dist/esm/checkout/payment-status.js +68 -28
  22. package/dist/esm/checkout/payment-status.js.map +1 -1
  23. package/dist/esm/checkout/provider-status.js +9 -0
  24. package/dist/esm/checkout/provider-status.js.map +1 -0
  25. package/dist/esm/checkout/providers/checkout-wallet.js +140 -44
  26. package/dist/esm/checkout/providers/checkout-wallet.js.map +1 -1
  27. package/dist/esm/checkout/providers/wagmi-config.js +6 -3
  28. package/dist/esm/checkout/providers/wagmi-config.js.map +1 -1
  29. package/dist/esm/checkout/refund-notice.js +16 -0
  30. package/dist/esm/checkout/refund-notice.js.map +1 -0
  31. package/dist/esm/checkout/resume-state.js +207 -1
  32. package/dist/esm/checkout/resume-state.js.map +1 -1
  33. package/dist/esm/checkout/surplus-refund.js +12 -0
  34. package/dist/esm/checkout/surplus-refund.js.map +1 -1
  35. package/dist/esm/checkout/views/amount-header.js +11 -2
  36. package/dist/esm/checkout/views/amount-header.js.map +1 -1
  37. package/dist/esm/checkout/views/claimable-funds.js +21 -13
  38. package/dist/esm/checkout/views/claimable-funds.js.map +1 -1
  39. package/dist/esm/checkout/views/crypto-intent/direct-details.js +288 -888
  40. package/dist/esm/checkout/views/crypto-intent/direct-details.js.map +1 -1
  41. package/dist/esm/checkout/views/crypto-intent/manual-instruction-card.js +239 -0
  42. package/dist/esm/checkout/views/crypto-intent/manual-instruction-card.js.map +1 -0
  43. package/dist/esm/checkout/views/crypto-intent/manual-payment-summary.js +2 -26
  44. package/dist/esm/checkout/views/crypto-intent/manual-payment-summary.js.map +1 -1
  45. package/dist/esm/checkout/views/crypto-intent/manual-refresh.js +19 -0
  46. package/dist/esm/checkout/views/crypto-intent/manual-refresh.js.map +1 -0
  47. package/dist/esm/checkout/views/crypto-intent/manual-refund-preference.js +151 -23
  48. package/dist/esm/checkout/views/crypto-intent/manual-refund-preference.js.map +1 -1
  49. package/dist/esm/checkout/views/crypto-intent/manual-route-picker.js +309 -0
  50. package/dist/esm/checkout/views/crypto-intent/manual-route-picker.js.map +1 -0
  51. package/dist/esm/checkout/views/crypto-intent/manual-sources.js +155 -0
  52. package/dist/esm/checkout/views/crypto-intent/manual-sources.js.map +1 -0
  53. package/dist/esm/checkout/views/crypto-intent/manual-transfer-instructions.js +84 -0
  54. package/dist/esm/checkout/views/crypto-intent/manual-transfer-instructions.js.map +1 -0
  55. package/dist/esm/checkout/views/crypto-intent/payment-route-error.js +10 -0
  56. package/dist/esm/checkout/views/crypto-intent/payment-route-error.js.map +1 -0
  57. package/dist/esm/checkout/views/crypto-intent/processing.js +183 -32
  58. package/dist/esm/checkout/views/crypto-intent/processing.js.map +1 -1
  59. package/dist/esm/checkout/views/crypto-intent/success.js +74 -46
  60. package/dist/esm/checkout/views/crypto-intent/success.js.map +1 -1
  61. package/dist/esm/checkout/views/crypto-intent/wallet-payment-confirmation-amount.js +14 -24
  62. package/dist/esm/checkout/views/crypto-intent/wallet-payment-confirmation-amount.js.map +1 -1
  63. package/dist/esm/checkout/views/crypto-intent/wallet-payment-discovery.js +61 -0
  64. package/dist/esm/checkout/views/crypto-intent/wallet-payment-discovery.js.map +1 -0
  65. package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js +105 -627
  66. package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js.map +1 -1
  67. package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.styles.js +506 -0
  68. package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.styles.js.map +1 -0
  69. package/dist/esm/checkout/views/crypto-intent/wallet-select.js +4 -11
  70. package/dist/esm/checkout/views/crypto-intent/wallet-select.js.map +1 -1
  71. package/dist/esm/checkout/views/failed.js +44 -55
  72. package/dist/esm/checkout/views/failed.js.map +1 -1
  73. package/dist/esm/checkout/views/funding-timeline.js +182 -0
  74. package/dist/esm/checkout/views/funding-timeline.js.map +1 -0
  75. package/dist/esm/checkout/views/initial.js +35 -46
  76. package/dist/esm/checkout/views/initial.js.map +1 -1
  77. package/dist/esm/checkout/views/method-select.js +6 -4
  78. package/dist/esm/checkout/views/method-select.js.map +1 -1
  79. package/dist/esm/checkout/views/payment-follower.js +128 -0
  80. package/dist/esm/checkout/views/payment-follower.js.map +1 -0
  81. package/dist/esm/checkout/views/restart.js +17 -2
  82. package/dist/esm/checkout/views/restart.js.map +1 -1
  83. package/dist/esm/checkout/views/use-checkout-refund-status.js +75 -0
  84. package/dist/esm/checkout/views/use-checkout-refund-status.js.map +1 -0
  85. package/dist/esm/components/buttons/index.js +3 -2
  86. package/dist/esm/components/buttons/index.js.map +1 -1
  87. package/dist/esm/components/icons/search.js +5 -0
  88. package/dist/esm/components/icons/search.js.map +1 -0
  89. package/dist/esm/components/loading/index.js +2 -2
  90. package/dist/esm/components/loading/index.js.map +1 -1
  91. package/dist/esm/components/modals/modal-with-views.js +8 -14
  92. package/dist/esm/components/modals/modal-with-views.js.map +1 -1
  93. package/dist/esm/components/modals/modal.js +3 -3
  94. package/dist/esm/components/modals/modal.js.map +1 -1
  95. package/dist/esm/components/modals/transition-view.js +16 -0
  96. package/dist/esm/components/modals/transition-view.js.map +1 -0
  97. package/dist/esm/components/modals/use-modal-with-views.js +17 -19
  98. package/dist/esm/components/modals/use-modal-with-views.js.map +1 -1
  99. package/dist/esm/components/wallet-selector/wallets/wagmi/index.js +36 -2
  100. package/dist/esm/components/wallet-selector/wallets/wagmi/index.js.map +1 -1
  101. package/dist/esm/config.js.map +1 -1
  102. package/dist/esm/integrations/bitcoin-metamask.js +87 -0
  103. package/dist/esm/integrations/bitcoin-metamask.js.map +1 -0
  104. package/dist/esm/integrations/bitcoin-network.js +59 -0
  105. package/dist/esm/integrations/bitcoin-network.js.map +1 -0
  106. package/dist/esm/integrations/bitcoin-psbt.js +4 -0
  107. package/dist/esm/integrations/bitcoin-psbt.js.map +1 -0
  108. package/dist/esm/integrations/bitcoin-source.js +12 -0
  109. package/dist/esm/integrations/bitcoin-source.js.map +1 -0
  110. package/dist/esm/integrations/bitcoin-wallet.js +225 -0
  111. package/dist/esm/integrations/bitcoin-wallet.js.map +1 -0
  112. package/dist/esm/integrations/evm-chain.js +18 -0
  113. package/dist/esm/integrations/evm-chain.js.map +1 -1
  114. package/dist/esm/integrations/guarded-wallet-client.js +19 -0
  115. package/dist/esm/integrations/guarded-wallet-client.js.map +1 -0
  116. package/dist/esm/integrations/lifi.js +134 -45
  117. package/dist/esm/integrations/lifi.js.map +1 -1
  118. package/dist/esm/refund/index.js +237 -227
  119. package/dist/esm/refund/index.js.map +1 -1
  120. package/dist/esm/state/checkout/bitcoin-payment.js +254 -0
  121. package/dist/esm/state/checkout/bitcoin-payment.js.map +1 -0
  122. package/dist/esm/state/checkout/checkout-state.js +5 -11
  123. package/dist/esm/state/checkout/checkout-state.js.map +1 -1
  124. package/dist/esm/state/checkout/funding.js +5 -0
  125. package/dist/esm/state/checkout/funding.js.map +1 -0
  126. package/dist/esm/state/checkout/issuance-conflicts.js +29 -0
  127. package/dist/esm/state/checkout/issuance-conflicts.js.map +1 -0
  128. package/dist/esm/state/checkout/manual-route.js +10 -0
  129. package/dist/esm/state/checkout/manual-route.js.map +1 -0
  130. package/dist/esm/state/checkout/payment-attempt.js +44 -20
  131. package/dist/esm/state/checkout/payment-attempt.js.map +1 -1
  132. package/dist/esm/state/checkout/payment-lifecycle.js +9 -15
  133. package/dist/esm/state/checkout/payment-lifecycle.js.map +1 -1
  134. package/dist/esm/state/checkout/payment-observer.js +148 -0
  135. package/dist/esm/state/checkout/payment-observer.js.map +1 -0
  136. package/dist/esm/state/checkout/payment-phase.js +142 -0
  137. package/dist/esm/state/checkout/payment-phase.js.map +1 -0
  138. package/dist/esm/state/checkout/quote-countdown.js +26 -0
  139. package/dist/esm/state/checkout/quote-countdown.js.map +1 -0
  140. package/dist/esm/state/checkout/quote-lifecycle.js +145 -144
  141. package/dist/esm/state/checkout/quote-lifecycle.js.map +1 -1
  142. package/dist/esm/state/checkout/route-estimate.js +77 -0
  143. package/dist/esm/state/checkout/route-estimate.js.map +1 -0
  144. package/dist/esm/state/checkout/store.js +348 -313
  145. package/dist/esm/state/checkout/store.js.map +1 -1
  146. package/dist/esm/state/checkout/wallet-payment.js +334 -37
  147. package/dist/esm/state/checkout/wallet-payment.js.map +1 -1
  148. package/dist/esm/state/checkout/wallet-transfer-receipt.js +68 -0
  149. package/dist/esm/state/checkout/wallet-transfer-receipt.js.map +1 -0
  150. package/dist/esm/utils/string.js +2 -0
  151. package/dist/esm/utils/string.js.map +1 -1
  152. package/dist/esm/utils/token-amount.js +88 -0
  153. package/dist/esm/utils/token-amount.js.map +1 -0
  154. package/dist/esm/utils/wallet-errors.js +21 -4
  155. package/dist/esm/utils/wallet-errors.js.map +1 -1
  156. package/dist/types/api/errors.d.ts +37 -0
  157. package/dist/types/api/errors.d.ts.map +1 -0
  158. package/dist/types/api/generated.d.ts +4570 -707
  159. package/dist/types/api/generated.d.ts.map +1 -1
  160. package/dist/types/api/payments.d.ts +22 -2
  161. package/dist/types/api/payments.d.ts.map +1 -1
  162. package/dist/types/api/tokens.d.ts +6 -0
  163. package/dist/types/api/tokens.d.ts.map +1 -0
  164. package/dist/types/api/types.d.ts +30 -2
  165. package/dist/types/api/types.d.ts.map +1 -1
  166. package/dist/types/checkout/claimable-funds.d.ts +12 -2
  167. package/dist/types/checkout/claimable-funds.d.ts.map +1 -1
  168. package/dist/types/checkout/creation-error-modal.d.ts +2 -1
  169. package/dist/types/checkout/creation-error-modal.d.ts.map +1 -1
  170. package/dist/types/checkout/index.d.ts +23 -2
  171. package/dist/types/checkout/index.d.ts.map +1 -1
  172. package/dist/types/checkout/modal.d.ts +5 -2
  173. package/dist/types/checkout/modal.d.ts.map +1 -1
  174. package/dist/types/checkout/payment-status.d.ts +10 -2
  175. package/dist/types/checkout/payment-status.d.ts.map +1 -1
  176. package/dist/types/checkout/provider-status.d.ts +11 -0
  177. package/dist/types/checkout/provider-status.d.ts.map +1 -0
  178. package/dist/types/checkout/providers/checkout-wallet.d.ts +2 -3
  179. package/dist/types/checkout/providers/checkout-wallet.d.ts.map +1 -1
  180. package/dist/types/checkout/providers/wagmi-config.d.ts.map +1 -1
  181. package/dist/types/checkout/refund-notice.d.ts +7 -0
  182. package/dist/types/checkout/refund-notice.d.ts.map +1 -0
  183. package/dist/types/checkout/resume-state.d.ts +63 -1
  184. package/dist/types/checkout/resume-state.d.ts.map +1 -1
  185. package/dist/types/checkout/surplus-refund.d.ts +8 -0
  186. package/dist/types/checkout/surplus-refund.d.ts.map +1 -1
  187. package/dist/types/checkout/views/amount-header.d.ts +1 -0
  188. package/dist/types/checkout/views/amount-header.d.ts.map +1 -1
  189. package/dist/types/checkout/views/claimable-funds.d.ts.map +1 -1
  190. package/dist/types/checkout/views/crypto-intent/direct-details.d.ts +3 -13
  191. package/dist/types/checkout/views/crypto-intent/direct-details.d.ts.map +1 -1
  192. package/dist/types/checkout/views/crypto-intent/manual-instruction-card.d.ts +11 -0
  193. package/dist/types/checkout/views/crypto-intent/manual-instruction-card.d.ts.map +1 -0
  194. package/dist/types/checkout/views/crypto-intent/manual-payment-summary.d.ts +4 -11
  195. package/dist/types/checkout/views/crypto-intent/manual-payment-summary.d.ts.map +1 -1
  196. package/dist/types/checkout/views/crypto-intent/manual-refresh.d.ts +4 -0
  197. package/dist/types/checkout/views/crypto-intent/manual-refresh.d.ts.map +1 -0
  198. package/dist/types/checkout/views/crypto-intent/manual-refund-preference.d.ts +14 -10
  199. package/dist/types/checkout/views/crypto-intent/manual-refund-preference.d.ts.map +1 -1
  200. package/dist/types/checkout/views/crypto-intent/manual-route-picker.d.ts +18 -0
  201. package/dist/types/checkout/views/crypto-intent/manual-route-picker.d.ts.map +1 -0
  202. package/dist/types/checkout/views/crypto-intent/manual-sources.d.ts +33 -0
  203. package/dist/types/checkout/views/crypto-intent/manual-sources.d.ts.map +1 -0
  204. package/dist/types/checkout/views/crypto-intent/manual-transfer-instructions.d.ts +18 -0
  205. package/dist/types/checkout/views/crypto-intent/manual-transfer-instructions.d.ts.map +1 -0
  206. package/dist/types/checkout/views/crypto-intent/payment-route-error.d.ts +2 -0
  207. package/dist/types/checkout/views/crypto-intent/payment-route-error.d.ts.map +1 -0
  208. package/dist/types/checkout/views/crypto-intent/processing.d.ts +3 -2
  209. package/dist/types/checkout/views/crypto-intent/processing.d.ts.map +1 -1
  210. package/dist/types/checkout/views/crypto-intent/success.d.ts +2 -1
  211. package/dist/types/checkout/views/crypto-intent/success.d.ts.map +1 -1
  212. package/dist/types/checkout/views/crypto-intent/wallet-payment-confirmation-amount.d.ts +8 -8
  213. package/dist/types/checkout/views/crypto-intent/wallet-payment-confirmation-amount.d.ts.map +1 -1
  214. package/dist/types/checkout/views/crypto-intent/wallet-payment-discovery.d.ts +17 -0
  215. package/dist/types/checkout/views/crypto-intent/wallet-payment-discovery.d.ts.map +1 -0
  216. package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts +2 -1
  217. package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts.map +1 -1
  218. package/dist/types/checkout/views/crypto-intent/wallet-payment-options.styles.d.ts +61 -0
  219. package/dist/types/checkout/views/crypto-intent/wallet-payment-options.styles.d.ts.map +1 -0
  220. package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts +1 -2
  221. package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts.map +1 -1
  222. package/dist/types/checkout/views/failed.d.ts +6 -0
  223. package/dist/types/checkout/views/failed.d.ts.map +1 -1
  224. package/dist/types/checkout/views/funding-timeline.d.ts +21 -0
  225. package/dist/types/checkout/views/funding-timeline.d.ts.map +1 -0
  226. package/dist/types/checkout/views/initial.d.ts +2 -4
  227. package/dist/types/checkout/views/initial.d.ts.map +1 -1
  228. package/dist/types/checkout/views/method-select.d.ts +2 -1
  229. package/dist/types/checkout/views/method-select.d.ts.map +1 -1
  230. package/dist/types/checkout/views/payment-follower.d.ts +12 -0
  231. package/dist/types/checkout/views/payment-follower.d.ts.map +1 -0
  232. package/dist/types/checkout/views/restart.d.ts +1 -1
  233. package/dist/types/checkout/views/restart.d.ts.map +1 -1
  234. package/dist/types/checkout/views/use-checkout-refund-status.d.ts +74 -0
  235. package/dist/types/checkout/views/use-checkout-refund-status.d.ts.map +1 -0
  236. package/dist/types/components/buttons/index.d.ts.map +1 -1
  237. package/dist/types/components/icons/search.d.ts +2 -0
  238. package/dist/types/components/icons/search.d.ts.map +1 -0
  239. package/dist/types/components/loading/index.d.ts +6 -1
  240. package/dist/types/components/loading/index.d.ts.map +1 -1
  241. package/dist/types/components/modals/modal-with-views.d.ts +3 -1
  242. package/dist/types/components/modals/modal-with-views.d.ts.map +1 -1
  243. package/dist/types/components/modals/modal.d.ts +2 -1
  244. package/dist/types/components/modals/modal.d.ts.map +1 -1
  245. package/dist/types/components/modals/transition-view.d.ts +2 -0
  246. package/dist/types/components/modals/transition-view.d.ts.map +1 -0
  247. package/dist/types/components/modals/use-modal-with-views.d.ts +2 -1
  248. package/dist/types/components/modals/use-modal-with-views.d.ts.map +1 -1
  249. package/dist/types/components/wallet-selector/domain.d.ts +1 -1
  250. package/dist/types/components/wallet-selector/domain.d.ts.map +1 -1
  251. package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts +2 -1
  252. package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts.map +1 -1
  253. package/dist/types/config.d.ts +2 -0
  254. package/dist/types/config.d.ts.map +1 -1
  255. package/dist/types/integrations/bitcoin-metamask.d.ts +11 -0
  256. package/dist/types/integrations/bitcoin-metamask.d.ts.map +1 -0
  257. package/dist/types/integrations/bitcoin-network.d.ts +13 -0
  258. package/dist/types/integrations/bitcoin-network.d.ts.map +1 -0
  259. package/dist/types/integrations/bitcoin-psbt.d.ts +5 -0
  260. package/dist/types/integrations/bitcoin-psbt.d.ts.map +1 -0
  261. package/dist/types/integrations/bitcoin-source.d.ts +12 -0
  262. package/dist/types/integrations/bitcoin-source.d.ts.map +1 -0
  263. package/dist/types/integrations/bitcoin-wallet.d.ts +63 -0
  264. package/dist/types/integrations/bitcoin-wallet.d.ts.map +1 -0
  265. package/dist/types/integrations/evm-chain.d.ts +5 -0
  266. package/dist/types/integrations/evm-chain.d.ts.map +1 -1
  267. package/dist/types/integrations/guarded-wallet-client.d.ts +4 -0
  268. package/dist/types/integrations/guarded-wallet-client.d.ts.map +1 -0
  269. package/dist/types/integrations/lifi.d.ts +42 -0
  270. package/dist/types/integrations/lifi.d.ts.map +1 -1
  271. package/dist/types/refund/index.d.ts +1 -1
  272. package/dist/types/refund/index.d.ts.map +1 -1
  273. package/dist/types/state/checkout/bitcoin-payment.d.ts +28 -0
  274. package/dist/types/state/checkout/bitcoin-payment.d.ts.map +1 -0
  275. package/dist/types/state/checkout/checkout-state.d.ts +46 -13
  276. package/dist/types/state/checkout/checkout-state.d.ts.map +1 -1
  277. package/dist/types/state/checkout/funding.d.ts +6 -0
  278. package/dist/types/state/checkout/funding.d.ts.map +1 -0
  279. package/dist/types/state/checkout/issuance-conflicts.d.ts +22 -0
  280. package/dist/types/state/checkout/issuance-conflicts.d.ts.map +1 -0
  281. package/dist/types/state/checkout/manual-route.d.ts +13 -0
  282. package/dist/types/state/checkout/manual-route.d.ts.map +1 -0
  283. package/dist/types/state/checkout/payment-attempt.d.ts +19 -1
  284. package/dist/types/state/checkout/payment-attempt.d.ts.map +1 -1
  285. package/dist/types/state/checkout/payment-lifecycle.d.ts +6 -8
  286. package/dist/types/state/checkout/payment-lifecycle.d.ts.map +1 -1
  287. package/dist/types/state/checkout/payment-observer.d.ts +42 -0
  288. package/dist/types/state/checkout/payment-observer.d.ts.map +1 -0
  289. package/dist/types/state/checkout/payment-phase.d.ts +118 -0
  290. package/dist/types/state/checkout/payment-phase.d.ts.map +1 -0
  291. package/dist/types/state/checkout/quote-countdown.d.ts +15 -0
  292. package/dist/types/state/checkout/quote-countdown.d.ts.map +1 -0
  293. package/dist/types/state/checkout/quote-lifecycle.d.ts +17 -6
  294. package/dist/types/state/checkout/quote-lifecycle.d.ts.map +1 -1
  295. package/dist/types/state/checkout/route-estimate.d.ts +38 -0
  296. package/dist/types/state/checkout/route-estimate.d.ts.map +1 -0
  297. package/dist/types/state/checkout/store.d.ts +35 -15
  298. package/dist/types/state/checkout/store.d.ts.map +1 -1
  299. package/dist/types/state/checkout/wallet-payment.d.ts +15 -2
  300. package/dist/types/state/checkout/wallet-payment.d.ts.map +1 -1
  301. package/dist/types/state/checkout/wallet-transfer-receipt.d.ts +18 -0
  302. package/dist/types/state/checkout/wallet-transfer-receipt.d.ts.map +1 -0
  303. package/dist/types/utils/string.d.ts +2 -0
  304. package/dist/types/utils/string.d.ts.map +1 -1
  305. package/dist/types/utils/token-amount.d.ts +18 -0
  306. package/dist/types/utils/token-amount.d.ts.map +1 -0
  307. package/dist/types/utils/wallet-errors.d.ts.map +1 -1
  308. package/package.json +3 -1
  309. package/dist/esm/refund/confirmation.js +0 -30
  310. package/dist/esm/refund/confirmation.js.map +0 -1
  311. package/dist/types/refund/confirmation.d.ts +0 -14
  312. package/dist/types/refund/confirmation.d.ts.map +0 -1
@@ -1,348 +1,33 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useEffect, useMemo, useRef, useState } from "react";
3
- //@ts-expect-error import error
4
- import { QRCode } from "react-qr-code";
5
- import { keyframes, styled } from "styled-components";
2
+ import { useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
3
+ import { styled } from "styled-components";
6
4
  import { useAccount } from "wagmi";
7
- import { confirmPayment, getManualPaymentOptions, } from "../../../api/payments.js";
8
- import { AlertCircleIcon, ClipboardAddIcon, ClipboardCheckIcon, QuoteExpiryCountdown, StyledButton, Text, useModalWithView, } from "../../../components/index.js";
5
+ import { describeRevealFailure } from "../../../api/errors.js";
6
+ import { confirmPayment } from "../../../api/payments.js";
7
+ import { AlertCircleIcon, QuoteExpiryCountdown, StyledButton, Text, useModalWithView, } from "../../../components/index.js";
8
+ import { transitionView } from "../../../components/modals/transition-view.js";
9
9
  import { useMintMoneyConfig } from "../../../context.js";
10
- import { getAttemptQuoteTiming, isAttemptStale, } from "../../../state/checkout/payment-lifecycle.js";
11
- import { clearQuoteRefresh, captureCheckoutOpening, configureManualQuoteRefresh, createManualDirectPaymentAttempt, refreshQuote, useCheckoutStore, } from "../../../state/checkout/store.js";
10
+ import { BITCOIN, BITCOIN_CHAIN, } from "../../../integrations/bitcoin-source.js";
11
+ import { hasReceivedFunds } from "../../../state/checkout/funding.js";
12
+ import { hasClosedPaymentMovedOn } from "../../../state/checkout/issuance-conflicts.js";
13
+ import { getManualPaymentAttemptMode, } from "../../../state/checkout/manual-route.js";
14
+ import { canCreateFreshAttempt, isAttemptStale, } from "../../../state/checkout/payment-lifecycle.js";
15
+ import { acceptsFunds, derivePaymentPhase, isPendingPhase, pendingShortfall, } from "../../../state/checkout/payment-phase.js";
16
+ import { QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO, useQuoteCountdown, } from "../../../state/checkout/quote-countdown.js";
17
+ import { clearQuoteRefresh, captureCheckoutOpening, configureManualQuoteRefresh, createManualDirectPaymentAttempt, getFrozenRefundRecipient, isCheckoutIssued, recordManualTransfer, refreshQuote, useCheckoutStore, } from "../../../state/checkout/store.js";
18
+ import { formatChainLabel, formatTokenLabel, } from "../../../utils/token-amount.js";
12
19
  import { ModalViewContainer } from "../../container.js";
20
+ import { isManualTransferPending, manualTransferFor, } from "../../resume-state.js";
13
21
  import { ModalBackButton } from "../back.js";
22
+ import { FundingProgress } from "../funding-timeline.js";
23
+ import { ManualInstructionCard } from "./manual-instruction-card.js";
14
24
  import { ManualPaymentSummary } from "./manual-payment-summary.js";
15
- const QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO = 0.25;
16
- const ETHEREUM_ICON_URL = "https://coin-images.coingecko.com/coins/images/279/large/ethereum.png?1696501628";
17
- const QRCard = styled.div `
18
- background: #ffffff;
19
- border: 1px solid #111827;
20
- border-radius: 10px;
21
- padding: 10px;
22
- display: flex;
23
- flex-direction: column;
24
- align-items: center;
25
- justify-content: center;
26
- margin: 8px 0 0;
27
- `;
28
- const PaymentInstructionCard = styled.div `
29
- background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
30
- border: 1px solid #e2e8f0;
31
- border-radius: 16px;
32
- padding: 16px;
33
- display: flex;
34
- flex-direction: column;
35
- gap: 14px;
36
- box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
37
- `;
38
- const PaymentInstructionHeader = styled.div `
39
- display: flex;
40
- align-items: center;
41
- justify-content: space-between;
42
- gap: 8px;
43
- `;
44
- const PaymentInstructionLabel = styled.div `
45
- font-size: 13px;
46
- line-height: 1.3;
47
- font-weight: 600;
48
- color: ${({ theme }) => theme.font.color.tertiary};
49
- `;
50
- const PaymentInstructionValue = styled.div `
51
- font-size: 16px;
52
- line-height: 1.45;
53
- font-weight: 700;
54
- color: ${({ theme }) => theme.font.color.primary};
55
- min-width: 0;
56
- overflow-wrap: anywhere;
57
- `;
58
- const PaymentInstructionDivider = styled.div `
59
- height: 1px;
60
- background: #eef2f6;
61
- `;
62
- const InfoRow = styled.div `
63
- display: flex;
64
- align-items: center;
65
- background: transparent;
66
- border-radius: 8px;
67
- padding: 0;
68
- margin: 0;
69
- cursor: pointer;
70
- transition: all 0.2s ease-in-out;
71
- border: 0;
72
-
73
- &:hover {
74
- opacity: 0.78;
75
- }
76
-
77
- ${({ isCopied }) => isCopied &&
78
- `
79
- animation: copySuccess 0.6s ease-in-out;
80
- `}
81
-
82
- @keyframes copySuccess {
83
- 0% {
84
- border-color: transparent;
85
- }
86
- 50% {
87
- border-color: #10b981;
88
- }
89
- 100% {
90
- border-color: #10b981;
91
- }
92
- }
93
- `;
94
- const AddressInfoRow = styled(InfoRow) `
95
- align-items: flex-start;
96
- width: 100%;
97
- margin-top: 4px;
98
- `;
99
- const AddressText = styled.div `
100
- font-family: "Monaco", "Menlo", "Ubuntu Mono", monospace;
101
- font-size: 14px;
102
- line-height: 1.55;
103
- font-weight: 600;
104
- color: ${({ theme }) => theme.font.color.primary};
105
- width: 100%;
106
- flex: 1 1 auto;
107
- min-width: 0;
108
- overflow-wrap: anywhere;
109
- `;
110
- const AmountInfoRow = styled(InfoRow) `
111
- align-items: center;
112
- gap: 8px;
113
- width: fit-content;
114
- max-width: 100%;
115
- margin-top: 4px;
116
- `;
117
- const CopyButton = styled.button `
118
- display: flex;
119
- align-items: center;
120
- justify-content: center;
121
- width: 28px;
122
- height: 28px;
123
- flex: 0 0 28px;
124
- background: ${({ isCopied }) => (isCopied ? "#ecfdf5" : "#f1f3fb")};
125
- color: ${({ isCopied }) => (isCopied ? "#047857" : "#374151")};
126
- border: none;
127
- cursor: pointer;
128
- padding: 0;
129
- border-radius: 999px;
130
- transition:
131
- background 0.15s ease,
132
- color 0.15s ease,
133
- transform 0.15s ease;
134
-
135
- &:hover {
136
- background: ${({ isCopied }) => (isCopied ? "#dcfce7" : "#e8edf7")};
137
- }
138
-
139
- ${({ isCopied }) => isCopied &&
140
- `
141
- animation: iconBounce 0.6s ease-in-out;
142
- `}
143
-
144
- @keyframes iconBounce {
145
- 0% {
146
- transform: scale(1);
147
- }
148
- 25% {
149
- transform: scale(1.2);
150
- }
151
- 50% {
152
- transform: scale(0.9);
153
- }
154
- 75% {
155
- transform: scale(1.1);
156
- }
157
- 100% {
158
- transform: scale(1);
159
- }
160
- }
161
- `;
162
- const IconButton = styled.button `
163
- width: 28px;
164
- height: 28px;
165
- border: 0;
166
- border-radius: 8px;
167
- background: ${({ $active }) => ($active ? "#e0f2fe" : "transparent")};
168
- color: ${({ $active }) => ($active ? "#0369a1" : "#374151")};
169
- display: inline-flex;
170
- align-items: center;
171
- justify-content: center;
172
- padding: 0;
173
- cursor: pointer;
174
- transition:
175
- background 0.15s ease,
176
- color 0.15s ease;
177
-
178
- &:hover,
179
- &:focus-visible {
180
- background: #eef2f7;
181
- outline: none;
182
- }
183
- `;
184
- const CopyAddressCta = styled.button `
185
- width: 100%;
186
- min-height: 44px;
187
- border: 0;
188
- border-radius: 8px;
189
- background: ${({ isCopied }) => (isCopied ? "#ecfdf5" : "#f1f3fb")};
190
- color: ${({ isCopied }) => (isCopied ? "#047857" : "#111827")};
191
- display: inline-flex;
192
- align-items: center;
193
- justify-content: center;
194
- gap: 8px;
195
- padding: 0 14px;
196
- font-size: 15px;
197
- line-height: 1.2;
198
- font-weight: 700;
199
- cursor: pointer;
200
- transition:
201
- background 0.15s ease,
202
- color 0.15s ease,
203
- transform 0.15s ease;
204
-
205
- &:hover,
206
- &:focus-visible {
207
- background: ${({ isCopied }) => (isCopied ? "#dcfce7" : "#e8edf7")};
208
- outline: none;
209
- }
210
-
211
- &:active {
212
- transform: translateY(1px);
213
- }
214
- `;
215
- const OptionList = styled.div `
216
- display: flex;
217
- flex-direction: column;
218
- gap: 8px;
219
- min-height: 0;
220
- max-height: min(34vh, 300px);
221
- overflow-y: auto;
222
- overscroll-behavior: contain;
223
- scrollbar-width: none;
224
-
225
- &::-webkit-scrollbar {
226
- display: none;
227
- }
228
- `;
229
- const SelectionSectionLabel = styled.div `
230
- font-size: 12px;
231
- font-weight: 600;
232
- line-height: 1.3;
233
- color: #94a3b8;
234
- padding: 0 2px;
235
- `;
236
- const SelectionRow = styled.button `
237
- width: 100%;
238
- min-height: 72px;
239
- border: 1px solid #eef2f6;
240
- border-radius: 16px;
241
- background: #ffffff;
242
- display: flex;
243
- align-items: center;
244
- justify-content: space-between;
245
- gap: 12px;
246
- padding: 12px 14px;
247
- cursor: pointer;
248
- text-align: left;
249
- color: inherit;
250
- transition:
251
- border-color 140ms ease,
252
- box-shadow 140ms ease,
253
- transform 140ms ease,
254
- background-color 140ms ease;
255
-
256
- &:hover,
257
- &:focus-visible {
258
- border-color: #cdd9e3;
259
- box-shadow: 0 6px 14px rgba(15, 23, 42, 0.05);
260
- transform: translateY(-1px);
261
- outline: none;
262
- }
263
-
264
- &:disabled {
265
- cursor: not-allowed;
266
- opacity: 0.65;
267
- }
268
- `;
269
- const SelectionRowLeft = styled.div `
270
- display: flex;
271
- align-items: center;
272
- gap: 12px;
273
- min-width: 0;
274
- `;
275
- const SelectionIcon = styled.div `
276
- position: relative;
277
- width: 40px;
278
- height: 40px;
279
- border-radius: 999px;
280
- flex-shrink: 0;
281
- display: inline-flex;
282
- align-items: center;
283
- justify-content: center;
284
- font-size: 11px;
285
- font-weight: 700;
286
- color: #1f2937;
287
- background: #eef2f7;
288
- overflow: hidden;
289
- `;
290
- const SelectionIconFallback = styled.span `
291
- position: relative;
292
- z-index: 0;
293
- `;
294
- const SelectionIconImage = styled.img `
295
- position: absolute;
296
- inset: 6px;
297
- z-index: 1;
298
- width: calc(100% - 12px);
299
- height: calc(100% - 12px);
300
- object-fit: contain;
301
- `;
302
- const SelectionText = styled.div `
303
- display: flex;
304
- flex-direction: column;
305
- gap: 2px;
306
- min-width: 0;
307
- `;
308
- const SelectionTitle = styled.span `
309
- font-size: 14px;
310
- line-height: 1.3;
311
- font-weight: 600;
312
- color: #111827;
313
- overflow: hidden;
314
- text-overflow: ellipsis;
315
- white-space: nowrap;
316
- `;
317
- const SelectionSubtitle = styled.span `
318
- font-size: 12px;
319
- line-height: 1.3;
320
- color: #6b7280;
321
- overflow: hidden;
322
- text-overflow: ellipsis;
323
- white-space: nowrap;
324
- `;
325
- const SelectionMeta = styled.span `
326
- font-size: 12px;
327
- line-height: 1.3;
328
- color: #7c83a5;
329
- white-space: nowrap;
330
- flex-shrink: 0;
331
- `;
332
- const SelectionBadge = styled.span `
333
- display: inline-flex;
334
- align-items: center;
335
- border-radius: 999px;
336
- gap: 4px;
337
- background: #ecfdf5;
338
- color: #047857;
339
- font-size: 11px;
340
- font-weight: 600;
341
- line-height: 1;
342
- padding: 4px 8px;
343
- white-space: nowrap;
344
- flex-shrink: 0;
345
- `;
25
+ import { ManualPaymentRefresh } from "./manual-refresh.js";
26
+ import { ManualRefundPreference } from "./manual-refund-preference.js";
27
+ import { ManualRoutePicker } from "./manual-route-picker.js";
28
+ import { getChainAbbreviation, getManualChainIconUrl, getManualInstructionSource, getMonogram, getSourceTokenSymbol, isEvmAddress, manualOptionLookupKey, manualPaymentOptionToCurrency, uniqueSourceOptions, useManualPaymentOptions, } from "./manual-sources.js";
29
+ import { getManualTransferInstructions, manualInstructionsMatchFunding, } from "./manual-transfer-instructions.js";
30
+ import { PaymentRouteError } from "./payment-route-error.js";
346
31
  const TokenIconWrap = styled.div `
347
32
  position: relative;
348
33
  width: 42px;
@@ -436,209 +121,36 @@ const ErrorCard = styled.div `
436
121
  align-items: center;
437
122
  gap: 8px;
438
123
  `;
439
- const spin = keyframes `
440
- to { transform: rotate(360deg); }
441
- `;
442
- const RefreshCard = styled.div `
443
- background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
444
- border: 1px solid #e8eef3;
445
- border-radius: 14px;
446
- padding: 18px;
447
- margin: 8px 0;
448
- display: flex;
449
- align-items: center;
450
- gap: 12px;
451
- box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
452
- `;
453
- const RefreshSpinner = styled.div `
454
- width: 30px;
455
- height: 30px;
456
- border-radius: 999px;
457
- border: 3px solid #d1fae5;
458
- border-top-color: #10b981;
459
- flex-shrink: 0;
460
- animation: ${spin} 0.8s linear infinite;
461
- `;
462
- const RefreshTitle = styled.div `
463
- display: flex;
464
- flex-direction: column;
465
- gap: 2px;
466
- min-width: 0;
467
- `;
468
- const isEvmAddress = (value) => /^0x[0-9a-fA-F]{40}$/.test(value);
469
- const isValidRefundAddressForSource = (value, _source) => isEvmAddress(value);
470
- const shouldResetManualRefundWalletForSource = (value, source) => {
471
- const trimmedValue = value.trim();
472
- return (trimmedValue.length > 0 &&
473
- !isValidRefundAddressForSource(trimmedValue, source));
474
- };
475
- const getManualAttemptErrorMessage = (error) => {
476
- const responseError = typeof error === "object" && error !== null && "error" in error
477
- ? error.error
478
- : null;
479
- const apiError = typeof responseError === "object" &&
480
- responseError !== null &&
481
- "error" in responseError
482
- ? responseError.error
483
- : null;
484
- const apiMessage = typeof apiError === "string" ? apiError : "";
485
- const message = error instanceof Error
486
- ? error.message
487
- : apiMessage || (typeof error === "string" ? error : "");
488
- return message || "We couldn't generate payment details. Please try again.";
489
- };
490
- 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" })] }));
491
- const getMonogram = (value) => {
492
- const parts = value
493
- .split(/\s+/)
494
- .map((part) => part.trim())
495
- .filter(Boolean);
496
- if (parts.length === 0) {
497
- return "?";
498
- }
499
- if (parts.length === 1) {
500
- return parts[0].slice(0, 2).toUpperCase();
501
- }
502
- return `${parts[0][0]}${parts[1][0]}`.toUpperCase();
503
- };
504
- const getChainAbbreviation = (chainName) => {
505
- const normalized = chainName.toLowerCase();
506
- if (normalized === "base")
507
- return "B";
508
- if (normalized === "ethereum")
509
- return "ETH";
510
- return getMonogram(chainName);
511
- };
512
- const getManualChainIconUrl = (source) => {
513
- const normalizedChain = source.chain.toLowerCase();
514
- const normalizedChainName = source.chain_name.toLowerCase();
515
- if (normalizedChain === "eip155:1" || normalizedChainName === "ethereum") {
516
- return ETHEREUM_ICON_URL;
517
- }
518
- return source.chain_logo_url ?? null;
519
- };
520
- const SelectionIconView = ({ iconUrl, fallback, }) => {
521
- const [failedIconUrl, setFailedIconUrl] = useState(null);
522
- const resolvedIconUrl = iconUrl && iconUrl !== failedIconUrl ? iconUrl : null;
523
- useEffect(() => {
524
- setFailedIconUrl(null);
525
- }, [iconUrl]);
526
- return (_jsx(SelectionIcon, { children: resolvedIconUrl ? (_jsx(SelectionIconImage, { src: resolvedIconUrl, alt: "", "aria-hidden": "true", onError: () => setFailedIconUrl(resolvedIconUrl) })) : (_jsx(SelectionIconFallback, { children: fallback })) }));
527
- };
528
- const formatManualPaymentAmount = (amount, currency) => {
529
- const amountText = String(amount);
530
- return `${amountText} ${currency}`;
531
- };
532
- const shouldUseRawManualAmount = (chainName, currency) => {
533
- const normalizedChain = chainName.toLowerCase();
534
- const normalizedCurrency = currency.toLowerCase();
535
- return (normalizedChain.includes("sepolia") ||
536
- normalizedChain.includes("testnet") ||
537
- normalizedCurrency.includes("mock"));
538
- };
539
- const isTestnetOrMockCurrency = (currency) => shouldUseRawManualAmount(currency.chain_name, currency.asset_name) ||
540
- shouldUseRawManualAmount(currency.chain, currency.asset);
541
- const shouldLoadManualPaymentOptions = (currency) => !isTestnetOrMockCurrency(currency);
542
- const sourceKey = (source) => `${source.chain}__${source.asset}`;
543
- const normalizeOptionalAddress = (address) => address?.trim().toLowerCase() || null;
544
- const uniqueSourceOptions = (settlementCurrency, configuredSources) => {
545
- const options = [settlementCurrency, ...(configuredSources ?? [])];
546
- const seen = new Set();
547
- return options.filter((option) => {
548
- const key = sourceKey(option);
549
- if (seen.has(key))
550
- return false;
551
- seen.add(key);
552
- return true;
553
- });
554
- };
555
- const getManualPaymentAttemptMode = (source, settlementCurrency) => source.asset.toLowerCase() === settlementCurrency.asset.toLowerCase() &&
556
- source.chain.toLowerCase() === settlementCurrency.chain.toLowerCase()
557
- ? undefined
558
- : "relay_deposit";
559
- const manualPaymentOptionToCurrency = (option) => ({
560
- chain: option.from_chain.caip2,
561
- asset: option.from_token.caip21,
562
- chain_name: option.from_chain.name,
563
- asset_name: option.from_token.name,
564
- asset_id: option.id,
565
- logo_url: option.from_token.logo_url,
566
- chain_logo_url: option.from_chain.logo_url,
567
- });
568
- const manualPaymentOptionKey = (option) => `${option.from_chain.caip2}__${option.from_token.caip21}`;
569
- const manualOptionLookupKey = (source) => `${source.chain}__${source.asset}`.toLowerCase();
570
- const getSourceTokenSymbol = (source, manualOptions) => manualOptions.find((option) => manualPaymentOptionKey(option).toLowerCase() ===
571
- manualOptionLookupKey(source))?.from_token.symbol ?? source.asset_name;
572
- const getSourceTokenGroupKey = (source, manualOptions) => getSourceTokenSymbol(source, manualOptions).toLowerCase();
573
- const uniqueSourceTokens = (options, manualOptions) => {
574
- const seen = new Set();
575
- return options.filter((option) => {
576
- const key = getSourceTokenGroupKey(option, manualOptions);
577
- if (seen.has(key))
578
- return false;
579
- seen.add(key);
580
- return true;
581
- });
582
- };
583
- const uniqueSourceChains = (options) => {
584
- const seen = new Set();
585
- return options.filter((option) => {
586
- if (seen.has(option.chain))
587
- return false;
588
- seen.add(option.chain);
589
- return true;
590
- });
591
- };
592
- const getManualInstructionSource = (instructions) => {
593
- if (!instructions)
594
- return null;
595
- if ("source_chain" in instructions &&
596
- "source_token" in instructions &&
597
- typeof instructions.source_chain === "string" &&
598
- typeof instructions.source_token === "string") {
599
- return {
600
- chain: instructions.source_chain,
601
- token: instructions.source_token,
602
- };
603
- }
604
- const tokenTransferInstructions = instructions;
605
- if (typeof tokenTransferInstructions.chain === "string" &&
606
- typeof tokenTransferInstructions.token === "string") {
607
- return {
608
- chain: tokenTransferInstructions.chain,
609
- token: tokenTransferInstructions.token,
610
- };
611
- }
612
- return null;
613
- };
614
- const manualAttemptKey = (attempt) => {
615
- const instructions = attempt?.payment_instructions;
616
- if (!instructions)
617
- return null;
618
- const instructionSource = getManualInstructionSource(instructions);
619
- const requestId = "request_id" in instructions ? instructions.request_id : null;
620
- return [
621
- requestId,
622
- instructionSource?.chain,
623
- instructionSource?.token,
624
- instructions.payment_address ?? attempt.destination_address,
625
- ]
626
- .filter(Boolean)
627
- .join(":");
628
- };
629
- const CryptoIntentDirectDetailsViewContent = () => {
630
- const modalRef = useRef(null);
631
- const dismissedAttemptKeyRef = useRef(null);
632
- const hasAutoPrefilledRefundWalletRef = useRef(false);
633
- const { goToView } = useModalWithView();
124
+ const MANUAL_ATTEMPT_FAILED_MESSAGE = "We couldn't generate payment details. Please try again.";
125
+ const MANUAL_TRANSFER_IN_PROGRESS = "This transfer is already being processed.";
126
+ const CryptoIntentDirectDetailsViewContent = ({ onPaymentSelectionChange, hostedRecovery, }) => {
127
+ const isIssuingRef = useRef(false);
128
+ const { goToView, viewProps } = useModalWithView();
634
129
  const connectedAccount = useAccount();
635
- const { cryptoPaymentAttempt, cryptoCurrency, payment, quote } = useCheckoutStore();
130
+ const checkoutState = useCheckoutStore();
131
+ const { cryptoPaymentAttempt, cryptoCurrency, manualTransfer, payment, quote, } = checkoutState;
132
+ const phase = derivePaymentPhase(payment);
133
+ const shortfall = pendingShortfall(phase);
134
+ const instructions = cryptoPaymentAttempt?.payment_instructions;
135
+ const instructionSource = getManualInstructionSource(instructions ?? null);
136
+ const issuedRouteKey = instructionSource
137
+ ? manualOptionLookupKey({
138
+ asset: instructionSource.token,
139
+ chain: instructionSource.chain,
140
+ })
141
+ : null;
142
+ const canIssueInstructions = canCreateFreshAttempt(payment) &&
143
+ phase.kind !== "funded" &&
144
+ !phase.relayTransferDetected;
145
+ // Once issued, the refund recipient is fixed and never sent again (QCT D1).
146
+ const isIssued = isCheckoutIssued(checkoutState);
147
+ const frozenRefundTo = getFrozenRefundRecipient(checkoutState);
636
148
  const config = useMintMoneyConfig();
637
149
  const fallbackSourceOptions = useMemo(() => cryptoCurrency
638
150
  ? uniqueSourceOptions(cryptoCurrency, config.cryptoCheckoutConfig.directPaymentSources)
639
151
  : [], [cryptoCurrency, config.cryptoCheckoutConfig.directPaymentSources]);
640
- const [manualPaymentOptions, setManualPaymentOptions] = useState([]);
641
- const [manualPaymentOptionsStatus, setManualPaymentOptionsStatus] = useState("idle");
152
+ const { manualPaymentOptions, manualPaymentOptionsStatus } = useManualPaymentOptions(payment?.id, cryptoCurrency);
153
+ const loadingSources = manualPaymentOptionsStatus === "loading";
642
154
  const manualOptionSources = useMemo(() => manualPaymentOptions.map(manualPaymentOptionToCurrency), [manualPaymentOptions]);
643
155
  const sourceOptions = useMemo(() => {
644
156
  if (cryptoCurrency &&
@@ -653,168 +165,134 @@ const CryptoIntentDirectDetailsViewContent = () => {
653
165
  manualOptionSources,
654
166
  manualPaymentOptionsStatus,
655
167
  ]);
656
- const [copiedAddress, setCopiedAddress] = useState(false);
657
- const [copiedAmount, setCopiedAmount] = useState(false);
658
- const [hasAcknowledged, setHasAcknowledged] = useState(false);
168
+ const [localInstructionView, setInstructionView] = useState("picker");
169
+ const reviewingIssuedInstructions = viewProps.showIssuedInstructions === true && Boolean(instructions);
170
+ const instructionView = reviewingIssuedInstructions
171
+ ? "reopened"
172
+ : localInstructionView;
173
+ const showInstructions = instructionView !== "picker";
174
+ const reopened = instructionView === "reopened";
175
+ const reopenedQuoteExpired = reopened && isAttemptStale(cryptoPaymentAttempt);
176
+ const readOnly = showInstructions &&
177
+ (!canIssueInstructions ||
178
+ reopenedQuoteExpired ||
179
+ (reopened && viewProps.readOnly === true));
180
+ const transferShortfall = readOnly
181
+ ? (manualTransfer?.shortfall ?? null)
182
+ : shortfall;
659
183
  const [paymentDetailsExpanded, setPaymentDetailsExpanded] = useState(false);
660
- const [refundEditorExpanded, setRefundEditorExpanded] = useState(false);
661
- const [refundWallet, setRefundWallet] = useState("");
662
- const [selectedSourceKey, setSelectedSourceKey] = useState(sourceOptions[0] ? sourceKey(sourceOptions[0]) : "");
663
- const [selectedTokenKey, setSelectedTokenKey] = useState("");
664
- const [manualSetupStep, setManualSetupStep] = useState("token");
665
- const [showQrCode, setShowQrCode] = useState(false);
184
+ const [refundWallet, setRefundWallet] = useState(null);
666
185
  const [refundWalletError, setRefundWalletError] = useState(null);
667
- const [isCreatingAttempt, setIsCreatingAttempt] = useState(false);
668
- const [manualQuoteTick, setManualQuoteTick] = useState(0);
669
- const attemptIsStale = isAttemptStale(cryptoPaymentAttempt);
670
- const attemptQuoteTiming = useMemo(() => getAttemptQuoteTiming(cryptoPaymentAttempt), [cryptoPaymentAttempt, manualQuoteTick]);
671
- const countdownRemainingMs = quote.remainingMs ?? attemptQuoteTiming.remainingMs;
672
- const countdownTotalDurationMs = quote.totalDurationMs ?? attemptQuoteTiming.totalDurationMs;
673
- const setAcknowledgedWithTransition = (value) => {
674
- if (document.startViewTransition) {
675
- document.startViewTransition(() => {
676
- setHasAcknowledged(value);
677
- });
678
- return;
679
- }
680
- setHasAcknowledged(value);
681
- };
682
- useEffect(() => {
683
- if (!hasAcknowledged) {
684
- clearQuoteRefresh();
685
- return undefined;
686
- }
687
- configureManualQuoteRefresh();
688
- return () => {
689
- clearQuoteRefresh();
690
- };
691
- }, [hasAcknowledged]);
186
+ const [issuingSource, setIssuingSource] = useState(null);
187
+ const [isConfirmingTransfer, setIsConfirmingTransfer] = useState(false);
188
+ const confirmationInFlight = useRef(false);
189
+ useLayoutEffect(() => () => {
190
+ confirmationInFlight.current = false;
191
+ }, []);
192
+ const [revealError, setRevealError] = useState(null);
193
+ const countdown = useQuoteCountdown(quote, showInstructions ? cryptoPaymentAttempt : null);
194
+ const funding = payment?.funding;
195
+ const receivedFunds = hasReceivedFunds(funding);
196
+ const expiredWithoutTransfer = phase.cutoffPassed &&
197
+ !phase.broadcast &&
198
+ !receivedFunds &&
199
+ ["awaiting_deposit", "relay_delivered_nothing", "failed"].includes(phase.kind);
200
+ const settlementCurrency = cryptoPaymentAttempt?.settlement_config ?? cryptoCurrency;
201
+ const [resumeSelection, setResumeSelection] = useState(() => {
202
+ const selection = viewProps.resumePaymentSelection;
203
+ return !isIssued && selection?.kind === "manual" ? selection : undefined;
204
+ });
205
+ const resumeSource = resumeSelection &&
206
+ settlementCurrency &&
207
+ getManualPaymentAttemptMode(resumeSelection, settlementCurrency) ===
208
+ undefined
209
+ ? settlementCurrency
210
+ : null;
211
+ // Issued instructions are payable while the payment accepts funds and
212
+ // Relay's quote still matches what is due.
213
+ const instructionsOutdated = !acceptsFunds(phase) ||
214
+ !manualInstructionsMatchFunding(cryptoPaymentAttempt, shortfall);
692
215
  useEffect(() => {
693
- if (!hasAcknowledged || !cryptoPaymentAttempt)
216
+ if (!showInstructions ||
217
+ reopened ||
218
+ readOnly ||
219
+ isConfirmingTransfer ||
220
+ expiredWithoutTransfer)
694
221
  return;
695
222
  configureManualQuoteRefresh();
696
- }, [cryptoPaymentAttempt, hasAcknowledged]);
697
- useEffect(() => {
698
- if (!hasAcknowledged ||
699
- quote.remainingMs !== null ||
700
- attemptQuoteTiming.expiresAt === null) {
701
- return undefined;
702
- }
703
- const interval = window.setInterval(() => {
704
- setManualQuoteTick((tick) => tick + 1);
705
- }, 1000);
706
- return () => {
707
- window.clearInterval(interval);
708
- };
709
- }, [attemptQuoteTiming.expiresAt, hasAcknowledged, quote.remainingMs]);
710
- useEffect(() => {
711
- if (!payment?.id ||
712
- !cryptoCurrency ||
713
- !shouldLoadManualPaymentOptions(cryptoCurrency)) {
714
- setManualPaymentOptions([]);
715
- setManualPaymentOptionsStatus("idle");
716
- return undefined;
717
- }
718
- let cancelled = false;
719
- setManualPaymentOptionsStatus("loading");
720
- getManualPaymentOptions(payment.id)
721
- .then((options) => {
722
- if (cancelled)
723
- return;
724
- setManualPaymentOptions(options);
725
- setManualPaymentOptionsStatus("ready");
726
- })
727
- .catch((error) => {
728
- if (cancelled)
729
- return;
730
- console.error("Failed to load manual payment options:", error);
731
- setManualPaymentOptions([]);
732
- setManualPaymentOptionsStatus("failed");
733
- });
734
- return () => {
735
- cancelled = true;
736
- };
737
- }, [cryptoCurrency, payment?.id]);
738
- useEffect(() => {
739
- const selectedSourceIsAvailable = sourceOptions.some((option) => sourceKey(option) === selectedSourceKey);
740
- if (!selectedSourceIsAvailable && sourceOptions[0]) {
741
- setSelectedSourceKey(sourceKey(sourceOptions[0]));
742
- }
743
- }, [selectedSourceKey, sourceOptions]);
744
- useEffect(() => {
745
- const currentSource = sourceOptions.find((option) => sourceKey(option) === selectedSourceKey);
746
- const nextTokenKey = currentSource
747
- ? getSourceTokenGroupKey(currentSource, manualPaymentOptions)
748
- : "";
749
- const selectedTokenIsAvailable = sourceOptions.some((option) => getSourceTokenGroupKey(option, manualPaymentOptions) ===
750
- selectedTokenKey);
751
- if (nextTokenKey && (!selectedTokenKey || !selectedTokenIsAvailable)) {
752
- setSelectedTokenKey(nextTokenKey);
753
- }
223
+ return () => clearQuoteRefresh();
754
224
  }, [
755
- manualPaymentOptions,
756
- selectedSourceKey,
757
- selectedTokenKey,
758
- sourceOptions,
225
+ expiredWithoutTransfer,
226
+ isConfirmingTransfer,
227
+ readOnly,
228
+ reopened,
229
+ showInstructions,
759
230
  ]);
760
231
  useEffect(() => {
761
- if (!hasAcknowledged)
762
- return;
763
- const instructions = cryptoPaymentAttempt?.payment_instructions;
764
- if (!instructions)
765
- return;
766
- const attemptKey = manualAttemptKey(cryptoPaymentAttempt);
767
- if (!attemptKey || dismissedAttemptKeyRef.current === attemptKey)
768
- return;
769
- const instructionSource = getManualInstructionSource(instructions);
770
- if (!instructionSource)
771
- return;
772
- const attemptSource = sourceOptions.find((option) => option.asset.toLowerCase() === instructionSource.token.toLowerCase() &&
773
- option.chain.toLowerCase() === instructionSource.chain.toLowerCase());
774
- if (attemptSource) {
775
- setSelectedSourceKey(sourceKey(attemptSource));
232
+ if (showInstructions &&
233
+ !readOnly &&
234
+ instructionsOutdated &&
235
+ !expiredWithoutTransfer &&
236
+ quote.status !== "refreshing") {
237
+ goToView("paymentStatus");
776
238
  }
777
- setHasAcknowledged(true);
778
239
  }, [
779
- cryptoPaymentAttempt,
780
- cryptoPaymentAttempt?.payment_instructions,
781
- hasAcknowledged,
782
- sourceOptions,
240
+ expiredWithoutTransfer,
241
+ goToView,
242
+ instructionsOutdated,
243
+ quote.status,
244
+ readOnly,
245
+ showInstructions,
783
246
  ]);
784
- useEffect(() => {
785
- if (hasAcknowledged || refundEditorExpanded || refundWallet)
247
+ const paymentId = payment?.id;
248
+ const directInstructions = instructions?.type === "token_transfer" ? instructions : null;
249
+ const manualAsset = directInstructions?.token;
250
+ const manualChain = directInstructions?.chain;
251
+ const continueManualPayment = showInstructions &&
252
+ !phase.broadcast &&
253
+ !receivedFunds &&
254
+ !isConfirmingTransfer &&
255
+ !reopened;
256
+ useLayoutEffect(() => {
257
+ if (!continueManualPayment || !paymentId || !manualAsset || !manualChain)
786
258
  return;
787
- const attemptRefundTo = cryptoPaymentAttempt?.refund_to?.trim();
788
- if (attemptRefundTo) {
789
- setRefundWallet(attemptRefundTo);
790
- }
259
+ onPaymentSelectionChange?.(paymentId, {
260
+ kind: "manual",
261
+ asset: manualAsset,
262
+ chain: manualChain,
263
+ refundTo: frozenRefundTo,
264
+ });
265
+ return () => onPaymentSelectionChange?.(paymentId, null);
791
266
  }, [
792
- cryptoPaymentAttempt?.refund_to,
793
- hasAcknowledged,
794
- refundEditorExpanded,
795
- refundWallet,
267
+ continueManualPayment,
268
+ frozenRefundTo,
269
+ manualAsset,
270
+ manualChain,
271
+ onPaymentSelectionChange,
272
+ paymentId,
796
273
  ]);
797
274
  useEffect(() => {
798
- if (hasAcknowledged ||
799
- refundEditorExpanded ||
800
- refundWallet ||
801
- hasAutoPrefilledRefundWalletRef.current ||
802
- !connectedAccount.address)
803
- return;
804
- hasAutoPrefilledRefundWalletRef.current = true;
805
- setRefundWallet(connectedAccount.address);
806
- }, [
807
- connectedAccount.address,
808
- hasAcknowledged,
809
- refundEditorExpanded,
810
- refundWallet,
811
- ]);
275
+ if (!isIssued && !showInstructions && connectedAccount.address) {
276
+ const address = connectedAccount.address;
277
+ setRefundWallet((current) => current ?? address);
278
+ }
279
+ }, [connectedAccount.address, isIssued, showInstructions]);
812
280
  const handleConfirm = async () => {
813
- const isCurrent = captureCheckoutOpening();
814
- if (!payment?.id) {
281
+ if (confirmationInFlight.current ||
282
+ (reopened && isAttemptStale(cryptoPaymentAttempt)))
283
+ return;
284
+ if (!payment?.id || !cryptoPaymentAttempt) {
815
285
  goToView("failed", { reason: "confirm_payment" });
816
286
  return;
817
287
  }
288
+ recordManualTransfer(manualTransferFor(cryptoPaymentAttempt, transferShortfall));
289
+ if (readOnly) {
290
+ goToView("paymentStatus");
291
+ return;
292
+ }
293
+ confirmationInFlight.current = true;
294
+ const isCurrent = captureCheckoutOpening(() => confirmationInFlight.current);
295
+ setIsConfirmingTransfer(true);
818
296
  try {
819
297
  await confirmPayment(payment.id);
820
298
  if (!isCurrent())
@@ -824,239 +302,161 @@ const CryptoIntentDirectDetailsViewContent = () => {
824
302
  catch (error) {
825
303
  if (!isCurrent())
826
304
  return;
305
+ const latestPayment = useCheckoutStore.getState().payment;
306
+ const latestPhase = derivePaymentPhase(latestPayment);
307
+ if (latestPhase.relayTransferDetected || !isPendingPhase(latestPhase)) {
308
+ confirmationInFlight.current = false;
309
+ setIsConfirmingTransfer(false);
310
+ return;
311
+ }
312
+ const received = BigInt(latestPayment?.funding?.received_amount ?? "0");
313
+ const receivedAtSubmission = BigInt(funding?.received_amount ?? "0");
314
+ if (received > receivedAtSubmission) {
315
+ goToView("paymentStatus");
316
+ return;
317
+ }
827
318
  console.error("Failed to confirm payment:", error);
828
319
  goToView("failed", { reason: "confirm_payment" });
829
320
  }
830
321
  };
831
- if (!cryptoCurrency) {
832
- return null;
833
- }
834
- // Action needed: the quote refresh failed. No funds have been sent under a
835
- // stale address, so the recovery is simply to fetch a fresh amount again.
836
- if (quote.status === "failed") {
837
- 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 ??
838
- "We couldn't get a fresh payment amount. Please try again." })] }), _jsxs(SetupActions, { children: [_jsx(StyledButton, { onClick: () => {
839
- void refreshQuote();
840
- }, variant: "primary", style: { marginTop: 8 }, children: "Try again" }), _jsx(ModalBackButton, { view: "cryptoIntent" })] })] }));
841
- }
842
- // Quote refreshing: the address/route was stale or missing, so Mint is
843
- // fetching a fresh payable amount — no expiry dead-end.
844
- if (quote.status === "refreshing") {
845
- 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..." })] })] }) }));
846
- }
847
- const settlementCurrency = cryptoPaymentAttempt?.settlement_config ?? cryptoCurrency;
848
- const selectedSource = sourceOptions.find((option) => sourceKey(option) === selectedSourceKey) ??
849
- sourceOptions[0] ??
850
- cryptoCurrency;
851
- const tokenOptions = uniqueSourceTokens(sourceOptions, manualPaymentOptions);
852
- const activeTokenKey = selectedTokenKey ||
853
- getSourceTokenGroupKey(selectedSource, manualPaymentOptions);
854
- const networkOptions = sourceOptions.filter((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === activeTokenKey);
855
- const uniqueNetworkOptions = uniqueSourceChains(networkOptions);
856
- const selectedTokenOption = tokenOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === activeTokenKey);
857
- const instructions = cryptoPaymentAttempt?.payment_instructions ?? null;
858
- const instructionSource = getManualInstructionSource(instructions);
859
- const amount = cryptoPaymentAttempt?.amount_formatted;
860
- const currency = settlementCurrency.asset_name;
861
- const chain = settlementCurrency.chain_name;
862
- const sourceCurrency = selectedSource?.asset_name ?? currency;
863
- const sourceChain = selectedSource?.chain_name ?? chain;
864
- const trimmedRefundWallet = refundWallet.trim();
865
- const issuedPaymentAddress = instructions?.payment_address ?? cryptoPaymentAttempt?.destination_address;
866
- const manualRefundWallet = trimmedRefundWallet;
867
- const refundPreferenceChanged = normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) !==
868
- normalizeOptionalAddress(manualRefundWallet);
869
- const sourceMatchesSettlementCurrency = (source) => source.asset.toLowerCase() === settlementCurrency.asset.toLowerCase() &&
870
- source.chain.toLowerCase() === settlementCurrency.chain.toLowerCase();
871
- const canReuseAttemptForSource = (source, sourceRefundWallet = manualRefundWallet) => Boolean(instructionSource &&
872
- instructionSource.token.toLowerCase() === source.asset.toLowerCase() &&
873
- instructionSource.chain.toLowerCase() === source.chain.toLowerCase() &&
874
- normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) ===
875
- normalizeOptionalAddress(sourceRefundWallet) &&
876
- !attemptIsStale);
877
- const tokenHasFastManualRoute = (token) => sourceOptions.some((option) => getSourceTokenGroupKey(option, manualPaymentOptions) ===
878
- getSourceTokenGroupKey(token, manualPaymentOptions) &&
879
- (sourceMatchesSettlementCurrency(option) ||
880
- manualPaymentOptions.some((manualOption) => manualPaymentOptionKey(manualOption).toLowerCase() ===
881
- manualOptionLookupKey(option) && manualOption.kind === "direct")));
882
- const tokenIconUrl = selectedSource?.logo_url ?? settlementCurrency.logo_url ?? null;
883
- const chainIconUrl = getManualChainIconUrl(selectedSource ?? settlementCurrency);
884
- const rawAmount = cryptoPaymentAttempt?.amount === undefined
885
- ? null
886
- : String(cryptoPaymentAttempt.amount);
887
- const sourceAmountFormatted = instructions?.type === "relay_deposit_address"
888
- ? instructions.source_amount_formatted
889
- : (instructions?.amount_formatted ?? amount);
890
- const sourceAmountRaw = instructions?.type === "relay_deposit_address"
891
- ? instructions.source_amount
892
- : (instructions?.amount ?? rawAmount);
893
- const sourceTokenSymbol = getSourceTokenSymbol(selectedSource, manualPaymentOptions);
894
- const formattedAmount = sourceAmountFormatted === undefined
895
- ? null
896
- : formatManualPaymentAmount(sourceAmountFormatted, sourceCurrency);
897
- const useRawAmount = Boolean(sourceAmountRaw) &&
898
- sourceAmountRaw !== String(sourceAmountFormatted) &&
899
- shouldUseRawManualAmount(sourceChain, sourceCurrency);
900
- const sendAmount = useRawAmount ? sourceAmountRaw : formattedAmount;
901
- const copyAmount = useRawAmount
902
- ? sourceAmountRaw
903
- : sourceAmountFormatted === undefined
904
- ? null
905
- : String(sourceAmountFormatted);
906
- const paymentAddress = issuedPaymentAddress;
907
- const qrPayload = instructions?.type === "token_transfer"
908
- ? instructions.qr_payload
909
- : paymentAddress;
910
- const handleBackToSourceSetup = () => {
911
- dismissedAttemptKeyRef.current = manualAttemptKey(cryptoPaymentAttempt);
912
- setCopiedAddress(false);
913
- setCopiedAmount(false);
914
- setShowQrCode(false);
322
+ const manualRefundWallet = refundWallet?.trim() ?? "";
323
+ const clearPickerErrors = () => {
915
324
  setRefundWalletError(null);
916
- setRefundEditorExpanded(false);
917
- setPaymentDetailsExpanded(false);
918
- if (selectedSource &&
919
- shouldResetManualRefundWalletForSource(refundWallet, selectedSource)) {
920
- setRefundWallet("");
921
- }
922
- setIsCreatingAttempt(false);
923
- setHasAcknowledged(false);
924
- setManualSetupStep("network");
325
+ setRevealError(null);
925
326
  };
926
- const goBackInSetup = () => {
927
- setRefundWalletError(null);
928
- if (manualSetupStep === "network") {
929
- setManualSetupStep("token");
930
- return;
327
+ const validateRefundWallet = () => {
328
+ if (!isIssued && manualRefundWallet && !isEvmAddress(manualRefundWallet)) {
329
+ setRefundWalletError("Enter a valid EVM wallet address, or clear the field to use the merchant address.");
330
+ return false;
931
331
  }
932
- return;
933
- };
934
- const selectToken = (token) => {
935
- const nextTokenKey = getSourceTokenGroupKey(token, manualPaymentOptions);
936
- const firstNetworkForToken = sourceOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === nextTokenKey) ?? token;
937
- setSelectedTokenKey(nextTokenKey);
938
- setSelectedSourceKey(sourceKey(firstNetworkForToken));
939
- setManualSetupStep("network");
940
- setRefundWalletError(null);
332
+ return true;
941
333
  };
942
- const generateManualPaymentForSource = async (source, options = {}) => {
943
- const isCurrent = captureCheckoutOpening();
944
- const sourceRefundWallet = options.refundWallet ?? manualRefundWallet;
945
- if (sourceRefundWallet &&
946
- !isValidRefundAddressForSource(sourceRefundWallet, source)) {
947
- setRefundWalletError("Enter a valid EVM wallet address.");
948
- return false;
334
+ const revealManualPayment = async (source, resume) => {
335
+ if (isIssuingRef.current || !settlementCurrency)
336
+ return;
337
+ clearPickerErrors();
338
+ const matchesIssuedRoute = instructions?.payment_address &&
339
+ manualOptionLookupKey(source) === issuedRouteKey;
340
+ if (matchesIssuedRoute &&
341
+ (!canIssueInstructions ||
342
+ (!instructionsOutdated &&
343
+ !isAttemptStale(cryptoPaymentAttempt) &&
344
+ isManualTransferPending(cryptoPaymentAttempt, phase, manualTransfer)))) {
345
+ await transitionView(() => setInstructionView("reopened"));
346
+ return;
949
347
  }
950
- if (canReuseAttemptForSource(source, sourceRefundWallet)) {
951
- dismissedAttemptKeyRef.current = null;
952
- configureManualQuoteRefresh();
953
- setAcknowledgedWithTransition(true);
954
- return true;
348
+ if (payment && !canIssueInstructions) {
349
+ setRevealError(MANUAL_TRANSFER_IN_PROGRESS);
350
+ return;
955
351
  }
956
- setIsCreatingAttempt(true);
352
+ if (!resume && !validateRefundWallet())
353
+ return;
354
+ const isCurrent = captureCheckoutOpening();
355
+ const settlementRefundWallet = isIssued
356
+ ? null
357
+ : resume
358
+ ? resume.refundTo
359
+ : manualRefundWallet || null;
360
+ isIssuingRef.current = true;
361
+ setIssuingSource(source);
957
362
  try {
958
- const attempt = await createManualDirectPaymentAttempt("", 1, sourceRefundWallet || null, {
959
- mode: sourceMatchesSettlementCurrency(source)
960
- ? undefined
961
- : getManualPaymentAttemptMode(source, settlementCurrency),
363
+ await createManualDirectPaymentAttempt("", 1, settlementRefundWallet, {
364
+ mode: getManualPaymentAttemptMode(source, settlementCurrency),
962
365
  source,
963
366
  });
964
367
  if (!isCurrent())
965
- return false;
966
- setRefundWallet(attempt.refund_to ?? "");
967
- configureManualQuoteRefresh();
968
- setRefundEditorExpanded(false);
969
- setAcknowledgedWithTransition(true);
970
- return true;
368
+ return;
369
+ await transitionView(() => {
370
+ if (isCurrent())
371
+ setInstructionView("issued");
372
+ });
971
373
  }
972
374
  catch (error) {
973
375
  if (!isCurrent())
974
- return false;
376
+ return;
377
+ // The watcher handles the refreshed payment's outcome.
378
+ if (hasClosedPaymentMovedOn(error, useCheckoutStore.getState().payment)) {
379
+ setRevealError(MANUAL_TRANSFER_IN_PROGRESS);
380
+ return;
381
+ }
975
382
  console.error("Failed to create manual payment attempt:", error);
976
- goToView("failed", { reason: getManualAttemptErrorMessage(error) });
977
- return false;
383
+ setRevealError(describeRevealFailure(error, MANUAL_ATTEMPT_FAILED_MESSAGE));
978
384
  }
979
385
  finally {
980
- if (isCurrent())
981
- setIsCreatingAttempt(false);
982
- }
983
- };
984
- const selectNetwork = (network) => {
985
- const shouldResetRefundWallet = shouldResetManualRefundWalletForSource(refundWallet, network);
986
- const nextRefundWallet = shouldResetRefundWallet ? "" : manualRefundWallet;
987
- setSelectedSourceKey(sourceKey(network));
988
- setRefundWalletError(null);
989
- setRefundEditorExpanded(false);
990
- if (shouldResetRefundWallet) {
991
- setRefundWallet("");
992
- }
993
- setCopiedAddress(false);
994
- setCopiedAmount(false);
995
- setShowQrCode(false);
996
- void generateManualPaymentForSource(network, {
997
- refundWallet: nextRefundWallet,
998
- });
999
- };
1000
- const copyToClipboard = async (value, setCopied) => {
1001
- try {
1002
- await navigator.clipboard.writeText(value);
1003
- setCopied(true);
1004
- setTimeout(() => setCopied(false), 2000); // Reset after 2 seconds
1005
- }
1006
- catch (error) {
1007
- console.error("Failed to copy to clipboard:", error);
386
+ isIssuingRef.current = false;
387
+ if (isCurrent()) {
388
+ setIssuingSource(null);
389
+ if (resume)
390
+ setResumeSelection(undefined);
391
+ }
1008
392
  }
1009
393
  };
1010
- const renderManualPaymentPanel = (options) => (_jsxs(PaymentDetailsStack, { children: [options.showPaymentDetails ? (_jsx(QuoteExpiryCountdown, { remainingMs: countdownRemainingMs, totalDurationMs: countdownTotalDurationMs, primaryColor: config.theme.btn.primary.default.backgroundColor, urgentThresholdRatio: QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO })) : null, _jsx(ManualPaymentSummary, { icon: _jsxs(TokenIconWrap, { children: [_jsx(TokenIcon, { "$iconUrl": tokenIconUrl, children: tokenIconUrl ? null : getMonogram(sourceCurrency) }), _jsx(ChainBadge, { "$iconUrl": chainIconUrl, children: chainIconUrl ? null : getChainAbbreviation(sourceChain) })] }), tokenLabel: `${sourceTokenSymbol} on ${sourceChain}`, expanded: paymentDetailsExpanded, refundEditing: refundEditorExpanded, isSaving: isCreatingAttempt, refundAddress: cryptoPaymentAttempt?.refund_to, paymentTerms: cryptoPaymentAttempt?.payment_terms_snapshot, refundValue: refundWallet, refundError: refundWalletError, onToggle: () => setPaymentDetailsExpanded((expanded) => !expanded), onBeginRefundEdit: () => {
1011
- setPaymentDetailsExpanded(true);
1012
- setRefundWallet(cryptoPaymentAttempt?.refund_to ?? "");
1013
- setRefundWalletError(null);
1014
- setRefundEditorExpanded(true);
1015
- }, onSaveRefund: () => {
1016
- if (!refundPreferenceChanged) {
1017
- setRefundEditorExpanded(false);
1018
- setRefundWalletError(null);
1019
- return;
1020
- }
1021
- void generateManualPaymentForSource(selectedSource);
1022
- }, onRefundChange: (value) => {
1023
- setRefundWallet(value);
1024
- setRefundWalletError(null);
1025
- } }), options.showPaymentDetails &&
1026
- paymentAddress &&
1027
- sendAmount &&
1028
- copyAmount ? (_jsxs(PaymentInstructionCard, { children: [_jsxs("div", { children: [_jsxs(PaymentInstructionHeader, { children: [_jsx(PaymentInstructionLabel, { theme: config.theme, children: "Payment address" }), _jsx(IconButton, { type: "button", "$active": showQrCode, onClick: () => setShowQrCode((visible) => !visible), title: showQrCode ? "Hide QR code" : "Show QR code", "aria-label": showQrCode ? "Hide QR code" : "Show QR code", children: _jsx(QrCodeIcon, { size: 16 }) })] }), showQrCode ? (_jsx(QRCard, { children: _jsx(QRCode, { value: qrPayload ?? paymentAddress, size: 236 }) })) : (_jsx(AddressInfoRow, { isCopied: copiedAddress, onClick: () => copyToClipboard(paymentAddress, setCopiedAddress).catch((error) => {
1029
- console.error("Failed to copy address:", error);
1030
- }), 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) => {
1031
- console.error("Failed to copy address:", error);
1032
- }), children: [copiedAddress ? (_jsx(ClipboardCheckIcon, { size: 16 })) : (_jsx(ClipboardAddIcon, { size: 16 })), copiedAddress ? "Copied address" : "Copy address"] }), _jsx(PaymentInstructionDivider, {}), _jsxs("div", { children: [_jsx(PaymentInstructionHeader, { children: _jsx(PaymentInstructionLabel, { theme: config.theme, children: "Amount to send" }) }), _jsxs(AmountInfoRow, { isCopied: copiedAmount, onClick: () => copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
1033
- console.error("Failed to copy amount:", error);
1034
- }), title: "Click to copy amount", children: [_jsx(PaymentInstructionValue, { theme: config.theme, children: sendAmount }), _jsx(CopyButton, { isCopied: copiedAmount, onClick: (e) => {
1035
- e.stopPropagation();
1036
- copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
1037
- console.error("Failed to copy amount:", error);
1038
- });
1039
- }, title: "Copy amount", children: copiedAmount ? (_jsx(ClipboardCheckIcon, { size: 15 })) : (_jsx(ClipboardAddIcon, { size: 15 })) })] })] })] })) : null] }));
1040
- if (!hasAcknowledged) {
1041
- if (manualSetupStep === "token") {
1042
- return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select token" }), _jsx(OptionList, { children: tokenOptions.map((option) => {
1043
- const hasFastRoute = tokenHasFastManualRoute(option);
1044
- const tokenSymbol = getSourceTokenSymbol(option, manualPaymentOptions);
1045
- const showTokenName = option.asset_name.toLowerCase() !== tokenSymbol.toLowerCase();
1046
- return (_jsxs(SelectionRow, { type: "button", onClick: () => selectToken(option), children: [_jsxs(SelectionRowLeft, { children: [_jsx(SelectionIconView, { iconUrl: option.logo_url, fallback: getMonogram(option.asset_name) }), _jsxs(SelectionText, { children: [_jsx(SelectionTitle, { children: tokenSymbol }), showTokenName ? (_jsx(SelectionSubtitle, { children: option.asset_name })) : null] })] }), hasFastRoute ? (_jsxs(SelectionBadge, { children: [_jsx("span", { children: "\u26A1" }), _jsx("span", { children: "Fast" })] })) : null] }, getSourceTokenGroupKey(option, manualPaymentOptions)));
1047
- }) }), _jsx(SetupActions, { children: _jsx(ModalBackButton, { view: "cryptoIntent" }) })] }));
1048
- }
1049
- if (manualSetupStep === "network") {
1050
- const selectedTokenLabel = selectedTokenOption?.asset_name ?? sourceCurrency;
1051
- return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select network" }), _jsx(OptionList, { children: uniqueNetworkOptions.map((option) => (_jsxs(SelectionRow, { type: "button", onClick: () => selectNetwork(option), disabled: isCreatingAttempt, children: [_jsxs(SelectionRowLeft, { children: [_jsx(SelectionIconView, { iconUrl: getManualChainIconUrl(option), fallback: getChainAbbreviation(option.chain_name) }), _jsxs(SelectionText, { children: [_jsx(SelectionTitle, { children: option.chain_name }), _jsx(SelectionSubtitle, { children: selectedTokenLabel })] })] }), isCreatingAttempt &&
1052
- sourceKey(option) === selectedSourceKey ? (_jsx(SelectionMeta, { children: "Generating..." })) : null] }, sourceKey(option)))) }), _jsx(SetupActions, { children: _jsx(StyledButton, { onClick: goBackInSetup, variant: "secondary", children: "Back" }) })] }));
1053
- }
394
+ useEffect(() => {
395
+ if (!resumeSelection || !resumeSource || !paymentId || isIssued)
396
+ return;
397
+ void revealManualPayment(resumeSource, resumeSelection);
398
+ }, [isIssued, paymentId, resumeSelection, resumeSource, revealManualPayment]);
399
+ if (!cryptoCurrency || !settlementCurrency) {
1054
400
  return null;
1055
401
  }
1056
- if (!cryptoPaymentAttempt || !sendAmount || !copyAmount || !paymentAddress) {
402
+ const expired = showInstructions && expiredWithoutTransfer;
403
+ const refreshing = (expired &&
404
+ continueManualPayment &&
405
+ directInstructions &&
406
+ (hostedRecovery === "checking" || hostedRecovery === "available")) ||
407
+ (showInstructions && !issuingSource && quote.status === "refreshing") ||
408
+ (resumeSource && !showInstructions && !revealError);
409
+ if (!readOnly && (refreshing || expired)) {
410
+ return _jsx(ManualPaymentRefresh, { expired: !refreshing });
411
+ }
412
+ // Action needed: the quote refresh failed. No funds have been sent under a
413
+ // stale address, so the recovery is simply to fetch a fresh amount again.
414
+ if (!readOnly &&
415
+ showInstructions &&
416
+ !issuingSource &&
417
+ quote.status === "failed") {
418
+ return (_jsxs(ModalViewContainer, { 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(PaymentRouteError, { role: "alert", children: quote.error ??
419
+ "We couldn't get a fresh payment amount. Please try again." })] }), _jsxs(SetupActions, { children: [_jsx(StyledButton, { onClick: () => {
420
+ void refreshQuote();
421
+ }, variant: "primary", style: { marginTop: 8 }, children: "Try again" }), _jsx(ModalBackButton, { view: "cryptoIntent" })] })] }));
422
+ }
423
+ const relay = instructions?.type === "relay_deposit_address";
424
+ const bitcoin = relay && instructions.source_chain === BITCOIN_CHAIN;
425
+ if (!showInstructions) {
426
+ return (_jsx(ModalViewContainer, { children: _jsx(ManualRoutePicker, { sources: loadingSources ? [] : sourceOptions, loadingSources: loadingSources, manualPaymentOptions: manualPaymentOptions, settlementCurrency: settlementCurrency, issuingSource: issuingSource, error: revealError, onNavigate: clearPickerErrors, onSelectToken: validateRefundWallet, onReveal: (source) => void revealManualPayment(source), refundPreference: _jsx(ManualRefundPreference, { refundAddress: frozenRefundTo, editable: !isIssued, value: refundWallet ?? "", error: refundWalletError, disabled: Boolean(issuingSource), onChange: (value) => {
427
+ setRefundWallet(value);
428
+ setRefundWalletError(null);
429
+ } }) }) }));
430
+ }
431
+ if (!readOnly && instructionsOutdated)
1057
432
  return null;
433
+ const source = relay
434
+ ? sourceOptions.find((option) => manualOptionLookupKey(option) === issuedRouteKey)
435
+ : settlementCurrency;
436
+ const sourceCurrency = source?.asset_name ?? formatTokenLabel(instructionSource?.token ?? "");
437
+ const sourceChain = source?.chain_name ?? formatChainLabel(instructionSource?.chain ?? "");
438
+ const tokenIconUrl = source?.logo_url;
439
+ const chainIconUrl = source ? getManualChainIconUrl(source) : null;
440
+ const sourceTokenSymbol = source
441
+ ? getSourceTokenSymbol(source, manualPaymentOptions)
442
+ : sourceCurrency;
443
+ const transferInstructions = getManualTransferInstructions(cryptoPaymentAttempt, { chain: sourceChain, currency: bitcoin ? BITCOIN.symbol : sourceCurrency }, funding, transferShortfall);
444
+ if (transferInstructions.kind === "unavailable_top_up") {
445
+ return (_jsxs(ModalViewContainer, { children: [_jsx(PaymentRouteError, { role: "alert", children: "The remaining amount is unavailable." }), _jsx(StyledButton, { variant: "secondary", onClick: () => goToView("paymentStatus"), children: "Back to payment status" })] }));
1058
446
  }
1059
- 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" })] })] }));
447
+ if (transferInstructions.kind !== "ready")
448
+ return null;
449
+ return (_jsxs(ManualPaymentLayout, { children: [_jsx(ManualPaymentScrollArea, { children: _jsxs(PaymentDetailsStack, { children: [!readOnly ? (_jsx(QuoteExpiryCountdown, { remainingMs: countdown.remainingMs, totalDurationMs: countdown.totalDurationMs, primaryColor: config.theme.btn.primary.default.backgroundColor, urgentThresholdRatio: QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO })) : null, _jsx(ManualPaymentSummary, { icon: _jsxs(TokenIconWrap, { children: [_jsx(TokenIcon, { "$iconUrl": tokenIconUrl, children: tokenIconUrl ? null : getMonogram(sourceCurrency) }), _jsx(ChainBadge, { "$iconUrl": chainIconUrl, children: chainIconUrl ? null : getChainAbbreviation(sourceChain) })] }), tokenLabel: `${sourceTokenSymbol} on ${sourceChain}`, expanded: paymentDetailsExpanded, refundAddress: frozenRefundTo, bitcoin: bitcoin, relay: relay, onToggle: () => setPaymentDetailsExpanded((expanded) => !expanded) }), _jsx(FundingProgress, { funding: payment?.funding, tokenSymbol: instructions?.type === "token_transfer"
450
+ ? instructions.token_symbol
451
+ : settlementCurrency.asset_name }), _jsx(ManualInstructionCard, { ...transferInstructions, readOnly: readOnly }, transferInstructions.paymentAddress)] }) }), _jsxs(ManualPaymentActions, { children: [reopenedQuoteExpired ? (_jsx(Text, { size: "sm", children: "These payment details have expired. Go back to choose a token and network for fresh details." })) : (_jsx(StyledButton, { onClick: handleConfirm, variant: "primary", disabled: isConfirmingTransfer, children: isConfirmingTransfer ? "Confirming…" : "I've sent the funds" })), _jsx(StyledButton, { onClick: () => {
452
+ setPaymentDetailsExpanded(false);
453
+ if (reviewingIssuedInstructions) {
454
+ goToView("cryptoIntentDirectDetails");
455
+ }
456
+ else {
457
+ void transitionView(() => setInstructionView("picker"));
458
+ }
459
+ }, variant: "secondary", disabled: isConfirmingTransfer, children: "Back" })] })] }));
1060
460
  };
1061
- export { CryptoIntentDirectDetailsViewContent, getManualPaymentAttemptMode, getManualChainIconUrl, getManualInstructionSource, shouldResetManualRefundWalletForSource, shouldLoadManualPaymentOptions, uniqueSourceOptions, };
461
+ export { CryptoIntentDirectDetailsViewContent };
1062
462
  //# sourceMappingURL=direct-details.js.map