@mintmoney/react 0.2.0-alpha.1 → 0.2.0-alpha.3

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 (316) hide show
  1. package/dist/css/styles.css +12 -1
  2. package/dist/docs/customisation.md +8 -0
  3. package/dist/esm/api/errors.js +89 -0
  4. package/dist/esm/api/errors.js.map +1 -0
  5. package/dist/esm/api/generated.js +825 -65
  6. package/dist/esm/api/generated.js.map +1 -1
  7. package/dist/esm/api/payments.js +26 -2
  8. package/dist/esm/api/payments.js.map +1 -1
  9. package/dist/esm/api/tokens.js +34 -0
  10. package/dist/esm/api/tokens.js.map +1 -0
  11. package/dist/esm/api/types.js.map +1 -1
  12. package/dist/esm/checkout/claimable-funds.js +20 -10
  13. package/dist/esm/checkout/claimable-funds.js.map +1 -1
  14. package/dist/esm/checkout/creation-error-modal.js +2 -2
  15. package/dist/esm/checkout/creation-error-modal.js.map +1 -1
  16. package/dist/esm/checkout/index.js +48 -8
  17. package/dist/esm/checkout/index.js.map +1 -1
  18. package/dist/esm/checkout/modal.js +78 -78
  19. package/dist/esm/checkout/modal.js.map +1 -1
  20. package/dist/esm/checkout/payment-status.js +68 -28
  21. package/dist/esm/checkout/payment-status.js.map +1 -1
  22. package/dist/esm/checkout/provider-status.js +9 -0
  23. package/dist/esm/checkout/provider-status.js.map +1 -0
  24. package/dist/esm/checkout/providers/checkout-wallet.js +315 -0
  25. package/dist/esm/checkout/providers/checkout-wallet.js.map +1 -0
  26. package/dist/esm/checkout/providers/wagmi-config.js +55 -49
  27. package/dist/esm/checkout/providers/wagmi-config.js.map +1 -1
  28. package/dist/esm/checkout/refund-notice.js +16 -0
  29. package/dist/esm/checkout/refund-notice.js.map +1 -0
  30. package/dist/esm/checkout/resume-state.js +151 -13
  31. package/dist/esm/checkout/resume-state.js.map +1 -1
  32. package/dist/esm/checkout/surplus-refund.js +12 -0
  33. package/dist/esm/checkout/surplus-refund.js.map +1 -1
  34. package/dist/esm/checkout/views/amount-header.js +1 -1
  35. package/dist/esm/checkout/views/amount-header.js.map +1 -1
  36. package/dist/esm/checkout/views/claimable-funds.js +22 -13
  37. package/dist/esm/checkout/views/claimable-funds.js.map +1 -1
  38. package/dist/esm/checkout/views/crypto-intent/direct-details.js +226 -887
  39. package/dist/esm/checkout/views/crypto-intent/direct-details.js.map +1 -1
  40. package/dist/esm/checkout/views/crypto-intent/manual-instruction-card.js +235 -0
  41. package/dist/esm/checkout/views/crypto-intent/manual-instruction-card.js.map +1 -0
  42. package/dist/esm/checkout/views/crypto-intent/manual-payment-summary.js +2 -26
  43. package/dist/esm/checkout/views/crypto-intent/manual-payment-summary.js.map +1 -1
  44. package/dist/esm/checkout/views/crypto-intent/manual-refresh.js +19 -0
  45. package/dist/esm/checkout/views/crypto-intent/manual-refresh.js.map +1 -0
  46. package/dist/esm/checkout/views/crypto-intent/manual-refund-preference.js +151 -23
  47. package/dist/esm/checkout/views/crypto-intent/manual-refund-preference.js.map +1 -1
  48. package/dist/esm/checkout/views/crypto-intent/manual-route-picker.js +295 -0
  49. package/dist/esm/checkout/views/crypto-intent/manual-route-picker.js.map +1 -0
  50. package/dist/esm/checkout/views/crypto-intent/manual-sources.js +155 -0
  51. package/dist/esm/checkout/views/crypto-intent/manual-sources.js.map +1 -0
  52. package/dist/esm/checkout/views/crypto-intent/manual-transfer-instructions.js +84 -0
  53. package/dist/esm/checkout/views/crypto-intent/manual-transfer-instructions.js.map +1 -0
  54. package/dist/esm/checkout/views/crypto-intent/methods.js +22 -123
  55. package/dist/esm/checkout/views/crypto-intent/methods.js.map +1 -1
  56. package/dist/esm/checkout/views/crypto-intent/payment-route-error.js +10 -0
  57. package/dist/esm/checkout/views/crypto-intent/payment-route-error.js.map +1 -0
  58. package/dist/esm/checkout/views/crypto-intent/processing.js +167 -25
  59. package/dist/esm/checkout/views/crypto-intent/processing.js.map +1 -1
  60. package/dist/esm/checkout/views/crypto-intent/success.js +74 -46
  61. package/dist/esm/checkout/views/crypto-intent/success.js.map +1 -1
  62. package/dist/esm/checkout/views/crypto-intent/test-payment.js +11 -1
  63. package/dist/esm/checkout/views/crypto-intent/test-payment.js.map +1 -1
  64. package/dist/esm/checkout/views/crypto-intent/wallet-payment-confirmation-amount.js +14 -24
  65. package/dist/esm/checkout/views/crypto-intent/wallet-payment-confirmation-amount.js.map +1 -1
  66. package/dist/esm/checkout/views/crypto-intent/wallet-payment-discovery.js +61 -0
  67. package/dist/esm/checkout/views/crypto-intent/wallet-payment-discovery.js.map +1 -0
  68. package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js +136 -1169
  69. package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.js.map +1 -1
  70. package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.styles.js +506 -0
  71. package/dist/esm/checkout/views/crypto-intent/wallet-payment-options.styles.js.map +1 -0
  72. package/dist/esm/checkout/views/crypto-intent/wallet-select.js +7 -164
  73. package/dist/esm/checkout/views/crypto-intent/wallet-select.js.map +1 -1
  74. package/dist/esm/checkout/views/failed.js +62 -26
  75. package/dist/esm/checkout/views/failed.js.map +1 -1
  76. package/dist/esm/checkout/views/funding-timeline.js +255 -0
  77. package/dist/esm/checkout/views/funding-timeline.js.map +1 -0
  78. package/dist/esm/checkout/views/initial.js +25 -41
  79. package/dist/esm/checkout/views/initial.js.map +1 -1
  80. package/dist/esm/checkout/views/method-select.js +6 -4
  81. package/dist/esm/checkout/views/method-select.js.map +1 -1
  82. package/dist/esm/checkout/views/payment-follower.js +105 -0
  83. package/dist/esm/checkout/views/payment-follower.js.map +1 -0
  84. package/dist/esm/checkout/views/restart.js +11 -2
  85. package/dist/esm/checkout/views/restart.js.map +1 -1
  86. package/dist/esm/components/buttons/index.js +3 -2
  87. package/dist/esm/components/buttons/index.js.map +1 -1
  88. package/dist/esm/components/icons/search.js +5 -0
  89. package/dist/esm/components/icons/search.js.map +1 -0
  90. package/dist/esm/components/loading/index.js +2 -2
  91. package/dist/esm/components/loading/index.js.map +1 -1
  92. package/dist/esm/components/modals/modal-with-views.js +6 -12
  93. package/dist/esm/components/modals/modal-with-views.js.map +1 -1
  94. package/dist/esm/components/modals/modal.js +3 -3
  95. package/dist/esm/components/modals/modal.js.map +1 -1
  96. package/dist/esm/components/modals/transition-view.js +16 -0
  97. package/dist/esm/components/modals/transition-view.js.map +1 -0
  98. package/dist/esm/components/modals/use-modal-with-views.js +17 -19
  99. package/dist/esm/components/modals/use-modal-with-views.js.map +1 -1
  100. package/dist/esm/components/wallet-selector/wallets/wagmi/index.js +21 -2
  101. package/dist/esm/components/wallet-selector/wallets/wagmi/index.js.map +1 -1
  102. package/dist/esm/config.js.map +1 -1
  103. package/dist/esm/integrations/bitcoin-metamask.js +87 -0
  104. package/dist/esm/integrations/bitcoin-metamask.js.map +1 -0
  105. package/dist/esm/integrations/bitcoin-network.js +59 -0
  106. package/dist/esm/integrations/bitcoin-network.js.map +1 -0
  107. package/dist/esm/integrations/bitcoin-psbt.js +4 -0
  108. package/dist/esm/integrations/bitcoin-psbt.js.map +1 -0
  109. package/dist/esm/integrations/bitcoin-source.js +12 -0
  110. package/dist/esm/integrations/bitcoin-source.js.map +1 -0
  111. package/dist/esm/integrations/bitcoin-wallet.js +225 -0
  112. package/dist/esm/integrations/bitcoin-wallet.js.map +1 -0
  113. package/dist/esm/integrations/evm-chain.js +18 -0
  114. package/dist/esm/integrations/evm-chain.js.map +1 -1
  115. package/dist/esm/integrations/guarded-wallet-client.js +19 -0
  116. package/dist/esm/integrations/guarded-wallet-client.js.map +1 -0
  117. package/dist/esm/integrations/lifi.js +85 -38
  118. package/dist/esm/integrations/lifi.js.map +1 -1
  119. package/dist/esm/refund/index.js +217 -226
  120. package/dist/esm/refund/index.js.map +1 -1
  121. package/dist/esm/state/checkout/bitcoin-payment.js +253 -0
  122. package/dist/esm/state/checkout/bitcoin-payment.js.map +1 -0
  123. package/dist/esm/state/checkout/checkout-state.js +54 -0
  124. package/dist/esm/state/checkout/checkout-state.js.map +1 -0
  125. package/dist/esm/state/checkout/funding.js +5 -0
  126. package/dist/esm/state/checkout/funding.js.map +1 -0
  127. package/dist/esm/state/checkout/issuance-conflicts.js +29 -0
  128. package/dist/esm/state/checkout/issuance-conflicts.js.map +1 -0
  129. package/dist/esm/state/checkout/manual-route.js +10 -0
  130. package/dist/esm/state/checkout/manual-route.js.map +1 -0
  131. package/dist/esm/state/checkout/payment-attempt.js +50 -20
  132. package/dist/esm/state/checkout/payment-attempt.js.map +1 -1
  133. package/dist/esm/state/checkout/payment-lifecycle.js +9 -15
  134. package/dist/esm/state/checkout/payment-lifecycle.js.map +1 -1
  135. package/dist/esm/state/checkout/payment-observer.js +147 -0
  136. package/dist/esm/state/checkout/payment-observer.js.map +1 -0
  137. package/dist/esm/state/checkout/payment-phase.js +131 -0
  138. package/dist/esm/state/checkout/payment-phase.js.map +1 -0
  139. package/dist/esm/state/checkout/quote-countdown.js +26 -0
  140. package/dist/esm/state/checkout/quote-countdown.js.map +1 -0
  141. package/dist/esm/state/checkout/quote-lifecycle.js +378 -0
  142. package/dist/esm/state/checkout/quote-lifecycle.js.map +1 -0
  143. package/dist/esm/state/checkout/route-estimate.js +77 -0
  144. package/dist/esm/state/checkout/route-estimate.js.map +1 -0
  145. package/dist/esm/state/checkout/store.js +350 -708
  146. package/dist/esm/state/checkout/store.js.map +1 -1
  147. package/dist/esm/state/checkout/wallet-payment-options.js +0 -32
  148. package/dist/esm/state/checkout/wallet-payment-options.js.map +1 -1
  149. package/dist/esm/state/checkout/wallet-payment.js +249 -0
  150. package/dist/esm/state/checkout/wallet-payment.js.map +1 -0
  151. package/dist/esm/utils/string.js +2 -0
  152. package/dist/esm/utils/string.js.map +1 -1
  153. package/dist/esm/utils/token-amount.js +88 -0
  154. package/dist/esm/utils/token-amount.js.map +1 -0
  155. package/dist/esm/utils/wallet-errors.js +21 -4
  156. package/dist/esm/utils/wallet-errors.js.map +1 -1
  157. package/dist/types/api/errors.d.ts +37 -0
  158. package/dist/types/api/errors.d.ts.map +1 -0
  159. package/dist/types/api/generated.d.ts +4570 -695
  160. package/dist/types/api/generated.d.ts.map +1 -1
  161. package/dist/types/api/payments.d.ts +28 -1
  162. package/dist/types/api/payments.d.ts.map +1 -1
  163. package/dist/types/api/tokens.d.ts +6 -0
  164. package/dist/types/api/tokens.d.ts.map +1 -0
  165. package/dist/types/api/types.d.ts +28 -2
  166. package/dist/types/api/types.d.ts.map +1 -1
  167. package/dist/types/checkout/claimable-funds.d.ts +15 -2
  168. package/dist/types/checkout/claimable-funds.d.ts.map +1 -1
  169. package/dist/types/checkout/creation-error-modal.d.ts +2 -1
  170. package/dist/types/checkout/creation-error-modal.d.ts.map +1 -1
  171. package/dist/types/checkout/index.d.ts +21 -1
  172. package/dist/types/checkout/index.d.ts.map +1 -1
  173. package/dist/types/checkout/modal.d.ts +4 -1
  174. package/dist/types/checkout/modal.d.ts.map +1 -1
  175. package/dist/types/checkout/payment-status.d.ts +10 -2
  176. package/dist/types/checkout/payment-status.d.ts.map +1 -1
  177. package/dist/types/checkout/provider-status.d.ts +11 -0
  178. package/dist/types/checkout/provider-status.d.ts.map +1 -0
  179. package/dist/types/checkout/providers/checkout-wallet.d.ts +23 -0
  180. package/dist/types/checkout/providers/checkout-wallet.d.ts.map +1 -0
  181. package/dist/types/checkout/providers/wagmi-config.d.ts +8 -2
  182. package/dist/types/checkout/providers/wagmi-config.d.ts.map +1 -1
  183. package/dist/types/checkout/refund-notice.d.ts +7 -0
  184. package/dist/types/checkout/refund-notice.d.ts.map +1 -0
  185. package/dist/types/checkout/resume-state.d.ts +41 -4
  186. package/dist/types/checkout/resume-state.d.ts.map +1 -1
  187. package/dist/types/checkout/surplus-refund.d.ts +8 -0
  188. package/dist/types/checkout/surplus-refund.d.ts.map +1 -1
  189. package/dist/types/checkout/views/amount-header.d.ts.map +1 -1
  190. package/dist/types/checkout/views/claimable-funds.d.ts.map +1 -1
  191. package/dist/types/checkout/views/crypto-intent/direct-details.d.ts +3 -13
  192. package/dist/types/checkout/views/crypto-intent/direct-details.d.ts.map +1 -1
  193. package/dist/types/checkout/views/crypto-intent/manual-instruction-card.d.ts +10 -0
  194. package/dist/types/checkout/views/crypto-intent/manual-instruction-card.d.ts.map +1 -0
  195. package/dist/types/checkout/views/crypto-intent/manual-payment-summary.d.ts +4 -11
  196. package/dist/types/checkout/views/crypto-intent/manual-payment-summary.d.ts.map +1 -1
  197. package/dist/types/checkout/views/crypto-intent/manual-refresh.d.ts +4 -0
  198. package/dist/types/checkout/views/crypto-intent/manual-refresh.d.ts.map +1 -0
  199. package/dist/types/checkout/views/crypto-intent/manual-refund-preference.d.ts +14 -10
  200. package/dist/types/checkout/views/crypto-intent/manual-refund-preference.d.ts.map +1 -1
  201. package/dist/types/checkout/views/crypto-intent/manual-route-picker.d.ts +18 -0
  202. package/dist/types/checkout/views/crypto-intent/manual-route-picker.d.ts.map +1 -0
  203. package/dist/types/checkout/views/crypto-intent/manual-sources.d.ts +33 -0
  204. package/dist/types/checkout/views/crypto-intent/manual-sources.d.ts.map +1 -0
  205. package/dist/types/checkout/views/crypto-intent/manual-transfer-instructions.d.ts +18 -0
  206. package/dist/types/checkout/views/crypto-intent/manual-transfer-instructions.d.ts.map +1 -0
  207. package/dist/types/checkout/views/crypto-intent/methods.d.ts.map +1 -1
  208. package/dist/types/checkout/views/crypto-intent/payment-route-error.d.ts +2 -0
  209. package/dist/types/checkout/views/crypto-intent/payment-route-error.d.ts.map +1 -0
  210. package/dist/types/checkout/views/crypto-intent/processing.d.ts.map +1 -1
  211. package/dist/types/checkout/views/crypto-intent/success.d.ts +2 -1
  212. package/dist/types/checkout/views/crypto-intent/success.d.ts.map +1 -1
  213. package/dist/types/checkout/views/crypto-intent/test-payment.d.ts.map +1 -1
  214. package/dist/types/checkout/views/crypto-intent/wallet-payment-confirmation-amount.d.ts +8 -8
  215. package/dist/types/checkout/views/crypto-intent/wallet-payment-confirmation-amount.d.ts.map +1 -1
  216. package/dist/types/checkout/views/crypto-intent/wallet-payment-discovery.d.ts +17 -0
  217. package/dist/types/checkout/views/crypto-intent/wallet-payment-discovery.d.ts.map +1 -0
  218. package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts +2 -1
  219. package/dist/types/checkout/views/crypto-intent/wallet-payment-options.d.ts.map +1 -1
  220. package/dist/types/checkout/views/crypto-intent/wallet-payment-options.styles.d.ts +61 -0
  221. package/dist/types/checkout/views/crypto-intent/wallet-payment-options.styles.d.ts.map +1 -0
  222. package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts +1 -2
  223. package/dist/types/checkout/views/crypto-intent/wallet-select.d.ts.map +1 -1
  224. package/dist/types/checkout/views/failed.d.ts +6 -0
  225. package/dist/types/checkout/views/failed.d.ts.map +1 -1
  226. package/dist/types/checkout/views/funding-timeline.d.ts +49 -0
  227. package/dist/types/checkout/views/funding-timeline.d.ts.map +1 -0
  228. package/dist/types/checkout/views/initial.d.ts +2 -4
  229. package/dist/types/checkout/views/initial.d.ts.map +1 -1
  230. package/dist/types/checkout/views/method-select.d.ts +2 -1
  231. package/dist/types/checkout/views/method-select.d.ts.map +1 -1
  232. package/dist/types/checkout/views/payment-follower.d.ts +31 -0
  233. package/dist/types/checkout/views/payment-follower.d.ts.map +1 -0
  234. package/dist/types/checkout/views/restart.d.ts +1 -1
  235. package/dist/types/checkout/views/restart.d.ts.map +1 -1
  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 +2 -0
  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 -2
  252. package/dist/types/components/wallet-selector/wallets/wagmi/index.d.ts.map +1 -1
  253. package/dist/types/config.d.ts +1 -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 +22 -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 +102 -0
  276. package/dist/types/state/checkout/checkout-state.d.ts.map +1 -0
  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 +20 -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 +41 -0
  288. package/dist/types/state/checkout/payment-observer.d.ts.map +1 -0
  289. package/dist/types/state/checkout/payment-phase.d.ts +116 -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 +39 -0
  294. package/dist/types/state/checkout/quote-lifecycle.d.ts.map +1 -0
  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 +38 -90
  298. package/dist/types/state/checkout/store.d.ts.map +1 -1
  299. package/dist/types/state/checkout/wallet-payment-options.d.ts +0 -16
  300. package/dist/types/state/checkout/wallet-payment-options.d.ts.map +1 -1
  301. package/dist/types/state/checkout/wallet-payment.d.ts +24 -0
  302. package/dist/types/state/checkout/wallet-payment.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/checkout/providers/wallet-connect-resume.js +0 -129
  310. package/dist/esm/checkout/providers/wallet-connect-resume.js.map +0 -1
  311. package/dist/esm/refund/confirmation.js +0 -30
  312. package/dist/esm/refund/confirmation.js.map +0 -1
  313. package/dist/types/checkout/providers/wallet-connect-resume.d.ts +0 -9
  314. package/dist/types/checkout/providers/wallet-connect-resume.d.ts.map +0 -1
  315. package/dist/types/refund/confirmation.d.ts +0 -14
  316. package/dist/types/refund/confirmation.d.ts.map +0 -1
