@rango-dev/widget-embedded 0.17.1-next.1 → 0.17.1-next.11

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 (325) hide show
  1. package/dist/QueueManager.d.ts +5 -2
  2. package/dist/QueueManager.d.ts.map +1 -1
  3. package/dist/components/AppRouter.d.ts +0 -2
  4. package/dist/components/AppRouter.d.ts.map +1 -1
  5. package/dist/components/AppRoutes.d.ts +1 -6
  6. package/dist/components/AppRoutes.d.ts.map +1 -1
  7. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -3
  8. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  9. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
  10. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  11. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +1 -3
  12. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
  13. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  14. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +1 -4
  15. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
  16. package/dist/components/NoResult/NoResult.d.ts +4 -0
  17. package/dist/components/NoResult/NoResult.d.ts.map +1 -0
  18. package/dist/components/NoResult/NoResult.helpers.d.ts +4 -0
  19. package/dist/components/NoResult/NoResult.helpers.d.ts.map +1 -0
  20. package/dist/components/{NoRoutes/NoRoutes.styles.d.ts → NoResult/NoResult.styles.d.ts} +1 -1
  21. package/dist/components/{NoRoutes/NoRoutes.styles.d.ts.map → NoResult/NoResult.styles.d.ts.map} +1 -1
  22. package/dist/components/{NoRoutes/NoRoutes.types.d.ts → NoResult/NoResult.types.d.ts} +3 -3
  23. package/dist/components/NoResult/NoResult.types.d.ts.map +1 -0
  24. package/dist/components/NoResult/index.d.ts +2 -0
  25. package/dist/components/NoResult/index.d.ts.map +1 -0
  26. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  27. package/dist/components/Quote/Quote.d.ts +4 -0
  28. package/dist/components/Quote/Quote.d.ts.map +1 -0
  29. package/dist/components/Quote/Quote.styles.d.ts +1429 -0
  30. package/dist/components/Quote/Quote.styles.d.ts.map +1 -0
  31. package/dist/components/Quote/Quote.types.d.ts +22 -0
  32. package/dist/components/Quote/Quote.types.d.ts.map +1 -0
  33. package/dist/components/Quote/QuoteSkeleton.d.ts +4 -0
  34. package/dist/components/Quote/QuoteSkeleton.d.ts.map +1 -0
  35. package/dist/components/Quote/QuoteSkeleton.styles.d.ts +319 -0
  36. package/dist/components/Quote/QuoteSkeleton.styles.d.ts.map +1 -0
  37. package/dist/components/Quote/QuoteSkeleton.types.d.ts +6 -0
  38. package/dist/components/Quote/QuoteSkeleton.types.d.ts.map +1 -0
  39. package/dist/components/Quote/QuoteSummary.d.ts +11 -0
  40. package/dist/components/Quote/QuoteSummary.d.ts.map +1 -0
  41. package/dist/components/Quote/QuoteSummary.styles.d.ts +158 -0
  42. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -0
  43. package/dist/components/Quote/index.d.ts +4 -0
  44. package/dist/components/Quote/index.d.ts.map +1 -0
  45. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +11 -0
  46. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +1 -0
  47. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +4 -0
  48. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +1 -0
  49. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +4 -0
  50. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -0
  51. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +9 -0
  52. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -0
  53. package/dist/components/{RouteErrors/RouteErrors.styles.d.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts} +1 -1
  54. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -0
  55. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +22 -0
  56. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -0
  57. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +11 -0
  58. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +1 -0
  59. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +11 -0
  60. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +1 -0
  61. package/dist/components/QuoteWarningsAndErrors/index.d.ts +2 -0
  62. package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +1 -0
  63. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  64. package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
  65. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
  66. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  67. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  68. package/dist/components/UpdateUrl.d.ts +1 -6
  69. package/dist/components/UpdateUrl.d.ts.map +1 -1
  70. package/dist/components/WidgetEvents.d.ts.map +1 -1
  71. package/dist/constants/errors.d.ts +4 -4
  72. package/dist/constants/errors.d.ts.map +1 -1
  73. package/dist/constants/messages.d.ts +1 -1
  74. package/dist/constants/searchParams.d.ts +2 -1
  75. package/dist/constants/searchParams.d.ts.map +1 -1
  76. package/dist/constants/warnings.d.ts +2 -2
  77. package/dist/constants/warnings.d.ts.map +1 -1
  78. package/dist/containers/App/App.d.ts +3 -0
  79. package/dist/containers/App/App.d.ts.map +1 -0
  80. package/dist/containers/App/App.styles.d.ts +158 -0
  81. package/dist/containers/App/App.styles.d.ts.map +1 -0
  82. package/dist/containers/App/index.d.ts +2 -0
  83. package/dist/containers/App/index.d.ts.map +1 -0
  84. package/dist/containers/QuoteInfo/QuoteInfo.d.ts +4 -0
  85. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -0
  86. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +472 -0
  87. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -0
  88. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +17 -0
  89. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -0
  90. package/dist/containers/QuoteInfo/index.d.ts +2 -0
  91. package/dist/containers/QuoteInfo/index.d.ts.map +1 -0
  92. package/dist/containers/Wallets/Wallets.d.ts +6 -0
  93. package/dist/containers/Wallets/Wallets.d.ts.map +1 -0
  94. package/dist/containers/Wallets/Wallets.types.d.ts +11 -0
  95. package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -0
  96. package/dist/containers/Wallets/index.d.ts +2 -0
  97. package/dist/containers/Wallets/index.d.ts.map +1 -0
  98. package/dist/containers/Widget/Widget.d.ts +5 -0
  99. package/dist/containers/Widget/Widget.d.ts.map +1 -0
  100. package/dist/containers/Widget/Widget.types.d.ts +5 -0
  101. package/dist/containers/Widget/Widget.types.d.ts.map +1 -0
  102. package/dist/containers/Widget/index.d.ts +3 -0
  103. package/dist/containers/Widget/index.d.ts.map +1 -0
  104. package/dist/containers/WidgetInfo/WidgetInfo.d.ts +6 -0
  105. package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -0
  106. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +5 -0
  107. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -0
  108. package/dist/containers/WidgetInfo/index.d.ts +2 -0
  109. package/dist/containers/WidgetInfo/index.d.ts.map +1 -0
  110. package/dist/containers/WidgetProvider/WidgetProvider.d.ts +5 -0
  111. package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -0
  112. package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +7 -0
  113. package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +1 -0
  114. package/dist/containers/WidgetProvider/index.d.ts +2 -0
  115. package/dist/containers/WidgetProvider/index.d.ts.map +1 -0
  116. package/dist/hooks/useConfirmSwap/index.d.ts +2 -0
  117. package/dist/hooks/useConfirmSwap/index.d.ts.map +1 -0
  118. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +3 -0
  119. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -0
  120. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +16 -0
  121. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -0
  122. package/dist/hooks/{useConfirmSwap.d.ts → useConfirmSwap/useConfirmSwap.types.d.ts} +5 -7
  123. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -0
  124. package/dist/hooks/{useFetchBestRoute.d.ts → useFetchQuote.d.ts} +3 -3
  125. package/dist/hooks/useFetchQuote.d.ts.map +1 -0
  126. package/dist/hooks/useForceAutoConnect.d.ts +2 -0
  127. package/dist/hooks/useForceAutoConnect.d.ts.map +1 -0
  128. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
  129. package/dist/hooks/useSwapInput.d.ts +4 -2
  130. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  131. package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
  132. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  133. package/dist/hooks/useWalletList.d.ts.map +1 -1
  134. package/dist/index.d.ts +11 -4
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +1 -1
  137. package/dist/index.js.map +4 -4
  138. package/dist/pages/ConfirmSwapPage.d.ts +1 -6
  139. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  140. package/dist/pages/Home.d.ts.map +1 -1
  141. package/dist/pages/LiquiditySourcePage.d.ts +1 -2
  142. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  143. package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
  144. package/dist/pages/SettingsPage.d.ts +1 -6
  145. package/dist/pages/SettingsPage.d.ts.map +1 -1
  146. package/dist/pages/WalletsPage.d.ts +1 -8
  147. package/dist/pages/WalletsPage.d.ts.map +1 -1
  148. package/dist/store/AppStore.d.ts +11 -0
  149. package/dist/store/AppStore.d.ts.map +1 -0
  150. package/dist/store/app.d.ts +5 -23
  151. package/dist/store/app.d.ts.map +1 -1
  152. package/dist/store/{bestRoute.d.ts → quote.d.ts} +39 -27
  153. package/dist/store/quote.d.ts.map +1 -0
  154. package/dist/store/settings.d.ts +3 -2
  155. package/dist/store/settings.d.ts.map +1 -1
  156. package/dist/store/slices/config.d.ts +3 -2
  157. package/dist/store/slices/config.d.ts.map +1 -1
  158. package/dist/store/slices/data.d.ts +3 -0
  159. package/dist/store/slices/data.d.ts.map +1 -1
  160. package/dist/store/wallets.d.ts +5 -4
  161. package/dist/store/wallets.d.ts.map +1 -1
  162. package/dist/types/config.d.ts +5 -5
  163. package/dist/types/config.d.ts.map +1 -1
  164. package/dist/types/index.d.ts +1 -1
  165. package/dist/types/index.d.ts.map +1 -1
  166. package/dist/types/quote.d.ts +82 -0
  167. package/dist/types/quote.d.ts.map +1 -0
  168. package/dist/utils/colors.d.ts.map +1 -1
  169. package/dist/utils/numbers.d.ts +1 -1
  170. package/dist/utils/numbers.d.ts.map +1 -1
  171. package/dist/utils/{routing.d.ts → quote.d.ts} +16 -12
  172. package/dist/utils/quote.d.ts.map +1 -0
  173. package/dist/utils/settings.d.ts +3 -2
  174. package/dist/utils/settings.d.ts.map +1 -1
  175. package/dist/utils/swap.d.ts +25 -22
  176. package/dist/utils/swap.d.ts.map +1 -1
  177. package/dist/utils/wallets.d.ts +2 -2
  178. package/dist/utils/wallets.d.ts.map +1 -1
  179. package/package.json +6 -6
  180. package/src/QueueManager.tsx +17 -17
  181. package/src/components/AppRouter.tsx +6 -5
  182. package/src/components/AppRoutes.tsx +6 -39
  183. package/src/components/BlockchainList/BlockchainList.tsx +4 -4
  184. package/src/components/BlockchainsSection/BlockchainsSection.tsx +7 -7
  185. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +2 -64
  186. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +28 -40
  187. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +1 -3
  188. package/src/components/ConfirmWalletsModal/WalletList.tsx +6 -5
  189. package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
  190. package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +3 -3
  191. package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +6 -6
  192. package/src/components/{NoRoutes/NoRoutes.helper.ts → NoResult/NoResult.helpers.ts} +16 -9
  193. package/src/components/{NoRoutes/NoRoutes.styles.ts → NoResult/NoResult.styles.ts} +2 -0
  194. package/src/components/{NoRoutes/NoRoutes.tsx → NoResult/NoResult.tsx} +10 -12
  195. package/src/components/{NoRoutes/NoRoutes.types.ts → NoResult/NoResult.types.ts} +3 -2
  196. package/src/components/NoResult/index.ts +1 -0
  197. package/src/components/NotificationContent/NotificationContent.tsx +3 -2
  198. package/src/components/Quote/Quote.styles.ts +219 -0
  199. package/src/components/Quote/Quote.tsx +345 -0
  200. package/src/components/Quote/Quote.types.ts +16 -0
  201. package/src/components/Quote/QuoteSkeleton.styles.ts +110 -0
  202. package/src/components/Quote/QuoteSkeleton.tsx +108 -0
  203. package/src/components/Quote/QuoteSkeleton.types.ts +5 -0
  204. package/src/components/Quote/QuoteSummary.styles.ts +15 -0
  205. package/src/components/Quote/QuoteSummary.tsx +46 -0
  206. package/src/components/Quote/index.ts +3 -0
  207. package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +107 -0
  208. package/src/components/{RouteErrors/RouteErrorsModalItem.tsx → QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx} +4 -4
  209. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +67 -0
  210. package/src/components/{RouteErrors/RouteErrors.styles.ts → QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts} +8 -1
  211. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +103 -0
  212. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +24 -0
  213. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +77 -0
  214. package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +38 -0
  215. package/src/components/QuoteWarningsAndErrors/index.ts +1 -0
  216. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
  217. package/src/components/SwapDetails/SwapDetails.tsx +18 -22
  218. package/src/components/SwapsGroup/SwapsGroup.styles.ts +8 -1
  219. package/src/components/SwapsGroup/SwapsGroup.tsx +0 -2
  220. package/src/components/SwitchFromAndTo.tsx +2 -2
  221. package/src/components/TokenList/TokenList.styles.ts +14 -2
  222. package/src/components/TokenList/TokenList.tsx +6 -7
  223. package/src/components/UpdateUrl.tsx +36 -26
  224. package/src/components/WidgetEvents.tsx +4 -2
  225. package/src/constants/errors.ts +8 -10
  226. package/src/constants/messages.ts +1 -1
  227. package/src/constants/searchParams.ts +1 -0
  228. package/src/constants/warnings.ts +7 -7
  229. package/src/containers/App/App.styles.ts +18 -0
  230. package/src/containers/App/App.tsx +65 -0
  231. package/src/containers/App/index.ts +1 -0
  232. package/src/containers/QuoteInfo/QuoteInfo.styles.ts +15 -0
  233. package/src/containers/QuoteInfo/QuoteInfo.tsx +97 -0
  234. package/src/containers/QuoteInfo/QuoteInfo.types.ts +17 -0
  235. package/src/containers/QuoteInfo/index.ts +1 -0
  236. package/src/{Wallets.tsx → containers/Wallets/Wallets.tsx} +40 -32
  237. package/src/containers/Wallets/Wallets.types.ts +12 -0
  238. package/src/containers/Wallets/index.ts +1 -0
  239. package/src/containers/Widget/Widget.tsx +19 -0
  240. package/src/containers/Widget/Widget.types.ts +5 -0
  241. package/src/containers/Widget/index.ts +2 -0
  242. package/src/containers/WidgetInfo/WidgetInfo.tsx +36 -0
  243. package/src/containers/WidgetInfo/WidgetInfo.types.ts +5 -0
  244. package/src/containers/WidgetInfo/index.ts +1 -0
  245. package/src/containers/WidgetProvider/WidgetProvider.tsx +19 -0
  246. package/src/containers/WidgetProvider/WidgetProvider.types.ts +7 -0
  247. package/src/containers/WidgetProvider/index.ts +1 -0
  248. package/src/hooks/useConfirmSwap/index.ts +1 -0
  249. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +168 -0
  250. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +136 -0
  251. package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +19 -0
  252. package/src/hooks/{useFetchBestRoute.ts → useFetchQuote.ts} +3 -3
  253. package/src/hooks/useForceAutoConnect.ts +27 -0
  254. package/src/hooks/useNavigateBack.ts +3 -3
  255. package/src/hooks/useSwapInput.ts +58 -23
  256. package/src/hooks/useSyncStoresWithConfig.ts +22 -19
  257. package/src/hooks/useWalletList.ts +3 -5
  258. package/src/index.ts +12 -3
  259. package/src/pages/ConfirmSwapPage.tsx +58 -235
  260. package/src/pages/HistoryPage.tsx +1 -1
  261. package/src/pages/Home.tsx +58 -247
  262. package/src/pages/LanguagePage.tsx +1 -1
  263. package/src/pages/LiquiditySourcePage.tsx +23 -32
  264. package/src/pages/SelectBlockchainPage.tsx +6 -7
  265. package/src/pages/SelectSwapItemsPage.tsx +5 -5
  266. package/src/pages/SettingsPage.tsx +9 -13
  267. package/src/pages/SwapDetailsPage.tsx +3 -3
  268. package/src/pages/ThemePage.tsx +1 -1
  269. package/src/pages/WalletsPage.tsx +5 -12
  270. package/src/store/AppStore.tsx +35 -0
  271. package/src/store/app.ts +18 -6
  272. package/src/store/{bestRoute.ts → quote.ts} +68 -60
  273. package/src/store/settings.ts +7 -4
  274. package/src/store/slices/config.ts +25 -15
  275. package/src/store/slices/data.ts +64 -29
  276. package/src/store/wallets.ts +11 -8
  277. package/src/types/config.ts +5 -5
  278. package/src/types/index.ts +1 -1
  279. package/src/types/quote.ts +107 -0
  280. package/src/utils/colors.ts +2 -1
  281. package/src/utils/numbers.ts +1 -1
  282. package/src/utils/quote.ts +338 -0
  283. package/src/utils/settings.ts +8 -7
  284. package/src/utils/swap.ts +113 -85
  285. package/src/utils/wallets.ts +29 -17
  286. package/dist/Wallets.d.ts +0 -17
  287. package/dist/Wallets.d.ts.map +0 -1
  288. package/dist/Widget.d.ts +0 -9
  289. package/dist/Widget.d.ts.map +0 -1
  290. package/dist/components/NoRoutes/NoRoutes.d.ts +0 -4
  291. package/dist/components/NoRoutes/NoRoutes.d.ts.map +0 -1
  292. package/dist/components/NoRoutes/NoRoutes.helper.d.ts +0 -3
  293. package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +0 -1
  294. package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +0 -1
  295. package/dist/components/NoRoutes/index.d.ts +0 -2
  296. package/dist/components/NoRoutes/index.d.ts.map +0 -1
  297. package/dist/components/RouteErrors/RouteErrors.d.ts +0 -4
  298. package/dist/components/RouteErrors/RouteErrors.d.ts.map +0 -1
  299. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +0 -1
  300. package/dist/components/RouteErrors/RouteErrors.types.d.ts +0 -24
  301. package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +0 -1
  302. package/dist/components/RouteErrors/RouteErrorsModal.d.ts +0 -4
  303. package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +0 -1
  304. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +0 -4
  305. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +0 -1
  306. package/dist/components/RouteErrors/index.d.ts +0 -2
  307. package/dist/components/RouteErrors/index.d.ts.map +0 -1
  308. package/dist/hooks/useConfirmSwap.d.ts.map +0 -1
  309. package/dist/hooks/useFetchBestRoute.d.ts.map +0 -1
  310. package/dist/store/bestRoute.d.ts.map +0 -1
  311. package/dist/store/meta.d.ts +0 -23
  312. package/dist/store/meta.d.ts.map +0 -1
  313. package/dist/types/routing.d.ts +0 -65
  314. package/dist/types/routing.d.ts.map +0 -1
  315. package/dist/utils/routing.d.ts.map +0 -1
  316. package/src/Widget.tsx +0 -119
  317. package/src/components/NoRoutes/index.ts +0 -1
  318. package/src/components/RouteErrors/RouteErrors.tsx +0 -79
  319. package/src/components/RouteErrors/RouteErrors.types.ts +0 -29
  320. package/src/components/RouteErrors/RouteErrorsModal.tsx +0 -129
  321. package/src/components/RouteErrors/index.ts +0 -1
  322. package/src/hooks/useConfirmSwap.ts +0 -303
  323. package/src/store/meta.ts +0 -39
  324. package/src/types/routing.ts +0 -77
  325. package/src/utils/routing.ts +0 -321
