@lifi/widget 3.13.1 → 3.14.0-beta.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 (200) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +10 -5
  3. package/dist/esm/AppDrawer.style.d.ts +1 -3
  4. package/dist/esm/AppRoutes.d.ts +1 -1
  5. package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js +1 -0
  6. package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js.map +1 -1
  7. package/dist/esm/components/ActiveTransactions/ActiveTransactions.style.d.ts +3 -9
  8. package/dist/esm/components/AlertMessage/AlertMessage.style.d.ts +2 -6
  9. package/dist/esm/components/AmountInput/AmountInput.style.d.ts +2 -6
  10. package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +2 -6
  11. package/dist/esm/components/AppContainer.d.ts +3 -9
  12. package/dist/esm/components/Avatar/Avatar.style.d.ts +6 -18
  13. package/dist/esm/components/Avatar/SmallAvatar.d.ts +1 -3
  14. package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js +2 -2
  15. package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
  16. package/dist/esm/components/ButtonTertiary.d.ts +1 -3
  17. package/dist/esm/components/ButtonTertiary.js +4 -5
  18. package/dist/esm/components/ButtonTertiary.js.map +1 -1
  19. package/dist/esm/components/Card/Card.d.ts +1 -3
  20. package/dist/esm/components/Card/CardButton.style.d.ts +4 -12
  21. package/dist/esm/components/Card/CardHeader.d.ts +1 -3
  22. package/dist/esm/components/Card/CardIconButton.d.ts +1 -3
  23. package/dist/esm/components/Card/CardLabel.d.ts +2 -6
  24. package/dist/esm/components/Card/CardLabel.js +0 -1
  25. package/dist/esm/components/Card/CardLabel.js.map +1 -1
  26. package/dist/esm/components/Card/CardTitle.d.ts +1 -3
  27. package/dist/esm/components/Card/InputCard.d.ts +1 -3
  28. package/dist/esm/components/ChainSelect/ChainSelect.style.d.ts +2 -6
  29. package/dist/esm/components/ContractComponent/NFT/NFT.style.d.ts +1 -3
  30. package/dist/esm/components/Header/Header.style.d.ts +6 -18
  31. package/dist/esm/components/Header/SettingsButton.style.d.ts +2 -6
  32. package/dist/esm/components/IconTypography.d.ts +1 -3
  33. package/dist/esm/components/ListItem/ListItem.d.ts +1 -3
  34. package/dist/esm/components/ListItem/ListItemButton.d.ts +1 -3
  35. package/dist/esm/components/ListItemButton.d.ts +1 -3
  36. package/dist/esm/components/PageContainer.d.ts +1 -3
  37. package/dist/esm/components/PoweredBy/PoweredBy.style.d.ts +1 -3
  38. package/dist/esm/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +3 -9
  39. package/dist/esm/components/RouteCard/RouteCard.js +13 -4
  40. package/dist/esm/components/RouteCard/RouteCard.js.map +1 -1
  41. package/dist/esm/components/RouteCard/RouteCard.style.d.ts +1 -3
  42. package/dist/esm/components/RouteCard/getMatchingLabels.d.ts +3 -0
  43. package/dist/esm/components/RouteCard/getMatchingLabels.js +34 -0
  44. package/dist/esm/components/RouteCard/getMatchingLabels.js.map +1 -0
  45. package/dist/esm/components/Routes/RoutesExpanded.js +1 -1
  46. package/dist/esm/components/Routes/RoutesExpanded.js.map +1 -1
  47. package/dist/esm/components/Routes/RoutesExpanded.style.d.ts +4 -12
  48. package/dist/esm/components/Search/SearchInput.style.d.ts +2 -6
  49. package/dist/esm/components/Search/SearchNotFound.style.d.ts +3 -9
  50. package/dist/esm/components/SelectTokenButton/SelectTokenButton.style.d.ts +3 -9
  51. package/dist/esm/components/SendToWallet/SendToWallet.style.d.ts +1 -3
  52. package/dist/esm/components/SettingsListItemButton.d.ts +1 -3
  53. package/dist/esm/components/Skeleton/WidgetSkeleton.style.d.ts +11 -33
  54. package/dist/esm/components/Step/CircularProgress.js +2 -1
  55. package/dist/esm/components/Step/CircularProgress.js.map +1 -1
  56. package/dist/esm/components/Step/CircularProgress.style.d.ts +1 -3
  57. package/dist/esm/components/Step/CircularProgress.style.js +13 -2
  58. package/dist/esm/components/Step/CircularProgress.style.js.map +1 -1
  59. package/dist/esm/components/Step/Step.js +17 -8
  60. package/dist/esm/components/Step/Step.js.map +1 -1
  61. package/dist/esm/components/Step/StepProcess.js +2 -1
  62. package/dist/esm/components/Step/StepProcess.js.map +1 -1
  63. package/dist/esm/components/Step/StepTimer.js +2 -1
  64. package/dist/esm/components/Step/StepTimer.js.map +1 -1
  65. package/dist/esm/components/StepActions/StepActions.style.d.ts +3 -9
  66. package/dist/esm/components/StepDivider/StepDivider.style.d.ts +1 -3
  67. package/dist/esm/components/Tabs/Tabs.style.d.ts +3 -9
  68. package/dist/esm/components/Token/Token.style.d.ts +3 -9
  69. package/dist/esm/components/TokenList/TokenList.style.d.ts +3 -9
  70. package/dist/esm/components/TokenList/TokenListItem.js +1 -1
  71. package/dist/esm/components/TokenList/TokenListItem.js.map +1 -1
  72. package/dist/esm/components/TokenRate/TokenRate.style.d.ts +1 -3
  73. package/dist/esm/config/version.d.ts +1 -1
  74. package/dist/esm/config/version.js +1 -1
  75. package/dist/esm/config/version.js.map +1 -1
  76. package/dist/esm/hooks/timer/useInterval.js +1 -1
  77. package/dist/esm/hooks/timer/useInterval.js.map +1 -1
  78. package/dist/esm/hooks/useDebouncedWatch.js +1 -1
  79. package/dist/esm/hooks/useDebouncedWatch.js.map +1 -1
  80. package/dist/esm/hooks/useProcessMessage.js +18 -6
  81. package/dist/esm/hooks/useProcessMessage.js.map +1 -1
  82. package/dist/esm/hooks/useRoutes.d.ts +2 -2
  83. package/dist/esm/hooks/useRoutes.js +99 -58
  84. package/dist/esm/hooks/useRoutes.js.map +1 -1
  85. package/dist/esm/hooks/useSetContentHeight.d.ts +1 -1
  86. package/dist/esm/hooks/useSetContentHeight.js.map +1 -1
  87. package/dist/esm/i18n/bn.json +5 -1
  88. package/dist/esm/i18n/de.json +5 -1
  89. package/dist/esm/i18n/en.json +14 -10
  90. package/dist/esm/i18n/es.json +5 -1
  91. package/dist/esm/i18n/fr.json +5 -1
  92. package/dist/esm/i18n/hi.json +5 -1
  93. package/dist/esm/i18n/id.json +5 -1
  94. package/dist/esm/i18n/it.json +5 -1
  95. package/dist/esm/i18n/ja.json +5 -1
  96. package/dist/esm/i18n/ko.json +5 -1
  97. package/dist/esm/i18n/pt.json +5 -1
  98. package/dist/esm/i18n/th.json +5 -1
  99. package/dist/esm/i18n/tr.json +5 -1
  100. package/dist/esm/i18n/uk.json +5 -1
  101. package/dist/esm/i18n/vi.json +5 -1
  102. package/dist/esm/i18n/zh.json +5 -1
  103. package/dist/esm/pages/MainPage/MainPage.style.d.ts +1 -3
  104. package/dist/esm/pages/RoutesPage/RoutesPage.style.d.ts +1 -3
  105. package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js +1 -2
  106. package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js.map +1 -1
  107. package/dist/esm/pages/SendToWallet/BookmarksPage.js.map +1 -1
  108. package/dist/esm/pages/SendToWallet/SendToWalletPage.style.d.ts +15 -45
  109. package/dist/esm/pages/SettingsPage/ResetSettingsButton.style.d.ts +1 -3
  110. package/dist/esm/pages/SettingsPage/SettingsCard/SettingCard.style.d.ts +2 -6
  111. package/dist/esm/pages/SettingsPage/SlippageSettings/SlippageSettings.style.d.ts +3 -9
  112. package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.js +2 -2
  113. package/dist/esm/pages/TransactionPage/ExchangeRateBottomSheet.js.map +1 -1
  114. package/dist/esm/pages/TransactionPage/StatusBottomSheet.js +1 -1
  115. package/dist/esm/pages/TransactionPage/StatusBottomSheet.js.map +1 -1
  116. package/dist/esm/pages/TransactionPage/StatusBottomSheet.style.d.ts +3 -9
  117. package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.js +1 -1
  118. package/dist/esm/pages/TransactionPage/TokenValueBottomSheet.js.map +1 -1
  119. package/dist/esm/providers/WalletProvider/EVMBaseProvider.js +1 -1
  120. package/dist/esm/providers/WalletProvider/EVMBaseProvider.js.map +1 -1
  121. package/dist/esm/providers/WalletProvider/SDKProviders.js +2 -15
  122. package/dist/esm/providers/WalletProvider/SDKProviders.js.map +1 -1
  123. package/dist/esm/providers/WalletProvider/UTXOBaseProvider.js +1 -1
  124. package/dist/esm/providers/WalletProvider/UTXOBaseProvider.js.map +1 -1
  125. package/dist/esm/stores/bookmarks/BookmarkStore.js +1 -1
  126. package/dist/esm/stores/bookmarks/BookmarkStore.js.map +1 -1
  127. package/dist/esm/stores/chains/ChainOrderStore.js +1 -1
  128. package/dist/esm/stores/chains/ChainOrderStore.js.map +1 -1
  129. package/dist/esm/stores/form/FormStore.js +1 -1
  130. package/dist/esm/stores/form/FormStore.js.map +1 -1
  131. package/dist/esm/stores/header/useHeaderStore.js +1 -1
  132. package/dist/esm/stores/header/useHeaderStore.js.map +1 -1
  133. package/dist/esm/stores/routes/RouteExecutionStore.js +1 -1
  134. package/dist/esm/stores/routes/RouteExecutionStore.js.map +1 -1
  135. package/dist/esm/stores/routes/useExecutingRoutesIds.js +2 -2
  136. package/dist/esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
  137. package/dist/esm/stores/settings/useSplitSubvariantStore.js +1 -1
  138. package/dist/esm/stores/settings/useSplitSubvariantStore.js.map +1 -1
  139. package/dist/esm/themes/createTheme.js +4 -5
  140. package/dist/esm/themes/createTheme.js.map +1 -1
  141. package/dist/esm/types/widget.d.ts +19 -1
  142. package/dist/esm/types/widget.js.map +1 -1
  143. package/package.json +13 -16
  144. package/src/components/ActiveTransactions/ActiveTransactionItem.tsx +1 -0
  145. package/src/components/BaseTransactionButton/BaseTransactionButton.tsx +3 -3
  146. package/src/components/ButtonTertiary.tsx +4 -5
  147. package/src/components/Card/CardLabel.tsx +0 -1
  148. package/src/components/RouteCard/RouteCard.tsx +19 -6
  149. package/src/components/RouteCard/getMatchingLabels.ts +53 -0
  150. package/src/components/Routes/RoutesExpanded.tsx +3 -3
  151. package/src/components/Step/CircularProgress.style.tsx +13 -2
  152. package/src/components/Step/CircularProgress.tsx +2 -1
  153. package/src/components/Step/Step.tsx +23 -12
  154. package/src/components/Step/StepProcess.tsx +2 -1
  155. package/src/components/Step/StepTimer.tsx +3 -1
  156. package/src/components/TokenList/TokenListItem.tsx +1 -1
  157. package/src/config/version.ts +1 -1
  158. package/src/hooks/timer/useInterval.ts +1 -1
  159. package/src/hooks/useDebouncedWatch.ts +1 -1
  160. package/src/hooks/useProcessMessage.ts +24 -5
  161. package/src/hooks/useRoutes.ts +127 -66
  162. package/src/hooks/useSetContentHeight.ts +1 -1
  163. package/src/i18n/bn.json +5 -1
  164. package/src/i18n/de.json +5 -1
  165. package/src/i18n/en.json +14 -10
  166. package/src/i18n/es.json +5 -1
  167. package/src/i18n/fr.json +5 -1
  168. package/src/i18n/hi.json +5 -1
  169. package/src/i18n/id.json +5 -1
  170. package/src/i18n/it.json +5 -1
  171. package/src/i18n/ja.json +5 -1
  172. package/src/i18n/ko.json +5 -1
  173. package/src/i18n/pt.json +5 -1
  174. package/src/i18n/th.json +5 -1
  175. package/src/i18n/tr.json +5 -1
  176. package/src/i18n/uk.json +5 -1
  177. package/src/i18n/vi.json +5 -1
  178. package/src/i18n/zh.json +5 -1
  179. package/src/pages/SendToWallet/BookmarkAddressSheet.tsx +2 -3
  180. package/src/pages/SendToWallet/BookmarksPage.tsx +0 -1
  181. package/src/pages/TransactionPage/ExchangeRateBottomSheet.tsx +2 -2
  182. package/src/pages/TransactionPage/StatusBottomSheet.tsx +1 -1
  183. package/src/pages/TransactionPage/TokenValueBottomSheet.tsx +1 -1
  184. package/src/providers/WalletProvider/EVMBaseProvider.tsx +1 -1
  185. package/src/providers/WalletProvider/SDKProviders.tsx +2 -16
  186. package/src/providers/WalletProvider/UTXOBaseProvider.tsx +1 -1
  187. package/src/stores/bookmarks/BookmarkStore.tsx +1 -1
  188. package/src/stores/chains/ChainOrderStore.tsx +1 -1
  189. package/src/stores/form/FormStore.tsx +1 -1
  190. package/src/stores/header/useHeaderStore.tsx +1 -1
  191. package/src/stores/routes/RouteExecutionStore.tsx +1 -1
  192. package/src/stores/routes/useExecutingRoutesIds.ts +2 -2
  193. package/src/stores/settings/useSplitSubvariantStore.tsx +1 -1
  194. package/src/themes/createTheme.ts +6 -8
  195. package/src/themes/types.ts +0 -1
  196. package/src/types/widget.ts +23 -0
  197. package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.d.ts +0 -8
  198. package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.js +0 -95
  199. package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.js.map +0 -1
  200. package/src/providers/WalletProvider/getSafeMultisigConfig.ts +0 -144
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "3.13.1",
3
+ "version": "3.14.0-beta.0",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "type": "module",
6
6
  "main": "./dist/esm/index.js",
