@layerswap/widget 1.0.6 → 1.1.1

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 (437) hide show
  1. package/dist/esm/Models/LayerSwapSettings.js +0 -1
  2. package/dist/esm/Models/Theme.js +39 -0
  3. package/dist/esm/components/Buttons/submitButton.js +2 -1
  4. package/dist/esm/components/Common/ConnectWalletButton.js +9 -3
  5. package/dist/esm/components/Common/CountDownTimer.js +0 -1
  6. package/dist/esm/components/Common/WarningMessage.js +4 -2
  7. package/dist/esm/components/Common/guideLink.js +4 -6
  8. package/dist/esm/components/ErrorFallback.js +12 -12
  9. package/dist/esm/components/HeaderWithMenu.js +1 -1
  10. package/dist/esm/components/Icons/CircularLoader.js +5 -0
  11. package/dist/esm/components/Icons/FailIcon.js +2 -2
  12. package/dist/esm/components/Icons/GlobeIcon.js +3 -0
  13. package/dist/esm/components/Icons/MenuIcon.js +5 -0
  14. package/dist/esm/components/Icons/TokenIcon.js +1 -1
  15. package/dist/esm/components/Icons/Wallets/index.js +0 -1
  16. package/dist/esm/components/Input/Address/AddressNote.js +2 -2
  17. package/dist/esm/components/Input/Address/AddressPicker/AddressWithIcon.js +5 -2
  18. package/dist/esm/components/Input/Address/AddressPicker/index.js +15 -12
  19. package/dist/esm/components/Input/Address/ContractAddressNote.js +17 -0
  20. package/dist/esm/components/Input/Address/UrlAddressNote.js +10 -0
  21. package/dist/esm/components/Input/Amount/Balance.js +1 -1
  22. package/dist/esm/components/Input/Amount/ExchangeReceiveAmount.js +8 -0
  23. package/dist/esm/components/Input/Amount/MinMax.js +1 -1
  24. package/dist/esm/components/Input/Amount/PriceImpact.js +5 -40
  25. package/dist/esm/components/Input/Amount/ReceiveAmount.js +2 -2
  26. package/dist/esm/components/Input/Amount/index.js +3 -3
  27. package/dist/esm/components/Input/DestinationPicker.js +2 -2
  28. package/dist/esm/components/Input/RoutePicker/Content.js +19 -3
  29. package/dist/esm/components/Input/RoutePicker/RouteTokenSwitch.js +4 -4
  30. package/dist/esm/components/Input/RoutePicker/RouterPickerWalletConnect.js +5 -5
  31. package/dist/esm/components/Input/RoutePicker/Routes.js +27 -26
  32. package/dist/esm/components/Input/RoutePicker/Rows/CollapsableHeader.js +2 -2
  33. package/dist/esm/components/Input/RoutePicker/Rows/CollapsibleRow.js +3 -3
  34. package/dist/esm/components/Input/RoutePicker/Rows/StickyHeader.js +2 -2
  35. package/dist/esm/components/Input/RoutePicker/Rows/SuggestionsHeader.js +55 -0
  36. package/dist/esm/components/Input/RoutePicker/Rows/TitleRow.js +11 -0
  37. package/dist/esm/components/Input/RoutePicker/Rows/index.js +5 -6
  38. package/dist/esm/components/Input/RoutePicker/TokenTitleDetails.js +10 -0
  39. package/dist/esm/components/Input/RoutePicker/index.js +2 -2
  40. package/dist/esm/components/Input/SourceWalletPicker.js +6 -4
  41. package/dist/esm/components/Menu/MenuList.js +11 -19
  42. package/dist/esm/components/Menu/index.js +16 -7
  43. package/dist/esm/components/Modal/modalWithoutAnimation.js +3 -3
  44. package/dist/esm/components/Pages/Campaigns/Details/Leaderboard.js +2 -2
  45. package/dist/esm/components/Pages/Campaigns/Details/Rewards.js +2 -2
  46. package/dist/esm/components/Pages/Campaigns/Details/index.js +3 -4
  47. package/dist/esm/components/Pages/Campaigns/index.js +3 -4
  48. package/dist/esm/components/Pages/Swap/Form/ExchangeForm.js +21 -19
  49. package/dist/esm/components/Pages/Swap/Form/FeeDetails/Rate.js +6 -4
  50. package/dist/esm/components/Pages/Swap/Form/FeeDetails/Refuel.js +8 -3
  51. package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.js +51 -14
  52. package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/SummaryRow.js +1 -1
  53. package/dist/esm/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.js +3 -3
  54. package/dist/esm/components/Pages/Swap/Form/FeeDetails/index.js +10 -11
  55. package/dist/esm/components/Pages/Swap/Form/Form.js +27 -3
  56. package/dist/esm/components/Pages/Swap/Form/FormWrapper.js +35 -10
  57. package/dist/esm/components/Pages/Swap/Form/NetworkForm.js +13 -22
  58. package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/FormButton.js +1 -1
  59. package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.js +8 -6
  60. package/dist/esm/components/Pages/Swap/Form/SecondaryComponents/validationError/ContractAddressValidationCache.js +19 -0
  61. package/dist/esm/components/Pages/Swap/Withdraw/Failed.js +12 -8
  62. package/dist/esm/components/Pages/Swap/Withdraw/ManualWithdraw.js +28 -9
  63. package/dist/esm/components/Pages/Swap/Withdraw/NotFound.js +15 -4
  64. package/dist/esm/components/Pages/Swap/Withdraw/Processing/Processing.js +44 -45
  65. package/dist/esm/components/Pages/Swap/Withdraw/Summary/Summary.js +2 -3
  66. package/dist/esm/components/Pages/Swap/Withdraw/Summary/index.js +2 -2
  67. package/dist/esm/components/Pages/Swap/Withdraw/SwapDetails.js +9 -7
  68. package/dist/esm/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.js +43 -0
  69. package/dist/esm/components/Pages/Swap/Withdraw/Wallet/Common/buttons.js +125 -71
  70. package/dist/esm/components/Pages/Swap/Withdraw/Wallet/index.js +56 -65
  71. package/dist/esm/components/Pages/Swap/Withdraw/WalletTransferButton.js +2 -2
  72. package/dist/esm/components/Pages/Swap/Withdraw/WalletTransferContent.js +2 -2
  73. package/dist/esm/components/Pages/Swap/Withdraw/Withdraw.js +3 -3
  74. package/dist/esm/components/Pages/Swap/Withdraw/index.js +5 -4
  75. package/dist/esm/components/Pages/Swap/Withdraw/messages/Message.js +4 -4
  76. package/dist/esm/components/Pages/Swap/Withdraw/messages/TransactionMessages.js +14 -15
  77. package/dist/esm/components/Pages/SwapHistory/History.js +2 -2
  78. package/dist/esm/components/Pages/SwapHistory/HistorySummary.js +1 -1
  79. package/dist/esm/components/Pages/SwapHistory/index.js +4 -4
  80. package/dist/esm/components/Select/Selector/SelectItem.js +1 -1
  81. package/dist/esm/components/Wallet/WalletComponents/ConnectedWallets.js +4 -4
  82. package/dist/esm/components/Wallet/WalletComponents/WalletsList.js +1 -1
  83. package/dist/esm/components/Wallet/WalletModal/Connector.js +2 -2
  84. package/dist/esm/components/Wallet/WalletModal/ConnectorsList.js +78 -125
  85. package/dist/esm/components/Wallet/WalletModal/InstalledExtensionNotFound.js +16 -0
  86. package/dist/esm/components/Wallet/WalletModal/LoadingConnect.js +27 -0
  87. package/dist/esm/components/Wallet/WalletModal/MultichainConnectorPicker.js +23 -0
  88. package/dist/esm/components/Wallet/WalletModal/ProviderPicker.js +26 -0
  89. package/dist/esm/components/Wallet/WalletModal/WalletQrCode.js +18 -0
  90. package/dist/esm/components/Wallet/WalletModal/index.js +4 -2
  91. package/dist/esm/components/Wallet/WalletProviders/index.js +4 -2
  92. package/dist/esm/components/Widget/Content.js +2 -2
  93. package/dist/esm/components/Widget/Footer.js +21 -21
  94. package/dist/esm/components/Widget/Index.js +2 -2
  95. package/dist/esm/components/WidgetLoading.js +9 -2
  96. package/dist/esm/components/shadcn/checkbox.js +1 -1
  97. package/dist/esm/context/ErrorProvider.js +14 -0
  98. package/dist/esm/context/LayerswapProvider.js +6 -5
  99. package/dist/esm/context/callbackProvider.js +60 -52
  100. package/dist/esm/context/resolverContext.js +11 -2
  101. package/dist/esm/context/swap.js +10 -13
  102. package/dist/esm/context/{balanceAccounts.js → swapAccounts.js} +17 -17
  103. package/dist/esm/context/validationContext.js +1 -1
  104. package/dist/esm/context/walletProviders.js +7 -1
  105. package/dist/esm/context/withdrawalContext.js +2 -2
  106. package/dist/esm/exports/internal.js +4 -3
  107. package/dist/esm/helpers/filterSourceNetworks.js +23 -0
  108. package/dist/esm/helpers/getSettings/getSettings.js +18 -13
  109. package/dist/esm/helpers/routes.js +4 -1
  110. package/dist/esm/hooks/useAllWithdrawalBalances.js +11 -5
  111. package/dist/esm/hooks/useConnectors.js +72 -0
  112. package/dist/esm/hooks/useFormRoutes.js +16 -8
  113. package/dist/esm/hooks/useFormValidation.js +5 -4
  114. package/dist/esm/hooks/useRouteValidation.js +1 -1
  115. package/dist/esm/hooks/useSwrSwaps.js +1 -1
  116. package/dist/esm/hooks/useTransfer.js +9 -0
  117. package/dist/esm/hooks/useWallet.js +7 -7
  118. package/dist/esm/lib/AppSettings.js +27 -16
  119. package/dist/esm/lib/ErrorHandler.js +6 -0
  120. package/dist/esm/lib/address/contractAddressResolver.js +12 -0
  121. package/dist/esm/lib/apiClients/layerSwapApiClient.js +19 -35
  122. package/dist/esm/lib/balances/balanceResolver.js +57 -11
  123. package/dist/esm/lib/balances/errorUtils.js +13 -0
  124. package/dist/esm/lib/balances/nodeErrorClassifier.js +22 -0
  125. package/dist/esm/lib/fees.js +50 -0
  126. package/dist/esm/lib/generateSwapInitialValues.js +2 -2
  127. package/dist/esm/lib/isNewListed.js +8 -0
  128. package/dist/esm/lib/knownIds.js +1 -0
  129. package/dist/esm/lib/resolvers/resolverService.js +19 -1
  130. package/dist/esm/lib/transfers/index.js +1 -0
  131. package/dist/esm/lib/transfers/transferResolver.js +14 -0
  132. package/dist/esm/stores/balanceStore.js +39 -18
  133. package/dist/esm/stores/contractAddressStore.js +178 -0
  134. package/dist/esm/stores/logStore.js +11 -0
  135. package/dist/esm/types/balance.js +23 -11
  136. package/dist/esm/types/contract.js +1 -0
  137. package/dist/esm/types/index.js +2 -0
  138. package/dist/esm/types/logEvents.js +1 -0
  139. package/dist/index.css +1 -1
  140. package/dist/tsconfig.tsbuildinfo +1 -1
  141. package/dist/types/Models/Balance.d.ts +14 -2
  142. package/dist/types/Models/Balance.d.ts.map +1 -1
  143. package/dist/types/Models/LayerSwapSettings.d.ts +7 -0
  144. package/dist/types/Models/LayerSwapSettings.d.ts.map +1 -1
  145. package/dist/types/Models/Theme.d.ts.map +1 -1
  146. package/dist/types/components/Buttons/submitButton.d.ts +1 -1
  147. package/dist/types/components/Buttons/submitButton.d.ts.map +1 -1
  148. package/dist/types/components/Common/ConnectWalletButton.d.ts +1 -1
  149. package/dist/types/components/Common/ConnectWalletButton.d.ts.map +1 -1
  150. package/dist/types/components/Common/CountDownTimer.d.ts.map +1 -1
  151. package/dist/types/components/Common/WarningMessage.d.ts.map +1 -1
  152. package/dist/types/components/Common/guideLink.d.ts.map +1 -1
  153. package/dist/types/components/ErrorFallback.d.ts.map +1 -1
  154. package/dist/types/components/HeaderWithMenu.d.ts.map +1 -1
  155. package/dist/types/components/Icons/CircularLoader.d.ts +4 -0
  156. package/dist/types/components/Icons/CircularLoader.d.ts.map +1 -0
  157. package/dist/types/components/Icons/FailIcon.d.ts.map +1 -1
  158. package/dist/types/components/Icons/GasIcon.d.ts.map +1 -1
  159. package/dist/types/components/Icons/GlobeIcon.d.ts +4 -0
  160. package/dist/types/components/Icons/GlobeIcon.d.ts.map +1 -0
  161. package/dist/types/components/Icons/MenuIcon.d.ts +4 -0
  162. package/dist/types/components/Icons/MenuIcon.d.ts.map +1 -0
  163. package/dist/types/components/Icons/TokenIcon.d.ts.map +1 -1
  164. package/dist/types/components/Icons/Wallets/index.d.ts +0 -1
  165. package/dist/types/components/Icons/Wallets/index.d.ts.map +1 -1
  166. package/dist/types/components/Input/Address/AddressNote.d.ts +5 -5
  167. package/dist/types/components/Input/Address/AddressNote.d.ts.map +1 -1
  168. package/dist/types/components/Input/Address/AddressPicker/AddressBook.d.ts +3 -3
  169. package/dist/types/components/Input/Address/AddressPicker/AddressButton.d.ts +3 -3
  170. package/dist/types/components/Input/Address/AddressPicker/AddressWithIcon.d.ts +3 -2
  171. package/dist/types/components/Input/Address/AddressPicker/AddressWithIcon.d.ts.map +1 -1
  172. package/dist/types/components/Input/Address/AddressPicker/ConnectedWallets.d.ts +2 -2
  173. package/dist/types/components/Input/Address/AddressPicker/ManualAddressInput.d.ts +4 -4
  174. package/dist/types/components/Input/Address/AddressPicker/index.d.ts +4 -4
  175. package/dist/types/components/Input/Address/AddressPicker/index.d.ts.map +1 -1
  176. package/dist/types/components/Input/Address/ContractAddressNote.d.ts +9 -0
  177. package/dist/types/components/Input/Address/ContractAddressNote.d.ts.map +1 -0
  178. package/dist/types/components/Input/Address/UrlAddressNote.d.ts +10 -0
  179. package/dist/types/components/Input/Address/UrlAddressNote.d.ts.map +1 -0
  180. package/dist/types/components/Input/Address/index.d.ts +1 -1
  181. package/dist/types/components/Input/Amount/Balance.d.ts +1 -1
  182. package/dist/types/components/Input/Amount/Balance.d.ts.map +1 -1
  183. package/dist/types/components/Input/Amount/ExchangeReceiveAmount.d.ts +11 -0
  184. package/dist/types/components/Input/Amount/ExchangeReceiveAmount.d.ts.map +1 -0
  185. package/dist/types/components/Input/Amount/MinMax.d.ts +1 -1
  186. package/dist/types/components/Input/Amount/PriceImpact.d.ts +3 -6
  187. package/dist/types/components/Input/Amount/PriceImpact.d.ts.map +1 -1
  188. package/dist/types/components/Input/Amount/ReceiveAmount.d.ts +2 -3
  189. package/dist/types/components/Input/Amount/ReceiveAmount.d.ts.map +1 -1
  190. package/dist/types/components/Input/Amount/helpers.d.ts +2 -2
  191. package/dist/types/components/Input/Amount/index.d.ts +1 -1
  192. package/dist/types/components/Input/CexPicker.d.ts +1 -1
  193. package/dist/types/components/Input/DestinationPicker.d.ts +1 -1
  194. package/dist/types/components/Input/DestinationPicker.d.ts.map +1 -1
  195. package/dist/types/components/Input/RoutePicker/Content.d.ts +5 -5
  196. package/dist/types/components/Input/RoutePicker/Content.d.ts.map +1 -1
  197. package/dist/types/components/Input/RoutePicker/RouterPickerWalletConnect.d.ts +1 -1
  198. package/dist/types/components/Input/RoutePicker/RouterPickerWalletConnect.d.ts.map +1 -1
  199. package/dist/types/components/Input/RoutePicker/Routes.d.ts +4 -8
  200. package/dist/types/components/Input/RoutePicker/Routes.d.ts.map +1 -1
  201. package/dist/types/components/Input/RoutePicker/Rows/CollapsableHeader.d.ts +3 -4
  202. package/dist/types/components/Input/RoutePicker/Rows/CollapsableHeader.d.ts.map +1 -1
  203. package/dist/types/components/Input/RoutePicker/Rows/CollapsibleRow.d.ts +6 -5
  204. package/dist/types/components/Input/RoutePicker/Rows/CollapsibleRow.d.ts.map +1 -1
  205. package/dist/types/components/Input/RoutePicker/Rows/StickyHeader.d.ts +3 -4
  206. package/dist/types/components/Input/RoutePicker/Rows/StickyHeader.d.ts.map +1 -1
  207. package/dist/types/components/Input/RoutePicker/Rows/SuggestionsHeader.d.ts +7 -0
  208. package/dist/types/components/Input/RoutePicker/Rows/SuggestionsHeader.d.ts.map +1 -0
  209. package/dist/types/components/Input/RoutePicker/Rows/TitleRow.d.ts +7 -0
  210. package/dist/types/components/Input/RoutePicker/Rows/TitleRow.d.ts.map +1 -0
  211. package/dist/types/components/Input/RoutePicker/Rows/index.d.ts +5 -5
  212. package/dist/types/components/Input/RoutePicker/Rows/index.d.ts.map +1 -1
  213. package/dist/types/components/Input/RoutePicker/TokenTitleDetails.d.ts +18 -0
  214. package/dist/types/components/Input/RoutePicker/TokenTitleDetails.d.ts.map +1 -0
  215. package/dist/types/components/Input/RoutePicker/index.d.ts +1 -1
  216. package/dist/types/components/Input/RoutePicker/index.d.ts.map +1 -1
  217. package/dist/types/components/Input/SourcePicker.d.ts +1 -1
  218. package/dist/types/components/Input/SourceWalletPicker.d.ts.map +1 -1
  219. package/dist/types/components/Menu/MenuList.d.ts.map +1 -1
  220. package/dist/types/components/Menu/index.d.ts.map +1 -1
  221. package/dist/types/components/Modal/modalWithoutAnimation.d.ts +4 -2
  222. package/dist/types/components/Modal/modalWithoutAnimation.d.ts.map +1 -1
  223. package/dist/types/components/Pages/Campaigns/Details/Leaderboard.d.ts +1 -1
  224. package/dist/types/components/Pages/Campaigns/Details/Rewards.d.ts +1 -1
  225. package/dist/types/components/Pages/Campaigns/Details/index.d.ts +1 -2
  226. package/dist/types/components/Pages/Campaigns/Details/index.d.ts.map +1 -1
  227. package/dist/types/components/Pages/Campaigns/index.d.ts +2 -3
  228. package/dist/types/components/Pages/Campaigns/index.d.ts.map +1 -1
  229. package/dist/types/components/Pages/Swap/Form/ExchangeForm.d.ts +3 -1
  230. package/dist/types/components/Pages/Swap/Form/ExchangeForm.d.ts.map +1 -1
  231. package/dist/types/components/Pages/Swap/Form/FeeDetails/Rate.d.ts +7 -6
  232. package/dist/types/components/Pages/Swap/Form/FeeDetails/Rate.d.ts.map +1 -1
  233. package/dist/types/components/Pages/Swap/Form/FeeDetails/ReceiveAmounts.d.ts +2 -2
  234. package/dist/types/components/Pages/Swap/Form/FeeDetails/Refuel.d.ts +1 -2
  235. package/dist/types/components/Pages/Swap/Form/FeeDetails/Refuel.d.ts.map +1 -1
  236. package/dist/types/components/Pages/Swap/Form/FeeDetails/RefuelModal.d.ts +1 -1
  237. package/dist/types/components/Pages/Swap/Form/FeeDetails/Slippage.d.ts +1 -1
  238. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.d.ts +3 -2
  239. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/DetailedEstimates.d.ts.map +1 -1
  240. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/SummaryRow.d.ts +4 -4
  241. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.d.ts +4 -4
  242. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/index.d.ts.map +1 -1
  243. package/dist/types/components/Pages/Swap/Form/FeeDetails/SwapQuote/utils.d.ts +2 -2
  244. package/dist/types/components/Pages/Swap/Form/FeeDetails/index.d.ts +7 -4
  245. package/dist/types/components/Pages/Swap/Form/FeeDetails/index.d.ts.map +1 -1
  246. package/dist/types/components/Pages/Swap/Form/Form.d.ts.map +1 -1
  247. package/dist/types/components/Pages/Swap/Form/FormWrapper.d.ts +1 -1
  248. package/dist/types/components/Pages/Swap/Form/FormWrapper.d.ts.map +1 -1
  249. package/dist/types/components/Pages/Swap/Form/NetworkForm.d.ts +1 -1
  250. package/dist/types/components/Pages/Swap/Form/NetworkForm.d.ts.map +1 -1
  251. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/FormButton.d.ts +1 -1
  252. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/FormButton.d.ts.map +1 -1
  253. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.d.ts +2 -2
  254. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/ReserveGasNote.d.ts.map +1 -1
  255. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/validationError/ContractAddressValidationCache.d.ts +10 -0
  256. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/validationError/ContractAddressValidationCache.d.ts.map +1 -0
  257. package/dist/types/components/Pages/Swap/Form/SecondaryComponents/validationError/ErrorDisplay.d.ts +1 -1
  258. package/dist/types/components/Pages/Swap/Form/SwapFormValues.d.ts +2 -2
  259. package/dist/types/components/Pages/Swap/Withdraw/Failed.d.ts.map +1 -1
  260. package/dist/types/components/Pages/Swap/Withdraw/ManualWithdraw.d.ts +4 -3
  261. package/dist/types/components/Pages/Swap/Withdraw/ManualWithdraw.d.ts.map +1 -1
  262. package/dist/types/components/Pages/Swap/Withdraw/NotFound.d.ts.map +1 -1
  263. package/dist/types/components/Pages/Swap/Withdraw/Processing/Processing.d.ts +1 -1
  264. package/dist/types/components/Pages/Swap/Withdraw/Processing/Processing.d.ts.map +1 -1
  265. package/dist/types/components/Pages/Swap/Withdraw/QuoteUpdate.d.ts +1 -1
  266. package/dist/types/components/Pages/Swap/Withdraw/Summary/Summary.d.ts +1 -1
  267. package/dist/types/components/Pages/Swap/Withdraw/Summary/Summary.d.ts.map +1 -1
  268. package/dist/types/components/Pages/Swap/Withdraw/SwapDetails.d.ts +2 -1
  269. package/dist/types/components/Pages/Swap/Withdraw/SwapDetails.d.ts.map +1 -1
  270. package/dist/types/components/Pages/Swap/Withdraw/SwapQuoteDetails.d.ts +3 -3
  271. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.d.ts +6 -0
  272. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/actionMessage.d.ts.map +1 -0
  273. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/buttons.d.ts +4 -3
  274. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/buttons.d.ts.map +1 -1
  275. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/sharedTypes.d.ts +2 -1
  276. package/dist/types/components/Pages/Swap/Withdraw/Wallet/Common/sharedTypes.d.ts.map +1 -1
  277. package/dist/types/components/Pages/Swap/Withdraw/Wallet/index.d.ts +2 -1
  278. package/dist/types/components/Pages/Swap/Withdraw/Wallet/index.d.ts.map +1 -1
  279. package/dist/types/components/Pages/Swap/Withdraw/WalletTransferButton.d.ts +2 -1
  280. package/dist/types/components/Pages/Swap/Withdraw/WalletTransferButton.d.ts.map +1 -1
  281. package/dist/types/components/Pages/Swap/Withdraw/WalletTransferContent.d.ts +1 -1
  282. package/dist/types/components/Pages/Swap/Withdraw/Withdraw.d.ts +2 -1
  283. package/dist/types/components/Pages/Swap/Withdraw/Withdraw.d.ts.map +1 -1
  284. package/dist/types/components/Pages/Swap/Withdraw/index.d.ts +1 -2
  285. package/dist/types/components/Pages/Swap/Withdraw/index.d.ts.map +1 -1
  286. package/dist/types/components/Pages/Swap/Withdraw/messages/Message.d.ts.map +1 -1
  287. package/dist/types/components/Pages/Swap/Withdraw/messages/TransactionMessages.d.ts +3 -4
  288. package/dist/types/components/Pages/Swap/Withdraw/messages/TransactionMessages.d.ts.map +1 -1
  289. package/dist/types/components/Pages/SwapHistory/HistorySummary.d.ts +2 -2
  290. package/dist/types/components/Pages/SwapHistory/HistorySummary.d.ts.map +1 -1
  291. package/dist/types/components/Pages/SwapHistory/StatusIcons.d.ts +1 -1
  292. package/dist/types/components/Pages/SwapHistory/SwapDetailsComponent.d.ts +1 -1
  293. package/dist/types/components/Pages/SwapHistory/index.d.ts +3 -1
  294. package/dist/types/components/Pages/SwapHistory/index.d.ts.map +1 -1
  295. package/dist/types/components/Select/Command/commandSelect.d.ts.map +1 -1
  296. package/dist/types/components/Select/Selector/SelectItem.d.ts.map +1 -1
  297. package/dist/types/components/Wallet/WalletComponents/WalletsList.d.ts +3 -3
  298. package/dist/types/components/Wallet/WalletComponents/WalletsList.d.ts.map +1 -1
  299. package/dist/types/components/Wallet/WalletModal/Connector.d.ts +2 -1
  300. package/dist/types/components/Wallet/WalletModal/Connector.d.ts.map +1 -1
  301. package/dist/types/components/Wallet/WalletModal/ConnectorsList.d.ts +1 -1
  302. package/dist/types/components/Wallet/WalletModal/ConnectorsList.d.ts.map +1 -1
  303. package/dist/types/components/Wallet/WalletModal/InstalledExtensionNotFound.d.ts +7 -0
  304. package/dist/types/components/Wallet/WalletModal/InstalledExtensionNotFound.d.ts.map +1 -0
  305. package/dist/types/components/Wallet/WalletModal/LoadingConnect.d.ts +8 -0
  306. package/dist/types/components/Wallet/WalletModal/LoadingConnect.d.ts.map +1 -0
  307. package/dist/types/components/Wallet/WalletModal/MultichainConnectorPicker.d.ts +12 -0
  308. package/dist/types/components/Wallet/WalletModal/MultichainConnectorPicker.d.ts.map +1 -0
  309. package/dist/types/components/Wallet/WalletModal/ProviderPicker.d.ts +8 -0
  310. package/dist/types/components/Wallet/WalletModal/ProviderPicker.d.ts.map +1 -0
  311. package/dist/types/components/Wallet/WalletModal/WalletQrCode.d.ts +6 -0
  312. package/dist/types/components/Wallet/WalletModal/WalletQrCode.d.ts.map +1 -0
  313. package/dist/types/components/Wallet/WalletModal/index.d.ts +2 -1
  314. package/dist/types/components/Wallet/WalletModal/index.d.ts.map +1 -1
  315. package/dist/types/components/Wallet/WalletProviders/index.d.ts +3 -1
  316. package/dist/types/components/Wallet/WalletProviders/index.d.ts.map +1 -1
  317. package/dist/types/components/Widget/Content.d.ts +2 -1
  318. package/dist/types/components/Widget/Content.d.ts.map +1 -1
  319. package/dist/types/components/Widget/Footer.d.ts +2 -1
  320. package/dist/types/components/Widget/Footer.d.ts.map +1 -1
  321. package/dist/types/components/Widget/Index.d.ts +3 -2
  322. package/dist/types/components/Widget/Index.d.ts.map +1 -1
  323. package/dist/types/components/WidgetLoading.d.ts.map +1 -1
  324. package/dist/types/components/shadcn/command.d.ts +9 -52
  325. package/dist/types/components/shadcn/command.d.ts.map +1 -1
  326. package/dist/types/context/ErrorProvider.d.ts +3 -0
  327. package/dist/types/context/ErrorProvider.d.ts.map +1 -0
  328. package/dist/types/context/LayerswapProvider.d.ts +22 -4
  329. package/dist/types/context/LayerswapProvider.d.ts.map +1 -1
  330. package/dist/types/context/callbackProvider.d.ts +7 -10
  331. package/dist/types/context/callbackProvider.d.ts.map +1 -1
  332. package/dist/types/context/resolverContext.d.ts.map +1 -1
  333. package/dist/types/context/swap.d.ts +7 -7
  334. package/dist/types/context/swap.d.ts.map +1 -1
  335. package/dist/types/context/{balanceAccounts.d.ts → swapAccounts.d.ts} +9 -9
  336. package/dist/types/context/swapAccounts.d.ts.map +1 -0
  337. package/dist/types/context/walletProviders.d.ts.map +1 -1
  338. package/dist/types/context/withdrawalContext.d.ts +2 -0
  339. package/dist/types/context/withdrawalContext.d.ts.map +1 -1
  340. package/dist/types/exports/internal.d.ts +9 -7
  341. package/dist/types/exports/internal.d.ts.map +1 -1
  342. package/dist/types/helpers/accountSelectHelper.d.ts +1 -1
  343. package/dist/types/helpers/balanceHelper.d.ts +2 -2
  344. package/dist/types/helpers/filterSourceNetworks.d.ts +4 -0
  345. package/dist/types/helpers/filterSourceNetworks.d.ts.map +1 -0
  346. package/dist/types/helpers/getSettings/getSettings.d.ts +1 -1
  347. package/dist/types/helpers/getSettings/getSettings.d.ts.map +1 -1
  348. package/dist/types/helpers/routes.d.ts +1 -1
  349. package/dist/types/helpers/routes.d.ts.map +1 -1
  350. package/dist/types/helpers/tokenHelper.d.ts +2 -2
  351. package/dist/types/hooks/useAllWithdrawalBalances.d.ts +2 -1
  352. package/dist/types/hooks/useAllWithdrawalBalances.d.ts.map +1 -1
  353. package/dist/types/hooks/useConnectors.d.ts +28 -0
  354. package/dist/types/hooks/useConnectors.d.ts.map +1 -0
  355. package/dist/types/hooks/useFee.d.ts +1 -1
  356. package/dist/types/hooks/useFormRoutes.d.ts +2 -3
  357. package/dist/types/hooks/useFormRoutes.d.ts.map +1 -1
  358. package/dist/types/hooks/useFormValidation.d.ts +2 -1
  359. package/dist/types/hooks/useFormValidation.d.ts.map +1 -1
  360. package/dist/types/hooks/useSwapHistoryData.d.ts +2 -2
  361. package/dist/types/hooks/useTransfer.d.ts +5 -0
  362. package/dist/types/hooks/useTransfer.d.ts.map +1 -0
  363. package/dist/types/hooks/useWallet.d.ts +3 -3
  364. package/dist/types/hooks/useWallet.d.ts.map +1 -1
  365. package/dist/types/lib/AppSettings.d.ts +25 -16
  366. package/dist/types/lib/AppSettings.d.ts.map +1 -1
  367. package/dist/types/lib/ErrorHandler.d.ts +3 -0
  368. package/dist/types/lib/ErrorHandler.d.ts.map +1 -0
  369. package/dist/types/lib/address/contractAddressResolver.d.ts +7 -0
  370. package/dist/types/lib/address/contractAddressResolver.d.ts.map +1 -0
  371. package/dist/types/lib/apiClients/layerSwapApiClient.d.ts +1 -9
  372. package/dist/types/lib/apiClients/layerSwapApiClient.d.ts.map +1 -1
  373. package/dist/types/lib/balances/balanceResolver.d.ts +3 -3
  374. package/dist/types/lib/balances/balanceResolver.d.ts.map +1 -1
  375. package/dist/types/lib/balances/errorUtils.d.ts +12 -0
  376. package/dist/types/lib/balances/errorUtils.d.ts.map +1 -0
  377. package/dist/types/lib/balances/helpers.d.ts +1 -1
  378. package/dist/types/lib/balances/nodeErrorClassifier.d.ts +4 -0
  379. package/dist/types/lib/balances/nodeErrorClassifier.d.ts.map +1 -0
  380. package/dist/types/lib/balances/useBalance.d.ts +1 -1
  381. package/dist/types/lib/fees.d.ts +16 -0
  382. package/dist/types/lib/fees.d.ts.map +1 -1
  383. package/dist/types/lib/gases/gasResolver.d.ts +2 -2
  384. package/dist/types/lib/gases/useSWRGas.d.ts +3 -3
  385. package/dist/types/lib/generateSwapInitialValues.d.ts +1 -1
  386. package/dist/types/lib/isNewListed.d.ts +4 -0
  387. package/dist/types/lib/isNewListed.d.ts.map +1 -0
  388. package/dist/types/lib/knownIds.d.ts +1 -0
  389. package/dist/types/lib/knownIds.d.ts.map +1 -1
  390. package/dist/types/lib/nft/nftBalanceResolver.d.ts +1 -1
  391. package/dist/types/lib/resolvers/resolverService.d.ts +11 -5
  392. package/dist/types/lib/resolvers/resolverService.d.ts.map +1 -1
  393. package/dist/types/lib/transfers/index.d.ts +2 -0
  394. package/dist/types/lib/transfers/index.d.ts.map +1 -0
  395. package/dist/types/lib/transfers/transferResolver.d.ts +7 -0
  396. package/dist/types/lib/transfers/transferResolver.d.ts.map +1 -0
  397. package/dist/types/stores/balanceStore.d.ts +3 -0
  398. package/dist/types/stores/balanceStore.d.ts.map +1 -1
  399. package/dist/types/stores/contractAddressStore.d.ts +43 -0
  400. package/dist/types/stores/contractAddressStore.d.ts.map +1 -0
  401. package/dist/types/stores/logStore.d.ts +8 -0
  402. package/dist/types/stores/logStore.d.ts.map +1 -0
  403. package/dist/types/stores/walletStore.d.ts +1 -1
  404. package/dist/types/types/balance.d.ts +2 -2
  405. package/dist/types/types/balance.d.ts.map +1 -1
  406. package/dist/types/types/contract.d.ts +6 -0
  407. package/dist/types/types/contract.d.ts.map +1 -0
  408. package/dist/types/types/gas.d.ts +2 -2
  409. package/dist/types/types/index.d.ts +2 -0
  410. package/dist/types/types/index.d.ts.map +1 -1
  411. package/dist/types/types/logEvents.d.ts +59 -0
  412. package/dist/types/types/logEvents.d.ts.map +1 -0
  413. package/dist/types/types/nft.d.ts +1 -1
  414. package/dist/types/types/transfer.d.ts +7 -2
  415. package/dist/types/types/transfer.d.ts.map +1 -1
  416. package/dist/types/types/wallet.d.ts +29 -8
  417. package/dist/types/types/wallet.d.ts.map +1 -1
  418. package/package.json +3 -3
  419. package/dist/esm/components/Icons/Wallets/Keplr.js +0 -3
  420. package/dist/esm/components/Modal/popover.js +0 -15
  421. package/dist/esm/components/Wallet/WalletModal/utils.js +0 -23
  422. package/dist/esm/helpers/querryHelper.js +0 -13
  423. package/dist/esm/lib/logError.js +0 -17
  424. package/dist/esm/lib/sorting.js +0 -63
  425. package/dist/types/components/Icons/Wallets/Keplr.d.ts +0 -4
  426. package/dist/types/components/Icons/Wallets/Keplr.d.ts.map +0 -1
  427. package/dist/types/components/Modal/popover.d.ts +0 -12
  428. package/dist/types/components/Modal/popover.d.ts.map +0 -1
  429. package/dist/types/components/Wallet/WalletModal/utils.d.ts +0 -2
  430. package/dist/types/components/Wallet/WalletModal/utils.d.ts.map +0 -1
  431. package/dist/types/context/balanceAccounts.d.ts.map +0 -1
  432. package/dist/types/helpers/querryHelper.d.ts +0 -3
  433. package/dist/types/helpers/querryHelper.d.ts.map +0 -1
  434. package/dist/types/lib/logError.d.ts +0 -3
  435. package/dist/types/lib/logError.d.ts.map +0 -1
  436. package/dist/types/lib/sorting.d.ts +0 -22
  437. package/dist/types/lib/sorting.d.ts.map +0 -1
