@rango-dev/widget-embedded 0.12.1-next.9 → 0.13.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 (279) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/dist/Widget.d.ts.map +1 -1
  3. package/dist/components/AppRouter.d.ts +5 -2
  4. package/dist/components/AppRouter.d.ts.map +1 -1
  5. package/dist/components/AppRoutes.d.ts.map +1 -1
  6. package/dist/components/BlockchainList/BlockchainList.d.ts.map +1 -1
  7. package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
  8. package/dist/components/BlockchainList/BlockchainList.styles.d.ts +14 -4
  9. package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
  10. package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
  11. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +6 -1
  12. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
  13. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -1
  14. package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
  15. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +94 -17
  16. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  17. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  18. package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
  19. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +18 -3
  20. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
  21. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +25 -284
  22. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  23. package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +1 -0
  24. package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -1
  25. package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
  26. package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts.map +1 -1
  27. package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -1
  28. package/dist/components/Layout/Layout.d.ts.map +1 -1
  29. package/dist/components/Layout/Layout.styles.d.ts +18 -3
  30. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  31. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +6 -1
  32. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
  33. package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts +4 -0
  34. package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +1 -0
  35. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts +3 -0
  36. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -0
  37. package/dist/components/{SelectableCategoryList/SelectableCategoryList.styles.d.ts → LoadingSwapDetails/LoadingSwapDetails.styles.d.ts} +21 -6
  38. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -0
  39. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +4 -0
  40. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +1 -0
  41. package/dist/components/LoadingSwapDetails/index.d.ts +2 -0
  42. package/dist/components/LoadingSwapDetails/index.d.ts.map +1 -0
  43. package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -1
  44. package/dist/components/NoRoutes/NoRoutes.styles.d.ts +18 -3
  45. package/dist/components/NoRoutes/NoRoutes.styles.d.ts.map +1 -1
  46. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  47. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +24 -4
  48. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  49. package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -1
  50. package/dist/components/RouteErrors/RouteErrors.styles.d.ts +24 -4
  51. package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -1
  52. package/dist/components/RouteErrors/RouteErrors.types.d.ts +3 -1
  53. package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -1
  54. package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -1
  55. package/dist/components/SearchInput/SearchInput.styles.d.ts +6 -1
  56. package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  57. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +23 -151
  58. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
  59. package/dist/components/SettingsContainer/index.d.ts +1 -1
  60. package/dist/components/SettingsContainer/index.d.ts.map +1 -1
  61. package/dist/components/Slippage/Slippage.d.ts.map +1 -1
  62. package/dist/components/Slippage/Slippage.styles.d.ts +24 -4
  63. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  64. package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
  65. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  66. package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +2 -9
  67. package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
  68. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +35 -153
  69. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  70. package/dist/components/SwapDetails/SwapDetails.types.d.ts +1 -1
  71. package/dist/components/SwapDetails/SwapDetails.types.d.ts.map +1 -1
  72. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +6 -1
  73. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
  74. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +2 -1
  75. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
  76. package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts +1 -1
  77. package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
  78. package/dist/components/SwapDetailsModal/SwapDetailsModal.d.ts.map +1 -1
  79. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +6 -1
  80. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
  81. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +2 -1
  82. package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
  83. package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
  84. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +24 -4
  85. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
  86. package/dist/components/SwitchFromAndTo.d.ts.map +1 -1
  87. package/dist/components/TokenList/TokenList.d.ts.map +1 -1
  88. package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
  89. package/dist/components/TokenList/TokenList.styles.d.ts +207 -9
  90. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  91. package/dist/components/TokenList/TokenList.types.d.ts +1 -1
  92. package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
  93. package/dist/components/UpdateUrl.d.ts +6 -1
  94. package/dist/components/UpdateUrl.d.ts.map +1 -1
  95. package/dist/components/WalletModal/WalletModalContent.styles.d.ts +24 -4
  96. package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
  97. package/dist/components/WidgetEvents.d.ts.map +1 -1
  98. package/dist/constants/errors.d.ts +2 -2
  99. package/dist/constants/routing.d.ts +12 -2
  100. package/dist/constants/routing.d.ts.map +1 -1
  101. package/dist/constants.d.ts +2 -0
  102. package/dist/constants.d.ts.map +1 -0
  103. package/dist/globalStyles.d.ts +1 -1
  104. package/dist/globalStyles.d.ts.map +1 -1
  105. package/dist/hooks/useNavigateBack.d.ts.map +1 -1
  106. package/dist/hooks/usePrepareBlockchainList.d.ts +18 -0
  107. package/dist/hooks/usePrepareBlockchainList.d.ts.map +1 -0
  108. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  109. package/dist/hooks/useSyncStoresWithConfig.d.ts +3 -0
  110. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -0
  111. package/dist/hooks/useTheme.d.ts +3 -6
  112. package/dist/hooks/useTheme.d.ts.map +1 -1
  113. package/dist/hooks/useWalletProviders.d.ts +3 -3
  114. package/dist/hooks/useWalletProviders.d.ts.map +1 -1
  115. package/dist/index.js +1 -1
  116. package/dist/index.js.map +4 -4
  117. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  118. package/dist/pages/Home.d.ts.map +1 -1
  119. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  120. package/dist/pages/SelectBlockchainPage.d.ts +1 -2
  121. package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
  122. package/dist/pages/SelectSwapItemsPage.d.ts +1 -5
  123. package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
  124. package/dist/pages/SettingsPage.d.ts.map +1 -1
  125. package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
  126. package/dist/pages/WalletsPage.d.ts.map +1 -1
  127. package/dist/services/httpService.d.ts +0 -1
  128. package/dist/services/httpService.d.ts.map +1 -1
  129. package/dist/store/app.d.ts +26 -0
  130. package/dist/store/app.d.ts.map +1 -0
  131. package/dist/store/bestRoute.d.ts +4 -8
  132. package/dist/store/bestRoute.d.ts.map +1 -1
  133. package/dist/store/meta.d.ts +0 -2
  134. package/dist/store/meta.d.ts.map +1 -1
  135. package/dist/store/slices/config.d.ts +8 -0
  136. package/dist/store/slices/config.d.ts.map +1 -0
  137. package/dist/store/slices/data.d.ts +26 -0
  138. package/dist/store/slices/data.d.ts.map +1 -0
  139. package/dist/store/wallets.d.ts.map +1 -1
  140. package/dist/types/config.d.ts +3 -0
  141. package/dist/types/config.d.ts.map +1 -1
  142. package/dist/utils/common.d.ts +1 -0
  143. package/dist/utils/common.d.ts.map +1 -1
  144. package/dist/utils/configs.d.ts +5 -0
  145. package/dist/utils/configs.d.ts.map +1 -1
  146. package/dist/utils/meta.d.ts +1 -0
  147. package/dist/utils/meta.d.ts.map +1 -1
  148. package/dist/utils/numbers.d.ts +3 -1
  149. package/dist/utils/numbers.d.ts.map +1 -1
  150. package/dist/utils/routing.d.ts +6 -3
  151. package/dist/utils/routing.d.ts.map +1 -1
  152. package/dist/utils/settings.d.ts +1 -0
  153. package/dist/utils/settings.d.ts.map +1 -1
  154. package/dist/utils/swap.d.ts +1 -1
  155. package/dist/utils/swap.d.ts.map +1 -1
  156. package/dist/utils/time.d.ts +2 -2
  157. package/dist/utils/time.d.ts.map +1 -1
  158. package/dist/utils/wallets.d.ts +1 -1
  159. package/dist/utils/wallets.d.ts.map +1 -1
  160. package/package.json +8 -8
  161. package/readme.md +3 -1
  162. package/src/Widget.tsx +22 -3
  163. package/src/components/AppRouter.tsx +38 -7
  164. package/src/components/AppRoutes.tsx +4 -28
  165. package/src/components/BlockchainList/BlockchainList.helpers.ts +1 -1
  166. package/src/components/BlockchainList/BlockchainList.styles.ts +6 -5
  167. package/src/components/BlockchainList/BlockchainList.tsx +6 -9
  168. package/src/components/BlockchainsSection/BlockchainsSection.tsx +29 -42
  169. package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +33 -7
  170. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +48 -7
  171. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +59 -16
  172. package/src/components/ConfirmWalletsModal/WalletList.tsx +66 -22
  173. package/src/components/HeaderButtons/HeaderButtons.styles.ts +2 -2
  174. package/src/components/HeaderButtons/HeaderButtons.types.ts +1 -0
  175. package/src/components/HeaderButtons/HomeButtons.tsx +18 -5
  176. package/src/components/HeaderButtons/UnreadNotificationsBadge.tsx +1 -2
  177. package/src/components/HeaderButtons/WalletButton.tsx +4 -1
  178. package/src/components/Layout/Layout.styles.ts +5 -3
  179. package/src/components/Layout/Layout.tsx +5 -20
  180. package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +41 -0
  181. package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +78 -0
  182. package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +53 -0
  183. package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +3 -0
  184. package/src/components/LoadingSwapDetails/index.ts +1 -0
  185. package/src/components/NoRoutes/NoRoutes.helper.ts +4 -2
  186. package/src/components/NotificationContent/NotificationContent.tsx +3 -7
  187. package/src/components/RouteErrors/RouteErrors.styles.ts +2 -1
  188. package/src/components/RouteErrors/RouteErrors.tsx +37 -26
  189. package/src/components/RouteErrors/RouteErrors.types.ts +3 -1
  190. package/src/components/RouteErrors/RouteErrorsModal.tsx +42 -14
  191. package/src/components/SettingsContainer/SettingsContainer.style.ts +2 -7
  192. package/src/components/SettingsContainer/index.ts +0 -1
  193. package/src/components/Slippage/Slippage.tsx +6 -2
  194. package/src/components/Slippage/SlippageTooltipContent.tsx +1 -1
  195. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +52 -16
  196. package/src/components/SwapDetails/SwapDetails.helpers.tsx +19 -33
  197. package/src/components/SwapDetails/SwapDetails.styles.ts +10 -14
  198. package/src/components/SwapDetails/SwapDetails.tsx +143 -101
  199. package/src/components/SwapDetails/SwapDetails.types.ts +1 -1
  200. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +5 -4
  201. package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +6 -7
  202. package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +3 -0
  203. package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +2 -1
  204. package/src/components/SwapsGroup/SwapsGroup.tsx +3 -2
  205. package/src/components/SwitchFromAndTo.tsx +1 -35
  206. package/src/components/TokenList/TokenList.helpers.ts +6 -8
  207. package/src/components/TokenList/TokenList.styles.ts +7 -1
  208. package/src/components/TokenList/TokenList.tsx +29 -23
  209. package/src/components/TokenList/TokenList.types.ts +1 -1
  210. package/src/components/UpdateUrl.tsx +7 -1
  211. package/src/components/WidgetEvents.tsx +9 -3
  212. package/src/constants/errors.ts +2 -2
  213. package/src/constants/routing.ts +17 -2
  214. package/src/constants.ts +1 -0
  215. package/src/globalStyles.ts +1 -4
  216. package/src/hooks/useFetchBestRoute.ts +2 -2
  217. package/src/hooks/useNavigateBack.ts +10 -0
  218. package/src/hooks/usePrepareBlockchainList.ts +125 -0
  219. package/src/hooks/useSwapInput.ts +17 -3
  220. package/src/hooks/useSyncStoresWithConfig.ts +102 -0
  221. package/src/hooks/useTheme.ts +37 -75
  222. package/src/hooks/useWalletProviders.ts +7 -7
  223. package/src/pages/ConfirmSwapPage.tsx +65 -36
  224. package/src/pages/HistoryPage.tsx +2 -2
  225. package/src/pages/Home.tsx +114 -50
  226. package/src/pages/LanguagePage.tsx +1 -1
  227. package/src/pages/LiquiditySourcePage.tsx +22 -18
  228. package/src/pages/SelectBlockchainPage.tsx +19 -20
  229. package/src/pages/SelectSwapItemsPage.tsx +66 -88
  230. package/src/pages/SettingsPage.tsx +42 -15
  231. package/src/pages/SwapDetailsPage.tsx +9 -2
  232. package/src/pages/ThemePage.tsx +1 -1
  233. package/src/pages/WalletsPage.tsx +11 -5
  234. package/src/services/httpService.ts +4 -5
  235. package/src/store/app.ts +15 -0
  236. package/src/store/bestRoute.ts +45 -71
  237. package/src/store/meta.ts +11 -29
  238. package/src/store/slices/config.ts +26 -0
  239. package/src/store/slices/data.ts +203 -0
  240. package/src/store/wallets.ts +0 -27
  241. package/src/types/config.ts +3 -0
  242. package/src/utils/common.ts +3 -0
  243. package/src/utils/configs.ts +8 -2
  244. package/src/utils/meta.ts +7 -0
  245. package/src/utils/numbers.ts +3 -2
  246. package/src/utils/routing.ts +76 -14
  247. package/src/utils/settings.ts +15 -0
  248. package/src/utils/swap.ts +82 -26
  249. package/src/utils/time.ts +69 -36
  250. package/src/utils/wallets.ts +49 -29
  251. package/dist/components/BlockchainsChip/BlockchainsChip.d.ts +0 -5
  252. package/dist/components/BlockchainsChip/BlockchainsChip.d.ts.map +0 -1
  253. package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts +0 -151
  254. package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts.map +0 -1
  255. package/dist/components/BlockchainsChip/BlockchainsChip.types.d.ts +0 -6
  256. package/dist/components/BlockchainsChip/BlockchainsChip.types.d.ts.map +0 -1
  257. package/dist/components/BlockchainsChip/index.d.ts +0 -2
  258. package/dist/components/BlockchainsChip/index.d.ts.map +0 -1
  259. package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts +0 -3
  260. package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts.map +0 -1
  261. package/dist/components/SelectableCategoryList/SelectableCategoryList.d.ts +0 -4
  262. package/dist/components/SelectableCategoryList/SelectableCategoryList.d.ts.map +0 -1
  263. package/dist/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts +0 -4
  264. package/dist/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts.map +0 -1
  265. package/dist/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts.map +0 -1
  266. package/dist/components/SelectableCategoryList/SelectableCategoryList.types.d.ts +0 -12
  267. package/dist/components/SelectableCategoryList/SelectableCategoryList.types.d.ts.map +0 -1
  268. package/dist/components/SelectableCategoryList/index.d.ts +0 -2
  269. package/dist/components/SelectableCategoryList/index.d.ts.map +0 -1
  270. package/src/components/BlockchainsChip/BlockchainsChip.styles.ts +0 -30
  271. package/src/components/BlockchainsChip/BlockchainsChip.tsx +0 -15
  272. package/src/components/BlockchainsChip/BlockchainsChip.types.ts +0 -4
  273. package/src/components/BlockchainsChip/index.ts +0 -1
  274. package/src/components/BlockchainsSection/BlockchainSection.helpers.ts +0 -20
  275. package/src/components/SelectableCategoryList/SelectableCategoryList.helpers.ts +0 -20
  276. package/src/components/SelectableCategoryList/SelectableCategoryList.styles.ts +0 -21
  277. package/src/components/SelectableCategoryList/SelectableCategoryList.tsx +0 -79
  278. package/src/components/SelectableCategoryList/SelectableCategoryList.types.ts +0 -12
  279. package/src/components/SelectableCategoryList/index.ts +0 -1
