@layerswap/widget 1.0.5 → 1.1.0

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 (361) hide show
  1. package/dist/esm/Models/LayerSwapSettings.js +0 -1
  2. package/dist/esm/Models/Theme.js +39 -8
  3. package/dist/esm/components/Buttons/copyButton.js +5 -3
  4. package/dist/esm/components/Buttons/submitButton.js +2 -1
  5. package/dist/esm/components/ColorSchema.js +3 -10
  6. package/dist/esm/components/Common/ConnectWalletButton.js +9 -3
  7. package/dist/esm/components/Common/CountDownTimer.js +0 -15
  8. package/dist/esm/components/Common/WarningMessage.js +4 -2
  9. package/dist/esm/components/Common/guideLink.js +4 -6
  10. package/dist/esm/components/ErrorFallback.js +11 -11
  11. package/dist/esm/components/HeaderWithMenu.js +1 -1
  12. package/dist/esm/components/Icons/Wallets/Xverse.js +3 -0
  13. package/dist/esm/components/Icons/Wallets/index.js +1 -0
  14. package/dist/esm/components/Input/Address/AddressPicker/index.js +15 -12
  15. package/dist/esm/components/Input/Amount/Balance.js +8 -2
  16. package/dist/esm/components/Input/Amount/ExchangeReceiveAmount.js +8 -0
  17. package/dist/esm/components/Input/Amount/MinMax.js +1 -1
  18. package/dist/esm/components/Input/Amount/PriceImpact.js +5 -38
  19. package/dist/esm/components/Input/Amount/ReceiveAmount.js +2 -2
  20. package/dist/esm/components/Input/Amount/index.js +3 -3
  21. package/dist/esm/components/Input/DestinationPicker.js +2 -2
  22. package/dist/esm/components/Input/NumericInput.js +7 -4
  23. package/dist/esm/components/Input/RoutePicker/Content.js +19 -3
  24. package/dist/esm/components/Input/RoutePicker/RouterPickerWalletConnect.js +5 -5
  25. package/dist/esm/components/Input/RoutePicker/Routes.js +18 -18
  26. package/dist/esm/components/Input/RoutePicker/Rows/CollapsableHeader.js +2 -2
  27. package/dist/esm/components/Input/RoutePicker/Rows/CollapsibleRow.js +3 -3
  28. package/dist/esm/components/Input/RoutePicker/Rows/StickyHeader.js +2 -2
  29. package/dist/esm/components/Input/RoutePicker/Rows/SuggestionsHeader.js +55 -0
  30. package/dist/esm/components/Input/RoutePicker/Rows/TitleRow.js +11 -0
  31. package/dist/esm/components/Input/RoutePicker/Rows/index.js +6 -7
  32. package/dist/esm/components/Input/RoutePicker/index.js +2 -2
  33. package/dist/esm/components/Input/SourceWalletPicker.js +7 -5
  34. package/dist/esm/components/Menu/index.js +2 -2
  35. package/dist/esm/components/Modal/vaulModal.js +11 -16
  36. package/dist/esm/components/Pages/Campaigns/Details/Leaderboard.js +2 -2
  37. package/dist/esm/components/Pages/Campaigns/Details/Rewards.js +2 -2
  38. package/dist/esm/components/Pages/Campaigns/Details/index.js +2 -3
  39. package/dist/esm/components/Pages/Campaigns/index.js +3 -4
  40. package/dist/esm/components/Pages/Swap/Form/ExchangeForm.js +21 -19
  41. package/dist/esm/components/Pages/Swap/Form/FeeDetails/Rate.js +5 -4
  42. package/dist/esm/components/Pages/Swap/Form/FeeDetails/Refuel.js +8 -6
  43. package/dist/esm/components/Pages/Swap/Form/FeeDetails/Slippage.js +6 -1
  44. package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.js +51 -14
  45. package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/SummaryRow.js +2 -2
  46. package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.js +4 -4
  47. package/dist/esm/components/Pages/Swap/Form/FeeDetails/index.js +8 -9
  48. package/dist/esm/components/Pages/Swap/Form/Form.js +27 -3
  49. package/dist/esm/components/Pages/Swap/Form/FormWrapper.js +8 -14
  50. package/dist/esm/components/Pages/Swap/Form/NetworkForm.js +11 -13
  51. package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.js +8 -6
  52. package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/validationError/ErrorDisplay.js +1 -1
  53. package/dist/esm/components/Pages/Swap/Withdraw/Failed.js +12 -8
  54. package/dist/esm/components/Pages/Swap/Withdraw/ManualWithdraw.js +29 -10
  55. package/dist/esm/components/Pages/Swap/Withdraw/NotFound.js +15 -4
  56. package/dist/esm/components/Pages/Swap/Withdraw/Processing/Processing.js +36 -41
  57. package/dist/esm/components/Pages/Swap/Withdraw/Summary/Summary.js +3 -3
  58. package/dist/esm/components/Pages/Swap/Withdraw/Summary/index.js +3 -3
  59. package/dist/esm/components/Pages/Swap/Withdraw/SwapDetails.js +9 -7
  60. package/dist/esm/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.js +43 -0
  61. package/dist/esm/components/Pages/Swap/Withdraw/Wallet/Common/buttons.js +118 -71
  62. package/dist/esm/components/Pages/Swap/Withdraw/Wallet/index.js +56 -65
  63. package/dist/esm/components/Pages/Swap/Withdraw/WalletTransferButton.js +2 -2
  64. package/dist/esm/components/Pages/Swap/Withdraw/WalletTransferContent.js +2 -2
  65. package/dist/esm/components/Pages/Swap/Withdraw/Withdraw.js +3 -3
  66. package/dist/esm/components/Pages/Swap/Withdraw/index.js +5 -4
  67. package/dist/esm/components/Pages/Swap/Withdraw/messages/TransactionMessages.js +14 -15
  68. package/dist/esm/components/Pages/SwapHistory/History.js +2 -2
  69. package/dist/esm/components/Pages/SwapHistory/SwapDetailsComponent.js +4 -1
  70. package/dist/esm/components/Pages/SwapHistory/index.js +6 -6
  71. package/dist/esm/components/Wallet/WalletComponents/ConnectedWallets.js +1 -1
  72. package/dist/esm/components/Wallet/WalletComponents/WalletsList.js +4 -3
  73. package/dist/esm/components/Wallet/WalletModal/Connector.js +2 -2
  74. package/dist/esm/components/Wallet/WalletModal/ConnectorsList.js +49 -24
  75. package/dist/esm/components/Wallet/WalletModal/index.js +3 -1
  76. package/dist/esm/components/Wallet/WalletProviders/index.js +4 -2
  77. package/dist/esm/components/Widget/Content.js +2 -2
  78. package/dist/esm/components/Widget/Footer.js +1 -1
  79. package/dist/esm/components/Widget/Index.js +2 -3
  80. package/dist/esm/components/WidgetLoading.js +9 -2
  81. package/dist/esm/components/utils/RoundDecimals.js +4 -2
  82. package/dist/esm/context/ErrorProvider.js +14 -0
  83. package/dist/esm/context/LayerswapProvider.js +6 -5
  84. package/dist/esm/context/asyncModal.js +1 -1
  85. package/dist/esm/context/callbackProvider.js +54 -60
  86. package/dist/esm/context/resolverContext.js +7 -2
  87. package/dist/esm/context/swap.js +13 -18
  88. package/dist/esm/context/{balanceAccounts.js → swapAccounts.js} +17 -17
  89. package/dist/esm/context/validationContext.js +1 -1
  90. package/dist/esm/context/walletProviders.js +7 -1
  91. package/dist/esm/context/withdrawalContext.js +2 -2
  92. package/dist/esm/exports/internal.js +4 -3
  93. package/dist/esm/helpers/filterSourceNetworks.js +23 -0
  94. package/dist/esm/helpers/getSettings/getSettings.js +18 -13
  95. package/dist/esm/helpers/routes.js +4 -1
  96. package/dist/esm/hooks/useAllWithdrawalBalances.js +6 -5
  97. package/dist/esm/hooks/useFormRoutes.js +16 -8
  98. package/dist/esm/hooks/useFormValidation.js +11 -6
  99. package/dist/esm/hooks/useRouteValidation.js +1 -1
  100. package/dist/esm/hooks/useSwrSwaps.js +1 -1
  101. package/dist/esm/hooks/useTransfer.js +9 -0
  102. package/dist/esm/hooks/useWallet.js +7 -7
  103. package/dist/esm/lib/AppSettings.js +28 -17
  104. package/dist/esm/lib/ErrorHandler.js +6 -0
  105. package/dist/esm/lib/NetworkSettings.js +0 -16
  106. package/dist/esm/lib/apiClients/layerSwapApiClient.js +12 -35
  107. package/dist/esm/lib/axiosInterceptor.js +2 -2
  108. package/dist/esm/lib/balances/balanceResolver.js +9 -13
  109. package/dist/esm/lib/fees.js +50 -0
  110. package/dist/esm/lib/resolvers/resolverService.js +10 -1
  111. package/dist/esm/lib/transfers/index.js +1 -0
  112. package/dist/esm/lib/transfers/transferResolver.js +14 -0
  113. package/dist/esm/stores/balanceStore.js +1 -2
  114. package/dist/esm/stores/logStore.js +11 -0
  115. package/dist/esm/types/balance.js +8 -9
  116. package/dist/esm/types/index.js +1 -0
  117. package/dist/esm/types/logEvents.js +1 -0
  118. package/dist/index.css +2 -2
  119. package/dist/tsconfig.tsbuildinfo +1 -1
  120. package/dist/types/Models/Balance.d.ts +1 -1
  121. package/dist/types/Models/LayerSwapSettings.d.ts +7 -0
  122. package/dist/types/Models/LayerSwapSettings.d.ts.map +1 -1
  123. package/dist/types/Models/Theme.d.ts +0 -3
  124. package/dist/types/Models/Theme.d.ts.map +1 -1
  125. package/dist/types/components/Buttons/copyButton.d.ts +3 -1
  126. package/dist/types/components/Buttons/copyButton.d.ts.map +1 -1
  127. package/dist/types/components/Buttons/submitButton.d.ts +1 -1
  128. package/dist/types/components/Buttons/submitButton.d.ts.map +1 -1
  129. package/dist/types/components/ColorSchema.d.ts.map +1 -1
  130. package/dist/types/components/Common/ConnectWalletButton.d.ts +1 -1
  131. package/dist/types/components/Common/ConnectWalletButton.d.ts.map +1 -1
  132. package/dist/types/components/Common/CountDownTimer.d.ts.map +1 -1
  133. package/dist/types/components/Common/WarningMessage.d.ts.map +1 -1
  134. package/dist/types/components/Common/guideLink.d.ts.map +1 -1
  135. package/dist/types/components/ErrorFallback.d.ts.map +1 -1
  136. package/dist/types/components/HeaderWithMenu.d.ts.map +1 -1
  137. package/dist/types/components/Icons/Wallets/Xverse.d.ts +4 -0
  138. package/dist/types/components/Icons/Wallets/Xverse.d.ts.map +1 -0
  139. package/dist/types/components/Icons/Wallets/index.d.ts +1 -0
  140. package/dist/types/components/Icons/Wallets/index.d.ts.map +1 -1
  141. package/dist/types/components/Input/Address/AddressNote.d.ts +2 -2
  142. package/dist/types/components/Input/Address/AddressPicker/AddressBook.d.ts +3 -3
  143. package/dist/types/components/Input/Address/AddressPicker/AddressButton.d.ts +3 -3
  144. package/dist/types/components/Input/Address/AddressPicker/AddressWithIcon.d.ts +2 -2
  145. package/dist/types/components/Input/Address/AddressPicker/ConnectedWallets.d.ts +2 -2
  146. package/dist/types/components/Input/Address/AddressPicker/ManualAddressInput.d.ts +4 -4
  147. package/dist/types/components/Input/Address/AddressPicker/index.d.ts +4 -4
  148. package/dist/types/components/Input/Address/AddressPicker/index.d.ts.map +1 -1
  149. package/dist/types/components/Input/Address/index.d.ts +1 -1
  150. package/dist/types/components/Input/Amount/Balance.d.ts +1 -1
  151. package/dist/types/components/Input/Amount/Balance.d.ts.map +1 -1
  152. package/dist/types/components/Input/Amount/ExchangeReceiveAmount.d.ts +11 -0
  153. package/dist/types/components/Input/Amount/ExchangeReceiveAmount.d.ts.map +1 -0
  154. package/dist/types/components/Input/Amount/MinMax.d.ts +1 -1
  155. package/dist/types/components/Input/Amount/PriceImpact.d.ts +2 -6
  156. package/dist/types/components/Input/Amount/PriceImpact.d.ts.map +1 -1
  157. package/dist/types/components/Input/Amount/ReceiveAmount.d.ts +2 -3
  158. package/dist/types/components/Input/Amount/ReceiveAmount.d.ts.map +1 -1
  159. package/dist/types/components/Input/Amount/helpers.d.ts +2 -2
  160. package/dist/types/components/Input/Amount/index.d.ts +1 -1
  161. package/dist/types/components/Input/CexPicker.d.ts +1 -1
  162. package/dist/types/components/Input/DestinationPicker.d.ts +1 -1
  163. package/dist/types/components/Input/DestinationPicker.d.ts.map +1 -1
  164. package/dist/types/components/Input/NumericInput.d.ts.map +1 -1
  165. package/dist/types/components/Input/RoutePicker/Content.d.ts +5 -5
  166. package/dist/types/components/Input/RoutePicker/Content.d.ts.map +1 -1
  167. package/dist/types/components/Input/RoutePicker/RouterPickerWalletConnect.d.ts +1 -1
  168. package/dist/types/components/Input/RoutePicker/Routes.d.ts +4 -8
  169. package/dist/types/components/Input/RoutePicker/Routes.d.ts.map +1 -1
  170. package/dist/types/components/Input/RoutePicker/Rows/CollapsableHeader.d.ts +3 -4
  171. package/dist/types/components/Input/RoutePicker/Rows/CollapsableHeader.d.ts.map +1 -1
  172. package/dist/types/components/Input/RoutePicker/Rows/CollapsibleRow.d.ts +6 -5
  173. package/dist/types/components/Input/RoutePicker/Rows/CollapsibleRow.d.ts.map +1 -1
  174. package/dist/types/components/Input/RoutePicker/Rows/StickyHeader.d.ts +3 -4
  175. package/dist/types/components/Input/RoutePicker/Rows/StickyHeader.d.ts.map +1 -1
  176. package/dist/types/components/Input/RoutePicker/Rows/SuggestionsHeader.d.ts +7 -0
  177. package/dist/types/components/Input/RoutePicker/Rows/SuggestionsHeader.d.ts.map +1 -0
  178. package/dist/types/components/Input/RoutePicker/Rows/TitleRow.d.ts +7 -0
  179. package/dist/types/components/Input/RoutePicker/Rows/TitleRow.d.ts.map +1 -0
  180. package/dist/types/components/Input/RoutePicker/Rows/index.d.ts +5 -5
  181. package/dist/types/components/Input/RoutePicker/Rows/index.d.ts.map +1 -1
  182. package/dist/types/components/Input/RoutePicker/index.d.ts +1 -1
  183. package/dist/types/components/Input/RoutePicker/index.d.ts.map +1 -1
  184. package/dist/types/components/Input/SourcePicker.d.ts +1 -1
  185. package/dist/types/components/Input/SourceWalletPicker.d.ts.map +1 -1
  186. package/dist/types/components/Modal/vaulModal.d.ts.map +1 -1
  187. package/dist/types/components/Pages/Campaigns/Details/Leaderboard.d.ts +1 -1
  188. package/dist/types/components/Pages/Campaigns/Details/Rewards.d.ts +1 -1
  189. package/dist/types/components/Pages/Campaigns/Details/index.d.ts +1 -2
  190. package/dist/types/components/Pages/Campaigns/Details/index.d.ts.map +1 -1
  191. package/dist/types/components/Pages/Campaigns/index.d.ts +2 -3
  192. package/dist/types/components/Pages/Campaigns/index.d.ts.map +1 -1
  193. package/dist/types/components/Pages/Swap/Form/ExchangeForm.d.ts +3 -1
  194. package/dist/types/components/Pages/Swap/Form/ExchangeForm.d.ts.map +1 -1
  195. package/dist/types/components/Pages/Swap/Form/FeeDetails/Rate.d.ts +7 -6
  196. package/dist/types/components/Pages/Swap/Form/FeeDetails/Rate.d.ts.map +1 -1
  197. package/dist/types/components/Pages/Swap/Form/FeeDetails/ReceiveAmounts.d.ts +2 -2
  198. package/dist/types/components/Pages/Swap/Form/FeeDetails/Refuel.d.ts +1 -1
  199. package/dist/types/components/Pages/Swap/Form/FeeDetails/Refuel.d.ts.map +1 -1
  200. package/dist/types/components/Pages/Swap/Form/FeeDetails/RefuelModal.d.ts +1 -1
  201. package/dist/types/components/Pages/Swap/Form/FeeDetails/Slippage.d.ts +1 -1
  202. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.d.ts +3 -2
  203. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.d.ts.map +1 -1
  204. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/SummaryRow.d.ts +4 -4
  205. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.d.ts +4 -4
  206. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.d.ts.map +1 -1
  207. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/utils.d.ts +2 -2
  208. package/dist/types/components/Pages/Swap/Form/FeeDetails/index.d.ts +7 -4
  209. package/dist/types/components/Pages/Swap/Form/FeeDetails/index.d.ts.map +1 -1
  210. package/dist/types/components/Pages/Swap/Form/Form.d.ts.map +1 -1
  211. package/dist/types/components/Pages/Swap/Form/FormWrapper.d.ts +1 -1
  212. package/dist/types/components/Pages/Swap/Form/FormWrapper.d.ts.map +1 -1
  213. package/dist/types/components/Pages/Swap/Form/NetworkForm.d.ts +1 -1
  214. package/dist/types/components/Pages/Swap/Form/NetworkForm.d.ts.map +1 -1
  215. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/FormButton.d.ts +1 -1
  216. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.d.ts +2 -2
  217. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.d.ts.map +1 -1
  218. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/validationError/ErrorDisplay.d.ts +1 -1
  219. package/dist/types/components/Pages/Swap/Form/SwapFormValues.d.ts +2 -2
  220. package/dist/types/components/Pages/Swap/Withdraw/Failed.d.ts.map +1 -1
  221. package/dist/types/components/Pages/Swap/Withdraw/ManualWithdraw.d.ts +4 -3
  222. package/dist/types/components/Pages/Swap/Withdraw/ManualWithdraw.d.ts.map +1 -1
  223. package/dist/types/components/Pages/Swap/Withdraw/NotFound.d.ts.map +1 -1
  224. package/dist/types/components/Pages/Swap/Withdraw/Processing/Processing.d.ts +1 -1
  225. package/dist/types/components/Pages/Swap/Withdraw/Processing/Processing.d.ts.map +1 -1
  226. package/dist/types/components/Pages/Swap/Withdraw/QuoteUpdate.d.ts +1 -1
  227. package/dist/types/components/Pages/Swap/Withdraw/Summary/Summary.d.ts +1 -1
  228. package/dist/types/components/Pages/Swap/Withdraw/SwapDetails.d.ts +2 -1
  229. package/dist/types/components/Pages/Swap/Withdraw/SwapDetails.d.ts.map +1 -1
  230. package/dist/types/components/Pages/Swap/Withdraw/SwapQuoteDetails.d.ts +3 -3
  231. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.d.ts +6 -0
  232. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.d.ts.map +1 -0
  233. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/buttons.d.ts +4 -3
  234. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/buttons.d.ts.map +1 -1
  235. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/sharedTypes.d.ts +2 -1
  236. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/sharedTypes.d.ts.map +1 -1
  237. package/dist/types/components/Pages/Swap/Withdraw/Wallet/index.d.ts +2 -1
  238. package/dist/types/components/Pages/Swap/Withdraw/Wallet/index.d.ts.map +1 -1
  239. package/dist/types/components/Pages/Swap/Withdraw/WalletTransferButton.d.ts +2 -1
  240. package/dist/types/components/Pages/Swap/Withdraw/WalletTransferButton.d.ts.map +1 -1
  241. package/dist/types/components/Pages/Swap/Withdraw/WalletTransferContent.d.ts +1 -1
  242. package/dist/types/components/Pages/Swap/Withdraw/Withdraw.d.ts +2 -1
  243. package/dist/types/components/Pages/Swap/Withdraw/Withdraw.d.ts.map +1 -1
  244. package/dist/types/components/Pages/Swap/Withdraw/index.d.ts +1 -2
  245. package/dist/types/components/Pages/Swap/Withdraw/index.d.ts.map +1 -1
  246. package/dist/types/components/Pages/Swap/Withdraw/messages/TransactionMessages.d.ts +3 -4
  247. package/dist/types/components/Pages/Swap/Withdraw/messages/TransactionMessages.d.ts.map +1 -1
  248. package/dist/types/components/Pages/SwapHistory/HistorySummary.d.ts +2 -2
  249. package/dist/types/components/Pages/SwapHistory/StatusIcons.d.ts +1 -1
  250. package/dist/types/components/Pages/SwapHistory/SwapDetailsComponent.d.ts +1 -1
  251. package/dist/types/components/Pages/SwapHistory/SwapDetailsComponent.d.ts.map +1 -1
  252. package/dist/types/components/Pages/SwapHistory/index.d.ts +3 -1
  253. package/dist/types/components/Pages/SwapHistory/index.d.ts.map +1 -1
  254. package/dist/types/components/Wallet/WalletComponents/WalletsList.d.ts +3 -3
  255. package/dist/types/components/Wallet/WalletComponents/WalletsList.d.ts.map +1 -1
  256. package/dist/types/components/Wallet/WalletModal/Connector.d.ts +2 -1
  257. package/dist/types/components/Wallet/WalletModal/Connector.d.ts.map +1 -1
  258. package/dist/types/components/Wallet/WalletModal/ConnectorsList.d.ts +1 -1
  259. package/dist/types/components/Wallet/WalletModal/ConnectorsList.d.ts.map +1 -1
  260. package/dist/types/components/Wallet/WalletModal/index.d.ts +1 -1
  261. package/dist/types/components/Wallet/WalletModal/index.d.ts.map +1 -1
  262. package/dist/types/components/Wallet/WalletProviders/index.d.ts +3 -1
  263. package/dist/types/components/Wallet/WalletProviders/index.d.ts.map +1 -1
  264. package/dist/types/components/Widget/Content.d.ts +2 -1
  265. package/dist/types/components/Widget/Content.d.ts.map +1 -1
  266. package/dist/types/components/Widget/Footer.d.ts +2 -1
  267. package/dist/types/components/Widget/Footer.d.ts.map +1 -1
  268. package/dist/types/components/Widget/Index.d.ts +3 -2
  269. package/dist/types/components/Widget/Index.d.ts.map +1 -1
  270. package/dist/types/components/WidgetLoading.d.ts.map +1 -1
  271. package/dist/types/components/shadcn/command.d.ts +9 -52
  272. package/dist/types/components/shadcn/command.d.ts.map +1 -1
  273. package/dist/types/components/utils/RoundDecimals.d.ts.map +1 -1
  274. package/dist/types/context/ErrorProvider.d.ts +3 -0
  275. package/dist/types/context/ErrorProvider.d.ts.map +1 -0
  276. package/dist/types/context/LayerswapProvider.d.ts +22 -4
  277. package/dist/types/context/LayerswapProvider.d.ts.map +1 -1
  278. package/dist/types/context/callbackProvider.d.ts +6 -12
  279. package/dist/types/context/callbackProvider.d.ts.map +1 -1
  280. package/dist/types/context/resolverContext.d.ts.map +1 -1
  281. package/dist/types/context/swap.d.ts +7 -7
  282. package/dist/types/context/swap.d.ts.map +1 -1
  283. package/dist/types/context/{balanceAccounts.d.ts → swapAccounts.d.ts} +9 -9
  284. package/dist/types/context/swapAccounts.d.ts.map +1 -0
  285. package/dist/types/context/validationContext.d.ts +1 -0
  286. package/dist/types/context/validationContext.d.ts.map +1 -1
  287. package/dist/types/context/walletProviders.d.ts.map +1 -1
  288. package/dist/types/context/withdrawalContext.d.ts +2 -0
  289. package/dist/types/context/withdrawalContext.d.ts.map +1 -1
  290. package/dist/types/exports/internal.d.ts +9 -7
  291. package/dist/types/exports/internal.d.ts.map +1 -1
  292. package/dist/types/helpers/accountSelectHelper.d.ts +1 -1
  293. package/dist/types/helpers/balanceHelper.d.ts +2 -2
  294. package/dist/types/helpers/filterSourceNetworks.d.ts +4 -0
  295. package/dist/types/helpers/filterSourceNetworks.d.ts.map +1 -0
  296. package/dist/types/helpers/getSettings/getSettings.d.ts +1 -1
  297. package/dist/types/helpers/getSettings/getSettings.d.ts.map +1 -1
  298. package/dist/types/helpers/routes.d.ts +1 -1
  299. package/dist/types/helpers/routes.d.ts.map +1 -1
  300. package/dist/types/helpers/tokenHelper.d.ts +2 -2
  301. package/dist/types/hooks/useAllWithdrawalBalances.d.ts +2 -1
  302. package/dist/types/hooks/useAllWithdrawalBalances.d.ts.map +1 -1
  303. package/dist/types/hooks/useFee.d.ts +1 -1
  304. package/dist/types/hooks/useFormRoutes.d.ts +2 -3
  305. package/dist/types/hooks/useFormRoutes.d.ts.map +1 -1
  306. package/dist/types/hooks/useFormValidation.d.ts +10 -1
  307. package/dist/types/hooks/useFormValidation.d.ts.map +1 -1
  308. package/dist/types/hooks/useSwapHistoryData.d.ts +2 -2
  309. package/dist/types/hooks/useTransfer.d.ts +5 -0
  310. package/dist/types/hooks/useTransfer.d.ts.map +1 -0
  311. package/dist/types/hooks/useWallet.d.ts +3 -3
  312. package/dist/types/hooks/useWallet.d.ts.map +1 -1
  313. package/dist/types/lib/AppSettings.d.ts +25 -16
  314. package/dist/types/lib/AppSettings.d.ts.map +1 -1
  315. package/dist/types/lib/ErrorHandler.d.ts +3 -0
  316. package/dist/types/lib/ErrorHandler.d.ts.map +1 -0
  317. package/dist/types/lib/NetworkSettings.d.ts +0 -1
  318. package/dist/types/lib/NetworkSettings.d.ts.map +1 -1
  319. package/dist/types/lib/apiClients/layerSwapApiClient.d.ts +2 -10
  320. package/dist/types/lib/apiClients/layerSwapApiClient.d.ts.map +1 -1
  321. package/dist/types/lib/balances/balanceResolver.d.ts +3 -3
  322. package/dist/types/lib/balances/balanceResolver.d.ts.map +1 -1
  323. package/dist/types/lib/balances/helpers.d.ts +1 -1
  324. package/dist/types/lib/balances/useBalance.d.ts +1 -1
  325. package/dist/types/lib/fees.d.ts +16 -0
  326. package/dist/types/lib/fees.d.ts.map +1 -1
  327. package/dist/types/lib/gases/gasResolver.d.ts +2 -2
  328. package/dist/types/lib/gases/useSWRGas.d.ts +3 -3
  329. package/dist/types/lib/generateSwapInitialValues.d.ts +1 -1
  330. package/dist/types/lib/nft/nftBalanceResolver.d.ts +1 -1
  331. package/dist/types/lib/resolvers/resolverService.d.ts +8 -5
  332. package/dist/types/lib/resolvers/resolverService.d.ts.map +1 -1
  333. package/dist/types/lib/sorting.d.ts +1 -1
  334. package/dist/types/lib/transfers/index.d.ts +2 -0
  335. package/dist/types/lib/transfers/index.d.ts.map +1 -0
  336. package/dist/types/lib/transfers/transferResolver.d.ts +7 -0
  337. package/dist/types/lib/transfers/transferResolver.d.ts.map +1 -0
  338. package/dist/types/stores/balanceStore.d.ts.map +1 -1
  339. package/dist/types/stores/logStore.d.ts +8 -0
  340. package/dist/types/stores/logStore.d.ts.map +1 -0
  341. package/dist/types/stores/walletStore.d.ts +1 -1
  342. package/dist/types/types/balance.d.ts +2 -2
  343. package/dist/types/types/balance.d.ts.map +1 -1
  344. package/dist/types/types/gas.d.ts +2 -2
  345. package/dist/types/types/index.d.ts +1 -0
  346. package/dist/types/types/index.d.ts.map +1 -1
  347. package/dist/types/types/logEvents.d.ts +41 -0
  348. package/dist/types/types/logEvents.d.ts.map +1 -0
  349. package/dist/types/types/nft.d.ts +1 -1
  350. package/dist/types/types/transfer.d.ts +7 -2
  351. package/dist/types/types/transfer.d.ts.map +1 -1
  352. package/dist/types/types/wallet.d.ts +25 -6
  353. package/dist/types/types/wallet.d.ts.map +1 -1
  354. package/package.json +3 -3
  355. package/dist/esm/helpers/querryHelper.js +0 -13
  356. package/dist/esm/lib/logError.js +0 -17
  357. package/dist/types/context/balanceAccounts.d.ts.map +0 -1
  358. package/dist/types/helpers/querryHelper.d.ts +0 -3
  359. package/dist/types/helpers/querryHelper.d.ts.map +0 -1
  360. package/dist/types/lib/logError.d.ts +0 -3
  361. package/dist/types/lib/logError.d.ts.map +0 -1
