@lifi/widget 1.20.3 → 1.22.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 (230) hide show
  1. package/App.d.ts +2 -2
  2. package/App.js +5 -3
  3. package/AppDrawer.d.ts +3 -8
  4. package/AppDrawer.style.d.ts +1 -1
  5. package/AppProvider.d.ts +2 -5
  6. package/AppProvider.js +2 -2
  7. package/AppRoutes.js +5 -0
  8. package/cjs/App.d.ts +2 -2
  9. package/cjs/App.js +5 -4
  10. package/cjs/AppDrawer.d.ts +3 -8
  11. package/cjs/AppDrawer.style.d.ts +1 -1
  12. package/cjs/AppProvider.d.ts +2 -5
  13. package/cjs/AppProvider.js +1 -1
  14. package/cjs/AppRoutes.js +5 -0
  15. package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
  16. package/cjs/components/BottomSheet/BottomSheet.d.ts +1 -1
  17. package/cjs/components/ChainSelect/ChainSelect.d.ts +0 -1
  18. package/cjs/components/ChainSelect/ChainSelect.js +1 -3
  19. package/cjs/components/ChainSelect/useChainSelect.d.ts +1 -1
  20. package/cjs/components/Header/Header.style.d.ts +34 -1
  21. package/cjs/components/Header/Header.style.js +19 -1
  22. package/cjs/components/Header/NavigationHeader.js +4 -1
  23. package/cjs/components/Header/WalletHeader.js +34 -9
  24. package/cjs/components/Menu.d.ts +1 -0
  25. package/cjs/components/Menu.js +24 -0
  26. package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  27. package/cjs/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
  28. package/cjs/components/SelectChainAndToken.js +6 -1
  29. package/cjs/components/SelectTokenButton/SelectTokenButton.js +8 -6
  30. package/cjs/components/SelectTokenButton/SelectTokenButton.style.js +2 -1
  31. package/cjs/components/SendToWallet/SendToWallet.js +5 -0
  32. package/cjs/components/SendToWallet/SendToWallet.style.d.ts +1 -1
  33. package/cjs/components/SendToWallet/SendToWalletButton.js +5 -1
  34. package/cjs/components/Step/CircularProgress.d.ts +0 -1
  35. package/cjs/components/Step/StepProcess.style.d.ts +2 -2
  36. package/cjs/components/Step/StepTimer.js +1 -1
  37. package/cjs/components/StepActions/StepActions.js +6 -1
  38. package/cjs/components/SwapInput/FormPriceHelperText.js +4 -4
  39. package/cjs/components/SwapInput/SwapInput.js +5 -2
  40. package/cjs/components/SwapInput/SwapInput.style.d.ts +1 -1
  41. package/cjs/components/SwapInput/SwapInputAdornment.d.ts +0 -1
  42. package/cjs/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
  43. package/cjs/components/SwapRouteCard/SwapRouteCard.js +5 -3
  44. package/cjs/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
  45. package/cjs/components/SwapRouteCard/SwapRouteCardSkeleton.js +3 -1
  46. package/cjs/components/SwapRoutes/SwapRoutes.js +8 -3
  47. package/cjs/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
  48. package/cjs/components/Token/Token.js +6 -5
  49. package/cjs/components/TokenAvatar/TokenAvatar.d.ts +6 -1
  50. package/cjs/components/TokenAvatar/TokenAvatar.js +10 -3
  51. package/cjs/components/TokenList/TokenList.js +2 -23
  52. package/cjs/components/TokenList/TokenListItem.d.ts +2 -1
  53. package/cjs/components/TokenList/TokenListItem.js +12 -6
  54. package/cjs/components/TokenList/index.d.ts +1 -0
  55. package/cjs/components/TokenList/index.js +1 -0
  56. package/cjs/components/TokenList/types.d.ts +6 -0
  57. package/cjs/components/TokenList/useTokenSelect.d.ts +2 -0
  58. package/cjs/components/TokenList/useTokenSelect.js +33 -0
  59. package/cjs/config/version.d.ts +1 -1
  60. package/cjs/config/version.js +1 -1
  61. package/cjs/hooks/useChain.d.ts +2 -2
  62. package/cjs/hooks/useChains.d.ts +2 -2
  63. package/cjs/hooks/useExpandableVariant.js +3 -5
  64. package/cjs/hooks/useProcessMessage.d.ts +2 -2
  65. package/cjs/hooks/useSwapRoutes.js +11 -7
  66. package/cjs/i18n/de.json +199 -0
  67. package/cjs/i18n/{en/translation.json → en.json} +157 -150
  68. package/cjs/i18n/es.json +199 -0
  69. package/cjs/i18n/fr.json +199 -0
  70. package/cjs/i18n/index.d.ts +8 -199
  71. package/cjs/i18n/index.js +16 -22
  72. package/cjs/i18n/it.json +199 -0
  73. package/cjs/i18n/uk.json +200 -0
  74. package/cjs/i18n/zh.json +199 -0
  75. package/cjs/index.d.ts +6 -3
  76. package/cjs/index.js +3 -2
  77. package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
  78. package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +1 -1
  79. package/cjs/pages/SelectChainPage/SelectChainPage.js +2 -5
  80. package/cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.d.ts +3 -0
  81. package/cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.js +21 -0
  82. package/cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.d.ts +21 -0
  83. package/cjs/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.js +20 -0
  84. package/cjs/pages/SelectNativeTokenPage/index.d.ts +1 -0
  85. package/cjs/pages/SelectNativeTokenPage/index.js +17 -0
  86. package/cjs/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
  87. package/cjs/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
  88. package/cjs/pages/SettingsPage/AdvancedPreferences.d.ts +0 -1
  89. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  90. package/cjs/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
  91. package/cjs/pages/SettingsPage/LanguageSelect.d.ts +2 -0
  92. package/cjs/pages/SettingsPage/LanguageSelect.js +38 -0
  93. package/cjs/pages/SettingsPage/SettingsPage.d.ts +0 -1
  94. package/cjs/pages/SettingsPage/SettingsPage.js +2 -1
  95. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
  96. package/cjs/pages/SettingsPage/ShowDestinationWallet.js +6 -0
  97. package/cjs/pages/SettingsPage/SlippageInput.d.ts +0 -1
  98. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +4 -2
  99. package/cjs/pages/SwapHistoryPage/SwapHistoryItem.js +4 -2
  100. package/cjs/pages/SwapPage/StatusBottomSheet.js +3 -3
  101. package/cjs/pages/SwapPage/TokenValueBottomSheet.js +1 -1
  102. package/cjs/providers/I18nProvider/I18nProvider.d.ts +2 -0
  103. package/cjs/providers/I18nProvider/I18nProvider.js +62 -0
  104. package/cjs/providers/I18nProvider/index.d.ts +2 -0
  105. package/cjs/providers/I18nProvider/index.js +18 -0
  106. package/cjs/providers/I18nProvider/types.d.ts +16 -0
  107. package/cjs/providers/I18nProvider/types.js +2 -0
  108. package/cjs/providers/WidgetProvider/utils.d.ts +1 -1
  109. package/cjs/providers/WidgetProvider/utils.js +4 -4
  110. package/cjs/providers/index.d.ts +1 -0
  111. package/cjs/providers/index.js +1 -0
  112. package/cjs/stores/settings/types.d.ts +1 -0
  113. package/cjs/stores/settings/useSettingsStore.d.ts +2 -0
  114. package/cjs/types/widget.d.ts +30 -8
  115. package/cjs/types/widget.js +8 -0
  116. package/cjs/utils/deepMerge.d.ts +1 -0
  117. package/cjs/utils/deepMerge.js +18 -0
  118. package/cjs/utils/index.d.ts +1 -0
  119. package/cjs/utils/index.js +1 -0
  120. package/cjs/utils/navigationRoutes.d.ts +8 -7
  121. package/cjs/utils/navigationRoutes.js +10 -7
  122. package/components/ActiveSwaps/ActiveSwaps.style.d.ts +1 -1
  123. package/components/BottomSheet/BottomSheet.d.ts +1 -1
  124. package/components/ChainSelect/ChainSelect.d.ts +0 -1
  125. package/components/ChainSelect/ChainSelect.js +1 -3
  126. package/components/ChainSelect/useChainSelect.d.ts +1 -1
  127. package/components/Header/Header.style.d.ts +34 -1
  128. package/components/Header/Header.style.js +19 -1
  129. package/components/Header/NavigationHeader.js +4 -1
  130. package/components/Header/WalletHeader.js +37 -12
  131. package/components/Menu.d.ts +1 -0
  132. package/components/Menu.js +21 -0
  133. package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
  134. package/components/ReverseTokensButton/ReverseTokensButton.style.d.ts +1 -1
  135. package/components/SelectChainAndToken.js +7 -2
  136. package/components/SelectTokenButton/SelectTokenButton.js +9 -7
  137. package/components/SelectTokenButton/SelectTokenButton.style.js +2 -1
  138. package/components/SendToWallet/SendToWallet.js +6 -1
  139. package/components/SendToWallet/SendToWallet.style.d.ts +1 -1
  140. package/components/SendToWallet/SendToWalletButton.js +6 -2
  141. package/components/Step/CircularProgress.d.ts +0 -1
  142. package/components/Step/StepProcess.style.d.ts +2 -2
  143. package/components/Step/StepTimer.js +1 -1
  144. package/components/StepActions/StepActions.js +6 -1
  145. package/components/SwapInput/FormPriceHelperText.js +4 -4
  146. package/components/SwapInput/SwapInput.js +6 -3
  147. package/components/SwapInput/SwapInput.style.d.ts +1 -1
  148. package/components/SwapInput/SwapInputAdornment.d.ts +0 -1
  149. package/components/SwapInput/SwapInputAdornment.style.d.ts +1 -1
  150. package/components/SwapRouteCard/SwapRouteCard.js +5 -3
  151. package/components/SwapRouteCard/SwapRouteCard.style.d.ts +1 -1
  152. package/components/SwapRouteCard/SwapRouteCardSkeleton.js +3 -1
  153. package/components/SwapRoutes/SwapRoutes.js +8 -3
  154. package/components/SwapRoutes/SwapRoutesExpanded.d.ts +0 -1
  155. package/components/Token/Token.js +7 -6
  156. package/components/TokenAvatar/TokenAvatar.d.ts +6 -1
  157. package/components/TokenAvatar/TokenAvatar.js +8 -2
  158. package/components/TokenList/TokenList.js +4 -25
  159. package/components/TokenList/TokenListItem.d.ts +2 -1
  160. package/components/TokenList/TokenListItem.js +10 -5
  161. package/components/TokenList/index.d.ts +1 -0
  162. package/components/TokenList/index.js +1 -0
  163. package/components/TokenList/types.d.ts +6 -0
  164. package/components/TokenList/useTokenSelect.d.ts +2 -0
  165. package/components/TokenList/useTokenSelect.js +29 -0
  166. package/config/version.d.ts +1 -1
  167. package/config/version.js +1 -1
  168. package/hooks/useChain.d.ts +2 -2
  169. package/hooks/useChains.d.ts +2 -2
  170. package/hooks/useExpandableVariant.js +3 -5
  171. package/hooks/useProcessMessage.d.ts +2 -2
  172. package/hooks/useSwapRoutes.js +12 -8
  173. package/i18n/de.json +199 -0
  174. package/i18n/{en/translation.json → en.json} +157 -150
  175. package/i18n/es.json +199 -0
  176. package/i18n/fr.json +199 -0
  177. package/i18n/index.d.ts +8 -199
  178. package/i18n/index.js +9 -20
  179. package/i18n/it.json +199 -0
  180. package/i18n/uk.json +200 -0
  181. package/i18n/zh.json +199 -0
  182. package/index.d.ts +6 -3
  183. package/index.js +3 -2
  184. package/package.json +18 -17
  185. package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +0 -1
  186. package/pages/SelectChainPage/SelectChainPage.d.ts +1 -1
  187. package/pages/SelectChainPage/SelectChainPage.js +2 -5
  188. package/pages/SelectNativeTokenPage/SelectNativeTokenPage.d.ts +3 -0
  189. package/pages/SelectNativeTokenPage/SelectNativeTokenPage.js +17 -0
  190. package/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.d.ts +21 -0
  191. package/pages/SelectNativeTokenPage/SelectNativeTokenPage.style.js +17 -0
  192. package/pages/SelectNativeTokenPage/index.d.ts +1 -0
  193. package/pages/SelectNativeTokenPage/index.js +1 -0
  194. package/pages/SelectTokenPage/SearchTokenInput.d.ts +0 -1
  195. package/pages/SelectWalletPage/SelectWalletPage.d.ts +0 -1
  196. package/pages/SettingsPage/AdvancedPreferences.d.ts +0 -1
  197. package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
  198. package/pages/SettingsPage/GasPriceSelect.d.ts +0 -1
  199. package/pages/SettingsPage/LanguageSelect.d.ts +2 -0
  200. package/pages/SettingsPage/LanguageSelect.js +34 -0
  201. package/pages/SettingsPage/SettingsPage.d.ts +0 -1
  202. package/pages/SettingsPage/SettingsPage.js +2 -1
  203. package/pages/SettingsPage/ShowDestinationWallet.d.ts +1 -2
  204. package/pages/SettingsPage/ShowDestinationWallet.js +6 -0
  205. package/pages/SettingsPage/SlippageInput.d.ts +0 -1
  206. package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -2
  207. package/pages/SwapHistoryPage/SwapHistoryItem.js +4 -2
  208. package/pages/SwapPage/StatusBottomSheet.js +3 -3
  209. package/pages/SwapPage/TokenValueBottomSheet.js +1 -1
  210. package/providers/I18nProvider/I18nProvider.d.ts +2 -0
  211. package/providers/I18nProvider/I18nProvider.js +58 -0
  212. package/providers/I18nProvider/index.d.ts +2 -0
  213. package/providers/I18nProvider/index.js +2 -0
  214. package/providers/I18nProvider/types.d.ts +16 -0
  215. package/providers/I18nProvider/types.js +1 -0
  216. package/providers/WidgetProvider/utils.d.ts +1 -1
  217. package/providers/WidgetProvider/utils.js +4 -4
  218. package/providers/index.d.ts +1 -0
  219. package/providers/index.js +1 -0
  220. package/stores/settings/types.d.ts +1 -0
  221. package/stores/settings/useSettingsStore.d.ts +2 -0
  222. package/tsconfig.cjs.tsbuildinfo +1 -1
  223. package/types/widget.d.ts +30 -8
  224. package/types/widget.js +7 -1
  225. package/utils/deepMerge.d.ts +1 -0
  226. package/utils/deepMerge.js +14 -0
  227. package/utils/index.d.ts +1 -0
  228. package/utils/index.js +1 -0
  229. package/utils/navigationRoutes.d.ts +8 -7
  230. package/utils/navigationRoutes.js +10 -7
