@lifi/widget 2.0.0-beta.1 → 2.0.0-beta.10

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 (283) hide show
  1. package/App.d.ts +4 -3
  2. package/AppDrawer.d.ts +1 -1
  3. package/AppDrawer.js +2 -1
  4. package/AppProvider.js +1 -1
  5. package/README.md +11 -12
  6. package/cjs/App.d.ts +4 -3
  7. package/cjs/AppDrawer.d.ts +1 -1
  8. package/cjs/AppDrawer.js +2 -1
  9. package/cjs/AppProvider.js +1 -1
  10. package/cjs/components/ChainSelect/ChainSelect.d.ts +1 -2
  11. package/cjs/components/ChainSelect/ChainSelect.style.js +1 -1
  12. package/cjs/components/ChainSelect/useChainSelect.js +6 -0
  13. package/cjs/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
  14. package/cjs/components/GasMessage/GasMessage.js +1 -6
  15. package/cjs/components/Header/Header.js +2 -2
  16. package/cjs/components/Header/Header.style.d.ts +10 -3
  17. package/cjs/components/Header/Header.style.js +3 -0
  18. package/cjs/components/Header/NavigationHeader.js +23 -7
  19. package/cjs/components/Header/NavigationTabs.d.ts +1 -0
  20. package/cjs/components/Header/NavigationTabs.js +26 -0
  21. package/cjs/components/Header/NavigationTabs.style.d.ts +34 -0
  22. package/cjs/components/Header/NavigationTabs.style.js +61 -0
  23. package/cjs/components/Header/WalletHeader.d.ts +1 -0
  24. package/cjs/components/Header/WalletHeader.js +16 -9
  25. package/cjs/components/Header/useHeaderActionStore.js +0 -1
  26. package/cjs/components/Insurance/Insurance.js +2 -2
  27. package/cjs/components/Insurance/InsuranceCard.js +34 -12
  28. package/cjs/components/Insurance/InsuranceCollapsed.js +9 -11
  29. package/cjs/components/Insurance/index.d.ts +1 -0
  30. package/cjs/components/Insurance/index.js +1 -0
  31. package/cjs/components/Insurance/types.d.ts +12 -9
  32. package/cjs/components/NFT/NFT.js +2 -2
  33. package/cjs/components/NFT/types.d.ts +1 -1
  34. package/cjs/components/PoweredBy/PoweredBy.js +2 -3
  35. package/cjs/components/SelectChainAndToken.js +8 -7
  36. package/cjs/components/SelectTokenButton/SelectTokenButton.js +6 -3
  37. package/cjs/components/SendToWallet/SendToWallet.js +2 -2
  38. package/cjs/components/SmallAvatar.d.ts +1 -1
  39. package/cjs/components/Step/CircularProgress.d.ts +1 -2
  40. package/cjs/components/Step/Step.js +15 -5
  41. package/cjs/components/Step/StepList.d.ts +1 -2
  42. package/cjs/components/StepActions/StepActions.js +4 -20
  43. package/cjs/components/SwapButton/SwapButton.js +16 -4
  44. package/cjs/components/SwapInput/FormPriceHelperText.js +1 -1
  45. package/cjs/components/SwapInput/SwapInput.js +2 -2
  46. package/cjs/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
  47. package/cjs/components/SwapInput/SwapInputEndAdornment.js +2 -2
  48. package/cjs/components/SwapRouteCard/SwapRouteCard.js +19 -3
  49. package/cjs/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  50. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
  51. package/cjs/components/SwapRoutes/SwapRoutes.js +1 -1
  52. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
  53. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
  54. package/cjs/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
  55. package/cjs/components/Token/Token.js +1 -1
  56. package/cjs/components/TokenAvatar/TokenAvatar.d.ts +4 -4
  57. package/cjs/components/TokenList/TokenList.js +9 -4
  58. package/cjs/components/TokenList/TokenList.style.d.ts +5 -2
  59. package/cjs/components/TokenList/TokenList.style.js +20 -1
  60. package/cjs/components/TokenList/TokenListItem.d.ts +1 -1
  61. package/cjs/components/TokenList/TokenListItem.js +28 -5
  62. package/cjs/components/TokenList/VirtualizedTokenList.js +3 -3
  63. package/cjs/components/TokenList/types.d.ts +6 -3
  64. package/cjs/config/theme.js +15 -3
  65. package/cjs/config/version.d.ts +1 -1
  66. package/cjs/config/version.js +1 -1
  67. package/cjs/hooks/index.d.ts +2 -1
  68. package/cjs/hooks/index.js +2 -1
  69. package/cjs/hooks/useContentHeight.js +3 -5
  70. package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
  71. package/cjs/hooks/useFundsSufficiency.js +2 -2
  72. package/cjs/hooks/useGasRefuel.d.ts +1 -1
  73. package/cjs/hooks/useGasRefuel.js +5 -15
  74. package/cjs/hooks/useGasSufficiency.js +12 -3
  75. package/cjs/hooks/useInitializer.js +0 -1
  76. package/cjs/hooks/useProcessMessage.d.ts +2 -1
  77. package/cjs/hooks/useProcessMessage.js +27 -9
  78. package/cjs/hooks/useRouteExecution.js +6 -5
  79. package/cjs/hooks/useSwapOnly.d.ts +1 -0
  80. package/cjs/hooks/useSwapOnly.js +9 -0
  81. package/cjs/hooks/useSwapRoutes.d.ts +1 -2
  82. package/cjs/hooks/useSwapRoutes.js +32 -18
  83. package/cjs/hooks/useToken.d.ts +1 -1
  84. package/cjs/hooks/useTokenAddressBalance.d.ts +2 -2
  85. package/cjs/hooks/useTokenBalance.js +6 -7
  86. package/cjs/hooks/useTokenBalances.d.ts +5 -5
  87. package/cjs/hooks/useTokenBalances.js +4 -19
  88. package/cjs/hooks/useTokenSearch.d.ts +2 -2
  89. package/cjs/hooks/useTokens.d.ts +2 -2
  90. package/cjs/i18n/bn.json +8 -0
  91. package/cjs/i18n/en.json +30 -5
  92. package/cjs/i18n/fr.json +8 -0
  93. package/cjs/i18n/id.json +22 -7
  94. package/cjs/i18n/ko.json +22 -7
  95. package/cjs/i18n/pt.json +32 -7
  96. package/cjs/i18n/th.json +21 -6
  97. package/cjs/i18n/uk.json +43 -18
  98. package/cjs/i18n/zh.json +23 -8
  99. package/cjs/icons/InsuraceLogo.d.ts +1 -1
  100. package/cjs/icons/LiFiFullLogo.d.ts +1 -1
  101. package/cjs/icons/LiFiLogo.d.ts +1 -1
  102. package/cjs/icons/LiFiToolLogo.d.ts +1 -1
  103. package/cjs/index.d.ts +1 -1
  104. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
  105. package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
  106. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +3 -1
  107. package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
  108. package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
  109. package/cjs/pages/SettingsPage/LanguageSelect.js +1 -1
  110. package/cjs/pages/SettingsPage/SettingsPage.d.ts +1 -2
  111. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
  112. package/cjs/pages/SettingsPage/SlippageInput.d.ts +1 -2
  113. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
  114. package/cjs/pages/SwapPage/ExchangeRateBottomSheet.js +1 -1
  115. package/cjs/pages/SwapPage/StatusBottomSheet.js +15 -9
  116. package/cjs/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  117. package/cjs/pages/SwapPage/StatusBottomSheet.style.js +2 -2
  118. package/cjs/pages/SwapPage/SwapPage.js +31 -10
  119. package/cjs/pages/SwapPage/TokenValueBottomSheet.js +7 -12
  120. package/cjs/pages/SwapPage/utils.d.ts +2 -0
  121. package/cjs/pages/SwapPage/utils.js +10 -0
  122. package/cjs/providers/I18nProvider/I18nProvider.js +3 -3
  123. package/cjs/providers/SDKProvider/SDKProvider.js +2 -0
  124. package/cjs/providers/SwapFormProvider/FormUpdater.js +3 -0
  125. package/cjs/providers/WalletProvider/WalletProvider.js +77 -49
  126. package/cjs/providers/WalletProvider/types.d.ts +3 -5
  127. package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -1
  128. package/cjs/stores/StoreProvider.d.ts +2 -2
  129. package/cjs/stores/StoreProvider.js +3 -2
  130. package/cjs/stores/routes/RouteExecutionStore.d.ts +1 -1
  131. package/cjs/stores/routes/RouteExecutionStore.js +0 -1
  132. package/cjs/stores/settings/index.d.ts +1 -0
  133. package/cjs/stores/settings/index.js +1 -0
  134. package/cjs/stores/settings/types.d.ts +11 -0
  135. package/cjs/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  136. package/cjs/stores/settings/useSplitSubvariantStore.js +44 -0
  137. package/cjs/types/events.d.ts +9 -1
  138. package/cjs/types/events.js +1 -0
  139. package/cjs/types/token.d.ts +2 -2
  140. package/cjs/types/widget.d.ts +13 -8
  141. package/cjs/types/widget.js +4 -2
  142. package/cjs/utils/format.d.ts +1 -1
  143. package/cjs/utils/format.js +7 -12
  144. package/cjs/utils/wallet.d.ts +1 -1
  145. package/cjs/utils/wallet.js +3 -3
  146. package/components/ChainSelect/ChainSelect.d.ts +1 -2
  147. package/components/ChainSelect/ChainSelect.style.js +1 -1
  148. package/components/ChainSelect/useChainSelect.js +7 -1
  149. package/components/GasMessage/FundsSufficiencyMessage.d.ts +1 -2
  150. package/components/GasMessage/GasMessage.js +2 -7
  151. package/components/Header/Header.js +3 -3
  152. package/components/Header/Header.style.d.ts +10 -3
  153. package/components/Header/Header.style.js +3 -0
  154. package/components/Header/NavigationHeader.js +23 -7
  155. package/components/Header/NavigationTabs.d.ts +1 -0
  156. package/components/Header/NavigationTabs.js +22 -0
  157. package/components/Header/NavigationTabs.style.d.ts +34 -0
  158. package/components/Header/NavigationTabs.style.js +58 -0
  159. package/components/Header/WalletHeader.d.ts +1 -0
  160. package/components/Header/WalletHeader.js +14 -8
  161. package/components/Header/useHeaderActionStore.js +0 -1
  162. package/components/Insurance/Insurance.js +2 -2
  163. package/components/Insurance/InsuranceCard.js +37 -15
  164. package/components/Insurance/InsuranceCollapsed.js +9 -11
  165. package/components/Insurance/index.d.ts +1 -0
  166. package/components/Insurance/index.js +1 -0
  167. package/components/Insurance/types.d.ts +12 -9
  168. package/components/NFT/NFT.js +2 -2
  169. package/components/NFT/types.d.ts +1 -1
  170. package/components/PoweredBy/PoweredBy.js +2 -3
  171. package/components/SelectChainAndToken.js +9 -8
  172. package/components/SelectTokenButton/SelectTokenButton.js +7 -4
  173. package/components/SendToWallet/SendToWallet.js +2 -2
  174. package/components/SmallAvatar.d.ts +1 -1
  175. package/components/Step/CircularProgress.d.ts +1 -2
  176. package/components/Step/Step.js +16 -6
  177. package/components/Step/StepList.d.ts +1 -2
  178. package/components/StepActions/StepActions.js +4 -20
  179. package/components/SwapButton/SwapButton.js +16 -4
  180. package/components/SwapInput/FormPriceHelperText.js +2 -2
  181. package/components/SwapInput/SwapInput.js +3 -3
  182. package/components/SwapInput/SwapInputEndAdornment.d.ts +1 -2
  183. package/components/SwapInput/SwapInputEndAdornment.js +2 -2
  184. package/components/SwapRouteCard/SwapRouteCard.js +21 -5
  185. package/components/SwapRouteCard/SwapRouteCardEssentials.js +1 -1
  186. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +1 -1
  187. package/components/SwapRoutes/SwapRoutes.js +1 -1
  188. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +2 -3
  189. package/components/SwapRoutes/SwapRoutesExpanded.js +2 -2
  190. package/components/SwapRoutes/SwapRoutesExpanded.style.js +1 -0
  191. package/components/Token/Token.js +1 -1
  192. package/components/TokenAvatar/TokenAvatar.d.ts +4 -4
  193. package/components/TokenList/TokenList.js +10 -5
  194. package/components/TokenList/TokenList.style.d.ts +5 -2
  195. package/components/TokenList/TokenList.style.js +21 -2
  196. package/components/TokenList/TokenListItem.d.ts +1 -1
  197. package/components/TokenList/TokenListItem.js +32 -9
  198. package/components/TokenList/VirtualizedTokenList.js +3 -3
  199. package/components/TokenList/types.d.ts +6 -3
  200. package/config/theme.js +15 -3
  201. package/config/version.d.ts +1 -1
  202. package/config/version.js +1 -1
  203. package/hooks/index.d.ts +2 -1
  204. package/hooks/index.js +2 -1
  205. package/hooks/useContentHeight.js +4 -6
  206. package/hooks/useFeaturedTokens.d.ts +1 -1
  207. package/hooks/useFundsSufficiency.js +2 -2
  208. package/hooks/useGasRefuel.d.ts +1 -1
  209. package/hooks/useGasRefuel.js +5 -15
  210. package/hooks/useGasSufficiency.js +13 -4
  211. package/hooks/useInitializer.js +0 -1
  212. package/hooks/useProcessMessage.d.ts +2 -1
  213. package/hooks/useProcessMessage.js +27 -9
  214. package/hooks/useRouteExecution.js +6 -5
  215. package/hooks/useSwapOnly.d.ts +1 -0
  216. package/hooks/useSwapOnly.js +5 -0
  217. package/hooks/useSwapRoutes.d.ts +1 -2
  218. package/hooks/useSwapRoutes.js +32 -18
  219. package/hooks/useToken.d.ts +1 -1
  220. package/hooks/useTokenAddressBalance.d.ts +2 -2
  221. package/hooks/useTokenBalance.js +6 -7
  222. package/hooks/useTokenBalances.d.ts +5 -5
  223. package/hooks/useTokenBalances.js +4 -19
  224. package/hooks/useTokenSearch.d.ts +2 -2
  225. package/hooks/useTokens.d.ts +2 -2
  226. package/i18n/bn.json +8 -0
  227. package/i18n/en.json +30 -5
  228. package/i18n/fr.json +8 -0
  229. package/i18n/id.json +22 -7
  230. package/i18n/ko.json +22 -7
  231. package/i18n/pt.json +32 -7
  232. package/i18n/th.json +21 -6
  233. package/i18n/uk.json +43 -18
  234. package/i18n/zh.json +23 -8
  235. package/icons/InsuraceLogo.d.ts +1 -1
  236. package/icons/LiFiFullLogo.d.ts +1 -1
  237. package/icons/LiFiLogo.d.ts +1 -1
  238. package/icons/LiFiToolLogo.d.ts +1 -1
  239. package/index.d.ts +1 -1
  240. package/package.json +13 -13
  241. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +1 -2
  242. package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -2
  243. package/pages/SelectTokenPage/SelectTokenPage.js +4 -2
  244. package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -2
  245. package/pages/SettingsPage/GasPriceSelect.d.ts +1 -2
  246. package/pages/SettingsPage/LanguageSelect.js +1 -1
  247. package/pages/SettingsPage/SettingsPage.d.ts +1 -2
  248. package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
  249. package/pages/SettingsPage/SlippageInput.d.ts +1 -2
  250. package/pages/SwapDetailsPage/SwapDetailsPage.js +6 -2
  251. package/pages/SwapPage/ExchangeRateBottomSheet.js +2 -2
  252. package/pages/SwapPage/StatusBottomSheet.js +18 -12
  253. package/pages/SwapPage/StatusBottomSheet.style.d.ts +1 -1
  254. package/pages/SwapPage/StatusBottomSheet.style.js +1 -1
  255. package/pages/SwapPage/SwapPage.js +33 -12
  256. package/pages/SwapPage/TokenValueBottomSheet.js +8 -13
  257. package/pages/SwapPage/utils.d.ts +2 -0
  258. package/pages/SwapPage/utils.js +6 -0
  259. package/providers/I18nProvider/I18nProvider.js +3 -3
  260. package/providers/SDKProvider/SDKProvider.js +2 -0
  261. package/providers/SwapFormProvider/FormUpdater.js +3 -0
  262. package/providers/WalletProvider/WalletProvider.js +78 -50
  263. package/providers/WalletProvider/types.d.ts +3 -5
  264. package/providers/WidgetProvider/WidgetProvider.js +2 -2
  265. package/stores/StoreProvider.d.ts +2 -2
  266. package/stores/StoreProvider.js +3 -2
  267. package/stores/routes/RouteExecutionStore.d.ts +1 -1
  268. package/stores/routes/RouteExecutionStore.js +0 -1
  269. package/stores/settings/index.d.ts +1 -0
  270. package/stores/settings/index.js +1 -0
  271. package/stores/settings/types.d.ts +11 -0
  272. package/stores/settings/useSplitSubvariantStore.d.ts +7 -0
  273. package/stores/settings/useSplitSubvariantStore.js +37 -0
  274. package/tsconfig.cjs.tsbuildinfo +1 -1
  275. package/types/events.d.ts +9 -1
  276. package/types/events.js +1 -0
  277. package/types/token.d.ts +2 -2
  278. package/types/widget.d.ts +13 -8
  279. package/types/widget.js +4 -2
  280. package/utils/format.d.ts +1 -1
  281. package/utils/format.js +5 -10
  282. package/utils/wallet.d.ts +1 -1
  283. package/utils/wallet.js +1 -1