@@ -1,348 +1,32 @@
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, 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 { acceptsFunds, derivePaymentPhase, pendingShortfall, } from "../../../state/checkout/payment-phase.js";
15
+ import { QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO, useQuoteCountdown, } from "../../../state/checkout/quote-countdown.js";
16
+ import { clearQuoteRefresh, captureCheckoutOpening, configureManualQuoteRefresh, createManualDirectPaymentAttempt, getFrozenRefundRecipient, isCheckoutIssued, refreshQuote, useCheckoutStore, } from "../../../state/checkout/store.js";
17
+ import { formatChainLabel, formatTokenLabel, } from "../../../utils/token-amount.js";
12
18
  import { ModalViewContainer } from "../../container.js";
19
+ import { manualTransferFor, writeCheckoutResumeState, } from "../../resume-state.js";
13
20
  import { ModalBackButton } from "../back.js";
21
+ import { FundingProgress } from "../funding-timeline.js";
22
+ import { ManualInstructionCard } from "./manual-instruction-card.js";
14
23
  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
- `;
24
+ import { ManualPaymentRefresh } from "./manual-refresh.js";
25
+ import { ManualRefundPreference } from "./manual-refund-preference.js";
26
+ import { ManualRoutePicker } from "./manual-route-picker.js";
27
+ import { getChainAbbreviation, getManualChainIconUrl, getManualInstructionSource, getMonogram, getSourceTokenSymbol, isEvmAddress, manualPaymentOptionToCurrency, uniqueSourceOptions, useManualPaymentOptions, } from "./manual-sources.js";
28
+ import { getManualTransferInstructions, manualInstructionsMatchFunding, } from "./manual-transfer-instructions.js";
29
+ import { PaymentRouteError } from "./payment-route-error.js";
346
30
  const TokenIconWrap = styled.div `