@@ -8,12 +8,12 @@ const react_hook_form_1 = require("react-hook-form");
8
8
  const hooks_1 = require("../../hooks");
9
9
  const providers_1 = require("../../providers");
10
10
  const TokenNotFound_1 = require("./TokenNotFound");
11
+ const useTokenSelect_1 = require("./useTokenSelect");
11
12
  const VirtualizedTokenList_1 = require("./VirtualizedTokenList");
12
13
  const TokenList = ({ formType, height, onClick, }) => {
13
14
  var _a, _b;
14
15
  const parentRef = (0, react_1.useRef)(null);
15
16
  const { account } = (0, providers_1.useWallet)();
16
- const { setValue, getValues } = (0, react_hook_form_1.useFormContext)();
17
17
  const [selectedChainId] = (0, react_hook_form_1.useWatch)({
18
18
  name: [providers_1.SwapFormKeyHelper.getChainKey(formType)],
19
19
  });
@@ -37,28 +37,7 @@ const TokenList = ({ formType, height, onClick, }) => {
37
37
  : searchedToken
38
38
  ? [searchedToken]
39
39
  : filteredTokens;
40
- const handleTokenClick = (0, react_1.useCallback)((tokenAddress) => {
41
- setValue(providers_1.SwapFormKeyHelper.getTokenKey(formType), tokenAddress, {
42
- shouldTouch: true,
43
- });
44
- // Set chain again to trigger URL builder update
45
- setValue(providers_1.SwapFormKeyHelper.getChainKey(formType), selectedChainId, {
46
- shouldTouch: true,
47
- });
48
- setValue(providers_1.SwapFormKeyHelper.getAmountKey(formType), '');
49
- const oppositeFormType = formType === 'from' ? 'to' : 'from';
50
- const [selectedOppositeToken, selectedOppositeChainId] = getValues([
51
- providers_1.SwapFormKeyHelper.getTokenKey(oppositeFormType),
52
- providers_1.SwapFormKeyHelper.getChainKey(oppositeFormType),
53
- ]);
54
- if (selectedOppositeToken === tokenAddress &&
55
- selectedOppositeChainId === selectedChainId) {
56
- setValue(providers_1.SwapFormKeyHelper.getTokenKey(oppositeFormType), '', {
57
- shouldTouch: true,
58
- });
59
- }
60
- onClick === null || onClick === void 0 ? void 0 : onClick();
61
- }, [formType, getValues, onClick, selectedChainId, setValue]);
40
+ const handleTokenClick = (0, useTokenSelect_1.useTokenSelect)(formType, onClick);
62
41
  return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ ref: parentRef, style: { height, overflow: 'auto' } }, { children: [!tokens.length && !isLoading ? ((0, jsx_runtime_1.jsx)(TokenNotFound_1.TokenNotFound, { formType: formType })) : null, (0, jsx_runtime_1.jsx)(VirtualizedTokenList_1.VirtualizedTokenList, { tokens: tokens, featuredTokensLength: featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length, scrollElementRef: parentRef, chainId: selectedChainId, isLoading: isLoading, isBalanceLoading: isBalanceLoading, showBalance: account.isActive, showFeatured: !tokenSearchFilter, onClick: handleTokenClick })] })));
