@rango-dev/widget-embedded 0.12.1-next.9 → 0.14.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 +4 -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
@@ -1,87 +1,53 @@
1
- import { darkTheme, lightTheme } from '@rango-dev/ui';
2
- import { useState, useEffect, useLayoutEffect } from 'react';
1
+ import type { WidgetTheme } from '../types';
2
+
3
+ import { createTheme, darkTheme, lightTheme } from '@rango-dev/ui';
4
+ import { useEffect, useState } from 'react';
5
+
3
6
  import { useMetaStore } from '../store/meta';
4
7
  import { useSettingsStore } from '../store/settings';
5
- import { WidgetTheme } from '../types';
6
- import usePrevious from './usePrevious';
8
+ import {
9
+ DEFAULT_PRIMARY_RADIUS,
10
+ DEFAULT_SECONDARY_RADIUS,
11
+ } from '../utils/configs';
7
12
 
8
13
  export function useTheme({
9
14
  // colors,
10
15
  fontFamily = 'Roboto',
11
- // borderRadius = 8,
16
+ borderRadius = DEFAULT_PRIMARY_RADIUS,
17
+ secondaryBorderRadius = DEFAULT_SECONDARY_RADIUS,
12
18
  mode = 'auto',
13
19
  }: WidgetTheme) {
14
20
  const theme = useSettingsStore.use.theme();
15
21
  const fetchMeta = useMetaStore.use.fetchMeta();
16
22
  const setTheme = useSettingsStore.use.setTheme();
17
- // const light = themeColors?.light;
18
- // const dark = themeColors?.dark;
19
- // const neutral = light?.neutral || '#fafafa';
20
- // const background = light?.background || '#fff';
21
- // const foreground = light?.foreground || '#000';
22
23
 
23
- // const darkColors = {
24
- // ...generateRangeColors('primary', 'dark', dark?.primary),
25
- // ...generateRangeColors('error', 'dark', dark?.error),
26
- // ...generateRangeColors('warning', 'dark', dark?.warning),
27
- // ...generateRangeColors('success', 'dark', dark?.success),
28
- // ...generateRangeColors('neutral', 'dark', dark?.neutral),
29
- // surface: dark?.surface,
30
- // background: dark?.background,
31
- // foreground: dark?.foreground,
32
- // };
24
+ const customTheme = createTheme({
25
+ radii: {
26
+ primary: `${borderRadius}px`,
27
+ secondary: `${secondaryBorderRadius}px`,
28
+ },
29
+ fonts: {
30
+ widget: fontFamily,
31
+ },
32
+ });
33
33
 
34
- // const lightColors = {
35
- // surface: light?.surface || '#fff',
36
- // ...generateRangeColors('primary', 'light', light?.primary || '#5FA425'),
37
- // ...generateRangeColors('error', 'light', light?.error || '#FF0000'),
38
- // ...generateRangeColors('warning', 'light', light?.warning || '#F5A623'),
39
- // ...generateRangeColors('success', 'light', light?.success || '#0070F3'),
40
- // ...generateRangeColors('neutral', 'light', neutral),
41
- // background,
42
- // foreground,
43
- // };
34
+ const lightClassName = `${customTheme.className} ${lightTheme.className}`;
35
+ const darkClassName = `${customTheme.className} ${darkTheme.className}`;
44
36
 
45
- // const customLightTheme = createTheme({
46
- // colors: lightColors,
47
- // radii: {
48
- // xs: `${borderRadius}px`,
49
- // },
50
- // shadows: {
51
- // s: `0px 3px 5px 3px ${light?.neutral || '#f0f2f5'} ,0px 6px 10px 3px ${
52
- // light?.neutral || '#f0f2f5'
53
- // }, 0px 1px 18px 3px ${light?.neutral || '#f0f2f5'}`,
54
- // },
55
- // });
56
-
57
- // const customDarkTheme = createTheme({
58
- // colors: {
59
- // ...lightColors,
60
- // ...generateRangeColors('neutral', 'dark', '#111111'),
61
- // foreground: background,
62
- // background: foreground,
63
- // surface: '#000',
64
- // ...JSON.parse(JSON.stringify(darkColors)),
65
- // },
66
- // radii: {
67
- // xs: `${borderRadius}px`,
68
- // },
69
- // shadows: {
70
- // s: `0px 3px 5px 3px ${dark?.neutral || '#222'}, 0px 6px 10px 3px ${
71
- // dark?.neutral || '#222'
72
- // }, 0px 1px 18px 3px ${dark?.neutral || '#222'}`,
73
- // },
74
- // });
75
37
  const [OSTheme, setOSTheme] = useState('light');
76
38
 
77
39
  useEffect(() => {
78
- (async () => {
40
+ const fetchData = async () => {
79
41
  await fetchMeta();
80
- })();
42
+ };
43
+ void fetchData();
81
44
 
82
45
  const switchTheme = (event: MediaQueryListEvent) => {
83
- if (event.matches) setOSTheme('dark');
84
- else setOSTheme('light');
46
+ if (event.matches) {
47
+ setOSTheme('dark');
48
+ } else {
49
+ setOSTheme('light');
50
+ }
85
51
  };
86
52
 
87
53
  if (
@@ -101,20 +67,16 @@ export function useTheme({
101
67
  };
102
68
  }, []);
103
69
  useEffect(() => {
104
- if (mode !== 'auto') setTheme(mode);
70
+ if (mode !== 'auto') {
71
+ setTheme(mode);
72
+ }
105
73
  }, [mode]);
106
- const prevFont = usePrevious(fontFamily);
107
-
108
- useLayoutEffect(() => {
109
- const { classList } = document.body;
110
-
111
- if (prevFont) classList.remove(`font_${prevFont.replace(/ /g, '')}`);
112
- classList.add(`font_${fontFamily.replace(/ /g, '')}`);
113
- }, [fontFamily]);
114
74
 
115
75
  const getActiveTheme = () => {
116
- if (theme === 'auto') return OSTheme === 'dark' ? darkTheme : lightTheme;
117
- else return theme === 'dark' ? darkTheme : lightTheme;
76
+ if (theme === 'auto') {
77
+ return OSTheme === 'dark' ? darkClassName : lightClassName;
78
+ }
79
+ return theme === 'dark' ? darkClassName : lightClassName;
118
80
  };
119
81
 
120
82
  return { activeTheme: getActiveTheme() };
@@ -1,11 +1,11 @@
1
- import { ProviderInterface } from '@rango-dev/wallets-react';
1
+ import type { WidgetConfig } from '../types';
2
+ import type { ProvidersOptions } from '../utils/providers';
3
+ import type { ProviderInterface } from '@rango-dev/wallets-react';
4
+
2
5
  import { useEffect } from 'react';
6
+
3
7
  import { useWalletsStore } from '../store/wallets';
4
- import { WidgetConfig } from '../types';
5
- import {
6
- matchAndGenerateProviders,
7
- ProvidersOptions,
8
- } from '../utils/providers';
8
+ import { matchAndGenerateProviders } from '../utils/providers';
9
9
 
10
10
  export function useWalletProviders(
11
11
  providers: WidgetConfig['wallets'],
@@ -22,7 +22,7 @@ export function useWalletProviders(
22
22
  generateProviders = matchAndGenerateProviders(providers, {
23
23
  walletConnectProjectId: options?.walletConnectProjectId,
24
24
  });
25
- }, [providers]);
25
+ }, [providers?.length]);
26
26
 
27
27
  return {
28
28
  providers: generateProviders,
@@ -4,7 +4,6 @@ import type {
4
4
  ConfirmSwapFetchResult,
5
5
  } from '../hooks/useConfirmSwap';
6
6
  import type { WidgetConfig } from '../types';
7
- import type { PriceImpactWarningLevel } from '@rango-dev/ui/dist/widget/ui/src/components/PriceImpact/PriceImpact.types';
8
7
 
9
8
  import { i18n } from '@lingui/core';
10
9
  import { useManager } from '@rango-dev/queue-manager-react';
@@ -38,7 +37,16 @@ import { Layout } from '../components/Layout';
38
37
  import { NoRoutes } from '../components/NoRoutes';
39
38
  import { getConfirmSwapErrorMessage } from '../constants/errors';
40
39
  import { navigationRoutes } from '../constants/navigationRoutes';
41
- import { HIGHT_PRICE_IMPACT, LOW_PRICE_IMPACT } from '../constants/routing';
40
+ import {
41
+ GAS_FEE_MAX_DECIMALS,
42
+ GAS_FEE_MIN_DECIMALS,
43
+ PERCENTAGE_CHANGE_MAX_DECIMALS,
44
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
45
+ TOKEN_AMOUNT_MAX_DECIMALS,
46
+ TOKEN_AMOUNT_MIN_DECIMALS,
47
+ USD_VALUE_MAX_DECIMALS,
48
+ USD_VALUE_MIN_DECIMALS,
49
+ } from '../constants/routing';
42
50
  import { getRouteWarningMessage } from '../constants/warnings';
43
51
  import { useConfirmSwap } from '../hooks/useConfirmSwap';
44
52
  import { useBestRouteStore } from '../store/bestRoute';
@@ -51,11 +59,13 @@ import {
51
59
  RouteWarningType,
52
60
  SlippageWarningType,
53
61
  } from '../types';
62
+ import { getContainer } from '../utils/common';
54
63
  import {
55
64
  numberToString,
56
65
  secondsToString,
57
66
  totalArrivalTime,
58
67
  } from '../utils/numbers';
68
+ import { getPriceImpactLevel } from '../utils/routing';
59
69
  import { getPercentageChange, getTotalFeeInUsd } from '../utils/swap';
60
70
 
61
71
  const Container = styled('div', {
@@ -117,7 +127,10 @@ export function ConfirmSwapPage(props: PropTypes) {
117
127
  const showWalletsOnInit = !routeWalletsConfirmed;
118
128
  const [showWallets, setShowWallets] = useState(false);
119
129
  const setSelectedSwap = useUiStore.use.setSelectedSwap();
120
- const { tokens } = useMetaStore.use.meta();
130
+ const {
131
+ meta: { tokens, blockchains },
132
+ loadingStatus: loadingMetaStatus,
133
+ } = useMetaStore();
121
134
  const slippage = useSettingsStore.use.slippage();
122
135
  const customSlippage = useSettingsStore.use.customSlippage();
123
136
  const { manager } = useManager();
@@ -133,6 +146,8 @@ export function ConfirmSwapPage(props: PropTypes) {
133
146
  error: null,
134
147
  warnings: null,
135
148
  });
149
+ const showSkeleton =
150
+ fetchingConfirmationRoute || loadingMetaStatus === 'loading';
136
151
  const showNoRouteFound =
137
152
  !fetchingConfirmationRoute &&
138
153
  confirmSwapResult.error &&
@@ -152,15 +167,11 @@ export function ConfirmSwapPage(props: PropTypes) {
152
167
  inputUsdValue?.toNumber() ?? 0,
153
168
  outputUsdValue?.toNumber() ?? 0
154
169
  ),
155
- 2,
156
- 2
170
+ PERCENTAGE_CHANGE_MIN_DECIMALS,
171
+ PERCENTAGE_CHANGE_MAX_DECIMALS
157
172
  );
158
- let warningLevel: PriceImpactWarningLevel = undefined;
159
- if (parseFloat(percentageChange) >= HIGHT_PRICE_IMPACT) {
160
- warningLevel = 'high';
161
- } else if (parseFloat(percentageChange) >= LOW_PRICE_IMPACT) {
162
- warningLevel = 'low';
163
- }
173
+
174
+ const warningLevel = getPriceImpactLevel(parseFloat(percentageChange));
164
175
 
165
176
  const onConfirmSwap: ConfirmSwap['fetch'] = async ({
166
177
  selectedWallets,
@@ -240,12 +251,6 @@ export function ConfirmSwapPage(props: PropTypes) {
240
251
  }
241
252
  }, []);
242
253
 
243
- useEffect(() => {
244
- if (!showWallets && !routeWalletsConfirmed) {
245
- navigate(navigationRoutes.home, { replace: true });
246
- }
247
- }, [showWallets, routeWalletsConfirmed]);
248
-
249
254
  useEffect(() => {
250
255
  const routeChanged =
251
256
  confirmSwapResult.warnings?.route?.type &&
@@ -309,11 +314,14 @@ export function ConfirmSwapPage(props: PropTypes) {
309
314
  return (
310
315
  <Layout
311
316
  header={{
312
- title: 'Confirm Swap',
317
+ title: i18n.t('Confirm Swap'),
313
318
  onBack: navigate.bind(null, -1),
314
319
  hasConnectWallet: true,
315
320
  suffix: (
316
- <Tooltip side="bottom" content={i18n.t('Settings')}>
321
+ <Tooltip
322
+ container={getContainer()}
323
+ side="bottom"
324
+ content={i18n.t('Settings')}>
317
325
  <HeaderButton
318
326
  size="small"
319
327
  variant="ghost"
@@ -334,7 +342,7 @@ export function ConfirmSwapPage(props: PropTypes) {
334
342
  loading={fetchingConfirmationRoute}
335
343
  disabled={!!confirmSwapResult.error}
336
344
  onClick={onStartConfirmSwap}>
337
- Start Swap
345
+ {i18n.t('Start Swap')}
338
346
  </Button>
339
347
  </div>
340
348
  <IconButton
@@ -356,7 +364,7 @@ export function ConfirmSwapPage(props: PropTypes) {
356
364
  variant="ghost"
357
365
  onClick={() => navigate('/' + navigationRoutes.settings)}>
358
366
  <Typography variant="label" size="medium" color="$neutral900">
359
- Change settings
367
+ {i18n.t('Change settings')}
360
368
  </Typography>
361
369
  </Button>
362
370
  }
@@ -368,8 +376,8 @@ export function ConfirmSwapPage(props: PropTypes) {
368
376
  title={
369
377
  confirmSwapResult.warnings.slippage.type ===
370
378
  SlippageWarningType.HIGH_SLIPPAGE
371
- ? 'High slippage'
372
- : 'Low slippage'
379
+ ? i18n.t('High slippage')
380
+ : i18n.t('Low slippage')
373
381
  }
374
382
  description={
375
383
  confirmSwapResult.warnings.slippage.type ===
@@ -403,7 +411,7 @@ export function ConfirmSwapPage(props: PropTypes) {
403
411
  variant="contained"
404
412
  fullWidth
405
413
  onClick={onConfirm}>
406
- Confirm anyway
414
+ {i18n.t('Confirm anyway')}
407
415
  </Button>
408
416
  </MessageBox>
409
417
  )}
@@ -411,7 +419,7 @@ export function ConfirmSwapPage(props: PropTypes) {
411
419
  {showWallets && (
412
420
  <ConfirmWalletsModal
413
421
  open={showWallets}
414
- onClose={setShowWallets.bind(null, false)}
422
+ onClose={() => setShowWallets(false)}
415
423
  onCancel={cancelFetch}
416
424
  loading={fetchingConfirmationRoute}
417
425
  onCheckBalance={onConfirmSwap}
@@ -422,7 +430,7 @@ export function ConfirmSwapPage(props: PropTypes) {
422
430
  <Container>
423
431
  <div className="description">
424
432
  <Typography variant="title" size="small">
425
- You get
433
+ {i18n.t('You get')}
426
434
  </Typography>
427
435
  <Button
428
436
  style={{ padding: '0' }}
@@ -450,23 +458,44 @@ export function ConfirmSwapPage(props: PropTypes) {
450
458
  <Divider size={12} />
451
459
  </>
452
460
  )}
453
- {fetchingConfirmationRoute && (
454
- <BestRouteSkeleton type="swap-preview" expanded />
455
- )}
461
+ {showSkeleton && <BestRouteSkeleton type="swap-preview" expanded />}
456
462
  {showBestRoute && (
457
463
  <BestRoute
458
464
  expanded={true}
459
- steps={formatBestRoute(bestRoute) ?? []}
465
+ tooltipContainer={getContainer()}
466
+ steps={formatBestRoute(bestRoute, blockchains) ?? []}
460
467
  input={{
461
- value: numberToString(inputAmount, 6, 6),
462
- usdValue: numberToString(inputUsdValue, 6, 6),
468
+ value: numberToString(
469
+ inputAmount,
470
+ TOKEN_AMOUNT_MIN_DECIMALS,
471
+ TOKEN_AMOUNT_MAX_DECIMALS
472
+ ),
473
+ usdValue: numberToString(
474
+ inputUsdValue,
475
+ USD_VALUE_MIN_DECIMALS,
476
+ USD_VALUE_MAX_DECIMALS
477
+ ),
463
478
  }}
464
479
  output={{
465
- value: numberToString(outputAmount, 6, 6),
466
- usdValue: numberToString(outputUsdValue, 6, 6),
480
+ value: numberToString(
481
+ outputAmount,
482
+ TOKEN_AMOUNT_MIN_DECIMALS,
483
+ TOKEN_AMOUNT_MAX_DECIMALS
484
+ ),
485
+ usdValue: numberToString(
486
+ outputUsdValue,
487
+ USD_VALUE_MIN_DECIMALS,
488
+ USD_VALUE_MAX_DECIMALS
489
+ ),
467
490
  }}
468
- totalFee={numberToString(totalFeeInUsd, 0, 2)}
469
- totalTime={secondsToString(totalArrivalTime(bestRoute))}
491
+ totalFee={numberToString(
492
+ totalFeeInUsd,
493
+ GAS_FEE_MIN_DECIMALS,
494
+ GAS_FEE_MAX_DECIMALS
495
+ )}
496
+ totalTime={secondsToString(
497
+ totalArrivalTime(bestRoute.result?.swaps)
498
+ )}
470
499
  recommended={true}
471
500
  type="swap-preview"
472
501
  percentageChange={percentageChange}
@@ -78,7 +78,7 @@ export function HistoryPage() {
78
78
  return (
79
79
  <Layout
80
80
  header={{
81
- onBack: navigateBackFrom.bind(null, '/' + navigationRoutes.swaps),
81
+ onBack: navigateBackFrom.bind(null, navigationRoutes.swaps),
82
82
  title: i18n.t('History'),
83
83
  }}>
84
84
  <Container>
@@ -86,7 +86,7 @@ export function HistoryPage() {
86
86
  setValue={setSearchedFor}
87
87
  fullWidth
88
88
  variant="contained"
89
- placeholder="Search Transaction"
89
+ placeholder={i18n.t('Search Transaction')}
90
90
  autoFocus
91
91
  onChange={searchHandler}
92
92
  value={searchedFor}