@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
@@ -2,19 +2,29 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { useAppKit } from "@reown/appkit/react";
4
4
  import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
5
- import { disconnect, sendTransaction, switchChain, } from "@wagmi/core";
5
+ import { disconnect, getTransaction, getTransactionCount, sendTransaction, switchChain, } from "@wagmi/core";
6
6
  import { useEffect, useRef, useState } from "react";
7
7
  import { styled, ThemeProvider } from "styled-components";
8
+ import { BaseError, UserRejectedRequestError } from "viem";
8
9
  import { useAccount, useConfig, WagmiProvider } from "wagmi";
10
+ import { getApiErrorCode } from "../api/errors.js";
9
11
  import { confirmPaymentRefund, getPaymentRefundStatus, preparePaymentRefund, } from "../api/payments.js";
10
12
  import { getAppKitWagmiConfig, } from "../checkout/providers/wagmi-config.js";
13
+ import { PaymentFundingTimeline } from "../checkout/views/funding-timeline.js";
11
14
  import { StyledButton } from "../components/index.js";
12
15
  import { WalletProvider } from "../components/wallet-selector/provider.js";
13
16
  import { defaultTheme } from "../themes/default.js";
14
- import { waitForRefundConfirmation } from "./confirmation.js";
17
+ import { formatShortAddress } from "../utils/string.js";
18
+ import { formatChainLabel, formatRefundAmount, transactionUrl, } from "../utils/token-amount.js";
15
19
  import { buildRefundPrepareAttemptKey, claimRefundPrepareAttempt, normalizeComparableAddress, } from "./prepare-guard.js";
16
- const shortAddress = (address) => `${address.slice(0, 6)}...${address.slice(-4)}`;
20
+ // Prepare and confirm return a default history page. Keep the preview until
21
+ // the next status read refreshes it.
22
+ const keepRefundPreview = (status, updated) => status.timeline?.has_hidden_transactions === undefined
23
+ ? updated
24
+ : { ...updated, timeline: status.timeline };
17
25
  const REFUND_SELECTOR = "0x590e1ae3";
26
+ // Late deposits and claims reach the refund status through the chain scanner.
27
+ const REFUND_STATUS_REFRESH_MS = 15_000;
18
28
  const Shell = styled.div `
19
29
  width: 100%;
20
30
  display: flex;
@@ -22,19 +32,6 @@ const Shell = styled.div `
22
32
  gap: 18px;
23
33
  text-align: center;
24
34
  `;
25
- const StatusPill = styled.span `
26
- display: inline-flex;
27
- align-items: center;
28
- align-self: center;
29
- padding: 7px 14px;
30
- border-radius: 999px;
31
- background: rgba(24, 178, 138, 0.16);
32
- color: #68e1c0;
33
- font-size: 11px;
34
- font-weight: 700;
35
- letter-spacing: 0.08em;
36
- text-transform: uppercase;
37
- `;
38
35
  const BalancePanel = styled.div `
39
36
  padding: 18px;
40
37
  border-radius: 16px;
@@ -56,35 +53,6 @@ const BalanceValue = styled.div `
56
53
  font-weight: 800;
57
54
  overflow-wrap: anywhere;
58
55
  `;
59
- const Details = styled.div `
60
- display: flex;
61
- flex-direction: column;
62
- border: 1px solid rgba(148, 163, 184, 0.18);
63
- border-radius: 14px;
64
- overflow: hidden;
65
- `;
66
- const DetailRow = styled.div `
67
- display: flex;
68
- justify-content: space-between;
69
- gap: 16px;
70
- padding: 14px 16px;
71
- border-bottom: 1px solid rgba(148, 163, 184, 0.18);
72
- color: #9aa3b5;
73
- font-size: 14px;
74
- text-align: left;
75
- background: rgba(17, 24, 39, 0.62);
76
-
77
- strong {
78
- color: #edf1f7;
79
- font-weight: 600;
80
- text-align: right;
81
- word-break: break-word;
82
- }
83
-
84
- &:last-child {
85
- border-bottom: none;
86
- }
87
- `;
88
56
  const ErrorText = styled.p `
89
57
  margin: 0;
90
58
  color: #d94b4b;
@@ -137,12 +105,14 @@ const Actions = styled.div `
137
105
  gap: 10px;