63
42
  };
64
43
  exports.TokenList = TokenList;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
- import type { TokenListItemProps } from './types';
2
+ import type { TokenListItemButtonProps, TokenListItemProps } from './types';
3
3
  export declare const TokenListItem: React.FC<TokenListItemProps>;
4
+ export declare const TokenListItemButton: React.FC<TokenListItemButtonProps>;
4
5
  export declare const TokenListItemSkeleton: () => JSX.Element;
5
6
  export declare const TokenAmountSkeleton: React.FC;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TokenAmountSkeleton = exports.TokenListItemSkeleton = exports.TokenListItem = void 0;
3
+ exports.TokenAmountSkeleton = exports.TokenListItemSkeleton = exports.TokenListItemButton = exports.TokenListItem = void 0;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const material_1 = require("@mui/material");
6
6
  const react_1 = require("react");
@@ -8,16 +8,22 @@ const react_i18next_1 = require("react-i18next");
8
8
  const utils_1 = require("../../utils");
9
9
  const TokenList_style_1 = require("./TokenList.style");
10
10
  exports.TokenListItem = (0, react_1.memo)(({ onClick, size, start, token, showBalance, isBalanceLoading, startAdornment, endAdornment, }) => {
11
- const { t } = (0, react_i18next_1.useTranslation)();
12
11
  const handleClick = () => onClick === null || onClick === void 0 ? void 0 : onClick(token.address);
13
- const tokenPrice = (0, utils_1.formatTokenPrice)(token.amount, token.priceUSD);
14
12
  return ((0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItem, Object.assign({ disablePadding: true, style: {
15
13
  height: `${size}px`,
16
14
  transform: `translateY(${start}px)`,
17
- } }, { children: [startAdornment, (0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItemButton, Object.assign({ onClick: handleClick, dense: true, disableRipple: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: token.logoURI, alt: token.symbol }, { children: token.symbol[0] })) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: token.symbol, secondary: token.name }), showBalance ? (isBalanceLoading ? ((0, jsx_runtime_1.jsx)(exports.TokenAmountSkeleton, {})) : ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { textAlign: 'right' } }, { children: [Number(token.amount) ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", noWrap: true }, { children: token.amount }))) : null, tokenPrice ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontWeight: 400, fontSize: 12, color: "text.secondary", "data-price": token.priceUSD }, { children: t(`swap.currency`, {
18
- value: tokenPrice,
19
- }) }))) : null] })))) : null] })), endAdornment] })));
15
+ } }, { children: [startAdornment, (0, jsx_runtime_1.jsx)(exports.TokenListItemButton, { token: token, showBalance: showBalance, isBalanceLoading: isBalanceLoading, onClick: handleClick }), endAdornment] })));
20
16
  });
