@rango-dev/widget-embedded 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (476) hide show
  1. package/CHANGELOG.md +1 -113
  2. package/dist/QueueManager.d.ts +2 -5
  3. package/dist/QueueManager.d.ts.map +1 -1
  4. package/dist/Wallets.d.ts +17 -0
  5. package/dist/Wallets.d.ts.map +1 -0
  6. package/dist/Widget.d.ts +9 -0
  7. package/dist/Widget.d.ts.map +1 -0
  8. package/dist/components/AppRouter.d.ts +2 -0
  9. package/dist/components/AppRouter.d.ts.map +1 -1
  10. package/dist/components/AppRoutes.d.ts +6 -1
  11. package/dist/components/AppRoutes.d.ts.map +1 -1
  12. package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
  13. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +1 -1
  14. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
  15. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +3 -1
  16. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  17. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +62 -691
  18. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  19. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  20. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +3 -1
  21. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
  22. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  23. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +4 -1
  24. package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
  25. package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
  26. package/dist/components/Layout/Layout.d.ts.map +1 -1
  27. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  28. package/dist/components/Layout/Layout.types.d.ts +2 -2
  29. package/dist/components/Layout/Layout.types.d.ts.map +1 -1
  30. package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts +4 -0
  31. package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +1 -0
  32. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -1
  33. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +0 -1727
  34. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
  35. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +4 -0
  36. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +1 -0
  37. package/dist/components/NoRoutes/NoRoutes.d.ts +4 -0
  38. package/dist/components/NoRoutes/NoRoutes.d.ts.map +1 -0
  39. package/dist/components/NoRoutes/NoRoutes.helper.d.ts +3 -0
  40. package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -0
  41. package/dist/components/{NoResult/NoResult.styles.d.ts → NoRoutes/NoRoutes.styles.d.ts} +1 -1
  42. package/dist/components/{NoResult/NoResult.styles.d.ts.map → NoRoutes/NoRoutes.styles.d.ts.map} +1 -1
  43. package/dist/components/{NoResult/NoResult.types.d.ts → NoRoutes/NoRoutes.types.d.ts} +3 -3
  44. package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +1 -0
  45. package/dist/components/NoRoutes/index.d.ts +2 -0
  46. package/dist/components/NoRoutes/index.d.ts.map +1 -0
  47. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  48. package/dist/components/RouteErrors/RouteErrors.d.ts +4 -0
  49. package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -0
  50. package/dist/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts → RouteErrors/RouteErrors.styles.d.ts} +1 -1
  51. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -0
  52. package/dist/components/RouteErrors/RouteErrors.types.d.ts +24 -0
  53. package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -0
  54. package/dist/components/RouteErrors/RouteErrorsModal.d.ts +4 -0
  55. package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -0
  56. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +4 -0
  57. package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +1 -0
  58. package/dist/components/RouteErrors/index.d.ts +2 -0
  59. package/dist/components/RouteErrors/index.d.ts.map +1 -0
  60. package/dist/components/Slippage/Slippage.d.ts.map +1 -1
  61. package/dist/components/Slippage/Slippage.styles.d.ts +0 -158
  62. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  63. package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
  64. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  65. package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +1 -1
  66. package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
  67. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +0 -628
  68. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  69. package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
  70. package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
  71. package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts +1 -1
  72. package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts.map +1 -1
  73. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +1 -1
  74. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
  75. package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
  76. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +0 -157
  77. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
  78. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  79. package/dist/components/TokenList/TokenList.helpers.d.ts +2 -2
  80. package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
  81. package/dist/components/TokenList/TokenList.styles.d.ts +1 -1100
  82. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  83. package/dist/components/TokenList/TokenList.types.d.ts +9 -4
  84. package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
  85. package/dist/components/TokenList/index.d.ts +1 -0
  86. package/dist/components/TokenList/index.d.ts.map +1 -1
  87. package/dist/components/UpdateUrl.d.ts +6 -1
  88. package/dist/components/UpdateUrl.d.ts.map +1 -1
  89. package/dist/components/WidgetEvents.d.ts.map +1 -1
  90. package/dist/constants/errors.d.ts +4 -4
  91. package/dist/constants/errors.d.ts.map +1 -1
  92. package/dist/constants/index.d.ts +0 -1
  93. package/dist/constants/index.d.ts.map +1 -1
  94. package/dist/constants/messages.d.ts +1 -1
  95. package/dist/constants/navigationRoutes.d.ts +2 -1
  96. package/dist/constants/navigationRoutes.d.ts.map +1 -1
  97. package/dist/constants/searchParams.d.ts +1 -2
  98. package/dist/constants/searchParams.d.ts.map +1 -1
  99. package/dist/constants/warnings.d.ts +2 -2
  100. package/dist/constants/warnings.d.ts.map +1 -1
  101. package/dist/hooks/{useConfirmSwap/useConfirmSwap.types.d.ts → useConfirmSwap.d.ts} +7 -5
  102. package/dist/hooks/useConfirmSwap.d.ts.map +1 -0
  103. package/dist/hooks/{useFetchQuote.d.ts → useFetchBestRoute.d.ts} +3 -3
  104. package/dist/hooks/useFetchBestRoute.d.ts.map +1 -0
  105. package/dist/hooks/useLanguage.d.ts +1 -1
  106. package/dist/hooks/useLanguage.d.ts.map +1 -1
  107. package/dist/hooks/useNavigateBack.d.ts +3 -1
  108. package/dist/hooks/useNavigateBack.d.ts.map +1 -1
  109. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts +1 -1
  110. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts +2 -2
  111. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts.map +1 -1
  112. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +7 -5
  113. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -1
  114. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +0 -1
  115. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
  116. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +1 -5
  117. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -1
  118. package/dist/hooks/useSwapInput.d.ts +2 -4
  119. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  120. package/dist/hooks/useSyncStoresWithConfig.d.ts +2 -1
  121. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  122. package/dist/hooks/useTheme.d.ts +1 -1
  123. package/dist/hooks/useTheme.d.ts.map +1 -1
  124. package/dist/hooks/useWalletList.d.ts.map +1 -1
  125. package/dist/index.d.ts +8 -20
  126. package/dist/index.d.ts.map +1 -1
  127. package/dist/index.js +1 -1
  128. package/dist/index.js.map +4 -4
  129. package/dist/pages/ConfirmSwapPage.d.ts +6 -1
  130. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  131. package/dist/pages/HistoryPage.d.ts.map +1 -1
  132. package/dist/pages/Home.d.ts.map +1 -1
  133. package/dist/pages/LanguagePage.d.ts.map +1 -1
  134. package/dist/pages/LiquiditySourcePage.d.ts +2 -1
  135. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  136. package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
  137. package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
  138. package/dist/pages/SettingsPage.d.ts +6 -1
  139. package/dist/pages/SettingsPage.d.ts.map +1 -1
  140. package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
  141. package/dist/pages/ThemePage.d.ts.map +1 -1
  142. package/dist/pages/WalletsPage.d.ts +8 -1
  143. package/dist/pages/WalletsPage.d.ts.map +1 -1
  144. package/dist/store/app.d.ts +22 -41
  145. package/dist/store/app.d.ts.map +1 -1
  146. package/dist/store/bestRoute.d.ts +77 -0
  147. package/dist/store/bestRoute.d.ts.map +1 -0
  148. package/dist/store/meta.d.ts +23 -0
  149. package/dist/store/meta.d.ts.map +1 -0
  150. package/dist/store/notification.d.ts +3 -4
  151. package/dist/store/notification.d.ts.map +1 -1
  152. package/dist/store/settings.d.ts +81 -0
  153. package/dist/store/settings.d.ts.map +1 -0
  154. package/dist/store/slices/config.d.ts +2 -3
  155. package/dist/store/slices/config.d.ts.map +1 -1
  156. package/dist/store/slices/data.d.ts +2 -5
  157. package/dist/store/slices/data.d.ts.map +1 -1
  158. package/dist/store/ui.d.ts +1 -2
  159. package/dist/store/ui.d.ts.map +1 -1
  160. package/dist/store/wallets.d.ts +9 -14
  161. package/dist/store/wallets.d.ts.map +1 -1
  162. package/dist/types/config.d.ts +8 -41
  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/routing.d.ts +65 -0
  167. package/dist/types/routing.d.ts.map +1 -0
  168. package/dist/types/swap.d.ts +14 -4
  169. package/dist/types/swap.d.ts.map +1 -1
  170. package/dist/types/wallets.d.ts +1 -15
  171. package/dist/types/wallets.d.ts.map +1 -1
  172. package/dist/utils/colors.d.ts.map +1 -1
  173. package/dist/utils/configs.d.ts +0 -1
  174. package/dist/utils/configs.d.ts.map +1 -1
  175. package/dist/utils/meta.d.ts +1 -2
  176. package/dist/utils/meta.d.ts.map +1 -1
  177. package/dist/utils/numbers.d.ts +1 -1
  178. package/dist/utils/numbers.d.ts.map +1 -1
  179. package/dist/utils/providers.d.ts +2 -2
  180. package/dist/utils/providers.d.ts.map +1 -1
  181. package/dist/utils/queue.d.ts +2 -2
  182. package/dist/utils/queue.d.ts.map +1 -1
  183. package/dist/utils/routing.d.ts +28 -0
  184. package/dist/utils/routing.d.ts.map +1 -0
  185. package/dist/utils/settings.d.ts +2 -6
  186. package/dist/utils/settings.d.ts.map +1 -1
  187. package/dist/utils/swap.d.ts +24 -35
  188. package/dist/utils/swap.d.ts.map +1 -1
  189. package/dist/utils/time.d.ts +1 -1
  190. package/dist/utils/time.d.ts.map +1 -1
  191. package/dist/utils/wallets.d.ts +10 -9
  192. package/dist/utils/wallets.d.ts.map +1 -1
  193. package/package.json +10 -12
  194. package/src/QueueManager.tsx +17 -18
  195. package/src/{containers/Wallets/Wallets.tsx → Wallets.tsx} +34 -48
  196. package/src/Widget.tsx +119 -0
  197. package/src/components/AppRouter.tsx +32 -8
  198. package/src/components/AppRoutes.tsx +69 -57
  199. package/src/components/BlockchainList/BlockchainList.styles.ts +2 -2
  200. package/src/components/BlockchainList/BlockchainList.tsx +4 -4
  201. package/src/components/BlockchainsSection/BlockchainsSection.styles.ts +1 -1
  202. package/src/components/BlockchainsSection/BlockchainsSection.tsx +17 -26
  203. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +64 -2
  204. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +10 -29
  205. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +47 -43
  206. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +3 -1
  207. package/src/components/ConfirmWalletsModal/WalletList.tsx +8 -9
  208. package/src/components/ConfirmWalletsModal/WalletList.type.ts +4 -1
  209. package/src/components/HeaderButtons/HomeButtons.tsx +18 -28
  210. package/src/components/Layout/Layout.styles.ts +0 -2
  211. package/src/components/Layout/Layout.tsx +7 -20
  212. package/src/components/Layout/Layout.types.ts +2 -2
  213. package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +41 -0
  214. package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +61 -65
  215. package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +34 -28
  216. package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +3 -0
  217. package/src/components/{NoResult/NoResult.helpers.ts → NoRoutes/NoRoutes.helper.ts} +16 -23
  218. package/src/components/{NoResult/NoResult.styles.ts → NoRoutes/NoRoutes.styles.ts} +0 -2
  219. package/src/components/{NoResult/NoResult.tsx → NoRoutes/NoRoutes.tsx} +17 -12
  220. package/src/components/{NoResult/NoResult.types.ts → NoRoutes/NoRoutes.types.ts} +2 -3
  221. package/src/components/NoRoutes/index.ts +1 -0
  222. package/src/components/NotificationContent/NotificationContent.tsx +3 -5
  223. package/src/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts → RouteErrors/RouteErrors.styles.ts} +1 -8
  224. package/src/components/RouteErrors/RouteErrors.tsx +79 -0
  225. package/src/components/RouteErrors/RouteErrors.types.ts +29 -0
  226. package/src/components/RouteErrors/RouteErrorsModal.tsx +129 -0
  227. package/src/components/{QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx → RouteErrors/RouteErrorsModalItem.tsx} +4 -4
  228. package/src/components/RouteErrors/index.ts +1 -0
  229. package/src/components/Slippage/Slippage.styles.ts +5 -15
  230. package/src/components/Slippage/Slippage.tsx +10 -11
  231. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +8 -5
  232. package/src/components/SwapDetails/SwapDetails.helpers.tsx +1 -1
  233. package/src/components/SwapDetails/SwapDetails.styles.ts +33 -36
  234. package/src/components/SwapDetails/SwapDetails.tsx +56 -41
  235. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.tsx +1 -1
  236. package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +3 -4
  237. package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
  238. package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +8 -14
  239. package/src/components/SwapDetailsModal/SwapDetailsModal.helpers.tsx +1 -1
  240. package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +1 -1
  241. package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +1 -1
  242. package/src/components/SwapsGroup/SwapsGroup.styles.ts +1 -10
  243. package/src/components/SwapsGroup/SwapsGroup.tsx +5 -3
  244. package/src/components/SwitchFromAndTo.tsx +2 -2
  245. package/src/components/TokenList/TokenList.helpers.ts +2 -2
  246. package/src/components/TokenList/TokenList.styles.ts +38 -74
  247. package/src/components/TokenList/TokenList.tsx +26 -35
  248. package/src/components/TokenList/TokenList.types.ts +10 -4
  249. package/src/components/TokenList/index.ts +1 -0
  250. package/src/components/UpdateUrl.tsx +30 -35
  251. package/src/components/WidgetEvents.tsx +2 -4
  252. package/src/constants/errors.ts +15 -17
  253. package/src/constants/index.ts +0 -1
  254. package/src/constants/messages.ts +1 -1
  255. package/src/constants/navigationRoutes.ts +8 -7
  256. package/src/constants/searchParams.ts +0 -1
  257. package/src/constants/warnings.ts +7 -7
  258. package/src/hooks/useConfirmSwap.ts +303 -0
  259. package/src/hooks/{useFetchQuote.ts → useFetchBestRoute.ts} +3 -3
  260. package/src/hooks/useLanguage.ts +5 -4
  261. package/src/hooks/useNavigateBack.ts +52 -3
  262. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
  263. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +7 -37
  264. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +0 -60
  265. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +3 -78
  266. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +6 -15
  267. package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +1 -6
  268. package/src/hooks/useSwapInput.ts +48 -141
  269. package/src/hooks/useSyncStoresWithConfig.ts +24 -40
  270. package/src/hooks/useTheme.ts +5 -4
  271. package/src/hooks/useWalletList.ts +5 -3
  272. package/src/index.ts +5 -53
  273. package/src/pages/ConfirmSwapPage.tsx +266 -117
  274. package/src/pages/HistoryPage.tsx +7 -2
  275. package/src/pages/Home.tsx +303 -88
  276. package/src/pages/LanguagePage.tsx +5 -0
  277. package/src/pages/LiquiditySourcePage.tsx +37 -24
  278. package/src/pages/SelectBlockchainPage.tsx +24 -31
  279. package/src/pages/SelectSwapItemsPage.tsx +31 -18
  280. package/src/pages/SettingsPage.tsx +27 -32
  281. package/src/pages/SwapDetailsPage.tsx +7 -6
  282. package/src/pages/ThemePage.tsx +7 -2
  283. package/src/pages/WalletsPage.tsx +19 -9
  284. package/src/services/httpService.ts +1 -1
  285. package/src/store/app.ts +6 -44
  286. package/src/store/{quote.ts → bestRoute.ts} +64 -71
  287. package/src/store/meta.ts +39 -0
  288. package/src/store/settings.ts +158 -0
  289. package/src/store/slices/config.ts +15 -26
  290. package/src/store/slices/data.ts +35 -74
  291. package/src/store/wallets.ts +37 -68
  292. package/src/types/config.ts +8 -53
  293. package/src/types/index.ts +1 -1
  294. package/src/types/routing.ts +77 -0
  295. package/src/types/swap.ts +13 -4
  296. package/src/types/wallets.ts +1 -18
  297. package/src/utils/colors.ts +1 -2
  298. package/src/utils/configs.ts +1 -2
  299. package/src/utils/date.ts +1 -1
  300. package/src/utils/meta.ts +1 -8
  301. package/src/utils/numbers.ts +1 -1
  302. package/src/utils/providers.ts +5 -8
  303. package/src/utils/queue.ts +2 -2
  304. package/src/utils/routing.ts +321 -0
  305. package/src/utils/settings.ts +10 -17
  306. package/src/utils/swap.ts +120 -154
  307. package/src/utils/time.ts +1 -1
  308. package/src/utils/wallets.ts +161 -156
  309. package/dist/components/NoResult/NoResult.d.ts +0 -4
  310. package/dist/components/NoResult/NoResult.d.ts.map +0 -1
  311. package/dist/components/NoResult/NoResult.helpers.d.ts +0 -4
  312. package/dist/components/NoResult/NoResult.helpers.d.ts.map +0 -1
  313. package/dist/components/NoResult/NoResult.types.d.ts.map +0 -1
  314. package/dist/components/NoResult/index.d.ts +0 -2
  315. package/dist/components/NoResult/index.d.ts.map +0 -1
  316. package/dist/components/Quote/Quote.d.ts +0 -4
  317. package/dist/components/Quote/Quote.d.ts.map +0 -1
  318. package/dist/components/Quote/Quote.styles.d.ts +0 -2217
  319. package/dist/components/Quote/Quote.styles.d.ts.map +0 -1
  320. package/dist/components/Quote/Quote.types.d.ts +0 -21
  321. package/dist/components/Quote/Quote.types.d.ts.map +0 -1
  322. package/dist/components/Quote/QuoteSummary.d.ts +0 -11
  323. package/dist/components/Quote/QuoteSummary.d.ts.map +0 -1
  324. package/dist/components/Quote/QuoteSummary.styles.d.ts +0 -315
  325. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +0 -1
  326. package/dist/components/Quote/index.d.ts +0 -3
  327. package/dist/components/Quote/index.d.ts.map +0 -1
  328. package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts +0 -4
  329. package/dist/components/QuoteSkeleton/QuoteSkeleton.d.ts.map +0 -1
  330. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +0 -633
  331. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +0 -1
  332. package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts +0 -6
  333. package/dist/components/QuoteSkeleton/QuoteSkeleton.types.d.ts.map +0 -1
  334. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts +0 -4
  335. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.d.ts.map +0 -1
  336. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +0 -1571
  337. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +0 -1
  338. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts +0 -6
  339. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.types.d.ts.map +0 -1
  340. package/dist/components/QuoteSkeleton/StepSkeleton.d.ts +0 -4
  341. package/dist/components/QuoteSkeleton/StepSkeleton.d.ts.map +0 -1
  342. package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +0 -786
  343. package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +0 -1
  344. package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts +0 -4
  345. package/dist/components/QuoteSkeleton/StepSkeleton.types.d.ts.map +0 -1
  346. package/dist/components/QuoteSkeleton/index.d.ts +0 -4
  347. package/dist/components/QuoteSkeleton/index.d.ts.map +0 -1
  348. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +0 -11
  349. package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +0 -1
  350. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +0 -4
  351. package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +0 -1
  352. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +0 -4
  353. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +0 -1
  354. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +0 -9
  355. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +0 -1
  356. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +0 -1
  357. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -23
  358. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +0 -1
  359. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +0 -11
  360. package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +0 -1
  361. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +0 -11
  362. package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +0 -1
  363. package/dist/components/QuoteWarningsAndErrors/index.d.ts +0 -2
  364. package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +0 -1
  365. package/dist/containers/App/App.d.ts +0 -3
  366. package/dist/containers/App/App.d.ts.map +0 -1
  367. package/dist/containers/App/App.styles.d.ts +0 -158
  368. package/dist/containers/App/App.styles.d.ts.map +0 -1
  369. package/dist/containers/App/index.d.ts +0 -2
  370. package/dist/containers/App/index.d.ts.map +0 -1
  371. package/dist/containers/QuoteInfo/QuoteInfo.d.ts +0 -4
  372. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +0 -1
  373. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +0 -788
  374. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +0 -1
  375. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -20
  376. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +0 -1
  377. package/dist/containers/QuoteInfo/index.d.ts +0 -2
  378. package/dist/containers/QuoteInfo/index.d.ts.map +0 -1
  379. package/dist/containers/Wallets/Wallets.d.ts +0 -6
  380. package/dist/containers/Wallets/Wallets.d.ts.map +0 -1
  381. package/dist/containers/Wallets/Wallets.types.d.ts +0 -11
  382. package/dist/containers/Wallets/Wallets.types.d.ts.map +0 -1
  383. package/dist/containers/Wallets/index.d.ts +0 -2
  384. package/dist/containers/Wallets/index.d.ts.map +0 -1
  385. package/dist/containers/Widget/Widget.d.ts +0 -5
  386. package/dist/containers/Widget/Widget.d.ts.map +0 -1
  387. package/dist/containers/Widget/Widget.types.d.ts +0 -5
  388. package/dist/containers/Widget/Widget.types.d.ts.map +0 -1
  389. package/dist/containers/Widget/index.d.ts +0 -3
  390. package/dist/containers/Widget/index.d.ts.map +0 -1
  391. package/dist/containers/WidgetInfo/WidgetInfo.d.ts +0 -6
  392. package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +0 -1
  393. package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +0 -20
  394. package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +0 -1
  395. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +0 -21
  396. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +0 -1
  397. package/dist/containers/WidgetInfo/index.d.ts +0 -2
  398. package/dist/containers/WidgetInfo/index.d.ts.map +0 -1
  399. package/dist/containers/WidgetProvider/WidgetProvider.d.ts +0 -5
  400. package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +0 -1
  401. package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +0 -7
  402. package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +0 -1
  403. package/dist/containers/WidgetProvider/index.d.ts +0 -2
  404. package/dist/containers/WidgetProvider/index.d.ts.map +0 -1
  405. package/dist/hooks/useConfirmSwap/index.d.ts +0 -2
  406. package/dist/hooks/useConfirmSwap/index.d.ts.map +0 -1
  407. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +0 -3
  408. package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +0 -1
  409. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +0 -19
  410. package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +0 -1
  411. package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +0 -1
  412. package/dist/hooks/useFetchQuote.d.ts.map +0 -1
  413. package/dist/hooks/useForceAutoConnect.d.ts +0 -2
  414. package/dist/hooks/useForceAutoConnect.d.ts.map +0 -1
  415. package/dist/store/AppStore.d.ts +0 -47
  416. package/dist/store/AppStore.d.ts.map +0 -1
  417. package/dist/store/quote.d.ts +0 -89
  418. package/dist/store/quote.d.ts.map +0 -1
  419. package/dist/store/slices/settings.d.ts +0 -39
  420. package/dist/store/slices/settings.d.ts.map +0 -1
  421. package/dist/types/quote.d.ts +0 -82
  422. package/dist/types/quote.d.ts.map +0 -1
  423. package/dist/utils/quote.d.ts +0 -32
  424. package/dist/utils/quote.d.ts.map +0 -1
  425. package/src/components/NoResult/index.ts +0 -1
  426. package/src/components/Quote/Quote.styles.ts +0 -249
  427. package/src/components/Quote/Quote.tsx +0 -414
  428. package/src/components/Quote/Quote.types.ts +0 -15
  429. package/src/components/Quote/QuoteSummary.styles.ts +0 -16
  430. package/src/components/Quote/QuoteSummary.tsx +0 -46
  431. package/src/components/Quote/index.ts +0 -2
  432. package/src/components/QuoteSkeleton/QuoteSkeleton.styles.ts +0 -42
  433. package/src/components/QuoteSkeleton/QuoteSkeleton.tsx +0 -30
  434. package/src/components/QuoteSkeleton/QuoteSkeleton.types.ts +0 -5
  435. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.styles.ts +0 -57
  436. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.tsx +0 -76
  437. package/src/components/QuoteSkeleton/QuoteSummarySkeleton.types.ts +0 -6
  438. package/src/components/QuoteSkeleton/StepSkeleton.styles.ts +0 -33
  439. package/src/components/QuoteSkeleton/StepSkeleton.tsx +0 -44
  440. package/src/components/QuoteSkeleton/StepSkeleton.types.ts +0 -1
  441. package/src/components/QuoteSkeleton/index.ts +0 -3
  442. package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +0 -107
  443. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +0 -74
  444. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +0 -103
  445. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -25
  446. package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +0 -77
  447. package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +0 -38
  448. package/src/components/QuoteWarningsAndErrors/index.ts +0 -1
  449. package/src/containers/App/App.styles.ts +0 -18
  450. package/src/containers/App/App.tsx +0 -52
  451. package/src/containers/App/index.ts +0 -1
  452. package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -31
  453. package/src/containers/QuoteInfo/QuoteInfo.tsx +0 -99
  454. package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -20
  455. package/src/containers/QuoteInfo/index.ts +0 -1
  456. package/src/containers/Wallets/Wallets.types.ts +0 -12
  457. package/src/containers/Wallets/index.ts +0 -1
  458. package/src/containers/Widget/Widget.tsx +0 -19
  459. package/src/containers/Widget/Widget.types.ts +0 -5
  460. package/src/containers/Widget/index.ts +0 -2
  461. package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +0 -64
  462. package/src/containers/WidgetInfo/WidgetInfo.tsx +0 -62
  463. package/src/containers/WidgetInfo/WidgetInfo.types.ts +0 -21
  464. package/src/containers/WidgetInfo/index.ts +0 -1
  465. package/src/containers/WidgetProvider/WidgetProvider.tsx +0 -28
  466. package/src/containers/WidgetProvider/WidgetProvider.types.ts +0 -7
  467. package/src/containers/WidgetProvider/index.ts +0 -1
  468. package/src/hooks/useConfirmSwap/index.ts +0 -1
  469. package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -172
  470. package/src/hooks/useConfirmSwap/useConfirmSwap.ts +0 -137
  471. package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +0 -19
  472. package/src/hooks/useForceAutoConnect.ts +0 -27
  473. package/src/store/AppStore.tsx +0 -41
  474. package/src/store/slices/settings.ts +0 -168
  475. package/src/types/quote.ts +0 -107
  476. package/src/utils/quote.ts +0 -338