@@ -4,7 +4,7 @@ import { useFormikContext } from "formik";
4
4
  import { truncateDecimals } from "../../../../../components/utils/RoundDecimals";
5
5
  import { useBalance } from "../../../../../lib/balances/useBalance";
6
6
  import useSWRGas from "../../../../../lib/gases/useSWRGas";
7
- import { useSelectedAccount } from "../../../../../context/balanceAccounts";
7
+ import { useSelectedAccount } from "../../../../../context/swapAccounts";
8
8
  const ReserveGasNote = ({ onSubmit, minAllowedAmount, maxAllowedAmount }) => {
9
9
  const { values, } = useFormikContext();
10
10
  const selectedSourceAccount = useSelectedAccount("from", values.from?.name);
@@ -13,14 +13,16 @@ const ReserveGasNote = ({ onSubmit, minAllowedAmount, maxAllowedAmount }) => {
13
13
  const nativeTokenBalance = balances?.find(b => b.token == values?.from?.token?.symbol);
14
14
  const mightBeOutOfGas = !!(nativeTokenBalance?.amount && !!(gasData && nativeTokenBalance?.isNativeCurrency && (Number(values.amount)
15
15
  + gasData.gas) > nativeTokenBalance.amount
16
- && minAllowedAmount
16
+ && minAllowedAmount && maxAllowedAmount && values.amount
17
+ && values.fromAsset?.symbol === values.from?.token?.symbol
17
18
  && nativeTokenBalance.amount > minAllowedAmount
19
+ && !(Number(values.amount) > nativeTokenBalance.amount)
18
20
  && !(maxAllowedAmount && (nativeTokenBalance.amount > (maxAllowedAmount + gasData.gas)))));
19
21
  const gasToReserveFormatted = mightBeOutOfGas ? truncateDecimals(gasData.gas, values?.fromAsset?.precision) : '';
20
22
  return (_jsx(_Fragment, { children: mightBeOutOfGas && gasToReserveFormatted ?
21
- ((Number(nativeTokenBalance.amount) < Number(gasData)) ?
22
- _jsx(WarningMessage, { messageType: "warning", children: _jsx("div", { className: "font-normal text-primary-text", children: "You don't have enough funds to cover gas fees." }) })
23
- :
24
- _jsx(WarningMessage, { messageType: "warning", children: _jsxs("div", { className: "font-normal text-primary-text", children: [_jsx("div", { children: "You might not be able to complete the transaction." }), _jsxs("div", { onClick: () => onSubmit(nativeTokenBalance, gasData.gas), className: "cursor-pointer border-b border-dotted border-primary-text w-fit hover:text-primary hover:border-primary text-primary-text", children: [_jsx("span", { children: "Reserve" }), " ", _jsx("span", { children: gasToReserveFormatted }), " ", _jsx("span", { children: values?.fromAsset?.symbol }), " ", _jsx("span", { children: "for gas." })] })] }) })) : null }));
23
+ (_jsx("div", { className: "mt-3", children: (Number(nativeTokenBalance.amount) < Number(gasData.gas)) ?
24
+ _jsx(WarningMessage, { messageType: "warning", children: _jsx("div", { className: "font-normal text-primary-text", children: "You don't have enough funds to cover gas fees." }) })
25
+ :
26
+ _jsx(WarningMessage, { messageType: "warning", children: _jsxs("div", { className: "font-normal text-primary-text", children: [_jsx("div", { children: "You might not be able to complete the transaction." }), _jsxs("div", { onClick: () => onSubmit(nativeTokenBalance, gasData.gas), className: "cursor-pointer border-b border-dotted border-primary-text w-fit hover:text-primary hover:border-primary text-primary-text", children: [_jsx("span", { children: "Reserve" }), " ", _jsx("span", { children: gasToReserveFormatted }), " ", _jsx("span", { children: nativeTokenBalance?.token }), " ", _jsx("span", { children: "for gas." })] })] }) }) })) : null }));
25
27
  };