17
+ const TokenListItemButton = ({ onClick, token, showBalance, isBalanceLoading, }) => {
18
+ const { t } = (0, react_i18next_1.useTranslation)();
19
+ const tokenPrice = (0, utils_1.formatTokenPrice)(token.amount, token.priceUSD);
20
+ return ((0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItemButton, Object.assign({ onClick: onClick, dense: true, disableRipple: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: token.logoURI, alt: token.symbol }, { children: token.symbol[0] })) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: token.symbol, secondary: token.name }), showBalance ? (isBalanceLoading ? ((0, jsx_runtime_1.jsx)(exports.TokenAmountSkeleton, {})) : ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { textAlign: 'right' } }, { children: [Number(token.amount) ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body1", noWrap: true }, { children: t('format.number', {
21
+ value: token.amount,
22
+ }) }))) : null, tokenPrice ? ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontWeight: 400, fontSize: 12, color: "text.secondary", "data-price": token.priceUSD }, { children: t(`format.currency`, {
23
+ value: tokenPrice,
24
+ }) }))) : null] })))) : null] })));
25
+ };
26
+ exports.TokenListItemButton = TokenListItemButton;
21
27
  const TokenListItemSkeleton = () => {
22
28
  return ((0, jsx_runtime_1.jsxs)(TokenList_style_1.ListItem, Object.assign({ secondaryAction: (0, jsx_runtime_1.jsx)(exports.TokenAmountSkeleton, {}), disablePadding: true, sx: { position: 'relative', flexDirection: 'row', alignItems: 'center' } }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "circular", width: 32, height: 32, sx: { marginLeft: 1.5, marginRight: 2 } }) }), (0, jsx_runtime_1.jsx)(material_1.ListItemText, { primary: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 48, height: 20 }), secondary: (0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "text", width: 96, height: 20 }) })] })));