@@ -33,4 +33,4 @@ export declare const SmallAvatarSkeletonContainer: import("@emotion/styled").Sty
33
33
  } & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
34
34
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
35
35
  }, "children" | "sx" | "ref" | ("p" | "color" | "border" | "boxShadow" | "fontWeight" | "zIndex" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "component"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
36
- export declare const SmallAvatarSkeleton: () => JSX.Element;
36
+ export declare const SmallAvatarSkeleton: () => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
1
  import type { Process } from '@lifi/sdk';
3
2
  export declare function CircularProgress({ process }: {
4
3
  process: Process;
5
- }): JSX.Element;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,8 @@ import { Card, CardTitle } from '../../components/Card';
5
5
  import { StepActions } from '../../components/StepActions';
6
6
  import { Token } from '../../components/Token';
7
7
  import { useChains } from '../../hooks';
8
- import { shortenWalletAddress } from '../../utils';
8
+ import { useWidgetConfig } from '../../providers';
9
+ import { shortenAddress } from '../../utils';
9
10
  import { DestinationWalletAddress } from './DestinationWalletAddress';
10
11
  import { GasStepProcess } from './GasStepProcess';
11
12
  import { StepProcess } from './StepProcess';
@@ -13,6 +14,7 @@ import { StepTimer } from './StepTimer';
13
14
  export const Step = ({ step, fromToken, toToken, toAddress }) => {
14
15
  const { t } = useTranslation();
15
16
  const { getChainById } = useChains();
17
+ const { variant } = useWidgetConfig();
16
18
  const stepHasError = step.execution?.process.some((process) => process.status === 'FAILED');
17
19
  const getCardTitle = () => {
18
20
  switch (step.type) {
@@ -20,17 +22,25 @@ export const Step = ({ step, fromToken, toToken, toAddress }) => {
20
22
  const hasCrossStep = step.includedSteps.some((step) => step.type === 'cross');
21
23
  const hasSwapStep = step.includedSteps.some((step) => step.type === 'swap');
22
24
  if (hasCrossStep && hasSwapStep) {
23
- return t('swap.stepSwapAndBridge');
25
+ return variant === 'nft'
26
+ ? t('swap.stepBridgeAndBuy')
27
+ : t('swap.stepSwapAndBridge');
24
28
  }
25
29
  if (hasCrossStep) {
26
- return t('swap.stepBridge');
30
+ return variant === 'nft'
31
+ ? t('swap.stepBridgeAndBuy')
32
+ : t('swap.stepBridge');
27
33
  }
28
- return t('swap.stepSwap');
34
+ return variant === 'nft'
35
+ ? t('swap.stepSwapAndBuy')
36
+ : t('swap.stepSwap');
29
37
  default:
30
- return t('swap.stepSwap');
38
+ return variant === 'nft'
39
+ ? t('swap.stepSwapAndBuy')
40
+ : t('swap.stepSwap');
31
41
  }
32
42
  };
33
- const formattedToAddress = shortenWalletAddress(toAddress);
43
+ const formattedToAddress = shortenAddress(toAddress);
34
44
  const toAddressLink = toAddress
35
45
  ? `${getChainById(step.action.toChainId)?.metamask.blockExplorerUrls[0]}address/${toAddress}`
36
46
  : undefined;
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { Route } from '@lifi/sdk';
3
- export declare const getStepList: (route?: Route) => JSX.Element[] | undefined;
2
+ export declare const getStepList: (route?: Route) => import("react/jsx-runtime").JSX.Element[] | undefined;
@@ -15,27 +15,13 @@ import { SmallAvatar } from '../SmallAvatar';
15
15
  import { StepAvatar, StepConnector, StepContent, StepLabel, } from './StepActions.style';
16
16
  export const StepActions = ({ step, dense, ...other }) => {
17
17
  const { t } = useTranslation();
18
- const { variant, contractTool } = useWidgetConfig();
18
+ const { variant } = useWidgetConfig();
19
19
  const [cardExpanded, setCardExpanded] = useState(false);
20
20
  const handleExpand = (e) => {
21
21
  e.stopPropagation();
22
22
  setCardExpanded((expanded) => !expanded);
23
23
  };
24
- const customStep = variant === 'nft'
25
- ? step.includedSteps?.find((step) => step.type === 'custom')
26
- : undefined;
27
24
  const hasCollapsedSteps = dense && step.includedSteps?.length > 1;
28
- if (customStep && contractTool) {
29
- const toolDetails = {
30
- key: contractTool.name,
31
- name: contractTool.name,
32
- logoURI: contractTool.logoURI,
33
- };
34
- customStep.toolDetails = toolDetails;
35
- if (dense) {
36
- step.toolDetails = toolDetails;
37
- }
38
- }
39
25
  return (_jsxs(Box, { ...other, children: [_jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Badge, { overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: _jsx(SmallAvatar, { children: _jsx(LiFiToolLogo, {}) }), children: _jsx(StepAvatar, { variant: "circular", src: step.toolDetails.logoURI, alt: step.toolDetails.name, children: step.toolDetails.name[0] }) }), _jsx(Typography, { ml: 2, fontSize: 18, fontWeight: "500", flex: 1, children: t(`swap.stepDetails`, {
40
26
  tool: step.toolDetails.name,
41
27
  }) }), hasCollapsedSteps ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), hasCollapsedSteps ? (_jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: _jsx(IncludedSteps, { step: step, variant: variant }) })) : (_jsx(IncludedSteps, { step: step, variant: variant }))] }));