@@ -22,18 +22,32 @@ import { RouteErrors } from '../components/RouteErrors';
22
22
  import { SwitchFromAndToButton } from '../components/SwitchFromAndTo';
23
23
  import { errorMessages } from '../constants/errors';
24
24
  import { navigationRoutes } from '../constants/navigationRoutes';
25
+ import {
26
+ BALANCE_MAX_DECIMALS,
27
+ BALANCE_MIN_DECIMALS,
28
+ GAS_FEE_MAX_DECIMALS,
29
+ GAS_FEE_MIN_DECIMALS,
30
+ PERCENTAGE_CHANGE_MAX_DECIMALS,
31
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
32
+ TOKEN_AMOUNT_MAX_DECIMALS,
33
+ TOKEN_AMOUNT_MIN_DECIMALS,
34
+ USD_VALUE_MAX_DECIMALS,
35
+ USD_VALUE_MIN_DECIMALS,
36
+ } from '../constants/routing';
25
37
  import { useSwapInput } from '../hooks/useSwapInput';
26
38
  import { useBestRouteStore } from '../store/bestRoute';
27
39
  import { useMetaStore } from '../store/meta';
28
40
  import { useUiStore } from '../store/ui';
29
41
  import { useWalletsStore } from '../store/wallets';
30
42
  import { ButtonState } from '../types';