@@ -30,29 +30,26 @@
30
30
  "lifi"
31
31
  ],
32
32
  "dependencies": {
33
- "@bigmi/client": "^0.0.7",
34
- "@bigmi/core": "^0.0.7",
33
+ "@bigmi/client": "^0.1.0",
34
+ "@bigmi/core": "^0.1.0",
35
35
  "@emotion/react": "^11.14.0",
36
36
  "@emotion/styled": "^11.14.0",
37
- "@lifi/sdk": "^3.4.4",
37
+ "@lifi/sdk": "3.6.0-beta.3",
38
38
  "@mui/icons-material": "6.0.2",
39
- "@mui/lab": "6.0.0-beta.20",
40
- "@mui/material": "^6.2.0",
41
- "@mui/system": "^6.2.0",
39
+ "@mui/material": "^6.4.0",
40
+ "@mui/system": "^6.4.0",
42
41
  "@solana/wallet-adapter-base": "^0.9.23",
43
42
  "@solana/web3.js": "^1.98.0",
44
43
  "@tanstack/react-virtual": "^3.11.2",
45
- "i18next": "^24.2.0",
46
- "microdiff": "^1.4.0",
44
+ "i18next": "^24.2.1",
45
+ "microdiff": "^1.5.0",
47
46
  "mitt": "^3.0.1",
48
- "react": "^18.3.1",
49
- "react-dom": "^18.3.1",
50
- "react-i18next": "^15.2.0",
51
- "react-intersection-observer": "^9.14.0",
47
+ "react-i18next": "^15.4.0",
48
+ "react-intersection-observer": "^9.15.0",
52
49
  "react-router-dom": "^6.28.0",
53
- "viem": "^2.21.55",
54
- "zustand": "^5.0.2",
55
- "@lifi/wallet-management": "^3.5.1"
50
+ "viem": "^2.22.8",
51
+ "zustand": "^5.0.3",
52
+ "@lifi/wallet-management": "^3.6.0-beta.0"
56
53
  },
