@lifi/widget 3.0.2 → 3.1.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 (226) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/_esm/components/Card/CardIconButton.js +1 -0
  3. package/_esm/components/Card/CardIconButton.js.map +1 -1
  4. package/_esm/components/Card/CardLabel.d.ts +1 -1
  5. package/_esm/components/Card/CardLabel.js +8 -12
  6. package/_esm/components/Card/CardLabel.js.map +1 -1
  7. package/_esm/components/ChainSelect/ChainSelect.js +1 -1
  8. package/_esm/components/ChainSelect/ChainSelect.js.map +1 -1
  9. package/_esm/components/FeeBreakdownTooltip.d.ts +12 -0
  10. package/_esm/components/FeeBreakdownTooltip.js +13 -0
  11. package/_esm/components/FeeBreakdownTooltip.js.map +1 -0
  12. package/_esm/components/Header/CloseDrawerButton.js +1 -1
  13. package/_esm/components/Header/CloseDrawerButton.js.map +1 -1
  14. package/_esm/components/Header/SettingsButton.js +1 -1
  15. package/_esm/components/Header/SettingsButton.js.map +1 -1
  16. package/_esm/components/Header/TransactionHistoryButton.js +1 -1
  17. package/_esm/components/Header/TransactionHistoryButton.js.map +1 -1
  18. package/_esm/components/IconTypography.d.ts +3 -0
  19. package/_esm/components/IconTypography.js +8 -0
  20. package/_esm/components/IconTypography.js.map +1 -0
  21. package/_esm/components/PoweredBy/PoweredBy.js +1 -1
  22. package/_esm/components/PoweredBy/PoweredBy.js.map +1 -1
  23. package/_esm/components/ProgressToNextUpdate.js +1 -1
  24. package/_esm/components/ProgressToNextUpdate.js.map +1 -1
  25. package/_esm/components/RouteCard/RouteCard.js +7 -16
  26. package/_esm/components/RouteCard/RouteCard.js.map +1 -1
  27. package/_esm/components/RouteCard/RouteCard.style.d.ts +0 -3
  28. package/_esm/components/RouteCard/RouteCard.style.js +1 -7
  29. package/_esm/components/RouteCard/RouteCard.style.js.map +1 -1
  30. package/_esm/components/RouteCard/RouteCardEssentials.js +13 -14
  31. package/_esm/components/RouteCard/RouteCardEssentials.js.map +1 -1
  32. package/_esm/components/RouteCard/RouteCardEssentialsExpanded.js +4 -20
  33. package/_esm/components/RouteCard/RouteCardEssentialsExpanded.js.map +1 -1
  34. package/_esm/components/RouteCard/types.d.ts +1 -6
  35. package/_esm/components/Routes/RoutesExpanded.js +2 -4
  36. package/_esm/components/Routes/RoutesExpanded.js.map +1 -1
  37. package/_esm/components/SendToWallet/SendToWalletExpandButton.js +1 -1
  38. package/_esm/components/SendToWallet/SendToWalletExpandButton.js.map +1 -1
  39. package/_esm/components/Step/Step.d.ts +1 -0
  40. package/_esm/components/Step/Step.js +2 -2
  41. package/_esm/components/Step/Step.js.map +1 -1
  42. package/_esm/components/Step/StepList.js +16 -7
  43. package/_esm/components/Step/StepList.js.map +1 -1
  44. package/_esm/components/Step/StepTimer.js +3 -3
  45. package/_esm/components/Step/StepTimer.js.map +1 -1
  46. package/_esm/components/StepActions/StepActions.js +5 -4
  47. package/_esm/components/StepActions/StepActions.js.map +1 -1
  48. package/_esm/components/Token/Token.d.ts +2 -0
  49. package/_esm/components/Token/Token.js +22 -8
  50. package/_esm/components/Token/Token.js.map +1 -1
  51. package/_esm/components/Token/Token.style.js +1 -0
  52. package/_esm/components/Token/Token.style.js.map +1 -1
  53. package/_esm/components/TokenRate.d.ts +7 -0
  54. package/_esm/components/TokenRate.js +41 -0
  55. package/_esm/components/TokenRate.js.map +1 -0
  56. package/_esm/components/TransactionDetails.d.ts +7 -0
  57. package/_esm/components/TransactionDetails.js +46 -0
  58. package/_esm/components/TransactionDetails.js.map +1 -0
  59. package/_esm/config/version.d.ts +1 -1
  60. package/_esm/config/version.js +1 -1
  61. package/_esm/hooks/timer/useInterval.d.ts +1 -0
  62. package/_esm/hooks/timer/useInterval.js +18 -0
  63. package/_esm/hooks/timer/useInterval.js.map +1 -0
  64. package/_esm/hooks/timer/useTimer.d.ts +18 -0
  65. package/_esm/hooks/timer/useTimer.js +61 -0
  66. package/_esm/hooks/timer/useTimer.js.map +1 -0
  67. package/_esm/hooks/timer/utils.d.ts +11 -0
  68. package/_esm/hooks/timer/utils.js +46 -0
  69. package/_esm/hooks/timer/utils.js.map +1 -0
  70. package/_esm/hooks/useAccount.js +4 -5
  71. package/_esm/hooks/useAccount.js.map +1 -1
  72. package/_esm/hooks/useAvailableChains.js +1 -0
  73. package/_esm/hooks/useAvailableChains.js.map +1 -1
  74. package/_esm/hooks/useGasRecommendation.js +1 -0
  75. package/_esm/hooks/useGasRecommendation.js.map +1 -1
  76. package/_esm/hooks/useRoutes.d.ts +4 -2
  77. package/_esm/hooks/useRoutes.js +17 -10
  78. package/_esm/hooks/useRoutes.js.map +1 -1
  79. package/_esm/hooks/useTokens.js +1 -0
  80. package/_esm/hooks/useTokens.js.map +1 -1
  81. package/_esm/hooks/useTools.js +1 -0
  82. package/_esm/hooks/useTools.js.map +1 -1
  83. package/_esm/hooks/useTransactionDetails.d.ts +1 -1
  84. package/_esm/hooks/useTransactionDetails.js +1 -1
  85. package/_esm/hooks/useTransactionDetails.js.map +1 -1
  86. package/_esm/hooks/useTransactionHistory.js.map +1 -1
  87. package/_esm/i18n/en.json +14 -20
  88. package/_esm/i18n/index.js +15 -15
  89. package/_esm/i18n/index.js.map +1 -1
  90. package/_esm/index.d.ts +2 -1
  91. package/_esm/index.js +1 -4
  92. package/_esm/index.js.map +1 -1
  93. package/_esm/pages/MainPage/ReviewButton.js +2 -4
  94. package/_esm/pages/MainPage/ReviewButton.js.map +1 -1
  95. package/_esm/pages/RoutesPage/RoutesPage.js +2 -4
  96. package/_esm/pages/RoutesPage/RoutesPage.js.map +1 -1
  97. package/_esm/pages/SelectEnabledToolsPage.js +1 -1
  98. package/_esm/pages/SelectEnabledToolsPage.js.map +1 -1
  99. package/_esm/pages/SendToWallet/SendToWalletPage.js +1 -1
  100. package/_esm/pages/SendToWallet/SendToWalletPage.js.map +1 -1
  101. package/_esm/pages/SettingsPage/ThemeSettings.js +1 -1
  102. package/_esm/pages/SettingsPage/ThemeSettings.js.map +1 -1
  103. package/_esm/pages/TransactionDetailsPage/TransactionDetailsPage.js +5 -7
  104. package/_esm/pages/TransactionDetailsPage/TransactionDetailsPage.js.map +1 -1
  105. package/_esm/pages/TransactionHistoryPage/TransactionHistoryItem.js +2 -2
  106. package/_esm/pages/TransactionHistoryPage/TransactionHistoryItem.js.map +1 -1
  107. package/_esm/pages/TransactionPage/ExchangeRateBottomSheet.js +2 -2
  108. package/_esm/pages/TransactionPage/ExchangeRateBottomSheet.js.map +1 -1
  109. package/_esm/pages/TransactionPage/RouteTracker.d.ts +7 -0
  110. package/_esm/pages/TransactionPage/RouteTracker.js +39 -0
  111. package/_esm/pages/TransactionPage/RouteTracker.js.map +1 -0
  112. package/_esm/pages/TransactionPage/StartTransactionButton.d.ts +0 -1
  113. package/_esm/pages/TransactionPage/StartTransactionButton.js +0 -9
  114. package/_esm/pages/TransactionPage/StartTransactionButton.js.map +1 -1
  115. package/_esm/pages/TransactionPage/TransactionPage.js +10 -21
  116. package/_esm/pages/TransactionPage/TransactionPage.js.map +1 -1
  117. package/_esm/pages/TransactionPage/types.d.ts +0 -1
  118. package/_esm/providers/I18nProvider/I18nProvider.js +2 -0
  119. package/_esm/providers/I18nProvider/I18nProvider.js.map +1 -1
  120. package/_esm/providers/I18nProvider/currencyExtendedFormatter.d.ts +1 -0
  121. package/_esm/providers/I18nProvider/currencyExtendedFormatter.js +13 -0
  122. package/_esm/providers/I18nProvider/currencyExtendedFormatter.js.map +1 -0
  123. package/_esm/providers/WalletProvider/EVMBaseProvider.js +18 -12
  124. package/_esm/providers/WalletProvider/EVMBaseProvider.js.map +1 -1
  125. package/_esm/stores/routes/createRouteExecutionStore.js +2 -2
  126. package/_esm/stores/routes/createRouteExecutionStore.js.map +1 -1
  127. package/_esm/stores/routes/types.d.ts +1 -1
  128. package/_esm/stores/routes/useSetExecutableRoute.d.ts +1 -1
  129. package/_esm/themes/createTheme.js +6 -0
  130. package/_esm/themes/createTheme.js.map +1 -1
  131. package/_esm/types/widget.d.ts +1 -2
  132. package/_esm/utils/converters.js +5 -13
  133. package/_esm/utils/converters.js.map +1 -1
  134. package/_esm/utils/fees.d.ts +3 -3
  135. package/_esm/utils/fees.js +18 -13
  136. package/_esm/utils/fees.js.map +1 -1
  137. package/_esm/utils/format.d.ts +13 -4
  138. package/_esm/utils/format.js +51 -13
  139. package/_esm/utils/format.js.map +1 -1
  140. package/components/Card/CardIconButton.tsx +1 -0
  141. package/components/Card/CardLabel.tsx +13 -29
  142. package/components/ChainSelect/ChainSelect.tsx +1 -9
  143. package/components/FeeBreakdownTooltip.tsx +66 -0
  144. package/components/Header/CloseDrawerButton.tsx +1 -1
  145. package/components/Header/SettingsButton.tsx +1 -1
  146. package/components/Header/TransactionHistoryButton.tsx +1 -1
  147. package/components/IconTypography.ts +9 -0
  148. package/components/PoweredBy/PoweredBy.tsx +1 -1
  149. package/components/ProgressToNextUpdate.tsx +0 -3
  150. package/components/RouteCard/RouteCard.style.ts +1 -9
  151. package/components/RouteCard/RouteCard.tsx +15 -71
  152. package/components/RouteCard/RouteCardEssentials.tsx +52 -81
  153. package/components/RouteCard/RouteCardEssentialsExpanded.tsx +17 -107
  154. package/components/RouteCard/types.ts +1 -7
  155. package/components/Routes/RoutesExpanded.tsx +3 -4
  156. package/components/SendToWallet/SendToWalletExpandButton.tsx +1 -6
  157. package/components/Step/Step.tsx +11 -2
  158. package/components/Step/StepList.tsx +19 -10
  159. package/components/Step/StepTimer.tsx +9 -6
  160. package/components/StepActions/StepActions.tsx +11 -14
  161. package/components/Token/Token.style.tsx +1 -0
  162. package/components/Token/Token.tsx +49 -9
  163. package/components/TokenRate.tsx +79 -0
  164. package/components/TransactionDetails.tsx +182 -0
  165. package/config/version.ts +1 -1
  166. package/hooks/timer/useInterval.ts +21 -0
  167. package/hooks/timer/useTimer.ts +91 -0
  168. package/hooks/timer/utils.ts +54 -0
  169. package/hooks/useAccount.ts +8 -5
  170. package/hooks/useAvailableChains.ts +2 -1
  171. package/hooks/useGasRecommendation.ts +1 -0
  172. package/hooks/useRoutes.ts +23 -13
  173. package/hooks/useTokens.ts +1 -0
  174. package/hooks/useTools.ts +2 -1
  175. package/hooks/useTransactionDetails.ts +3 -3
  176. package/hooks/useTransactionHistory.ts +1 -1
  177. package/i18n/en.json +14 -20
  178. package/i18n/index.ts +15 -15
  179. package/index.ts +2 -5
  180. package/package.json +15 -16
  181. package/pages/MainPage/ReviewButton.tsx +2 -4
  182. package/pages/RoutesPage/RoutesPage.tsx +3 -4
  183. package/pages/SelectEnabledToolsPage.tsx +1 -1
  184. package/pages/SendToWallet/SendToWalletPage.tsx +1 -1
  185. package/pages/SettingsPage/ThemeSettings.tsx +1 -1
  186. package/pages/TransactionDetailsPage/TransactionDetailsPage.tsx +9 -20
  187. package/pages/TransactionHistoryPage/TransactionHistoryItem.tsx +3 -5
  188. package/pages/TransactionPage/ExchangeRateBottomSheet.tsx +0 -2
  189. package/pages/TransactionPage/RouteTracker.tsx +68 -0
  190. package/pages/TransactionPage/StartTransactionButton.tsx +0 -24
  191. package/pages/TransactionPage/TransactionPage.tsx +21 -48
  192. package/pages/TransactionPage/types.ts +0 -1
  193. package/providers/I18nProvider/I18nProvider.tsx +6 -0
  194. package/providers/I18nProvider/currencyExtendedFormatter.ts +15 -0
  195. package/providers/WalletProvider/EVMBaseProvider.tsx +13 -7
  196. package/stores/routes/createRouteExecutionStore.ts +2 -2
  197. package/stores/routes/types.ts +1 -1
  198. package/themes/createTheme.ts +6 -0
  199. package/types/widget.ts +1 -2
  200. package/utils/converters.ts +5 -13
  201. package/utils/fees.ts +23 -24
  202. package/utils/format.ts +67 -20
  203. package/_esm/components/Insurance/Insurance.d.ts +0 -2
  204. package/_esm/components/Insurance/Insurance.js +0 -8
  205. package/_esm/components/Insurance/Insurance.js.map +0 -1
  206. package/_esm/components/Insurance/InsuranceCard.d.ts +0 -2
  207. package/_esm/components/Insurance/InsuranceCard.js +0 -36
  208. package/_esm/components/Insurance/InsuranceCard.js.map +0 -1
  209. package/_esm/components/Insurance/InsuranceCollapsed.d.ts +0 -2
  210. package/_esm/components/Insurance/InsuranceCollapsed.js +0 -29
  211. package/_esm/components/Insurance/InsuranceCollapsed.js.map +0 -1
  212. package/_esm/components/Insurance/types.d.ts +0 -19
  213. package/_esm/components/Insurance/types.js +0 -2
  214. package/_esm/components/Insurance/types.js.map +0 -1
  215. package/_esm/components/StepActions/StepFeeBreakdown.d.ts +0 -4
  216. package/_esm/components/StepActions/StepFeeBreakdown.js +0 -42
  217. package/_esm/components/StepActions/StepFeeBreakdown.js.map +0 -1
  218. package/_esm/icons/InsuraceLogo.d.ts +0 -2
  219. package/_esm/icons/InsuraceLogo.js +0 -8
  220. package/_esm/icons/InsuraceLogo.js.map +0 -1
  221. package/components/Insurance/Insurance.tsx +0 -22
  222. package/components/Insurance/InsuranceCard.tsx +0 -119
  223. package/components/Insurance/InsuranceCollapsed.tsx +0 -59
  224. package/components/Insurance/types.ts +0 -24
  225. package/components/StepActions/StepFeeBreakdown.tsx +0 -108
  226. package/icons/InsuraceLogo.tsx +0 -46