138
106
  `;
139
107
  const Page = styled.div `
140
- min-height: 100vh;
141
- padding: 32px 20px;
108
+ height: 100vh;
109
+ height: 100dvh;
110
+ overflow-y: auto;
111
+ overscroll-behavior: contain;
112
+ padding: 72px 20px 32px;
142
113
  display: flex;
143
114
  flex-direction: column;
144
115
  align-items: center;
145
- justify-content: center;
146
116
  gap: 24px;
147
117
  position: relative;
148
118
  background: #0b0e16;
@@ -165,7 +135,8 @@ const PageMain = styled.main `
165
135
  display: flex;
166
136
  align-items: center;
167
137
  justify-content: center;
168
- min-height: 100vh;
138
+ flex: 0 0 auto;
139
+ margin-block: auto;
169
140
  width: 100%;
170
141
  `;
171
142
  const PageCard = styled.div `
@@ -195,81 +166,13 @@ function caip2ToChainId(caip2) {
195
166
  function isSubmittedRefundTxHash(value) {
196
167
  return /^(?:0x)?[0-9a-fA-F]{64}$/.test(value);
197
168
  }
198
- function formatStatusLabel(status) {
199
- if (!status)
200
- return "Refund";
201
- return status.replace(/_/g, " ");
202
- }
203
- function formatChainLabel(chain) {
204
- if (chain === "eip155:8453")
205
- return "Base";
206
- if (chain === "eip155:84532")
207
- return "Base Sepolia";
208
- return chain;
209
- }
210
- function formatTokenLabel(token) {
211
- if (/\/(native|slip44:60)$/.test(token))
212
- return "ETH";
213
- const erc20Match = /\/erc20:(0x[a-fA-F0-9]{40})$/.exec(token);
214
- if (!erc20Match)
215
- return token;
216
- const address = erc20Match[1];
217
- if (address.toLowerCase() === "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913") {
218
- return "USDC";
219
- }
220
- return `ERC-20 ${shortAddress(address)}`;
221
- }
222
- function transactionUrl(chain, transactionHash) {
223
- if (chain === "eip155:8453")
224
- return `https://basescan.org/tx/${transactionHash}`;
225
- if (chain === "eip155:84532")
226
- return `https://sepolia.basescan.org/tx/${transactionHash}`;
227
- if (chain === "eip155:1")
228
- return `https://etherscan.io/tx/${transactionHash}`;
229
- if (chain === "eip155:11155111")
230
- return `https://sepolia.etherscan.io/tx/${transactionHash}`;
231
- return null;
232
- }
233
- function tokenDecimals(refundStatus) {
234
- if (refundStatus.token_decimals !== null)
235
- return refundStatus.token_decimals;
236
- const token = refundStatus.token;
237
- if (/\/(native|slip44:60)$/.test(token))
238
- return 18;
239
- const erc20Match = /\/erc20:(0x[a-fA-F0-9]{40})$/.exec(token);
240
- if (!erc20Match)
241
- return 18;
242
- const address = erc20Match[1];
243
- if (address.toLowerCase() === "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913") {
244
- return 6;
245
- }
246
- return 18;
247
- }
248
- function formatTokenAmount(rawAmount, decimals) {
249
- let amount;
250
- try {
251
- amount = BigInt(rawAmount);
252
- }
253
- catch {
254
- return rawAmount;
255
- }
256
- const negative = amount < 0n;
257
- const value = negative ? -amount : amount;
258
- const divisor = 10n ** BigInt(decimals);
259
- const whole = value / divisor;
260
- const fraction = value % divisor;
261
- if (decimals === 0)
262
- return `${negative ? "-" : ""}${whole.toString()}`;
263
- const fractionText = fraction
264
- .toString()
265
- .padStart(decimals, "0")
266
- .slice(0, 6)
267
- .replace(/0+$/, "");
268
- const displayFraction = fractionText.padEnd(2, "0");
269
- return `${negative ? "-" : ""}${whole.toString()}.${displayFraction}`;
270
- }
271
- function formatRefundAmount(refundStatus) {
272
- return `${formatTokenAmount(refundStatus.current_refundable_balance, tokenDecimals(refundStatus))} ${formatTokenLabel(refundStatus.token)}`;
169
+ function isRecordedRefund(status, hash) {
170
+ const normalized = hash.toLowerCase().replace(/^0x/, "");
171
+ return (status.refund_transaction_hash?.toLowerCase().replace(/^0x/, "") ===
172
+ normalized ||
173
+ (status.timeline?.items.some((item) => item.kind === "claim" &&
174
+ item.transaction_hash.toLowerCase().replace(/^0x/, "") === normalized) ??
175
+ false));
273
176
  }
274
177
  function refundUnlockDate(refundStatus) {
275
178
  if (!refundStatus || refundStatus.payment_status === "paid")
@@ -296,7 +199,17 @@ function readSubmittedRefundTx(paymentId, attemptId) {
296
199
  if (typeof parsed.hash === "string" &&
297
200
  isSubmittedRefundTxHash(parsed.hash) &&
298
201
  typeof parsed.submittedAt === "number") {
299
- return { hash: parsed.hash, submittedAt: parsed.submittedAt };
202
+ const { hash, submittedAt, identity } = parsed;
203
+ return {
204
+ hash,
205
+ submittedAt,
206
+ ...(typeof identity?.from === "string" &&
207
+ /^0x[0-9a-f]{40}$/i.test(identity.from) &&
208
+ Number.isSafeInteger(identity.nonce) &&
209
+ identity.nonce >= 0
210
+ ? { identity }
211
+ : {}),
212
+ };
300
213
  }
301
214
  }
302
215
  catch {
@@ -304,17 +217,43 @@ function readSubmittedRefundTx(paymentId, attemptId) {
304
217
  }
305
218
  return null;
306
219
  }
307
- function writeSubmittedRefundTx(paymentId, attemptId, transactionHash) {
220
+ function writeSubmittedRefundTx(paymentId, attemptId, submission) {
308
221
  if (typeof window === "undefined")
309
222
  return;
310
- window.sessionStorage.setItem(refundSubmittedTxStorageKey(paymentId, attemptId), JSON.stringify({ hash: transactionHash, submittedAt: Date.now() }));
223
+ window.sessionStorage.setItem(refundSubmittedTxStorageKey(paymentId, attemptId), JSON.stringify(submission));
311
224
  }
312
225
  function clearSubmittedRefundTx(paymentId, attemptId) {
313
226
  if (typeof window === "undefined")
314
227
  return;
315
228
  window.sessionStorage.removeItem(refundSubmittedTxStorageKey(paymentId, attemptId));
316
229
  }
317
- export async function claimPaymentRefund(refundStatus, { address, wagmiConfig, }) {
230
+ async function reconcileRefundReplacement(config, status, submission) {
231
+ const chainId = caip2ToChainId(status.settlement_chain);
232
+ if (!chainId)
233
+ return { submission, replaced: false };
234
+ const lookup = (hash) => getTransaction(config, {
235
+ chainId,
236
+ hash: `0x${hash.replace(/^0x/i, "")}`,
237
+ }).catch(() => null);
238
+ // Keep the original sender and nonce even if the RPC forgets its hash after
239
+ // a speed-up. A different claim only resolves this submission if it used
240
+ // that same nonce, which makes it impossible for the original to mine too.
241
+ const original = submission.identity ?? (await lookup(submission.hash));
242
+ if (!original)
243
+ return { submission, replaced: false };
244
+ const identity = { from: original.from, nonce: original.nonce };
245
+ const confirmedHash = status.refund_transaction_hash;
246
+ const replacement = confirmedHash && isSubmittedRefundTxHash(confirmedHash)
247
+ ? await lookup(confirmedHash)
248
+ : null;
249
+ return {
250
+ submission: { ...submission, identity },
251
+ replaced: Boolean(replacement?.blockNumber != null) &&
252
+ replacement?.from.toLowerCase() === identity.from.toLowerCase() &&
253
+ replacement?.nonce === identity.nonce,
254
+ };
255
+ }
256
+ async function submitRefund(refundStatus, { address, wagmiConfig, }) {
318
257
  if (!address) {
319
258
  throw new Error("No wallet account connected.");
320
259
  }
@@ -323,7 +262,7 @@ export async function claimPaymentRefund(refundStatus, { address, wagmiConfig, }
323
262
  if (refundStatus.refund_to &&
324
263
  normalizeComparableAddress(refundStatus.settlement_chain, address) !==
325
264
  normalizeComparableAddress(refundStatus.settlement_chain, refundStatus.refund_to)) {
326
- throw new Error(`Connected wallet ${shortAddress(address)} is not the refund recipient. Connect ${shortAddress(refundStatus.refund_to)} and try again.`);
265
+ throw new Error(`Connected wallet ${formatShortAddress(address)} is not the refund recipient. Connect ${formatShortAddress(refundStatus.refund_to)} and try again.`);
327
266
  }
328
267
  const chainId = caip2ToChainId(refundStatus.settlement_chain);
329
268
  if (!chainId) {
@@ -335,11 +274,25 @@ export async function claimPaymentRefund(refundStatus, { address, wagmiConfig, }
335
274
  catch {
336
275
  throw new Error(`Refunds are claimed on the merchant settlement chain (${refundStatus.settlement_chain}). Switch your wallet to that network and try again.`);
337
276
  }
277
+ const from = address;
278
+ // The original hash may already be gone when the wallet returns control.
279
+ // Set the nonce on the send itself so a speed-up can still be identified.
280
+ const nonce = await getTransactionCount(wagmiConfig, {
281
+ address: from,
282
+ chainId,
283
+ blockTag: "pending",
284
+ });
338
285
  const transactionHash = await sendTransaction(wagmiConfig, {
339
- account: address,
286
+ account: from,
287
+ chainId,
288
+ nonce,
340
289
  to: refundStatus.splitter_address,
341
290
  data: REFUND_SELECTOR,
342
291
  });
292
+ return { transactionHash, identity: { from, nonce } };
293
+ }
294
+ export async function claimPaymentRefund(refundStatus, wallet) {
295
+ const { transactionHash } = await submitRefund(refundStatus, wallet);
343
296
  return { transactionHash };
344
297
  }
345
298
  export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
@@ -351,64 +304,106 @@ export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
351
304
  const [busy, setBusy] = useState(false);
352
305
  const [preparing, setPreparing] = useState(false);
353
306
  const [error, setError] = useState(null);
354
- const [txHash, setTxHash] = useState(null);
307
+ const [submittedClaim, setSubmittedClaim] = useState(null);
355
308
  const [claimedAmountLabel, setClaimedAmountLabel] = useState(null);
356
309
  const attemptedPrepareKeys = useRef(new Set());
357
310
  const connectedAddress = account.address ?? null;
358
- const loadStatus = async (address) => {
311
+ useEffect(() => {
359
312
  setLoading(true);
360
313
  setError(null);
361
- try {
362
- const status = await getPaymentRefundStatus(paymentId, {
363
- attemptId,
364
- apiUrl,
365
- connectedAddress: address ?? undefined,
366
- });
367
- setRefundStatus(status);
368
- const submittedTx = readSubmittedRefundTx(paymentId, status.attempt_id);
369
- if (status.attempt_status === "refund_claimed" &&
370
- typeof window !== "undefined") {
371
- clearSubmittedRefundTx(paymentId, status.attempt_id);
372
- const storedAmount = window.sessionStorage.getItem(refundClaimedAmountStorageKey(paymentId, status.attempt_id));
373
- if (storedAmount)
374
- setClaimedAmountLabel(storedAmount);
375
- if (status.refund_transaction_hash) {
376
- setTxHash(status.refund_transaction_hash);
377
- }
378
- }
379
- else if (submittedTx) {
380
- setTxHash(submittedTx.hash);
381
- if (Date.now() - submittedTx.submittedAt > 120_000) {
314
+ }, [apiUrl, paymentId, attemptId, connectedAddress]);
315
+ useEffect(() => {
316
+ if (busy || preparing)
317
+ return;
318
+ const request = new AbortController();
319
+ let timer;
320
+ const options = {
321
+ attemptId,
322
+ apiUrl,
323
+ connectedAddress: connectedAddress ?? undefined,
324
+ signal: request.signal,
325
+ };
326
+ const poll = async () => {
327
+ try {
328
+ let status = await getPaymentRefundStatus(paymentId, {
329
+ ...options,
330
+ timeline: "preview",
331
+ });
332
+ if (request.signal.aborted)
333
+ return;
334
+ const submitted = readSubmittedRefundTx(paymentId, status.attempt_id);
335
+ let hash = submitted?.hash ?? null;
336
+ let recorded = hash !== null && isRecordedRefund(status, hash);
337
+ if (hash && !recorded) {
382
338
  try {
383
- const recorded = await confirmPaymentRefund(paymentId, {
384
- transactionHash: submittedTx.hash,
339
+ const confirmed = await confirmPaymentRefund(paymentId, {
340
+ ...options,
385
341
  attemptId: status.attempt_id,
386
- connectedAddress: address ?? undefined,
387
- apiUrl,
342
+ transactionHash: hash,
388
343
  });
389
- setRefundStatus(recorded);
390
- if (recorded.attempt_status === "refund_claimed") {
344
+ recorded = isRecordedRefund(confirmed, hash);
345
+ status = keepRefundPreview(status, confirmed);
346
+ }
347
+ catch (error) {
348
+ if (request.signal.aborted)
349
+ return;
350
+ if (getApiErrorCode(error) === "REFUND_TRANSACTION_REVERTED") {
391
351
  clearSubmittedRefundTx(paymentId, status.attempt_id);
352
+ hash = null;
353
+ setError("The refund transaction reverted. You can try again.");
392
354
  }
393
355
  }
394
- catch {
356
+ }
357
+ if (request.signal.aborted)
358
+ return;
359
+ if (hash && submitted) {
360
+ const reconciled = recorded
361
+ ? null
362
+ : await reconcileRefundReplacement(wagmiConfig, status, submitted);
363
+ if (request.signal.aborted)
364
+ return;
365
+ if (recorded || reconciled?.replaced) {
395
366
  clearSubmittedRefundTx(paymentId, status.attempt_id);
396
- setTxHash(null);
397
- setError("That transaction did not claim this refund. The refund contract may still need setup.");
367
+ hash = null;
368
+ }
369
+ else if (!submitted.identity && reconciled?.submission.identity) {
370
+ writeSubmittedRefundTx(paymentId, status.attempt_id, reconciled.submission);
398
371
  }
399
372
  }
373
+ setRefundStatus(status);
374
+ setSubmittedClaim(hash ? { attemptId: status.attempt_id, hash } : null);
375
+ setClaimedAmountLabel(window.sessionStorage.getItem(refundClaimedAmountStorageKey(paymentId, status.attempt_id)));
400
376
  }
401
- }
402
- catch (err) {
403
- setError(err instanceof Error ? err.message : "Unable to load refund status.");
404
- }
405
- finally {
406
- setLoading(false);
407
- }
408
- };
409
- useEffect(() => {
410
- void loadStatus(connectedAddress);
411
- }, [apiUrl, paymentId, attemptId, connectedAddress]);
377
+ catch (err) {
378
+ if (request.signal.aborted)
379
+ return;
380
+ setError(err instanceof Error ? err.message : "Unable to load refund status.");
381
+ }
382
+ finally {
383
+ if (!request.signal.aborted) {
384
+ setLoading(false);
385
+ timer = setTimeout(poll, REFUND_STATUS_REFRESH_MS);
386
+ }
387
+ }
388
+ };
389
+ void poll();
390
+ return () => {
391
+ request.abort();
392
+ clearTimeout(timer);
393
+ };
394
+ }, [
395
+ apiUrl,
396
+ attemptId,
397
+ busy,
398
+ connectedAddress,
399
+ paymentId,
400
+ preparing,
401
+ wagmiConfig,
402
+ ]);
403
+ const submittedHash = refundStatus?.payment_id === paymentId &&
404
+ refundStatus.attempt_id === submittedClaim?.attemptId
405
+ ? submittedClaim.hash
406
+ : null;
412
407
  const connectWallet = async () => {
413
408
  setError(null);
414
409
  await open({ view: "Connect" });
@@ -416,7 +411,6 @@ export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
416
411
  const useAnotherWallet = async () => {
417
412
  setBusy(true);
418
413
  setError(null);
419
- setTxHash(null);
420
414
  try {
421
415
  await disconnect(wagmiConfig);
422
416
  }
@@ -448,7 +442,7 @@ export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
448
442
  connectedAddress: prepareConnectedAddress,
449
443
  apiUrl,
450
444
  });
451
- setRefundStatus(prepared);
445
+ setRefundStatus(keepRefundPreview(refundStatus, prepared));
452
446
  }
453
447
  catch (err) {
454
448
  setError(err instanceof Error
@@ -486,23 +480,30 @@ export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
486
480
  await connectWallet();
487
481
  return;
488
482
  }
489
- const result = await claimPaymentRefund(refundStatus, {
483
+ const result = await submitRefund(refundStatus, {
490
484
  address: connectedAddress,
491
485
  wagmiConfig,
492
486
  });
493
- setTxHash(result.transactionHash);
494
- writeSubmittedRefundTx(paymentId, refundStatus.attempt_id, result.transactionHash);
495
- const recorded = await waitForRefundConfirmation(paymentId, {
496
- transactionHash: result.transactionHash,
487
+ setSubmittedClaim({
497
488
  attemptId: refundStatus.attempt_id,
498
- connectedAddress,
499
- apiUrl,
489
+ hash: result.transactionHash,
490
+ });
491
+ writeSubmittedRefundTx(paymentId, refundStatus.attempt_id, {
492
+ hash: result.transactionHash,
493
+ submittedAt: Date.now(),
494
+ identity: result.identity,
500
495
  });
501
- setRefundStatus(recorded);
502
- clearSubmittedRefundTx(paymentId, refundStatus.attempt_id);
503
496
  }
504
497
  catch (err) {
505
- setError(err instanceof Error ? err.message : "Refund transaction failed.");
498
+ if (err instanceof BaseError) {
499
+ const rejected = err.walk((cause) => cause instanceof UserRejectedRequestError);
500
+ setError(rejected
501
+ ? "Refund cancelled in wallet. You can try again."
502
+ : "Unable to submit the refund. Check your wallet and try again.");
503
+ }
504
+ else {
505
+ setError(err instanceof Error ? err.message : "Refund transaction failed.");
506
+ }
506
507
  }
507
508
  finally {
508
509
  setBusy(false);
@@ -531,62 +532,71 @@ export function RefundClaim({ paymentId, attemptId, apiUrl, className, }) {
531
532
  Boolean(refundStatus &&
532
533
  ["refund_available", "surplus_available"].includes(refundStatus.attempt_status));
533
534
  const isRefundUnavailable = Boolean(refundStatus) && !isClaimed && !hasRefundableBalance;
535
+ const refundPending = hasRefundableBalance &&
536
+ !["refund_available", "surplus_available"].includes(refundStatus?.attempt_status ?? "");
537
+ const isSurplus = refundStatus?.attempt_status === "surplus_available";
538
+ const isSubmitted = Boolean(submittedHash) && !isClaimed;
534
539
  const balanceLabel = isClaimed
535
- ? "Refund claimed"
536
- : isRefundUnavailable
537
- ? "Refund balance"
538
- : "Refundable balance";
539
- const balanceValue = refundStatus
540
- ? isClaimed
541
- ? (claimedAmountLabel ?? "Claimed")
542
- : formatRefundAmount(refundStatus)
543
- : null;
544
- const recordedTxHash = refundStatus?.refund_transaction_hash ?? txHash;
545
- const recordedTxUrl = refundStatus && recordedTxHash
546
- ? transactionUrl(refundStatus.settlement_chain, recordedTxHash)
540
+ ? "Amount returned"
541
+ : refundPending
542
+ ? "Amount received"
543
+ : "Amount available";
544
+ const balanceValue = isClaimed
545
+ ? claimedAmountLabel
546
+ : refundStatus && hasRefundableBalance
547
+ ? formatRefundAmount(refundStatus)
548
+ : null;
549
+ const transactionHash = isClaimed
550
+ ? refundStatus.refund_transaction_hash
551
+ : isSubmitted
552
+ ? submittedHash
553
+ : null;
554
+ const explorerUrl = refundStatus && transactionHash
555
+ ? transactionUrl(refundStatus.settlement_chain, transactionHash)
547
556
  : null;
548
- const isSubmitted = Boolean(txHash) && !isClaimed;
549
557
  const claimedAtLabel = refundStatus?.refund_claimed_at
550
558
  ? new Date(refundStatus.refund_claimed_at).toLocaleString()
551
559
  : null;
552
- return (_jsxs(Shell, { className: className, children: [_jsx(StatusPill, { children: formatStatusLabel(refundStatus?.attempt_status) }), _jsx(TitleText, { children: isClaimed
553
- ? "Refund claimed"
554
- : isSubmitted
555
- ? "Refund submitted"
556
- : isRefundUnavailable
557
- ? "Refund unavailable"
558
- : "Claim refund" }), loading ? _jsx(SubtleText, { children: "Loading refund status..." }) : null, preparing ? _jsx(SubtleText, { children: "Preparing refund contract..." }) : null, refundStatus ? (_jsxs(_Fragment, { children: [_jsxs(BalancePanel, { children: [_jsx(BalanceLabel, { children: balanceLabel }), _jsx(BalanceValue, { children: balanceValue })] }), _jsxs(Details, { children: [_jsxs(DetailRow, { children: [_jsx("span", { children: "Settlement token" }), _jsx("strong", { children: formatTokenLabel(refundStatus.token) })] }), _jsxs(DetailRow, { children: [_jsx("span", { children: "Settlement chain" }), _jsx("strong", { children: formatChainLabel(refundStatus.settlement_chain) })] }), _jsxs(DetailRow, { children: [_jsx("span", { children: "Refund contract" }), _jsx("strong", { title: refundStatus.splitter_address, children: shortAddress(refundStatus.splitter_address) })] })] }), isClaimed ? (_jsxs(HelperText, { children: ["The refundable balance was returned to", " ", refundStatus.refund_to
559
- ? shortAddress(refundStatus.refund_to)
560
- : "the refund wallet", claimedAtLabel ? ` on ${claimedAtLabel}` : "", "."] })) : isSubmitted ? (_jsxs(HelperText, { children: ["Refund transaction submitted from", " ", connectedAddress
561
- ? shortAddress(connectedAddress)
562
- : "your connected wallet", ". This page will update after the claim is confirmed."] })) : !hasRefundableBalance ? (_jsx(HelperText, { children: "This payment attempt expired with no recoverable funds." })) : !refundRecipient ? (_jsx(HelperText, { children: "This attempt needs merchant recovery before a refund can be claimed." })) : connectedAddress && !connectedMatchesRefundRecipient ? (_jsxs(HelperText, { children: ["Connected wallet ", shortAddress(connectedAddress), " is not the refund recipient. Connect ", shortAddress(refundRecipient), " to claim."] })) : connectedMatchesRefundRecipient ? (_jsx(HelperText, { children: waitingForRefundWindow
560
+ return (_jsxs(Shell, { className: className, children: [_jsx(TitleText, { children: !refundStatus
561
+ ? "Refund"
562
+ : isClaimed
563
+ ? "Refund claimed"
564
+ : isSubmitted
565
+ ? "Refund submitted"
566
+ : isRefundUnavailable
567
+ ? "Refund unavailable"
568
+ : refundPending || waitingForRefundWindow
569
+ ? "Refund pending"
570
+ : isSurplus
571
+ ? "Surplus available"
572
+ : "Refund available" }), loading ? _jsx(SubtleText, { children: "Loading refund details\u2026" }) : null, refundStatus ? (_jsxs(_Fragment, { children: [balanceValue ? (_jsxs(BalancePanel, { children: [_jsx(BalanceLabel, { children: balanceLabel }), _jsx(BalanceValue, { children: balanceValue })] })) : null, _jsx(SubtleText, { children: formatChainLabel(refundStatus.settlement_chain) }), isClaimed ? (_jsxs(HelperText, { children: ["Returned to", " ", refundStatus.refund_to
573
+ ? formatShortAddress(refundStatus.refund_to)
574
+ : "the refund wallet", claimedAtLabel ? ` on ${claimedAtLabel}` : "", "."] })) : isSubmitted ? (_jsx(HelperText, { children: "This page will update once the network confirms your transaction." })) : refundPending ? (_jsx(HelperText, { children: refundStatus.funding?.settlement_cutoff_at &&
575
+ Date.parse(refundStatus.funding.settlement_cutoff_at) > Date.now()
576
+ ? "You can send the rest from your original payment link."
577
+ : "This page will update when the refund is available." })) : !hasRefundableBalance ? (_jsx(HelperText, { children: "There\u2019s no refundable balance for this payment." })) : !refundRecipient ? (_jsx(HelperText, { children: "This attempt needs merchant recovery before a refund can be claimed." })) : connectedAddress && !connectedMatchesRefundRecipient ? (_jsxs(HelperText, { children: ["Connected wallet ", formatShortAddress(connectedAddress), " is not the refund recipient. Connect ", formatShortAddress(refundRecipient), " to claim."] })) : connectedMatchesRefundRecipient ? (_jsx(HelperText, { children: waitingForRefundWindow
563
578
  ? `Refunds can be claimed after ${refundAvailableAt?.toLocaleString()} if this payment does not settle.`
564
579
  : needsRefundSetup
565
- ? preparing
566
- ? "Preparing the refund contract for this wallet."
567
- : "Prepare the refund contract before claiming."
568
- : `Connected refund wallet ${shortAddress(refundRecipient)} can claim this refund.` })) : (_jsxs(HelperText, { children: ["Connect refund wallet ", shortAddress(refundRecipient), " to claim."] }))] })) : null, error ? _jsx(ErrorText, { children: error }) : null, isClaimed && recordedTxHash ? (_jsxs(SuccessText, { children: ["Refund transaction:", " ", recordedTxUrl ? (_jsx(TransactionLink, { href: recordedTxUrl, target: "_blank", rel: "noreferrer", children: recordedTxHash })) : (recordedTxHash)] })) : txHash ? (_jsxs(SuccessText, { children: ["Refund transaction submitted:", " ", refundStatus &&
569
- transactionUrl(refundStatus.settlement_chain, txHash) ? (_jsx(TransactionLink, { href: transactionUrl(refundStatus.settlement_chain, txHash) ??
570
- undefined, target: "_blank", rel: "noreferrer", children: txHash })) : (txHash)] })) : null, isClaimed ||
580
+ ? "Set up this wallet on the settlement network to continue."
581
+ : `Connected as ${formatShortAddress(refundRecipient)}.` })) : (_jsxs(HelperText, { children: ["Connect refund wallet ", formatShortAddress(refundRecipient), " to claim."] }))] })) : null, error && !isClaimed ? _jsx(ErrorText, { children: error }) : null, transactionHash ? (_jsx(SuccessText, { children: explorerUrl ? (_jsx(TransactionLink, { href: explorerUrl, target: "_blank", rel: "noreferrer", title: transactionHash, children: "View transaction" })) : (transactionHash) })) : null, isClaimed ||
571
582
  isRefundUnavailable ||
583
+ refundPending ||
584
+ waitingForRefundWindow ||
572
585
  isSubmitted ? null : !connectedAddress ? (_jsx(Actions, { children: _jsx(StyledButton, { onClick: () => void connectWallet(), disabled: busy, children: "Connect wallet" }) })) : (_jsxs(Actions, { children: [_jsx(StyledButton, { onClick: () => {
573
586
  if (needsRefundSetup) {
574
587
  retryRefundSetup();
575
588
  return;
576
589
  }
577
590
  void claimRefund();
578
- }, disabled: busy ||
579
- preparing ||
580
- waitingForRefundWindow ||
581
- (!canClaim && !needsRefundSetup), children: waitingForRefundWindow
582
- ? "Refund not ready"
583
- : preparing
584
- ? "Preparing refund..."
585
- : needsRefundSetup
586
- ? "Prepare refund"
587
- : busy
588
- ? "Submitting..."
589
- : "Claim refund" }), !canClaim && !needsRefundSetup && !waitingForRefundWindow ? (_jsx(StyledButton, { variant: "secondary", onClick: () => void useAnotherWallet(), disabled: busy, children: "Use another wallet" })) : null] }))] }));
591
+ }, disabled: busy || preparing || (!canClaim && !needsRefundSetup), children: preparing
592
+ ? "Preparing refund…"
593
+ : needsRefundSetup
594
+ ? "Prepare refund"
595
+ : busy
596
+ ? "Submitting…"
597
+ : isSurplus
598
+ ? "Claim surplus"
599
+ : "Claim refund" }), !canClaim && !needsRefundSetup ? (_jsx(StyledButton, { variant: "secondary", onClick: () => void useAnotherWallet(), disabled: busy, children: "Use another wallet" })) : null] })), refundStatus ? (_jsx(PaymentFundingTimeline, { funding: refundStatus.funding, timeline: refundStatus.timeline, tokenSymbol: refundStatus.token_symbol })) : null] }));
590
600
  }
591
601
  export function RefundClaimPage({ logoSrc = "/logo.svg", wagmiConfig, walletConnectProjectId, ...props }) {
592
602
  const wagmi = useRef();