@lifi/widget 1.18.8 → 1.18.9

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 (36) hide show
  1. package/cjs/components/SwapRouteCard/SwapRouteCard.js +6 -3
  2. package/cjs/components/SwapRoutes/SwapRoutes.style.d.ts +14 -14
  3. package/cjs/components/SwapRoutes/SwapRoutes.style.js +13 -13
  4. package/cjs/components/SwapRoutes/SwapRoutesExpanded.js +1 -1
  5. package/cjs/components/Token/Token.js +5 -5
  6. package/cjs/components/Token/Token.style.d.ts +10 -0
  7. package/cjs/components/Token/Token.style.js +13 -7
  8. package/cjs/components/TokenList/TokenList.js +1 -1
  9. package/cjs/config/version.d.ts +1 -1
  10. package/cjs/config/version.js +1 -1
  11. package/cjs/hooks/useToken.js +5 -2
  12. package/cjs/hooks/useTokenBalance.js +15 -10
  13. package/cjs/hooks/useTokenSearch.d.ts +1 -3
  14. package/cjs/hooks/useTokenSearch.js +3 -5
  15. package/cjs/i18n/en/translation.json +1 -1
  16. package/cjs/stores/routes/useRouteExecutionStore.js +1 -0
  17. package/cjs/stores/settings/useSettingsStore.js +5 -2
  18. package/components/SwapRouteCard/SwapRouteCard.js +6 -3
  19. package/components/SwapRoutes/SwapRoutes.style.d.ts +14 -14
  20. package/components/SwapRoutes/SwapRoutes.style.js +13 -13
  21. package/components/SwapRoutes/SwapRoutesExpanded.js +1 -1
  22. package/components/Token/Token.js +7 -7
  23. package/components/Token/Token.style.d.ts +10 -0
  24. package/components/Token/Token.style.js +12 -6
  25. package/components/TokenList/TokenList.js +1 -1
  26. package/config/version.d.ts +1 -1
  27. package/config/version.js +1 -1
  28. package/hooks/useToken.js +5 -2
  29. package/hooks/useTokenBalance.js +15 -10
  30. package/hooks/useTokenSearch.d.ts +1 -3
  31. package/hooks/useTokenSearch.js +3 -5
  32. package/i18n/en/translation.json +1 -1
  33. package/package.json +5 -5
  34. package/stores/routes/useRouteExecutionStore.js +1 -0
  35. package/stores/settings/useSettingsStore.js +5 -2
  36. package/tsconfig.cjs.tsbuildinfo +1 -1
@@ -1,4 +1,14 @@
1
1
  /// <reference types="react" />
