@lifi/widget 1.27.1 → 1.28.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 (221) hide show
  1. package/AppDrawer.style.d.ts +1 -1
  2. package/AppRoutes.js +15 -33
  3. package/README.md +1 -1
  4. package/cjs/AppDrawer.style.d.ts +1 -1
  5. package/cjs/AppRoutes.js +15 -33
  6. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
  7. package/cjs/components/Card/Card.d.ts +1 -1
  8. package/cjs/components/ChainSelect/ChainSelect.style.d.ts +1 -1
  9. package/cjs/components/ContractComponent/ContractComponent.d.ts +3 -0
  10. package/cjs/components/ContractComponent/ContractComponent.js +14 -0
  11. package/cjs/components/ContractComponent/index.d.ts +1 -0
  12. package/cjs/components/ContractComponent/index.js +17 -0
  13. package/cjs/components/Header/Header.style.d.ts +2 -2
  14. package/cjs/components/Header/NavigationHeader.js +10 -2
  15. package/cjs/components/Header/WalletHeader.js +1 -1
  16. package/cjs/components/NFT/NFT.d.ts +4 -0
  17. package/cjs/components/NFT/NFT.js +41 -0
  18. package/cjs/components/NFT/NFT.style.d.ts +16 -0
  19. package/cjs/components/NFT/NFT.style.js +11 -0
  20. package/cjs/components/NFT/index.d.ts +2 -0
  21. package/cjs/components/NFT/index.js +18 -0
  22. package/cjs/components/NFT/types.d.ts +15 -0
  23. package/cjs/components/NFT/types.js +2 -0
  24. package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
  25. package/cjs/components/Select.d.ts +1 -1
  26. package/cjs/components/SelectChainAndToken.js +12 -2
  27. package/cjs/components/SelectTokenButton/SelectTokenButton.js +5 -2
  28. package/cjs/components/SendToWallet/SendToWallet.style.d.ts +1 -1
  29. package/cjs/components/SmallAvatar.d.ts +1 -1
  30. package/cjs/components/Step/StepProcess.style.d.ts +1 -1
  31. package/cjs/components/StepActions/StepActions.d.ts +6 -7
  32. package/cjs/components/StepActions/StepActions.js +41 -12
  33. package/cjs/components/StepActions/StepActions.style.d.ts +1 -1
  34. package/cjs/components/StepActions/types.d.ts +5 -0
  35. package/cjs/components/SwapInput/SwapInput.d.ts +2 -1
  36. package/cjs/components/SwapInput/SwapInput.js +15 -3
  37. package/cjs/components/SwapInput/SwapInput.style.d.ts +1 -1
  38. package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
  39. package/cjs/components/SwapRouteCard/SwapRouteCard.js +3 -1
  40. package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
  41. package/cjs/components/Token/Token.d.ts +1 -1
  42. package/cjs/components/Token/Token.js +12 -12
  43. package/cjs/components/TokenAvatar/TokenAvatar.d.ts +5 -3
  44. package/cjs/components/TokenAvatar/TokenAvatar.js +10 -9
  45. package/cjs/components/TokenList/TokenList.style.js +6 -0
  46. package/cjs/components/TokenList/VirtualizedTokenList.js +4 -2
  47. package/cjs/config/theme.js +3 -5
  48. package/cjs/config/version.d.ts +1 -1
  49. package/cjs/config/version.js +1 -1
  50. package/cjs/hooks/useSwapRoutes.d.ts +5 -2
  51. package/cjs/hooks/useSwapRoutes.js +64 -14
  52. package/cjs/hooks/useToken.d.ts +1 -1
  53. package/cjs/hooks/useTokenSearch.d.ts +1 -1
  54. package/cjs/i18n/de.json +214 -214
  55. package/cjs/i18n/en.json +218 -214
  56. package/cjs/i18n/es.json +191 -191
  57. package/cjs/i18n/fr.json +214 -214
  58. package/cjs/i18n/it.json +214 -214
  59. package/cjs/i18n/uk.json +214 -214
  60. package/cjs/i18n/zh.json +214 -214
  61. package/cjs/index.d.ts +2 -0
  62. package/cjs/index.js +4 -1
  63. package/cjs/pages/MainPage/MainPage.js +5 -1
  64. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  65. package/cjs/pages/SettingsPage/LanguageSelect.js +1 -2
  66. package/cjs/providers/SwapFormProvider/types.d.ts +10 -0
  67. package/cjs/providers/SwapFormProvider/types.js +5 -0
  68. package/cjs/stores/chains/useChainOrderStore.d.ts +1 -1
  69. package/cjs/stores/routes/useRouteExecutionStore.d.ts +1 -1
  70. package/cjs/stores/settings/useSettingsStore.d.ts +1 -1
  71. package/cjs/types/widget.d.ts +12 -6
  72. package/cjs/types/widget.js +2 -0
  73. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
  74. package/components/Card/Card.d.ts +1 -1
  75. package/components/ChainSelect/ChainSelect.style.d.ts +1 -1
  76. package/components/ContractComponent/ContractComponent.d.ts +3 -0
  77. package/components/ContractComponent/ContractComponent.js +10 -0
  78. package/components/ContractComponent/index.d.ts +1 -0
  79. package/components/ContractComponent/index.js +1 -0
  80. package/components/Header/Header.style.d.ts +2 -2
  81. package/components/Header/NavigationHeader.js +12 -4
  82. package/components/Header/WalletHeader.js +1 -1
  83. package/components/NFT/NFT.d.ts +4 -0
  84. package/components/NFT/NFT.js +37 -0
  85. package/components/NFT/NFT.style.d.ts +16 -0
  86. package/components/NFT/NFT.style.js +8 -0
  87. package/components/NFT/index.d.ts +2 -0
  88. package/components/NFT/index.js +2 -0
  89. package/components/NFT/types.d.ts +15 -0
  90. package/components/NFT/types.js +1 -0
  91. package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
  92. package/components/Select.d.ts +1 -1
  93. package/components/SelectChainAndToken.js +12 -2
  94. package/components/SelectTokenButton/SelectTokenButton.js +5 -2
  95. package/components/SendToWallet/SendToWallet.style.d.ts +1 -1
  96. package/components/SmallAvatar.d.ts +1 -1
  97. package/components/Step/StepProcess.style.d.ts +1 -1
  98. package/components/StepActions/StepActions.d.ts +6 -7
  99. package/components/StepActions/StepActions.js +40 -12
  100. package/components/StepActions/StepActions.style.d.ts +1 -1
  101. package/components/StepActions/types.d.ts +5 -0
  102. package/components/SwapInput/SwapInput.d.ts +2 -1
  103. package/components/SwapInput/SwapInput.js +15 -3
  104. package/components/SwapInput/SwapInput.style.d.ts +1 -1
  105. package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
  106. package/components/SwapRouteCard/SwapRouteCard.js +3 -1
  107. package/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
  108. package/components/Token/Token.d.ts +1 -1
  109. package/components/Token/Token.js +13 -13
  110. package/components/TokenAvatar/TokenAvatar.d.ts +5 -3
  111. package/components/TokenAvatar/TokenAvatar.js +10 -9
  112. package/components/TokenList/TokenList.style.js +6 -0
  113. package/components/TokenList/VirtualizedTokenList.js +4 -2
  114. package/config/theme.js +3 -5
  115. package/config/version.d.ts +1 -1
  116. package/config/version.js +1 -1
  117. package/hooks/useSwapRoutes.d.ts +5 -2
  118. package/hooks/useSwapRoutes.js +64 -14
  119. package/hooks/useToken.d.ts +1 -1
  120. package/hooks/useTokenSearch.d.ts +1 -1
  121. package/i18n/de.json +214 -214
  122. package/i18n/en.json +218 -214
  123. package/i18n/es.json +191 -191
  124. package/i18n/fr.json +214 -214
  125. package/i18n/it.json +214 -214
  126. package/i18n/uk.json +214 -214
  127. package/i18n/zh.json +214 -214
  128. package/index.d.ts +2 -0
  129. package/index.js +2 -0
  130. package/package.json +15 -13
  131. package/pages/MainPage/MainPage.js +5 -1
  132. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  133. package/pages/SettingsPage/LanguageSelect.js +1 -2
  134. package/providers/SwapFormProvider/types.d.ts +10 -0
  135. package/providers/SwapFormProvider/types.js +5 -0
  136. package/stores/chains/useChainOrderStore.d.ts +1 -1
  137. package/stores/routes/useRouteExecutionStore.d.ts +1 -1
  138. package/stores/settings/useSettingsStore.d.ts +1 -1
  139. package/tsconfig.cjs.tsbuildinfo +1 -1
  140. package/types/widget.d.ts +12 -6
  141. package/types/widget.js +2 -0
  142. package/cjs/fonts/Inter-Black.woff +0 -0
  143. package/cjs/fonts/Inter-Black.woff2 +0 -0
  144. package/cjs/fonts/Inter-BlackItalic.woff +0 -0
  145. package/cjs/fonts/Inter-BlackItalic.woff2 +0 -0
  146. package/cjs/fonts/Inter-Bold.woff +0 -0
  147. package/cjs/fonts/Inter-Bold.woff2 +0 -0
  148. package/cjs/fonts/Inter-BoldItalic.woff +0 -0
  149. package/cjs/fonts/Inter-BoldItalic.woff2 +0 -0
  150. package/cjs/fonts/Inter-ExtraBold.woff +0 -0
  151. package/cjs/fonts/Inter-ExtraBold.woff2 +0 -0
  152. package/cjs/fonts/Inter-ExtraBoldItalic.woff +0 -0
  153. package/cjs/fonts/Inter-ExtraBoldItalic.woff2 +0 -0
  154. package/cjs/fonts/Inter-ExtraLight.woff +0 -0
  155. package/cjs/fonts/Inter-ExtraLight.woff2 +0 -0
  156. package/cjs/fonts/Inter-ExtraLightItalic.woff +0 -0
  157. package/cjs/fonts/Inter-ExtraLightItalic.woff2 +0 -0
  158. package/cjs/fonts/Inter-Italic.woff +0 -0
  159. package/cjs/fonts/Inter-Italic.woff2 +0 -0
  160. package/cjs/fonts/Inter-Light.woff +0 -0
  161. package/cjs/fonts/Inter-Light.woff2 +0 -0
  162. package/cjs/fonts/Inter-LightItalic.woff +0 -0
  163. package/cjs/fonts/Inter-LightItalic.woff2 +0 -0
  164. package/cjs/fonts/Inter-Medium.woff +0 -0
  165. package/cjs/fonts/Inter-Medium.woff2 +0 -0
  166. package/cjs/fonts/Inter-MediumItalic.woff +0 -0
  167. package/cjs/fonts/Inter-MediumItalic.woff2 +0 -0
  168. package/cjs/fonts/Inter-Regular.woff +0 -0
  169. package/cjs/fonts/Inter-Regular.woff2 +0 -0
  170. package/cjs/fonts/Inter-SemiBold.woff +0 -0
  171. package/cjs/fonts/Inter-SemiBold.woff2 +0 -0
  172. package/cjs/fonts/Inter-SemiBoldItalic.woff +0 -0
  173. package/cjs/fonts/Inter-SemiBoldItalic.woff2 +0 -0
  174. package/cjs/fonts/Inter-Thin.woff +0 -0
  175. package/cjs/fonts/Inter-Thin.woff2 +0 -0
  176. package/cjs/fonts/Inter-ThinItalic.woff +0 -0
  177. package/cjs/fonts/Inter-ThinItalic.woff2 +0 -0
  178. package/cjs/fonts/Inter-italic.var.woff2 +0 -0
  179. package/cjs/fonts/Inter-roman.var.woff2 +0 -0
  180. package/cjs/fonts/Inter.var.woff2 +0 -0
  181. package/cjs/fonts/inter.css +0 -200
  182. package/fonts/Inter-Black.woff +0 -0
  183. package/fonts/Inter-Black.woff2 +0 -0
  184. package/fonts/Inter-BlackItalic.woff +0 -0
  185. package/fonts/Inter-BlackItalic.woff2 +0 -0
  186. package/fonts/Inter-Bold.woff +0 -0
  187. package/fonts/Inter-Bold.woff2 +0 -0
  188. package/fonts/Inter-BoldItalic.woff +0 -0
  189. package/fonts/Inter-BoldItalic.woff2 +0 -0
  190. package/fonts/Inter-ExtraBold.woff +0 -0
  191. package/fonts/Inter-ExtraBold.woff2 +0 -0
  192. package/fonts/Inter-ExtraBoldItalic.woff +0 -0
  193. package/fonts/Inter-ExtraBoldItalic.woff2 +0 -0
  194. package/fonts/Inter-ExtraLight.woff +0 -0
  195. package/fonts/Inter-ExtraLight.woff2 +0 -0
  196. package/fonts/Inter-ExtraLightItalic.woff +0 -0
  197. package/fonts/Inter-ExtraLightItalic.woff2 +0 -0
  198. package/fonts/Inter-Italic.woff +0 -0
  199. package/fonts/Inter-Italic.woff2 +0 -0
  200. package/fonts/Inter-Light.woff +0 -0
  201. package/fonts/Inter-Light.woff2 +0 -0
  202. package/fonts/Inter-LightItalic.woff +0 -0
  203. package/fonts/Inter-LightItalic.woff2 +0 -0
  204. package/fonts/Inter-Medium.woff +0 -0
  205. package/fonts/Inter-Medium.woff2 +0 -0
  206. package/fonts/Inter-MediumItalic.woff +0 -0
  207. package/fonts/Inter-MediumItalic.woff2 +0 -0
  208. package/fonts/Inter-Regular.woff +0 -0
  209. package/fonts/Inter-Regular.woff2 +0 -0
  210. package/fonts/Inter-SemiBold.woff +0 -0
  211. package/fonts/Inter-SemiBold.woff2 +0 -0
  212. package/fonts/Inter-SemiBoldItalic.woff +0 -0
  213. package/fonts/Inter-SemiBoldItalic.woff2 +0 -0
  214. package/fonts/Inter-Thin.woff +0 -0
  215. package/fonts/Inter-Thin.woff2 +0 -0
  216. package/fonts/Inter-ThinItalic.woff +0 -0
  217. package/fonts/Inter-ThinItalic.woff2 +0 -0
  218. package/fonts/Inter-italic.var.woff2 +0 -0
  219. package/fonts/Inter-roman.var.woff2 +0 -0
  220. package/fonts/Inter.var.woff2 +0 -0
  221. package/fonts/inter.css +0 -200
