@lifi/widget 1.6.1 → 1.8.1

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 (73) hide show
  1. package/App.js +2 -1
  2. package/LICENSE.md +201 -21
  3. package/components/AppContainer.js +2 -2
  4. package/components/Header/Header.js +1 -1
  5. package/components/Header/NavigationHeader.js +1 -1
  6. package/components/InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.d.ts +3 -0
  7. package/components/InsufficientGasOrFundsMessage/InsufficientGasOrFundsMessage.js +31 -0
  8. package/{pages/MainPage → components/InsufficientGasOrFundsMessage}/InsufficientGasOrFundsMessage.style.d.ts +0 -0
  9. package/{pages/MainPage → components/InsufficientGasOrFundsMessage}/InsufficientGasOrFundsMessage.style.js +3 -2
  10. package/components/InsufficientGasOrFundsMessage/index.d.ts +1 -0
  11. package/components/InsufficientGasOrFundsMessage/index.js +1 -0
  12. package/components/NotFound.d.ts +2 -0
  13. package/components/NotFound.js +14 -0
  14. package/components/StepActions/StepActions.d.ts +1 -1
  15. package/components/StepActions/types.d.ts +1 -1
  16. package/components/StepToken.d.ts +1 -1
  17. package/components/SwapButton/ButtonTooltip.d.ts +1 -0
  18. package/components/SwapButton/SwapButton.js +3 -3
  19. package/components/SwapButton/SwapButton.style.d.ts +2 -2
  20. package/components/SwapButton/SwapButton.style.js +0 -4
  21. package/components/SwapInput/SwapInputAdornment.d.ts +1 -0
  22. package/components/SwapRouteCard/types.d.ts +1 -1
  23. package/components/TokenList/types.d.ts +1 -1
  24. package/components/TokenList/utils.d.ts +2 -2
  25. package/config/theme.js +17 -2
  26. package/config/version.d.ts +1 -1
  27. package/config/version.js +1 -1
  28. package/hooks/useChain.d.ts +1 -1
  29. package/hooks/useChains.d.ts +12 -12
  30. package/hooks/useHasSufficientBalance.d.ts +1 -1
  31. package/hooks/useHasSufficientBalance.js +27 -22
  32. package/hooks/useRouteExecution.d.ts +1 -1
  33. package/hooks/useSwapRoutes.d.ts +2 -2
  34. package/hooks/useSwapRoutes.js +2 -2
  35. package/hooks/useToken.d.ts +1 -1
  36. package/hooks/useTokenBalance.d.ts +1 -1
  37. package/hooks/useTokenBalances.d.ts +1 -1
  38. package/hooks/useTokens.d.ts +1 -1
  39. package/hooks/useTools.d.ts +1 -1
  40. package/i18n/en/translation.json +9 -7
  41. package/i18n/index.d.ts +5 -3
  42. package/lifi.d.ts +1 -1
  43. package/lifi.js +1 -1
  44. package/package.json +10 -10
  45. package/pages/MainPage/MainPage.js +2 -2
  46. package/pages/MainPage/MainPage.style.d.ts +1 -1
  47. package/pages/MainPage/MainPage.style.js +1 -1
  48. package/pages/SelectTokenPage/ChainSelect.d.ts +1 -0
  49. package/pages/SelectTokenPage/SearchTokenInput.d.ts +1 -0
  50. package/pages/SelectWalletPage/SelectWalletPage.d.ts +1 -0
  51. package/pages/SettingsPage/AdvancedPreferences.d.ts +1 -0
  52. package/pages/SettingsPage/GasPriceSelect.d.ts +1 -0
  53. package/pages/SettingsPage/RoutePrioritySelect.js +1 -1
  54. package/pages/SettingsPage/SettingsPage.d.ts +1 -0
  55. package/pages/SettingsPage/SlippageInput.d.ts +1 -0
  56. package/pages/SwapPage/CircularProgress.d.ts +2 -1
  57. package/pages/SwapPage/CircularProgress.style.d.ts +1 -1
  58. package/pages/SwapPage/ExecutionItem.d.ts +1 -1
  59. package/pages/SwapPage/StepItem.d.ts +1 -1
  60. package/pages/SwapPage/StepTimer.d.ts +1 -1
  61. package/pages/SwapPage/SwapPage.js +5 -2
  62. package/pages/SwapPage/utils.d.ts +1 -1
  63. package/pages/SwapPage/utils.js +1 -1
  64. package/providers/WalletProvider/types.d.ts +1 -1
  65. package/providers/WidgetProvider/WidgetProvider.js +1 -1
  66. package/stores/route/types.d.ts +1 -1
  67. package/stores/route/useCurrentRoute.d.ts +1 -1
  68. package/stores/route/useSetExecutableRoute.d.ts +1 -1
  69. package/stores/settings/types.d.ts +1 -1
  70. package/stores/settings/useSettingsStore.d.ts +1 -1
  71. package/types/widget.d.ts +1 -1
  72. package/pages/MainPage/InsufficientGasOrFundsMessage.d.ts +0 -2
  73. package/pages/MainPage/InsufficientGasOrFundsMessage.js +0 -28