57
54
  "peerDependencies": {
58
55
  "@bigmi/react": ">=0.0.7",
@@ -35,6 +35,7 @@ export const ActiveTransactionItem: React.FC<{
35
35
 
36
36
  const getStatusComponent = () => {
37
37
  switch (lastActiveProcess?.status) {
38
+ case 'PERMIT_REQUIRED':
38
39
  case 'ACTION_REQUIRED':
39
40
  return <InfoRounded color="info" fontSize="small" />
40
41
  case 'FAILED':
@@ -1,5 +1,5 @@
1
1
  import { useAccount, useWalletMenu } from '@lifi/wallet-management'
2
- import { LoadingButton } from '@mui/lab'
2
+ import { Button } from '@mui/material'
3
3
  import { useTranslation } from 'react-i18next'
4
4
  import { useChain } from '../../hooks/useChain.js'
5
5
  import { useWidgetConfig } from '../../providers/WidgetProvider/WidgetProvider.js'
@@ -39,7 +39,7 @@ export const BaseTransactionButton: React.FC<BaseTransactionButtonProps> = ({
39
39
  }
40
40
 
41
41
  return (
42
- <LoadingButton
42
+ <Button
43
43
  variant="contained"
44
44
  color="primary"
45
45
  onClick={handleClick}
@@ -49,6 +49,6 @@ export const BaseTransactionButton: React.FC<BaseTransactionButtonProps> = ({
49
49
  fullWidth
50
50
  >
51
51
  {getButtonText()}
52
- </LoadingButton>
52
+ </Button>
53
53
  )
54
54
  }
@@ -1,8 +1,7 @@
1
- import { LoadingButton, loadingButtonClasses } from '@mui/lab'
2
- import { styled } from '@mui/material'
1
+ import { Button, buttonClasses, styled } from '@mui/material'
3
2
  import { getContrastAlphaColor } from '../utils/colors.js'
4
3
 
5
- export const ButtonTertiary = styled(LoadingButton)(({ theme }) => ({
4
+ export const ButtonTertiary = styled(Button)(({ theme }) => ({
6
5
  color: theme.palette.text.primary,
7
6
  height: 40,
8
7
  fontSize: 14,
@@ -10,10 +9,10 @@ export const ButtonTertiary = styled(LoadingButton)(({ theme }) => ({
10
9
  '&:hover, &:active': {
11
10
  backgroundColor: getContrastAlphaColor(theme, 0.08),
12
11
  },
13
- [`&.${loadingButtonClasses.loading}:disabled`]: {
12
+ [`&.${buttonClasses.loading}:disabled`]: {
14
13
  backgroundColor: getContrastAlphaColor(theme, 0.04),
15
14
  },
16
- [`.${loadingButtonClasses.loadingIndicator}`]: {
15
+ [`.${buttonClasses.loadingIndicator}`]: {
17
16
  color: theme.palette.text.primary,
18
17
  },
19
18
  }))
@@ -13,7 +13,6 @@ export const CardLabel = styled(Box, {
13
13
  minWidth: 24,
14
14
  userSelect: 'none',
15
15
  fontSize: '1rem',
16
- marginRight: theme.spacing(1),
17
16
  backgroundColor: blend(
18
17
  theme.palette.background.paper,
19
18
  theme.palette.common.white,
@@ -1,4 +1,5 @@
1
1
  import type { TokenAmount } from '@lifi/sdk'
2
+ import { isEVMPermitStep } from '@lifi/sdk'
2
3
  import { ExpandLess, ExpandMore } from '@mui/icons-material'
3
4
  import { Box, Collapse } from '@mui/material'
4
5
  import type { MouseEventHandler } from 'react'
@@ -14,6 +15,7 @@ import { Token } from '../Token/Token.js'
14
15
  import { TokenContainer } from './RouteCard.style.js'
15
16
  import { RouteCardEssentials } from './RouteCardEssentials.js'
16
17
  import { RouteCardEssentialsExpanded } from './RouteCardEssentialsExpanded.js'
18
+ import { getMatchingLabels } from './getMatchingLabels.js'
17
19
  import type { RouteCardProps } from './types.js'
18
20
 
19
21
  export const RouteCard: React.FC<
@@ -26,7 +28,7 @@ export const RouteCard: React.FC<
26
28
  ...other
27
29
  }) => {
28
30
  const { t } = useTranslation()
29
- const { subvariant, subvariantOptions } = useWidgetConfig()
31
+ const { subvariant, subvariantOptions, routeLabels } = useWidgetConfig()
30
32
  const [cardExpanded, setCardExpanded] = useState(defaulExpanded)
31
33
 
32
34
  const handleExpand: MouseEventHandler<HTMLButtonElement> = (e) => {
@@ -43,9 +45,13 @@ export const RouteCard: React.FC<
43
45
  ? { ...route.fromToken, amount: BigInt(route.fromAmount) }
44
46
  : undefined
45
47
 
46
- const tags = route.tags?.filter(
47
- (tag) => tag === 'CHEAPEST' || tag === 'FASTEST'
48
- )
48
+ const customLabels = getMatchingLabels(route, routeLabels)
49
+ const tags: string[] =
50
+ route.tags?.filter((tag) => tag === 'CHEAPEST' || tag === 'FASTEST') ?? []
51
+ const hasRelayerSupport = route.steps.some((step) => isEVMPermitStep(step))
52
+ if (hasRelayerSupport) {
53
+ tags.push('GASLESS')
54
+ }
49
55
 
50
56
  const cardContent = (
51
57
  <Box
@@ -53,21 +59,28 @@ export const RouteCard: React.FC<
53
59
  flex: 1,
54
60
  }}
55
61
  >
56
- {subvariant !== 'refuel' && route.tags?.length ? (
62
+ {subvariant !== 'refuel' && (tags.length || customLabels.length) ? (
57
63
  <Box
58
64
  sx={{
59
65
  display: 'flex',
60
66
  alignItems: 'center',
61
67
  mb: 2,
68
+ gap: 1,
69
+ flexWrap: 'wrap',
62
70
  }}
63
71
  >
64
- {tags?.length ? (
72
+ {tags.length ? (
65
73
  <CardLabel type={active ? 'active' : undefined}>
66
74
  <CardLabelTypography>
67
75
  {t(`main.tags.${tags[0].toLowerCase()}` as any)}
68
76
  </CardLabelTypography>
69
77
  </CardLabel>
70
78
  ) : null}
79
+ {customLabels.map((label, index) => (
80
+ <CardLabel key={index} sx={label.sx}>
81
+ <CardLabelTypography>{label.text}</CardLabelTypography>
82
+ </CardLabel>
83
+ ))}
71
84
  </Box>
72
85
  ) : null}
73
86
  <TokenContainer>
@@ -0,0 +1,53 @@
1
+ import type { Route } from '@lifi/sdk'
2
+ import type { RouteLabel, RouteLabelRule } from '../../types/widget.js'
3
+ import { isItemAllowed } from '../../utils/item.js'
4
+
5
+ export const getMatchingLabels = (
6
+ route: Route,
7
+ routeLabels?: RouteLabelRule[]
8
+ ): RouteLabel[] => {
9
+ if (!routeLabels?.length) {
10
+ return []
11
+ }
12
+
13
+ return routeLabels
14
+ .filter((rule) => {
15
+ const conditions: boolean[] = []
16
+
17
+ // Check bridge/exchange matches if specified
18
+ if (rule.bridges || rule.exchanges) {
19
+ const toolNames = route.steps.flatMap((step) =>
20
+ step.includedSteps.map((s) => s.tool)
21
+ )
22
+ conditions.push(
23
+ toolNames.some(
24
+ (toolName) =>
25
+ isItemAllowed(toolName, rule.bridges) &&
26
+ isItemAllowed(toolName, rule.exchanges)
27
+ )
28
+ )
29
+ }
30
+
31
+ // Check token matches if specified
32
+ if (rule.fromTokenAddress?.length) {
33
+ conditions.push(rule.fromTokenAddress.includes(route.fromToken.address))
34
+ }
35
+
36
+ if (rule.toTokenAddress?.length) {
37
+ conditions.push(rule.toTokenAddress.includes(route.toToken.address))
38
+ }
39
+
40
+ // Check chain matches if specified
41
+ if (rule.fromChainId?.length) {
42
+ conditions.push(rule.fromChainId.includes(route.fromChainId))
43
+ }
44
+
45
+ if (rule.toChainId?.length) {
46
+ conditions.push(rule.toChainId.includes(route.toChainId))
47
+ }
48
+
49
+ // Must have at least one condition and all conditions must be true
50
+ return conditions.length && conditions.every(Boolean)
51
+ })
52
+ .map((rule) => rule.label)
53
+ }
@@ -1,7 +1,7 @@
1
1
  import type { Route } from '@lifi/sdk'
2
2
  import { useAccount } from '@lifi/wallet-management'
3
3
  import { Collapse, Grow, Stack, Typography } from '@mui/material'
4
- import { useEffect, useRef } from 'react'
4
+ import { type PropsWithChildren, useEffect, useRef } from 'react'
5
5
  import { useTranslation } from 'react-i18next'
6
6
  import type { RouteObject } from 'react-router-dom'
7
7
  import { useRoutes as useDOMRoutes, useNavigate } from 'react-router-dom'
@@ -41,7 +41,7 @@ const routes: RouteObject[] = [
41
41
 
42
42
  export const RoutesExpanded = () => {
43
43
  const element = useDOMRoutes(routes)
44
- const match = Boolean(element?.props?.children)
44
+ const match = Boolean((element?.props as PropsWithChildren)?.children)
45
45
 
46
46
  return (
47
47
  <CollapseContainer>
@@ -65,7 +65,7 @@ export const RoutesExpandedElement = () => {
65
65
  const { t } = useTranslation()
66
66
  const navigate = useNavigate()
67
67
  const { subvariant, subvariantOptions } = useWidgetConfig()
68
- const routesRef = useRef<Route[]>()
68
+ const routesRef = useRef<Route[]>(undefined)
69
69
  const emitter = useWidgetEvents()
70
70
  const routesActiveRef = useRef(false)
71
71
  const {
@@ -15,6 +15,7 @@ const getStatusColor = (
15
15
  substatus?: Substatus
16
16
  ) => {
17
17
  switch (status) {
18
+ case 'PERMIT_REQUIRED':
18
19
  case 'ACTION_REQUIRED':
19
20
  return alpha(theme.palette.info.main, 0.12)
20
21
  case 'DONE':
@@ -33,12 +34,22 @@ export const CircularIcon = styled(Box, {
33
34
  shouldForwardProp: (prop: string) => !['status', 'substatus'].includes(prop),
34
35
  })<{ status?: ProcessStatus; substatus?: Substatus }>(
35
36
  ({ theme, status, substatus }) => ({
36
- backgroundColor: ['ACTION_REQUIRED', 'DONE', 'FAILED'].includes(status!)
37
+ backgroundColor: [
38
+ 'PERMIT_REQUIRED',
39
+ 'ACTION_REQUIRED',
40
+ 'DONE',
41
+ 'FAILED',
42
+ ].includes(status!)
37
43
  ? getStatusColor(theme, status, substatus)
38
44
  : theme.palette.background.paper,
39
45
  borderStyle: 'solid',
40
46
  borderColor: getStatusColor(theme, status, substatus),
41
- borderWidth: !['ACTION_REQUIRED', 'DONE', 'FAILED'].includes(status!)
47
+ borderWidth: ![
48
+ 'PERMIT_REQUIRED',
49
+ 'ACTION_REQUIRED',
50
+ 'DONE',
51
+ 'FAILED',
52
+ ].includes(status!)
42
53
  ? 3
43
54
  : 0,
44
55
  display: 'grid',
@@ -17,7 +17,8 @@ export function CircularProgress({ process }: { process: Process }) {
17
17
  {process.status === 'STARTED' || process.status === 'PENDING' ? (
18
18
  <CircularProgressPending size={40} />
19
19
  ) : null}
20
- {process.status === 'ACTION_REQUIRED' ? (
20
+ {process.status === 'PERMIT_REQUIRED' ||
21
+ process.status === 'ACTION_REQUIRED' ? (
21
22
  <InfoRounded
22
23
  color="info"
23
24
  sx={{
@@ -27,36 +27,47 @@ export const Step: React.FC<{
27
27
  )
28
28
 
29
29
  const getCardTitle = () => {
30
+ const hasBridgeStep = step.includedSteps.some(
31
+ (step) => step.type === 'cross'
32
+ )
33
+ const hasSwapStep = step.includedSteps.some((step) => step.type === 'swap')
34
+ const hasCustomStep = step.includedSteps.some(
35
+ (step) => step.type === 'custom'
36
+ )
37
+
38
+ const isCustomVariant = hasCustomStep && subvariant === 'custom'
39
+
30
40
  switch (step.type) {
31
41
  case 'lifi': {
32
- const hasBridgeStep = step.includedSteps.some(
33
- (step) => step.type === 'cross'
34
- )
35
- const hasSwapStep = step.includedSteps.some(
36
- (step) => step.type === 'swap'
37
- )
38
42
  if (hasBridgeStep && hasSwapStep) {
39
- return subvariant === 'custom'
43
+ return isCustomVariant
40
44
  ? subvariantOptions?.custom === 'deposit'
41
45
  ? t('main.stepBridgeAndDeposit')
42
46
  : t('main.stepBridgeAndBuy')
43
47
  : t('main.stepSwapAndBridge')
44
48
  }
45
49
  if (hasBridgeStep) {
46
- return subvariant === 'custom'
50
+ return isCustomVariant
47
51
  ? subvariantOptions?.custom === 'deposit'
48
52
  ? t('main.stepBridgeAndDeposit')
49
53
  : t('main.stepBridgeAndBuy')
50
54
  : t('main.stepBridge')
51
55
  }
52
- return subvariant === 'custom'
56
+ if (hasSwapStep) {
57
+ return isCustomVariant
58
+ ? subvariantOptions?.custom === 'deposit'
59
+ ? t('main.stepSwapAndDeposit')
60
+ : t('main.stepSwapAndBuy')
61
+ : t('main.stepSwap')
62
+ }
63
+ return isCustomVariant
53
64
  ? subvariantOptions?.custom === 'deposit'
54
- ? t('main.stepSwapAndDeposit')
55
- : t('main.stepSwapAndBuy')
65
+ ? t('main.stepDeposit')
66
+ : t('main.stepBuy')
56
67
  : t('main.stepSwap')
57
68
  }
58
69
  default:
59
- return subvariant === 'custom'
70
+ return isCustomVariant
60
71
  ? subvariantOptions?.custom === 'deposit'
61
72
  ? t('main.stepDeposit')
62
73
  : t('main.stepBuy')
@@ -29,7 +29,8 @@ export const StepProcess: React.FC<{
29
29
  <CircularProgress process={process} />
30
30
  <Typography
31
31
  sx={{
32
- mx: 2,
32
+ marginLeft: 2,
33
+ marginRight: 0.5,
33
34
  flex: 1,
34
35
  fontSize: 14,
35
36
  fontWeight: process.error ? 600 : 400,
@@ -44,7 +44,9 @@ export const StepTimer: React.FC<{
44
44
  return
45
45
  }
46
46
  const shouldRestart = executionProcess.status === 'FAILED'
47
- const shouldPause = executionProcess.status === 'ACTION_REQUIRED'
47
+ const shouldPause =
48
+ executionProcess.status === 'PERMIT_REQUIRED' ||
49
+ executionProcess.status === 'ACTION_REQUIRED'
48
50
  const shouldStart =
49
51
  executionProcess.status === 'STARTED' ||
50
52
  executionProcess.status === 'PENDING'
@@ -73,7 +73,7 @@ export const TokenListItemButton: React.FC<TokenListItemButtonProps> = ({
73
73
  )
74
74
  : undefined
75
75
  const container = useRef(null)
76
- const timeoutId = useRef<ReturnType<typeof setTimeout>>()
76
+ const timeoutId = useRef<ReturnType<typeof setTimeout>>(undefined)
77
77
  const [showAddress, setShowAddress] = useState(false)
78
78
 
79
79
  const tokenAddress =
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget'
2
- export const version = '3.13.1'
2
+ export const version = '3.14.0-beta.0'
@@ -1,7 +1,7 @@
1
1
  import { useEffect, useRef } from 'react'
2
2
 
3
3
  export function useInterval(callback: () => void, delay: number) {
4
- const callbacRef = useRef<() => void>()
4
+ const callbacRef = useRef<() => void>(null)
5
5
 
6
6
  // update callback function with current render callback that has access to latest props and state
7
7
  useEffect(() => {
@@ -8,7 +8,7 @@ export const useDebouncedWatch = <T extends FormFieldNames[]>(
8
8
  ) => {
9
9
  const watchedValue = useFieldValues(...name)
10
10
  const [debouncedValue, setDebouncedValue] = useState(watchedValue)
11
- const debouncedValueRef = useRef<typeof watchedValue>()
11
+ const debouncedValueRef = useRef<typeof watchedValue>(null)
12
12
  const isMounted = useRef(false)
13
13
 
14
14
  useEffect(() => {
@@ -39,6 +39,7 @@ const processStatusMessages: Record<
39
39
  ProcessStatus,
40
40
  (
41
41
  t: TFunction,
42
+ step: LiFiStep,
42
43
  subvariant?: WidgetSubvariant,
43
44
  subvariantOptions?: SubvariantOptions
44
45
  ) => string
@@ -47,9 +48,18 @@ const processStatusMessages: Record<
47
48
  > = {
48
49
  TOKEN_ALLOWANCE: {
49
50
  STARTED: (t) => t('main.process.tokenAllowance.started'),
50
- ACTION_REQUIRED: (t) => t('main.process.tokenAllowance.pending'),
51
- PENDING: (t) => t('main.process.tokenAllowance.pending'),
52
- DONE: (t) => t('main.process.tokenAllowance.done'),
51
+ ACTION_REQUIRED: (t, step) =>
52
+ t('main.process.tokenAllowance.actionRequired', {
53
+ tokenSymbol: step.action.fromToken.symbol,
54
+ }),
55
+ PENDING: (t, step) =>
56
+ t('main.process.tokenAllowance.pending', {
57
+ tokenSymbol: step.action.fromToken.symbol,
58
+ }),
59
+ DONE: (t, step) =>
60
+ t('main.process.tokenAllowance.done', {
61
+ tokenSymbol: step.action.fromToken.symbol,
62
+ }),
53
63
  },
54
64
  SWITCH_CHAIN: {
55
65
  ACTION_REQUIRED: (t) => t('main.process.switchChain.actionRequired'),
@@ -57,22 +67,30 @@ const processStatusMessages: Record<
57
67
  },
58
68
  SWAP: {
59
69
  STARTED: (t) => t('main.process.swap.started'),
70
+ PERMIT_REQUIRED: (t, step) =>
71
+ t('main.process.swap.permitRequired', {
72
+ tokenSymbol: step.action.fromToken.symbol,
73
+ }),
60
74
  ACTION_REQUIRED: (t) => t('main.process.swap.actionRequired'),
61
75
  PENDING: (t) => t('main.process.swap.pending'),
62
- DONE: (t, subvariant, subvariantOptions) =>
76
+ DONE: (t, _, subvariant, subvariantOptions) =>
63
77
  subvariant === 'custom'
64
78
  ? t(`main.process.${subvariantOptions?.custom ?? 'checkout'}.done`)
65
79
  : t('main.process.swap.done'),
66
80
  },
67
81
  CROSS_CHAIN: {
68
82
  STARTED: (t) => t('main.process.bridge.started'),
83
+ PERMIT_REQUIRED: (t, step) =>
84
+ t('main.process.bridge.permitRequired', {
85
+ tokenSymbol: step.action.fromToken.symbol,
86
+ }),
69
87
  ACTION_REQUIRED: (t) => t('main.process.bridge.actionRequired'),
70
88
  PENDING: (t) => t('main.process.bridge.pending'),
71
89
  DONE: (t) => t('main.process.bridge.done'),
72
90
  },
73
91
  RECEIVING_CHAIN: {
74
92
  PENDING: (t) => t('main.process.receivingChain.pending'),
75
- DONE: (t, subvariant, subvariantOptions) =>
93
+ DONE: (t, _, subvariant, subvariantOptions) =>
76
94
  subvariant === 'custom'
77
95
  ? t(`main.process.${subvariantOptions?.custom ?? 'checkout'}.done`)
78
96
  : t('main.process.receivingChain.done'),
@@ -229,6 +247,7 @@ export function getProcessMessage(
229
247
  ]?.(t) ??
230
248
  processStatusMessages[process.type]?.[process.status]?.(
231
249
  t,
250
+ step,
232
251
  subvariant,
233
252
  subvariantOptions
234
253
  )