@@ -2,7 +2,7 @@
2
2
  import type { Step, TokenAmount } from '@lifi/sdk';
3
3
  import type { BoxProps } from '@mui/material';
4
4
  interface TokenProps {
5
- token: TokenAmount;
5
+ token?: TokenAmount;
6
6
  connected?: boolean;
7
7
  step?: Step;
8
8
  disableDescription?: boolean;
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
- import { Box } from '@mui/material';
13
+ import { Box, Skeleton } from '@mui/material';
14
14
  import { useTranslation } from 'react-i18next';
15
15
  import { useChain, useToken } from '../../hooks';
16
16
  import { formatTokenAmount, formatTokenPrice } from '../../utils';
@@ -20,32 +20,32 @@ import { TokenAvatar } from '../TokenAvatar';
20
20
  import { TextSecondary, TextSecondaryContainer } from './Token.style';
21
21
  export const Token = (_a) => {
22
22
  var { token } = _a, other = __rest(_a, ["token"]);
23
- if (!token.priceUSD || !token.logoURI) {
23
+ if (!(token === null || token === void 0 ? void 0 : token.priceUSD) || !token.logoURI) {
24
24
  return _jsx(TokenFallback, Object.assign({ token: token }, other));
25
25
  }
26
26
  return _jsx(TokenBase, Object.assign({ token: token }, other));
27
27
  };
28
28
  export const TokenFallback = (_a) => {
29
- var { token, connected, step, disableDescription } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription"]);
30
- const { token: chainToken, isLoading } = useToken(token.chainId, token.address);
31
- return (_jsx(TokenBase, Object.assign({ token: Object.assign(Object.assign({}, token), chainToken), isLoading: isLoading }, other)));
29
+ var { token, connected, step, disableDescription, isLoading } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription", "isLoading"]);
30
+ const { token: chainToken, isLoading: isLoadingToken } = useToken(token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address);
31
+ return (_jsx(TokenBase, Object.assign({ token: Object.assign(Object.assign({}, token), chainToken), isLoading: isLoading || isLoadingToken }, other)));
32
32
  };
33
33
  export const TokenBase = (_a) => {
34
34
  var { token, connected, step, disableDescription, isLoading } = _a, other = __rest(_a, ["token", "connected", "step", "disableDescription", "isLoading"]);
35
35
  const { t } = useTranslation();
36
- const { chain } = useChain(token.chainId);
37
- const formattedTokenAmount = formatTokenAmount(token.amount, token.decimals);
38
- const formattedTokenPrice = formatTokenPrice(formattedTokenAmount, token.priceUSD);
39
- return (_jsxs(Box, Object.assign({ flex: 1 }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", flex: 1, alignItems: "center" }, { children: [_jsx(TokenAvatar, { token: token, chain: chain, sx: { marginRight: 2 } }), _jsx(TextFitter, Object.assign({ height: 30, textStyle: {
36
+ const { chain } = useChain(token === null || token === void 0 ? void 0 : token.chainId);
37
+ const formattedTokenAmount = formatTokenAmount(token === null || token === void 0 ? void 0 : token.amount, token === null || token === void 0 ? void 0 : token.decimals);
38
+ const formattedTokenPrice = formatTokenPrice(formattedTokenAmount, token === null || token === void 0 ? void 0 : token.priceUSD);
39
+ return (_jsxs(Box, Object.assign({ flex: 1 }, other, { children: [_jsxs(Box, Object.assign({ display: "flex", flex: 1, alignItems: "center" }, { children: [_jsx(TokenAvatar, { token: token, chain: chain, isLoading: isLoading, sx: { marginRight: 2 } }), isLoading ? (_jsx(Skeleton, { width: 112, height: 32, variant: "text" })) : (_jsx(TextFitter, Object.assign({ height: 30, textStyle: {
40
40
  fontWeight: 700,
41
41
  } }, { children: t('format.number', {
42
42
  value: formattedTokenAmount,
43
- }) }))] })), _jsxs(TextSecondaryContainer, Object.assign({ connected: connected, component: "span" }, { children: [_jsx(TextSecondary, Object.assign({ connected: connected }, { children: t(`format.currency`, {
43
+ }) })))] })), _jsxs(TextSecondaryContainer, Object.assign({ connected: connected, component: "span" }, { children: [isLoading ? (_jsx(Skeleton, { width: 48, height: 12, variant: "rounded", sx: { marginTop: 0.5 } })) : (_jsx(TextSecondary, Object.assign({ connected: connected }, { children: t(`format.currency`, {
44
44
  value: formattedTokenPrice,
45
- }) })), !disableDescription ? (_jsx(TextSecondary, Object.assign({ connected: connected, px: 0.5, dot: true }, { children: "\u2022" }))) : null, !step && !disableDescription ? (_jsx(TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
46
- tokenSymbol: token.symbol,
45
+ }) }))), !disableDescription ? (_jsx(TextSecondary, Object.assign({ connected: connected, px: 0.5, dot: true }, { children: "\u2022" }))) : null, !step && !disableDescription ? (isLoading ? (_jsx(Skeleton, { width: 96, height: 12, variant: "rounded", sx: { marginTop: 0.5 } })) : (_jsx(TextSecondary, Object.assign({ connected: connected }, { children: t(`swap.tokenOnChain`, {
46
+ tokenSymbol: token === null || token === void 0 ? void 0 : token.symbol,
47
47
  chainName: chain === null || chain === void 0 ? void 0 : chain.name,
48
- }) }))) : null, step ? (_jsxs(Box, Object.assign({ display: "flex", alignItems: "flex-end", height: 12, mt: 0.5 }, { children: [_jsx(Box, Object.assign({ pr: 0.75 }, { children: _jsx(SmallAvatar, Object.assign({ src: step.toolDetails.logoURI, alt: step.toolDetails.name, sx: {
48
+ }) })))) : null, step ? (_jsxs(Box, Object.assign({ display: "flex", alignItems: "flex-end", height: 12, mt: 0.5 }, { children: [_jsx(Box, Object.assign({ pr: 0.75 }, { children: _jsx(SmallAvatar, Object.assign({ src: step.toolDetails.logoURI, alt: step.toolDetails.name, sx: {
49
49
  border: 0,
50
50
  marginBottom: -0.25,
51
51
  } }, { children: step.toolDetails.name[0] })) })), _jsx(TextSecondary, Object.assign({ connected: true }, { children: step.toolDetails.name }))] }))) : null] }))] })));
@@ -2,18 +2,20 @@
2
2
  import type { Chain, Token } 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?: Token;
6
+ isLoading?: boolean;
6
7
  sx?: SxProps<Theme>;
7
8
  }>;
8
9
  export declare const TokenAvatarBase: React.FC<{
9
- token: Token;
10
+ token?: Token;
10
11
  chain?: Chain;
11
12
  isLoading?: boolean;
12
13
  sx?: SxProps<Theme>;
13
14
  }>;
14
15
  export declare const TokenAvatar: React.FC<{
15
- token: Token;
16
+ token?: Token;
16
17
  chain?: Chain;
18
+ isLoading?: boolean;
17
19
  sx?: SxProps<Theme>;
18
20
  }>;
19
21
  export declare const TokenAvatarDefault: React.FC<{
@@ -3,19 +3,20 @@ import { Avatar, Badge, Skeleton } from '@mui/material';
3
3
  import { useChain, useToken } from '../../hooks';
4
4
  import { SmallAvatar, SmallAvatarSkeleton } from '../SmallAvatar';
5
5
  import { AvatarDefault, AvatarDefaultContainer } from './TokenAvatar.style';
6
- export const TokenAvatarFallback = ({ token, sx }) => {
7
- const { chain } = useChain(token.chainId);
8
- const { token: chainToken, isLoading } = useToken(token.chainId, token.address);
9
- return (_jsx(TokenAvatarBase, { token: chainToken !== null && chainToken !== void 0 ? chainToken : token, isLoading: isLoading, chain: chain, sx: sx }));
6
+ export const TokenAvatarFallback = ({ token, isLoading, sx }) => {
7
+ const { chain } = useChain(token === null || token === void 0 ? void 0 : token.chainId);
8
+ const { token: chainToken, isLoading: isLoadingToken } = useToken(token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address);
9
+ return (_jsx(TokenAvatarBase, { token: chainToken !== null && chainToken !== void 0 ? chainToken : token, isLoading: isLoading || isLoadingToken, chain: chain, sx: sx }));
10
10
  };
11
11
  export const TokenAvatarBase = ({ token, chain, isLoading, sx }) => {
12
- return (_jsx(Badge, Object.assign({ overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: chain ? (_jsx(SmallAvatar, Object.assign({ src: chain.logoURI, alt: chain.name }, { children: chain.name[0] }))) : (_jsx(SmallAvatarSkeleton, {})), sx: sx }, { children: isLoading ? (_jsx(Skeleton, { width: 32, height: 32, variant: "circular" })) : (_jsx(Avatar, Object.assign({ src: token.logoURI, alt: token.symbol }, { children: token.symbol[0] }))) })));
12
+ var _a;
13
+ return (_jsx(Badge, Object.assign({ overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: chain && !isLoading ? (_jsx(SmallAvatar, Object.assign({ src: chain.logoURI, alt: chain.name }, { children: chain.name[0] }))) : (_jsx(SmallAvatarSkeleton, {})), sx: sx }, { children: isLoading ? (_jsx(Skeleton, { width: 32, height: 32, variant: "circular" })) : (_jsx(Avatar, Object.assign({ src: token === null || token === void 0 ? void 0 : token.logoURI, alt: token === null || token === void 0 ? void 0 : token.symbol }, { children: (_a = token === null || token === void 0 ? void 0 : token.symbol) === null || _a === void 0 ? void 0 : _a[0] }))) })));
13
14
  };
14
- export const TokenAvatar = ({ token, chain, sx }) => {
15
- if (!chain || !token.logoURI) {
16
- return _jsx(TokenAvatarFallback, { token: token, sx: sx });
15
+ export const TokenAvatar = ({ token, chain, isLoading, sx }) => {
16
+ if (!chain || !(token === null || token === void 0 ? void 0 : token.logoURI)) {
17
+ return _jsx(TokenAvatarFallback, { token: token, isLoading: isLoading, sx: sx });
17
18
  }
18
- return _jsx(TokenAvatarBase, { token: token, chain: chain, sx: sx });
19
+ return (_jsx(TokenAvatarBase, { token: token, chain: chain, isLoading: isLoading, sx: sx }));
19
20
  };
20
21
  export const TokenAvatarDefault = ({ sx }) => {
21
22
  return (_jsx(Badge, Object.assign({ overlap: "circular", anchorOrigin: { vertical: 'bottom', horizontal: 'right' }, badgeContent: _jsx(AvatarDefault, { width: 16, height: 16 }), sx: sx }, { children: _jsx(AvatarDefaultContainer, { children: _jsx(AvatarDefault, { width: 28, height: 28 }) }) })));
@@ -1,5 +1,6 @@
1
1
  import { ListItem as MuiListItem, ListItemButton as MuiListItemButton, } from '@mui/material';
2
2
  import { listItemSecondaryActionClasses } from '@mui/material/ListItemSecondaryAction';
3
+ import { listItemTextClasses } from '@mui/material/ListItemText';
3
4
  import { styled } from '@mui/material/styles';
4
5
  import { getContrastAlphaColor } from '../../utils';
5
6
  export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
@@ -23,4 +24,9 @@ export const ListItem = styled(MuiListItem)(({ theme }) => ({
23
24
  [`.${listItemSecondaryActionClasses.root}`]: {
24
25
  right: theme.spacing(3),
25
26
  },
27
+ [`& .${listItemTextClasses.primary}, & .${listItemTextClasses.secondary}`]: {
28
+ textOverflow: 'ellipsis',
29
+ overflow: 'hidden',
30
+ whiteSpace: 'nowrap',
31
+ },
26
32
  }));
@@ -36,8 +36,10 @@ export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollEleme
36
36
  getItemKey: (index) => { var _a; return (_a = tokens[index].address) !== null && _a !== void 0 ? _a : index; },
37
37
  });
38
38
  useEffect(() => {
39
- scrollToIndex(0, { align: 'start' });
40
- }, [scrollToIndex, chainId]);
39
+ if (getVirtualItems().length) {
40
+ scrollToIndex(0, { align: 'start' });
41
+ }
42
+ }, [scrollToIndex, chainId, getVirtualItems]);
41
43
  if (isLoading) {
42
44
  return (_jsx(List, Object.assign({ disablePadding: true }, { children: Array.from({ length: 3 }).map((_, index) => (
43
45
  // eslint-disable-next-line react/no-array-index-key
package/config/theme.js CHANGED
@@ -42,7 +42,7 @@ const shape = {
42
42
  borderRadiusSecondary: 6,
43
43
  };
44
44
  export const createTheme = (mode, theme = {}) => {
45
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
45
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
46
46
  const primaryMainColor = (_c = (_b = (_a = theme.palette) === null || _a === void 0 ? void 0 : _a.primary) === null || _b === void 0 ? void 0 : _b.main) !== null && _c !== void 0 ? _c : palette.primary.main;
47
47
  const primaryLightColor = lighten((_f = (_e = (_d = theme.palette) === null || _d === void 0 ? void 0 : _d.primary) === null || _e === void 0 ? void 0 : _e.main) !== null && _f !== void 0 ? _f : palette.primary.main, 0.5);
48
48
  const primaryDarkColor = darken((_j = (_h = (_g = theme.palette) === null || _g === void 0 ? void 0 : _g.primary) === null || _h === void 0 ? void 0 : _h.main) !== null && _j !== void 0 ? _j : palette.primary.main, 0.2);
@@ -147,14 +147,12 @@ export const createTheme = (mode, theme = {}) => {
147
147
  },
148
148
  },
149
149
  },
150
- MuiAvatar: {
151
- styleOverrides: {
150
+ MuiAvatar: Object.assign({ styleOverrides: {
152
151
  root: {
153
152
  height: 32,
154
153
  width: 32,
155
154
  },
156
- },
157
- },
155
+ } }, (_w = theme.components) === null || _w === void 0 ? void 0 : _w.MuiAvatar),
158
156
  MuiListItemAvatar: {
159
157
  styleOverrides: {
160
158
  root: {
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.27.1";
2
+ export declare const version = "1.28.0";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.27.1';
2
+ export const version = '1.28.0';
@@ -1,9 +1,12 @@
1
+ import type { Route } from '@lifi/sdk';
1
2
  export declare const useSwapRoutes: () => {
2
- routes: import("@lifi/sdk").Route[] | undefined;
3
+ routes: Route[] | undefined;
3
4
  isLoading: boolean;
4
5
  isFetching: boolean;
5
6
  isFetched: boolean;
6
7
  dataUpdatedAt: number;
7
8
  refetchTime: number;
8
- refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/sdk").RoutesResponse, any>>;
9
+ refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<import("@lifi/sdk").RoutesResponse | {
10
+ routes: Route[];
11
+ }, any>>;
9
12
  };
@@ -12,6 +12,7 @@ import { LifiErrorCode } from '@lifi/sdk';
12
12
  import { useQuery, useQueryClient } from '@tanstack/react-query';
13
13
  import Big from 'big.js';
14
14
  import { useWatch } from 'react-hook-form';
15
+ import { v4 as uuidv4 } from 'uuid';
15
16
  import { useDebouncedWatch, useToken } from '.';
16
17
  import { SwapFormKey, useLiFi, useWallet, useWidgetConfig } from '../providers';
17
18
  import { useSettings } from '../stores';
@@ -28,36 +29,47 @@ export const useSwapRoutes = () => {
28
29
  'enabledBridges',
29
30
  'enabledExchanges',
30
31
  ]);
31
- const [fromChainId, fromTokenAddress, toChainId, toTokenAddress, toAddress] = useWatch({
32
+ const [fromTokenAmount] = useDebouncedWatch([SwapFormKey.FromAmount], 320);
33
+ const [fromChainId, fromTokenAddress, toAddress, toTokenAmount, toChainId, toContractAddress, toContractCallData, toContractGasLimit, toTokenAddress,] = useWatch({
32
34
  name: [
33
35
  SwapFormKey.FromChain,
34
36
  SwapFormKey.FromToken,
37
+ SwapFormKey.ToAddress,
38
+ SwapFormKey.ToAmount,
35
39
  SwapFormKey.ToChain,
40
+ SwapFormKey.ToContractAddress,
41
+ SwapFormKey.ToContractCallData,
42
+ SwapFormKey.ToContractGasLimit,
36
43
  SwapFormKey.ToToken,
37
- SwapFormKey.ToAddress,
38
44
  ],
39
45
  });
40
- const [fromTokenAmount] = useDebouncedWatch([SwapFormKey.FromAmount], 320);
41
46
  const { token: fromToken } = useToken(fromChainId, fromTokenAddress);
42
47
  const { token: toToken } = useToken(toChainId, toTokenAddress);
43
- const isEnabled =
44
- // Boolean(account.address) &&
45
- !isNaN(fromChainId) &&
48
+ const hasAmount = (!isNaN(fromTokenAmount) && Number(fromTokenAmount) > 0) ||
49
+ (!isNaN(toTokenAmount) && Number(toTokenAmount) > 0);
50
+ const contractCallQuoteEnabled = variant === 'nft'
51
+ ? Boolean(toContractAddress && toContractCallData && toContractGasLimit)
52
+ : true;
53
+ const isEnabled = !isNaN(fromChainId) &&
46
54
  !isNaN(toChainId) &&
47
55
  Boolean(fromToken === null || fromToken === void 0 ? void 0 : fromToken.address) &&
48
56
  Boolean(toToken === null || toToken === void 0 ? void 0 : toToken.address) &&
49
- !isNaN(fromTokenAmount) &&
50
- Number(fromTokenAmount) > 0 &&
51
- !Number.isNaN(slippage);
57
+ !Number.isNaN(slippage) &&
58
+ hasAmount &&
59
+ contractCallQuoteEnabled;
52
60
  const queryKey = [
53
61
  'routes',
54
62
  account.address,
55
63
  fromChainId,
56
64
  fromToken === null || fromToken === void 0 ? void 0 : fromToken.address,
57
65
  fromTokenAmount,
66
+ toAddress,
58
67
  toChainId,
59
68
  toToken === null || toToken === void 0 ? void 0 : toToken.address,
60
- toAddress,
69
+ toTokenAmount,
70
+ toContractAddress,
71
+ toContractCallData,
72
+ toContractGasLimit,
61
73
  slippage,
62
74
  enabledBridges,
63
75
  enabledExchanges,
@@ -69,20 +81,58 @@ export const useSwapRoutes = () => {
69
81
  const refetchInterval = previousDataUpdatedAt
70
82
  ? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
71
83
  : refetchTime;
72
- const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress, toAddress, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
73
- var _c, _d;
84
+ const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = useQuery(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toAddress, toChainId, toTokenAddress, toTokenAmount, toContractAddress, toContractCallData, toContractGasLimit, slippage, enabledBridges, enabledExchanges, routePriority, variant, allowSwitchChain,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
85
+ var _c, _d, _e;
74
86
  let toWalletAddress;
75
87
  try {
76
88
  toWalletAddress =
77
89
  (_c = (yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(toAddress)))) !== null && _c !== void 0 ? _c : (isAddress(toAddress) ? toAddress : fromAddress);
78
90
  }
79
- catch (_e) {
91
+ catch (_f) {
80
92
  toWalletAddress = isAddress(toAddress) ? toAddress : fromAddress;
81
93
  }
82
- const fromAmount = Big(fromTokenAmount)
94
+ const fromAmount = Big(fromTokenAmount || 0)
83
95
  .mul(Math.pow(10, ((_d = fromToken === null || fromToken === void 0 ? void 0 : fromToken.decimals) !== null && _d !== void 0 ? _d : 0)))
84
96
  .toString();
97
+ // const toAmount = Big(toTokenAmount || 0)
98
+ // .mul(10 ** (toToken?.decimals ?? 0))
99
+ // .toString();
85
100
  const formattedSlippage = parseFloat(slippage) / 100;
101
+ if (variant === 'nft') {
102
+ const contractCallQuote = yield lifi.getContractCallQuote({
103
+ fromAddress,
104
+ fromChain: fromChainId,
105
+ fromToken: fromTokenAddress,
106
+ toAmount: toTokenAmount,
107
+ toChain: toChainId,
108
+ toToken: toTokenAddress,
109
+ toContractAddress,
110
+ toContractCallData,
111
+ toContractGasLimit,
112
+ // toFallbackAddress: toAddress,
113
+ slippage: formattedSlippage,
114
+ }, { signal });
115
+ contractCallQuote.estimate.toAmount = toTokenAmount;
116
+ contractCallQuote.estimate.toAmountMin = toTokenAmount;
117
+ contractCallQuote.action.toToken = toToken;
118
+ const route = {
119
+ id: uuidv4(),
120
+ fromChainId: contractCallQuote.action.fromChainId,
121
+ fromAmountUSD: contractCallQuote.estimate.fromAmountUSD || '',
122
+ fromAmount: contractCallQuote.action.fromAmount,
123
+ fromToken: contractCallQuote.action.fromToken,
124
+ fromAddress: contractCallQuote.action.fromAddress,
125
+ toChainId: contractCallQuote.action.toChainId,
126
+ toAmountUSD: contractCallQuote.estimate.toAmountUSD || '',
127
+ toAmount: toTokenAmount,
128
+ toAmountMin: toTokenAmount,
129
+ toToken: toToken,
130
+ toAddress: toAddress,
131
+ gasCostUSD: (_e = contractCallQuote.estimate.gasCosts) === null || _e === void 0 ? void 0 : _e[0].amountUSD,
132
+ steps: [contractCallQuote],
133
+ };
134
+ return { routes: [route] };
135
+ }
86
136
  return lifi.getRoutes({
87
137
  fromChainId,
88
138
  fromAmount,
@@ -1,4 +1,4 @@
1
- export declare const useToken: (chainId: number, tokenAddress: string) => {
1
+ export declare const useToken: (chainId?: number, tokenAddress?: string) => {
2
2
  token: import("..").Token | undefined;
3
3
  isLoading: boolean;
4
4
  };
@@ -1,5 +1,5 @@
1
1
  import type { Token } from '../types';
2
- export declare const useTokenSearch: (chainId: number, token: string, enabled?: boolean) => {
2
+ export declare const useTokenSearch: (chainId?: number, token?: string, enabled?: boolean) => {
3
3
  token: Token | undefined;
4
4
  isLoading: boolean;
5
5
  };