@@ -1,58 +1,63 @@
1
- import { isSwapStep } from '@lifinance/sdk';
1
+ import { isSwapStep } from '@lifi/sdk';
2
2
  import Big from 'big.js';
3
3
  import { useMemo } from 'react';
4
4
  import { useWatch } from 'react-hook-form';
5
- import { SwapFormKeyHelper } from '../providers/SwapFormProvider';
5
+ import { useDebouncedWatch } from '.';
6
+ import { SwapFormKey, SwapFormKeyHelper } from '../providers/SwapFormProvider';
6
7
  import { useCurrentRoute } from '../stores';
7
8
  import { useTokenBalances } from './useTokenBalances';
8
9
  export const useHasSufficientBalance = () => {
9
10
  var _a;
10
11
  const [route] = useCurrentRoute();
11
- const [fromChainId, toChainId] = useWatch({
12
+ const [fromChainId, toChainId, fromToken] = useWatch({
12
13
  name: [
13
14
  SwapFormKeyHelper.getChainKey('from'),
14
15
  SwapFormKeyHelper.getChainKey('to'),
16
+ SwapFormKey.FromToken,
15
17
  ],
16
18
  });
19
+ const fromAmount = useDebouncedWatch(SwapFormKey.FromAmount, 250);
17
20
  const lastStep = route === null || route === void 0 ? void 0 : route.steps.at(-1);
18
21
  const { tokens: fromChainTokenBalances } = useTokenBalances(fromChainId);
19
22
  const { tokens: toChainTokenBalances } = useTokenBalances((_a = lastStep === null || lastStep === void 0 ? void 0 : lastStep.action.fromChainId) !== null && _a !== void 0 ? _a : toChainId);
20
- const hasGasBalanceOnStartChain = useMemo(() => {
21
- var _a, _b, _c;
22
- const token = (_a = route === null || route === void 0 ? void 0 : route.steps[0].estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].token;
23
- if (!token) {
23
+ const hasGasOnStartChain = useMemo(() => {
24
+ var _a, _b, _c, _d, _e;
25
+ const gasToken = (_a = route === null || route === void 0 ? void 0 : route.steps[0].estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].token;
26
+ if (!gasToken) {
24
27
  return true;
25
28
  }
26
- const balance = Big((_c = (_b = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === token.address)) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0);
27
- const requiredAmount = route.steps
29
+ const gasTokenBalance = Big((_c = (_b = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === gasToken.address)) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0);
30
+ let requiredAmount = route.steps
28
31
  .filter((step) => step.action.fromChainId === route.fromChainId)
29
32
  .reduce((big, step) => { var _a; return big.plus(Big(((_a = step.estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].amount) || 0)); }, Big(0))
30
- .div(Math.pow(10, token.decimals));
31
- return balance.gt(0) && balance.gte(requiredAmount);
33
+ .div(Math.pow(10, gasToken.decimals));
34
+ if (route.fromToken.address === gasToken.address) {
35
+ const tokenBalance = Big((_e = (_d = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === route.fromToken.address)) === null || _d === void 0 ? void 0 : _d.amount) !== null && _e !== void 0 ? _e : 0);
36
+ requiredAmount = requiredAmount.plus(tokenBalance);
37
+ }
38
+ return gasTokenBalance.gt(0) && gasTokenBalance.gte(requiredAmount);
32
39
  }, [fromChainTokenBalances, route]);
33
40
  const hasGasOnCrossChain = useMemo(() => {
34
41
  var _a, _b, _c, _d, _e, _f;
35
- const token = (_a = lastStep === null || lastStep === void 0 ? void 0 : lastStep.estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].token;
36
- if (!token || !isSwapStep(lastStep)) {
42
+ const gasToken = (_a = lastStep === null || lastStep === void 0 ? void 0 : lastStep.estimate.gasCosts) === null || _a === void 0 ? void 0 : _a[0].token;
43
+ if (!gasToken || !isSwapStep(lastStep)) {
37
44
  return true;
38
45
  }
39
- const balance = Big((_c = (_b = toChainTokenBalances === null || toChainTokenBalances === void 0 ? void 0 : toChainTokenBalances.find((t) => t.address === token.address)) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0);
46
+ const balance = Big((_c = (_b = toChainTokenBalances === null || toChainTokenBalances === void 0 ? void 0 : toChainTokenBalances.find((t) => t.address === gasToken.address)) === null || _b === void 0 ? void 0 : _b.amount) !== null && _c !== void 0 ? _c : 0);
40
47
  const gasEstimate = (_d = lastStep.estimate.gasCosts) === null || _d === void 0 ? void 0 : _d[0].amount;
41
48
  const requiredAmount = Big(gasEstimate || 0).div(Math.pow(10, ((_f = (_e = lastStep.estimate.gasCosts) === null || _e === void 0 ? void 0 : _e[0].token.decimals) !== null && _f !== void 0 ? _f : 0)));
42
49
  return balance.gt(0) && balance.gte(requiredAmount);
43
50
  }, [lastStep, toChainTokenBalances]);
44
51
  const hasSufficientBalance = useMemo(() => {
45
- var _a, _b, _c;
46
- if (!route) {
52
+ var _a, _b;
53
+ if (!fromToken || !fromAmount) {
47
54
  return true;
48
55
  }
49
- const balance = Big((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === route.fromToken.address)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
50
- return Big(route.fromAmount)
51
- .div(Math.pow(10, ((_c = route.fromToken.decimals) !== null && _c !== void 0 ? _c : 0)))
52
- .lte(balance);
53
- }, [fromChainTokenBalances, route]);
56
+ const balance = Big((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === fromToken)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
57
+ return Big(fromAmount).lte(balance);
58
+ }, [fromAmount, fromChainTokenBalances, fromToken]);
54
59
  return {
55
- hasGasBalanceOnStartChain,
60
+ hasGasOnStartChain,
56
61
  hasGasOnCrossChain,
57
62
  hasSufficientBalance,
58
63
  };
@@ -1,4 +1,4 @@
1
- import { Route } from '@lifinance/sdk';
1
+ import { Route } from '@lifi/sdk';
2
2
  export declare const useRouteExecution: (routeId: string) => {
3
3
  executeRoute: () => void;
4
4
  restartRoute: () => void;
@@ -1,8 +1,8 @@
1
1
  export declare const useSwapRoutes: () => {
2
- routes: import("@lifinance/types").Route[] | undefined;
2
+ routes: import("@lifi/types").Route[] | undefined;
3
3
  isLoading: boolean;
4
4
  isFetching: boolean;
5
5
  dataUpdatedAt: number;
6
6
  refetchTime: number;
7
- refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("@lifinance/types").RoutesResponse, unknown>>;
7
+ refetch: <TPageData>(options?: (import("react-query").RefetchOptions & import("react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("react-query").QueryObserverResult<import("@lifi/types").RoutesResponse, unknown>>;
8
8
  };
@@ -97,10 +97,10 @@ export const useSwapRoutes = () => {
97
97
  const isCurrentRouteInSet = data === null || data === void 0 ? void 0 : data.routes.some((route) => route.id === (currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.id));
98
98
  const recommendedRoute = data === null || data === void 0 ? void 0 : data.routes[0];
99
99
  // we don't want to set the current route again if it's already selected from existing routes
100
- if (!isCurrentRouteInSet && recommendedRoute) {
100
+ if (!isCurrentRouteInSet && currentRoute !== recommendedRoute) {
101
101
  setCurrentRoute(recommendedRoute);
102
102
  }
103
- }, [currentRoute === null || currentRoute === void 0 ? void 0 : currentRoute.id, data === null || data === void 0 ? void 0 : data.routes, setCurrentRoute]);
103
+ }, [currentRoute, data === null || data === void 0 ? void 0 : data.routes, setCurrentRoute]);
104
104
  return {
105
105
  routes: data === null || data === void 0 ? void 0 : data.routes,
106
106
  isLoading: isEnabled && isLoading,
@@ -1,4 +1,4 @@
1
1
  export declare const useToken: (chainId: number, tokenAddress: string) => {
2
- token: import("@lifinance/types").Token | undefined;
2
+ token: import("@lifi/types").Token | undefined;
3
3
  isLoading: boolean;
4
4
  };
@@ -1,4 +1,4 @@
1
- import { TokenAmount } from '@lifinance/sdk';
1
+ import { TokenAmount } from '@lifi/sdk';
2
2
  export declare const useTokenBalance: (chainId: number, tokenAddress: string) => {
3
3
  token: TokenAmount | undefined;
4
4
  isLoading: boolean;
@@ -1,4 +1,4 @@
1
- import { TokenAmount } from '@lifinance/sdk';
1
+ import { TokenAmount } from '@lifi/sdk';
2
2
  export declare const useTokenBalances: (selectedChainId: number) => {
3
3
  tokens: TokenAmount[] | undefined;
4
4
  isLoading: boolean;
@@ -1,5 +1,5 @@
1
1
  export declare const useTokens: (selectedChainId: number) => {
2
- tokens: import("@lifinance/types").Token[] | undefined;
2
+ tokens: import("@lifi/types").Token[] | undefined;
3
3
  isLoading: boolean;
4
4
  isFetching: boolean;
5
5
  };
@@ -1 +1 @@
1
- export declare const useTools: () => import("@lifinance/types").ToolsResponse | undefined;
1
+ export declare const useTools: () => import("@lifi/types").ToolsResponse | undefined;
@@ -70,14 +70,12 @@
70
70
  },
71
71
  "warning": {
72
72
  "title": {
73
- "insufficientFunds": "Insufficient funds",
74
- "insufficientGasOnStartChain": "Insufficient gas on start chain",
75
- "insufficientGasOnDestinationChain": "Insufficient gas on destination chain"
73
+ "insufficientGas": "Insufficient gas"
76
74
  },
77
75
  "message": {
78
- "insufficientFunds": "You don't have enough funds in this account.",
79
- "insufficientGasOnStartChain": "The selected route requires a swap on the chain you are transferring from. You need to have gas on that chain to pay for the transaction there.",
80
- "insufficientGasOnDestinationChain": "The selected route requires a swap on the chain you are transferring to. You need to have gas on that chain to pay for the transaction there."
76
+ "insufficientFunds": "You don't have enough funds for this transaction on the start “from” chain.",
77
+ "insufficientGasOnStartChain": "You need to have enough gas to pay for this transaction on the start “from” chain.",
78
+ "insufficientGasOnDestinationChain": "You need to have enough gas to pay for this transaction on the destination “to” chain."
81
79
  }
82
80
  },
83
81
  "error": {
@@ -100,7 +98,7 @@
100
98
  "process": {
101
99
  "tokenAllowance": {
102
100
  "started": "Setting token allowance.",
103
- "pending": "Waiting for token allowance approval.",
101
+ "pending": "Waiting for token allowance.",
104
102
  "done": "Token allowance approved."
105
103
  },
106
104
  "switchChain": {
@@ -145,6 +143,10 @@
145
143
  "extensionNotFound": "Please make sure that only the {{name}} browser extension is active before choosing this wallet."
146
144
  },
147
145
  "tooltip": {
146
+ "notFound": {
147
+ "title": "Sorry 🥲",
148
+ "text": "We couldn't find this page."
149
+ },
148
150
  "progressToNextUpdate": "Displayed data will auto-refresh after {{value}} seconds. Click this circle to update manually."
149
151
  }
150
152
  }
package/i18n/index.d.ts CHANGED
@@ -73,9 +73,7 @@ export declare const resources: {
73
73
  };
74
74
  warning: {
75
75
  title: {
76
- insufficientFunds: string;
77
- insufficientGasOnStartChain: string;
78
- insufficientGasOnDestinationChain: string;
76
+ insufficientGas: string;
79
77
  };
80
78
  message: {
81
79
  insufficientFunds: string;
@@ -148,6 +146,10 @@ export declare const resources: {
148
146
  extensionNotFound: string;
149
147
  };
150
148
  tooltip: {
149
+ notFound: {
150
+ title: string;
151
+ text: string;
152
+ };
151
153
  progressToNextUpdate: string;
152
154
  };
153
155
  };
package/lifi.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import LIFI from '@lifinance/sdk';
1
+ import LIFI from '@lifi/sdk';
2
2
  export declare const LiFi: LIFI;
package/lifi.js CHANGED
@@ -1,4 +1,4 @@
1
- import LIFI from '@lifinance/sdk';
1
+ import LIFI from '@lifi/sdk';
2
2
  export const LiFi = new LIFI({
3
3
  // apiUrl: env.LIFI_API_URL,
4
4
  defaultRouteOptions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lifi/widget",
3
- "version": "1.6.1",
3
+ "version": "1.8.1",
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
  "sideEffects": false,
6
6
  "main": "./index.js",
@@ -23,7 +23,7 @@
23
23
  "bugs": {
24
24
  "url": "https://github.com/lifinance/widget/issues"
25
25
  },
26
- "license": "MIT",
26
+ "license": "Apache-2.0",
27
27
  "keywords": [
28
28
  "widget",
29
29
  "lifi-widget",
@@ -41,15 +41,15 @@
41
41
  "@emotion/styled": "^11.9.3",
42
42
  "@ethersproject/experimental": "^5.6.3",
43
43
  "@ethersproject/providers": "^5.6.8",
44
- "@lifi/wallet-management": "^1.0.4",
45
- "@lifinance/sdk": "^1.0.0-beta.14",
44
+ "@lifi/sdk": "^1.0.0",
45
+ "@lifi/wallet-management": "^1.1.1",
46
46
  "@mui/icons-material": "^5.8.4",
47
- "@mui/lab": "^5.0.0-alpha.89",
48
- "@mui/material": "^5.8.7",
49
- "@sentry/integrations": "^7.5.1",
50
- "@sentry/react": "^7.5.1",
51
- "@sentry/tracing": "^7.5.1",
52
- "big.js": "^6.2.0",
47
+ "@mui/lab": "^5.0.0-alpha.90",
48
+ "@mui/material": "^5.9.0",
49
+ "@sentry/integrations": "^7.6.0",
50
+ "@sentry/react": "^7.6.0",
51
+ "@sentry/tracing": "^7.6.0",
52
+ "big.js": "^6.2.1",
53
53
  "i18next": "^21.8.13",
54
54
  "immer": "^9.0.15",
55
55
  "react": "^18.2.0",
@@ -1,12 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Box } from '@mui/material';
3
+ import { InsufficientGasOrFundsMessage } from '../../components/InsufficientGasOrFundsMessage';
3
4
  import { SelectChainAndToken } from '../../components/SelectChainAndToken';
4
5
  import { SwapButton } from '../../components/SwapButton';
5
6
  import { SwapInProgress } from '../../components/SwapInProgress';
6
7
  import { SwapInput } from '../../components/SwapInput';
7
8
  import { SwapRoutes } from '../../components/SwapRoutes';
8
- import { InsufficientGasOrFundsMessage } from './InsufficientGasOrFundsMessage';
9
9
  import { FormContainer } from './MainPage.style';
10
10
  export const MainPage = () => {
11
- return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(SwapInProgress, { mx: 3, mt: 2, mb: 1 }), _jsx(SelectChainAndToken, { mt: 2, mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 3 }, { children: _jsx(SwapInput, { formType: "from" }) })), _jsx(SwapRoutes, { mx: 3, mb: 3 }), _jsx(InsufficientGasOrFundsMessage, {}), _jsx(Box, Object.assign({ mx: 3, mb: 1 }, { children: _jsx(SwapButton, {}) }))] })));
11
+ return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(SwapInProgress, { mx: 3, mt: 2, mb: 1 }), _jsx(SelectChainAndToken, { mt: 2, mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 3 }, { children: _jsx(SwapInput, { formType: "from" }) })), _jsx(SwapRoutes, { mx: 3, mb: 3 }), _jsx(InsufficientGasOrFundsMessage, { mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 1 }, { children: _jsx(SwapButton, {}) }))] })));
12
12
  };
@@ -8,4 +8,4 @@ export declare const FormContainer: import("@emotion/styled").StyledComponent<{
8
8
  sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
9
9
  } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
10
10
  ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
11
- }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "maxWidth" | "fixed" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/system").Theme>, {}, {}>;
11
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "children" | "sx" | "maxWidth" | "fixed" | "disableGutters"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -1,5 +1,5 @@
1
1
  import { Container } from '@mui/material';
2
- import { styled } from '@mui/system';
2
+ import { styled } from '@mui/material/styles';
3
3
  export const FormContainer = styled(Container)({
4
4
  display: 'flex',
5
5
  flexDirection: 'column',
@@ -1,2 +1,3 @@
1
+ /// <reference types="react" />
1
2
  import { SwapFormTypeProps } from '../../providers/SwapFormProvider';
2
3
  export declare const ChainSelect: ({ formType }: SwapFormTypeProps) => JSX.Element;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const SearchTokenInput: () => JSX.Element;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const SelectWalletPage: () => JSX.Element;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const AdvancedPreferences: () => JSX.Element;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const GasPriceSelect: () => JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Orders } from '@lifinance/sdk';
2
+ import { Orders } from '@lifi/sdk';
3
3
  import { KeyboardArrowDown as KeyboardArrowDownIcon } from '@mui/icons-material';
4
4
  import { FormControl, MenuItem } from '@mui/material';
5
5
  import { useTranslation } from 'react-i18next';
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const SettingsPage: () => JSX.Element;
@@ -1 +1,2 @@
1
+ /// <reference types="react" />
1
2
  export declare const SlippageInput: () => JSX.Element;
@@ -1,4 +1,5 @@
1
- import { Status } from '@lifinance/sdk';
1
+ /// <reference types="react" />
2
+ import { Status } from '@lifi/sdk';
2
3
  export declare function CircularProgress({ status }: {
3
4
  status: Status;
4
5
  }): JSX.Element;
@@ -1,4 +1,4 @@
1
- import { Status } from '@lifinance/sdk';
1
+ import { Status } from '@lifi/sdk';
2
2
  import { Theme } from '@mui/material';
3
3
  export declare const CircularProgress: import("@emotion/styled").StyledComponent<import("@mui/material").CircularProgressProps & import("@mui/system").MUIStyledCommonProps<Theme> & {
4
4
  status: Status;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Process, Step } from '@lifinance/sdk';
2
+ import { Process, Step } from '@lifi/sdk';
3
3
  export declare const ExecutionItem: React.FC<{
4
4
  step: Step;
5
5
  process: Process;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Step, TokenAmount } from '@lifinance/sdk';
2
+ import { Step, TokenAmount } from '@lifi/sdk';
3
3
  export declare const StepItem: React.FC<{
4
4
  step: Step;
5
5
  fromToken?: TokenAmount;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { Step } from '@lifinance/sdk';
2
+ import { Step } from '@lifi/sdk';
3
3
  export declare const StepTimer: React.FC<{
4
4
  step: Step;
5
5
  }>;
@@ -2,7 +2,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { Fragment } from 'react';
3
3
  import { useTranslation } from 'react-i18next';
4
4
  import { useLocation, useNavigate } from 'react-router-dom';
5
- import { useRouteExecution } from '../../hooks';
5
+ import { InsufficientGasOrFundsMessage } from '../../components/InsufficientGasOrFundsMessage';
6
+ import { useHasSufficientBalance, useRouteExecution } from '../../hooks';
6
7
  import { StatusBottomSheet } from './StatusBottomSheet';
7
8
  import { StepDivider } from './StepDivider';
8
9
  import { StepItem } from './StepItem';
@@ -11,12 +12,14 @@ export const SwapPage = () => {
11
12
  const { t } = useTranslation();
12
13
  const { state } = useLocation();
13
14
  const navigate = useNavigate();
15
+ const { hasGasOnStartChain, hasGasOnCrossChain, hasSufficientBalance } = useHasSufficientBalance();
14
16
  const { route, status, executeRoute, restartRoute, removeRoute } = useRouteExecution(state.routeId);
15
17
  const handleRemoveRoute = () => {
16
18
  removeRoute();
17
19
  navigate(-1);
18
20
  };
21
+ const isDisabled = !hasSufficientBalance || !hasGasOnStartChain || !hasGasOnCrossChain;
19
22
  return (_jsxs(Container, { children: [route === null || route === void 0 ? void 0 : route.steps.map((step, index, steps) => (_jsxs(Fragment, { children: [_jsx(StepItem, { step: step, fromToken: index === 0
20
23
  ? Object.assign(Object.assign({}, route.fromToken), { amount: route.fromAmount }) : undefined, toToken: index === steps.length - 1
21
- ? Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }) : undefined }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id))), status === 'idle' ? (_jsx(Button, Object.assign({ variant: "contained", disableElevation: true, fullWidth: true, onClick: executeRoute }, { children: t('button.startSwap') }))) : null, status === 'error' ? (_jsxs(_Fragment, { children: [_jsx(Button, Object.assign({ variant: "contained", disableElevation: true, fullWidth: true, onClick: restartRoute }, { children: t('button.restartSwap') })), _jsx(Button, Object.assign({ variant: "outlined", disableElevation: true, fullWidth: true, onClick: handleRemoveRoute }, { children: t('button.removeSwap') }))] })) : null, _jsx(StatusBottomSheet, { status: status, route: route })] }));
24
+ ? Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }) : undefined }), steps.length > 1 && index !== steps.length - 1 ? (_jsx(StepDivider, {})) : null] }, step.id))), _jsx(InsufficientGasOrFundsMessage, { mt: 2 }), status === 'idle' ? (_jsx(Button, Object.assign({ variant: "contained", disableElevation: true, fullWidth: true, onClick: executeRoute, disabled: isDisabled }, { children: t('button.startSwap') }))) : null, status === 'error' ? (_jsxs(_Fragment, { children: [_jsx(Button, Object.assign({ variant: "contained", disableElevation: true, fullWidth: true, onClick: restartRoute, disabled: isDisabled }, { children: t('button.restartSwap') })), _jsx(Button, Object.assign({ variant: "outlined", disableElevation: true, fullWidth: true, onClick: handleRemoveRoute, disabled: isDisabled }, { children: t('button.removeSwap') }))] })) : null, _jsx(StatusBottomSheet, { status: status, route: route })] }));
22
25
  };