23
29
  };
@@ -1 +1,2 @@
1
1
  export * from './TokenList';
2
+ export * from './useTokenSelect';
@@ -15,3 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./TokenList"), exports);
18
+ __exportStar(require("./useTokenSelect"), exports);
@@ -30,3 +30,9 @@ export interface TokenListItemProps extends TokenListItemBaseProps {
30
30
  startAdornment?: React.ReactNode;
31
31
  endAdornment?: React.ReactNode;
32
32
  }
33
+ export interface TokenListItemButtonProps {
34
+ onClick?(): void;
35
+ showBalance?: boolean;
36
+ token: TokenAmount;
37
+ isBalanceLoading?: boolean;
38
+ }
@@ -0,0 +1,2 @@
1
+ import type { SwapFormType } from '../../providers';
2
+ export declare const useTokenSelect: (formType: SwapFormType, onClick?: () => void) => (tokenAddress: string, chainId?: number) => void;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTokenSelect = void 0;
4
+ const react_1 = require("react");
5
+ const react_hook_form_1 = require("react-hook-form");
6
+ const providers_1 = require("../../providers");
7
+ const useTokenSelect = (formType, onClick) => {
8
+ const { setValue, getValues } = (0, react_hook_form_1.useFormContext)();
9
+ return (0, react_1.useCallback)((tokenAddress, chainId) => {
10
+ const selectedChainId = chainId !== null && chainId !== void 0 ? chainId : getValues(providers_1.SwapFormKeyHelper.getChainKey(formType));
11
+ setValue(providers_1.SwapFormKeyHelper.getTokenKey(formType), tokenAddress, {
12
+ shouldTouch: true,
13
+ });
14
+ // Set chain again to trigger URL builder update
15
+ setValue(providers_1.SwapFormKeyHelper.getChainKey(formType), selectedChainId, {
16
+ shouldTouch: true,
17
+ });
18
+ setValue(providers_1.SwapFormKeyHelper.getAmountKey(formType), '');
19
+ const oppositeFormType = formType === 'from' ? 'to' : 'from';
20
+ const [selectedOppositeToken, selectedOppositeChainId] = getValues([
21
+ providers_1.SwapFormKeyHelper.getTokenKey(oppositeFormType),
22
+ providers_1.SwapFormKeyHelper.getChainKey(oppositeFormType),
23
+ ]);
24
+ if (selectedOppositeToken === tokenAddress &&
25
+ selectedOppositeChainId === selectedChainId) {
26
+ setValue(providers_1.SwapFormKeyHelper.getTokenKey(oppositeFormType), '', {
27
+ shouldTouch: true,
28
+ });
29
+ }
30
+ onClick === null || onClick === void 0 ? void 0 : onClick();
31
+ }, [formType, getValues, onClick, setValue]);
32
+ };
33
+ exports.useTokenSelect = useTokenSelect;
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.20.3";
2
+ export declare const version = "1.22.0";
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.name = void 0;
4
4
  exports.name = '@lifi/widget';