@@ -64,15 +50,13 @@ export const StepDetailsContent = ({ step, variant }) => {
64
50
  if (sameTokenProtocolStep) {
65
51
  fromAmount = Big(step.estimate.fromAmount)
66
52
  .div(10 ** step.action.fromToken.decimals)
67
- .minus(Big(step.estimate.toAmount).div(10 ** step.action.toToken.decimals));
53
+ .minus(Big(step.estimate.toAmount).div(10 ** step.action.toToken.decimals))
54
+ .toString();
68
55
  }
69
56
  else {
70
57
  fromAmount = formatTokenAmount(step.estimate.fromAmount, step.action.fromToken.decimals);
71
58
  }
72
- const showToAmount = step.type !== 'custom' &&
73
- step.tool !== 'custom' &&
74
- variant !== 'nft' &&
75
- !sameTokenProtocolStep;
59
+ const showToAmount = step.type !== 'custom' && step.tool !== 'custom' && !sameTokenProtocolStep;
76
60
  return (_jsxs(Typography, { fontSize: 12, fontWeight: "500", color: "text.secondary", alignItems: "center", display: "flex", children: [t('format.number', {
77
61
  value: fromAmount,
78
62
  }), ' ', step.action.fromToken.symbol, showToAmount ? (_jsxs(_Fragment, { children: [_jsx(ArrowForwardIcon, { sx: { fontSize: 18, paddingX: 0.5 } }), t('format.number', {
@@ -25,14 +25,26 @@ export const SwapButton = ({ onClick, hasRoute, text, disabled, loading, }) => {
25
25
  const getButtonText = () => {
26
26
  if (account.isActive) {
27
27
  if (!hasRoute) {
28
- return variant !== 'refuel' ? t(`button.swap`) : t(`button.getGas`);
28
+ switch (variant) {
29
+ case 'nft':
30
+ return t(`button.buy`);
31
+ case 'refuel':
32
+ return t(`button.getGas`);
33
+ default:
34
+ return t(`button.swap`);
35
+ }
29
36
  }
30
37
  if (text) {
31
38
  return text;
32
39
  }
33
- return variant !== 'refuel'
34
- ? t(`button.reviewSwap`)
35
- : t(`button.reviewGasSwap`);
40
+ switch (variant) {
41
+ case 'nft':
42
+ return t(`button.reviewPurchase`);
43
+ case 'refuel':
44
+ return t(`button.reviewGasSwap`);
45
+ default:
46
+ return t(`button.reviewSwap`);
47
+ }
36
48
  }
37
49
  return t(`button.connectWallet`);
38
50
  };
@@ -4,7 +4,7 @@ import { useWatch } from 'react-hook-form';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useTokenAddressBalance } from '../../hooks';
6
6
  import { SwapFormKeyHelper } from '../../providers';
7
- import { formatTokenPrice } from '../../utils';
7
+ import { formatTokenAmount, formatTokenPrice } from '../../utils';
8
8
  export const FormPriceHelperText = ({ formType, }) => {
9
9
  const { t } = useTranslation();
10
10
  const [amount, chainId, tokenAddress] = useWatch({
@@ -22,6 +22,6 @@ export const FormPriceHelperText = ({ formType, }) => {
22
22
  }, children: t(`format.currency`, {
23
23
  value: fromAmountTokenPrice,
24
24
  }) }), isLoading && tokenAddress ? (_jsx(Skeleton, { variant: "text", width: 48, height: 16, sx: { borderRadius: 0.25 } })) : token?.amount ? (_jsx(Typography, { fontWeight: 400, fontSize: 12, color: "text.secondary", lineHeight: 1.3334, pl: 0.25, children: `/ ${t(`format.number`, {
25
- value: token?.amount,
25
+ value: formatTokenAmount(token?.amount),
26
26
  })}` })) : null] }));
27
27
  };
@@ -4,7 +4,7 @@ import { useController } from 'react-hook-form';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { SwapFormKeyHelper, useWidgetConfig } from '../../providers';
6
6
  import { DisabledUI } from '../../types';
7
- import { formatAmount } from '../../utils';
7
+ import { formatInputAmount } from '../../utils';
8
8
  import { Card, CardTitle } from '../Card';
9
9
  import { FitInputText } from './FitInputText';
10
10
  import { FormPriceHelperText } from './FormPriceHelperText';
@@ -21,12 +21,12 @@ export const SwapInput = ({ formType, ...props }) => {
21
21
  const ref = useRef(null);
22
22
  const handleChange = (event) => {
23
23
  const { value } = event.target;
24
- const formattedAmount = formatAmount(value, true);
24
+ const formattedAmount = formatInputAmount(value, true);
25
25
  onChange(formattedAmount);
26
26
  };
27
27
  const handleBlur = (event) => {
28
28
  const { value } = event.target;
29
- const formattedAmount = formatAmount(value);
29
+ const formattedAmount = formatInputAmount(value);
30
30
  onChange(formattedAmount);
31
31
  onBlur();
32
32
  };
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
1
  import type { SwapFormTypeProps } from '../../providers';
3
- export declare const SwapInputEndAdornment: ({ formType }: SwapFormTypeProps) => JSX.Element;
2
+ export declare const SwapInputEndAdornment: ({ formType }: SwapFormTypeProps) => import("react/jsx-runtime").JSX.Element;
@@ -21,7 +21,7 @@ export const SwapInputEndAdornment = ({ formType }) => {
21
21
  const { token, isLoading } = useTokenAddressBalance(chainId, tokenAddress);
22
22
  const handleMax = () => {
23
23
  const chain = getChainById(chainId);
24
- let maxAmount;
24
+ let maxAmount = token?.amount;
25
25
  if (chain?.nativeToken.address === tokenAddress &&
26
26
  data?.available &&
27
27
  data?.recommended) {
@@ -33,7 +33,7 @@ export const SwapInputEndAdornment = ({ formType }) => {
33
33
  maxAmount = formatTokenAmount(tokenAmount.minus(recommendedAmount).toString());
34
34
  }
35
35
  }
36
- setValue(SwapFormKeyHelper.getAmountKey(formType), maxAmount || token?.amount || '', {
36
+ setValue(SwapFormKeyHelper.getAmountKey(formType), maxAmount || '', {
37
37
  shouldTouch: true,
38
38
  });
39
39
  };
@@ -2,10 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import ExpandLessIcon from '@mui/icons-material/ExpandLess';
3
3
  import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
4
4
  import VerifiedUserIcon from '@mui/icons-material/VerifiedUser';
5
- import { Box, Collapse } from '@mui/material';
6
- import { useState } from 'react';
5
+ import { Box, Collapse, Tooltip, Typography } from '@mui/material';
6
+ import { Fragment, useState } from 'react';
7
7
  import { useTranslation } from 'react-i18next';
8
8
  import { useWidgetConfig } from '../../providers';
9
+ import { formatTokenAmount } from '../../utils';
9
10
  import { Card, CardIconButton, CardLabel, CardLabelTypography } from '../Card';
10
11
  import { StepActions } from '../StepActions';
11
12
  import { Token } from '../Token';
@@ -22,8 +23,23 @@ export const SwapRouteCard = ({ route, active, variant = 'default', expanded, ..
22
23
  const token = widgetVariant === 'nft'
23
24
  ? { ...route.fromToken, amount: route.fromAmount }
24
25
  : { ...route.toToken, amount: route.toAmount };
25
- const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' && (insurable || route.tags?.length) ? (_jsxs(Box, { display: "flex", alignItems: "center", mb: 2, children: [insurable ? (_jsxs(CardLabel, { type: route.tags?.length && !cardExpanded
26
- ? 'insurance-icon'
27
- : 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), cardExpanded || !route.tags?.length ? (_jsx(CardLabelTypography, { type: "icon", children: t(`swap.tags.insurable`) })) : null] })) : null, route.tags?.length ? (_jsx(CardLabel, { type: active ? 'active' : undefined, children: _jsx(CardLabelTypography, { children: t(`swap.tags.${route.tags[0].toLowerCase()}`) }) })) : null] })) : null, _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [_jsx(Token, { token: token, step: !cardExpanded ? route.steps[0] : undefined }), !expanded ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), _jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) }), _jsx(SwapRouteCardEssentials, { route: route })] }));
26
+ const RecommendedTagTooltip = route.tags?.[0] === 'RECOMMENDED' ? RecommendedTooltip : Fragment;
27
+ const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' && (insurable || route.tags?.length) ? (_jsxs(Box, { display: "flex", alignItems: "center", mb: 2, children: [insurable ? (_jsx(InsuranceTooltip, { insuredAmount: formatTokenAmount(route.toAmountMin, route.toToken.decimals), insuredTokenSymbol: route.toToken.symbol, children: _jsxs(CardLabel, { type: route.tags?.length && !cardExpanded
28
+ ? 'insurance-icon'
29
+ : 'insurance', children: [_jsx(VerifiedUserIcon, { fontSize: "inherit" }), cardExpanded || !route.tags?.length ? (_jsx(CardLabelTypography, { type: "icon", children: t(`swap.tags.insurable`) })) : null] }) })) : null, route.tags?.length ? (_jsx(RecommendedTagTooltip, { children: _jsx(CardLabel, { type: active ? 'active' : undefined, children: _jsx(CardLabelTypography, { children: t(`swap.tags.${route.tags[0].toLowerCase()}`) }) }) })) : null] })) : null, _jsxs(Box, { display: "flex", justifyContent: "space-between", alignItems: "start", children: [_jsx(Token, { token: token, step: !cardExpanded ? route.steps[0] : undefined }), !expanded ? (_jsx(CardIconButton, { onClick: handleExpand, size: "small", children: cardExpanded ? _jsx(ExpandLessIcon, {}) : _jsx(ExpandMoreIcon, {}) })) : null] }), _jsx(Collapse, { timeout: 225, in: cardExpanded, mountOnEnter: true, unmountOnExit: true, children: route.steps.map((step) => (_jsx(StepActions, { step: step, mt: 2 }, step.id))) }), _jsx(SwapRouteCardEssentials, { route: route })] }));
28
30
  return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : (_jsx(Card, { variant: active ? 'selected' : 'default', selectionColor: "secondary", indented: true, ...other, children: cardContent }));