2
+ export declare const TextSecondaryContainer: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
3
+ children?: import("react").ReactNode;
4
+ component?: import("react").ElementType<any> | undefined;
5
+ ref?: import("react").Ref<unknown> | undefined;
6
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
7
+ } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
8
+ ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
9
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "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> & {
10
+ connected?: boolean | undefined;
11
+ }, {}, {}>;
2
12
  export declare const TextSecondary: import("@emotion/styled").StyledComponent<import("@mui/system").SystemProps<import("@mui/material").Theme> & {
3
13
  align?: "inherit" | "left" | "right" | "center" | "justify" | undefined;
4
14
  children?: import("react").ReactNode;
@@ -1,12 +1,8 @@
1
1
  import { Box, Typography } from '@mui/material';
2
2
  import { styled } from '@mui/material/styles';
3
- export const TextSecondary = styled(Typography, {
3
+ export const TextSecondaryContainer = styled(Box, {
4
4
  shouldForwardProp: (prop) => prop !== 'connected',
5
5
  })(({ theme, connected }) => ({
6
- fontSize: 12,
7
- lineHeight: 1,
8
- fontWeight: 500,
9
- color: theme.palette.text.secondary,
10
6
  borderLeftWidth: connected ? 2 : 0,
11
7
  borderLeftStyle: 'solid',
12
8
  borderColor: theme.palette.mode === 'light'
@@ -14,12 +10,22 @@ export const TextSecondary = styled(Typography, {
14
10
  : theme.palette.grey[800],
15
11
  margin: connected
16
12
  ? theme.spacing(0.5, 0, 0, 1.875)
17
- : theme.spacing(0.5, 0, 0, 6),
13
+ : theme.spacing(0, 0, 0, 6),
18
14
  padding: connected
19
15
  ? theme.spacing(0, 0, 0, 3.875)
20
16
  : theme.spacing(0, 0, 0, 0),
21
17
  display: 'flex',
22
18
  alignItems: 'flex-start',
19
+ flexWrap: 'wrap',
20
+ }));
21
+ export const TextSecondary = styled(Typography, {
22
+ shouldForwardProp: (prop) => prop !== 'connected',
23
+ })(({ theme, connected }) => ({
24
+ fontSize: 12,
25
+ lineHeight: 1,
26
+ fontWeight: 500,
27
+ color: theme.palette.text.secondary,
28
+ marginTop: connected ? 0 : theme.spacing(0.5),
23
29
  }));
24
30
  export const TokenDivider = styled(Box)(({ theme }) => ({
25
31
  height: 12,
@@ -27,7 +27,7 @@ export const TokenList = ({ formType, height, onClick, }) => {
27
27
  !filteredTokens.length &&
28
28
  !!tokenSearchFilter &&
29
29
  !!selectedChainId;
30
- const { token: searchedToken, isLoading: isSearchedTokenLoading } = useTokenSearch(tokenSearchFilter, selectedChainId, tokenSearchEnabled);
30
+ const { token: searchedToken, isLoading: isSearchedTokenLoading } = useTokenSearch(selectedChainId, tokenSearchFilter, tokenSearchEnabled);
31
31
  const isLoading = isTokensLoading || (tokenSearchEnabled && isSearchedTokenLoading);
32
32
  const tokens = filteredTokens.length
33
33
  ? filteredTokens
@@ -1,2 +1,2 @@
1
1
  export declare const name = "@lifi/widget";
2
- export declare const version = "1.18.8";
2
+ export declare const version = "1.18.9";
package/config/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/widget';
2
- export const version = '1.18.8';
2
+ export const version = '1.18.9';
package/hooks/useToken.js CHANGED
@@ -1,13 +1,16 @@
1
1
  import { useMemo } from 'react';
2
2
  import { useTokens } from './useTokens';
3
+ import { useTokenSearch } from './useTokenSearch';
3
4
  export const useToken = (chainId, tokenAddress) => {
4
5
  const { tokens, isLoading } = useTokens(chainId);
5
6
  const token = useMemo(() => {
6
7
  const token = tokens === null || tokens === void 0 ? void 0 : tokens.find((token) => token.address === tokenAddress && token.chainId === chainId);
7
8
  return token;
8
9
  }, [chainId, tokenAddress, tokens]);
10
+ const tokenSearchEnabled = !isLoading && !token;
11
+ const { token: searchedToken, isLoading: isSearchedTokenLoading } = useTokenSearch(chainId, tokenAddress, tokenSearchEnabled);
9
12
  return {
10
- token,
11
- isLoading,
13
+ token: token !== null && token !== void 0 ? token : searchedToken,
14
+ isLoading: isLoading || (tokenSearchEnabled && isSearchedTokenLoading),
12
15
  };
13
16
  };
@@ -18,18 +18,23 @@ export const useTokenBalance = (token, accountAddress) => {
18
18
  const queryClient = useQueryClient();
19
19
  const walletAddress = accountAddress !== null && accountAddress !== void 0 ? accountAddress : account.address;
20
20
  const getTokenBalancesWithRetry = useCallback((accountAddress, tokens, depth = 0) => __awaiter(void 0, void 0, void 0, function* () {
21
- const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
22
- if (!tokenBalances.every((token) => token.blockNumber)) {
23
- if (depth > 5) {
24
- console.warn('Token balance backoff depth exceeded.');
25
- return undefined;
21
+ try {
22
+ const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
23
+ if (!tokenBalances.every((token) => token.blockNumber)) {
24
+ if (depth > 5) {
25
+ console.warn('Token balance backoff depth exceeded.');
26
+ return undefined;
27
+ }
28
+ yield new Promise((resolve) => {
29
+ setTimeout(resolve, depth * 100);
30
+ });
31
+ return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
26
32
  }
27
- yield new Promise((resolve) => {
28
- setTimeout(resolve, depth * 100);
29
- });
30
- return getTokenBalancesWithRetry(accountAddress, tokens, depth + 1);
33
+ return tokenBalances;
34
+ }
35
+ catch (error) {
36
+ //
31
37
  }
32
- return tokenBalances;
33
38
  }), [lifi]);
34
39
  const tokenBalanceQueryKey = useMemo(() => ['token-balance', walletAddress, token === null || token === void 0 ? void 0 : token.chainId, token === null || token === void 0 ? void 0 : token.address], [token === null || token === void 0 ? void 0 : token.address, token === null || token === void 0 ? void 0 : token.chainId, walletAddress]);
35
40
  const { data, isLoading, refetch } = useQuery(tokenBalanceQueryKey, ({ queryKey: [, accountAddress] }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -1,7 +1,5 @@
1
1
  import type { Token } from '../types';
2
- export declare const useTokenSearch: (token: string, chainId: number, enabled?: boolean) => {
2
+ export declare const useTokenSearch: (chainId: number, token: string, enabled?: boolean) => {
3
3
  token: Token | undefined;
4
4
  isLoading: boolean;
5
- isFetching: boolean;
6
- isFetched: boolean;
7
5
  };
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { useQuery, useQueryClient } from '@tanstack/react-query';
11
11
  import { useLiFi } from '../providers';
12
- export const useTokenSearch = (token, chainId, enabled) => {
12
+ export const useTokenSearch = (chainId, token, enabled) => {
13
13
  const lifi = useLiFi();
14
14
  const queryClient = useQueryClient();
15
- const { data, isLoading, isFetching, isFetched } = useQuery(['token-search', chainId, token], ({ queryKey: [, chainId, token], signal }) => __awaiter(void 0, void 0, void 0, function* () {
15
+ const { data, isLoading } = useQuery(['token-search', chainId, token], ({ queryKey: [, chainId, token], signal }) => __awaiter(void 0, void 0, void 0, function* () {
16
16
  const data = yield lifi.getToken(chainId, token, {
17
17
  signal,
18
18
  });
@@ -26,13 +26,11 @@ export const useTokenSearch = (token, chainId, enabled) => {
26
26
  }
27
27
  return data;
28
28
  }), {
29
- enabled,
29
+ enabled: Boolean(chainId && token && enabled),
30
30
  retry: false,
31
31
  });
32
32
  return {
33
33
  token: data,
34
34
  isLoading,
35
- isFetching,
36
- isFetched,
37
35
  };
38
36
  };
@@ -58,7 +58,7 @@
58
58
  "stepSwap": "Swap",
59
59
  "stepBridge": "Bridge",
60
60
  "stepSwapAndBridge": "Swap and bridge",
61
- "estimatedTime": "~{{value}} min.",
61
+ "estimatedTime": "{{value}}m",
62
62
  "crossStepDetails": "Bridge from {{from}} to {{to}} via {{tool}}",
63
63
  "swapStepDetails": "Swap on {{chain}} via {{tool}}",
64
64
  "tokenOnChain": "{{tokenSymbol}} on {{chainName}}",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.18.8",
3
+ "version": "1.18.9",
4
4
  "description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./index.js",
@@ -47,10 +47,10 @@
47
47
  "@mui/icons-material": "^5.10.6",
48
48
  "@mui/lab": "^5.0.0-alpha.101",
49
49
  "@mui/material": "^5.10.7",
50
- "@sentry/integrations": "^7.13.0",
51
- "@sentry/react": "^7.13.0",
52
- "@sentry/tracing": "^7.13.0",
53
- "@tanstack/react-query": "^4.7.1",
50
+ "@sentry/integrations": "^7.14.0",
51
+ "@sentry/react": "^7.14.0",
52
+ "@sentry/tracing": "^7.14.0",
53
+ "@tanstack/react-query": "^4.8.0",
54
54
  "@tanstack/react-virtual": "^3.0.0-beta.18",
55
55
  "big.js": "^6.2.1",
56
56
  "i18next": "^21.9.2",
@@ -79,6 +79,7 @@ export const useRouteExecutionStore = create()(persist(immer((set) => ({
79
79
  }
80
80
  });
81
81
  }
82
+ localStorage.removeItem('routes');
82
83
  }
83
84
  catch (error) {
84
85
  console.log(error);
@@ -20,7 +20,7 @@ export const useSettingsStore = create()(persist(immer((set) => ({
20
20
  appearance: 'auto',
21
21
  gasPrice: 'normal',
22
22
  routePriority: 'RECOMMENDED',
23
- slippage: '3',
23
+ slippage: '0.5',
24
24
  setValue: (key, value) => set((state) => {
25
25
  state[key] = value;
26
26
  }),
@@ -65,7 +65,7 @@ export const useSettingsStore = create()(persist(immer((set) => ({
65
65
  }),
66
66
  })), {
67
67
  name: 'li.fi-widget-settings',
68
- version: 1,
68
+ version: 2,
69
69
  partialize: (state) => {
70
70
  const { enabledBridges, enabledExchanges } = state, partializedState = __rest(state, ["enabledBridges", "enabledExchanges"]);
71
71
  return partializedState;
@@ -83,6 +83,9 @@ export const useSettingsStore = create()(persist(immer((set) => ({
83
83
  if (version === 0 && persistedState.appearance === 'system') {
84
84
  persistedState.appearance = 'auto';
85
85
  }
86
+ if (version === 1) {
87
+ persistedState.slippage = '0.5';
88
+ }
86
89
  return persistedState;
87
90
  },
88
91
  }));