347
31
  position: relative;
348
32
  width: 42px;
@@ -436,209 +120,25 @@ const ErrorCard = styled.div `
436
120
  align-items: center;
437
121
  gap: 8px;
438
122
  `;
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();
123
+ const MANUAL_ATTEMPT_FAILED_MESSAGE = "We couldn't generate payment details. Please try again.";
124
+ const CryptoIntentDirectDetailsViewContent = ({ onPaymentSelectionChange, hostedRecovery, }) => {
125
+ const isIssuingRef = useRef(false);
126
+ const { goToView, viewProps } = useModalWithView();
634
127
  const connectedAccount = useAccount();
635
- const { cryptoPaymentAttempt, cryptoCurrency, payment, quote } = useCheckoutStore();
128
+ const checkoutState = useCheckoutStore();
129
+ const { cryptoPaymentAttempt, cryptoCurrency, payment, quote } = checkoutState;
130
+ const phase = derivePaymentPhase(payment);
131
+ const shortfall = pendingShortfall(phase);
132
+ const instructions = cryptoPaymentAttempt?.payment_instructions;
133
+ // Once issued, the refund recipient is fixed and never sent again (QCT D1).
134
+ const isIssued = isCheckoutIssued(checkoutState);
135
+ const frozenRefundTo = getFrozenRefundRecipient(checkoutState);
636
136
  const config = useMintMoneyConfig();
637
137
  const fallbackSourceOptions = useMemo(() => cryptoCurrency
638
138
  ? uniqueSourceOptions(cryptoCurrency, config.cryptoCheckoutConfig.directPaymentSources)
639
139
  : [], [cryptoCurrency, config.cryptoCheckoutConfig.directPaymentSources]);
640
- const [manualPaymentOptions, setManualPaymentOptions] = useState([]);
641
- const [manualPaymentOptionsStatus, setManualPaymentOptionsStatus] = useState("idle");
140
+ const { manualPaymentOptions, manualPaymentOptionsStatus } = useManualPaymentOptions(payment?.id, cryptoCurrency);
141
+ const loadingSources = manualPaymentOptionsStatus === "loading";
642
142
  const manualOptionSources = useMemo(() => manualPaymentOptions.map(manualPaymentOptionToCurrency), [manualPaymentOptions]);
643
143
  const sourceOptions = useMemo(() => {
644
144
  if (cryptoCurrency &&
@@ -653,399 +153,238 @@ const CryptoIntentDirectDetailsViewContent = () => {
653
153
  manualOptionSources,
654
154
  manualPaymentOptionsStatus,
655
155
  ]);
656
- const [copiedAddress, setCopiedAddress] = useState(false);
657
- const [copiedAmount, setCopiedAmount] = useState(false);
658
- const [hasAcknowledged, setHasAcknowledged] = useState(false);
156
+ // The processing view returns a payer who confirmed sending too early to the
157
+ // instructions already issued, without choosing a route again.
158
+ const [showInstructions, setShowInstructions] = useState(() => viewProps.showIssuedInstructions === true &&
159
+ Boolean(cryptoPaymentAttempt?.payment_instructions));
659
160
  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);
161
+ const [refundWallet, setRefundWallet] = useState(null);
666
162
  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]);