@@ -0,0 +1 @@
1
+ export { WidgetWallets, WidgetContext } from './Wallets';
@@ -0,0 +1,19 @@
1
+ import type { WidgetProps } from './Widget.types';
2
+ import type { PropsWithChildren } from 'react';
3
+
4
+ import React from 'react';
5
+
6
+ import { DEFAULT_CONFIG } from '../../store/slices/config';
7
+ import { Main } from '../App';
8
+ import { WidgetProvider } from '../WidgetProvider';
9
+
10
+ export function Widget(props: PropsWithChildren<WidgetProps>) {
11
+ if (!props.config?.externalWallets) {
12
+ return (
13
+ <WidgetProvider config={props.config ?? DEFAULT_CONFIG}>
14
+ <Main />
15
+ </WidgetProvider>
16
+ );
17
+ }
18
+ return <Main />;
19
+ }
@@ -0,0 +1,5 @@
1
+ import type { WidgetConfig } from '../../types';
2
+
3
+ export type WidgetProps = {
4
+ config?: WidgetConfig;
5
+ };
@@ -0,0 +1,2 @@
1
+ export { Widget } from './Widget';
2
+ export type { WidgetProps } from './Widget.types';
@@ -0,0 +1,36 @@
1
+ import type { WidgetInfoContextInterface } from './WidgetInfo.types';
2
+
3
+ import { useManager } from '@rango-dev/queue-manager-react';
4
+ import React, { createContext, useContext, useMemo } from 'react';
5
+
6
+ import { getPendingSwaps } from '../../utils/queue';
7
+
8
+ export const WidgetInfoContext = createContext<
9
+ WidgetInfoContextInterface | undefined
10
+ >(undefined);
11
+
12
+ export function WidgetInfo(props: React.PropsWithChildren) {
13
+ const { manager } = useManager();
14
+ const swaps = getPendingSwaps(manager);
15
+ const value = useMemo(() => {
16
+ return {
17
+ swaps,
18
+ };
19
+ }, [manager, swaps]);
20
+
21
+ return (
22
+ <WidgetInfoContext.Provider value={value}>
23
+ {props.children}
24
+ </WidgetInfoContext.Provider>
25
+ );
26
+ }
27
+
28
+ export function useWidget(): WidgetInfoContextInterface {
29
+ const context = useContext(WidgetInfoContext);
30
+ if (!context) {
31
+ throw new Error(
32
+ 'useWidget can only be used within the WidgetProvider component'
33
+ );
34
+ }
35
+ return context;
36
+ }
@@ -0,0 +1,5 @@
1
+ import type { PendingSwapWithQueueID } from '@rango-dev/queue-manager-rango-preset';
2
+
3
+ export interface WidgetInfoContextInterface {
4
+ swaps?: PendingSwapWithQueueID[];
5
+ }
@@ -0,0 +1 @@
1
+ export { WidgetInfo, useWidget } from './WidgetInfo';
@@ -0,0 +1,19 @@
1
+ import type { PropTypes } from './WidgetProvider.types';
2
+ import type { PropsWithChildren } from 'react';
3
+
4
+ import React from 'react';
5
+
6
+ import QueueManager from '../../QueueManager';
7
+ import { WidgetWallets } from '../Wallets';
8
+ import { WidgetInfo } from '../WidgetInfo';
9
+
10
+ export function WidgetProvider(props: PropsWithChildren<PropTypes>) {
11
+ const { onUpdateState, config } = props;
12
+ return (
13
+ <WidgetWallets config={config} onUpdateState={onUpdateState}>
14
+ <QueueManager apiKey={config.apiKey}>
15
+ <WidgetInfo>{props.children}</WidgetInfo>
16
+ </QueueManager>
17
+ </WidgetWallets>
18
+ );
19
+ }
@@ -0,0 +1,7 @@
1
+ import type { WidgetConfig } from '../../types';
2
+ import type { EventHandler } from '@rango-dev/wallets-react';
3
+
4
+ export type PropTypes = {
5
+ onUpdateState?: EventHandler;
6
+ config: WidgetConfig;
7
+ };
@@ -0,0 +1 @@
1
+ export { WidgetProvider } from './WidgetProvider';
@@ -0,0 +1 @@
1
+ export { useConfirmSwap } from './useConfirmSwap';
@@ -0,0 +1,168 @@
1
+ import type { ConfirmSwapFetchResult } from './useConfirmSwap.types';
2
+ import type { ConfirmSwapWarnings, Wallet } from '../../types';
3
+ import type { BestRouteResponse, Token } from 'rango-sdk';
4
+
5
+ import { errorMessages } from '../../constants/errors';
6
+ import { QuoteErrorType, QuoteUpdateType } from '../../types';
7
+ import { numberToString } from '../../utils/numbers';
8
+ import {
9
+ generateQuoteWarnings,
10
+ isNumberOfSwapsChanged,
11
+ isQuoteChanged,
12
+ isQuoteInternalCoinsUpdated,
13
+ isQuoteSwappersUpdated,
14
+ } from '../../utils/quote';
15
+ import {
16
+ checkSlippageErrors,
17
+ getBalanceWarnings,
18
+ getLimitErrorMessage,
19
+ getMinRequiredSlippage,
20
+ getPercentageChange,
21
+ getQuoteOutputAmount,
22
+ hasLimitError,
23
+ isOutputAmountChangedALot,
24
+ } from '../../utils/swap';
25
+
26
+ /**
27
+ * A request can be successful but in body of the response, it can be some case which is considered as failed.
28
+ */
29
+ export function throwErrorIfResponseIsNotValid(response: BestRouteResponse) {
30
+ if (!response.result) {
31
+ throw new Error(errorMessages().noResultError.title, {
32
+ cause: {
33
+ type: QuoteErrorType.NO_RESULT,
34
+ diagnosisMessage: response.diagnosisMessages?.[0],
35
+ },
36
+ });
37
+ }
38
+ const limitError = hasLimitError(response);
39
+ if (limitError) {
40
+ const { swap, recommendation, fromAmountRangeError } =
41
+ getLimitErrorMessage(response);
42
+
43
+ throw new Error('bridge limit error', {
44
+ cause: {
45
+ type: QuoteErrorType.BRIDGE_LIMIT,
46
+ swap: swap,
47
+ recommendation,
48
+ fromAmountRangeError,
49
+ },
50
+ });
51
+ }
52
+
53
+ const recommendedSlippages = checkSlippageErrors(response);
54
+
55
+ if (recommendedSlippages) {
56
+ const minRequiredSlippage = getMinRequiredSlippage(response);
57
+ throw new Error('', {
58
+ cause: {
59
+ type: QuoteErrorType.INSUFFICIENT_SLIPPAGE,
60
+ recommendedSlippages,
61
+ minRequiredSlippage,
62
+ },
63
+ });
64
+ }
65
+
66
+ return response;
67
+ }
68
+
69
+ export function generateWarnings(
70
+ previousQuote: BestRouteResponse,
71
+ currentQuote: BestRouteResponse,
72
+ params: {
73
+ fromToken: Token;
74
+ toToken: Token;
75
+ tokens: Token[];
76
+ selectedWallets: Wallet[];
77
+ userSlippage: number;
78
+ }
79
+ ): ConfirmSwapWarnings {
80
+ const quoteChanged = isQuoteChanged(previousQuote, currentQuote);
81
+ const output: ConfirmSwapWarnings = {
82
+ quote: null,
83
+ quoteUpdate: null,
84
+ balance: null,
85
+ };
86
+
87
+ const quoteWarning = generateQuoteWarnings(currentQuote, {
88
+ fromToken: params.fromToken,
89
+ toToken: params.toToken,
90
+ tokens: params.tokens,
91
+ userSlippage: params.userSlippage,
92
+ });
93
+
94
+ if (quoteWarning) {
95
+ output.quote = quoteWarning;
96
+ }
97
+
98
+ if (quoteChanged) {
99
+ if (isOutputAmountChangedALot(previousQuote, currentQuote)) {
100
+ output.quoteUpdate = {
101
+ type: QuoteUpdateType.QUOTE_AND_OUTPUT_AMOUNT_UPDATED,
102
+ newOutputAmount: numberToString(getQuoteOutputAmount(currentQuote)),
103
+ percentageChange: numberToString(
104
+ getPercentageChange(
105
+ getQuoteOutputAmount(previousQuote) ?? '',
106
+ getQuoteOutputAmount(currentQuote) ?? ''
107
+ ),
108
+ null,
109
+ 2
110
+ ),
111
+ };
112
+ } else if (isNumberOfSwapsChanged(previousQuote, currentQuote)) {
113
+ output.quoteUpdate = {
114
+ type: QuoteUpdateType.QUOTE_UPDATED,
115
+ };
116
+ } else if (isQuoteSwappersUpdated(previousQuote, currentQuote)) {
117
+ output.quoteUpdate = {
118
+ type: QuoteUpdateType.QUOTE_SWAPPERS_UPDATED,
119
+ };
120
+ } else if (isQuoteInternalCoinsUpdated(previousQuote, currentQuote)) {
121
+ output.quoteUpdate = {
122
+ type: QuoteUpdateType.QUOTE_COINS_UPDATED,
123
+ };
124
+ }
125
+ }
126
+
127
+ const balanceWarnings = getBalanceWarnings(
128
+ currentQuote,
129
+ params.selectedWallets
130
+ );
131
+ const enoughBalance = balanceWarnings.length === 0;
132
+
133
+ if (!enoughBalance) {
134
+ output.balance = {
135
+ messages: balanceWarnings,
136
+ };
137
+ }
138
+
139
+ return output;
140
+ }
141
+
142
+ export function handleQuoteErrors(error: any): ConfirmSwapFetchResult {
143
+ if (error?.code === 'ERR_CANCELED') {
144
+ return {
145
+ swap: null,
146
+ error: {
147
+ type: QuoteErrorType.REQUEST_CANCELED,
148
+ },
149
+ warnings: null,
150
+ };
151
+ }
152
+
153
+ if (error.cause) {
154
+ return {
155
+ swap: null,
156
+ error: error.cause,
157
+ warnings: null,
158
+ };
159
+ }
160
+
161
+ return {
162
+ swap: null,
163
+ error: {
164
+ type: QuoteErrorType.REQUEST_FAILED,
165
+ },
166
+ warnings: null,
167
+ };
168
+ }
@@ -0,0 +1,136 @@
1
+ import type { ConfirmSwap, Params } from './useConfirmSwap.types';
2
+ import type { PendingSwapSettings } from '../../types';
3
+ import type { BestRouteResponse } from 'rango-sdk';
4
+
5
+ import { calculatePendingSwap } from '@rango-dev/queue-manager-rango-preset';
6
+ import { useEffect } from 'react';
7
+
8
+ import { useAppStore } from '../../store/AppStore';
9
+ import { useQuoteStore } from '../../store/quote';
10
+ import { useSettingsStore } from '../../store/settings';
11
+ import { useWalletsStore } from '../../store/wallets';
12
+ import { QuoteErrorType } from '../../types';
13
+ import { createQuoteRequestBody, getWalletsForNewSwap } from '../../utils/swap';
14
+ import { useFetchQuote } from '../useFetchQuote';
15
+
16
+ import {
17
+ generateWarnings,
18
+ handleQuoteErrors,
19
+ throwErrorIfResponseIsNotValid,
20
+ } from './useConfirmSwap.helpers';
21
+
22
+ export function useConfirmSwap(): ConfirmSwap {
23
+ const {
24
+ fromToken,
25
+ toToken,
26
+ inputAmount,
27
+ setQuote,
28
+ resetQuote,
29
+ quote: initialQuote,
30
+ customDestination: customDestinationFromStore,
31
+ setQuoteWarningsConfirmed,
32
+ } = useQuoteStore();
33
+
34
+ const {
35
+ slippage,
36
+ customSlippage,
37
+ affiliatePercent,
38
+ affiliateRef,
39
+ affiliateWallets,
40
+ disabledLiquiditySources,
41
+ } = useSettingsStore();
42
+ const { connectedWallets } = useWalletsStore();
43
+ const blockchains = useAppStore().blockchains();
44
+ const tokens = useAppStore().tokens();
45
+
46
+ const userSlippage = customSlippage || slippage;
47
+
48
+ const { fetch: fetchQuote, cancelFetch, loading } = useFetchQuote();
49
+
50
+ useEffect(() => cancelFetch, []);
51
+
52
+ const fetch: ConfirmSwap['fetch'] = async (params: Params) => {
53
+ const selectedWallets = params.selectedWallets;
54
+ const customDestination =
55
+ params?.customDestination ?? customDestinationFromStore;
56
+
57
+ if (!fromToken || !toToken || !inputAmount || !initialQuote) {
58
+ return {
59
+ quote: null,
60
+ swap: null,
61
+ error: null,
62
+ warnings: null,
63
+ };
64
+ }
65
+
66
+ const requestBody = createQuoteRequestBody({
67
+ fromToken,
68
+ toToken,
69
+ inputAmount,
70
+ wallets: connectedWallets,
71
+ selectedWallets,
72
+ disabledLiquiditySources,
73
+ slippage: userSlippage,
74
+ affiliateRef,
75
+ affiliatePercent,
76
+ affiliateWallets,
77
+ initialQuote: initialQuote,
78
+ destination: customDestination,
79
+ });
80
+
81
+ let currentQuote: BestRouteResponse;
82
+ try {
83
+ currentQuote = await fetchQuote(requestBody).then((response) =>
84
+ throwErrorIfResponseIsNotValid(response)
85
+ );
86
+ setQuote(currentQuote);
87
+ } catch (error: any) {
88
+ const confirmSwapResult = handleQuoteErrors(error);
89
+ if (
90
+ confirmSwapResult.error?.type === QuoteErrorType.NO_RESULT ||
91
+ confirmSwapResult.error?.type === QuoteErrorType.REQUEST_FAILED
92
+ ) {
93
+ resetQuote();
94
+ }
95
+ return confirmSwapResult;
96
+ }
97
+
98
+ const swapSettings: PendingSwapSettings = {
99
+ slippage: userSlippage.toString(),
100
+ disabledSwappersGroups: disabledLiquiditySources,
101
+ };
102
+ const swap = calculatePendingSwap(
103
+ inputAmount.toString(),
104
+ currentQuote,
105
+ getWalletsForNewSwap(selectedWallets),
106
+ swapSettings,
107
+ false,
108
+ { blockchains, tokens }
109
+ );
110
+
111
+ const confirmSwapWarnings = generateWarnings(initialQuote, currentQuote, {
112
+ fromToken,
113
+ toToken,
114
+ tokens: tokens,
115
+ selectedWallets,
116
+ userSlippage,
117
+ });
118
+
119
+ if (confirmSwapWarnings.quoteUpdate) {
120
+ setQuoteWarningsConfirmed(false);
121
+ }
122
+
123
+ return {
124
+ quote: currentQuote,
125
+ swap,
126
+ error: null,
127
+ warnings: confirmSwapWarnings,
128
+ };
129
+ };
130
+
131
+ return {
132
+ loading,
133
+ fetch,
134
+ cancelFetch,
135
+ };
136
+ }
@@ -0,0 +1,19 @@
1
+ import type { ConfirmSwapWarnings, QuoteError, Wallet } from '../../types';
2
+ import type { PendingSwap } from 'rango-types/lib';
3
+
4
+ export type ConfirmSwapFetchResult = {
5
+ swap: PendingSwap | null;
6
+ error: QuoteError | null;
7
+ warnings: ConfirmSwapWarnings | null;
8
+ };
9
+
10
+ export type ConfirmSwap = {
11
+ loading: boolean;
12
+ fetch: (params: Params) => Promise<ConfirmSwapFetchResult>;
13
+ cancelFetch: () => void;
14
+ };
15
+
16
+ export type Params = {
17
+ selectedWallets: Wallet[];
18
+ customDestination?: string;
19
+ };
@@ -4,18 +4,18 @@ import { useRef, useState } from 'react';
4
4
 