@@ -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,35 @@ 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
+ swapId: swapDetails?.id,
81
+ transactionHash: transactionHash,
82
+ fromAddress: swapInputTransaction?.from,
83
+ toAddress: swapBasicData?.destination_address
84
+ });
86
85
  }
87
86
  }, [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])
87
+ useEffect(() => {
88
+ const status = swapDetails?.status;
89
+ if (status === SwapStatus.Completed ||
90
+ status === SwapStatus.Failed ||
91
+ status === SwapStatus.Expired ||
92
+ status === SwapStatus.LsTransferPending) {
93
+ onSwapStatusChange({
94
+ type: status,
95
+ swapId: swapDetails?.id,
96
+ path: 'Processing',
97
+ });
98
+ }
99
+ }, [swapDetails?.status, swapDetails?.id]);
101
100
  const truncatedRefuelAmount = refuel && truncateDecimals(refuel.amount, refuel.token?.precision);
102
101
  const progressStatuses = getProgressStatuses(swapDetails, refuel, inputTxStatusData?.data?.status.toLowerCase());
103
102
  const stepStatuses = progressStatuses.stepStatuses;
@@ -110,7 +109,7 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
110
109
  },
111
110
  current: {
112
111
  name: 'Processing your deposit',
113
- description: _jsxs("div", { className: 'flex space-x-1', children: [_jsx("div", { className: 'flex items-center space-x-1', children: _jsx(LinkWithIcon, { name: 'View in explorer', url: input_tx_explorer?.replace("{0}", transactionHash) }) }), _jsx("div", { children: _jsx("span", { children: swapInputTransaction && swapInputTransaction?.confirmations && (_jsxs("div", { children: [_jsx("span", { className: 'whitespace-nowrap', children: "| Confirmations" }), _jsxs("span", { className: "text-primary-text ml-1", children: [_jsx("span", { children: swapInputTransaction?.confirmations >= swapInputTransaction?.max_confirmations
112
+ description: _jsxs("div", { className: 'flex space-x-1', children: [_jsx("div", { className: 'flex items-center space-x-1', children: _jsx(LinkWithIcon, { name: 'View in explorer', url: input_tx_explorer?.replace("{0}", transactionHash) }) }), _jsx("div", { children: _jsx("span", { children: swapInputTransaction && swapInputTransaction?.confirmations > 0 && (_jsxs("div", { children: [_jsx("span", { className: 'whitespace-nowrap', children: "| Confirmations " }), _jsxs("span", { className: "text-primary-text ml-1", children: [_jsx("span", { children: swapInputTransaction?.confirmations >= swapInputTransaction?.max_confirmations
114
113
  ? swapInputTransaction?.max_confirmations
115
114
  : swapInputTransaction?.confirmations }), _jsx("span", { children: "/" }), swapInputTransaction?.max_confirmations] })] })) }) })] })
116
115
  },
@@ -147,7 +146,7 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
147
146
  },
148
147
  complete: {
149
148
  name: `${swapOutputTransaction?.amount && truncateDecimals(swapOutputTransaction?.amount, destination_token.decimals)} ${destination_token.symbol} was sent to your address`,
150
- description: swapOutputTransaction ? _jsx("div", { className: "flex flex-col", children: _jsxs("div", { className: 'flex items-center space-x-1', children: [_jsx("span", { children: "Transaction: " }), _jsx(LinkWithIcon, { name: 'View in explorer', url: output_tx_explorer?.replace("{0}", swapOutputTransaction.transaction_hash) })] }) }) : null,
149
+ description: swapOutputTransaction?.amount ? _jsx("div", { className: "flex flex-col", children: _jsxs("div", { className: 'flex items-center space-x-1', children: [_jsx("span", { children: "Transaction: " }), _jsx(LinkWithIcon, { name: 'View in explorer', url: output_tx_explorer?.replace("{0}", swapOutputTransaction.transaction_hash) })] }) }) : null,
151
150
  },
152
151
  failed: {
153
152
  name: (swapDetails.status === SwapStatus.PendingRefund || swapDetails.status === SwapStatus.Refunded)
@@ -237,7 +236,7 @@ const Processing = ({ swapBasicData, swapDetails, quote, refuel }) => {
237
236
  let currentSteps = allSteps.filter((s) => s.status && s.status != ProgressStatus.Removed);
238
237
  let stepsProgressPercentage = currentSteps.filter(x => x.status == ProgressStatus.Complete).length / currentSteps.length * 100;
239
238
  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 &&
239
+ 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
240
  _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
241
  _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
242
  _jsx("div", { className: 'flex flex-col justify-center space-y-4', children: _jsx(Steps, { steps: currentSteps }) }), ([SwapStatus.Expired, SwapStatus.Cancelled, SwapStatus.UserTransferDelayed].includes(swapStatus)) &&
@@ -269,8 +268,8 @@ const getProgressStatuses = (swapDetails, refuel, inputTxStatusFromApi) => {
269
268
  subtitle = null;
270
269
  }
271
270
  let input_transfer = transactionStatusToProgressStatus(swapInputTxStatus) || '';
272
- let output_transfer = swapOutputTransaction?.transaction_hash ? ProgressStatus.Complete : inputIsCompleted ? ProgressStatus.Current : ProgressStatus.Upcoming;
273
- let refuel_transfer = swapRefuelTransaction?.transaction_hash ? ProgressStatus.Complete : !!refuel ? ProgressStatus.Upcoming : ProgressStatus.Removed;
271
+ let output_transfer = (swapOutputTransaction?.transaction_hash && swapOutputTransaction?.amount) ? ProgressStatus.Complete : inputIsCompleted ? ProgressStatus.Current : ProgressStatus.Upcoming;
272
+ let refuel_transfer = (swapRefuelTransaction?.transaction_hash && swapRefuelTransaction?.amount) ? ProgressStatus.Complete : !!refuel ? ProgressStatus.Upcoming : ProgressStatus.Removed;
274
273
  let refund_status = ProgressStatus.Removed;
275
274
  if (swapStatus === SwapStatus.PendingRefund || swapStatus === SwapStatus.Refunded) {
276
275
  // For refund cases: 1) Deposit Confirmed 2) Processing Failed 3) Refund Pending/Completed
@@ -7,7 +7,6 @@ import useSWR from 'swr';
7
7
  import { useInitialSettings } from "../../../../../context/settings";
8
8
  import { ImageWithFallback } from "../../../../../components/Common/ImageWithFallback";
9
9
  import NumberFlow from "@number-flow/react";
10
- import clsx from "clsx";
11
10
  import { PriceImpact } from "../../../../../components/Input/Amount/PriceImpact";
12
11
  const Summary = (props) => {
13
12
  const { swap, quote, receiveAmount } = props;
@@ -26,12 +25,12 @@ const Summary = (props) => {
26
25
  truncateDecimals(refuel.amount, nativeCurrency?.precision) : null;
27
26
  const refuelAmountInUsd = nativeCurrency && ((nativeCurrency?.price_in_usd || 1) * (Number(truncatedRefuelAmount) || 0)).toFixed(2);
28
27
  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 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", 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) ?
28
+ _jsxs("p", { className: "text-primary-text text-xl leading-6 font-normal whitespace-nowrap", children: [truncateDecimals(Number(requestedAmount), sourceCurrency.precision), " ", sourceCurrency.symbol] }), _jsx("p", { className: "text-secondary-text text-sm leading-5 flex font-medium justify-end", children: _jsx(NumberFlow, { value: Number(requestedAmountInUsd || 0), prefix: "$", 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 h-[44px]", children: [_jsx("p", { className: "text-primary-text text-xl font-normal 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 font-medium", children: [_jsx(PriceImpact, { className: "text-sm", quote: swapQuote, refuel: refuel }), _jsx(NumberFlow, { value: Number(receiveAmountInUsd || 0), prefix: "$", trend: 0 })] })] }))] }), (!!refuel != undefined && nativeCurrency) ?
30
29
  _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
30
  :
32
31
  _jsx(_Fragment, {})] }) }));
33
32
  };
34
33
  const RouteTokenPair = ({ route, token }) => {
35
- return (_jsxs("div", { className: "flex grow gap-4 text-left items-center md:text-base relative col-span-6 align-center", children: [_jsxs("div", { className: "inline-flex items-center relative shrink-0 mb-1.5", children: [_jsx(ImageWithFallback, { src: token.logo, alt: "Token Logo", height: "28", width: "28", loading: "eager", fetchPriority: "high", className: "rounded-full object-contain" }), _jsx(ImageWithFallback, { src: route.logo, alt: "Route Logo", height: "16", width: "16", loading: "eager", fetchPriority: "high", className: "absolute -right-1.5 -bottom-1.5 object-contain rounded-md border-1 border-secondary-300" })] }), _jsxs("div", { className: "flex flex-col font-medium text-primary-text overflow-hidden", children: [_jsx("span", { className: "leading-4 text-sm p-[1.75px]", children: token.symbol }), _jsx("div", { className: "flex items-center gap-1 leading-3 text-sm sm:text-base", children: _jsx("p", { className: "text-secondary-text text-sm truncate whitespace-nowrap p-[1.75px]", children: route.display_name }) })] })] }));
34
+ return (_jsxs("div", { className: "flex grow gap-4 text-left items-center md:text-base relative col-span-6 align-center", children: [_jsxs("div", { className: "inline-flex items-center relative shrink-0 h-8 w-8", children: [_jsx(ImageWithFallback, { src: token.logo, alt: "Token Logo", height: "28", width: "28", loading: "eager", fetchPriority: "high", className: "rounded-full object-contain" }), _jsx("div", { className: "absolute -right-0.5 -bottom-0.5 rounded border border-secondary-500 bg-secondary-400 overflow-hidden", children: _jsx(ImageWithFallback, { src: route.logo, alt: "Route Logo", height: "16", width: "16", loading: "eager", fetchPriority: "high", className: "object-contain" }) })] }), _jsxs("div", { className: "text-primary-text overflow-hidden", children: [_jsx("p", { className: "text-xl leading-6 font-normal", children: token.symbol }), _jsx("p", { className: "text-secondary-text text-sm truncate whitespace-nowrap font-medium leading-5", children: route.display_name })] })] }));
36
35
  };
37
36
  export default Summary;
@@ -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;
@@ -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
+ };
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useCallback, useState } from "react";
2
+ import { useCallback, useMemo, useState } from "react";
3
3
  import WalletIcon from "../../../../../../components/Icons/WalletIcon";
4
4
  import SubmitButton from "../../../../../../components/Buttons/submitButton";
5
5
  import useWallet from "../../../../../../hooks/useWallet";
@@ -8,15 +8,19 @@ import toast from "react-hot-toast";
8
8
  import { Loader2 } from "lucide-react";
9
9
  import WalletMessage from "../../messages/Message";
10
10
  import { useConnectModal } from "../../../../../../components/Wallet/WalletModal";
11
- import { useInitialSettings } from "../../../../../../context/settings";
11
+ import { useInitialSettings, useSettingsState } from "../../../../../../context/settings";
12
12
  import { useSwapTransactionStore } from "../../../../../../stores/swapTransactionStore";
13
- import { BackendTransactionStatus } from "../../../../../../lib/apiClients/layerSwapApiClient";
13
+ import LayerSwapApiClient, { BackendTransactionStatus } from "../../../../../../lib/apiClients/layerSwapApiClient";
14
14
  import sleep from "../../../../../../lib/wallets/utils/sleep";
15
15
  import { isDiffByPercent } from "../../../../../../components/utils/numbers";
16
- // import posthog from "posthog-js";
17
16
  import { useWalletWithdrawalState } from "../../../../../../context/withdrawalContext";
18
- import { useSelectedAccount } from "../../../../../../context/balanceAccounts";
19
- import { useSwapCreateCallback } from "../../../../../../context/callbackProvider";
17
+ import { useSelectedAccount } from "../../../../../../context/swapAccounts";
18
+ import { ErrorHandler } from "../../../../../../lib/ErrorHandler";
19
+ import { resolvePriceImpactValues } from "../../../../../../lib/fees";
20
+ import InfoIcon from "../../../../../../components/Icons/InfoIcon";
21
+ import { addressFormat } from "../../../../../../lib/address/formatter";
22
+ import { useBalance } from "../../../../../../lib/balances/useBalance";
23
+ import KnownInternalNames from "../../../../../../lib/knownIds";
20
24
  export const ConnectWalletButton = ({ ...props }) => {
21
25
  const { swapBasicData } = useSwapDataState();
22
26
  const { source_network } = swapBasicData || {};
@@ -83,20 +87,26 @@ export const ChangeNetworkButton = (props) => {
83
87
  export const ButtonWrapper = ({ ...props }) => {
84
88
  return _jsx(SubmitButton, { text_align: 'center', buttonStyle: 'filled', size: "medium", type: "button", className: "text-primary-text text-base", ...props, children: props.children });
85
89
  };
86
- export const SendTransactionButton = ({ error, onClick, swapData, refuel, ...props }) => {
87
- const [actionStateText, setActionStateText] = useState();
88
- const [loading, setLoading] = useState(false);
89
- const { quote, quoteIsLoading, quoteError } = useSwapDataState();
90
+ export const SendTransactionButton = ({ error, clearError, onClick, swapData: swapBasicData, refuel, ...props }) => {
91
+ const { quote, quoteIsLoading, quoteError, swapId, swapDetails, depositActionsResponse, refuel: refuelData } = useSwapDataState();
92
+ const { onWalletWithdrawalSuccess: onWalletWithdrawalSuccess, onCancelWithdrawal } = useWalletWithdrawalState();
90
93
  const { createSwap, setSwapId, setQuoteLoading } = useSwapDataUpdate();
91
94
  const { setSwapTransaction } = useSwapTransactionStore();
92
95
  const initialSettings = useInitialSettings();
93
- const triggerSwapCreateCallback = useSwapCreateCallback();
94
- const { onWalletWithdrawalSuccess: onWalletWithdrawalSuccess } = useWalletWithdrawalState();
95
- const selectedSourceAccount = useSelectedAccount("from", swapData.source_network?.name);
96
- const { wallets } = useWallet(swapData.source_network, 'withdrawal');
96
+ const layerswapApiClient = new LayerSwapApiClient();
97
+ const selectedSourceAccount = useSelectedAccount("from", swapBasicData.source_network?.name);
98
+ const { networks } = useSettingsState();
99
+ const networkWithTokens = swapBasicData.source_network && networks.find(n => n.name === swapBasicData.source_network?.name);
100
+ const { balances } = useBalance(selectedSourceAccount?.address, networkWithTokens);
101
+ const { wallets } = useWallet(swapBasicData.source_network, 'withdrawal');
102
+ const [actionStateText, setActionStateText] = useState();
103
+ const [loading, setLoading] = useState(false);
104
+ const [showCriticalMarketPriceImpactButtons, setShowCriticalMarketPriceImpactButtons] = useState(false);
105
+ const priceImpactValues = useMemo(() => quote ? resolvePriceImpactValues(quote, refuel ? refuelData : undefined) : undefined, [quote, refuel]);
106
+ const criticalMarketPriceImpact = useMemo(() => priceImpactValues?.criticalMarketPriceImpact, [priceImpactValues]);
97
107
  const handleClick = async () => {
98
108
  try {
99
- const selectedWallet = wallets.find(w => w.id === selectedSourceAccount?.id);
109
+ const selectedWallet = selectedSourceAccount && wallets.find(w => w.addresses.some(a => addressFormat(a, swapBasicData.source_network) === addressFormat(selectedSourceAccount?.address, swapBasicData.source_network)));
100
110
  if (!selectedSourceAccount) {
101
111
  throw new Error('Selected source account is undefined');
102
112
  }
@@ -104,71 +114,89 @@ export const SendTransactionButton = ({ error, onClick, swapData, refuel, ...pro
104
114
  throw new Error('Wallet is not active');
105
115
  }
106
116
  setLoading(true);
107
- setActionStateText("Preparing");
108
- setSwapId(undefined);
109
- const swapValues = {
110
- amount: swapData.requested_amount,
111
- from: swapData.source_network,
112
- to: swapData.destination_network,
113
- fromAsset: swapData.source_token,
114
- toAsset: swapData.destination_token,
115
- refuel: refuel,
116
- destination_address: swapData.destination_address,
117
- depositMethod: 'wallet',
118
- };
119
- const newSwapData = await createSwap(swapValues, initialSettings);
120
- const swapId = newSwapData?.swap?.id;
121
- if (!swapId) {
122
- throw new Error('Swap ID is undefined');
117
+ clearError?.();
118
+ let swapData = swapDetails;
119
+ let depositActions = depositActionsResponse;
120
+ if (!swapId || !swapDetails) {
121
+ setActionStateText("Preparing");
122
+ setSwapId(undefined);
123
+ const swapValues = {
124
+ amount: swapBasicData.requested_amount.toString(),
125
+ from: swapBasicData.source_network,
126
+ to: swapBasicData.destination_network,
127
+ fromAsset: swapBasicData.source_token,
128
+ toAsset: swapBasicData.destination_token,
129
+ refuel: refuel,
130
+ destination_address: swapBasicData.destination_address,
131
+ depositMethod: 'wallet',
132
+ };
133
+ const newSwapData = await createSwap(swapValues, initialSettings);
134
+ const newSwapId = newSwapData?.swap?.id;
135
+ if (!newSwapId) {
136
+ throw new Error('Swap ID is undefined');
137
+ }
138
+ setSwapId(newSwapId);
139
+ const priceImpactValues = newSwapData.quote ? resolvePriceImpactValues(newSwapData.quote, newSwapData.refuel) : undefined;
140
+ if (priceImpactValues?.criticalMarketPriceImpact) {
141
+ setShowCriticalMarketPriceImpactButtons(true);
142
+ return;
143
+ }
144
+ if (isDiffByPercent(quote?.receive_amount, newSwapData.quote.receive_amount, 2)) {
145
+ setActionStateText("Updating quotes");
146
+ setQuoteLoading(true);
147
+ await sleep(3500);
148
+ setQuoteLoading(false);
149
+ }
150
+ swapData = newSwapData.swap;
151
+ depositActions = newSwapData.deposit_actions;
123
152
  }
124
- if (isDiffByPercent(quote?.receive_amount, newSwapData.quote.receive_amount, 2)) {
125
- setActionStateText("Updating quotes");
126
- setQuoteLoading(true);
127
- await sleep(3500);
128
- setQuoteLoading(false);
129
- }
130
- setActionStateText("Opening Wallet");
131
- setSwapId(swapId);
132
- const depositAction = newSwapData?.deposit_actions && newSwapData?.deposit_actions[0];
133
- if (!depositAction) {
134
- throw new Error('No deposit action');
153
+ if (!depositActions?.length) {
154
+ throw new Error('No deposit actions');
135
155
  }
136
- if (!depositAction.call_data) {
137
- throw new Error('No deposit action call data');
156
+ if (!swapData) {
157
+ throw new Error('No swap data');
138
158
  }
139
- const transferProps = {
140
- network: swapData.source_network,
141
- token: swapData.source_token,
142
- selectedWallet: selectedWallet,
143
- amount: depositAction?.amount,
144
- callData: depositAction?.call_data,
145
- depositAddress: depositAction?.to_address,
146
- sequenceNumber: newSwapData.swap?.metadata.sequence_number,
147
- swapId: swapId,
148
- userDestinationAddress: newSwapData.swap?.destination_address
149
- };
159
+ const transferProps = resolveTransactionData(swapData, swapBasicData, depositActions, balances, selectedWallet);
160
+ setActionStateText("Opening Wallet");
150
161
  const hash = await onClick(transferProps);
151
162
  if (hash) {
152
163
  onWalletWithdrawalSuccess?.();
153
- setSwapTransaction(swapId, BackendTransactionStatus.Pending, hash);
154
- triggerSwapCreateCallback(newSwapData);
164
+ setSwapTransaction(swapData.id, BackendTransactionStatus.Pending, hash);
165
+ try {
166
+ await layerswapApiClient.SwapCatchup(swapData.id, hash);
167
+ }
168
+ catch (e) {
169
+ console.error('Error in SwapCatchup:', e);
170
+ const swapWithdrawalError = new Error(e);
171
+ swapWithdrawalError.name = `SwapCatchupError`;
172
+ swapWithdrawalError.cause = e;
173
+ ErrorHandler({
174
+ type: 'SwapWithdrawalError',
175
+ message: swapWithdrawalError.message,
176
+ name: swapWithdrawalError.name,
177
+ stack: swapWithdrawalError.stack,
178
+ cause: swapWithdrawalError.cause,
179
+ swapId: swapData.id,
180
+ transactionHash: hash,
181
+ fromAddress: selectedSourceAccount?.address,
182
+ toAddress: swapBasicData?.destination_address
183
+ });
184
+ }
155
185
  }
156
186
  }
157
187
  catch (e) {
158
188
  setSwapId(undefined);
159
- console.log('Error in SendTransactionButton:', e);
160
- const swapWithdrawalError = new Error(e);
161
- swapWithdrawalError.name = `SwapWithdrawalError`;
162
- swapWithdrawalError.cause = e;
163
- // posthog.capture('$exception', {
164
- // name: swapWithdrawalError.name,
165
- // cause: swapWithdrawalError.cause,
166
- // message: swapWithdrawalError.message,
167
- // $layerswap_exception_type: "Swap Withdrawal Error",
168
- // stack: swapWithdrawalError.stack,
169
- // where: 'TransactionError',
170
- // severity: 'error',
171
- // });
189
+ const error = e;
190
+ ErrorHandler({
191
+ type: 'SwapWithdrawalError',
192
+ message: error.message,
193
+ name: error.name,
194
+ stack: error.stack,
195
+ cause: error.cause,
196
+ swapId: swapId,
197
+ fromAddress: selectedSourceAccount?.address,
198
+ toAddress: swapBasicData?.destination_address
199
+ });
172
200
  }
173
201
  finally {
174
202
  setLoading(false);
@@ -176,5 +204,31 @@ export const SendTransactionButton = ({ error, onClick, swapData, refuel, ...pro
176
204
  };
177
205
  if (quoteIsLoading || loading)
178
206
  return (_jsx(ButtonWrapper, { ...props, isSubmitting: true, isDisabled: true, children: actionStateText || "Preparing" }));
179
- return (_jsx(ButtonWrapper, { ...props, isSubmitting: props.isSubmitting || loading || quoteIsLoading, onClick: handleClick, isDisabled: quoteIsLoading || !!quoteError, children: error ? 'Try again' : 'Swap now' }));
207
+ if (showCriticalMarketPriceImpactButtons) {
208
+ return (_jsxs(_Fragment, { children: [quote && priceImpactValues && _jsx("div", { className: "py-1", children: _jsxs("div", { className: "flex items-start gap-2.5", children: [_jsx("span", { className: "shrink-0", children: _jsx(InfoIcon, { className: "w-5 h-5 text-warning-foreground" }) }), _jsxs("div", { className: "flex flex-col gap-1.5 pr-4", children: [_jsx("p", { className: "text-primary-text font-semibold leading-4 text-base mt-0.5", children: "Critical receiving amount" }), _jsxs("p", { className: "text-priamry-text text-base font-normal leading-[18px]", children: [_jsx("span", { children: "By continuing, you agree to receive as low as " }), _jsxs("span", { className: "text-warning-foreground text-nowrap", children: [quote.min_receive_amount, " ", quote.destination_token?.symbol, " ($ ", priceImpactValues.minReceiveAmountUSD, ")"] })] })] })] }) }), _jsx(ButtonWrapper, { ...props, onClick: handleClick, buttonStyle: "secondary", size: "small", isSubmitting: false, isDisabled: false, children: "Continue anyway" }), _jsx(ButtonWrapper, { ...props, size: "small", onClick: () => onCancelWithdrawal?.(), isSubmitting: false, isDisabled: false, children: "Cancel & try another route" })] }));
209
+ }
210
+ return (_jsxs(_Fragment, { children: [!!(!swapId && criticalMarketPriceImpact && quote?.destination_token && priceImpactValues && !error) && _jsx("div", { className: "py-1", children: _jsxs("div", { className: "flex items-start gap-2.5", children: [_jsx("span", { className: "shrink-0", children: _jsx(InfoIcon, { className: "w-5 h-5 text-warning-foreground" }) }), _jsxs("div", { className: "flex flex-col gap-1.5 pr-4", children: [_jsx("p", { className: "text-primary-text font-medium leading-4 text-base mt-0.5", children: "Critical receiving amount" }), _jsxs("p", { className: "text-secondary-text text-sm leading-[18px]", children: [_jsx("span", { children: "The \u201Creceive at least\u201D amount is affected by high price impact. You will receive at least " }), _jsxs("span", { children: [quote.min_receive_amount, " ", quote.destination_token?.symbol, " ($ ", priceImpactValues.minReceiveAmountUSD, ") "] })] })] })] }) }), _jsx(ButtonWrapper, { ...props, isSubmitting: props.isSubmitting || loading || quoteIsLoading, onClick: handleClick, isDisabled: quoteIsLoading || !!quoteError, children: error ? 'Try again' : 'Swap now' })] }));
211
+ };
212
+ const resolveTransactionData = (swapDetails, swapBasicData, deposit_actions, balances, selectedWallet) => {
213
+ const depositAction = deposit_actions?.find(action => action.type === 'transfer'
214
+ || ExceptionNetworks.includes(swapBasicData.source_network?.name) && action.type === 'manual_transfer');
215
+ if (!depositAction) {
216
+ throw new Error('No deposit action found');
217
+ }
218
+ return {
219
+ amount: depositAction.amount,
220
+ callData: depositAction.call_data,
221
+ depositAddress: depositAction.to_address,
222
+ sequenceNumber: swapDetails.metadata.sequence_number,
223
+ swapId: swapDetails.id,
224
+ userDestinationAddress: swapBasicData.destination_address,
225
+ balances: balances,
226
+ network: swapBasicData.source_network,
227
+ token: swapBasicData.source_token,
228
+ selectedWallet: selectedWallet,
229
+ };
180
230
  };
231
+ const ExceptionNetworks = [
232
+ KnownInternalNames.Networks.ImmutableXMainnet,
233
+ KnownInternalNames.Networks.ImmutableXSepolia
234
+ ];