163
+ const [issuingSource, setIssuingSource] = useState(null);
164
+ const [isConfirmingTransfer, setIsConfirmingTransfer] = useState(false);
165
+ const [revealError, setRevealError] = useState(null);
166
+ const countdown = useQuoteCountdown(quote, showInstructions ? cryptoPaymentAttempt : null);
167
+ const funding = payment?.funding;
168
+ const receivedFunds = hasReceivedFunds(funding);
169
+ const expiredWithoutTransfer = phase.cutoffPassed &&
170
+ !phase.broadcast &&
171
+ !receivedFunds &&
172
+ ["awaiting_deposit", "relay_delivered_nothing", "failed"].includes(phase.kind);
173
+ const settlementCurrency = cryptoPaymentAttempt?.settlement_config ?? cryptoCurrency;
174
+ const [resumeSelection, setResumeSelection] = useState(() => {
175
+ const selection = viewProps.resumePaymentSelection;
176
+ return !isIssued && selection?.kind === "manual" ? selection : undefined;
177
+ });
178
+ const resumeSource = resumeSelection &&
179
+ settlementCurrency &&
180
+ getManualPaymentAttemptMode(resumeSelection, settlementCurrency) ===
181
+ undefined
182
+ ? settlementCurrency
183
+ : null;
184
+ // Issued instructions are payable while the payment accepts funds and
185
+ // Relay's quote still matches what is due.
186
+ const instructionsOutdated = !acceptsFunds(phase) ||
187
+ !manualInstructionsMatchFunding(cryptoPaymentAttempt, shortfall);
692
188
  useEffect(() => {
693
- if (!hasAcknowledged || !cryptoPaymentAttempt)
189
+ if (!showInstructions || isConfirmingTransfer || expiredWithoutTransfer)
694
190
  return;
695
191
  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]);