@@ -2,66 +2,6 @@ import type { BlockchainMeta } from 'rango-sdk';
2
2
 
3
3
  import { TransactionType } from 'rango-sdk';
4
4
 
5
- export const sampleDefaultBlockchainNames = [
6
- 'ETH',
7
- 'COSMOS',
8
- 'OSMOSIS',
9
- 'BSC',
10
- 'ARBITRUM',
11
- 'POLYGON',
12
- 'ZKSYNC',
13
- 'STARKNET',
14
- 'OPTIMISM',
15
- 'AVAX_CCHAIN',
16
- 'POLYGONZK',
17
- 'LINEA',
18
- 'TRON',
19
- 'BTC',
20
- 'NEUTRON',
21
- 'NOBLE',
22
- 'SOLANA',
23
- 'CRONOS',
24
- 'BNB',
25
- 'AURORA',
26
- 'MAYA',
27
- 'THOR',
28
- 'BOBA',
29
- 'MOONBEAM',
30
- 'MOONRIVER',
31
- 'OKC',
32
- 'BOBA_AVALANCHE',
33
- 'LTC',
34
- 'BCH',
35
- 'HECO',
36
- 'STARGAZE',
37
- 'CRYPTO_ORG',
38
- 'CHIHUAHUA',
39
- 'BANDCHAIN',
40
- 'COMDEX',
41
- 'REGEN',
42
- 'IRIS',
43
- 'EMONEY',
44
- 'JUNO',
45
- 'STRIDE',
46
- 'MARS',
47
- 'TERRA',
48
- 'BITSONG',
49
- 'AKASH',
50
- 'KI',
51
- 'PERSISTENCE',
52
- 'MEDIBLOC',
53
- 'KUJIRA',
54
- 'SENTINEL',
55
- 'INJECTIVE',
56
- 'SECRET',
57
- 'KONSTELLATION',
58
- 'STARNAME',
59
- 'BITCANNA',
60
- 'UMEE',
61
- 'DESMOS',
62
- 'LUMNETWORK',
63
- ];
64
-
65
5
  export const sampleBlockchains: BlockchainMeta[] = [
66
6
  {
67
7
  name: 'ETH',
@@ -2,7 +2,7 @@ import type { BlockchainMeta } from 'rango-sdk';
2
2
 
3
3
  import { beforeEach, describe, expect, it } from 'vitest';
4
4
 
5
- import { MOST_USED_BLOCKCHAINS } from './usePrepareBlockchainList.constants';
5
+ import { MOST_USED_BLOCKChAINS } from './usePrepareBlockchainList.constants';
6
6
  import {
7
7
  generateSortByPreferredBlockchainsFor,
8
8
  prepare,
@@ -20,8 +20,8 @@ describe('usePrepareBlockchainList', () => {
20
20
  it('should sort blockchains by most used ones.', () => {
21
21
  const sortedBlockchainsList = sample.sort(sortByMostUsedBlockchains);
22
22
 
23
- const mostUsedCount = MOST_USED_BLOCKCHAINS.length;
24
- const expected = MOST_USED_BLOCKCHAINS;
23
+ const mostUsedCount = MOST_USED_BLOCKChAINS.length;
24
+ const expected = MOST_USED_BLOCKChAINS;
25
25
  const received = sortedBlockchainsList
26
26
  .map((blockchain) => blockchain.name)
27
27
  .slice(0, mostUsedCount);
@@ -270,79 +270,4 @@ describe('usePrepareBlockchainList', () => {
270
270
  ...received.more.map((blockchain) => blockchain.name),
271
271
  ]);
272
272
  });
273
-
274
- it.only('Last item of the main list should be moved to front if it selected again.', () => {
275
- const listLimit = 10;
276
- const preferredBlockchains = ['AVAX_CCHAIN', 'BTC'];
277
- const expected = [
278
- 'AVAX_CCHAIN',
279
- 'BTC',
280
- 'ETH',
281
- 'COSMOS',
282
- 'OSMOSIS',
283
- 'BSC',
284
- 'ARBITRUM',
285
- 'POLYGON',
286
- 'ZKSYNC',
287
- 'STARKNET',
288
- 'OPTIMISM',
289
- 'POLYGONZK',
290
- 'LINEA',
291
- 'TRON',
292
- 'NEUTRON',
293
- 'NOBLE',
294
- 'SOLANA',
295
- 'CRONOS',
296
- 'BNB',
297
- 'AURORA',
298
- 'MAYA',
299
- 'THOR',
300
- 'BOBA',
301
- 'MOONBEAM',
302
- 'MOONRIVER',
303
- 'OKC',
304
- 'BOBA_AVALANCHE',
305
- 'LTC',
306
- 'BCH',
307
- 'HECO',
308
- 'STARGAZE',
309
- 'CRYPTO_ORG',
310
- 'CHIHUAHUA',
311
- 'BANDCHAIN',
312
- 'COMDEX',
313
- 'REGEN',
314
- 'IRIS',
315
- 'EMONEY',
316
- 'JUNO',
317
- 'STRIDE',
318
- 'MARS',
319
- 'TERRA',
320
- 'BITSONG',
321
- 'AKASH',
322
- 'KI',
323
- 'PERSISTENCE',
324
- 'MEDIBLOC',
325
- 'KUJIRA',
326
- 'SENTINEL',
327
- 'INJECTIVE',
328
- 'SECRET',
329
- 'KONSTELLATION',
330
- 'STARNAME',
331
- 'BITCANNA',
332
- 'UMEE',
333
- 'DESMOS',
334
- 'LUMNETWORK',
335
- ];
336
-
337
- const output = prepare(sample, preferredBlockchains, {
338
- limit: listLimit,
339
- });
340
-
341
- const received = [
342
- ...output.list.map((blockchain) => blockchain.name),
343
- ...output.more.map((blockchain) => blockchain.name),
344
- ];
345
-
346
- expect(expected).toEqual(received);
347
- });
348
273
  });
@@ -1,14 +1,14 @@
1
1
  import type {
2
2
  PrepareListOptions,
3
- UsePrepareList,
3
+ PrepareListOutput,
4
4
  } from './usePrepareBlockchainList.types';
5
5
  import type { BlockchainMeta } from 'rango-sdk';
6
6
 
7
7
  import { useEffect } from 'react';
8
8
 
9
- import { useAppStore } from '../../store/AppStore';
9
+ import { useSettingsStore } from '../../store/settings';
10
10
 
11
- import { isInVisibleList, prepare } from './usePrepareBlockchainList.helpers';
11
+ import { prepare } from './usePrepareBlockchainList.helpers';
12
12
 
13
13
  /**
14
14
  *
@@ -19,21 +19,12 @@ import { isInVisibleList, prepare } from './usePrepareBlockchainList.helpers';
19
19
  export function usePrepareBlockchainList(
20
20
  blockchains: BlockchainMeta[],
21
21
  options?: PrepareListOptions
22
- ): UsePrepareList {
23
- const { preferredBlockchains, addPreferredBlockchain } = useAppStore();
22
+ ): PrepareListOutput {
23
+ const { preferredBlockchains, addPreferredBlockchain } = useSettingsStore();
24
24
 
25
25
  useEffect(() => {
26
26
  if (options?.selected) {
27
- const output = prepare(blockchains, preferredBlockchains, options);
28
-
29
- /**
30
- * We only add a new blockchain to preferred when it's not in the main list
31
- * In this way we can guarantee we will be able to regenerate the same list always.
32
- * And also it helps us to avoid jumping for the last item of the main list (e.g. tenth item of our list).
33
- */
34
- if (!isInVisibleList(options.selected, output)) {
35
- addPreferredBlockchain(options?.selected);
36
- }
27
+ addPreferredBlockchain(options?.selected);
37
28
  }
38
29
  }, [options?.selected]);