@@ -27,7 +27,7 @@ export const SettingsButton = () => {
27
27
  : t(`header.settings`);
28
28
 
29
29
  return (
30
- <Tooltip title={tooltipMessage} enterDelay={400} arrow>
30
+ <Tooltip title={tooltipMessage}>
31
31
  <SettingsIconButton
32
32
  size="medium"
33
33
  onClick={() => navigate(navigationRoutes.settings)}
@@ -9,7 +9,7 @@ export const TransactionHistoryButton = () => {
9
9
  const { navigate } = useNavigateBack();
10
10
 
11
11
  return (
12
- <Tooltip title={t(`header.transactionHistory`)} enterDelay={400} arrow>
12
+ <Tooltip title={t(`header.transactionHistory`)}>
13
13
  <IconButton
14
14
  size="medium"
15
15
  onClick={() => navigate(navigationRoutes.transactionHistory)}
@@ -0,0 +1,9 @@
1
+ import { Typography, alpha, styled } from '@mui/material';
2
+
3
+ export const IconTypography = styled(Typography)(({ theme }) => ({
4
+ color:
5
+ theme.palette.mode === 'light'
6
+ ? alpha(theme.palette.common.black, 0.32)
7
+ : alpha(theme.palette.common.white, 0.4),
8
+ lineHeight: 0,
9
+ }));
@@ -14,7 +14,7 @@ export const PoweredBy: React.FC = () => {
14
14
  justifyContent: 'flex-end',
15
15
  }}
16
16
  >
17
- <Tooltip title={`v${version}`} placement="top" enterDelay={1000} arrow>
17
+ <Tooltip title={`v${version}`} enterDelay={1000}>
18
18
  <Link
19
19
  href="https://li.fi"
20
20
  target="_blank"
@@ -52,9 +52,6 @@ export const ProgressToNextUpdate: React.FC<
52
52
  components={[<br />]}
53
53
  />
54
54
  }
55
- placement="top"
56
- enterDelay={400}
57
- arrow
58
55
  >
59
56
  <Box
60
57
  sx={{
@@ -1,12 +1,4 @@
1
- import { Box, Typography, alpha, styled } from '@mui/material';
2
-
3
- export const IconTypography = styled(Typography)(({ theme }) => ({
4
- color:
5
- theme.palette.mode === 'light'
6
- ? alpha(theme.palette.common.black, 0.32)
7
- : alpha(theme.palette.common.white, 0.4),
8
- lineHeight: 0,
9
- }));
1
+ import { Box, styled } from '@mui/material';
10
2
 
11
3
  export const TokenContainer = styled(Box)(({ theme }) => ({
12
4
  display: 'flex',
@@ -1,17 +1,14 @@
1
1
  import type { TokenAmount } from '@lifi/sdk';
2
- import { ExpandLess, ExpandMore, VerifiedUser } from '@mui/icons-material';
3
- import type { TooltipProps } from '@mui/material';
4
- import { Box, Collapse, Tooltip, Typography } from '@mui/material';
2
+ import { ExpandLess, ExpandMore } from '@mui/icons-material';
3
+ import { Box, Collapse } from '@mui/material';
5
4
  import type { MouseEventHandler } from 'react';
6
5
  import { useState } from 'react';
7
- import { Trans, useTranslation } from 'react-i18next';
6
+ import { useTranslation } from 'react-i18next';
8
7
  import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
9
- import { formatTokenAmount } from '../../utils/format.js';
10
8
  import type { CardProps } from '../Card/Card.js';
11
9
  import { Card } from '../Card/Card.js';
12
10
  import { CardIconButton } from '../Card/CardIconButton.js';
13
11
  import { CardLabel, CardLabelTypography } from '../Card/CardLabel.js';
14
- import type { InsuredAmount } from '../Insurance/types.js';
15
12
  import { StepActions } from '../StepActions/StepActions.js';
16
13
  import { Token } from '../Token/Token.js';
17
14
  import { TokenContainer } from './RouteCard.style.js';
@@ -37,12 +34,14 @@ export const RouteCard: React.FC<
37
34
  setCardExpanded((expanded) => !expanded);
38
35
  };
39
36
 
40
- const insurable = route.insurance?.state === 'INSURABLE';
41
-
42
37
  const token: TokenAmount =
43
38
  subvariant === 'custom'
44
39
  ? { ...route.fromToken, amount: BigInt(route.fromAmount) }
45
40
  : { ...route.toToken, amount: BigInt(route.toAmount) };
41
+ const impactToken: TokenAmount | undefined =
42
+ subvariant !== 'custom'
43
+ ? { ...route.fromToken, amount: BigInt(route.fromAmount) }
44
+ : undefined;
46
45
 
47
46
  const tags = route.tags?.filter(
48
47
  (tag) => tag === 'CHEAPEST' || tag === 'FASTEST',
@@ -50,7 +49,7 @@ export const RouteCard: React.FC<
50
49
 
51
50
  const cardContent = (
52
51
  <Box flex={1}>
53
- {subvariant !== 'refuel' && (insurable || route.tags?.length) ? (
52
+ {subvariant !== 'refuel' && route.tags?.length ? (
54
53
  <Box display="flex" alignItems="center" mb={2}>
55
54
  {tags?.length ? (
56
55
  <CardLabel type={active ? 'active' : undefined}>
@@ -59,33 +58,22 @@ export const RouteCard: React.FC<
59
58
  </CardLabelTypography>
60
59
  </CardLabel>
61
60
  ) : null}
62
- {insurable ? (
63
- <InsuranceTooltip
64
- insuredAmount={formatTokenAmount(
65
- BigInt(route.toAmountMin),
66
- route.toToken.decimals,
67
- )}
68
- insuredTokenSymbol={route.toToken.symbol}
69
- >
70
- <CardLabel type={'insurance'}>
71
- <VerifiedUser fontSize="inherit" />
72
- <CardLabelTypography type="icon">
73
- {t(`main.tags.insurable`)}
74
- </CardLabelTypography>
75
- </CardLabel>
76
- </InsuranceTooltip>
77
- ) : null}
78
61
  </Box>
79
62
  ) : null}
80
63
  <TokenContainer>
81
64
  <Token
82
65
  token={token}
66
+ impactToken={impactToken}
83
67
  step={route.steps[0]}
84
68
  stepVisible={!cardExpanded}
85
69
  />
86
70
  {!defaulExpanded ? (
87
71
  <CardIconButton onClick={handleExpand} size="small">
88
- {cardExpanded ? <ExpandLess /> : <ExpandMore />}
72
+ {cardExpanded ? (
73
+ <ExpandLess fontSize="inherit" />
74
+ ) : (
75
+ <ExpandMore fontSize="inherit" />
76
+ )}
89
77
  </CardIconButton>
90
78
  ) : null}
91
79
  </TokenContainer>
@@ -95,9 +83,7 @@ export const RouteCard: React.FC<
95
83
  ))}
96
84
  <RouteCardEssentialsExpanded route={route} />
97
85
  </Collapse>
98
- <Collapse timeout={225} in={!cardExpanded} mountOnEnter unmountOnExit>
99
- <RouteCardEssentials route={route} />
100
- </Collapse>
86
+ <RouteCardEssentials route={route} />
101
87
  </Box>
102
88
  );
103
89
 
@@ -114,45 +100,3 @@ export const RouteCard: React.FC<
114
100
  </Card>
115
101
  );
116
102
  };
117
-
118
- const InsuranceTooltip: React.FC<
119
- InsuredAmount & Pick<TooltipProps, 'children'>
120
- > = ({ insuredAmount, insuredTokenSymbol, children }) => {
121
- const { t } = useTranslation();
122
- return (
123
- <Tooltip
124
- title={
125
- <Box component="span">
126
- <Typography fontSize={12} fontWeight="500">
127
- <Trans
128
- i18nKey="insurance.insure"
129
- values={{
130
- amount: insuredAmount,
131
- tokenSymbol: insuredTokenSymbol,
132
- }}
133
- components={[<strong />]}
134
- />
135
- </Typography>
136
- <Box
137
- sx={{
138
- listStyleType: 'disc',
139
- pl: 2,
140
- }}
141
- >
142
- <Typography fontSize={12} fontWeight="500" display="list-item">
143
- {t('insurance.bridgeExploits')}
144
- </Typography>
145
- <Typography fontSize={12} fontWeight="500" display="list-item">
146
- {t('insurance.slippageError')}
147
- </Typography>
148
- </Box>
149
- </Box>
150
- }
151
- placement="top"
152
- enterDelay={400}
153
- arrow
154
- >
155
- {children}
156
- </Tooltip>
157
- );
158
- };
@@ -1,14 +1,11 @@
1
- import { AccessTimeFilled, MonetizationOn } from '@mui/icons-material';
1
+ import { AccessTimeFilled, LocalGasStationRounded } from '@mui/icons-material';
2
2
  import { Box, Tooltip, Typography } from '@mui/material';
3
- import type { TFunction } from 'i18next';
4
3
  import { useTranslation } from 'react-i18next';
5
- import { formatUnits } from 'viem';
6
- import {
7
- getFeeCostsBreakdown,
8
- getGasCostsBreakdown,
9
- } from '../../utils/fees.js';
10
- import { IconTypography } from './RouteCard.style.js';
11
- import type { FeesBreakdown, RouteCardEssentialsProps } from './types.js';
4
+ import { getFeeCostsBreakdown } from '../../utils/fees.js';
5
+ import { FeeBreakdownTooltip } from '../FeeBreakdownTooltip.js';
6
+ import { IconTypography } from '../IconTypography.js';
7
+ import { TokenRate } from '../TokenRate.js';
8
+ import type { RouteCardEssentialsProps } from './types.js';
12
9
 
13
10
  export const RouteCardEssentials: React.FC<RouteCardEssentialsProps> = ({
14
11
  route,
@@ -19,83 +16,57 @@ export const RouteCardEssentials: React.FC<RouteCardEssentialsProps> = ({
19
16
  .map((step) => step.estimate.executionDuration)
20
17
  .reduce((duration, x) => duration + x, 0) / 60,
21
18
  );
22
- const gasCostUSD = parseFloat(route.gasCostUSD ?? '') || 0.01;
23
- const gasCosts = getGasCostsBreakdown(route);
19
+ const gasCostUSD = parseFloat(route.gasCostUSD || '0');
24
20
  const feeCosts = getFeeCostsBreakdown(route, false);
25
21
  const fees =
26
22
  gasCostUSD + feeCosts.reduce((sum, feeCost) => sum + feeCost.amountUSD, 0);
27
23
  return (
28
- <Box display="flex" justifyContent={'space-between'} flex={1} mt={2}>
29
- <Tooltip
30
- title={
31
- <Box component="span">
32
- {t('main.fees.networkEstimated')}
33
- {getFeeBreakdownTypography(gasCosts, t)}
34
- {feeCosts.length ? (
35
- <Box mt={1}>
36
- {t('main.fees.providerEstimated')}
37
- {getFeeBreakdownTypography(feeCosts, t)}
38
- </Box>
39
- ) : null}
24
+ <Box
25
+ display="flex"
26
+ alignItems="center"
27
+ justifyContent={'space-between'}
28
+ flex={1}
29
+ mt={2}
30
+ >
31
+ <TokenRate route={route} />
32
+ <Box display="flex" alignItems="center">
33
+ <FeeBreakdownTooltip route={route} feeCosts={feeCosts}>
34
+ <Box display="flex" mr={1.5} alignItems="center">
35
+ <IconTypography mr={0.5} fontSize={16}>
36
+ <LocalGasStationRounded fontSize="inherit" />
37
+ </IconTypography>
38
+ <Typography
39
+ fontSize={14}
40
+ color="text.primary"
41
+ fontWeight="500"
42
+ lineHeight={1}
43
+ >
44
+ {t(`format.currency`, {
45
+ value: fees,
46
+ })}
47
+ </Typography>
48
+ </Box>
49
+ </FeeBreakdownTooltip>
50
+ <Tooltip title={t(`tooltip.estimatedTime`)} sx={{ cursor: 'help' }}>
51
+ <Box display="flex" alignItems="center">
52
+ <IconTypography mr={0.5} fontSize={16}>
53
+ <AccessTimeFilled fontSize="inherit" />
54
+ </IconTypography>
55
+ <Typography
56
+ fontSize={14}
57
+ color="text.primary"
58
+ fontWeight="500"
59
+ lineHeight={1}
60
+ >
61
+ {executionTimeMinutes.toLocaleString(i18n.language, {
62
+ style: 'unit',
63
+ unit: 'minute',
64
+ unitDisplay: 'narrow',
65
+ })}
66
+ </Typography>
40
67
  </Box>
41
- }
42
- placement="top"
43
- enterDelay={400}
44
- arrow
45
- >
46
- <Box display="flex" alignItems="center">
47
- <IconTypography mr={0.5}>
48
- <MonetizationOn fontSize="small" />
49
- </IconTypography>
50
- <Typography
51
- fontSize={14}
52
- color="text.primary"
53
- fontWeight="500"
54
- lineHeight={1}
55
- >
56
- {t(`format.currency`, {
57
- value: fees,
58
- })}
59
- </Typography>
60
- </Box>
61
- </Tooltip>
62
- <Tooltip
63
- title={t(`tooltip.estimatedTime`)}
64
- placement="top"
65
- enterDelay={400}
66
- arrow
67
- >
68
- <Box display="flex" alignItems="center">
69
- <IconTypography mr={0.5}>
70
- <AccessTimeFilled fontSize="small" />
71
- </IconTypography>
72
- <Typography
73
- fontSize={14}
74
- color="text.primary"
75
- fontWeight="500"
76
- lineHeight={1}
77
- >
78
- {new Intl.NumberFormat(i18n.language, {
79
- style: 'unit',
80
- unit: 'minute',
81
- unitDisplay: 'narrow',
82
- }).format(executionTimeMinutes)}
83
- </Typography>
84
- </Box>
85
- </Tooltip>
68
+ </Tooltip>
69
+ </Box>
86
70
  </Box>
87
71
  );
88
72
  };
89
-
90
- const getFeeBreakdownTypography = (fees: FeesBreakdown[], t: TFunction) =>
91
- fees.map((fee, index) => (
92
- <Typography
93
- fontSize={12}
94
- fontWeight="500"
95
- key={`${fee.token.address}${index}`}
96
- >
97
- {t(`format.currency`, { value: fee.amountUSD })} (
98
- {parseFloat(formatUnits(fee.amount, fee.token.decimals))?.toFixed(9)}{' '}
99
- {fee.token.symbol})
100
- </Typography>
101
- ));
@@ -1,100 +1,18 @@
1
- import { AccessTimeFilled, Layers, MonetizationOn } from '@mui/icons-material';
1
+ import { Layers } from '@mui/icons-material';
2
2
  import { Box, Typography } from '@mui/material';
3
- import type { TFunction } from 'i18next';
4
3
  import { useTranslation } from 'react-i18next';
5
- import { formatUnits } from 'viem';
6
- import {
7
- getFeeCostsBreakdown,
8
- getGasCostsBreakdown,
9
- } from '../../utils/fees.js';
10
- import { IconTypography } from './RouteCard.style.js';
11
- import type { FeesBreakdown, RouteCardEssentialsProps } from './types.js';
4
+ import { IconTypography } from '../IconTypography.js';
5
+ import type { RouteCardEssentialsProps } from './types.js';
12
6
 
13
7
  export const RouteCardEssentialsExpanded: React.FC<
14
8
  RouteCardEssentialsProps
15
9
  > = ({ route }) => {
16
- const { t, i18n } = useTranslation();
17
- const executionTimeMinutes = Math.ceil(
18
- route.steps
19
- .map((step) => step.estimate.executionDuration)
20
- .reduce((duration, x) => duration + x, 0) / 60,
21
- );
22
- const gasCostUSD = parseFloat(route.gasCostUSD ?? '') || 0.01;
23
- const gasCosts = getGasCostsBreakdown(route);
24
- const feeCosts = getFeeCostsBreakdown(route, false);
25
- const fees =
26
- gasCostUSD + feeCosts.reduce((sum, feeCost) => sum + feeCost.amountUSD, 0);
10
+ const { t } = useTranslation();
27
11
  return (
28
12
  <Box flex={1} mt={2}>
29
- <Box>
30
- <Box display="flex" alignItems="center">
31
- <IconTypography ml={1} mr={3}>
32
- <MonetizationOn />
33
- </IconTypography>
34
- <Typography
35
- fontSize={16}
36
- color="text.primary"
37
- fontWeight="600"
38
- lineHeight={1.125}
39
- >
40
- {t(`format.currency`, {
41
- value: fees,
42
- })}
43
- </Typography>
44
- </Box>
45
- <Box mt={0.5} ml={7}>
46
- <Typography
47
- fontSize={12}
48
- color="text.secondary"
49
- fontWeight="500"
50
- lineHeight={1.125}
51
- >
52
- {t('main.fees.networkEstimated')}
53
- </Typography>
54
- {getFeeBreakdownTypography(gasCosts, t)}
55
- {feeCosts.length ? (
56
- <Box mt={0.5}>
57
- <Typography
58
- fontSize={12}
59
- color="text.secondary"
60
- fontWeight="500"
61
- lineHeight={1.125}
62
- >
63
- {t('main.fees.providerEstimated')}
64
- </Typography>
65
- {getFeeBreakdownTypography(feeCosts, t)}
66
- </Box>
67
- ) : null}
68
- </Box>
69
- </Box>
70
- <Box mt={2}>
71
- <Box display="flex" alignItems="center">
72
- <IconTypography ml={1} mr={3}>
73
- <Layers />
74
- </IconTypography>
75
- <Typography
76
- fontSize={16}
77
- color="text.primary"
78
- fontWeight="600"
79
- lineHeight={1.125}
80
- >
81
- {route.steps.length}
82
- </Typography>
83
- </Box>
84
- <Box mt={0.5} ml={7}>
85
- <Typography
86
- fontSize={12}
87
- color="text.secondary"
88
- fontWeight="500"
89
- lineHeight={1.125}
90
- >
91
- {t(`tooltip.numberOfSteps`)}
92
- </Typography>
93
- </Box>
94
- </Box>
95
- <Box display="flex" alignItems="center" mt={2}>
13
+ <Box display="flex" alignItems="center">
96
14
  <IconTypography ml={1} mr={3}>
97
- <AccessTimeFilled />
15
+ <Layers />
98
16
  </IconTypography>
99
17
  <Typography
100
18
  fontSize={16}
@@ -102,27 +20,19 @@ export const RouteCardEssentialsExpanded: React.FC<
102
20
  fontWeight="600"
103
21
  lineHeight={1.125}
104
22
  >
105
- {new Intl.NumberFormat(i18n.language, {
106
- style: 'unit',
107
- unit: 'minute',
108
- unitDisplay: 'long',
109
- }).format(executionTimeMinutes)}
23
+ {route.steps.length}
24
+ </Typography>
25
+ </Box>
26
+ <Box mt={0.5} ml={7}>
27
+ <Typography
28
+ fontSize={12}
29
+ color="text.secondary"
30
+ fontWeight="500"
31
+ lineHeight={1.125}
32
+ >
33
+ {t(`tooltip.numberOfSteps`)}
110
34
  </Typography>
111
35
  </Box>
112
36
  </Box>
113
37
  );
114
38
  };
115
-
116
- const getFeeBreakdownTypography = (fees: FeesBreakdown[], t: TFunction) =>
117
- fees.map((fee, index) => (
118
- <Typography
119
- fontSize={12}
120
- fontWeight="500"
121
- color="text.secondary"
122
- key={`${fee.token.address}${index}`}
123
- >
124
- {t(`format.currency`, { value: fee.amountUSD })} (
125
- {parseFloat(formatUnits(fee.amount, fee.token.decimals))?.toFixed(9)}{' '}
126
- {fee.token.symbol})
127
- </Typography>
128
- ));
@@ -1,4 +1,4 @@
1
- import type { Route, Token } from '@lifi/sdk';
1
+ import type { Route } from '@lifi/sdk';
2
2
 
3
3
  export interface RouteCardProps {
4
4
  route: Route;
@@ -14,9 +14,3 @@ export interface RouteCardEssentialsProps {
14
14
  export interface RouteCardSkeletonProps {
15
15
  variant?: 'default' | 'cardless';
16
16
  }
17
-
18
- export interface FeesBreakdown {
19
- amount: bigint;
20
- amountUSD: number;
21
- token: Token;
22
- }
@@ -11,7 +11,6 @@ import { useToAddressRequirements } from '../../hooks/useToAddressRequirements.j
11
11
  import { useWidgetEvents } from '../../hooks/useWidgetEvents.js';
12
12
  import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js';
13
13
  import { useFieldValues } from '../../stores/form/useFieldValues.js';
14
- import { useSetExecutableRoute } from '../../stores/routes/useSetExecutableRoute.js';
15
14
  import { WidgetEvent } from '../../types/events.js';
16
15
  import { navigationRoutes } from '../../utils/navigationRoutes.js';
17
16
  import { PageContainer } from '../PageContainer.js';
@@ -59,7 +58,6 @@ export const RoutesExpanded = () => {
59
58
  export const RoutesExpandedElement = () => {
60
59
  const { t } = useTranslation();
61
60
  const navigate = useNavigate();
62
- const setExecutableRoute = useSetExecutableRoute();
63
61
  const { subvariant } = useWidgetConfig();
64
62
  const routesRef = useRef<Route[]>();
65
63
  const emitter = useWidgetEvents();
@@ -71,15 +69,16 @@ export const RoutesExpandedElement = () => {
71
69
  isFetched,
72
70
  dataUpdatedAt,
73
71
  refetchTime,
74
- refetch,
75
72
  fromChain,
73
+ refetch,
74
+ setReviewableRoute,
76
75
  } = useRoutes();
77
76
  const { account } = useAccount({ chainType: fromChain?.chainType });
78
77
  const [toAddress] = useFieldValues('toAddress');
79
78
  const { requiredToAddress } = useToAddressRequirements();
80
79
 
81
80
  const handleRouteClick = (route: Route) => {
82
- setExecutableRoute(route);
81
+ setReviewableRoute(route);
83
82
  navigate(navigationRoutes.transactionExecution, {
84
83
  state: { routeId: route.id },
85
84
  });
@@ -41,12 +41,7 @@ export const SendToWalletExpandButton: React.FC = () => {
41
41
  };
42
42
 
43
43
  return (
44
- <Tooltip
45
- title={t('main.sendToWallet')}
46
- placement="bottom-end"
47
- enterDelay={400}
48
- arrow
49
- >
44
+ <Tooltip title={t('main.sendToWallet')} placement="bottom-end">
50
45
  <Button
51
46
  variant={isActive ? 'contained' : 'text'}
52
47
  onClick={handleClick}
@@ -17,8 +17,9 @@ export const Step: React.FC<{
17
17
  step: LiFiStepExtended;
18
18
  fromToken?: TokenAmount;
19
19
  toToken?: TokenAmount;
20
+ impactToken?: TokenAmount;
20
21
  toAddress?: string;
21
- }> = ({ step, fromToken, toToken, toAddress }) => {
22
+ }> = ({ step, fromToken, toToken, impactToken, toAddress }) => {
22
23
  const { t } = useTranslation();
23
24
  const { getChainById } = useAvailableChains();
24
25
  const { subvariant } = useWidgetConfig();
@@ -89,7 +90,15 @@ export const Step: React.FC<{
89
90
  toAddressLink={toAddressLink}
90
91
  />
91
92
  ) : null}
92
- {toToken ? <Token token={toToken} px={2} py={1} /> : null}
93
+ {toToken ? (
94
+ <Token
95
+ token={toToken}
96
+ impactToken={impactToken}
97
+ enableImpactTokenTooltip
98
+ px={2}
99
+ py={1}
100
+ />
101
+ ) : null}
93
102
  </Box>
94
103
  </Card>
95
104
  );
@@ -12,19 +12,27 @@ export const getStepList = (
12
12
  const lastIndex = steps.length - 1;
13
13
  const fromToken: TokenAmount | undefined =
14
14
  index === 0
15
- ? { ...step.action.fromToken, amount: BigInt(step.action.fromAmount) }
16
- : undefined;
17
- const toToken: TokenAmount | undefined =
18
- index === lastIndex
19
15
  ? {
20
- ...(step.execution?.toToken ?? step.action?.toToken),
21
- amount: step.execution?.toAmount
22
- ? BigInt(step.execution.toAmount)
23
- : subvariant === 'custom'
24
- ? BigInt(route.toAmount)
25
- : BigInt(step.estimate.toAmount),
16
+ ...step.action.fromToken,
17
+ amount: BigInt(step.action.fromAmount),
26
18
  }
27
19
  : undefined;
20
+ let toToken: TokenAmount | undefined;
21
+ let impactToken: TokenAmount | undefined;
22
+ if (index === lastIndex) {
23
+ toToken = {
24
+ ...(step.execution?.toToken ?? step.action.toToken),
25
+ amount: step.execution?.toAmount
26
+ ? BigInt(step.execution.toAmount)
27
+ : subvariant === 'custom'
28
+ ? BigInt(route.toAmount)
29
+ : BigInt(step.estimate.toAmount),
30
+ };
31
+ impactToken = {
32
+ ...steps[0].action.fromToken,
33
+ amount: BigInt(steps[0].action.fromAmount),
34
+ };
35
+ }
28
36
  const toAddress =
29
37
  index === lastIndex && route.fromAddress !== route.toAddress
30
38
  ? route.toAddress
@@ -35,6 +43,7 @@ export const getStepList = (
35
43
  step={step}
36
44
  fromToken={fromToken}
37
45
  toToken={toToken}
46
+ impactToken={impactToken}
38
47
  toAddress={toAddress}
39
48
  />
40
49
  {steps.length > 1 && index !== steps.length - 1 ? (
@@ -1,7 +1,7 @@
1
1
  import type { LiFiStepExtended } from '@lifi/sdk';
2
2
  import { useEffect, useState } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
- import { useTimer } from 'react-timer-hook';
4
+ import { useTimer } from '../../hooks/timer/useTimer.js';
5
5
 
6
6
  const getExpiryTimestamp = (step: LiFiStepExtended) =>
7
7
  new Date(
@@ -52,11 +52,14 @@ export const StepTimer: React.FC<{
52
52
  ]);
53
53
 
54
54
  if (!isExecutionStarted) {
55
- return new Intl.NumberFormat(i18n.language, {
56
- style: 'unit',
57
- unit: 'minute',
58
- unitDisplay: 'narrow',
59
- }).format(Math.ceil(step.estimate.executionDuration / 60));
55
+ return Math.ceil(step.estimate.executionDuration / 60).toLocaleString(
56
+ i18n.language,
57
+ {
58
+ style: 'unit',
59
+ unit: 'minute',
60
+ unitDisplay: 'narrow',
61
+ },
62
+ );
60
63
  }
61
64
 
62
65
  const isTimerExpired = isExpired || (!minutes && !seconds);