192
+ return () => clearQuoteRefresh();
193
+ }, [expiredWithoutTransfer, isConfirmingTransfer, showInstructions]);
744
194
  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);
195
+ if (showInstructions &&
196
+ instructionsOutdated &&
197
+ !expiredWithoutTransfer &&
198
+ quote.status !== "refreshing") {
199
+ goToView("paymentStatus");
753
200
  }
754
201
  }, [
755
- manualPaymentOptions,
756
- selectedSourceKey,
757
- selectedTokenKey,
758
- sourceOptions,
202
+ expiredWithoutTransfer,
203
+ goToView,
204
+ instructionsOutdated,
205
+ quote.status,
206
+ showInstructions,
759
207
  ]);
760
- 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)
208
+ const paymentId = payment?.id;
209
+ const manualTransferPending = viewProps.showIssuedInstructions === true;
210
+ const directInstructions = instructions?.type === "token_transfer" ? instructions : null;
211
+ const manualAsset = directInstructions?.token;
212
+ const manualChain = directInstructions?.chain;
213
+ const continueManualPayment = showInstructions &&
214
+ !phase.broadcast &&
215
+ !receivedFunds &&
216
+ !isConfirmingTransfer &&
217
+ !manualTransferPending;
218
+ useLayoutEffect(() => {
219
+ if (!continueManualPayment || !paymentId || !manualAsset || !manualChain)
768
220
  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));
776
- }
777
- setHasAcknowledged(true);
221
+ onPaymentSelectionChange?.(paymentId, {
222
+ kind: "manual",
223
+ asset: manualAsset,
224
+ chain: manualChain,
225
+ refundTo: frozenRefundTo,
226
+ });
227
+ return () => onPaymentSelectionChange?.(paymentId, null);
778
228
  }, [
779
- cryptoPaymentAttempt,
780
- cryptoPaymentAttempt?.payment_instructions,
781
- hasAcknowledged,
782
- sourceOptions,
229
+ continueManualPayment,
230
+ frozenRefundTo,
231
+ manualAsset,
232
+ manualChain,
233
+ onPaymentSelectionChange,
234
+ paymentId,
783
235
  ]);
