@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
@@ -14,8 +14,8 @@ import {
14
14
  Divider,
15
15
  IconButton,
16
16
  RouteCost,
17
+ RouteSummary,
17
18
  StepDetails,
18
- TokenAmount,
19
19
  Typography,
20
20
  useCopyToClipboard,
21
21
  } from '@rango-dev/ui';
@@ -24,10 +24,26 @@ import React, { useEffect, useRef, useState } from 'react';
24
24
  import { useNavigate } from 'react-router-dom';
25
25
 
26
26
  import { navigationRoutes } from '../../constants/navigationRoutes';
27
+ import {
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';
27
37
  import { useNavigateBack } from '../../hooks/useNavigateBack';
28
38
  import { useBestRouteStore } from '../../store/bestRoute';
29
39
  import { useMetaStore } from '../../store/meta';
30
- import { numberToString } from '../../utils/numbers';
40
+ import { useNotificationStore } from '../../store/notification';
41
+ import {
42
+ numberToString,
43
+ secondsToString,
44
+ totalArrivalTime,
45
+ } from '../../utils/numbers';
46
+ import { getPriceImpactLevel } from '../../utils/routing';
31
47
  import {
32
48
  getLastConvertedTokenInFailedSwap,
33
49
  getPercentageChange,
@@ -43,48 +59,46 @@ import {
43
59
  SwapDetailsModal,
44
60
  } from '../SwapDetailsModal';
45
61
 
46
- import {
47
- AMOUNT_DECIMALS,
48
- getPriceImpactWarningLevel,
49
- getSteps,
50
- getStepState,
51
- MIN_DECIMALS,
52
- PERCENT_DECIMALS,
53
- RESET_INTERVAL,
54
- SECONDS,
55
- } from './SwapDetails.helpers';
56
- import {
57
- Container,
58
- HeaderDetails,
59
- Separator,
60
- StepsList,
61
- } from './SwapDetails.styles';
62
+ import { getSteps, getStepState, RESET_INTERVAL } from './SwapDetails.helpers';
63
+ import { Container, HeaderDetails, StepsList } from './SwapDetails.styles';
62
64
 
63
65
  export function SwapDetails(props: SwapDetailsProps) {
64
66
  const { swap, requestId, onDelete, onCancel: onCancelProps } = props;
65
- const { tokens } = useMetaStore.use.meta();
66
67
  const { canSwitchNetworkTo, connect, getWalletInfo } = useWallets();
67
68
  const retry = useBestRouteStore.use.retry();
68
69
  const navigate = useNavigate();
69
70
  const { navigateBackFrom } = useNavigateBack();
70
- const listRef = useRef(null);
71
71
  const [_, handleCopy] = useCopyToClipboard(RESET_INTERVAL);
72
+ const listRef = useRef<HTMLDivElement | null>(null);
72
73
  const [modalState, setModalState] = useState<ModalState>(null);
73
74
  const [showCompletedModal, setShowCompletedModal] = useState<
74
75
  'success' | 'failed' | null
75
76
  >(null);
77
+ const {
78
+ meta: { tokens, blockchains },
79
+ } = useMetaStore();
76
80
 
77
81
  const onCancel = () => {
78
82
  onCancelProps();
79
83
  setModalState(null);
80
84
  };
81
85
 
86
+ const getUnreadNotifications =
87
+ useNotificationStore.use.getUnreadNotifications();
88
+ const setAsRead = useNotificationStore.use.setAsRead();
89
+ const unreadNotifications = getUnreadNotifications();
82
90
  const currentStep = getCurrentStep(swap);
83
91
  const currentStepNetworkStatus = currentStep?.networkStatus;
84
92
 
85
93
  useEffect(() => {
86
- if (swap.status === 'success' || swap.status === 'failed') {
87
- setShowCompletedModal(swap.status);
94
+ const existNotification = unreadNotifications.find(
95
+ (n) => n.requestId === swap.requestId
96
+ );
97
+ if (existNotification) {
98
+ if (swap.status === 'success' || swap.status === 'failed') {
99
+ setShowCompletedModal(swap.status);
100
+ setAsRead(swap.requestId);
101
+ }
88
102
  }
89
103
  }, [swap.status]);
90
104
 
@@ -137,35 +151,31 @@ export function SwapDetails(props: SwapDetailsProps) {
137
151
  showNetworkModal: currentStepNetworkStatus,
138
152
  setNetworkModal: setModalState,
139
153
  message: stepMessage,
154
+ blockchains,
140
155
  });
141
156
  const numberOfSteps = steps.length;
142
157
  const [firstStep, lastStep] = [swap.steps[0], swap.steps[numberOfSteps - 1]];
143
158
  const outputAmount =
144
159
  lastStep.outputAmount || lastStep.expectedOutputAmountHumanReadable;
145
- const percentageChange =
146
- swap.inputAmount && outputAmount
147
- ? getPercentageChange(swap.inputAmount, outputAmount)
148
- : null;
149
160
 
150
161
  const totalFee = swap.steps.reduce(
151
162
  (totalFee, steps) => totalFee + parseFloat(steps.feeInUsd || ''),
152
163
  0
153
164
  );
154
165
 
155
- const totalTime = swap.steps.reduce(
156
- (totalTime, step) => totalTime + (step.estimatedTimeInSeconds || 0),
157
- 0
158
- );
159
-
160
- const minutes = Math.floor(totalTime / SECONDS);
161
-
162
166
  const diagnosisUrl = swap.steps.find(
163
167
  (step) => step.diagnosisUrl
164
168
  )?.diagnosisUrl;
165
169
 
166
170
  const outputUsdValue = numberToString(
167
171
  String(
168
- parseFloat(numberToString(outputAmount, MIN_DECIMALS, AMOUNT_DECIMALS)) *
172
+ parseFloat(
173
+ numberToString(
174
+ outputAmount,
175
+ TOKEN_AMOUNT_MIN_DECIMALS,
176
+ TOKEN_AMOUNT_MAX_DECIMALS
177
+ )
178
+ ) *
169
179
  (getUsdPrice(
170
180
  lastStep.toBlockchain,
171
181
  lastStep.toSymbol,
@@ -173,25 +183,58 @@ export function SwapDetails(props: SwapDetailsProps) {
173
183
  tokens
174
184
  ) || 0)
175
185
  ),
176
- MIN_DECIMALS,
177
- AMOUNT_DECIMALS
186
+ USD_VALUE_MIN_DECIMALS,
187
+ USD_VALUE_MAX_DECIMALS
188
+ );
189
+
190
+ const inputUsdValue = numberToString(
191
+ String(
192
+ parseFloat(swap.inputAmount) *
193
+ (getUsdPrice(
194
+ firstStep.fromBlockchain,
195
+ firstStep.fromSymbol,
196
+ firstStep.fromSymbolAddress,
197
+ tokens
198
+ ) || 0)
199
+ ),
200
+ USD_VALUE_MIN_DECIMALS,
201
+ USD_VALUE_MAX_DECIMALS
178
202
  );
179
203
 
204
+ const percentageChange = getPercentageChange(inputUsdValue, outputUsdValue);
205
+
180
206
  const completeModalDesc =
181
- showCompletedModal === 'success'
182
- ? `You have recieved ${numberToString(
183
- outputAmount,
184
- MIN_DECIMALS,
185
- AMOUNT_DECIMALS
186
- )} ${
187
- steps[numberOfSteps - 1].to.token.displayName
188
- } in ${getConciseAddress(
189
- swap.wallets[steps[numberOfSteps - 1].to.chain.displayName]
190
- ?.address || ''
191
- )} wallet on ${steps[numberOfSteps - 1].to.chain.displayName} chain.`
207
+ swap.status === 'success'
208
+ ? i18n.t({
209
+ id: 'receivedMessage',
210
+ message:
211
+ 'You have received {amount} {token} in {conciseAddress} wallet on {chain} chain.',
212
+ values: {
213
+ amount: numberToString(
214
+ outputAmount,
215
+ TOKEN_AMOUNT_MIN_DECIMALS,
216
+ TOKEN_AMOUNT_MAX_DECIMALS
217
+ ),
218
+ token: steps[numberOfSteps - 1].to.token.displayName,
219
+ conciseAddress: getConciseAddress(
220
+ swap.wallets[steps[numberOfSteps - 1].to.chain.displayName]
221
+ ?.address || ''
222
+ ),
223
+ chain: steps[numberOfSteps - 1].to.chain.displayName,
224
+ },
225
+ })
192
226
  : `${i18n.t('Transaction was not sent.')} ${
193
227
  lastConvertedTokenInFailedSwap
194
- ? `${lastConvertedTokenInFailedSwap.outputAmount} ${lastConvertedTokenInFailedSwap.symbol} on ${lastConvertedTokenInFailedSwap.blockchain} remain in your wallet`
228
+ ? i18n.t({
229
+ id: 'remainSymbol',
230
+ message:
231
+ '{amount} {symbol} on {blockchain} remain in your wallet',
232
+ values: {
233
+ amount: lastConvertedTokenInFailedSwap.outputAmount,
234
+ symbol: lastConvertedTokenInFailedSwap.symbol,
235
+ blockchain: lastConvertedTokenInFailedSwap.blockchain,
236
+ },
237
+ })
195
238
  : ''
196
239
  }`;
197
240
 
@@ -261,68 +304,62 @@ export function SwapDetails(props: SwapDetailsProps) {
261
304
  </Typography>
262
305
  </div>
263
306
  </HeaderDetails>
307
+
264
308
  <div className="output">
265
309
  <RouteCost
266
310
  fee={numberToString(
267
311
  String(totalFee),
268
- AMOUNT_DECIMALS,
269
- AMOUNT_DECIMALS
312
+ GAS_FEE_MIN_DECIMALS,
313
+ GAS_FEE_MAX_DECIMALS
270
314
  )}
271
- time={minutes}
315
+ time={secondsToString(totalArrivalTime(swap.steps))}
272
316
  steps={numberOfSteps}
273
317
  />
274
- <TokenAmount
275
- direction="horizontal"
276
- type="input"
277
- price={{
278
- value: numberToString(
279
- swap.inputAmount,
280
- AMOUNT_DECIMALS,
281
- AMOUNT_DECIMALS
282
- ),
283
- usdValue: numberToString(
284
- String(
285
- parseFloat(swap.inputAmount) *
286
- (getUsdPrice(
287
- firstStep.fromBlockchain,
288
- firstStep.fromSymbol,
289
- firstStep.fromSymbolAddress,
290
- tokens
291
- ) || 0)
318
+ <RouteSummary
319
+ from={{
320
+ price: {
321
+ value: numberToString(
322
+ swap.inputAmount,
323
+ TOKEN_AMOUNT_MIN_DECIMALS,
324
+ TOKEN_AMOUNT_MAX_DECIMALS
292
325
  ),
293
- MIN_DECIMALS,
294
- AMOUNT_DECIMALS
295
- ),
296
- }}
297
- token={{
298
- displayName: steps[0].from.token.displayName,
299
- image: steps[0].from.token.image,
326
+ usdValue: inputUsdValue,
327
+ },
328
+ token: {
329
+ displayName: steps[0].from.token.displayName,
330
+ image: steps[0].from.token.image,
331
+ },
332
+ chain: {
333
+ image: steps[0].from.chain.image,
334
+ displayName: steps[0].from.chain.displayName,
335
+ },
300
336
  }}
301
- chain={{ image: steps[0].from.chain.image }}
302
- />
303
- <Separator />
304
- <TokenAmount
305
- direction="horizontal"
306
- type="output"
307
- price={{
308
- value: numberToString(
309
- outputAmount,
310
- MIN_DECIMALS,
311
- AMOUNT_DECIMALS
312
- ),
313
- usdValue: outputUsdValue,
314
- }}
315
- token={{
316
- displayName: steps[numberOfSteps - 1].to.token.displayName,
317
- image: steps[numberOfSteps - 1].to.token.image,
337
+ to={{
338
+ price: {
339
+ value: numberToString(
340
+ outputAmount,
341
+ TOKEN_AMOUNT_MIN_DECIMALS,
342
+ TOKEN_AMOUNT_MAX_DECIMALS
343
+ ),
344
+ usdValue: outputUsdValue,
345
+ },
346
+ token: {
347
+ displayName: steps[numberOfSteps - 1].to.token.displayName,
348
+ image: steps[numberOfSteps - 1].to.token.image,
349
+ },
350
+ chain: {
351
+ image: steps[numberOfSteps - 1].to.chain.image,
352
+ displayName: steps[numberOfSteps - 1].to.chain.displayName,
353
+ },
318
354
  }}
319
- chain={{ image: steps[numberOfSteps - 1].to.chain.image }}
320
355
  percentageChange={numberToString(
321
356
  percentageChange,
322
- PERCENT_DECIMALS,
323
- PERCENT_DECIMALS
357
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
358
+ PERCENTAGE_CHANGE_MAX_DECIMALS
359
+ )}
360
+ warningLevel={getPriceImpactLevel(
361
+ percentageChange?.toNumber() ?? 0
324
362
  )}
325
- warningLevel={getPriceImpactWarningLevel(percentageChange)}
326
363
  />
327
364
  </div>
328
365
  <div className="title-steps">
@@ -355,6 +392,7 @@ export function SwapDetails(props: SwapDetailsProps) {
355
392
  })}
356
393
  </StepsList>
357
394
  </Container>
395
+
358
396
  <SwapDetailsModal
359
397
  state={modalState}
360
398
  onClose={() => setModalState(null)}
@@ -367,13 +405,17 @@ export function SwapDetails(props: SwapDetailsProps) {
367
405
  open={!!showCompletedModal}
368
406
  diagnosisUrl={diagnosisUrl}
369
407
  onClose={() => setShowCompletedModal(null)}
370
- status={showCompletedModal}
371
- priceValue={numberToString(outputAmount, MIN_DECIMALS, AMOUNT_DECIMALS)}
408
+ status={swap.status === 'success' ? 'success' : 'failed'}
409
+ priceValue={numberToString(
410
+ outputAmount,
411
+ TOKEN_AMOUNT_MIN_DECIMALS,
412
+ TOKEN_AMOUNT_MAX_DECIMALS
413
+ )}
372
414
  usdValue={outputUsdValue}
373
415
  percentageChange={numberToString(
374
416
  percentageChange,
375
- PERCENT_DECIMALS,
376
- PERCENT_DECIMALS
417
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
418
+ PERCENTAGE_CHANGE_MAX_DECIMALS
377
419
  )}
378
420
  token={{
379
421
  displayName: steps[numberOfSteps - 1].to.token.displayName,
@@ -8,5 +8,5 @@ export interface SwapDetailsProps {
8
8
  }
9
9
  export interface SwapDetailsPlaceholderPropTypes {
10
10
  requestId: string;
11
- loading: boolean;
11
+ showSkeleton: boolean;
12
12
  }
@@ -2,6 +2,7 @@ import type { getSwapMessages } from '../../utils/swap';
2
2
  import type { ModalState } from '../SwapDetailsModal';
3
3
  import type { ConnectResult } from '@rango-dev/wallets-react';
4
4
  import type {
5
+ BlockchainMeta,
5
6
  PendingSwap,
6
7
  PendingSwapNetworkStatus,
7
8
  PendingSwapStep,
@@ -22,7 +23,7 @@ export interface FailedAlertsProps {
22
23
  message: ReturnType<typeof getSwapMessages>;
23
24
  }
24
25
 
25
- export type GetStep = { swap: PendingSwap } & Omit<
26
- SwapAlertsProps,
27
- 'step' | 'hasAlreadyProceededToSign'
28
- >;
26
+ export type GetStep = {
27
+ swap: PendingSwap;
28
+ blockchains: BlockchainMeta[];
29
+ } & Omit<SwapAlertsProps, 'step' | 'hasAlreadyProceededToSign'>;
@@ -4,14 +4,12 @@ import { MessageBox, Wallet, WalletState } from '@rango-dev/ui';
4
4
  import { useWallets } from '@rango-dev/wallets-react';
5
5
  import React from 'react';
6
6
 
7
+ import { getContainer } from '../../utils/common';
8
+
7
9
  import { WalletContainer } from './SwapDetailsModal.styles';
8
10
 
9
- export const WalletStateContent = ({
10
- type,
11
- title,
12
- currentStepWallet,
13
- message,
14
- }: WalletStateContentProps) => {
11
+ export const WalletStateContent = (props: WalletStateContentProps) => {
12
+ const { type, title, currentStepWallet, message, showWalletButton } = props;
15
13
  const { connect, getWalletInfo, state: walletState } = useWallets();
16
14
  const walletType = currentStepWallet?.walletType;
17
15
  const isConnected = walletType && walletState(walletType).connected;
@@ -19,9 +17,10 @@ export const WalletStateContent = ({
19
17
  return (
20
18
  <>
21
19
  <MessageBox type={type} title={title} description={message} />
22
- {walletType && (
20
+ {showWalletButton && walletType && (
23
21
  <WalletContainer>
24
22
  <Wallet
23
+ container={getContainer()}
25
24
  title={getWalletInfo(walletType).name}
26
25
  image={getWalletInfo(walletType).img}
27
26
  type={walletType}
@@ -29,6 +29,9 @@ export function SwapDetailsModal(props: ModalPropTypes) {
29
29
  title={modalNetworkValues[state].title}
30
30
  currentStepWallet={currentStepWallet}
31
31
  message={message}
32
+ showWalletButton={
33
+ state !== PendingSwapNetworkStatus.WaitingForNetworkChange
34
+ }
32
35
  />
33
36
  )}
34
37
  {state === 'delete' && (
@@ -22,7 +22,7 @@ export interface ModalPropTypes {
22
22
  export interface CompleteModalPropTypes {
23
23
  open: boolean;
24
24
  onClose: () => void;
25
- status: 'success' | 'failed' | null;
25
+ status: 'success' | 'failed';
26
26
  priceValue: string;
27
27
  usdValue: string;
28
28
  percentageChange: string;
@@ -46,6 +46,7 @@ export interface ModalNetworkValueTypes {
46
46
  export interface WalletStateContentProps extends ModalNetworkValueTypes {
47
47
  currentStepWallet: WalletTypeAndAddress | null;
48
48
  message: string;
49
+ showWalletButton: boolean;
49
50
  }
50
51
 
51
52
  export type CancelContentProps = Pick<ModalPropTypes, 'onClose' | 'onCancel'>;
@@ -1,5 +1,6 @@
1
1
  import type { PropTypes } from './SwapsGroup.types';
2
2
 
3
+ import { i18n } from '@lingui/core';
3
4
  import { Divider, SwapListItem, Typography } from '@rango-dev/ui';
4
5
  import React from 'react';
5
6
 
@@ -35,7 +36,7 @@ export function SwapsGroup(props: PropTypes) {
35
36
  size="medium"
36
37
  color="neutral800"
37
38
  className="group-title">
38
- {group.title}
39
+ {i18n.t(group.title)}
39
40
  </Typography>
40
41
  </Time>
41
42
  <Divider size={4} />
@@ -69,7 +70,7 @@ export function SwapsGroup(props: PropTypes) {
69
70
  size="medium"
70
71
  color="neutral800"
71
72
  className="group-title">
72
- {group.title}
73
+ {i18n.t(group.title)}
73
74
  </Typography>
74
75
  </Time>
75
76
  <Divider size={4} />
@@ -1,38 +1,8 @@
1
1
  import { ReverseIcon, styled } from '@rango-dev/ui';
2
- import React, { useEffect, useRef, useState } from 'react';
3
- import { useInRouterContext, useSearchParams } from 'react-router-dom';
2
+ import React from 'react';
4
3
 
5
- import { SearchParams } from '../constants/searchParams';
6
4
  import { useBestRouteStore } from '../store/bestRoute';
7
5
 
8
- function SwitchFromAndTo({ count }: { count: number }) {
9
- const firstRender = useRef(true);
10
- const [searchParams, setSearchParams] = useSearchParams();
11
- const outputAmount = useBestRouteStore.use.outputAmount();
12
-
13
- useEffect(() => {
14
- if (!firstRender.current) {
15
- const fromChainString = searchParams.get(SearchParams.FROM_CHAIN);
16
- const fromTokenString = searchParams.get(SearchParams.FROM_TOKEN);
17
- const toChainString = searchParams.get(SearchParams.TO_CHAIN);
18
- const toTokenString = searchParams.get(SearchParams.TO_TOKEN);
19
- setSearchParams({
20
- ...(toChainString && { [SearchParams.FROM_CHAIN]: toChainString }),
21
- ...(toTokenString && { [SearchParams.FROM_TOKEN]: toTokenString }),
22
- ...(fromChainString && { [SearchParams.TO_CHAIN]: fromChainString }),
23
- ...(fromTokenString && { [SearchParams.TO_TOKEN]: fromTokenString }),
24
- ...(outputAmount && {
25
- [SearchParams.FROM_AMOUNT]: outputAmount.toString(),
26
- }),
27
- });
28
- } else {
29
- firstRender.current = false;
30
- }
31
- }, [count]);
32
-
33
- return null;
34
- }
35
-
36
6
  const SwitchButtonContainer = styled('div', {
37
7
  position: 'absolute',
38
8
  bottom: '-12px',
@@ -58,18 +28,14 @@ const StyledButton = styled('div', {
58
28
 
59
29
  export function SwitchFromAndToButton() {
60
30
  const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
61
- const isRouterInContext = useInRouterContext();
62
- const [count, setCount] = useState(0);
63
31
 
64
32
  return (
65
33
  <SwitchButtonContainer>
66
34
  <StyledButton
67
35
  onClick={() => {
68
36
  switchFromAndTo();
69
- setCount((prev) => prev + 1);
70
37
  }}>
71
38
  <ReverseIcon size={12} />
72
- {isRouterInContext && <SwitchFromAndTo count={count} />}
73
39
  </StyledButton>
74
40
  </SwitchButtonContainer>
75
41
  );
@@ -3,11 +3,9 @@ import type { TokenWithBalance } from './TokenList.types';
3
3
  import { containsText } from '../../utils/common';
4
4
 
5
5
  export const filterTokens = (list: TokenWithBalance[], searchedFor: string) =>
6
- list
7
- .filter(
8
- (token) =>
9
- containsText(token.symbol, searchedFor) ||
10
- containsText(token.address || '', searchedFor) ||
11
- containsText(token.name || '', searchedFor)
12
- )
13
- .sort((a, b) => (b.pin as any) - (a.pin as any));
6
+ list.filter(
7
+ (token) =>
8
+ containsText(token.symbol, searchedFor) ||
9
+ containsText(token.address || '', searchedFor) ||
10
+ containsText(token.name || '', searchedFor)
11
+ );
@@ -1,5 +1,11 @@
1
1
  import { styled, Typography } from '@rango-dev/ui';
2
2
 
3
+ export const Container = styled('div', {
4
+ display: 'flex',
5
+ flexDirection: 'column',
6
+ flexGrow: 1,
7
+ });
8
+
3
9
  export const Title = styled('div', {
4
10
  display: 'flex',
5
11
  alignItems: 'center',
@@ -11,7 +17,7 @@ export const Title = styled('div', {
11
17
  },
12
18
  });
13
19
  export const List = styled('ul', {
14
- minHeight: 280,
20
+ flexGrow: 1,
15
21
  padding: 0,
16
22
  margin: 0,
17
23
  listStyle: 'none',