39
30
 
@@ -5,13 +5,8 @@ export interface PrepareListOptions {
5
5
  selected?: string;
6
6
  }
7
7
 
8
- export interface PrepareOutput {
8
+ export interface PrepareListOutput {
9
9
  list: BlockchainMeta[];
10
10
  more: BlockchainMeta[];
11
- }
12
-
13
- export interface UsePrepareList {
14
- list: PrepareOutput['list'];
15
- more: PrepareOutput['more'];
16
11
  history: string[];
17
12
  }
@@ -1,56 +1,37 @@
1
- import type { QuoteError, QuoteWarning } from '../types';
2
- import type { Token } from 'rango-sdk';
1
+ import { useEffect, useRef, useState } from 'react';
3
2
 
4
- import { useCallback, useEffect, useState } from 'react';
5
-
6
- import { useAppStore } from '../store/AppStore';
7
- import { useQuoteStore } from '../store/quote';
8
- import { QuoteErrorType } from '../types';
3
+ import { useBestRouteStore } from '../store/bestRoute';
4
+ import { useSettingsStore } from '../store/settings';
9
5
  import { debounce } from '../utils/common';
10
6
  import { isPositiveNumber } from '../utils/numbers';
11
- import { generateQuoteWarnings } from '../utils/quote';
12
- import { isFeatureEnabled } from '../utils/settings';
13
- import { createQuoteRequestBody } from '../utils/swap';
7
+ import { createBestRouteRequestBody } from '../utils/swap';
14
8
  import { tokensAreEqual } from '../utils/wallets';
15
9
 
16
- import {
17
- handleQuoteErrors,
18
- throwErrorIfResponseIsNotValid,
19
- } from './useConfirmSwap/useConfirmSwap.helpers';
20
- import { useFetchQuote } from './useFetchQuote';
10
+ import { useFetchBestRoute } from './useFetchBestRoute';
21
11
 
22
12
  const DEBOUNCE_DELAY = 600;
23
- const FIRST_INDEX = 0;
24
-
25
- type FetchQuoteParams = Omit<
26
- Parameters<typeof createQuoteRequestBody>[typeof FIRST_INDEX],
27
- 'fromToken' | 'toToken'
28
- > & { fromToken: Token | null; toToken: Token | null };
29
13
 
30
14
  type UseSwapInput = {
31
15
  fetch: () => void;
32
16
  loading: boolean;
33
- error: QuoteError | null;
34
- warning: QuoteWarning | null;
17
+ error: string;
35
18
  };
36
19
 
37
20
  /**
38
- * a hook for fetching quote based on from and to input values
21
+ * a hook for fetching best route based on from and to input values
39
22
  * we use this hook in home page
40
23
  */
41
24
  export function useSwapInput(): UseSwapInput {
42
- const { fetch: fetchQuote, cancelFetch } = useFetchQuote();
43
- const { liquiditySources, enableNewLiquiditySources, features } =
44
- useAppStore().config;
45
- const tokens = useAppStore().tokens();
25
+ const { fetch: fetchBestRoute, cancelFetch } = useFetchBestRoute();
26
+ const [loading, setLoading] = useState(false);
46
27
  const {
47
28
  fromToken,
48
29
  toToken,
49
30
  inputAmount,
50
31
  inputUsdValue,
51
- resetQuote,
52
- setQuote,
53
- } = useQuoteStore();
32
+ resetRoute,
33
+ setRoute,
34
+ } = useBestRouteStore();
54
35
  const {
55
36
  slippage,
56
37
  customSlippage,
@@ -58,10 +39,9 @@ export function useSwapInput(): UseSwapInput {
58
39
  affiliateRef,
59
40
  affiliateWallets,
60
41
  disabledLiquiditySources,
61
- } = useAppStore();
62
- const [loading, setLoading] = useState(false);
63
- const [error, setError] = useState<QuoteError | null>(null);
64
- const [warning, setWarning] = useState<QuoteWarning | null>(null);
42
+ } = useSettingsStore();
43
+ const [error, setError] = useState('');
44
+ const prevDisabledLiquiditySources = useRef(disabledLiquiditySources);
65
45
  const userSlippage = customSlippage ?? slippage;
66
46
  const hasTokensValue = !fromToken || !toToken;
67
47
  const shouldSkipRequest =
@@ -69,141 +49,68 @@ export function useSwapInput(): UseSwapInput {
69
49
  tokensAreEqual(fromToken, toToken) ||
70
50
  !isPositiveNumber(inputAmount);
71
51
 
72
- const resetState = (loading: boolean) => {
73
- setLoading(loading);
74
- setError(null);
75
- setWarning(null);
76
- };
77
-
78
- const fetch = (params: FetchQuoteParams) => {
79
- const {
80
- fromToken,
81
- toToken,
82
- inputAmount,
83
- liquiditySources,
84
- excludeLiquiditySources,
85
- disabledLiquiditySources,
86
- slippage,
87
- affiliateRef,
88
- affiliatePercent,
89
- affiliateWallets,
90
- } = params;
52
+ const fetch: UseSwapInput['fetch'] = () => {
91
53
  if (!loading) {
92
- resetState(true);
54
+ setLoading(true);
93
55
  }
94
- if (!shouldSkipRequest && fromToken && toToken) {
95
- resetQuote();
96
- const requestBody = createQuoteRequestBody({
56
+ if (!shouldSkipRequest) {
57
+ resetRoute();
58
+ const requestBody = createBestRouteRequestBody({
97
59
  fromToken,
98
60
  toToken,
99
61
  inputAmount,
100
- liquiditySources,
101
- excludeLiquiditySources,
102
62
  disabledLiquiditySources,
103
- slippage,
63
+ slippage: userSlippage,
104
64
  affiliateRef,
105
65
  affiliatePercent,
106
66
  affiliateWallets,
107
67
  });
108
- if (isFeatureEnabled('experimentalRoute', features)) {
109
- requestBody.experimental = true;
110
- }
111
- fetchQuote(requestBody)
68
+ fetchBestRoute(requestBody)
112
69
  .then((res) => {
113
70
  setLoading(false);
114
- setQuote(res);
115
- throwErrorIfResponseIsNotValid(res);
116
- const quoteWarning = generateQuoteWarnings(res, {
117
- fromToken,
118
- toToken,
119
- userSlippage,
120
- tokens,
121
- });
122
- setWarning(quoteWarning);
71
+ setRoute(res);
123
72
  })
124
73
  .catch((error) => {
125
- const { error: quoteError } = handleQuoteErrors(error);
126
- if (
127
- quoteError?.type === QuoteErrorType.NO_RESULT ||
128
- quoteError?.type === QuoteErrorType.REQUEST_FAILED
129
- ) {
130
- resetQuote();
131
- }
132
- if (quoteError?.type !== QuoteErrorType.REQUEST_CANCELED) {
133
- setError(quoteError);
74
+ resetRoute();
75
+ if (error?.code !== 'ERR_CANCELED') {
76
+ setError(error.message);
134
77
  setLoading(false);
135
78
  }
136
79
  });
137
80
  }
138
81
  };
139
82
 
140
- const debouncedFetch = useCallback(
141
- debounce((params: FetchQuoteParams) => {
142
- if (!shouldSkipRequest) {
143
- fetch(params);
144
- }
145
- }, DEBOUNCE_DELAY),
146
- [shouldSkipRequest]
147
- );
83
+ const debouncedFetch = debounce(() => {
84
+ if (!shouldSkipRequest) {
85
+ fetch();
86
+ }
87
+ }, DEBOUNCE_DELAY);
148
88
 
149
89
  useEffect(() => {
150
90
  if (!isPositiveNumber(inputAmount) || inputUsdValue?.eq(0)) {
151
- resetState(false);
91
+ setLoading(false);
152
92
  cancelFetch();
153
93
  return;
154
94
  }
155
95
  if (shouldSkipRequest) {
156
96
  return;
157
97
  }
158
- resetQuote();
159
- resetState(true);
160
- debouncedFetch({
161
- inputAmount,
162
- fromToken,
163
- toToken,
164
- liquiditySources,
165
- excludeLiquiditySources: enableNewLiquiditySources,
166
- disabledLiquiditySources,
167
- slippage: userSlippage,
168
- affiliateRef,
169
- affiliatePercent,
170
- affiliateWallets,
171
- });
98
+ resetRoute();
99
+ setLoading(true);
100
+ debouncedFetch();
172
101
  return cancelFetch;
173
- }, [
174
- inputAmount,
175
- fromToken?.symbol,
176
- fromToken?.address,
177
- fromToken?.blockchain,
178
- toToken?.symbol,
179
- toToken?.address,
180
- toToken?.blockchain,
181
- shouldSkipRequest,
182
- liquiditySources?.length,
183
- enableNewLiquiditySources,
184
- disabledLiquiditySources.length,
185
- userSlippage,
186
- affiliateRef,
187
- affiliatePercent,
188
- JSON.stringify(affiliateWallets),
189
- ]);
102
+ }, [inputAmount, shouldSkipRequest]);
190
103
 
191
- return {
192
- fetch: () =>
193
- fetch({
194
- inputAmount,
195
- fromToken,
196
- toToken,
197
- liquiditySources,
198
- excludeLiquiditySources: enableNewLiquiditySources,
199
- disabledLiquiditySources,
200
- slippage: userSlippage,
201
- affiliateRef,
202
- affiliatePercent,
203
- affiliateWallets,
204
- }),
205
- loading,
206
- error,
207
- warning,
208
- };
104
+ useEffect(() => {
105
+ const disabledLiquiditySourceReset =
106
+ !!prevDisabledLiquiditySources.current.length &&
107
+ !disabledLiquiditySources.length;
108
+ if (!shouldSkipRequest && disabledLiquiditySourceReset) {
109
+ fetch();
110
+ }
111
+ prevDisabledLiquiditySources.current = disabledLiquiditySources;
112
+ return cancelFetch;
113
+ }, [disabledLiquiditySources.length]);
114
+
115
+ return { fetch, loading, error };
209
116
  }
@@ -1,12 +1,14 @@
1
+ import type { WidgetConfig } from '../types';
1
2
  import type { Asset } from 'rango-sdk';
2
3
 
3
- import { useEffect, useLayoutEffect, useMemo, useRef } from 'react';
4
+ import { useEffect, useMemo, useRef } from 'react';
4
5
 
5
- import { useAppStore } from '../store/AppStore';
6
- import { useQuoteStore } from '../store/quote';
6
+ import { useBestRouteStore } from '../store/bestRoute';
7
+ import { useMetaStore } from '../store/meta';
8
+ import { useSettingsStore } from '../store/settings';
7
9
  import { tokensAreEqual } from '../utils/wallets';
8
10
 
9
- export function useSyncStoresWithConfig() {
11
+ export function useSyncStoresWithConfig(config: WidgetConfig | undefined) {
10
12
  const {
11
13
  setInputAmount,
12
14
  setToToken,
@@ -17,15 +19,15 @@ export function useSyncStoresWithConfig() {
17
19
  toToken,
18
20
  fromBlockchain,
19
21
  toBlockchain,
20
- } = useQuoteStore();
22
+ } = useBestRouteStore();
21
23
 
22
- const config = useAppStore().config;
23
- const fetchMetaStatus = useAppStore().fetchStatus;
24
- const blockchains = useAppStore().blockchains();
25
- const tokens = useAppStore().tokens();
24
+ const {
25
+ meta: { tokens, blockchains },
26
+ loadingStatus: loadingMetaStatus,
27
+ } = useMetaStore();
26
28
 
27
29
  const { setAffiliateRef, setAffiliatePercent, setAffiliateWallets } =
28
- useAppStore();
30
+ useSettingsStore();
29
31
 
30
32
  const fromTokensConfig = useMemo(
31
33
  () => config?.from?.tokens,
@@ -52,15 +54,8 @@ export function useSyncStoresWithConfig() {
52
54
  setInputAmount(config?.amount?.toString() || '');
53
55
  }, [config?.amount]);
54
56
 
55
- /*
56
- * We update quote tokens in two scenarios.
57
- * If default values exist in widget config or search parameters exist in URL.
58
- * The logic for updating quote store exists in two useEffect in two locations, and they run in order.If default tokens for quote exist in widget config and also exist in URL, widget config values take precedence over URL values, and URL search parameters don’t affect the widget.
59
- * Using useLayoutEffect causes widget config values to apply first.
60
- * We may consider replacing this with a better solution in the future.
61
- */
62
- useLayoutEffect(() => {
63
- if (fetchMetaStatus === 'success') {
57
+ useEffect(() => {
58
+ if (loadingMetaStatus === 'success') {
64
59
  const chain = blockchains.find(
65
60
  (chain) => chain.name === config?.from?.blockchain
66
61
  );
@@ -72,10 +67,8 @@ export function useSyncStoresWithConfig() {
72
67
  setFromBlockchain(chain ?? null);
73
68
  }
74
69
 
75
- if (token) {
76
- setFromToken({ token, meta: { blockchains, tokens } });
77
- } else if (!token && prevConfigFromToken.current) {
78
- setFromToken({ token: null });
70
+ if (token || (!token && prevConfigFromToken.current)) {
71
+ setFromToken(token ?? null);
79
72
  }
80
73
 
81
74
  prevConfigFromBlockchain.current = config?.from?.blockchain;
@@ -86,13 +79,13 @@ export function useSyncStoresWithConfig() {
86
79
  config?.from?.token?.address,
87
80
  config?.from?.token?.blockchain,
88
81
  config?.from?.blockchain,
89
- fetchMetaStatus,
82
+ loadingMetaStatus,
90
83
  ]);
91
84
 
92
85
  useEffect(() => {
93
86
  if (fromToken && fromTokensConfig) {
94
87
  if (!fromTokensConfig.some((token) => tokensAreEqual(token, fromToken))) {
95
- setFromToken({ token: null });
88
+ setFromToken(null);
96
89
  }
97
90
  }
98
91
 
@@ -106,7 +99,7 @@ export function useSyncStoresWithConfig() {
106
99
  useEffect(() => {
107
100
  if (toToken && toTokensConfig) {
108
101
  if (!toTokensConfig.some((token) => tokensAreEqual(token, toToken))) {
109
- setToToken({ token: null });
102
+ setToToken(null);
110
103
  }
111
104
  }
112
105
 
@@ -117,15 +110,8 @@ export function useSyncStoresWithConfig() {
117
110
  }
118
111
  }, [toTokensConfig, toBlockchainsConfig]);
119
112
 
120
- /*
121
- * We update quote tokens in two scenarios.
122
- * If default values exist in widget config or search parameters exist in URL.
123
- * The logic for updating quote store exists in two useEffect in two locations, and they run in order.If default tokens for quote exist in widget config and also exist in URL, widget config values take precedence over URL values, and URL search parameters don’t affect the widget.
124
- * Using useLayoutEffect causes widget config values to apply first.
125
- * We may consider replacing this with a better solution in the future.
126
- */
127
- useLayoutEffect(() => {
128
- if (fetchMetaStatus === 'success') {
113
+ useEffect(() => {
114
+ if (loadingMetaStatus === 'success') {
129
115
  const chain = blockchains.find(
130
116
  (chain) => chain.name === config?.to?.blockchain
131
117
  );
@@ -137,10 +123,8 @@ export function useSyncStoresWithConfig() {
137
123
  setToBlockchain(chain ?? null);
138
124
  }
139
125
 
140
- if (token) {
141
- setToToken({ token, meta: { blockchains, tokens } });
142
- } else if (!token && prevConfigToToken.current) {
143
- setToToken({ token: null });
126
+ if (token || (!token && prevConfigToToken.current)) {
127
+ setToToken(token ?? null);
144
128
  }
145
129
 
146
130
  prevConfigToBlockchain.current = config?.to?.blockchain;
@@ -151,7 +135,7 @@ export function useSyncStoresWithConfig() {
151
135
  config?.to?.token?.address,
152
136
  config?.to?.token?.blockchain,
153
137
  config?.to?.blockchain,
154
- fetchMetaStatus,
138
+ loadingMetaStatus,
155
139
  ]);
156
140
 
157
141
  useEffect(() => {
@@ -1,4 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-magic-numbers */
2
+ import type { WidgetTheme } from '../types';
3
+
2
4
  import {
3
5
  createTheme,
4
6
  darkTheme as defaultDarkTheme,
@@ -6,8 +8,7 @@ import {
6
8
  } from '@rango-dev/ui';
7
9
  import { useEffect, useState } from 'react';
8
10
 
9
- import { useAppStore } from '../store/AppStore';
10
- import { type WidgetTheme } from '../types';
11
+ import { useSettingsStore } from '../store/settings';
11
12
  import {
12
13
  DEFAULT_FONT_FAMILY,
13
14
  DEFAULT_PRIMARY_RADIUS,
@@ -25,8 +26,8 @@ export function useTheme(props: WidgetTheme) {
25
26
  } = props;
26
27
 
27
28
  const [OSTheme, setOSTheme] = useState('light');
28
-
29
- const { setTheme, theme } = useAppStore();
29
+ const theme = useSettingsStore.use.theme();
30
+ const setTheme = useSettingsStore.use.setTheme();
30
31
 
31
32
  const { dark, light } = customizedThemeTokens(colors);
32
33
 
@@ -10,7 +10,7 @@ import {
10
10
  } from '@rango-dev/wallets-shared';
11
11
  import { useEffect, useState } from 'react';
12
12
 
13
- import { useAppStore } from '../store/AppStore';
13
+ import { useMetaStore } from '../store/meta';
14
14
  import { useWalletsStore } from '../store/wallets';
15
15
  import { configWalletsToWalletName } from '../utils/providers';
16
16
  import {
@@ -37,7 +37,9 @@ export function useWalletList(params: Params) {
37
37
  const { config, chain, onBeforeConnect, onConnect } = params;
38
38
  const { state, disconnect, getWalletInfo, connect } = useWallets();
39
39
  const { connectedWallets } = useWalletsStore();
40
- const blockchains = useAppStore().blockchains();
40
+ const { blockchains } = useMetaStore().meta;
41
+ const multiWallets =
42
+ typeof config?.multiWallets === 'undefined' ? true : config.multiWallets;
41
43
 
42
44
  /** It can be what has been set by widget config or as a fallback we use all the supported wallets by our library */
43
45
  const listAvailableWalletTypes =
@@ -74,7 +76,7 @@ export function useWalletList(params: Params) {
74
76
  const atLeastOneWalletIsConnected = !!wallets.find(
75
77
  (w) => w.state === WalletState.CONNECTED
76
78
  );
77
- if (!config?.multiWallets && atLeastOneWalletIsConnected) {
79
+ if (!multiWallets && atLeastOneWalletIsConnected) {
78
80
  return;
79
81
  }
80
82
  onBeforeConnect?.(type);