784
236
  useEffect(() => {
785
- if (hasAcknowledged || refundEditorExpanded || refundWallet)
786
- return;
787
- const attemptRefundTo = cryptoPaymentAttempt?.refund_to?.trim();
788
- if (attemptRefundTo) {
789
- setRefundWallet(attemptRefundTo);
237
+ if (!isIssued && !showInstructions && connectedAccount.address) {
238
+ const address = connectedAccount.address;
239
+ setRefundWallet((current) => current ?? address);
790
240
  }
791
- }, [
792
- cryptoPaymentAttempt?.refund_to,
793
- hasAcknowledged,
794
- refundEditorExpanded,
795
- refundWallet,
796
- ]);
797
- 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
- ]);
241
+ }, [connectedAccount.address, isIssued, showInstructions]);
812
242
  const handleConfirm = async () => {
813
- if (!payment?.id) {
243
+ if (isConfirmingTransfer)
244
+ return;
245
+ const isCurrent = captureCheckoutOpening();
246
+ if (!payment?.id || !cryptoPaymentAttempt) {
814
247
  goToView("failed", { reason: "confirm_payment" });
815
248
  return;
816
249
  }
250
+ setIsConfirmingTransfer(true);
251
+ const manualTransfer = manualTransferFor(cryptoPaymentAttempt, shortfall);
252
+ writeCheckoutResumeState(payment.id, {
253
+ view: "paymentStatus",
254
+ manualTransfer,
255
+ });
817
256
  try {
818
257
  await confirmPayment(payment.id);
819
- goToView("paymentStatus");
258
+ if (!isCurrent())
259
+ return;
260
+ goToView("paymentStatus", { justSubmitted: true, manualTransfer });
820
261
  }
821
262
  catch (error) {
263
+ if (!isCurrent())
264
+ return;
822
265
  console.error("Failed to confirm payment:", error);
823
266
  goToView("failed", { reason: "confirm_payment" });
824
267
  }
825
268
  };
826
- if (!cryptoCurrency) {
827
- return null;
828
- }
829
- // Action needed: the quote refresh failed. No funds have been sent under a
830
- // stale address, so the recovery is simply to fetch a fresh amount again.
831
- if (quote.status === "failed") {
832
- 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 ??
833
- "We couldn't get a fresh payment amount. Please try again." })] }), _jsxs(SetupActions, { children: [_jsx(StyledButton, { onClick: () => {
834
- void refreshQuote();
835
- }, variant: "primary", style: { marginTop: 8 }, children: "Try again" }), _jsx(ModalBackButton, { view: "cryptoIntent" })] })] }));
836
- }
837
- // Quote refreshing: the address/route was stale or missing, so Mint is
838
- // fetching a fresh payable amount — no expiry dead-end.
839
- if (quote.status === "refreshing") {
840
- 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..." })] })] }) }));
841
- }
842
- const settlementCurrency = cryptoPaymentAttempt?.settlement_config ?? cryptoCurrency;
843
- const selectedSource = sourceOptions.find((option) => sourceKey(option) === selectedSourceKey) ??
844
- sourceOptions[0] ??
845
- cryptoCurrency;
846
- const tokenOptions = uniqueSourceTokens(sourceOptions, manualPaymentOptions);
847
- const activeTokenKey = selectedTokenKey ||
848
- getSourceTokenGroupKey(selectedSource, manualPaymentOptions);
849
- const networkOptions = sourceOptions.filter((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === activeTokenKey);
850
- const uniqueNetworkOptions = uniqueSourceChains(networkOptions);
851
- const selectedTokenOption = tokenOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === activeTokenKey);
852
- const instructions = cryptoPaymentAttempt?.payment_instructions ?? null;
853
- const instructionSource = getManualInstructionSource(instructions);
854
- const amount = cryptoPaymentAttempt?.amount_formatted;
855
- const currency = settlementCurrency.asset_name;
856
- const chain = settlementCurrency.chain_name;
857
- const sourceCurrency = selectedSource?.asset_name ?? currency;
858
- const sourceChain = selectedSource?.chain_name ?? chain;
859
- const trimmedRefundWallet = refundWallet.trim();
860
- const issuedPaymentAddress = instructions?.payment_address ?? cryptoPaymentAttempt?.destination_address;
861
- const manualRefundWallet = trimmedRefundWallet;
862
- const refundPreferenceChanged = normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) !==
863
- normalizeOptionalAddress(manualRefundWallet);
864
- const sourceMatchesSettlementCurrency = (source) => source.asset.toLowerCase() === settlementCurrency.asset.toLowerCase() &&
865
- source.chain.toLowerCase() === settlementCurrency.chain.toLowerCase();
866
- const canReuseAttemptForSource = (source, sourceRefundWallet = manualRefundWallet) => Boolean(instructionSource &&
867
- instructionSource.token.toLowerCase() === source.asset.toLowerCase() &&
868
- instructionSource.chain.toLowerCase() === source.chain.toLowerCase() &&
869
- normalizeOptionalAddress(cryptoPaymentAttempt?.refund_to) ===
870
- normalizeOptionalAddress(sourceRefundWallet) &&
871
- !attemptIsStale);
872
- const tokenHasFastManualRoute = (token) => sourceOptions.some((option) => getSourceTokenGroupKey(option, manualPaymentOptions) ===
873
- getSourceTokenGroupKey(token, manualPaymentOptions) &&
874
- (sourceMatchesSettlementCurrency(option) ||
875
- manualPaymentOptions.some((manualOption) => manualPaymentOptionKey(manualOption).toLowerCase() ===
876
- manualOptionLookupKey(option) && manualOption.kind === "direct")));
877
- const tokenIconUrl = selectedSource?.logo_url ?? settlementCurrency.logo_url ?? null;
878
- const chainIconUrl = getManualChainIconUrl(selectedSource ?? settlementCurrency);
879
- const rawAmount = cryptoPaymentAttempt?.amount === undefined
880
- ? null
881
- : String(cryptoPaymentAttempt.amount);
882
- const sourceAmountFormatted = instructions?.type === "relay_deposit_address"
883
- ? instructions.source_amount_formatted
884
- : (instructions?.amount_formatted ?? amount);
885
- const sourceAmountRaw = instructions?.type === "relay_deposit_address"
886
- ? instructions.source_amount
887
- : (instructions?.amount ?? rawAmount);
888
- const sourceTokenSymbol = getSourceTokenSymbol(selectedSource, manualPaymentOptions);
889
- const formattedAmount = sourceAmountFormatted === undefined
890
- ? null
891
- : formatManualPaymentAmount(sourceAmountFormatted, sourceCurrency);
892
- const useRawAmount = Boolean(sourceAmountRaw) &&
893
- sourceAmountRaw !== String(sourceAmountFormatted) &&
894
- shouldUseRawManualAmount(sourceChain, sourceCurrency);
895
- const sendAmount = useRawAmount ? sourceAmountRaw : formattedAmount;
896
- const copyAmount = useRawAmount
897
- ? sourceAmountRaw
898
- : sourceAmountFormatted === undefined
899
- ? null
900
- : String(sourceAmountFormatted);
901
- const paymentAddress = issuedPaymentAddress;
902
- const qrPayload = instructions?.type === "token_transfer"
903
- ? instructions.qr_payload
904
- : paymentAddress;
905
- const handleBackToSourceSetup = () => {
906
- dismissedAttemptKeyRef.current = manualAttemptKey(cryptoPaymentAttempt);
907
- setCopiedAddress(false);
908
- setCopiedAmount(false);
909
- setShowQrCode(false);
910
- setRefundWalletError(null);
911
- setRefundEditorExpanded(false);
912
- setPaymentDetailsExpanded(false);
913
- if (selectedSource &&
914
- shouldResetManualRefundWalletForSource(refundWallet, selectedSource)) {
915
- setRefundWallet("");
916
- }
917
- setIsCreatingAttempt(false);
918
- setHasAcknowledged(false);
919
- setManualSetupStep("network");
920
- };
921
- const goBackInSetup = () => {
922
- setRefundWalletError(null);
923
- if (manualSetupStep === "network") {
924
- setManualSetupStep("token");
925
- return;
926
- }
927
- return;
928
- };
929
- const selectToken = (token) => {
930
- const nextTokenKey = getSourceTokenGroupKey(token, manualPaymentOptions);
931
- const firstNetworkForToken = sourceOptions.find((option) => getSourceTokenGroupKey(option, manualPaymentOptions) === nextTokenKey) ?? token;
932
- setSelectedTokenKey(nextTokenKey);
933
- setSelectedSourceKey(sourceKey(firstNetworkForToken));
934
- setManualSetupStep("network");
269
+ const manualRefundWallet = refundWallet?.trim() ?? "";
270
+ const clearPickerErrors = () => {
935
271
  setRefundWalletError(null);
272
+ setRevealError(null);
936
273
  };
937
- const generateManualPaymentForSource = async (source, options = {}) => {
938
- const sourceRefundWallet = options.refundWallet ?? manualRefundWallet;
939
- if (sourceRefundWallet &&
940
- !isValidRefundAddressForSource(sourceRefundWallet, source)) {
941
- setRefundWalletError("Enter a valid EVM wallet address.");
274
+ const validateRefundWallet = () => {
275
+ if (!isIssued && manualRefundWallet && !isEvmAddress(manualRefundWallet)) {
276
+ setRefundWalletError("Enter a valid EVM wallet address, or clear the field to use the merchant address.");
942
277
  return false;
943
278
  }
944
- if (canReuseAttemptForSource(source, sourceRefundWallet)) {
945
- dismissedAttemptKeyRef.current = null;
946
- configureManualQuoteRefresh();
947
- setAcknowledgedWithTransition(true);
948
- return true;
949
- }
950
- setIsCreatingAttempt(true);
279
+ return true;
280
+ };
281
+ const revealManualPayment = async (source, resume) => {
282
+ if (isIssuingRef.current || !settlementCurrency)
283
+ return;
284
+ clearPickerErrors();
285
+ if (!resume && !validateRefundWallet())
286
+ return;
287
+ const isCurrent = captureCheckoutOpening();
288
+ const settlementRefundWallet = isIssued
289
+ ? null
290
+ : resume
291
+ ? resume.refundTo
292
+ : manualRefundWallet || null;
293
+ isIssuingRef.current = true;
294
+ setIssuingSource(source);
951
295
  try {
952
- const attempt = await createManualDirectPaymentAttempt("", 1, sourceRefundWallet || null, {
953
- mode: sourceMatchesSettlementCurrency(source)
954
- ? undefined
955
- : getManualPaymentAttemptMode(source, settlementCurrency),
296
+ await createManualDirectPaymentAttempt("", 1, settlementRefundWallet, {
297
+ mode: getManualPaymentAttemptMode(source, settlementCurrency),
956
298
  source,
957
299
  });
958
- setRefundWallet(attempt.refund_to ?? "");
959
- configureManualQuoteRefresh();
960
- setRefundEditorExpanded(false);
961
- setAcknowledgedWithTransition(true);
962
- return true;
300
+ if (!isCurrent())
301
+ return;
302
+ await transitionView(() => {
303
+ if (isCurrent())
304
+ setShowInstructions(true);
305
+ });
963
306
  }
964
307
  catch (error) {
308
+ if (!isCurrent())
309
+ return;
310
+ // The closed payment was read again; it may have moved on with funds.
311
+ if (hasClosedPaymentMovedOn(error, useCheckoutStore.getState().payment)) {
312
+ goToView("paymentStatus");
313
+ return;
314
+ }
965
315
  console.error("Failed to create manual payment attempt:", error);
966
- goToView("failed", { reason: getManualAttemptErrorMessage(error) });
967
- return false;
316
+ setRevealError(describeRevealFailure(error, MANUAL_ATTEMPT_FAILED_MESSAGE));
968
317
  }
969
318
  finally {
970
- setIsCreatingAttempt(false);
971
- }
972
- };
973
- const selectNetwork = (network) => {
974
- const shouldResetRefundWallet = shouldResetManualRefundWalletForSource(refundWallet, network);
975
- const nextRefundWallet = shouldResetRefundWallet ? "" : manualRefundWallet;
976
- setSelectedSourceKey(sourceKey(network));
977
- setRefundWalletError(null);
978
- setRefundEditorExpanded(false);
979
- if (shouldResetRefundWallet) {
980
- setRefundWallet("");
981
- }
982
- setCopiedAddress(false);
983
- setCopiedAmount(false);
984
- setShowQrCode(false);
985
- void generateManualPaymentForSource(network, {
986
- refundWallet: nextRefundWallet,
987
- });
988
- };
989
- const copyToClipboard = async (value, setCopied) => {
990
- try {
991
- await navigator.clipboard.writeText(value);
992
- setCopied(true);
993
- setTimeout(() => setCopied(false), 2000); // Reset after 2 seconds
994
- }
995
- catch (error) {
996
- console.error("Failed to copy to clipboard:", error);
319
+ isIssuingRef.current = false;
320
+ if (isCurrent()) {
321
+ setIssuingSource(null);
322
+ if (resume)
323
+ setResumeSelection(undefined);
324
+ }
997
325
  }
998
326
  };
999
- 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: () => {
1000
- setPaymentDetailsExpanded(true);
1001
- setRefundWallet(cryptoPaymentAttempt?.refund_to ?? "");
1002
- setRefundWalletError(null);
1003
- setRefundEditorExpanded(true);
1004
- }, onSaveRefund: () => {
1005
- if (!refundPreferenceChanged) {
1006
- setRefundEditorExpanded(false);
1007
- setRefundWalletError(null);
1008
- return;
1009
- }
1010
- void generateManualPaymentForSource(selectedSource);
1011
- }, onRefundChange: (value) => {
1012
- setRefundWallet(value);
1013
- setRefundWalletError(null);
1014
- } }), options.showPaymentDetails &&
1015
- paymentAddress &&
1016
- sendAmount &&
1017
- 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) => {
1018
- console.error("Failed to copy address:", error);
1019
- }), 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) => {
1020
- console.error("Failed to copy address:", error);
1021
- }), 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) => {
1022
- console.error("Failed to copy amount:", error);
1023
- }), title: "Click to copy amount", children: [_jsx(PaymentInstructionValue, { theme: config.theme, children: sendAmount }), _jsx(CopyButton, { isCopied: copiedAmount, onClick: (e) => {
1024
- e.stopPropagation();
1025
- copyToClipboard(copyAmount, setCopiedAmount).catch((error) => {
1026
- console.error("Failed to copy amount:", error);
1027
- });
1028
- }, title: "Copy amount", children: copiedAmount ? (_jsx(ClipboardCheckIcon, { size: 15 })) : (_jsx(ClipboardAddIcon, { size: 15 })) })] })] })] })) : null] }));
1029
- if (!hasAcknowledged) {
1030
- if (manualSetupStep === "token") {
1031
- return (_jsxs(ModalViewContainer, { ref: modalRef, children: [_jsx(SelectionSectionLabel, { children: "Select token" }), _jsx(OptionList, { children: tokenOptions.map((option) => {
1032
- const hasFastRoute = tokenHasFastManualRoute(option);
1033
- const tokenSymbol = getSourceTokenSymbol(option, manualPaymentOptions);
1034
- const showTokenName = option.asset_name.toLowerCase() !== tokenSymbol.toLowerCase();
1035
- 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)));
1036
- }) }), _jsx(SetupActions, { children: _jsx(ModalBackButton, { view: "cryptoIntent" }) })] }));
1037
- }
1038
- if (manualSetupStep === "network") {
1039
- const selectedTokenLabel = selectedTokenOption?.asset_name ?? sourceCurrency;
1040
- 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 &&
1041
- sourceKey(option) === selectedSourceKey ? (_jsx(SelectionMeta, { children: "Generating..." })) : null] }, sourceKey(option)))) }), _jsx(SetupActions, { children: _jsx(StyledButton, { onClick: goBackInSetup, variant: "secondary", children: "Back" }) })] }));
1042
- }
327
+ useEffect(() => {
328
+ if (!resumeSelection || !resumeSource || !paymentId || isIssued)
329
+ return;
330
+ void revealManualPayment(resumeSource, resumeSelection);
331
+ }, [isIssued, paymentId, resumeSelection, resumeSource, revealManualPayment]);
332
+ if (!cryptoCurrency || !settlementCurrency) {
1043
333
  return null;
1044
334
  }