26
28
  export default ReserveGasNote;
@@ -13,5 +13,5 @@ export const defaultErrors = {
13
13
  };
14
14
  export const ErrorDisplay = (props) => {
15
15
  const { message, details } = { ...defaultErrors[props?.errorName || ''], ...props };
16
- return (_jsx("div", { className: "px-2 py-3 rounded-2xl bg-secondary-400", children: _jsxs("div", { className: "flex items-start gap-2", children: [_jsx("span", { className: "shrink-0", children: details?.icon }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("p", { className: "text-primary-text font-medium leading-4 text-base mt-0.5", children: details?.title }), message ? _jsx("p", { className: "text-secondary-text text-sm leading-[18px]", children: message }) : null] })] }) }));
16
+ return (_jsx("div", { className: "px-2 py-3 rounded-2xl bg-secondary-400", children: _jsxs("div", { className: "flex items-start gap-2", children: [_jsx("span", { className: "shrink-0 p-0.5", children: details?.icon }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx("p", { className: "text-primary-text font-medium leading-4 text-base mt-0.5", children: details?.title }), message ? _jsx("p", { className: "text-secondary-text text-sm leading-[18px]", children: message }) : null] })] }) }));
17
17
  };
@@ -1,20 +1,24 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useCallback } from 'react';
2
+ import { useCallback, useEffect } from 'react';
3
3
  import { useSwapDataState } from '../../../../context/swap';