@@ -1,4 +1,4 @@
1
- import { EVMChain, Process, Step } from '@lifinance/sdk';
1
+ import { EVMChain, Process, Step } from '@lifi/sdk';
2
2
  import { TFunction } from 'react-i18next';
3
3
  export declare function getProcessMessage(t: TFunction<'translation', undefined>, getChainById: (chainId: number) => EVMChain | undefined, step: Step, process: Process): {
4
4
  title?: string;
@@ -1,4 +1,4 @@
1
- import { LifiErrorCode, MetaMaskProviderErrorCode, } from '@lifinance/sdk';
1
+ import { LifiErrorCode, MetaMaskProviderErrorCode, } from '@lifi/sdk';
2
2
  import { formatTokenAmount } from '../../utils/format';
3
3
  const formatProcessMessage = (initialMessage, args = {}) => {
4
4
  return Object.keys(args).reduce((message, key) => {
@@ -1,5 +1,5 @@
1
+ import { Token } from '@lifi/sdk';
1
2
  import { Wallet } from '@lifi/wallet-management';
2
- import { Token } from '@lifinance/sdk';
3
3
  import { Signer } from 'ethers';
4
4
  export interface WalletContextProps {
5
5
  account: WalletAccount;
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  return t;
11
11
  };
12
12
  import { jsx as _jsx } from "react/jsx-runtime";
13
- import { ChainId, getChainByKey } from '@lifinance/sdk';
13
+ import { ChainId, getChainByKey } from '@lifi/sdk';
14
14
  import { createContext, useContext, useMemo } from 'react';
15
15
  const stub = () => {
16
16
  throw new Error('You forgot to wrap your component in <WidgetProvider>.');
@@ -1,4 +1,4 @@
1
- import { Route } from '@lifinance/sdk';
1
+ import { Route } from '@lifi/sdk';
2
2
  export interface RouteExecutionStore {
3
3
  currentRoute?: Route;
4
4
  routes: Record<string, RouteExecution>;
@@ -1,2 +1,2 @@
1
- import { Route } from '@lifinance/sdk';
1
+ import { Route } from '@lifi/sdk';
2
2
  export declare const useCurrentRoute: () => [Route | undefined, (route?: Route) => void];
@@ -1 +1 @@
1
- export declare const useSetExecutableRoute: () => (route: import("@lifinance/types").Route) => void;
1
+ export declare const useSetExecutableRoute: () => (route: import("@lifi/types").Route) => void;
@@ -1,4 +1,4 @@
1
- import { Bridge, Exchange, Order } from '@lifinance/sdk';
1
+ import { Bridge, Exchange, Order } from '@lifi/sdk';
2
2
  import { Appearance } from '../../types';
3
3
  export declare type ValueSetter<S> = <K extends keyof S>(key: K, value: S[Extract<K, string>]) => void;
4
4
  export declare type ValuesSetter<S> = <K extends keyof S>(values: Record<K, S[Extract<K, string>]>) => void;
@@ -5,7 +5,7 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<Omit
5
5
  setValue: import("./types").ValueSetter<SettingsState>;
6
6
  setValues: import("./types").ValuesSetter<SettingsState>;
7
7
  initializeTools(toolType: import("./types").SettingsToolType, tools: string[]): void;
8
- setTools(toolType: import("./types").SettingsToolType, tools: string[], availableTools: (Pick<import("@lifinance/types").Bridge, "key"> | Pick<import("@lifinance/types").Exchange, "key">)[]): void;
8
+ setTools(toolType: import("./types").SettingsToolType, tools: string[], availableTools: (Pick<import("@lifi/types").Bridge, "key"> | Pick<import("@lifi/types").Exchange, "key">)[]): void;
9
9
  advancedPreferences: boolean;
10
10
  appearance: import("../..").Appearance;
11
11
  routePriority: "RECOMMENDED" | "FASTEST" | "CHEAPEST" | "SAFEST";
package/types/widget.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ChainKey, Token } from '@lifinance/sdk';
1
+ import { ChainKey, Token } from '@lifi/sdk';
2
2
  import { PaletteMode, PaletteOptions, Shape } from '@mui/material';
3
3
  import { TypographyOptions } from '@mui/material/styles/createTypography';
4
4
  import { Signer } from 'ethers';
@@ -1,2 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const InsufficientGasOrFundsMessage: React.FC;
@@ -1,28 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Typography } from '@mui/material';
3
- import { useTranslation } from 'react-i18next';
4
- import { CardTitle } from '../../components/Card';
5
- import { useHasSufficientBalance } from '../../hooks';
6
- import { MessageCard } from './InsufficientGasOrFundsMessage.style';
7
- export const InsufficientGasOrFundsMessage = () => {
8
- const { t } = useTranslation();
9
- const { hasGasBalanceOnStartChain, hasGasOnCrossChain, hasSufficientBalance, } = useHasSufficientBalance();
10
- if (hasSufficientBalance && hasGasBalanceOnStartChain && hasGasOnCrossChain) {
11
- return null;
12
- }
13
- let title;
14
- let message;
15
- if (!hasSufficientBalance) {
16
- title = t(`swap.warning.title.insufficientFunds`);
17
- message = t(`swap.warning.message.insufficientFunds`);
18
- }
19
- if (!hasGasBalanceOnStartChain) {
20
- title = t(`swap.warning.title.insufficientGasOnStartChain`);
21
- message = t(`swap.warning.message.insufficientGasOnStartChain`);
22
- }
23
- if (!hasGasOnCrossChain) {
24
- title = t(`swap.warning.title.insufficientGasOnDestinationChain`);
25
- message = t(`swap.warning.message.insufficientGasOnDestinationChain`);
26
- }
27
- return (_jsxs(MessageCard, Object.assign({ mx: 3, mb: 3 }, { children: [_jsx(CardTitle, { children: title }), _jsx(Typography, Object.assign({ variant: "body2", px: 2, pb: 2, pt: 1 }, { children: message }))] })));
28
- };