1045
- if (!cryptoPaymentAttempt || !sendAmount || !copyAmount || !paymentAddress) {
335
+ const expired = showInstructions && expiredWithoutTransfer;
336
+ const refreshing = (expired &&
337
+ continueManualPayment &&
338
+ directInstructions &&
339
+ (hostedRecovery === "checking" || hostedRecovery === "available")) ||
340
+ (showInstructions && !issuingSource && quote.status === "refreshing") ||
341
+ (resumeSource && !showInstructions && !revealError);
342
+ if (refreshing || expired) {
343
+ return _jsx(ManualPaymentRefresh, { expired: !refreshing });
344
+ }
345
+ // Action needed: the quote refresh failed. No funds have been sent under a
346
+ // stale address, so the recovery is simply to fetch a fresh amount again.
347
+ if (showInstructions && !issuingSource && quote.status === "failed") {
348
+ 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 ??
349
+ "We couldn't get a fresh payment amount. Please try again." })] }), _jsxs(SetupActions, { children: [_jsx(StyledButton, { onClick: () => {
350
+ void refreshQuote();
351
+ }, variant: "primary", style: { marginTop: 8 }, children: "Try again" }), _jsx(ModalBackButton, { view: "cryptoIntent" })] })] }));
352
+ }
353
+ const relay = instructions?.type === "relay_deposit_address";
354
+ const bitcoin = relay && instructions.source_chain === BITCOIN_CHAIN;
355
+ if (!showInstructions) {
356
+ 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) => {
357
+ setRefundWallet(value);
358
+ setRefundWalletError(null);
359
+ } }) }) }));
360
+ }
361
+ if (instructionsOutdated)
1046
362
  return null;