4
4
  import { useIntercom } from 'react-use-intercom';
5
5
  import { SwapStatus } from '../../../../Models/SwapStatus';
6
6
  import QuestionIcon from '../../../../components/Icons/Question';
7
- // import { posthog } from 'posthog-js';
7
+ import { ErrorHandler } from '../../../../lib/ErrorHandler';
8
8
  const Failed = () => {
9
9
  const { swapDetails } = useSwapDataState();
10
10
  const { boot, show, update } = useIntercom();
11
11
  const updateWithProps = () => update({ customAttributes: { swapId: swapDetails?.id } });
12
- // useEffect(() => {
13
- // posthog.capture('Swap failed', {
14
- // swapId: swapDetails?.id ?? null,
15
- // path: typeof window !== 'undefined' ? window.location.pathname : undefined,
16
- // });
17
- // }, []);
12
+ useEffect(() => {
13
+ const error = new Error(`Swap failed: ${swapDetails?.id}`);
14
+ ErrorHandler({
15
+ type: "SwapFailed",
16
+ message: error.message,
17
+ name: error.name,
18
+ stack: error.stack,
19
+ cause: error.cause
20
+ });
21
+ }, [swapDetails?.id]);
18
22
  const startIntercom = useCallback(() => {
19
23
  boot();
20
24
  show();
@@ -23,11 +23,15 @@ import { truncateDecimals } from '../../../../components/utils/RoundDecimals';
23
23
  import { addressFormat } from '../../../../lib/address/formatter';
24
24
  import { isValidAddress } from '../../../../lib/address/validator';
25
25
  import { ExtendedAddress } from '../../../../components/Input/Address/AddressPicker/AddressWithIcon';
26
- const ManualWithdraw = ({ swapBasicData, quote, depositActions, refuel, partner, type }) => {
26
+ import QuoteDetails from '../Form/FeeDetails';
27
+ const ManualWithdraw = ({ swapBasicData, depositActions, refuel, partner, type, quote, isQuoteLoading }) => {
27
28
  const { wallets } = useWallet();
28
29
  const { createSwap, setSwapId } = useSwapDataUpdate();
29
30
  const [isPopoverOpen, setIsPopoverOpen] = useState(false);
30
- const [newNetwork, setNewNetwork] = useState(null);
31
+ const [selectedFrom, setSelectedFrom] = useState({
32
+ network: swapBasicData?.source_network ?? null,
33
+ token: swapBasicData?.source_token ?? null,
34
+ });
31
35
  const [loading, setLoading] = useState(false);
32
36
  const { getConfirmation } = useAsyncModal();
33
37
  const [showQR, setShowQR] = useState(false);
@@ -43,8 +47,23 @@ const ManualWithdraw = ({ swapBasicData, quote, depositActions, refuel, partner,
43
47
  copy(depositAddress);
44
48
  }
45
49
  };
50
+ const swapValues = useMemo(() => {
51
+ const fromNetwork = (selectedFrom.network ?? swapBasicData?.source_network);
52
+ const fromToken = selectedFrom.token ?? swapBasicData?.source_token;
53
+ return {
54
+ amount: swapBasicData?.requested_amount?.toString(),
55
+ from: fromNetwork,
56
+ to: swapBasicData?.destination_network,
57
+ fromAsset: fromToken,
58
+ toAsset: swapBasicData?.destination_token,
59
+ refuel: !!refuel,
60
+ destination_address: swapBasicData?.destination_address,
61
+ fromExchange: swapBasicData?.source_exchange,
62
+ depositMethod: 'deposit_address',
63
+ };
64
+ }, [selectedFrom.network, selectedFrom.token, swapBasicData, refuel]);
46
65
  const handleClick = async (network, token) => {
47
- const swapValues = {
66
+ const nextSwapValues = {
48
67
  amount: swapBasicData?.requested_amount?.toString(),
49
68
  from: network,
50
69
  to: swapBasicData?.destination_network,
@@ -58,17 +77,17 @@ const ManualWithdraw = ({ swapBasicData, quote, depositActions, refuel, partner,
58
77
  try {
59
78
  setLoading(true);
60
79
  await handleLimitsUpdate({
61
- swapValues,
80
+ swapValues: nextSwapValues,
62
81
  network,
63
82
  token,
64
83
  getConfirmation
65
84
  });
66
- const swapData = await createSwap(swapValues, initialSettings);
67
- setNewNetwork(network);
85
+ const swapData = await createSwap(nextSwapValues, initialSettings);
68
86
  const swapId = swapData?.swap?.id;
69
87
  if (!swapId)
70
88
  throw new Error('Swap ID is undefined');
71
89
  setSwapId(swapId);
90
+ setSelectedFrom({ network, token });
72
91
  setIsPopoverOpen(false);
73
92
  }
74
93
  catch (e) {
@@ -84,15 +103,15 @@ const ManualWithdraw = ({ swapBasicData, quote, depositActions, refuel, partner,
84
103
  toAsset: swapBasicData?.destination_token?.symbol
85
104
  }), [swapBasicData]);
86
105
  const { networks: withdrawalNetworks, isLoading: exchangeSourceNetworksLoading } = useExchangeNetworks(exchangeNetworkParams);
87
- const requestAmount = (_jsxs("span", { className: 'inline-flex items-center gap-1 px-1.5 mx-1 bg-secondary-300 rounded-lg', children: [_jsx("span", { children: truncateDecimals(swapBasicData?.requested_amount, swapBasicData?.source_token?.precision) }), " ", _jsx("span", { children: swapBasicData?.source_token?.symbol }), _jsx(CopyButton, { toCopy: swapBasicData?.requested_amount, iconClassName: 'text-secondary-text' })] }));
106
+ const requestAmount = (_jsxs("span", { className: 'inline-flex items-center gap-1 px-1.5 mx-1 bg-secondary-300 rounded-lg', children: [_jsx("span", { children: truncateDecimals(Number(swapBasicData?.requested_amount), swapBasicData?.source_token?.precision) }), " ", _jsx("span", { children: swapBasicData?.source_token?.symbol }), _jsx(CopyButton, { toCopy: swapBasicData?.requested_amount, iconClassName: 'text-secondary-text' })] }));
88
107
  const destinationNetwork = (_jsxs("span", { className: 'flex items-center gap-1', children: [destinationLogo && _jsx(ImageWithFallback, { src: destinationLogo, alt: "Project Logo", height: "16", width: "16", loading: "eager", className: "rounded-md object-contain" }), swapBasicData?.destination_network?.display_name] }));
89
- const sourceNetworkPopover = (_jsxs(Popover, { open: isPopoverOpen, onOpenChange: setIsPopoverOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { className: "inline-flex items-center gap-1 px-1.5 mx-1 bg-secondary-300 rounded-lg", children: [_jsx(ImageWithFallback, { src: newNetwork?.logo || swapBasicData?.source_network?.logo, alt: "Project Logo", height: "16", width: "16", loading: "eager", className: "rounded-sm object-contain" }), _jsx("span", { children: newNetwork?.display_name || swapBasicData?.source_network?.display_name }), _jsx("span", { className: "pointer-events-none text-shadow-primary-text-tertiary", children: _jsx(ChevronDown, { className: "h-3.5 w-3.5 text-secondary-text", "aria-hidden": "true" }) })] }) }), _jsx(PopoverContent, { side: 'top', className: "bg-secondary-300! space-y-1 p-1! rounded-lg!", children: _jsx(CommandWrapper, { children: _jsx(CommandList, { children: withdrawalNetworks?.map((item) => {
108
+ const sourceNetworkPopover = (_jsxs(Popover, { open: isPopoverOpen, onOpenChange: setIsPopoverOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs("button", { className: "inline-flex items-center gap-1 px-1.5 mx-1 bg-secondary-300 rounded-lg", children: [_jsx(ImageWithFallback, { src: selectedFrom.network?.logo ?? swapBasicData?.source_network?.logo, alt: "Project Logo", height: "16", width: "16", loading: "eager", className: "rounded-sm object-contain" }), _jsx("span", { children: selectedFrom.network?.display_name ?? swapBasicData?.source_network?.display_name }), _jsx("span", { className: "pointer-events-none text-shadow-primary-text-tertiary", children: _jsx(ChevronDown, { className: "h-3.5 w-3.5 text-secondary-text", "aria-hidden": "true" }) })] }) }), _jsx(PopoverContent, { side: 'top', className: "bg-secondary-300! space-y-1 p-1! rounded-lg!", children: _jsx(CommandWrapper, { children: _jsx(CommandList, { children: withdrawalNetworks?.map((item) => {
90
109
  return (_jsx(CommandItem, { className: 'hover:bg-secondary-100 rounded-md p-1! cursor-pointer', value: item.network.name, onSelect: () => handleClick(item.network, item.token), children: _jsx("div", { className: `flex items-center justify-between w-full overflow-hidden`, children: _jsxs("div", { className: `gap-2 relative flex items-center w-full space-y-1`, children: [_jsx("div", { className: `h-6 w-6 shrink-0 mb-0!`, children: item.network.logo && (_jsx(ImageWithFallback, { src: item.network.logo, alt: "Project Logo", height: "24", width: "24", loading: "eager", className: "rounded-md object-contain" })) }), _jsx("div", { className: "flex justify-between w-full items-center", children: _jsx("span", { className: "flex items-center pb-0.5 text-sm font-medium text-primary-text pr-20", children: item.network.display_name }) })] }) }) }, item.network.name));
91
110
  }) }) }) })] }));
92
- return (_jsxs(_Fragment, { children: [_jsx(Widget.Content, { children: _jsx("div", { className: 'flex flex-col flex-1 h-full min-h-0 w-full space-y-3', children: (loading || exchangeSourceNetworksLoading) ? (_jsxs(_Fragment, { children: [_jsx(SkeletonStep, { number: 1 }), _jsx(SkeletonStep, { number: 2 }), _jsx(SkeletonStep, { number: 3 })] })) : (_jsxs(_Fragment, { children: [_jsx(Step, { number: 1, label: _jsxs("div", { className: "flex items-center justify-between gap-2 relative", children: [_jsx("span", { children: "Copy the deposit address" }), _jsx("div", { className: "relative", children: _jsxs(Popover, { open: showQR, onOpenChange: setShowQR, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("div", { className: "relative", children: _jsx(QRIcon, { className: "bg-secondary-300 p-1 rounded-lg cursor-pointer hover:opacity-80 fill-primary-text text-primary-text" }) }) }), _jsx(PopoverContent, { side: "left", align: "start", className: "bg-secondary-300 p-2 rounded-xl z-50", children: _jsx("div", { className: "bg-white p-2 rounded-xl shadow-lg", children: _jsx(QRCodeSVG, { className: "rounded-lg", value: depositAddress || '', includeMargin: true, size: 160, level: "H" }) }) })] }) })] }), value: _jsx("span", { className: "cursor-pointer hover:underline min-h-[20px] block", children: depositAddress ? (_jsxs("span", { className: 'flex items-center gap-1', children: [shortenAddress(depositAddress), _jsx(CopyButton, { toCopy: depositAddress || '', className: 'flex' })] })) : (_jsx("span", { className: "inline-block w-28 bg-secondary-400 h-[20px] rounded animate-pulse" })) }) }), _jsx(Step, { number: 2, label: _jsxs("span", { children: [_jsxs("span", { className: 'inline-flex items-center', children: [_jsx("span", { children: "Send" }), requestAmount] }), _jsx("span", { children: "via" }), swapBasicData?.source_exchange ? (_jsx("span", { className: "inline-flex items-center align-bottom", children: sourceNetworkPopover })) : (_jsxs("span", { className: "inline-flex items-center gap-1 mx-1 h-6 align-bottom", children: [_jsx(ImageWithFallback, { src: swapBasicData?.source_network?.logo, alt: "Project Logo", height: "16", width: "16", loading: "eager", className: "rounded-sm object-contain" }), _jsx("span", { children: swapBasicData?.source_network?.display_name })] })), _jsx("span", { children: "to the deposit address" })] }) }), _jsx(Step, { number: 3, label: _jsxs("span", { className: 'flex items-center gap-1', children: [_jsx("span", { children: "Receive" }), " ", _jsx("span", { children: truncateDecimals(quote?.receive_amount ?? 0, swapBasicData?.destination_token?.precision) }), " ", _jsx("span", { children: swapBasicData?.destination_token?.symbol }), " ", _jsx("span", { children: "at" }), " ", _jsx("span", { children: destinationNetwork })] }), value: _jsxs("span", { className: "cursor-pointer hover:underline flex items-center gap-1", children: [WalletIcon ? (_jsx(WalletIcon, { className: "w-4 h-4 p-0.5 bg-white rounded-sm" })) : addressProviderIcon ? (_jsx(ImageWithFallback, { alt: "Partner logo", className: "h-4 w-4 rounded-md object-contain", src: partner.logo, width: "36", height: "36" })) : (_jsx(AddressIcon, { className: "h-4 w-4", address: swapBasicData.destination_address, size: 36, rounded: "4px" })), ((swapBasicData?.destination_network && isValidAddress(swapBasicData?.destination_address, swapBasicData?.destination_network)) ?
111
+ return (_jsxs(_Fragment, { children: [_jsx(Widget.Content, { children: _jsx("div", { className: 'flex flex-col flex-1 h-full min-h-0 w-full space-y-3', children: (loading || exchangeSourceNetworksLoading) ? (_jsxs(_Fragment, { children: [_jsx(SkeletonStep, { number: 1 }), _jsx(SkeletonStep, { number: 2 }), _jsx(SkeletonStep, { number: 3 })] })) : (_jsxs(_Fragment, { children: [_jsx(Step, { number: 1, label: _jsxs("div", { className: "flex items-center justify-between gap-2 relative", children: [_jsx("span", { children: "Copy the deposit address" }), _jsx("div", { className: "relative", children: _jsxs(Popover, { open: showQR, onOpenChange: setShowQR, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("div", { className: "relative", children: _jsx(QRIcon, { className: "bg-secondary-300 p-1 rounded-lg cursor-pointer hover:opacity-80 fill-primary-text text-primary-text" }) }) }), _jsx(PopoverContent, { side: "left", align: "start", className: "bg-secondary-300 p-2 rounded-xl z-50", children: _jsx("div", { className: "bg-white p-2 rounded-xl shadow-lg", children: _jsx(QRCodeSVG, { className: "rounded-lg", value: depositAddress || '', includeMargin: true, size: 160, level: "H" }) }) })] }) })] }), value: _jsx("span", { className: "cursor-pointer hover:underline min-h-5 block", children: depositAddress ? (_jsxs("span", { className: 'flex items-center gap-1', children: [shortenAddress(depositAddress), _jsx(CopyButton, { toCopy: depositAddress || '', className: 'flex' })] })) : (_jsx("span", { className: "inline-block w-28 bg-secondary-400 h-5 rounded animate-pulse" })) }) }), _jsx(Step, { number: 2, label: _jsxs("span", { children: [_jsxs("span", { className: 'inline-flex items-center', children: [_jsx("span", { children: "Send" }), requestAmount] }), _jsx("span", { children: "via" }), swapBasicData?.source_exchange ? (_jsx("span", { className: "inline-flex items-center align-bottom max-sm:mt-1", children: sourceNetworkPopover })) : (_jsxs("span", { className: "inline-flex items-center gap-1 mx-1 h-6 align-bottom", children: [_jsx(ImageWithFallback, { src: swapBasicData?.source_network?.logo, alt: "Project Logo", height: "16", width: "16", loading: "eager", className: "rounded-sm object-contain" }), _jsx("span", { children: swapBasicData?.source_network?.display_name })] })), _jsx("span", { children: "to the deposit address" })] }) }), _jsx(Step, { number: 3, label: _jsxs("span", { className: 'flex items-center gap-1', children: [_jsx("span", { children: "Receive" }), " ", _jsx("span", { children: truncateDecimals(quote?.receive_amount ?? 0, swapBasicData?.destination_token?.precision) }), " ", _jsx("span", { children: swapBasicData?.destination_token?.symbol }), " ", _jsx("span", { children: "at" }), " ", _jsx("span", { children: destinationNetwork })] }), value: _jsxs("span", { className: "cursor-pointer hover:underline flex items-center gap-1", children: [WalletIcon ? (_jsx(WalletIcon, { className: "w-4 h-4 bg-secondary-700 rounded-sm" })) : addressProviderIcon ? (_jsx(ImageWithFallback, { alt: "Partner logo", className: "h-4 w-4 rounded-md object-contain", src: partner.logo, width: "36", height: "36" })) : (_jsx(AddressIcon, { className: "h-4 w-4", address: swapBasicData.destination_address, size: 36, rounded: "4px" })), ((swapBasicData?.destination_network && isValidAddress(swapBasicData?.destination_address, swapBasicData?.destination_network)) ?
93
112
  _jsx("div", { className: "text-sm group/addressItem text-secondary-text", children: _jsx(ExtendedAddress, { address: addressFormat(swapBasicData?.destination_address, swapBasicData?.destination_network), network: swapBasicData?.destination_network, shouldShowChevron: false }) })
94
113
  :
95
- _jsx("p", { className: "text-sm text-secondary-text", children: shortenAddress(swapBasicData?.destination_address) }))] }) })] })) }) }), _jsx(Widget.Footer, { sticky: type == 'widget', children: _jsx(SubmitButton, { onClick: handleCopy, children: copied ? 'Copied!' : 'Copy deposit address' }) })] }));
114
+ _jsx("p", { className: "text-sm text-secondary-text", children: shortenAddress(swapBasicData?.destination_address) }))] }) }), _jsx(QuoteDetails, { swapValues: swapValues, quote: quote, isQuoteLoading: isQuoteLoading, triggerClassnames: 'mt-0!' })] })) }) }), _jsx(Widget.Footer, { sticky: type == 'widget', children: _jsx(SubmitButton, { onClick: handleCopy, children: copied ? 'Copied!' : 'Copy deposit address' }) })] }));
96
115
  };
97
116
  const Step = ({ number, label, value }) => (_jsxs("div", { className: "flex items-start space-x-3 bg-secondary-500 p-3 rounded-xl", children: [_jsx("div", { className: "w-6 h-6 rounded-md bg-secondary-400 text-primary-text flex items-center justify-center text-base font-normal leading-6", children: number }), _jsxs("div", { className: "flex-1", children: [_jsx("div", { className: "font-normal text-base leading-6", children: label }), _jsx("div", { className: "text-sm text-secondary-text", children: value })] })] }));
98
117
  const SkeletonStep = ({ number }) => (_jsxs("div", { className: "flex items-start space-x-3 bg-secondary-500 p-3 rounded-lg animate-pulse", children: [_jsx("div", { className: "w-6 h-6 rounded-md bg-secondary-400 text-primary-text flex items-center justify-center text-base font-normal leading-6", children: number }), _jsxs("div", { className: "flex-1 space-y-3", children: [_jsx("div", { className: "h-5 bg-secondary-300 rounded w-3/4" }), _jsx("div", { className: "h-4 bg-secondary-300 rounded w-1/2" })] })] }));
@@ -1,19 +1,30 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback } from "react";
2
+ import { useCallback, useEffect } from "react";
3
3
  import { useIntercom } from "react-use-intercom";
4
4
  import { Home } from "lucide-react";
5
- import { useBackClickCallback } from "../../../../context/callbackProvider";
5
+ import { useCallbacks } from "../../../../context/callbackProvider";
6
6
  import MessageComponent from "../../../../components/Common/MessageComponent";
7
7
  import NotFoundIcon from "../../../../components/Icons/NotFoundIcon";
8
+ import { ErrorHandler } from "../../../../lib/ErrorHandler";
8
9
  const NotFound = ({ swapId }) => {
9
10
  const { boot, show, update } = useIntercom();
10
11
  const updateWithProps = () => update({ customAttributes: { swapId: swapId } });
11
- const triggerBackClickCallback = useBackClickCallback();
12
+ const { onBackClick } = useCallbacks();
13
+ useEffect(() => {
14
+ const error = new Error(`Swap not found: ${swapId}`);
15
+ ErrorHandler({
16
+ type: "NotFound",
17
+ message: error.message,
18
+ name: error.name,
19
+ stack: error.stack,
20
+ cause: error.cause
21
+ });
22
+ }, [swapId]);
12
23
  const startIntercom = useCallback(() => {
13
24
  boot();
14
25
  show();
15
26
  updateWithProps();
16
27
  }, [boot, show, updateWithProps]);
17
- return _jsxs(MessageComponent, { children: [_jsxs(MessageComponent.Content, { center: true, children: [_jsxs(MessageComponent.Header, { className: "mb-3", children: [_jsx("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-red-600/20", children: _jsx(NotFoundIcon, {}) }), _jsx("h1", { className: "text-center text-2xl font-semibold text-primary-text", children: "Swap not found" })] }), _jsx(MessageComponent.Description, { children: _jsxs("p", { className: "mx-auto text-center text-base font-normal leading-5 text-secondary-text px-9", children: [_jsx("span", { children: "We couldn't find a swap with this link. If you believe there's an issue, please" }), _jsx("button", { type: "button", onClick: startIntercom, className: "mx-1 underline decoration-gray-400 underline-offset-2 hover:decoration-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-[#0f1420] focus:ring-gray-400 rounded", children: _jsx("span", { children: "contact our support" }) }), _jsx("span", { children: "and we'll help you fix it." })] }) })] }), _jsx(MessageComponent.Buttons, { children: _jsx("div", { className: "flex w-full text-primary-text text-base space-x-2", children: _jsxs("button", { onClick: triggerBackClickCallback, type: "button", className: "w-full inline-flex items-center justify-center gap-2 rounded-xl bg-secondary-300 px-5 py-4 text-base font-semibold leading-6 hover:bg-secondary-400 focus:outline-none transition", children: [_jsx(Home, { className: "h-5 w-5", "aria-hidden": "true" }), _jsx("span", { children: "Back to app" })] }) }) })] });
28
+ return _jsxs(MessageComponent, { children: [_jsxs(MessageComponent.Content, { center: true, children: [_jsxs(MessageComponent.Header, { className: "mb-3", children: [_jsx("div", { className: "mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-full bg-red-600/20", children: _jsx(NotFoundIcon, {}) }), _jsx("h1", { className: "text-center text-2xl font-semibold text-primary-text", children: "Swap not found" })] }), _jsx(MessageComponent.Description, { children: _jsxs("p", { className: "mx-auto text-center text-base font-normal leading-5 text-secondary-text px-9", children: [_jsx("span", { children: "We couldn't find a swap with this link. If you believe there's an issue, please" }), _jsx("button", { type: "button", onClick: startIntercom, className: "mx-1 underline decoration-gray-400 underline-offset-2 hover:decoration-gray-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-[#0f1420] focus:ring-gray-400 rounded", children: _jsx("span", { children: "contact our support" }) }), _jsx("span", { children: "and we'll help you fix it." })] }) })] }), _jsx(MessageComponent.Buttons, { children: _jsx("div", { className: "flex w-full text-primary-text text-base space-x-2", children: _jsxs("button", { onClick: onBackClick, type: "button", className: "w-full inline-flex items-center justify-center gap-2 rounded-xl bg-secondary-300 px-5 py-4 text-base font-semibold leading-6 hover:bg-secondary-400 focus:outline-none transition", children: [_jsx(Home, { className: "h-5 w-5", "aria-hidden": "true" }), _jsx("span", { children: "Back to app" })] }) }) })] });
18
29
  };
19
30
  export default NotFound;
@@ -16,12 +16,13 @@ import { useSwapTransactionStore } from '../../../../../stores/swapTransactionSt
16
16
  import CountdownTimer from '../../../../../components/Common/CountDownTimer';
17
17
  import useSWR from 'swr';
18
18
  import { useIntercom } from 'react-use-intercom';
19
- import logError from '../../../../../lib/logError';
20
- // import { posthog } from 'posthog-js';
21
19
  import Steps from './StepsComponent';
20
+ import { useCallbacks } from '../../../../../context/callbackProvider';
21
+ import { ErrorHandler } from '../../../../../lib/ErrorHandler';
22
22
  const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
23
- const { boot, show, update, showNewMessages } = useIntercom();
23
+ const { boot, show, update } = useIntercom();
24
24
  const { setSwapTransaction, swapTransactions } = useSwapTransactionStore();
25
+ const { onSwapStatusChange } = useCallbacks();
25
26
  const { source_network, destination_network, destination_token, } = swapBasicData;
26
27
  const { fail_reason } = swapDetails;
27
28
  const updateWithProps = () => update({ customAttributes: { swapId: swapDetails.id } });
@@ -42,17 +43,6 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
42
43
  const { data: inputTxStatusData } = useSWR((transactionHash && swapInputTransaction?.status !== BackendTransactionStatus.Completed) ? [source_network?.name, transactionHash] : null, ([network, tx_id]) => apiClient.GetTransactionStatus(network, tx_id), { dedupingInterval: 6000 });
43
44
  const inputTxStatus = swapInputTransaction ? swapInputTransaction.status : inputTxStatusData?.data?.status.toLowerCase();
44
45
  const loggedNotDetectedTxAt = useRef(null);
45
- const handleSupportClick = useCallback(() => {
46
- const transactionHash = swapInputTransaction?.transaction_hash || storedWalletTransaction?.hash;
47
- const message = `Hi! My transaction (Swap ID: ${swapDetails.id}) has been processing for longer than expected. ${transactionHash ? `Transaction hash: ${transactionHash}` : ''} Could you please help me check the status?`;
48
- boot();
49
- update({
50
- customAttributes: {
51
- swapId: swapDetails.id,
52
- }
53
- });
54
- showNewMessages(message);
55
- }, [boot, show, update, swapDetails.id, swapInputTransaction, storedWalletTransaction]);
56
46
  useEffect(() => {
57
47
  if (inputTxStatus === TransactionStatus.Completed || inputTxStatus === TransactionStatus.Pending) {
58
48
  if (swapDetails?.transactions?.find(t => t.type === TransactionType.Input) || !swapDetails) {
@@ -60,7 +50,14 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
60
50
  }
61
51
  if (Date.now() - (loggedNotDetectedTxAt.current || storedWalletTransaction.timestamp) > 60000) {
62
52
  loggedNotDetectedTxAt.current = Date.now();
63
- logError(`Transaction not detected in ${source_network.name}. Tx hash: \`${transactionHash}\`. Tx status: ${inputTxStatus}. Swap id: \`${swapDetails.id}\`. ${source_network.display_name} explorer: ${source_network?.transaction_explorer_template?.replace("{0}", transactionHash)} . LS explorer: https://layerswap.io/explorer/${storedWalletTransaction?.hash} `);
53
+ const error = new Error(`Transaction not detected in ${source_network.name}. Tx hash: \`${transactionHash}\`. Tx status: ${inputTxStatus}. Swap id: \`${swapDetails.id}\`. ${source_network.display_name} explorer: ${source_network?.transaction_explorer_template?.replace("{0}", transactionHash)} . LS explorer: https://layerswap.io/explorer/${storedWalletTransaction?.hash} `);
54
+ ErrorHandler({
55
+ type: "TransactionNotDetected",
56
+ message: error.message,
57
+ name: error.name,
58
+ stack: error.stack,
59
+ cause: error.cause
60
+ });
64
61
  }
65
62
  }
66
63
  }, [swapDetails, storedWalletTransaction, source_network]);
@@ -71,33 +68,31 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
71
68
  useEffect(() => {
72
69
  if (inputTxStatus === TransactionStatus.Failed) {
73
70
  const err = new Error("Transaction failed");
74
- const renderingError = new Error(`Swap:${swapDetails?.id} transaction:${transactionHash} failed`);
75
- renderingError.name = `TransactionFailed`;
76
- renderingError.cause = err;
77
- // posthog.capture('$exception', {
78
- // name: renderingError.name,
79
- // message: renderingError.message,
80
- // $layerswap_exception_type: "Transaction Error",
81
- // stack: renderingError.stack,
82
- // cause: renderingError.cause,
83
- // where: 'TransactionError',
84
- // severity: 'error',
85
- // });
71
+ const error = new Error(`Swap:${swapDetails?.id} transaction:${transactionHash} failed`);
72
+ error.name = `TransactionFailed`;
73
+ error.cause = err;
74
+ ErrorHandler({
75
+ type: "TransactionFailed",
76
+ message: error.message,
77
+ name: error.name,
78
+ stack: error.stack,
79
+ cause: error.cause
80
+ });
86
81
  }
87
82
  }, [inputTxStatus, transactionHash, swapDetails?.id]);
88
- // useEffect(() => {
89
- // if (
90
- // swapDetails?.status === SwapStatus.Completed ||
91
- // swapDetails?.status === SwapStatus.Failed ||
92
- // swapDetails?.status === SwapStatus.Expired ||
93
- // swapDetails?.status === SwapStatus.LsTransferPending
94
- // ) {
95
- // posthog?.capture(`${swapDetails?.status}`, {
96
- // swap_id: swapDetails?.id,
97
- // status: swapDetails?.status,
98
- // })
99
- // }
100
- // }, [swapDetails?.status, swapDetails?.id])
83
+ useEffect(() => {
84
+ const status = swapDetails?.status;
85
+ if (status === SwapStatus.Completed ||
86
+ status === SwapStatus.Failed ||
87
+ status === SwapStatus.Expired ||
88
+ status === SwapStatus.LsTransferPending) {
89
+ onSwapStatusChange({
90
+ type: status,
91
+ swapId: swapDetails?.id,
92
+ path: 'Processing',
93
+ });
94
+ }
95
+ }, [swapDetails?.status, swapDetails?.id]);
101
96
  const truncatedRefuelAmount = refuel && truncateDecimals(refuel.amount, refuel.token?.precision);
102
97
  const progressStatuses = getProgressStatuses(swapDetails, refuel, inputTxStatusData?.data?.status.toLowerCase());
103
98
  const stepStatuses = progressStatuses.stepStatuses;
@@ -237,7 +232,7 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
237
232
  let currentSteps = allSteps.filter((s) => s.status && s.status != ProgressStatus.Removed);
238
233
  let stepsProgressPercentage = currentSteps.filter(x => x.status == ProgressStatus.Complete).length / currentSteps.length * 100;
239
234
  const swapStatus = swapDetails.status;
240
- return (_jsx(Widget.Content, { children: _jsxs("div", { className: `w-full min-h-[410px] h-full space-y-3 flex flex-col justify-between text-primary-text`, children: [_jsx(SwapSummary, {}), _jsxs("div", { className: "bg-secondary-500 font-normal px-3 pt-6 pb-3 rounded-2xl space-y-4 flex flex-col w-full relative z-10 divide-y-2 divide-secondary-300 divide-dashed", children: [_jsx("div", { className: 'pb-4', children: _jsxs("div", { className: 'flex flex-col gap-2 items-center', children: [_jsxs("div", { className: 'flex items-center', children: [swapStatus === SwapStatus.PendingRefund && (_jsx("span", { className: "relative z-10 flex h-10 w-10 items-center justify-center rounded-full bg-primary/20", children: _jsx(Undo2, { className: "h-7 w-7 text-primary", "aria-hidden": "true" }) })), swapStatus === SwapStatus.Refunded && (_jsx("span", { className: "relative z-10 flex h-10 w-10 items-center justify-center", children: _jsx(CircleCheck, { className: "h-10 w-10 text-primary", strokeWidth: 2, "aria-hidden": "true" }) })), swapStatus !== SwapStatus.PendingRefund && swapStatus !== SwapStatus.Refunded && (_jsx(Gauge, { value: stepsProgressPercentage, size: "small", showCheckmark: swapStatus === SwapStatus.Completed }))] }), _jsxs("div", { className: "flex-col text-center ", children: [_jsx("span", { className: "font-medium text-primary-text", children: progressStatuses.generalStatus.title }), progressStatuses.generalStatus.subTitle &&
235
+ return (_jsx(Widget.Content, { fitContent: true, children: _jsxs("div", { className: `w-full min-h-[410px] h-full space-y-3 flex flex-col justify-between text-primary-text`, children: [_jsx(SwapSummary, {}), _jsxs("div", { className: "bg-secondary-500 font-normal px-3 pt-6 pb-3 rounded-2xl space-y-4 flex flex-col w-full relative z-10 divide-y-2 divide-secondary-300 divide-dashed", children: [_jsx("div", { className: 'pb-4', children: _jsxs("div", { className: 'flex flex-col gap-2 items-center', children: [_jsxs("div", { className: 'flex items-center', children: [swapStatus === SwapStatus.PendingRefund && (_jsx("span", { className: "relative z-10 flex h-10 w-10 items-center justify-center rounded-full bg-primary/20", children: _jsx(Undo2, { className: "h-7 w-7 text-primary", "aria-hidden": "true" }) })), swapStatus === SwapStatus.Refunded && (_jsx("span", { className: "relative z-10 flex h-10 w-10 items-center justify-center", children: _jsx(CircleCheck, { className: "h-10 w-10 text-primary", strokeWidth: 2, "aria-hidden": "true" }) })), swapStatus !== SwapStatus.PendingRefund && swapStatus !== SwapStatus.Refunded && (_jsx(Gauge, { value: stepsProgressPercentage, size: "small", showCheckmark: swapStatus === SwapStatus.Completed }))] }), _jsxs("div", { className: "flex-col text-center ", children: [_jsx("span", { className: "font-medium text-primary-text", children: progressStatuses.generalStatus.title }), progressStatuses.generalStatus.subTitle &&
241
236
  _jsx("span", { className: "text-sm block text-secondary-text", children: progressStatuses.generalStatus.subTitle }), swapOutputTransaction?.status != BackendTransactionStatus.Completed && (swapStatus !== SwapStatus.Cancelled && swapStatus !== SwapStatus.Expired && swapStatus !== SwapStatus.Failed && swapStatus !== SwapStatus.PendingRefund && swapStatus !== SwapStatus.Refunded) &&
242
237
  _jsx("span", { className: 'text-sm block space-x-1 text-secondary-text', children: _jsx("span", { children: countDownTimer }) })] })] }) }), _jsxs("div", { className: 'pt-4', children: [swapStatus != SwapStatus.Cancelled && swapStatus != SwapStatus.Expired && currentSteps.find(x => x.status != null) &&
243
238
  _jsx("div", { className: 'flex flex-col justify-center space-y-4', children: _jsx(Steps, { steps: currentSteps }) }), ([SwapStatus.Expired, SwapStatus.Cancelled, SwapStatus.UserTransferDelayed].includes(swapStatus)) &&
@@ -10,7 +10,7 @@ import NumberFlow from "@number-flow/react";
10
10
  import clsx from "clsx";
11
11
  import { PriceImpact } from "../../../../../components/Input/Amount/PriceImpact";
12
12
  const Summary = (props) => {
13
- const { swap, quote, receiveAmount, quoteIsLoading } = props;
13
+ const { swap, quote, receiveAmount } = props;
14
14
  const { refuel, quote: swapQuote } = quote;
15
15
  const { source_token: sourceCurrency, destination_token: destinationCurrency, source_network: from, destination_network: to, requested_amount: requestedAmount, destination_address: destinationAddress, source_exchange: sourceExchange } = swap;
16
16
  const { hideFrom, hideTo, account, appName, } = useInitialSettings();
@@ -19,14 +19,14 @@ const Summary = (props) => {
19
19
  const partner = partnerData?.data;
20
20
  const source = (hideFrom && partner && account) ? partner : from;
21
21
  const destination = (hideTo && partner && account) ? partner : to;
22
- const requestedAmountInUsd = requestedAmount && (sourceCurrency?.price_in_usd * requestedAmount).toFixed(2);
22
+ const requestedAmountInUsd = requestedAmount && (sourceCurrency?.price_in_usd * Number(requestedAmount)).toFixed(2);
23
23
  const receiveAmountInUsd = receiveAmount ? (destinationCurrency?.price_in_usd * receiveAmount).toFixed(2) : undefined;
24
24
  const nativeCurrency = refuel?.token;
25
25
  const truncatedRefuelAmount = nativeCurrency && !!refuel ?
26
26
  truncateDecimals(refuel.amount, nativeCurrency?.precision) : null;
27
27
  const refuelAmountInUsd = nativeCurrency && ((nativeCurrency?.price_in_usd || 1) * (Number(truncatedRefuelAmount) || 0)).toFixed(2);
28
28
  return (_jsx("div", { className: "bg-secondary-500 rounded-2xl px-3 py-4 w-full relative z-10 space-y-4", children: _jsxs("div", { className: "font-normal flex flex-col w-full relative z-10 space-y-3", children: [_jsxs("div", { className: "w-full grid grid-cols-10", children: [_jsx(RouteTokenPair, { route: sourceExchange || source, token: sourceCurrency }), _jsxs("div", { className: "flex flex-col col-start-7 col-span-4 items-end", children: [requestedAmount &&
29
- _jsxs("p", { className: "text-primary-text text-sm", children: [truncateDecimals(requestedAmount, sourceCurrency.precision), " ", sourceCurrency.symbol] }), _jsx("p", { className: "text-secondary-text text-sm flex justify-end", children: _jsx(NumberFlow, { value: Number(requestedAmountInUsd) || 0, format: { style: 'currency', currency: 'USD' }, trend: 0 }) })] })] }), _jsxs("div", { className: "relative text-secondary-text", children: [_jsx("hr", { className: "border border-secondary-400 w-full rounded-full" }), _jsx(ArrowDown, { className: "absolute left-1/2 -translate-x-1/2 top-[-10px] h-6 w-6 p-1 bg-secondary-400 rounded-md text-secondary-text" })] }), _jsxs("div", { className: "w-full grid grid-cols-10", children: [_jsx(RouteTokenPair, { route: destination, token: destinationCurrency }), receiveAmount && (_jsxs("div", { className: "flex flex-col justify-end items-end w-full col-start-7 col-span-4", children: [_jsx("p", { className: clsx("text-primary-text text-sm text-end"), children: _jsx(NumberFlow, { value: receiveAmount, suffix: ` ${destinationCurrency.symbol}`, trend: 0, format: { maximumFractionDigits: quote.quote.destination_token?.decimals || 2 } }) }), _jsxs("p", { className: "text-secondary-text text-sm flex items-center gap-1", children: [_jsx(PriceImpact, { className: "text-sm", bridgeFee: swapQuote?.blockchain_fee, destinationTokenPriceUsd: swapQuote?.destination_token?.price_in_usd, receiveAmount: swapQuote?.receive_amount, requestedAmount: swapQuote?.requested_amount, serviceFee: swapQuote?.service_fee, sourceTokenPriceUsd: swapQuote?.source_token?.price_in_usd }), _jsx(NumberFlow, { value: Number(receiveAmountInUsd) || 0, format: { style: 'currency', currency: 'USD' }, trend: 0 })] })] }))] }), (!!refuel != undefined && nativeCurrency) ?
29
+ _jsxs("p", { className: "text-primary-text text-sm whitespace-nowrap", children: [truncateDecimals(Number(requestedAmount), sourceCurrency.precision), " ", sourceCurrency.symbol] }), _jsx("p", { className: "text-secondary-text text-sm flex justify-end", children: _jsx(NumberFlow, { value: Number(requestedAmountInUsd) || 0, format: { style: 'currency', currency: 'USD' }, trend: 0 }) })] })] }), _jsxs("div", { className: "relative text-secondary-text", children: [_jsx("hr", { className: "border border-secondary-400 w-full rounded-full" }), _jsx(ArrowDown, { className: "absolute left-1/2 -translate-x-1/2 top-[-10px] h-6 w-6 p-1 bg-secondary-400 rounded-md text-secondary-text" })] }), _jsxs("div", { className: "w-full grid grid-cols-10", children: [_jsx(RouteTokenPair, { route: destination, token: destinationCurrency }), receiveAmount && (_jsxs("div", { className: "flex flex-col justify-end items-end w-full col-start-7 col-span-4", children: [_jsx("p", { className: clsx("text-primary-text text-sm text-end"), children: _jsx(NumberFlow, { value: receiveAmount, suffix: ` ${destinationCurrency.symbol}`, trend: 0, format: { maximumFractionDigits: quote.quote.destination_token?.decimals || 2 } }) }), _jsxs("p", { className: "text-secondary-text text-sm flex items-center gap-1", children: [_jsx(PriceImpact, { className: "text-sm", quote: swapQuote }), _jsx(NumberFlow, { value: Number(receiveAmountInUsd) || 0, format: { style: 'currency', currency: 'USD' }, trend: 0 })] })] }))] }), (!!refuel != undefined && nativeCurrency) ?
30
30
  _jsxs("div", { className: "flex items-center justify-between w-full ", children: [_jsxs("div", { className: 'flex items-center gap-3 text-sm', children: [_jsx("span", { className: "relative z-10 flex h-8 w-8 items-center justify-center rounded-lg p-2 bg-primary/20", children: _jsx(Fuel, { className: "h-5 w-5 text-primary", "aria-hidden": "true" }) }), _jsx("p", { children: "Refuel" })] }), _jsxs("div", { className: "flex flex-col items-end", children: [_jsxs("p", { className: "text-primary-text text-sm", children: [truncatedRefuelAmount, " ", nativeCurrency?.symbol] }), _jsxs("p", { className: "text-secondary-text text-sm flex justify-end", children: ["$", refuelAmountInUsd] })] })] })
31
31
  :
32
32
  _jsx(_Fragment, {})] }) }));
@@ -5,7 +5,7 @@ import { TransactionType } from "../../../../../lib/apiClients/layerSwapApiClien
5
5
  import { shortenEmail } from "../../../../../components/utils/ShortenAddress";
6
6
  import KnownInternalNames from "../../../../../lib/knownIds";
7
7
  import { useInitialSettings } from "../../../../../context/settings";
8
- import { useSelectedAccount } from "../../../../../context/balanceAccounts";
8
+ import { useSelectedAccount } from "../../../../../context/swapAccounts";
9
9
  const SwapSummary = () => {
10
10
  const { hideFrom, account, } = useInitialSettings();
11
11
  const { swapBasicData, swapDetails, quote, refuel, quoteIsLoading } = useSwapDataState();
@@ -18,7 +18,7 @@ const SwapSummary = () => {
18
18
  const swapOutputTransaction = swapDetails?.transactions?.find(t => t.type === TransactionType.Output);
19
19
  const requested_amount = (swapInputTransaction?.amount ?? swapBasicData.requested_amount) || undefined;
20
20
  const receiveAmount = quote?.receive_amount;
21
- const calculatedReceiveAmount = swapOutputTransaction?.amount ?? receiveAmount;
21
+ const calculatedReceiveAmount = swapOutputTransaction?.amount ? swapOutputTransaction?.amount : receiveAmount;
22
22
  let sourceAccountAddress = "";
23
23
  if (hideFrom && account) {
24
24
  sourceAccountAddress = account;
@@ -41,7 +41,7 @@ const SwapSummary = () => {
41
41
  const swapData = {
42
42
  swap: {
43
43
  ...swapBasicData,
44
- requested_amount: requested_amount
44
+ requested_amount: requested_amount?.toString()
45
45
  },
46
46
  quote: {
47
47
  quote: quote,
@@ -9,8 +9,10 @@ import { SwapStatus } from '../../../../Models/SwapStatus';
9
9
  import { useSwapTransactionStore } from '../../../../stores/swapTransactionStore';
10
10
  import SubmitButton from '../../../../components/Buttons/submitButton';
11
11
  import ManualWithdraw from './ManualWithdraw';
12
- const SwapDetails = ({ type, onWalletWithdrawalSuccess, partner }) => {
13
- const { swapDetails, swapBasicData, quote, refuel, depositActionsResponse } = useSwapDataState();
12
+ import { useCallbacks } from "../../../../context/callbackProvider";
13
+ const SwapDetails = ({ type, onWalletWithdrawalSuccess, onCancelWithdrawal, partner }) => {
14
+ const { swapDetails, swapBasicData, refuel, depositActionsResponse, quote, quoteIsLoading } = useSwapDataState();
15
+ const { onBackClick } = useCallbacks();
14
16
  const swapStatus = swapDetails?.status || SwapStatus.UserTransferPending;
15
17
  const storedWalletTransactions = useSwapTransactionStore();
16
18
  const swapInputTransaction = swapDetails?.transactions?.find(t => t.type === TransactionType.Input);
@@ -20,18 +22,18 @@ const SwapDetails = ({ type, onWalletWithdrawalSuccess, partner }) => {
20
22
  }, [swapDetails?.id, storedWalletTransactions]);
21
23
  if (!swapBasicData)
22
24
  return _jsx(_Fragment, { children: _jsx("div", { className: "w-full h-[430px]", children: _jsx("div", { className: "animate-pulse flex space-x-4", children: _jsxs("div", { className: "flex-1 space-y-6 py-1", children: [_jsx("div", { className: "h-32 bg-secondary-700 rounded-lg" }), _jsx("div", { className: "h-40 bg-secondary-700 rounded-lg" }), _jsx("div", { className: "h-12 bg-secondary-700 rounded-lg" })] }) }) }) });
23
- return (_jsx(Container, { type: type, children: ((swapStatus === SwapStatus.UserTransferPending
25
+ return (_jsx(Container, { type: type, goBack: onBackClick, children: ((swapStatus === SwapStatus.UserTransferPending
24
26
  && !(swapInputTransaction || storedWalletTransaction))) ?
25
27
  (swapBasicData?.use_deposit_address === true
26
- ? _jsx(ManualWithdraw, { swapBasicData: swapBasicData, quote: quote, depositActions: depositActionsResponse, refuel: refuel, partner: partner, type: type })
27
- : _jsx(Withdraw, { type: type, onWalletWithdrawalSuccess: onWalletWithdrawalSuccess, partner: partner }))
28
+ ? _jsx(ManualWithdraw, { swapBasicData: swapBasicData, depositActions: depositActionsResponse, refuel: refuel, partner: partner, type: type, quote: quote, isQuoteLoading: quoteIsLoading })
29
+ : _jsx(Withdraw, { type: type, onWalletWithdrawalSuccess: onWalletWithdrawalSuccess, onCancelWithdrawal: onCancelWithdrawal, partner: partner }))
28
30
  :
29
31
  _jsxs("div", { className: 'space-y-3 w-full h-full', children: [_jsx(Processing, {}), storedWalletTransaction?.status == BackendTransactionStatus.Failed &&
30
32
  _jsx(SubmitButton, { isDisabled: false, isSubmitting: false, onClick: removeStoredTransaction, children: "Try again" })] }) }));
31
33
  };
32
- const Container = ({ type, children }) => {
34
+ const Container = ({ type, children, goBack }) => {
33
35
  if (type === "widget")
34
- return _jsx(Widget, { children: _jsx(_Fragment, { children: children }) });
36
+ return _jsx(Widget, { goBack: goBack, children: _jsx(_Fragment, { children: children }) });
35
37
  else
36
38
  return _jsx("div", { className: "w-full flex flex-col justify-between h-full space-y-3 text-secondary-text", children: children });
37
39
  };
@@ -0,0 +1,43 @@
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ import { ActionMessages, ActionMessageType } from "../../messages/TransactionMessages";
4
+ import { ErrorHandler } from "../../../../../../lib/ErrorHandler";
5
+ export const ActionMessage = ({ error, isLoading }) => {
6
+ useEffect(() => {
7
+ if (error && (error?.name === ActionMessageType.UnexpectedErrorMessage
8
+ || !Object.values(ActionMessageType).includes(error.name))) {
9
+ ErrorHandler({
10
+ type: "SwapWithdrawalError",
11
+ message: error.message,
12
+ name: error.name,
13
+ stack: error.stack,
14
+ cause: error.cause
15
+ });
16
+ }
17
+ }, [error]);
18
+ if (isLoading) {
19
+ return _jsx(ActionMessages.ConfirmActionMessage, {});
20
+ }
21
+ else if (error?.name === ActionMessageType.TransactionRejected) {
22
+ return _jsx(ActionMessages.TransactionRejectedMessage, {});
23
+ }
24
+ else if (error?.name === ActionMessageType.TransactionFailed) {
25
+ return _jsx(ActionMessages.TransactionFailedMessage, {});
26
+ }
27
+ else if (error?.name === ActionMessageType.InsufficientFunds) {
28
+ return _jsx(ActionMessages.InsufficientFundsMessage, {});
29
+ }
30
+ else if (error?.name === ActionMessageType.WaletMismatch) {
31
+ return _jsx(ActionMessages.WaletMismatchMessage, { address: error?.message });
32
+ }
33
+ else if (error?.name === ActionMessageType.DifferentAccountsNotAllowedError) {
34
+ return _jsx(ActionMessages.DifferentAccountsNotAllowedError, { network: error?.message });
35
+ }
36
+ else if (error) {
37
+ if (!error.message)
38
+ return _jsx(ActionMessages.UnexpectedErrorMessage, { message: 'Something went wrong' });
39
+ return _jsx(ActionMessages.UnexpectedErrorMessage, { message: error.message });
40
+ }
41
+ else
42
+ return _jsx(_Fragment, {});
43
+ };