5
- exports.version = '1.20.3';
5
+ exports.version = '1.22.0';
@@ -1,4 +1,4 @@
1
- export declare const useChain: (chainId: number) => {
2
- chain: import("@lifi/types").EVMChain | undefined;
1
+ export declare const useChain: (chainId?: number) => {
2
+ chain: import("@lifi/types").ExtendedChain | undefined;
3
3
  isLoading: boolean;
4
4
  };
@@ -1,5 +1,5 @@
1
1
  export declare const useChains: () => {
2
- chains: import("@lifi/types").EVMChain[] | undefined;
3
- getChainById: (chainId: number) => import("@lifi/types").EVMChain | undefined;
2
+ chains: import("@lifi/types").ExtendedChain[] | undefined;
3
+ getChainById: (chainId: number) => import("@lifi/types").ExtendedChain | undefined;
4
4
  isLoading: boolean;
5
5
  };
@@ -5,10 +5,8 @@ const material_1 = require("@mui/material");
5
5
  const providers_1 = require("../providers");
6
6
  const defaultExpandableWidth = 852;
7
7
  const useExpandableVariant = () => {
8
- const { variant } = (0, providers_1.useWidgetConfig)();
9
- const expandableAllowed = (0, material_1.useMediaQuery)((theme) => {
10
- return theme.breakpoints.up(defaultExpandableWidth);
11
- });
12
- return variant === 'expandable' && expandableAllowed;
8
+ const { variant, useRecommendedRoute } = (0, providers_1.useWidgetConfig)();
9
+ const expandableAllowed = (0, material_1.useMediaQuery)((theme) => theme.breakpoints.up(defaultExpandableWidth));
10
+ return variant === 'expandable' && expandableAllowed && !useRecommendedRoute;
13
11
  };
14
12
  exports.useExpandableVariant = useExpandableVariant;
@@ -1,10 +1,10 @@
1
1
  import type { EVMChain, Process, Step } from '@lifi/sdk';
2
- import type { TFunction } from 'react-i18next';
2
+ import type { TFunction } from 'i18next';
3
3
  export declare const useProcessMessage: (step?: Step, process?: Process) => {
4
4
  title?: string | undefined;
5
5
  message?: string | undefined;
6
6
  };
7
- export declare function getProcessMessage(t: TFunction<'translation', undefined>, getChainById: (chainId: number) => EVMChain | undefined, step: Step, process: Process): {
7
+ export declare function getProcessMessage(t: TFunction, getChainById: (chainId: number) => EVMChain | undefined, step: Step, process: Process): {
8
8
  title?: string;
9
9
  message?: string;
10
10
  };
@@ -21,6 +21,7 @@ const refetchTime = 60000;
21
21
  const useSwapRoutes = () => {
22
22
  var _a;
23
23
  const lifi = (0, providers_1.useLiFi)();
24
+ const { variant } = (0, providers_1.useWidgetConfig)();
24
25
  const { account, provider } = (0, providers_1.useWallet)();
25
26
  const queryClient = (0, react_query_1.useQueryClient)();
26
27
  const { slippage, enabledBridges, enabledExchanges, routePriority } = (0, stores_1.useSettings)([
@@ -39,13 +40,14 @@ const useSwapRoutes = () => {
39
40
  ],
40
41
  });
41
42
  const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount], 320);
42
- const { token } = (0, _1.useToken)(fromChainId, fromTokenAddress);
43
+ const { token: fromToken } = (0, _1.useToken)(fromChainId, fromTokenAddress);
44
+ const { token: toToken } = (0, _1.useToken)(toChainId, toTokenAddress);
43
45
  const isEnabled =
44
46
  // Boolean(account.address) &&
45
47
  !isNaN(fromChainId) &&
46
48
  !isNaN(toChainId) &&
47
- Boolean(token === null || token === void 0 ? void 0 : token.address) &&
48
- Boolean(toTokenAddress) &&
49
+ Boolean(fromToken === null || fromToken === void 0 ? void 0 : fromToken.address) &&
50
+ Boolean(toToken === null || toToken === void 0 ? void 0 : toToken.address) &&
49
51
  !isNaN(fromTokenAmount) &&
50
52
  Number(fromTokenAmount) > 0 &&
51
53
  !Number.isNaN(slippage);
@@ -53,21 +55,22 @@ const useSwapRoutes = () => {
53
55
  'routes',
54
56
  account.address,
55
57
  fromChainId,
56
- token === null || token === void 0 ? void 0 : token.address,
58
+ fromToken === null || fromToken === void 0 ? void 0 : fromToken.address,
57
59
  fromTokenAmount,
58
60
  toChainId,
59
- toTokenAddress,
61
+ toToken === null || toToken === void 0 ? void 0 : toToken.address,
60
62
  toAddress,
61
63
  slippage,
62
64
  enabledBridges,
63
65
  enabledExchanges,
64
66
  routePriority,
67
+ variant,
65
68
  ];
66
69
  const previousDataUpdatedAt = (_a = queryClient.getQueryState(queryKey)) === null || _a === void 0 ? void 0 : _a.dataUpdatedAt;
67
70
  const refetchInterval = previousDataUpdatedAt
68
71
  ? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
69
72
  : refetchTime;
70
- const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress, toAddress, slippage, enabledBridges, enabledExchanges, routePriority,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
73
+ const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress, toAddress, slippage, enabledBridges, enabledExchanges, routePriority, variant,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
71
74
  var _b, _c;
72
75
  let toWalletAddress;
73
76
  try {
@@ -77,7 +80,7 @@ const useSwapRoutes = () => {
77
80
  catch (_d) {
78
81
  toWalletAddress = (0, address_1.isAddress)(toAddress) ? toAddress : fromAddress;
79
82
  }
80
- const fromAmount = (0, big_js_1.default)(Number(fromTokenAmount) * Math.pow(10, ((_c = token === null || token === void 0 ? void 0 : token.decimals) !== null && _c !== void 0 ? _c : 0))).toString();
83
+ const fromAmount = (0, big_js_1.default)(Number(fromTokenAmount) * Math.pow(10, ((_c = fromToken === null || fromToken === void 0 ? void 0 : fromToken.decimals) !== null && _c !== void 0 ? _c : 0))).toString();
81
84
  const formattedSlippage = parseFloat(slippage) / 100;
82
85
  return lifi.getRoutes({
83
86
  fromChainId,
@@ -96,6 +99,7 @@ const useSwapRoutes = () => {
96
99
  allow: enabledExchanges,
97
100
  },
98
101
  order: routePriority,
102
+ allowSwitchChain: variant !== 'refuel',
99
103
  },
100
104
  }, { signal });
101
105
  }), {
@@ -0,0 +1,199 @@
1
+ {
2
+ "button": {
3
+ "auto": "Auto",
4
+ "cancel": "Absagen",
5
+ "connectWallet": "Brieftasche verbinden",
6
+ "contactSupport": "Kontaktieren Sie Support",
7
+ "continue": "Fortsetzen",
8
+ "copyAddress": "Adresse kopieren",
9
+ "dark": "Dunkel",
10
+ "delete": "Löschen",
11
+ "disconnectWallet": "Wallet trennen",
12
+ "done": "Fertig",
13
+ "hide": "Ausblenden",
14
+ "lifiSwap": "LI.FI Tausch",
15
+ "light": "Licht",
16
+ "max": "max",
17
+ "ok": "OK",
18
+ "okay": "Okay",
19
+ "removeSwap": "Austausch entfernen",
20
+ "restartSwap": "Swap neu starten",
21
+ "reviewSwap": "Bewertungstausch",
22
+ "seeDetails": "Siehe Einzelheiten",
23
+ "showAll": "Zeige alles",
24
+ "startSwap": "Tausch starten",
25
+ "swap": "Tausch",
26
+ "tryAgain": "Versuchen Sie es nochmal"
27
+ },
28
+ "format": {
29
+ "currency": "{{value, currency(currency: USD)}}",
30
+ "number": "{{value, number(maximumFractionDigits: 4)}}"
31
+ },
32
+ "header": {
33
+ "activeSwaps": "Aktive Swaps",
34
+ "from": "Abtauschen",
35
+ "routes": "Du erhältst",
36
+ "selectChain": "Kette auswählen",
37
+ "selectWallet": "Wählen Sie Ihre Geldbörse aus",
38
+ "settings": "Einstellungen",
39
+ "swap": "Tausch",
40
+ "swapDetails": "Details tauschen",
41
+ "swapHistory": "Historie tauschen",
42
+ "to": "Wechseln zu",
43
+ "walletConnected": "Brieftasche verbunden"
44
+ },
45
+ "language": {
46
+ "name": "Deutsch",
47
+ "title": "Sprache"
48
+ },
49
+ "settings": {
50
+ "advancedPreferences": "Erweiterte Einstellungen",
51
+ "enabledBridges": "Aktivierte Brücken",
52
+ "enabledExchanges": "Aktivierter Austausch",
53
+ "gasPrice": {
54
+ "fast": "Schnell",
55
+ "normal": "Normal",
56
+ "slow": "Langsam",
57
+ "title": "Gaspreis"
58
+ },
59
+ "resetToDefault": "Zurücksetzen",
60
+ "routePriority": "Routenpriorität",
61
+ "selectEnabledBridges": "Wählen Sie aktivierte Bridges aus",
62
+ "selectEnabledExchanges": "Wählen Sie aktivierte Börsen aus",
63
+ "showDestinationWallet": "Zielgeldbörse anzeigen",
64
+ "slippage": "Abweichung"
65
+ },
66
+ "swap": {
67
+ "crossStepDetails": "Brücke von {{from}} nach {{to}} über {{tool}}",
68
+ "error": {
69
+ "message": {
70
+ "slippageTooLarge": "Der Schlupf ist größer als der definierte Schwellenwert. Bitte fordern Sie eine neue Route an, um ein neues Angebot zu erhalten.",
71
+ "transactionFailed": "Weitere Informationen finden Sie im Block-Explorer.",
72
+ "transactionNotSent": "Die Transaktion wurde nicht gesendet, Ihr Geld befindet sich noch in Ihrer Brieftasche ({{amount, number(maximumFractionDigits: 4)}} {{tokenSymbol}} auf {{chainName}}).",
73
+ "transactionRejected": "Ihre Unterschrift ist erforderlich, um die Transaktion abzuschließen. {{amount, number(maximumFractionDigits: 4)}} {{tokenSymbol}} auf {{chainName}} verbleiben in Ihrem Wallet."
74
+ },
75
+ "title": {
76
+ "chainSwitch": "Kettenschalter erforderlich.",
77
+ "failed": "Austausch fehlgeschlagen.",
78
+ "slippageTooLarge": "Schlupf zu groß.",
79
+ "transactionFailed": "Transaktion ist fehlgeschlagen.",
80
+ "transactionRejected": "Signatur benötigt.",
81
+ "transactionUnderpriced": "Transaktion ist unterbewertet.",
82
+ "transactionUnprepared": "Transaktion kann nicht vorbereitet werden.",
83
+ "unknown": "Etwas ist schief gelaufen.",
84
+ "walletAddressInvalid": "Wallet-Adresse ist ungültig.",
85
+ "walletEnsAddressInvalid": "Die Wallet-Adresse ist ungültig oder das Netzwerk unterstützt ENS nicht."
86
+ }
87
+ },
88
+ "estimatedTime": "{{value}} m",
89
+ "featuredTokens": "Ausgewählte Token",
90
+ "from": "Aus",
91
+ "fromAmount": "Sie bezahlen",
92
+ "gasCost": "Gaskosten",
93
+ "inProgress": "im Gange",
94
+ "info": {
95
+ "message": {
96
+ "emptyActiveSwaps": "Laufende Swaps werden hier angezeigt. Sobald Sie fertig sind, finden Sie sie im Swap-Verlauf.",
97
+ "emptySwapHistory": "Der Swap-Verlauf wird nur lokal gespeichert und gelöscht, wenn Sie Ihre Browserdaten löschen.",
98
+ "emptyTokenList": "Wir konnten keine Tokens in der Kette {{chainName}} finden oder Sie haben keine. Bitte versuchen Sie die Suche erneut oder wählen Sie eine andere Kette.",
99
+ "routeNotFound": "Probieren Sie eine andere Token-Kombination aus."
100
+ },
101
+ "title": {
102
+ "emptyActiveSwaps": "Keine aktiven Swaps",
103
+ "emptySwapHistory": "Keine kürzlichen Swaps",
104
+ "routeNotFound": "Keine Routen verfügbar"
105
+ }
106
+ },
107
+ "otherTokens": "Andere Token",
108
+ "process": {
109
+ "crossChain": {
110
+ "actionRequired": "Bitte signieren Sie die Transaktion.",
111
+ "done": "Transaktion genehmigt.",
112
+ "pending": "Warten auf Transaktion.",
113
+ "started": "Transaktion vorbereiten."
114
+ },
115
+ "receivingChain": {
116
+ "done": "Erhaltene Mittel.",
117
+ "pending": "Warten auf Empfänger-Chain."
118
+ },
119
+ "swap": {
120
+ "actionRequired": "Bitte signieren Sie die Transaktion.",
121
+ "done": "Austausch abgeschlossen.",
122
+ "pending": "Austauschen.",
123
+ "started": "Austausch vorbereiten."
124
+ },
125
+ "switchChain": {
126
+ "actionRequired": "Kettenschalter erforderlich.",
127
+ "done": "Chain erfolgreich gewechselt."
128
+ },
129
+ "tokenAllowance": {
130
+ "done": "Token-Zulassung genehmigt.",
131
+ "pending": "Warten auf Token-Genehmigung.",
132
+ "started": "Token-Freigabe festlegen."
133
+ }
134
+ },
135
+ "receiving": "Empfang",
136
+ "routes": "Du erhältst",
137
+ "selectChain": "Chain",
138
+ "selectChainAndToken": "Kette und Token auswählen",
139
+ "selectToken": "Token",
140
+ "sendToWallet": "An eine andere Brieftasche senden",
141
+ "stepBridge": "Brücke",
142
+ "stepSwap": "Tausch",
143
+ "stepSwapAndBridge": "Tauschen und überbrücken",
144
+ "success": {
145
+ "message": {
146
+ "swapSuccessful": "Es sind jetzt {{amount, number(maximumFractionDigits: 4)}} {{tokenSymbol}} in wallet {{walletAddress}} auf chain {{chainName}}."
147
+ },
148
+ "title": {
149
+ "swapSuccessful": "Tausch erfolgreich"
150
+ }
151
+ },
152
+ "supportId": "Support-ID",
153
+ "swapStepDetails": "Tausche auf {{chain}} über {{tool}}",
154
+ "swapping": "Austauschen",
155
+ "tags": {
156
+ "ALTERNATIVE": "ALTERNATIVE",
157
+ "CHEAPEST": "BILLIG",
158
+ "FASTEST": "SCHNELL",
159
+ "RECOMMENDED": "EMPFOHLEN",
160
+ "SAFEST": "SICHER"
161
+ },
162
+ "to": "Zu",
163
+ "tokenOnChain": "{{tokenSymbol}} auf {{chainName}}",
164
+ "tokenOnChainAmount": "{{amount, number(maximumFractionDigits: 4)}} {{tokenSymbol}} auf {{chainName}}",
165
+ "tokenSearch": "Suchen Sie Ihr Token",
166
+ "valueLoss": "Wertverlust",
167
+ "walletAddressOrEns": "Wallet-Adresse oder ENS-Name",
168
+ "warning": {
169
+ "message": {
170
+ "deleteActiveSwaps": "Aktive Swaps werden nur lokal gespeichert und können nicht wiederhergestellt werden, wenn Sie sie löschen.",
171
+ "deleteSwapHistory": "Der Swap-Verlauf wird nur lokal gespeichert und kann nicht wiederhergestellt werden, wenn Sie ihn löschen.",
172
+ "highValueLoss": "Der Wert der erhaltenen Token ist deutlich niedriger als die getauschten Token und die Transaktionskosten.",
173
+ "insufficientFunds": "Sie haben nicht genug Geld, um den Tausch durchzuführen.",
174
+ "insufficientGas": "Sie müssen mindestens hinzufügen:"
175
+ },
176
+ "title": {
177
+ "deleteActiveSwaps": "Alle aktiven Swaps löschen?",
178
+ "deleteSwap": "Diesen Tausch löschen?",
179
+ "deleteSwapHistory": "Swap-Verlauf löschen?",
180
+ "highValueLoss": "Hoher Wertverlust",
181
+ "insufficientGas": "Unzureichendes Gas"
182
+ }
183
+ }
184
+ },
185
+ "tooltip": {
186
+ "estimatedNetworkFee": "Geschätzte Netzwerkgebühr.",
187
+ "estimatedTime": "Geschätzte Tausch-Ausführungszeit in Minuten.",
188
+ "notFound": {
189
+ "text": "Wir konnten diese Seite nicht finden.",
190
+ "title": "404"
191
+ },
192
+ "numberOfSteps": "Eine Anzahl von Tausch-Schritten. Jeder Schritt kann 2 Transaktionen enthalten, die eine Unterschrift erfordern.",
193
+ "progressToNextUpdate": "Angezeigte Daten werden nach {{value}} Sekunden automatisch aktualisiert. Klicken Sie hier, um manuell zu aktualisieren.",
194
+ "settingsModified": "Einstellungen (geändert)"
195
+ },
196
+ "wallet": {
197
+ "extensionNotFound": "Bitte stellen Sie sicher, dass nur die Browsererweiterung {{name}} aktiv ist, bevor Sie dieses Wallet auswählen."
198
+ }
199
+ }