5
5
  import { httpService } from '../services/httpService';
6
6
 
7
- interface UseFetchBestRoute {
7
+ interface UseFetchQuote {
8
8
  fetch: (requestBody: BestRouteRequest) => Promise<BestRouteResponse>;
9
9
  cancelFetch: () => void;
10
10
  loading: boolean;
11
11
  }
12
12
 
13
- export function useFetchBestRoute(): UseFetchBestRoute {
13
+ export function useFetchQuote(): UseFetchQuote {
14
14
  const [loading, setLoading] = useState(false);
15
15
  const abortController = useRef<AbortController | null>(null);
16
16
  const cancel = () => abortController.current?.abort();
17
17
 
18
- const fetch: UseFetchBestRoute['fetch'] = async (requestBody) => {
18
+ const fetch: UseFetchQuote['fetch'] = async (requestBody) => {
19
19
  cancel();
20
20
  abortController.current = new AbortController();
21
21
 
@@ -0,0 +1,27 @@
1
+ import { useWallets } from '@rango-dev/wallets-react';
2
+ import { useEffect, useRef } from 'react';
3
+
4
+ import { SearchParams } from '../constants/searchParams';
5
+ import { useAppStore } from '../store/AppStore';
6
+
7
+ export function useForceAutoConnect(): void {
8
+ const { connect, state } = useWallets();
9
+ const initiated = useRef<{ [key: string]: boolean }>({});
10
+ const { fetchStatus } = useAppStore();
11
+ const walletType =
12
+ new URLSearchParams(location.search).get(SearchParams.AUTO_CONNECT) || '';
13
+ const walletState = state(walletType);
14
+
15
+ useEffect(() => {
16
+ const shouldTryConnect =
17
+ fetchStatus === 'success' &&
18
+ walletType &&
19
+ walletState.installed &&
20
+ !walletState.connecting &&
21
+ !walletState.connected;
22
+ if (shouldTryConnect && !initiated.current[walletType]) {
23
+ initiated.current[walletType] = true;
24
+ void connect(walletType);
25
+ }
26
+ }, [walletState, fetchStatus]);
27
+ }
@@ -1,12 +1,12 @@
1
1
  import { useInRouterContext, useNavigate } from 'react-router-dom';
2
2
 
3
3
  import { navigationRoutes } from '../constants/navigationRoutes';
4
- import { useBestRouteStore } from '../store/bestRoute';
4
+ import { useQuoteStore } from '../store/quote';
5
5
 
6
6
  export function useNavigateBack() {
7
7
  const isRouterInContext = useInRouterContext();
8
8
  const navigate = useNavigate();
9
- const routeWalletsConfirmed = useBestRouteStore.use.routeWalletsConfirmed();
9
+ const quoteWalletsConfirmed = useQuoteStore.use.quoteWalletsConfirmed();
10
10
 
11
11
  navigationRoutes;
12
12
 
@@ -26,7 +26,7 @@ export function useNavigateBack() {
26
26
  [navigationRoutes.settings, navigationRoutes.wallets].includes(
27
27
  currentRoute
28
28
  ) &&
29
- routeWalletsConfirmed
29
+ quoteWalletsConfirmed
30
30
  ) {
31
31
  return navigate('/' + navigationRoutes.confirmSwap, { replace: true });
32
32
  }
@@ -1,37 +1,48 @@
1
+ import type { QuoteError, QuoteWarning } from '../types';
2
+
1
3
  import { useEffect, useRef, useState } from 'react';
2
4
 
3
- import { useBestRouteStore } from '../store/bestRoute';
5
+ import { useAppStore } from '../store/AppStore';
6
+ import { useQuoteStore } from '../store/quote';
4
7
  import { useSettingsStore } from '../store/settings';
8
+ import { QuoteErrorType } from '../types';
5
9
  import { debounce } from '../utils/common';
6
10
  import { isPositiveNumber } from '../utils/numbers';
7
- import { createBestRouteRequestBody } from '../utils/swap';
11
+ import { generateQuoteWarnings } from '../utils/quote';
12
+ import { createQuoteRequestBody } from '../utils/swap';
8
13
  import { tokensAreEqual } from '../utils/wallets';
9
14
 
10
- import { useFetchBestRoute } from './useFetchBestRoute';
15
+ import {
16
+ handleQuoteErrors,
17
+ throwErrorIfResponseIsNotValid,
18
+ } from './useConfirmSwap/useConfirmSwap.helpers';
19
+ import { useFetchQuote } from './useFetchQuote';
11
20
 
12
21
  const DEBOUNCE_DELAY = 600;
13
22
 
14
23
  type UseSwapInput = {
15
24
  fetch: () => void;
16
25
  loading: boolean;
17
- error: string;
26
+ error: QuoteError | null;
27
+ warning: QuoteWarning | null;
18
28
  };
19
29
 
20
30
  /**
21
- * a hook for fetching best route based on from and to input values
31
+ * a hook for fetching quote based on from and to input values
22
32
  * we use this hook in home page
23
33
  */
24
34
  export function useSwapInput(): UseSwapInput {
25
- const { fetch: fetchBestRoute, cancelFetch } = useFetchBestRoute();
26
- const [loading, setLoading] = useState(false);
35
+ const { fetch: fetchQuote, cancelFetch } = useFetchQuote();
36
+ const { liquiditySources, enableNewLiquiditySources } = useAppStore().config;
37
+ const tokens = useAppStore().tokens();
27
38
  const {
28
39
  fromToken,
29
40
  toToken,
30
41
  inputAmount,
31
42
  inputUsdValue,
32
- resetRoute,
33
- setRoute,
34
- } = useBestRouteStore();
43
+ resetQuote,
44
+ setQuote,
45
+ } = useQuoteStore();
35
46
  const {
36
47
  slippage,
37
48
  customSlippage,
@@ -40,7 +51,9 @@ export function useSwapInput(): UseSwapInput {
40
51
  affiliateWallets,
41
52
  disabledLiquiditySources,
42
53
  } = useSettingsStore();
43
- const [error, setError] = useState('');
54
+ const [loading, setLoading] = useState(false);
55
+ const [error, setError] = useState<QuoteError | null>(null);
56
+ const [warning, setWarning] = useState<QuoteWarning | null>(null);
44
57
  const prevDisabledLiquiditySources = useRef(disabledLiquiditySources);
45
58
  const userSlippage = customSlippage ?? slippage;
46
59
  const hasTokensValue = !fromToken || !toToken;
@@ -49,31 +62,53 @@ export function useSwapInput(): UseSwapInput {
49
62
  tokensAreEqual(fromToken, toToken) ||
50
63
  !isPositiveNumber(inputAmount);
51
64
 
65
+ const resetState = (loading: boolean) => {
66
+ setLoading(loading);
67
+ setError(null);
68
+ setWarning(null);
69
+ };
70
+
52
71
  const fetch: UseSwapInput['fetch'] = () => {
53
72
  if (!loading) {
54
- setLoading(true);
73
+ resetState(true);
55
74
  }
56
75
  if (!shouldSkipRequest) {
57
- resetRoute();
58
- const requestBody = createBestRouteRequestBody({
76
+ resetQuote();
77
+ const requestBody = createQuoteRequestBody({
59
78
  fromToken,
60
79
  toToken,
61
80
  inputAmount,
81
+ liquiditySources,
82
+ excludeLiquiditySources: enableNewLiquiditySources,
62
83
  disabledLiquiditySources,
63
84
  slippage: userSlippage,
64
85
  affiliateRef,
65
86
  affiliatePercent,
66
87
  affiliateWallets,
67
88
  });
68
- fetchBestRoute(requestBody)
89
+ fetchQuote(requestBody)
69
90
  .then((res) => {
70
91
  setLoading(false);
71
- setRoute(res);
92
+ setQuote(res);
93
+ throwErrorIfResponseIsNotValid(res);
94
+ const quoteWarning = generateQuoteWarnings(res, {
95
+ fromToken,
96
+ toToken,
97
+ userSlippage,
98
+ tokens,
99
+ });
100
+ setWarning(quoteWarning);
72
101
  })
73
102
  .catch((error) => {
74
- resetRoute();
75
- if (error?.code !== 'ERR_CANCELED') {
76
- setError(error.message);
103
+ const { error: quoteError } = handleQuoteErrors(error);
104
+ if (
105
+ quoteError?.type === QuoteErrorType.NO_RESULT ||
106
+ quoteError?.type === QuoteErrorType.REQUEST_FAILED
107
+ ) {
108
+ resetQuote();
109
+ }
110
+ if (quoteError?.type !== QuoteErrorType.REQUEST_CANCELED) {
111
+ setError(quoteError);
77
112
  setLoading(false);
78
113
  }
79
114
  });
@@ -88,15 +123,15 @@ export function useSwapInput(): UseSwapInput {
88
123
 
89
124
  useEffect(() => {
90
125
  if (!isPositiveNumber(inputAmount) || inputUsdValue?.eq(0)) {
91
- setLoading(false);
126
+ resetState(false);
92
127
  cancelFetch();
93
128
  return;
94
129
  }
95
130
  if (shouldSkipRequest) {
96
131
  return;
97
132
  }
98
- resetRoute();
99
- setLoading(true);
133
+ resetQuote();
134
+ resetState(true);
100
135
  debouncedFetch();
101
136
  return cancelFetch;
102
137
  }, [inputAmount, shouldSkipRequest]);
@@ -112,5 +147,5 @@ export function useSwapInput(): UseSwapInput {
112
147
  return cancelFetch;
113
148
  }, [disabledLiquiditySources.length]);
114
149
 
115
- return { fetch, loading, error };
150
+ return { fetch, loading, error, warning };
116
151
  }