29
31
  };
32
+ const InsuranceTooltip = ({ insuredAmount, insuredTokenSymbol, children }) => {
33
+ const { t } = useTranslation();
34
+ return (_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [_jsx(Typography, { fontSize: 12, fontWeight: "500", children: t('swap.insurance.insure', {
35
+ amount: insuredAmount,
36
+ tokenSymbol: insuredTokenSymbol,
37
+ }) }), _jsxs(Box, { sx: {
38
+ listStyleType: 'disc',
39
+ pl: 2,
40
+ }, children: [_jsx(Typography, { fontSize: 12, fontWeight: "500", display: "list-item", children: t('swap.insurance.bridgeExploits') }), _jsx(Typography, { fontSize: 12, fontWeight: "500", display: "list-item", children: t('swap.insurance.slippageError') })] })] }), placement: "top", enterDelay: 400, arrow: true, children: children }));
41
+ };
42
+ const RecommendedTooltip = ({ children, }) => {
43
+ const { t } = useTranslation();
44
+ return (_jsx(Tooltip, { title: t('tooltip.recommended'), placement: "top", enterDelay: 400, arrow: true, children: children }));
45
+ };
@@ -15,7 +15,7 @@ export const SwapRouteCardEssentials = ({ route, dense }) => {
15
15
  const gasCostUSD = parseFloat(route.gasCostUSD ?? '') || 0.01;
16
16
  const gasCosts = getGasCostsBreakdown(route);
17
17
  const feeCosts = getFeeCostsBreakdown(route, false);
18
- return (_jsxs(Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => (_jsxs(Typography, { fontSize: 11, children: [gas.amount?.toFixed(9), " ", gas.token.symbol, " (", t(`format.currency`, { value: gas.amountUSD }), ")"] }, `${gas.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(EvStationIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), _jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.additionalProviderFee`), feeCosts.map((fee, index) => (_jsxs(Typography, { fontSize: 11, children: [fee.amount?.toFixed(9), " ", fee.token.symbol, " (", t(`format.currency`, { value: fee.amountUSD }), ")"] }, `${fee.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(MonetizationOnIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, {
18
+ return (_jsxs(Box, { display: "flex", justifyContent: 'space-between', flex: 1, mt: 2, children: [_jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.estimatedNetworkFee`), gasCosts.map((gas, index) => (_jsxs(Typography, { fontSize: 12, fontWeight: "500", children: [gas.amount?.toFixed(9), " ", gas.token.symbol, " (", t(`format.currency`, { value: gas.amountUSD }), ")"] }, `${gas.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(EvStationIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, { value: gasCostUSD }) })] }) }), _jsx(Tooltip, { title: _jsxs(Box, { component: "span", children: [t(`tooltip.additionalProviderFee`), feeCosts.map((fee, index) => (_jsxs(Typography, { fontSize: 12, fontWeight: "500", children: [fee.amount?.toFixed(9), " ", fee.token.symbol, " (", t(`format.currency`, { value: fee.amountUSD }), ")"] }, `${fee.token.address}${index}`)))] }), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(MonetizationOnIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t(`format.currency`, {
19
19
  value: feeCosts.reduce((sum, feeCost) => sum + feeCost.amountUSD, 0),
20
20
  }) })] }) }), _jsx(Tooltip, { title: t(`tooltip.estimatedTime`), placement: "top", enterDelay: 400, arrow: true, children: _jsxs(Box, { display: "flex", alignItems: "center", mr: dense ? 0 : 2, children: [_jsx(IconTypography, { children: _jsx(AccessTimeIcon, { fontSize: "small" }) }), _jsx(Typography, { fontSize: 14, color: "text.primary", fontWeight: "500", lineHeight: 1, children: t('swap.estimatedTime', {
21
21
  value: executionTimeMinutes,
@@ -4,7 +4,7 @@ import { useWidgetConfig } from '../../providers';
4
4
  import { Card } from '../Card';
5
5
  export const SwapRouteCardSkeleton = ({ variant, ...other }) => {
6
6
  const { variant: widgetVariant } = useWidgetConfig();
7
- const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' ? (_jsx(Box, { display: "flex", alignItems: "center", mb: 2, children: _jsx(Skeleton, { variant: "rectangular", width: 112, height: 24, sx: (theme) => ({
7
+ const cardContent = (_jsxs(Box, { flex: 1, children: [widgetVariant !== 'refuel' && widgetVariant !== 'nft' ? (_jsx(Box, { display: "flex", alignItems: "center", mb: 2, children: _jsx(Skeleton, { variant: "rectangular", width: 112, height: 24, sx: (theme) => ({
8
8
  borderRadius: `${theme.shape.borderRadius}px`,
9
9
  }) }) })) : null, _jsxs(Box, { children: [_jsxs(Box, { display: "flex", alignItems: "center", children: [_jsx(Box, { mr: 2, children: _jsx(Skeleton, { variant: "circular", width: 32, height: 32 }) }), _jsx(Skeleton, { variant: "text", width: 96, height: 32 })] }), _jsxs(Box, { ml: 6, display: "flex", alignItems: "center", children: [_jsx(Skeleton, { variant: "text", width: 102, height: 16 }), _jsx(Skeleton, { variant: "text", width: 72, height: 16, sx: { marginLeft: 1 } })] })] }), _jsxs(Box, { mt: 2, display: "flex", justifyContent: "space-between", children: [_jsx(Skeleton, { variant: "text", width: 64, height: 20 }), _jsx(Skeleton, { variant: "text", width: 64, height: 20 }), _jsx(Skeleton, { variant: "text", width: 48, height: 20 }), _jsx(Skeleton, { variant: "text", width: 32, height: 20 })] })] }));
10
10
  return widgetVariant === 'refuel' || variant === 'cardless' ? (cardContent) : (_jsx(Card, { indented: true, ...other, children: cardContent }));
@@ -25,7 +25,7 @@ export const SwapRoutes = (props) => {
25
25
  const routeNotFound = !currentRoute && !isLoading && !isFetching;
26
26
  const onlyRecommendedRoute = variant === 'refuel' || useRecommendedRoute;
27
27
  const showAll = !onlyRecommendedRoute && !routeNotFound && (routes?.length ?? 0) > 1;
28
- return (_jsxs(Card, { ...props, children: [_jsx(CardTitle, { children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
28
+ return (_jsxs(Card, { ...props, children: [_jsx(CardTitle, { children: variant === 'nft' ? t('swap.fromAmount') : t('header.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: {
29
29
  position: 'absolute',
30
30
  top: 8,
31
31
  right: 8,
@@ -1,3 +1,2 @@
1
- /// <reference types="react" />
2
- export declare const SwapRoutesExpanded: () => JSX.Element;
3
- export declare const SwapRoutesExpandedElement: () => JSX.Element;
1
+ export declare const SwapRoutesExpanded: () => import("react/jsx-runtime").JSX.Element;
2
+ export declare const SwapRoutesExpandedElement: () => import("react/jsx-runtime").JSX.Element;
@@ -19,7 +19,7 @@ export const SwapRoutesExpandedElement = () => {
19
19
  const { t } = useTranslation();
20
20
  const navigate = useNavigate();
21
21
  const setExecutableRoute = useSetExecutableRoute();
22
- const { containerStyle } = useWidgetConfig();
22
+ const { variant, containerStyle } = useWidgetConfig();
23
23
  const { isValid, isValidating } = useFormState();
24
24
  const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
25
25
  const currentRoute = routes?.[0];
@@ -33,5 +33,5 @@ export const SwapRoutesExpandedElement = () => {
33
33
  };
34
34
  const expanded = Boolean(currentRoute || isLoading || isFetching || isFetched);
35
35
  const routeNotFound = !currentRoute && !isLoading && !isFetching && expanded;
36
- return (_jsx(Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: _jsx(Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: _jsx(Container, { sx: containerStyle, enableColorScheme: true, children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: t('swap.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
36
+ return (_jsx(Collapse, { timeout: timeout.enter, in: expanded, orientation: "horizontal", children: _jsx(Grow, { timeout: timeout.enter, in: expanded, mountOnEnter: true, unmountOnExit: true, children: _jsx(Container, { sx: containerStyle, enableColorScheme: true, children: _jsxs(ScrollableContainer, { children: [_jsxs(Header, { children: [_jsx(Typography, { fontSize: 18, fontWeight: "700", flex: 1, noWrap: true, children: variant === 'nft' ? t('swap.fromAmount') : t('header.routes') }), _jsx(ProgressToNextUpdate, { updatedAt: dataUpdatedAt || new Date().getTime(), timeToUpdate: refetchTime, isLoading: isFetching, onClick: () => refetch(), sx: { marginRight: -1 } })] }), _jsx(Stack, { direction: "column", spacing: 2, flex: 1, paddingX: 3, paddingBottom: 3, children: routeNotFound ? (_jsx(SwapRouteNotFoundCard, {})) : isLoading || (isFetching && !routes?.length) ? (Array.from({ length: 3 }).map((_, index) => (_jsx(SwapRouteCardSkeleton, {}, index)))) : (routes?.map((route, index) => (_jsx(SwapRouteCard, { route: route, onClick: () => handleRouteClick(route), active: index === 0, expanded: routes?.length <= 2 }, route.id)))) })] }) }) }) }));
37
37
  };
@@ -8,6 +8,7 @@ export const CollapseContainer = styled(Box)(({ theme }) => ({
8
8
  export const ScrollableContainer = styled(Box)({
9
9
  overflowY: 'auto',
10
10
  height: '100%',
11
+ width: '100%',
11
12
  flex: 1,
12
13
  display: 'flex',
13
14
  flexDirection: 'column',
@@ -13,7 +13,7 @@ export const Token = ({ token, ...other }) => {
13
13
  }
14
14
  return _jsx(TokenBase, { token: token, ...other });
15
15
  };
16
- export const TokenFallback = ({ token, connected, step, disableDescription, isLoading, ...other }) => {
16
+ export const TokenFallback = ({ token, isLoading, ...other }) => {
17
17
  const { token: chainToken, isLoading: isLoadingToken } = useToken(token?.chainId, token?.address);
18
18
  return (_jsx(TokenBase, { token: { ...token, ...chainToken }, isLoading: isLoading || isLoadingToken, ...other }));
19
19
  };
@@ -1,19 +1,19 @@
1
1
  /// <reference types="react" />
2
- import type { Chain, Token } from '@lifi/sdk';
2
+ import type { Chain, StaticToken } from '@lifi/sdk';
3
3
  import type { SxProps, Theme } from '@mui/material';
4
4
  export declare const TokenAvatarFallback: React.FC<{
5
- token?: Token;
5
+ token?: StaticToken;
6
6
  isLoading?: boolean;
7
7
  sx?: SxProps<Theme>;
8
8
  }>;
9
9
  export declare const TokenAvatarBase: React.FC<{
10
- token?: Token;
10
+ token?: StaticToken;
11
11
  chain?: Chain;
12
12
  isLoading?: boolean;
13
13
  sx?: SxProps<Theme>;
14
14
  }>;
15
15
  export declare const TokenAvatar: React.FC<{
16
- token?: Token;
16
+ token?: StaticToken;
17
17
  chain?: Chain;
18
18
  isLoading?: boolean;
19
19
  sx?: SxProps<Theme>;
@@ -2,11 +2,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box } from '@mui/material';
3
3
  import { useRef } from 'react';
4
4
  import { useWatch } from 'react-hook-form';
5
- import { useDebouncedWatch, useTokenBalances, useTokenSearch, } from '../../hooks';
5
+ import { useChain, useDebouncedWatch, useTokenBalances, useTokenSearch, } from '../../hooks';
6
6
  import { SwapFormKey, SwapFormKeyHelper, useWallet } from '../../providers';
7
7
  import { TokenNotFound } from './TokenNotFound';
8
- import { useTokenSelect } from './useTokenSelect';
9
8
  import { VirtualizedTokenList } from './VirtualizedTokenList';
9
+ import { useTokenSelect } from './useTokenSelect';
10
10
  export const TokenList = ({ formType, height, onClick, }) => {
11
11
  const parentRef = useRef(null);
12
12
  const { account } = useWallet();
@@ -14,8 +14,11 @@ export const TokenList = ({ formType, height, onClick, }) => {
14
14
  name: [SwapFormKeyHelper.getChainKey(formType)],
15
15
  });
16
16
  const [tokenSearchFilter] = useDebouncedWatch([SwapFormKey.TokenSearchFilter], 320);
17
+ const { chain, isLoading: isChainLoading } = useChain(selectedChainId);
17
18
  const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = useTokenBalances(selectedChainId);
18
- let filteredTokens = (tokensWithBalance ?? chainTokens ?? []);
19
+ let filteredTokens = (tokensWithBalance ??
20
+ chainTokens ??
21
+ []);
19
22
  const searchFilter = tokenSearchFilter?.toUpperCase() ?? '';
20
23
  filteredTokens = tokenSearchFilter
21
24
  ? filteredTokens.filter((token) => token.name.toUpperCase().includes(searchFilter) ||
@@ -27,12 +30,14 @@ export const TokenList = ({ formType, height, onClick, }) => {
27
30
  !!tokenSearchFilter &&
28
31
  !!selectedChainId;
29
32
  const { token: searchedToken, isLoading: isSearchedTokenLoading } = useTokenSearch(selectedChainId, tokenSearchFilter, tokenSearchEnabled);
30
- const isLoading = isTokensLoading || (tokenSearchEnabled && isSearchedTokenLoading);
33
+ const isLoading = isTokensLoading ||
34
+ isChainLoading ||
35
+ (tokenSearchEnabled && isSearchedTokenLoading);
31
36
  const tokens = filteredTokens.length
32
37
  ? filteredTokens
33
38
  : searchedToken
34
39
  ? [searchedToken]
35
40
  : filteredTokens;
36
41
  const handleTokenClick = useTokenSelect(formType, onClick);
37
- return (_jsxs(Box, { ref: parentRef, style: { height, overflow: 'auto' }, children: [!tokens.length && !isLoading ? (_jsx(TokenNotFound, { formType: formType })) : null, _jsx(VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens?.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] }));
42
+ return (_jsxs(Box, { ref: parentRef, style: { height, overflow: 'auto' }, children: [!tokens.length && !isLoading ? (_jsx(TokenNotFound, { formType: formType })) : null, _jsx(VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens?.length, scrollElementRef: parentRef, chainId: selectedChainId, chain: chain, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] }));
38
43
  };
@@ -1,5 +1,7 @@
1
1
  /// <reference types="react" />
2
- export declare const ListItemButton: import("@emotion/styled").StyledComponent<import("@mui/material").ListItemButtonBaseProps & Omit<{
2
+ import type { StyledComponent } from '@emotion/styled';
3
+ import type { ButtonProps, LinkProps } from '@mui/material';
4
+ export declare const ListItemButton: StyledComponent<import("@mui/material").ListItemButtonBaseProps & Omit<{
3
5
  action?: import("react").Ref<import("@mui/material").ButtonBaseActions> | undefined;
4
6
  centerRipple?: boolean | undefined;
5
7
  children?: import("react").ReactNode;
@@ -18,7 +20,7 @@ export declare const ListItemButton: import("@emotion/styled").StyledComponent<i
18
20
  }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & {
19
21
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
20
22
  }, "className" | "style" | "classes" | "autoFocus" | "tabIndex" | "children" | "action" | "centerRipple" | "disabled" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "sx" | "TouchRippleProps" | "touchRippleRef" | "alignItems" | "dense" | "divider" | "selected" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
21
- export declare const ListItem: import("@emotion/styled").StyledComponent<{
23
+ export declare const ListItem: StyledComponent<{
22
24
  button?: false | undefined;
23
25
  } & import("@mui/material").ListItemBaseProps & {
24
26
  components?: {
@@ -36,3 +38,4 @@ export declare const ListItem: import("@emotion/styled").StyledComponent<{
36
38
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Omit<import("react").DetailedHTMLProps<import("react").LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, "ref"> & {
37
39
  ref?: ((instance: HTMLLIElement | null) => void) | import("react").RefObject<HTMLLIElement> | null | undefined;
38
40
  }, "button" | "className" | "style" | "classes" | "autoFocus" | "children" | "disabled" | "sx" | "alignItems" | "dense" | "divider" | "components" | "slotProps" | "slots" | "componentsProps" | "selected" | "disableGutters" | "ContainerComponent" | "ContainerProps" | "disablePadding" | "secondaryAction"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
41
+ export declare const LinkButton: StyledComponent<ButtonProps & LinkProps>;
@@ -1,7 +1,7 @@
1
- import { ListItem as MuiListItem } from '@mui/material';
1
+ import { Button, ListItem as MuiListItem, buttonClasses } from '@mui/material';
2
2
  import { listItemSecondaryActionClasses } from '@mui/material/ListItemSecondaryAction';
3
3
  import { listItemTextClasses } from '@mui/material/ListItemText';
4
- import { styled } from '@mui/material/styles';
4
+ import { alpha, styled } from '@mui/material/styles';
5
5
  import { ListItemButton as ListItemButtonBase } from '../ListItemButton';
6
6
  export const ListItemButton = styled(ListItemButtonBase)(({ theme }) => ({
7
7
  paddingLeft: theme.spacing(1.5),
@@ -26,3 +26,22 @@ export const ListItem = styled(MuiListItem)(({ theme }) => ({
26
26
  whiteSpace: 'nowrap',
27
27
  },
28
28
  }));
29
+ export const LinkButton = styled(Button)(({ theme }) => ({
30
+ lineHeight: 1,
31
+ fontSize: '0.75rem',
32
+ fontWeight: 400,
33
+ padding: theme.spacing(0.375, 0.75),
34
+ color: 'inherit',
35
+ backgroundColor: 'unset',
36
+ '&:hover': {
37
+ backgroundColor: theme.palette.mode === 'light'
38
+ ? alpha(theme.palette.common.black, 0.04)
39
+ : alpha(theme.palette.common.white, 0.08),
40
+ },
41
+ [`.${buttonClasses.endIcon}`]: {
42
+ marginLeft: theme.spacing(0.25),
43
+ },
44
+ [`.${buttonClasses.endIcon} > *:nth-of-type(1)`]: {
45
+ fontSize: '0.75rem',
46
+ },
47
+ }));
@@ -2,5 +2,5 @@
2
2
  import type { TokenListItemButtonProps, TokenListItemProps } from './types';
3
3
  export declare const TokenListItem: React.FC<TokenListItemProps>;
4
4
  export declare const TokenListItemButton: React.FC<TokenListItemButtonProps>;
5
- export declare const TokenListItemSkeleton: () => JSX.Element;
5
+ export declare const TokenListItemSkeleton: () => import("react/jsx-runtime").JSX.Element;
6
6
  export declare const TokenAmountSkeleton: React.FC;
@@ -1,21 +1,44 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Avatar, Box, ListItemAvatar, ListItemText, Skeleton, Typography, } from '@mui/material';
3
- import { memo } from 'react';
2
+ import OpenInNewIcon from '@mui/icons-material/OpenInNewRounded';
3
+ import { Avatar, Box, Link, ListItemAvatar, ListItemText, Skeleton, Slide, Typography, } from '@mui/material';
4
+ import { memo, useRef, useState } from 'react';
4
5
  import { useTranslation } from 'react-i18next';
5
- import { formatTokenPrice } from '../../utils';
6
- import { ListItem, ListItemButton } from './TokenList.style';
7
- export const TokenListItem = memo(({ onClick, size, start, token, showBalance, isBalanceLoading, startAdornment, endAdornment, }) => {
6
+ import { formatTokenAmount, formatTokenPrice, shortenAddress, } from '../../utils';
7
+ import { LinkButton, ListItem, ListItemButton } from './TokenList.style';
8
+ export const TokenListItem = memo(({ onClick, size, start, token, chain, showBalance, isBalanceLoading, startAdornment, endAdornment, }) => {
8
9
  const handleClick = () => onClick?.(token.address);
9
10
  return (_jsxs(ListItem, { disablePadding: true, style: {
10
11
  height: `${size}px`,
11
12
  transform: `translateY(${start}px)`,
12
- }, children: [startAdornment, _jsx(TokenListItemButton, { token: token, showBalance: showBalance, isBalanceLoading: isBalanceLoading, onClick: handleClick }), endAdornment] }));
13
+ }, children: [startAdornment, _jsx(TokenListItemButton, { token: token, chain: chain, showBalance: showBalance, isBalanceLoading: isBalanceLoading, onClick: handleClick }), endAdornment] }));
13
14
  });
14
- export const TokenListItemButton = ({ onClick, token, showBalance, isBalanceLoading, }) => {
15
+ export const TokenListItemButton = ({ onClick, token, chain, showBalance, isBalanceLoading, }) => {
15
16
  const { t } = useTranslation();
16
17
  const tokenPrice = formatTokenPrice(token.amount, token.priceUSD);
17
- return (_jsxs(ListItemButton, { onClick: onClick, dense: true, children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, { src: token.logoURI, alt: token.symbol, children: token.symbol[0] }) }), _jsx(ListItemText, { primary: token.symbol, secondary: token.name }), showBalance ? (isBalanceLoading ? (_jsx(TokenAmountSkeleton, {})) : (_jsxs(Box, { sx: { textAlign: 'right' }, children: [Number(token.amount) ? (_jsx(Typography, { variant: "body1", noWrap: true, children: t('format.number', {
18
- value: token.amount,
18
+ const container = useRef(null);
19
+ const timeoutId = useRef();
20
+ const [showAddress, setShowAddress] = useState(false);
21
+ const onMouseEnter = () => {
22
+ timeoutId.current = setTimeout(() => setShowAddress(true), 350);
23
+ };
24
+ const onMouseLeave = () => {
25
+ clearTimeout(timeoutId.current);
26
+ if (showAddress) {
27
+ setShowAddress(false);
28
+ }
29
+ };
30
+ return (_jsxs(ListItemButton, { onClick: onClick, onMouseEnter: onMouseEnter, onMouseLeave: onMouseLeave, dense: true, children: [_jsx(ListItemAvatar, { children: _jsx(Avatar, { src: token.logoURI, alt: token.symbol, children: token.symbol[0] }) }), _jsx(ListItemText, { primary: token.symbol, secondaryTypographyProps: {
31
+ component: 'div',
32
+ sx: {
33
+ overflow: 'auto',
34
+ marginLeft: -0.75,
35
+ },
36
+ }, secondary: _jsxs(Box, { position: "relative", height: 18, ref: container, children: [_jsx(Slide, { direction: "down", in: !showAddress, container: container.current, style: {
37
+ position: 'absolute',
38
+ }, appear: false, children: _jsx(Box, { pl: 0.75, children: token.name }) }), _jsx(Slide, { direction: "up", in: showAddress, container: container.current, style: {
39
+ position: 'absolute',
40
+ }, appear: false, mountOnEnter: true, children: _jsx(LinkButton, { size: "small", LinkComponent: Link, href: `${chain?.metamask.blockExplorerUrls[0]}address/${token.address}`, target: "_blank", rel: "nofollow noreferrer", onClick: (e) => e.stopPropagation(), endIcon: _jsx(OpenInNewIcon, {}), children: shortenAddress(token.address) }) })] }) }), showBalance ? (isBalanceLoading ? (_jsx(TokenAmountSkeleton, {})) : (_jsxs(Box, { sx: { textAlign: 'right' }, children: [Number(token.amount) ? (_jsx(Typography, { variant: "body1", noWrap: true, children: t('format.number', {
41
+ value: formatTokenAmount(token.amount),
19
42
  }) })) : null, tokenPrice ? (_jsx(Typography, { fontWeight: 400, fontSize: 12, color: "text.secondary", "data-price": token.priceUSD, children: t(`format.currency`, {
20
43
  value: tokenPrice,
21
44
  }) })) : null] }))) : null] }));
@@ -4,7 +4,7 @@ import { useVirtualizer } from '@tanstack/react-virtual';
4
4
  import { useEffect } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { TokenListItem, TokenListItemSkeleton } from './TokenListItem';
7
- export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef, chainId, isLoading, isBalanceLoading, showBalance, showFeatured, onClick, }) => {
7
+ export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef, chainId, chain, isLoading, isBalanceLoading, showBalance, showFeatured, onClick, }) => {
8
8
  const { t } = useTranslation();
9
9
  const hasFeaturedTokens = !!featuredTokensLength && showFeatured;
10
10
  const featuredTokensLastIndex = (featuredTokensLength ?? 0) - 1;
@@ -32,7 +32,7 @@ export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollEleme
32
32
  }
33
33
  return size;
34
34
  },
35
- getItemKey: (index) => tokens[index].address ?? index,
35
+ getItemKey: (index) => `${tokens[index].address}-${index}`,
36
36
  });
37
37
  useEffect(() => {
38
38
  if (getVirtualItems().length) {
@@ -46,7 +46,7 @@ export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollEleme
46
46
  }
47
47
  return (_jsx(List, { style: { height: getTotalSize() }, disablePadding: true, children: getVirtualItems().map((item) => {
48
48
  const token = tokens[item.index];
49
- return (_jsx(TokenListItem, { onClick: onClick, size: item.size, start: item.start, token: token, isBalanceLoading: isBalanceLoading, showBalance: showBalance, startAdornment: hasFeaturedTokens && token.featured && item.index === 0 ? (_jsx(Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, pb: 1.25, children: t('swap.featuredTokens') })) : null, endAdornment: hasFeaturedTokens &&
49
+ return (_jsx(TokenListItem, { onClick: onClick, size: item.size, start: item.start, token: token, chain: chain, isBalanceLoading: isBalanceLoading, showBalance: showBalance, startAdornment: hasFeaturedTokens && token.featured && item.index === 0 ? (_jsx(Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, pb: 1.25, children: t('swap.featuredTokens') })) : null, endAdornment: hasFeaturedTokens &&
50
50
  token.featured &&
51
51
  item.index === featuredTokensLastIndex &&
52
52
  item.index !== tokensLastIndex ? (_jsx(Typography, { fontSize: 14, fontWeight: 600, lineHeight: 1, px: 2, py: 1.25, children: t('swap.otherTokens') })) : null }, item.key));