@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
@@ -1,172 +0,0 @@
1
- import type { ConfirmSwapFetchResult } from './useConfirmSwap.types';
2
- import type { ConfirmSwapWarnings, Wallet } from '../../types';
3
- import type { BestRouteResponse, BlockchainMeta, 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
- getPriceImpact,
11
- isNumberOfSwapsChanged,
12
- isQuoteChanged,
13
- isQuoteInternalCoinsUpdated,
14
- isQuoteSwappersUpdated,
15
- } from '../../utils/quote';
16
- import {
17
- checkSlippageErrors,
18
- generateBalanceWarnings,
19
- getLimitErrorMessage,
20
- getMinRequiredSlippage,
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 | undefined,
71
- currentQuote: BestRouteResponse,
72
- params: {
73
- fromToken: Token;
74
- toToken: Token;
75
- meta: { blockchains: BlockchainMeta[]; tokens: Token[] };
76
- selectedWallets: Wallet[];
77
- userSlippage: number;
78
- }
79
- ): ConfirmSwapWarnings {
80
- let quoteChanged = false;
81
- if (previousQuote) {
82
- quoteChanged = isQuoteChanged(previousQuote, currentQuote);
83
- }
84
- const output: ConfirmSwapWarnings = {
85
- quote: null,
86
- quoteUpdate: null,
87
- balance: null,
88
- };
89
-
90
- const quoteWarning = generateQuoteWarnings(currentQuote, {
91
- fromToken: params.fromToken,
92
- toToken: params.toToken,
93
- tokens: params.meta.tokens,
94
- userSlippage: params.userSlippage,
95
- });
96
-
97
- if (quoteWarning) {
98
- output.quote = quoteWarning;
99
- }
100
-
101
- if (previousQuote && quoteChanged) {
102
- if (isOutputAmountChangedALot(previousQuote, currentQuote)) {
103
- output.quoteUpdate = {
104
- type: QuoteUpdateType.QUOTE_AND_OUTPUT_AMOUNT_UPDATED,
105
- newOutputAmount: numberToString(getQuoteOutputAmount(currentQuote)),
106
- percentageChange: numberToString(
107
- getPriceImpact(
108
- getQuoteOutputAmount(previousQuote) ?? '',
109
- getQuoteOutputAmount(currentQuote) ?? ''
110
- ),
111
- null,
112
- 2
113
- ),
114
- };
115
- } else if (isNumberOfSwapsChanged(previousQuote, currentQuote)) {
116
- output.quoteUpdate = {
117
- type: QuoteUpdateType.QUOTE_UPDATED,
118
- };
119
- } else if (isQuoteSwappersUpdated(previousQuote, currentQuote)) {
120
- output.quoteUpdate = {
121
- type: QuoteUpdateType.QUOTE_SWAPPERS_UPDATED,
122
- };
123
- } else if (isQuoteInternalCoinsUpdated(previousQuote, currentQuote)) {
124
- output.quoteUpdate = {
125
- type: QuoteUpdateType.QUOTE_COINS_UPDATED,
126
- };
127
- }
128
- }
129
-
130
- const balanceWarnings = generateBalanceWarnings(
131
- currentQuote,
132
- params.selectedWallets,
133
- params.meta.blockchains
134
- );
135
- const enoughBalance = balanceWarnings.length === 0;
136
-
137
- if (!enoughBalance) {
138
- output.balance = {
139
- messages: balanceWarnings,
140
- };
141
- }
142
-
143
- return output;
144
- }
145
-
146
- export function handleQuoteErrors(error: any): ConfirmSwapFetchResult {
147
- if (error?.code === 'ERR_CANCELED') {
148
- return {
149
- swap: null,
150
- error: {
151
- type: QuoteErrorType.REQUEST_CANCELED,
152
- },
153
- warnings: null,
154
- };
155
- }
156
-
157
- if (error.cause) {
158
- return {
159
- swap: null,
160
- error: error.cause,
161
- warnings: null,
162
- };
163
- }
164
-
165
- return {
166
- swap: null,
167
- error: {
168
- type: QuoteErrorType.REQUEST_FAILED,
169
- },
170
- warnings: null,
171
- };
172
- }
@@ -1,137 +0,0 @@
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 { useWalletsStore } from '../../store/wallets';
11
- import { isFeatureEnabled } from '../../utils/settings';
12
- import { createQuoteRequestBody, getWalletsForNewSwap } from '../../utils/swap';
13
- import { useFetchQuote } from '../useFetchQuote';
14
-
15
- import {
16
- generateWarnings,
17
- handleQuoteErrors,
18
- throwErrorIfResponseIsNotValid,
19
- } from './useConfirmSwap.helpers';
20
-
21
- export function useConfirmSwap(): ConfirmSwap {
22
- const {
23
- fromToken,
24
- toToken,
25
- inputAmount,
26
- setQuote,
27
- quote: initialQuote,
28
- customDestination: customDestinationFromStore,
29
- setQuoteWarningsConfirmed,
30
- } = useQuoteStore();
31
-
32
- const {
33
- slippage,
34
- customSlippage,
35
- affiliatePercent,
36
- affiliateRef,
37
- affiliateWallets,
38
- disabledLiquiditySources,
39
- } = useAppStore();
40
- const { connectedWallets } = useWalletsStore();
41
- const blockchains = useAppStore().blockchains();
42
- const tokens = useAppStore().tokens();
43
- const { features } = useAppStore().config;
44
- const { enableNewLiquiditySources } = useAppStore().config;
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) {
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
- excludeLiquiditySources: enableNewLiquiditySources,
73
- disabledLiquiditySources,
74
- slippage: userSlippage,
75
- affiliateRef,
76
- affiliatePercent,
77
- affiliateWallets,
78
- initialQuote: initialQuote ?? undefined,
79
- destination: customDestination,
80
- });
81
- if (isFeatureEnabled('experimentalRoute', features)) {
82
- requestBody.experimental = true;
83
- }
84
- let currentQuote: BestRouteResponse;
85
- try {
86
- currentQuote = await fetchQuote(requestBody).then((response) =>
87
- throwErrorIfResponseIsNotValid(response)
88
- );
89
- setQuote(currentQuote);
90
- } catch (error: any) {
91
- const confirmSwapResult = handleQuoteErrors(error);
92
- return confirmSwapResult;
93
- }
94
-
95
- const swapSettings: PendingSwapSettings = {
96
- slippage: userSlippage.toString(),
97
- disabledSwappersGroups: disabledLiquiditySources,
98
- };
99
- const swap = calculatePendingSwap(
100
- inputAmount.toString(),
101
- currentQuote,
102
- getWalletsForNewSwap(selectedWallets),
103
- swapSettings,
104
- false,
105
- { blockchains, tokens }
106
- );
107
-
108
- const confirmSwapWarnings = generateWarnings(
109
- initialQuote ?? undefined,
110
- currentQuote,
111
- {
112
- fromToken,
113
- toToken,
114
- meta: { blockchains, tokens },
115
- selectedWallets,
116
- userSlippage,
117
- }
118
- );
119
-
120
- if (confirmSwapWarnings.quoteUpdate) {
121
- setQuoteWarningsConfirmed(false);
122
- }
123
-
124
- return {
125
- quote: currentQuote,
126
- swap,
127
- error: null,
128
- warnings: confirmSwapWarnings,
129
- };
130
- };
131
-
132
- return {
133
- loading,
134
- fetch,
135
- cancelFetch,
136
- };
137
- }
@@ -1,19 +0,0 @@
1
- import type { ConfirmSwapWarnings, QuoteError, Wallet } from '../../types';
2
- import type { PendingSwap } from 'rango-types';
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
- };
@@ -1,27 +0,0 @@
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,41 +0,0 @@
1
- import type { WidgetConfig } from '../types';
2
- import type { PropsWithChildren } from 'react';
3
-
4
- import React, { createContext, useContext, useEffect, useRef } from 'react';
5
-
6
- import { createAppStore } from './app';
7
-
8
- type AppStore = ReturnType<typeof createAppStore>;
9
- type AppStoreProviderProps = PropsWithChildren<{ config?: WidgetConfig }>;
10
-
11
- export const AppStoreContext = createContext<AppStore | null>(null);
12
-
13
- export function useAppStore() {
14
- const store = useContext(AppStoreContext);
15
-
16
- useEffect(() => {
17
- if (store && !store.persist.hasHydrated()) {
18
- void store.persist.rehydrate();
19
- }
20
- }, []);
21
-
22
- if (!store) {
23
- throw new Error('Missing AppStoreContext.Provider in the tree');
24
- }
25
-
26
- return store();
27
- }
28
-
29
- export function AppStoreProvider(props: AppStoreProviderProps) {
30
- const appStoreRef = useRef<AppStore>();
31
-
32
- if (!appStoreRef.current) {
33
- appStoreRef.current = createAppStore(props.config);
34
- }
35
-
36
- return (
37
- <AppStoreContext.Provider value={appStoreRef.current}>
38
- {props.children}
39
- </AppStoreContext.Provider>
40
- );
41
- }
@@ -1,168 +0,0 @@
1
- import type { ConfigSlice } from './config';
2
- import type { WidgetConfig } from '../../types';
3
- import type { SwapperMeta } from 'rango-sdk';
4
- import type { StateCreator } from 'zustand';
5
-
6
- import { type Language } from '@rango-dev/ui';
7
-
8
- import { BLOCKCHAIN_LIST_SIZE } from '../../constants/configs';
9
- import { DEFAULT_LANGUAGE } from '../../constants/languages';
10
- import { DEFAULT_SLIPPAGE } from '../../constants/swapSettings';
11
- import { removeDuplicateFrom } from '../../utils/common';
12
- import { isFeatureHidden } from '../../utils/settings';
13
-
14
- export type ThemeMode = 'auto' | 'dark' | 'light';
15
-
16
- export interface SettingsSlice {
17
- theme: ThemeMode;
18
- language: Language;
19
- disabledLiquiditySources: string[];
20
- /** Keeping a history of blockchains that user has selected (in Swap process) */
21
- preferredBlockchains: string[];
22
- slippage: number;
23
- customSlippage: number | null;
24
- infiniteApprove: boolean;
25
- affiliateRef: string | null;
26
- affiliatePercent: number | null;
27
- affiliateWallets: { [key: string]: string } | null;
28
-
29
- setSlippage: (slippage: number) => void;
30
- setCustomSlippage: (customSlippage: number | null) => void;
31
- toggleInfiniteApprove: () => void;
32
- toggleLiquiditySource: (name: string) => void;
33
- setTheme: (theme: ThemeMode) => void;
34
- setLanguage: (language: Language) => void;
35
- toggleAllLiquiditySources: (
36
- swappers: SwapperMeta[],
37
- shouldReset?: boolean
38
- ) => void;
39
- setAffiliateRef: (affiliateRef: string | null) => void;
40
- setAffiliatePercent: (affiliatePercent: number | null) => void;
41
- setAffiliateWallets: (
42
- affiliateWallets: { [key: string]: string } | null
43
- ) => void;
44
- addPreferredBlockchain: (blockchain: string) => void;
45
- updateSettings: (config: WidgetConfig) => void;
46
- }
47
-
48
- export const createSettingsSlice: StateCreator<
49
- SettingsSlice & ConfigSlice,
50
- [],
51
- [],
52
- SettingsSlice
53
- > = (set, get) => ({
54
- disabledLiquiditySources: [],
55
- theme: 'auto',
56
- language: DEFAULT_LANGUAGE,
57
- preferredBlockchains: [],
58
- slippage: DEFAULT_SLIPPAGE,
59
- customSlippage: null,
60
- infiniteApprove: false,
61
- affiliateRef: null,
62
- affiliatePercent: null,
63
- affiliateWallets: null,
64
-
65
- addPreferredBlockchain: (blockchain) => {
66
- const currentPreferredBlockchains = get().preferredBlockchains;
67
-
68
- const noNeedToDoAnything = currentPreferredBlockchains.find(
69
- (preferredBlockchain, index) => {
70
- const isSameBlockchain = preferredBlockchain === blockchain;
71
- const isInVisibleList = index <= BLOCKCHAIN_LIST_SIZE - 1;
72
-
73
- return isSameBlockchain && isInVisibleList;
74
- }
75
- );
76
-
77
- if (noNeedToDoAnything) {
78
- return;
79
- }
80
-
81
- const nextPreferredBlockchains: string[] =
82
- currentPreferredBlockchains.filter((preferredBlockchain) => {
83
- const isSameBlockchain = preferredBlockchain === blockchain;
84
-
85
- return !isSameBlockchain;
86
- });
87
-
88
- set(() => ({
89
- preferredBlockchains: [blockchain, ...nextPreferredBlockchains],
90
- }));
91
- },
92
- setSlippage: (slippage) =>
93
- set(() => ({
94
- slippage: slippage,
95
- })),
96
- setCustomSlippage: (customSlippage) =>
97
- set(() => ({
98
- customSlippage: customSlippage,
99
- })),
100
- setAffiliateRef: (affiliateRef) =>
101
- set(() => ({
102
- affiliateRef,
103
- })),
104
- setAffiliatePercent: (affiliatePercent) =>
105
- set(() => ({
106
- affiliatePercent,
107
- })),
108
-
109
- setAffiliateWallets: (affiliateWallets) =>
110
- set(() => ({
111
- affiliateWallets,
112
- })),
113
- toggleAllLiquiditySources: (swappers, shouldReset) =>
114
- set((state) => {
115
- if (shouldReset) {
116
- return { disabledLiquiditySources: [] };
117
- }
118
- const swappersGroup = removeDuplicateFrom(
119
- swappers.map((swapper) => swapper.swapperGroup)
120
- );
121
-
122
- if (swappersGroup.length === state.disabledLiquiditySources.length) {
123
- return { disabledLiquiditySources: [] };
124
- }
125
-
126
- return {
127
- disabledLiquiditySources: swappersGroup,
128
- };
129
- }),
130
- toggleInfiniteApprove: () =>
131
- set((state) => ({
132
- infiniteApprove: !state.infiniteApprove,
133
- })),
134
- toggleLiquiditySource: (name) =>
135
- set((state) => {
136
- if (state.disabledLiquiditySources.includes(name)) {
137
- return {
138
- disabledLiquiditySources: state.disabledLiquiditySources.filter(
139
- (liquiditySource) => liquiditySource != name
140
- ),
141
- };
142
- }
143
- return {
144
- disabledLiquiditySources: state.disabledLiquiditySources.concat(name),
145
- };
146
- }),
147
- setTheme: (theme) =>
148
- set(() => ({
149
- theme,
150
- })),
151
- setLanguage: (language) =>
152
- set(() => ({
153
- language,
154
- })),
155
- updateSettings: (nextConfig: WidgetConfig) => {
156
- const { features } = nextConfig;
157
-
158
- const isThemeHidden = isFeatureHidden('theme', features);
159
- const isLanguageHidden = isFeatureHidden('language', features);
160
- const isLiquidityHidden = isFeatureHidden('liquiditySource', features);
161
-
162
- set({
163
- ...(isThemeHidden && { theme: 'auto' }),
164
- ...(isLanguageHidden && { language: DEFAULT_LANGUAGE }),
165
- ...(isLiquidityHidden && { disabledLiquiditySources: [] }),
166
- });
167
- },
168
- });
@@ -1,107 +0,0 @@
1
- /* eslint-disable @typescript-eslint/prefer-enum-initializers */
2
-
3
- import type { PriceImpactWarningLevel } from '@rango-dev/ui';
4
- import type BigNumber from 'bignumber.js';
5
- import type { SwapResult } from 'rango-sdk';
6
-
7
- export enum QuoteErrorType {
8
- NO_RESULT,
9
- REQUEST_FAILED,
10
- REQUEST_CANCELED,
11
- BRIDGE_LIMIT,
12
- INSUFFICIENT_SLIPPAGE,
13
- }
14
-
15
- export type NoResultError = {
16
- type: QuoteErrorType.NO_RESULT;
17
- diagnosisMessage?: string;
18
- };
19
-
20
- export type BridgeLimitError = {
21
- type: QuoteErrorType.BRIDGE_LIMIT;
22
- swap: SwapResult;
23
- recommendation: string;
24
- fromAmountRangeError: string;
25
- };
26
-
27
- export type InsufficientSlippageError = {
28
- type: QuoteErrorType.INSUFFICIENT_SLIPPAGE;
29
- recommendedSlippages: RecommendedSlippages | null;
30
- minRequiredSlippage: string | null;
31
- };
32
-
33
- export type QuoteRequestFailed = { type: QuoteErrorType.REQUEST_FAILED };
34
- export type QuoteRequestCanceled = { type: QuoteErrorType.REQUEST_CANCELED };
35
-
36
- export type QuoteError =
37
- | NoResultError
38
- | BridgeLimitError
39
- | InsufficientSlippageError
40
- | QuoteRequestFailed
41
- | QuoteRequestCanceled;
42
-
43
- export enum QuoteWarningType {
44
- HIGH_VALUE_LOSS,
45
- UNKNOWN_PRICE,
46
- INSUFFICIENT_SLIPPAGE,
47
- HIGH_SLIPPAGE,
48
- }
49
-
50
- export enum QuoteUpdateType {
51
- QUOTE_UPDATED,
52
- QUOTE_SWAPPERS_UPDATED,
53
- QUOTE_COINS_UPDATED,
54
- QUOTE_AND_OUTPUT_AMOUNT_UPDATED,
55
- QUOTE_UPDATED_WITH_HIGH_VALUE_LOSS,
56
- }
57
-
58
- export type QuoteUpdateWarning =
59
- | {
60
- type: QuoteUpdateType.QUOTE_AND_OUTPUT_AMOUNT_UPDATED;
61
- newOutputAmount: string;
62
- percentageChange: string;
63
- }
64
- | {
65
- type: Exclude<
66
- QuoteUpdateType,
67
- QuoteUpdateType.QUOTE_AND_OUTPUT_AMOUNT_UPDATED
68
- >;
69
- };
70
-
71
- export type RecommendedSlippages = Map<number, string>;
72
-
73
- export type InsufficientSlippageWarning = {
74
- type: QuoteWarningType.INSUFFICIENT_SLIPPAGE;
75
- recommendedSlippages: RecommendedSlippages | null;
76
- minRequiredSlippage: string | null;
77
- };
78
-
79
- export type HighSlippageWarning = {
80
- type: QuoteWarningType.HIGH_SLIPPAGE;
81
- slippage: string | null;
82
- };
83
-
84
- export type HighValueLossWarning = {
85
- type: QuoteWarningType.HIGH_VALUE_LOSS;
86
- warningLevel: PriceImpactWarningLevel;
87
- inputUsdValue: BigNumber;
88
- outputUsdValue: BigNumber;
89
- totalFee: BigNumber;
90
- priceImpact: number;
91
- };
92
-
93
- export type UnknownPriceWarning = {
94
- type: QuoteWarningType.UNKNOWN_PRICE;
95
- };
96
-
97
- export type QuoteWarning =
98
- | HighValueLossWarning
99
- | InsufficientSlippageWarning
100
- | HighSlippageWarning
101
- | UnknownPriceWarning;
102
-
103
- export type ConfirmSwapWarnings = {
104
- quote: QuoteWarning | null;
105
- quoteUpdate: QuoteUpdateWarning | null;
106
- balance: { messages: string[] } | null;
107
- };