43
+ import { getContainer } from '../utils/common';
44
+ import { getBlockchainShortNameFor } from '../utils/meta';
31
45
  import {
32
46
  numberToString,
33
47
  secondsToString,
34
48
  totalArrivalTime,
35
49
  } from '../utils/numbers';
36
- import { getFormatedBestRoute } from '../utils/routing';
50
+ import { getFormattedBestRoute, getPriceImpactLevel } from '../utils/routing';
37
51
  import {
38
52
  canComputePriceImpact,
39
53
  getOutputRatio,
@@ -77,12 +91,6 @@ const FooterAlert = styled('div', {
77
91
  display: 'flex',
78
92
  });
79
93
 
80
- const BALANCE_PRECISION = 8;
81
- const TWO_DECIMAL = 2;
82
- const MAX_DECIMAL = 6;
83
- const MIN_DECIMAL = 0;
84
- const WARNING_LEVEL_LIMIT = -10;
85
-
86
94
  export function Home() {
87
95
  const navigate = useNavigate();
88
96
  const {
@@ -105,7 +113,7 @@ export function Home() {
105
113
  } = useBestRouteStore();
106
114
 
107
115
  const {
108
- meta: { tokens },
116
+ meta: { tokens, blockchains },
109
117
  loadingStatus: loadingMetaStatus,
110
118
  } = useMetaStore();
111
119
 
@@ -160,7 +168,8 @@ export function Home() {
160
168
  fromToken?.symbol,
161
169
  fromToken?.address
162
170
  )?.amount || '0',
163
- BALANCE_PRECISION
171
+ BALANCE_MIN_DECIMALS,
172
+ BALANCE_MAX_DECIMALS
164
173
  )
165
174
  : '0';
166
175
 
@@ -202,20 +211,26 @@ export function Home() {
202
211
  from: {
203
212
  token: { displayName: swap.from.symbol, image: swap.from.logo },
204
213
  chain: {
205
- displayName: swap.from.blockchain,
214
+ displayName:
215
+ getBlockchainShortNameFor(swap.from.blockchain, blockchains) ?? '',
206
216
  image: swap.from.blockchainLogo,
207
217
  },
208
218
  price: {
209
219
  value:
210
220
  index === 0
211
- ? numberToString(inputAmount, MIN_DECIMAL, TWO_DECIMAL)
221
+ ? numberToString(
222
+ inputAmount,
223
+ TOKEN_AMOUNT_MIN_DECIMALS,
224
+ TOKEN_AMOUNT_MAX_DECIMALS
225
+ )
212
226
  : swap.fromAmount,
213
227
  },
214
228
  },
215
229
  to: {
216
230
  token: { displayName: swap.to.symbol, image: swap.to.logo },
217
231
  chain: {
218
- displayName: swap.to.blockchain,
232
+ displayName:
233
+ getBlockchainShortNameFor(swap.to.blockchain, blockchains) ?? '',
219
234
  image: swap.to.blockchainLogo,
220
235
  },
221
236
  price: {
@@ -239,9 +254,18 @@ export function Home() {
239
254
  </Typography>
240
255
  <Divider direction="horizontal" size={8} />
241
256
  <Typography size="xsmall" variant="body" color="neutral900">
242
- {`Yours: ${numberToString(
243
- swapHasError?.fromAmount || null
244
- )} ${swap?.from.symbol}`}
257
+ {i18n.t({
258
+ id: 'yourSymbol',
259
+ message: 'Yours: {amount} {symbol}',
260
+ values: {
261
+ amount: numberToString(
262
+ swapHasError?.fromAmount || null,
263
+ TOKEN_AMOUNT_MIN_DECIMALS,
264
+ TOKEN_AMOUNT_MAX_DECIMALS
265
+ ),
266
+ symbol: swap?.from.symbol,
267
+ },
268
+ })}
245
269
  </Typography>
246
270
  </FooterAlert>
247
271
  }
@@ -253,7 +277,7 @@ export function Home() {
253
277
 
254
278
  const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
255
279
 
256
- const bestRouteData = getFormatedBestRoute(bestRoute);
280
+ const bestRouteData = getFormattedBestRoute(bestRoute);
257
281
 
258
282
  return (
259
283
  <Layout
@@ -300,7 +324,8 @@ export function Home() {
300
324
  <InputsContainer>
301
325
  <FromContainer>
302
326
  <SwapInput
303
- label="From"
327
+ label={i18n.t('From')}
328
+ mode="From"
304
329
  onInputChange={setInputAmount}
305
330
  balance={tokenBalance}
306
331
  chain={{
@@ -316,9 +341,13 @@ export function Home() {
316
341
  value: inputAmount,
317
342
  usdValue: priceImpactInputCanNotBeComputed
318
343
  ? undefined
319
- : numberToString(inputUsdValue),
344
+ : numberToString(
345
+ inputUsdValue,
346
+ USD_VALUE_MIN_DECIMALS,
347
+ USD_VALUE_MAX_DECIMALS
348
+ ),
320
349
  error: priceImpactInputCanNotBeComputed
321
- ? errorMessages.unknownPriceError.impacTitle
350
+ ? errorMessages.unknownPriceError.impactTitle
322
351
  : undefined,
323
352
  }}
324
353
  disabled={loadingMetaStatus === 'failed'}
@@ -333,7 +362,8 @@ export function Home() {
333
362
  </FromContainer>
334
363
  <SwapInput
335
364
  sharpBottomStyle={!!bestRoute?.result || fetchingBestRoute}
336
- label="To"
365
+ label={i18n.t('To')}
366
+ mode="To"
337
367
  chain={{
338
368
  displayName: toBlockchain?.displayName || '',
339
369
  image: toBlockchain?.logo || '',
@@ -344,19 +374,31 @@ export function Home() {
344
374
  }}
345
375
  percentageChange={
346
376
  !!percentageChange?.lt(0)
347
- ? numberToString(percentageChange, MIN_DECIMAL, TWO_DECIMAL)
377
+ ? numberToString(
378
+ percentageChange,
379
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
380
+ PERCENTAGE_CHANGE_MAX_DECIMALS
381
+ )
348
382
  : null
349
383
  }
350
- warningLevel={
351
- !!percentageChange?.lt(WARNING_LEVEL_LIMIT) ? 'high' : 'low'
352
- }
384
+ warningLevel={getPriceImpactLevel(
385
+ percentageChange?.toNumber() ?? 0
386
+ )}
353
387
  price={{
354
- value: numberToString(outputAmount),
388
+ value: numberToString(
389
+ outputAmount,
390
+ TOKEN_AMOUNT_MIN_DECIMALS,
391
+ TOKEN_AMOUNT_MAX_DECIMALS
392
+ ),
355
393
  usdValue: priceImpactOutputCanNotBeComputed
356
394
  ? undefined
357
- : numberToString(outputUsdValue),
395
+ : numberToString(
396
+ outputUsdValue,
397
+ USD_VALUE_MIN_DECIMALS,
398
+ USD_VALUE_MAX_DECIMALS
399
+ ),
358
400
  error: priceImpactOutputCanNotBeComputed
359
- ? errorMessages.unknownPriceError.impacTitle
401
+ ? errorMessages.unknownPriceError.impactTitle
360
402
  : undefined,
361
403
  }}
362
404
  onClickToken={() => navigate('to-swap')}
@@ -376,22 +418,45 @@ export function Home() {
376
418
  <BestRoute
377
419
  type="basic"
378
420
  recommended={true}
421
+ tooltipContainer={getContainer()}
379
422
  input={{
380
- value: numberToString(inputAmount, MIN_DECIMAL, MAX_DECIMAL),
381
- usdValue: numberToString(inputUsdValue),
423
+ value: numberToString(
424
+ inputAmount,
425
+ TOKEN_AMOUNT_MIN_DECIMALS,
426
+ TOKEN_AMOUNT_MAX_DECIMALS
427
+ ),
428
+ usdValue: numberToString(
429
+ inputUsdValue,
430
+ USD_VALUE_MIN_DECIMALS,
431
+ USD_VALUE_MAX_DECIMALS
432
+ ),
382
433
  }}
383
434
  output={{
384
- value: numberToString(outputAmount),
385
- usdValue: numberToString(outputUsdValue),
435
+ value: numberToString(
436
+ outputAmount,
437
+ TOKEN_AMOUNT_MIN_DECIMALS,
438
+ TOKEN_AMOUNT_MAX_DECIMALS
439
+ ),
440
+ usdValue: numberToString(
441
+ outputUsdValue,
442
+ USD_VALUE_MIN_DECIMALS,
443
+ USD_VALUE_MAX_DECIMALS
444
+ ),
386
445
  }}
387
446
  steps={getBestRouteSteps(bestRouteData.result.swaps)}
388
447
  percentageChange={numberToString(
389
448
  percentageChange,
390
- MIN_DECIMAL,
391
- TWO_DECIMAL
449
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
450
+ PERCENTAGE_CHANGE_MAX_DECIMALS
451
+ )}
452
+ totalFee={numberToString(
453
+ totalFeeInUsd,
454
+ GAS_FEE_MIN_DECIMALS,
455
+ GAS_FEE_MAX_DECIMALS
456
+ )}
457
+ totalTime={secondsToString(
458
+ totalArrivalTime(bestRoute?.result?.swaps)
392
459
  )}
393
- totalFee={numberToString(totalFeeInUsd, MIN_DECIMAL, TWO_DECIMAL)}
394
- totalTime={secondsToString(totalArrivalTime(bestRoute))}
395
460
  />
396
461
  </BestRouteContainer>
397
462
  ) : showBestRoute && !fetchingBestRoute ? (
@@ -405,21 +470,20 @@ export function Home() {
405
470
  </>
406
471
  ) : null}
407
472
  </Container>
408
- {!fetchingBestRoute && (
409
- <RouteErrors
410
- openModal={openWarningModal}
411
- onToggle={setOpenWarningModal}
412
- totalFeeInUsd={totalFeeInUsd}
413
- outputUsdValue={outputUsdValue}
414
- inputUsdValue={inputUsdValue}
415
- percentageChange={percentageChange}
416
- highValueLoss={highValueLoss}
417
- priceImpactCanNotBeComputed={
418
- priceImpactInputCanNotBeComputed ||
419
- priceImpactOutputCanNotBeComputed
420
- }
421
- />
422
- )}
473
+ <RouteErrors
474
+ openModal={openWarningModal}
475
+ onToggle={setOpenWarningModal}
476
+ totalFeeInUsd={totalFeeInUsd}
477
+ outputUsdValue={outputUsdValue}
478
+ inputUsdValue={inputUsdValue}
479
+ percentageChange={percentageChange}
480
+ highValueLoss={highValueLoss}
481
+ priceImpactCanNotBeComputed={
482
+ priceImpactInputCanNotBeComputed || priceImpactOutputCanNotBeComputed
483
+ }
484
+ loading={fetchingBestRoute || loadingMetaStatus === 'loading'}
485
+ extraSpace={!!bestRoute?.result || !bestRoute}
486
+ />
423
487
  </Layout>
424
488
  );
425
489
  }
@@ -69,7 +69,7 @@ export function LanguagePage() {
69
69
  <List
70
70
  type={
71
71
  <ListItemButton
72
- title="language"
72
+ title={i18n.t('language')}
73
73
  id="_"
74
74
  onClick={() => console.log()}
75
75
  />
@@ -18,7 +18,6 @@ import { Layout } from '../components/Layout';
18
18
  import { LoadingLiquiditySourceList } from '../components/LoadingLiquiditySourceList';
19
19
  import { SearchInput } from '../components/SearchInput';
20
20
  import {
21
- LiquiditySourceDivider,
22
21
  LiquiditySourceList,
23
22
  LiquiditySourceSuffix,
24
23
  NotFoundContainer,
@@ -29,7 +28,10 @@ import { useNavigateBack } from '../hooks/useNavigateBack';
29
28
  import { useMetaStore } from '../store/meta';
30
29
  import { useSettingsStore } from '../store/settings';
31
30
  import { containsText } from '../utils/numbers';
32
- import { getUniqueSwappersGroups } from '../utils/settings';
31
+ import {
32
+ getUniqueSwappersGroups,
33
+ sortLiquiditySourcesByGroupTitle,
34
+ } from '../utils/settings';
33
35
 
34
36
  interface PropTypes {
35
37
  supportedSwappers?: string[];
@@ -77,20 +79,22 @@ export function LiquiditySourcePage({
77
79
  });
78
80
  };
79
81
 
80
- const list = liquiditySources.map((sourceItem) => {
81
- const { selected, groupTitle, logo } = sourceItem;
82
- return {
83
- start: <Image src={logo} size={22} type="circular" />,
84
- onClick: () => toggleLiquiditySource(groupTitle),
85
- end: <Checkbox checked={selected} />,
86
- title: (
87
- <Typography variant="title" size="xmedium">
88
- {i18n.t(groupTitle)}
89
- </Typography>
90
- ),
91
- ...sourceItem,
92
- };
93
- });
82
+ const list = liquiditySources
83
+ .sort(sortLiquiditySourcesByGroupTitle)
84
+ .map((sourceItem) => {
85
+ const { selected, groupTitle, logo } = sourceItem;
86
+ return {
87
+ start: <Image src={logo} size={22} type="circular" />,
88
+ onClick: () => toggleLiquiditySource(groupTitle),
89
+ end: <Checkbox checked={selected} />,
90
+ title: (
91
+ <Typography variant="title" size="xmedium">
92
+ {i18n.t(groupTitle)}
93
+ </Typography>
94
+ ),
95
+ ...sourceItem,
96
+ };
97
+ });
94
98
 
95
99
  const searchHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
96
100
  const value = event.target.value;
@@ -124,7 +128,7 @@ export function LiquiditySourcePage({
124
128
  fullWidth
125
129
  color="light"
126
130
  variant="contained"
127
- placeholder={i18n.t('Swap {sourceType}', { sourceType })}
131
+ placeholder={i18n.t('Search {sourceType}', { sourceType })}
128
132
  onChange={searchHandler}
129
133
  />
130
134
  {loadingMetaStatus === 'loading' && <LoadingLiquiditySourceList />}
@@ -146,8 +150,8 @@ export function LiquiditySourcePage({
146
150
  style={{ height: '61px' }}
147
151
  {...sourceItem}
148
152
  selected={false}
153
+ hasDivider
149
154
  />
150
- <LiquiditySourceDivider />
151
155
  </React.Fragment>
152
156
  );
153
157
  })}
@@ -1,50 +1,48 @@
1
1
  import { i18n } from '@lingui/core';
2
- import { Divider } from '@rango-dev/ui';
2
+ import { Divider, SelectableCategoryList } from '@rango-dev/ui';
3
3
  import React, { useState } from 'react';
4
4
 
5
5
  import { BlockchainList } from '../components/BlockchainList';
6
6
  import { Layout } from '../components/Layout';
7
7
  import { SearchInput } from '../components/SearchInput';
8
- import { SelectableCategoryList } from '../components/SelectableCategoryList';
9
8
  import { navigationRoutes } from '../constants/navigationRoutes';
10
9
  import { useNavigateBack } from '../hooks/useNavigateBack';
10
+ import { useAppStore } from '../store/app';
11
11
  import { useBestRouteStore } from '../store/bestRoute';
12
12
  import { useMetaStore } from '../store/meta';
13
13
 
14
14
  interface PropTypes {
15
- type: 'from' | 'to';
16
- supportedBlockchains?: string[];
15
+ type: 'source' | 'destination';
17
16
  }
18
17
 
19
18
  export function SelectBlockchainPage(props: PropTypes) {
20
- const { type, supportedBlockchains } = props;
19
+ const { type } = props;
21
20
  const { navigateBackFrom } = useNavigateBack();
22
21
  const [searchedFor, setSearchedFor] = useState<string>('');
23
22
  const [blockchainCategory, setBlockchainCategory] = useState<string>('ALL');
24
23
  const setToBlockchain = useBestRouteStore.use.setToBlockchain();
25
24
  const setFromBlockchain = useBestRouteStore.use.setFromBlockchain();
25
+ const { loadingStatus } = useMetaStore();
26
26
 
27
- const blockchains = supportedBlockchains
28
- ? useMetaStore.use
29
- .meta()
30
- .blockchains.filter((chain) =>
31
- supportedBlockchains.includes(chain.name)
32
- )
33
- : useMetaStore.use.meta().blockchains;
27
+ const blockchains = useAppStore().blockchains({
28
+ type: type,
29
+ });
30
+ const routeKey = type === 'source' ? 'fromBlockchain' : 'toBlockchain';
34
31
 
35
32
  return (
36
33
  <Layout
37
34
  header={{
38
- onBack: navigateBackFrom.bind(
39
- null,
40
- navigationRoutes[`${type}Blockchain`]
41
- ),
35
+ onBack: () => {
36
+ navigateBackFrom(navigationRoutes[routeKey]);
37
+ },
42
38
  title: i18n.t(`Select Blockchain`),
43
39
  }}>
44
40
  <Divider size={12} />
45
41
  <SelectableCategoryList
46
42
  setCategory={setBlockchainCategory}
47
43
  category={blockchainCategory}
44
+ blockchains={blockchains}
45
+ isLoading={loadingStatus === 'loading'}
48
46
  />
49
47
  <Divider size={24} />
50
48
  <SearchInput
@@ -64,12 +62,13 @@ export function SelectBlockchainPage(props: PropTypes) {
64
62
  searchedFor={searchedFor}
65
63
  blockchainCategory={blockchainCategory}
66
64
  onChange={(blockchain) => {
67
- if (type === 'from') {
68
- setFromBlockchain(blockchain, true);
65
+ if (type === 'source') {
66
+ setFromBlockchain(blockchain);
69
67
  } else {
70
- setToBlockchain(blockchain, true);
68
+ setToBlockchain(blockchain);
71
69
  }
72
- navigateBackFrom(navigationRoutes[`${type}Blockchain`]);
70
+
71
+ navigateBackFrom(navigationRoutes[routeKey]);
73
72
  }}
74
73
  />
75
74
  </Layout>
@@ -1,119 +1,100 @@
1
- /* eslint-disable @typescript-eslint/no-magic-numbers */
2
- import type { Asset } from 'rango-sdk';
1
+ import type { BlockchainMeta, Token } from 'rango-sdk';
3
2
 
4
3
  import { i18n } from '@lingui/core';
5
4
  import { Divider } from '@rango-dev/ui';
6
- import React, { useEffect, useState } from 'react';
5
+ import React, { useState } from 'react';
7
6
  import { useNavigate } from 'react-router-dom';
8
7
 
9
8
  import { BlockchainsSection } from '../components/BlockchainsSection';
10
9
  import { Layout } from '../components/Layout';
11
10
  import { SearchInput } from '../components/SearchInput';
12
11
  import { TokenList } from '../components/TokenList/TokenList';
13
- import { filterTokens } from '../components/TokenList/TokenList.helpers';
14
12
  import { navigationRoutes } from '../constants/navigationRoutes';
15
13
  import { useNavigateBack } from '../hooks/useNavigateBack';
14
+ import { useAppStore } from '../store/app';
16
15
  import { useBestRouteStore } from '../store/bestRoute';
17
- import { useMetaStore } from '../store/meta';
18
16
  import { useWalletsStore } from '../store/wallets';
19
- import { tokensAreEqual } from '../utils/wallets';
17
+ import { getTokensBalanceFromWalletAndSort } from '../utils/wallets';
20
18
 
21
19
  interface PropTypes {
22
- type: 'from' | 'to';
23
- supportedBlockchains?: string[];
24
- supportedTokens?: Asset[];
25
- pinnedTokens?: Asset[];
20
+ type: 'source' | 'destination';
26
21
  }
27
22
 
28
23
  export function SelectSwapItemsPage(props: PropTypes) {
29
- const { type, supportedBlockchains, supportedTokens, pinnedTokens } = props;
24
+ const { type } = props;
30
25
  const navigate = useNavigate();
31
26
  const { navigateBackFrom } = useNavigateBack();
32
- const { tokens } = useMetaStore.use.meta();
33
- const sourceTokens = useBestRouteStore.use.sourceTokens();
34
- const destinationTokens = useBestRouteStore.use.destinationTokens();
27
+ const {
28
+ fromBlockchain,
29
+ toBlockchain,
30
+ setFromToken,
31
+ setToToken,
32
+ setFromBlockchain,
33
+ setToBlockchain,
34
+ } = useBestRouteStore();
35
+ const { connectedWallets } = useWalletsStore();
35
36
  const [searchedFor, setSearchedFor] = useState<string>('');
36
- const setFromToken = useBestRouteStore.use.setFromToken();
37
- const setToToken = useBestRouteStore.use.setToToken();
38
- const setToBlockchain = useBestRouteStore.use.setToBlockchain();
39
- const setFromBlockchain = useBestRouteStore.use.setFromBlockchain();
40
- const toBlockchain = useBestRouteStore.use.toBlockchain();
41
- const fromBlockchain = useBestRouteStore.use.fromBlockchain();
42
- const connectedWallets = useWalletsStore.use.connectedWallets();
43
- const loadingWallet = useWalletsStore.use.loading();
44
- const setTokensWithBalance = useMetaStore.use.setTokensWithBalance();
45
37
 
46
- const blockchains = supportedBlockchains
47
- ? useMetaStore.use
48
- .meta()
49
- .blockchains.filter((chain) =>
50
- supportedBlockchains.includes(chain.name)
51
- )
52
- : useMetaStore.use.meta().blockchains;
53
- const allTokens = supportedTokens
54
- ? tokens.filter((token) =>
55
- tokens.some((supportedToken) => tokensAreEqual(supportedToken, token))
56
- )
57
- : tokens;
58
- const supportedSourceTokens = supportedTokens
59
- ? sourceTokens.filter((token) =>
60
- supportedTokens.some((supportedToken) =>
61
- tokensAreEqual(supportedToken, token)
62
- )
63
- )
64
- : sourceTokens;
38
+ const selectedBlockchain = type === 'source' ? fromBlockchain : toBlockchain;
39
+ const selectedBlockchainName = selectedBlockchain?.name ?? '';
65
40
 
66
- const supportedDestinationTokens = supportedTokens
67
- ? destinationTokens.filter((token) =>
68
- supportedTokens.some((supportedToken) =>
69
- tokensAreEqual(supportedToken, token)
70
- )
71
- )
72
- : destinationTokens;
73
-
74
- const tokensByType =
75
- type === 'from' ? supportedSourceTokens : supportedDestinationTokens;
76
-
77
- const tokenList = (tokensByType.length ? tokensByType : allTokens).map(
78
- (token) => ({
79
- ...token,
80
- pin: pinnedTokens?.some((pinnedToken) =>
81
- tokensAreEqual(pinnedToken, token)
82
- ),
83
- })
41
+ // Tokens & Blockchains list
42
+ const blockchains = useAppStore().blockchains({
43
+ type: type,
44
+ });
45
+ const tokens = useAppStore().tokens({
46
+ type,
47
+ blockchain: selectedBlockchainName,
48
+ searchFor: searchedFor,
49
+ });
50
+ const tokensList = getTokensBalanceFromWalletAndSort(
51
+ tokens,
52
+ connectedWallets
84
53
  );
85
54
 
86
- useEffect(() => {
87
- if (connectedWallets.length && !loadingWallet) {
88
- setTokensWithBalance();
55
+ // Actions
56
+ const updateBlockchain = (blockchain: BlockchainMeta) => {
57
+ if (type === 'source') {
58
+ setFromBlockchain(blockchain);
59
+ } else {
60
+ setToBlockchain(blockchain);
61
+ }
62
+ };
63
+
64
+ const updateToken = (token: Token) => {
65
+ if (type === 'source') {
66
+ setFromToken(token);
67
+ } else {
68
+ setToToken(token);
89
69
  }
90
- }, [connectedWallets, loadingWallet]);
70
+ };
91
71
 
92
72
  return (
93
73
  <Layout
94
74
  header={{
95
- onBack: navigateBackFrom.bind(null, navigationRoutes.home),
96
- title: i18n.t('Swap {type}', { type }),
75
+ onBack: () =>
76
+ navigateBackFrom(
77
+ type === 'source'
78
+ ? navigationRoutes.fromSwap
79
+ : navigationRoutes.toSwap
80
+ ),
81
+ title: i18n.t('Swap {type}', {
82
+ type: type === 'source' ? 'from' : 'to',
83
+ }),
97
84
  }}>
98
85
  <BlockchainsSection
99
86
  blockchains={blockchains}
100
- type={type}
101
- blockchain={type === 'from' ? fromBlockchain : toBlockchain}
87
+ type={type == 'source' ? 'from' : 'to'}
88
+ blockchain={type === 'source' ? fromBlockchain : toBlockchain}
102
89
  onMoreClick={() =>
103
90
  navigate(
104
- type === 'from'
91
+ type === 'source'
105
92
  ? navigationRoutes.fromBlockchain
106
93
  : navigationRoutes.toBlockchain
107
94
  )
108
95
  }
109
96
  onChange={(blockchain) => {
110
- {
111
- if (type === 'from') {
112
- setFromBlockchain(blockchain, true);
113
- } else {
114
- setToBlockchain(blockchain, true);
115
- }
116
- }
97
+ updateBlockchain(blockchain);
117
98
  }}
118
99
  />
119
100
  <Divider size={24} />
@@ -129,22 +110,19 @@ export function SelectSwapItemsPage(props: PropTypes) {
129
110
  />
130
111
  <Divider size={16} />
131
112
  <TokenList
132
- list={filterTokens(tokenList, searchedFor)}
113
+ list={tokensList}
114
+ selectedBlockchain={selectedBlockchainName}
115
+ searchedFor={searchedFor}
133
116
  onChange={(token) => {
134
- const blockchain = blockchains.find(
117
+ updateToken(token);
118
+
119
+ const tokenBlockchain = blockchains.find(
135
120
  (chain) => token.blockchain === chain.name
136
121
  );
137
- if (type === 'from') {
138
- setFromToken(token);
139
- if (!!blockchain) {
140
- setFromBlockchain(blockchain, true);
141
- }
142
- } else {
143
- setToToken(token);
144
- if (!!blockchain) {
145
- setToBlockchain(blockchain, true);
146
- }
122
+ if (tokenBlockchain) {
123
+ updateBlockchain(tokenBlockchain);
147
124
  }
125
+
148
126
  navigateBackFrom(navigationRoutes.fromSwap);
149
127
  }}
150
128
  />