363
+ const instructionSource = getManualInstructionSource(instructions ?? null);
364
+ const source = relay
365
+ ? sourceOptions.find((option) => option.asset.toLowerCase() ===
366
+ instructionSource?.token.toLowerCase() &&
367
+ option.chain.toLowerCase() === instructionSource?.chain.toLowerCase())
368
+ : settlementCurrency;
369
+ const sourceCurrency = source?.asset_name ?? formatTokenLabel(instructionSource?.token ?? "");
370
+ const sourceChain = source?.chain_name ?? formatChainLabel(instructionSource?.chain ?? "");
371
+ const tokenIconUrl = source?.logo_url;
372
+ const chainIconUrl = source ? getManualChainIconUrl(source) : null;
373
+ const sourceTokenSymbol = source
374
+ ? getSourceTokenSymbol(source, manualPaymentOptions)
375
+ : sourceCurrency;
376
+ const transferInstructions = getManualTransferInstructions(cryptoPaymentAttempt, { chain: sourceChain, currency: bitcoin ? BITCOIN.symbol : sourceCurrency }, funding, shortfall);
377
+ if (transferInstructions.kind === "unavailable_top_up") {
378
+ 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" })] }));
1047
379
  }
1048
- 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" })] })] }));
380
+ if (transferInstructions.kind !== "ready")
381
+ return null;
382
+ return (_jsxs(ManualPaymentLayout, { children: [_jsx(ManualPaymentScrollArea, { children: _jsxs(PaymentDetailsStack, { children: [_jsx(QuoteExpiryCountdown, { remainingMs: countdown.remainingMs, totalDurationMs: countdown.totalDurationMs, primaryColor: config.theme.btn.primary.default.backgroundColor, urgentThresholdRatio: QUOTE_COUNTDOWN_URGENT_THRESHOLD_RATIO }), _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"
383
+ ? instructions.token_symbol
384
+ : settlementCurrency.asset_name }), _jsx(ManualInstructionCard, { ...transferInstructions }, transferInstructions.paymentAddress)] }) }), _jsxs(ManualPaymentActions, { children: [_jsx(StyledButton, { onClick: handleConfirm, variant: "primary", disabled: isConfirmingTransfer, children: isConfirmingTransfer ? "Confirming…" : "I've sent the funds" }), _jsx(StyledButton, { onClick: () => {
385
+ setPaymentDetailsExpanded(false);
386
+ void transitionView(() => setShowInstructions(false));
387
+ }, variant: "secondary", disabled: isConfirmingTransfer, children: "Back" })] })] }));
1049
388
  };
1050
- export { CryptoIntentDirectDetailsViewContent, getManualPaymentAttemptMode, getManualChainIconUrl, getManualInstructionSource, shouldResetManualRefundWalletForSource, shouldLoadManualPaymentOptions, uniqueSourceOptions, };
389
+ export { CryptoIntentDirectDetailsViewContent };
1051
390
  //# sourceMappingURL=direct-details.js.map