@lifi/widget 1.13.7 → 1.15.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 (152) hide show
  1. package/cjs/components/Header/Header.js +2 -2
  2. package/cjs/components/Header/NavigationHeader.js +5 -7
  3. package/cjs/components/Header/WalletHeader.js +4 -5
  4. package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +10 -10
  5. package/cjs/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
  6. package/cjs/components/SelectTokenButton/SelectTokenButton.js +3 -3
  7. package/cjs/components/{SwapInProgress/SwapInProgress.d.ts → SendToWallet/SendToWallet.d.ts} +1 -1
  8. package/cjs/components/SendToWallet/SendToWallet.js +53 -0
  9. package/cjs/components/SendToWallet/SendToWallet.style.d.ts +19 -0
  10. package/cjs/components/SendToWallet/SendToWallet.style.js +15 -0
  11. package/cjs/components/SendToWallet/index.d.ts +1 -0
  12. package/cjs/components/{SwapInProgress → SendToWallet}/index.js +1 -1
  13. package/cjs/components/Step/StepTimer.js +1 -1
  14. package/cjs/components/SwapButton/SwapButton.js +11 -8
  15. package/cjs/components/SwapInput/FormPriceHelperText.d.ts +1 -1
  16. package/cjs/components/SwapInput/FormPriceHelperText.js +4 -4
  17. package/cjs/components/SwapInput/SwapInput.d.ts +1 -1
  18. package/cjs/components/SwapInput/SwapInput.js +4 -4
  19. package/cjs/components/SwapInput/SwapInputAdornment.d.ts +1 -1
  20. package/cjs/components/SwapInput/SwapInputAdornment.js +4 -4
  21. package/cjs/components/SwapRouteCard/SwapRouteCard.js +4 -3
  22. package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +3 -3
  23. package/cjs/components/SwapsInProgress/SwapsInProgress.d.ts +3 -0
  24. package/cjs/components/SwapsInProgress/SwapsInProgress.js +29 -0
  25. package/cjs/components/{SwapInProgress/SwapInProgress.style.d.ts → SwapsInProgress/SwapsInProgress.style.d.ts} +0 -0
  26. package/cjs/components/{SwapInProgress/SwapInProgress.style.js → SwapsInProgress/SwapsInProgress.style.js} +0 -0
  27. package/cjs/components/SwapsInProgress/index.d.ts +1 -0
  28. package/cjs/components/SwapsInProgress/index.js +17 -0
  29. package/cjs/components/TokenList/TokenList.js +10 -11
  30. package/cjs/components/TokenList/VirtualizedTokenList.js +1 -1
  31. package/cjs/components/TokenList/types.d.ts +1 -1
  32. package/cjs/config/lifi.js +3 -1
  33. package/cjs/config/version.d.ts +1 -1
  34. package/cjs/config/version.js +1 -1
  35. package/cjs/hooks/index.d.ts +1 -0
  36. package/cjs/hooks/index.js +1 -0
  37. package/cjs/hooks/useNavigateBack.d.ts +4 -0
  38. package/cjs/hooks/useNavigateBack.js +18 -0
  39. package/cjs/hooks/useSwapRoutes.js +18 -7
  40. package/cjs/i18n/en/translation.json +13 -8
  41. package/cjs/i18n/index.d.ts +11 -6
  42. package/cjs/pages/MainPage/MainPage.js +3 -2
  43. package/cjs/pages/SelectTokenPage/ChainSelect.d.ts +1 -1
  44. package/cjs/pages/SelectTokenPage/ChainSelect.js +11 -12
  45. package/cjs/pages/SelectTokenPage/SearchTokenInput.js +3 -3
  46. package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +1 -1
  47. package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -6
  48. package/cjs/pages/SelectWalletPage/SelectWalletPage.js +6 -6
  49. package/cjs/pages/SettingsPage/AdvancedPreferences.js +2 -2
  50. package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
  51. package/cjs/pages/SettingsPage/SettingsPage.js +2 -1
  52. package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +2 -0
  53. package/cjs/pages/SettingsPage/ShowDestinationWallet.js +22 -0
  54. package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +3 -2
  55. package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
  56. package/cjs/pages/SwapPage/StatusBottomSheet.js +4 -5
  57. package/cjs/pages/SwapPage/SwapPage.js +2 -2
  58. package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
  59. package/cjs/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -0
  60. package/cjs/providers/SwapFormProvider/SwapFormProvider.js +10 -4
  61. package/cjs/providers/SwapFormProvider/types.d.ts +3 -1
  62. package/cjs/providers/SwapFormProvider/types.js +1 -0
  63. package/cjs/providers/WalletProvider/WalletProvider.js +5 -4
  64. package/cjs/providers/WalletProvider/types.d.ts +4 -2
  65. package/cjs/providers/WidgetProvider/WidgetProvider.js +4 -0
  66. package/cjs/providers/index.d.ts +4 -0
  67. package/cjs/providers/index.js +20 -0
  68. package/cjs/stores/route/useRouteStore.js +36 -0
  69. package/cjs/stores/settings/types.d.ts +2 -1
  70. package/cjs/stores/settings/useSettingsStore.d.ts +4 -2
  71. package/cjs/stores/settings/useSettingsStore.js +1 -0
  72. package/cjs/types/widget.d.ts +1 -0
  73. package/cjs/utils/format.js +7 -2
  74. package/components/Header/Header.js +1 -1
  75. package/components/Header/NavigationHeader.js +5 -7
  76. package/components/Header/WalletHeader.js +1 -2
  77. package/components/ReverseTokensButton/ReverseTokensButton.js +1 -1
  78. package/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
  79. package/components/SelectTokenButton/SelectTokenButton.js +1 -1
  80. package/components/{SwapInProgress/SwapInProgress.d.ts → SendToWallet/SendToWallet.d.ts} +1 -1
  81. package/components/SendToWallet/SendToWallet.js +49 -0
  82. package/components/SendToWallet/SendToWallet.style.d.ts +19 -0
  83. package/components/SendToWallet/SendToWallet.style.js +12 -0
  84. package/components/SendToWallet/index.d.ts +1 -0
  85. package/components/SendToWallet/index.js +1 -0
  86. package/components/Step/StepTimer.js +1 -1
  87. package/components/SwapButton/SwapButton.js +9 -6
  88. package/components/SwapInput/FormPriceHelperText.d.ts +1 -1
  89. package/components/SwapInput/FormPriceHelperText.js +1 -1
  90. package/components/SwapInput/SwapInput.d.ts +1 -1
  91. package/components/SwapInput/SwapInput.js +1 -1
  92. package/components/SwapInput/SwapInputAdornment.d.ts +1 -1
  93. package/components/SwapInput/SwapInputAdornment.js +1 -1
  94. package/components/SwapRouteCard/SwapRouteCard.js +4 -3
  95. package/components/SwapRouteCard/SwapRouteCard.style.js +3 -3
  96. package/components/SwapsInProgress/SwapsInProgress.d.ts +3 -0
  97. package/components/{SwapInProgress/SwapInProgress.js → SwapsInProgress/SwapsInProgress.js} +4 -4
  98. package/components/{SwapInProgress/SwapInProgress.style.d.ts → SwapsInProgress/SwapsInProgress.style.d.ts} +0 -0
  99. package/components/{SwapInProgress/SwapInProgress.style.js → SwapsInProgress/SwapsInProgress.style.js} +0 -0
  100. package/components/SwapsInProgress/index.d.ts +1 -0
  101. package/components/SwapsInProgress/index.js +1 -0
  102. package/components/TokenList/TokenList.js +1 -2
  103. package/components/TokenList/VirtualizedTokenList.js +1 -1
  104. package/components/TokenList/types.d.ts +1 -1
  105. package/config/lifi.js +3 -1
  106. package/config/version.d.ts +1 -1
  107. package/config/version.js +1 -1
  108. package/hooks/index.d.ts +1 -0
  109. package/hooks/index.js +1 -0
  110. package/hooks/useNavigateBack.d.ts +4 -0
  111. package/hooks/useNavigateBack.js +14 -0
  112. package/hooks/useSwapRoutes.js +18 -7
  113. package/i18n/en/translation.json +13 -8
  114. package/i18n/index.d.ts +11 -6
  115. package/package.json +9 -12
  116. package/pages/MainPage/MainPage.js +3 -2
  117. package/pages/SelectTokenPage/ChainSelect.d.ts +1 -1
  118. package/pages/SelectTokenPage/ChainSelect.js +9 -10
  119. package/pages/SelectTokenPage/SearchTokenInput.js +1 -1
  120. package/pages/SelectTokenPage/SelectTokenPage.d.ts +1 -1
  121. package/pages/SelectTokenPage/SelectTokenPage.js +3 -7
  122. package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
  123. package/pages/SettingsPage/AdvancedPreferences.js +2 -2
  124. package/pages/SettingsPage/ColorSchemeButtonGroup.js +1 -1
  125. package/pages/SettingsPage/SettingsPage.js +2 -1
  126. package/pages/SettingsPage/ShowDestinationWallet.d.ts +2 -0
  127. package/pages/SettingsPage/ShowDestinationWallet.js +18 -0
  128. package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -3
  129. package/pages/SwapHistoryPage/SwapHistoryPage.js +1 -1
  130. package/pages/SwapPage/StatusBottomSheet.js +4 -5
  131. package/pages/SwapPage/SwapPage.js +4 -4
  132. package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
  133. package/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -0
  134. package/providers/SwapFormProvider/SwapFormProvider.js +10 -4
  135. package/providers/SwapFormProvider/types.d.ts +3 -1
  136. package/providers/SwapFormProvider/types.js +1 -0
  137. package/providers/WalletProvider/WalletProvider.js +5 -4
  138. package/providers/WalletProvider/types.d.ts +4 -2
  139. package/providers/WidgetProvider/WidgetProvider.js +5 -1
  140. package/providers/index.d.ts +4 -0
  141. package/providers/index.js +4 -0
  142. package/stores/route/useRouteStore.js +36 -0
  143. package/stores/settings/types.d.ts +2 -1
  144. package/stores/settings/useSettingsStore.d.ts +4 -2
  145. package/stores/settings/useSettingsStore.js +1 -0
  146. package/tsconfig.cjs.tsbuildinfo +1 -1
  147. package/types/widget.d.ts +1 -0
  148. package/utils/format.js +7 -2
  149. package/cjs/components/SwapInProgress/SwapInProgress.js +0 -29
  150. package/cjs/components/SwapInProgress/index.d.ts +0 -1
  151. package/components/SwapInProgress/index.d.ts +0 -1
  152. package/components/SwapInProgress/index.js +0 -1
@@ -28,7 +28,7 @@ const WalletContext = (0, react_1.createContext)(initialContext);
28
28
  const useWallet = () => (0, react_1.useContext)(WalletContext);
29
29
  exports.useWallet = useWallet;
30
30
  const WalletProvider = ({ children, walletManagement }) => {
31
- const { connect: walletManagementConnect, disconnect: walletManagementDisconnect, signer, } = (0, wallet_management_1.useLiFiWalletManagement)();
31
+ const { connect: walletManagementConnect, disconnect: walletManagementDisconnect, signer, provider, } = (0, wallet_management_1.useLiFiWalletManagement)();
32
32
  const [account, setAccount] = (0, react_1.useState)({});
33
33
  const connect = (0, react_1.useCallback)((wallet) => __awaiter(void 0, void 0, void 0, function* () {
34
34
  if (walletManagement) {
@@ -85,17 +85,18 @@ const WalletProvider = ({ children, walletManagement }) => {
85
85
  addChain,
86
86
  addToken,
87
87
  account,
88
- }), [account, addChain, addToken, connect, disconnect, switchChain]);
88
+ provider,
89
+ }), [account, addChain, addToken, connect, disconnect, provider, switchChain]);
89
90
  return ((0, jsx_runtime_1.jsx)(WalletContext.Provider, Object.assign({ value: value }, { children: children })));
90
91
  };
91
92
  exports.WalletProvider = WalletProvider;
92
93
  const extractAccountFromSigner = (signer) => __awaiter(void 0, void 0, void 0, function* () {
93
94
  try {
94
95
  return {
95
- address: (yield (signer === null || signer === void 0 ? void 0 : signer.getAddress())) || undefined,
96
+ address: yield (signer === null || signer === void 0 ? void 0 : signer.getAddress()),
96
97
  isActive: (signer && !!(yield signer.getAddress()) === null) || !!signer,
97
98
  signer,
98
- chainId: (yield (signer === null || signer === void 0 ? void 0 : signer.getChainId())) || undefined,
99
+ chainId: yield (signer === null || signer === void 0 ? void 0 : signer.getChainId()),
99
100
  };
100
101
  }
101
102
  catch (error) {
@@ -1,8 +1,10 @@
1
+ import type { Web3Provider } from '@ethersproject/providers';
1
2
  import type { Token } from '@lifi/sdk';
2
3
  import type { Wallet } from '@lifi/wallet-management';
3
4
  import type { Signer } from 'ethers';
4
5
  export interface WalletContextProps {
5
6
  account: WalletAccount;
7
+ provider?: Web3Provider;
6
8
  addChain(chainId: number): Promise<boolean>;
7
9
  addToken(chainId: number, token: Token): Promise<void>;
8
10
  disconnect(): void;
@@ -10,8 +12,8 @@ export interface WalletContextProps {
10
12
  connect(wallet?: Wallet | undefined): Promise<void>;
11
13
  }
12
14
  export interface WalletAccount {
13
- address?: string;
14
15
  isActive?: boolean;
15
- signer?: Signer;
16
16
  chainId?: number;
17
+ address?: string;
18
+ signer?: Signer;
17
19
  }
@@ -16,6 +16,7 @@ const jsx_runtime_1 = require("react/jsx-runtime");
16
16
  const sdk_1 = require("@lifi/sdk");
17
17
  const react_1 = require("react");
18
18
  const lifi_1 = require("../../config/lifi");
19
+ const version_1 = require("../../config/version");
19
20
  const stub = () => {
20
21
  throw new Error('You forgot to wrap your component in <WidgetProvider>.');
21
22
  };
@@ -63,6 +64,9 @@ const WidgetProvider = (_a) => {
63
64
  },
64
65
  });
65
66
  }, [integrator]);
67
+ (0, react_1.useEffect)(() => {
68
+ (0, sdk_1.checkPackageUpdates)(version_1.name, version_1.version);
69
+ }, []);
66
70
  return ((0, jsx_runtime_1.jsx)(WidgetContext.Provider, Object.assign({ value: value }, { children: children })));
67
71
  };
68
72
  exports.WidgetProvider = WidgetProvider;
@@ -0,0 +1,4 @@
1
+ export * from './SwapFormProvider';
2
+ export * from './ThemeProvider';
3
+ export * from './WalletProvider';
4
+ export * from './WidgetProvider';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./SwapFormProvider"), exports);
18
+ __exportStar(require("./ThemeProvider"), exports);
19
+ __exportStar(require("./WalletProvider"), exports);
20
+ __exportStar(require("./WidgetProvider"), exports);
@@ -54,4 +54,40 @@ exports.useRouteStore = (0, zustand_1.default)()((0, middleware_1.persist)((0, i
54
54
  })), {
55
55
  name: 'li.fi-widget-routes',
56
56
  partialize: (state) => ({ routes: state.routes }),
57
+ merge: (persistedState, currentState) => {
58
+ const state = Object.assign(Object.assign({}, currentState), persistedState);
59
+ try {
60
+ const routeString = localStorage.getItem('routes');
61
+ if (routeString) {
62
+ const routes = JSON.parse(routeString);
63
+ routes.forEach((route) => {
64
+ if (state.routes[route.id]) {
65
+ return;
66
+ }
67
+ state.routes[route.id] = {
68
+ route,
69
+ status: 'idle',
70
+ };
71
+ const isFailed = route.steps.some((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
72
+ if (isFailed) {
73
+ state.routes[route.id].status = 'error';
74
+ return;
75
+ }
76
+ const isDone = route.steps.every((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE'; });
77
+ if (isDone) {
78
+ state.routes[route.id].status = 'success';
79
+ return;
80
+ }
81
+ const isLoading = route.steps.some((step) => step.execution);
82
+ if (isLoading) {
83
+ state.routes[route.id].status = 'loading';
84
+ }
85
+ });
86
+ }
87
+ }
88
+ catch (error) {
89
+ console.log(error);
90
+ }
91
+ return state;
92
+ },
57
93
  }));
@@ -7,9 +7,10 @@ export declare const SettingsToolTypes: SettingsToolType[];
7
7
  export interface SettingsState {
8
8
  advancedPreferences: boolean;
9
9
  appearance: Appearance;
10
+ gasPrice: string;
10
11
  routePriority: Order;
12
+ showDestinationWallet: boolean;
11
13
  slippage: string;
12
- gasPrice: string;
13
14
  enabledBridges?: string[];
14
15
  _enabledBridges?: Record<string, boolean>;
15
16
  enabledExchanges?: string[];
@@ -8,9 +8,10 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<Omit
8
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
+ gasPrice: string;
11
12
  routePriority: "RECOMMENDED" | "FASTEST" | "CHEAPEST" | "SAFEST";
13
+ showDestinationWallet: boolean;
12
14
  slippage: string;
13
- gasPrice: string;
14
15
  _enabledBridges?: Record<string, boolean> | undefined;
15
16
  _enabledExchanges?: Record<string, boolean> | undefined;
16
17
  }>>) => void;
@@ -26,9 +27,10 @@ export declare const useSettingsStore: import("zustand").UseBoundStore<Omit<Omit
26
27
  setTools(toolType: import("./types").SettingsToolType, tools: string[], availableTools: (Pick<import("@lifi/types").Bridge, "key"> | Pick<import("@lifi/types").Exchange, "key">)[]): void;
27
28
  advancedPreferences: boolean;
28
29
  appearance: import("../..").Appearance;
30
+ gasPrice: string;
29
31
  routePriority: "RECOMMENDED" | "FASTEST" | "CHEAPEST" | "SAFEST";
32
+ showDestinationWallet: boolean;
30
33
  slippage: string;
31
- gasPrice: string;
32
34
  _enabledBridges?: Record<string, boolean> | undefined;
33
35
  _enabledExchanges?: Record<string, boolean> | undefined;
34
36
  }>>;
@@ -22,6 +22,7 @@ const immer_1 = require("zustand/middleware/immer");
22
22
  const types_1 = require("./types");
23
23
  exports.useSettingsStore = (0, zustand_1.default)()((0, middleware_1.persist)((0, immer_1.immer)((set) => ({
24
24
  advancedPreferences: false,
25
+ showDestinationWallet: false,
25
26
  appearance: 'auto',
26
27
  gasPrice: 'normal',
27
28
  routePriority: 'RECOMMENDED',
@@ -19,6 +19,7 @@ export interface WidgetWalletManagement {
19
19
  }
20
20
  interface WidgetConfigBase {
21
21
  fromAmount?: number | string;
22
+ toAddress?: string;
22
23
  containerStyle?: CSSProperties;
23
24
  theme?: ThemeConfig;
24
25
  appearance?: Appearance;
@@ -68,8 +68,13 @@ const formatAmount = (amount = '', returnInitial = false) => {
68
68
  if (parsedAmount < 0) {
69
69
  return Math.abs(parsedAmount).toString();
70
70
  }
71
- if (returnInitial) {
72
- return amount;
71
+ try {
72
+ if (returnInitial && (0, big_js_1.default)(amount)) {
73
+ return amount;
74
+ }
75
+ }
76
+ catch (_a) {
77
+ return '';
73
78
  }
74
79
  return (0, big_js_1.default)(parsedAmount).toString();
75
80
  };
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useLocation } from 'react-router-dom';
3
- import { useWidgetConfig } from '../../providers/WidgetProvider';
3
+ import { useWidgetConfig } from '../../providers';
4
4
  import { ElementId, navigationRoutes } from '../../utils';
5
5
  import { Container } from './Header.style';
6
6
  import { NavigationHeader } from './NavigationHeader';
@@ -2,8 +2,9 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { ArrowBack as ArrowBackIcon, History as HistoryIcon, SettingsOutlined as SettingsIcon, } from '@mui/icons-material';
3
3
  import { Box, IconButton, Typography } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
- import { Route, Routes, useLocation, useNavigate } from 'react-router-dom';
6
- import { useWallet } from '../../providers/WalletProvider';
5
+ import { Route, Routes, useLocation } from 'react-router-dom';
6
+ import { useNavigateBack } from '../../hooks';
7
+ import { useWallet } from '../../providers';
7
8
  import { navigationRoutes, navigationRoutesValues } from '../../utils';
8
9
  import { HeaderAppBar } from './Header.style';
9
10
  import { useHeaderActionStore } from './useHeaderActionStore';
@@ -19,15 +20,12 @@ const backButtonRoutes = [
19
20
  ];
20
21
  export const NavigationHeader = () => {
21
22
  const { t } = useTranslation();
22
- const navigate = useNavigate();
23
+ const { navigate, navigateBack } = useNavigateBack();
23
24
  const { account } = useWallet();
24
25
  const { element } = useHeaderActionStore();
25
26
  const { pathname } = useLocation();
26
27
  const path = pathname.substring(pathname.lastIndexOf('/') + 1);
27
28
  const hasPath = navigationRoutesValues.includes(path);
28
- const handleBack = () => {
29
- navigate(-1);
30
- };
31
29
  const handleHeaderTitle = () => {
32
30
  switch (path) {
33
31
  case navigationRoutes.selectWallet:
@@ -50,5 +48,5 @@ export const NavigationHeader = () => {
50
48
  return t(`header.swap`);
51
49
  }
52
50
  };
53
- return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: handleBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "swap-history", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory) }, { children: _jsx(HistoryIcon, {}) }))) : null, _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: () => navigate(navigationRoutes.settings) }, { children: _jsx(SettingsIcon, {}) }))] }) }), _jsx(Route, { path: "*", element: element || _jsx(Box, { width: 28, height: 40 }) })] })] })));
51
+ return (_jsxs(HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: navigateBack }, { children: _jsx(ArrowBackIcon, {}) }))) : null, _jsx(Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), _jsxs(Routes, { children: [_jsx(Route, { path: navigationRoutes.home, element: _jsxs(_Fragment, { children: [account.isActive ? (_jsx(IconButton, Object.assign({ size: "medium", "aria-label": "swap-history", edge: "start", onClick: () => navigate(navigationRoutes.swapHistory) }, { children: _jsx(HistoryIcon, {}) }))) : null, _jsx(IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: () => navigate(navigationRoutes.settings) }, { children: _jsx(SettingsIcon, {}) }))] }) }), _jsx(Route, { path: "*", element: element || _jsx(Box, { width: 28, height: 40 }) })] })] })));
54
52
  };
@@ -12,8 +12,7 @@ import { AccountBalanceWalletOutlined as AccountBalanceWalletIcon, Logout as Log
12
12
  import { Box, IconButton, Typography } from '@mui/material';
13
13
  import { useTranslation } from 'react-i18next';
14
14
  import { useLocation, useNavigate } from 'react-router-dom';
15
- import { useWallet } from '../../providers/WalletProvider';
16
- import { useWidgetConfig } from '../../providers/WidgetProvider';
15
+ import { useWallet, useWidgetConfig } from '../../providers';
17
16
  import { navigationRoutes } from '../../utils';
18
17
  import { HeaderAppBar } from './Header.style';
19
18
  export const WalletHeader = () => {
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { SwapHoriz as SwapHorizIcon, SwapVert as SwapVertIcon, } from '@mui/icons-material';
3
3
  import { useFormContext } from 'react-hook-form';
4
- import { SwapFormKey } from '../../providers/SwapFormProvider';
4
+ import { SwapFormKey } from '../../providers';
5
5
  import { IconButton } from './ReverseTokensButton.style';
6
6
  export const ReverseTokensButton = ({ vertical, }) => {
7
7
  const { setValue, getValues } = useFormContext();
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { SwapFormTypeProps } from '../../providers/SwapFormProvider';
2
+ import type { SwapFormTypeProps } from '../../providers';
3
3
  export declare const SelectTokenButton: React.FC<SwapFormTypeProps & {
4
4
  compact: boolean;
5
5
  }>;
@@ -5,7 +5,7 @@ import { useWatch } from 'react-hook-form';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { useNavigate } from 'react-router-dom';
7
7
  import { useChain, useToken } from '../../hooks';
8
- import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
8
+ import { SwapFormKeyHelper } from '../../providers';
9
9
  import { navigationRoutes } from '../../utils';
10
10
  import { Card, CardTitle } from '../Card';
11
11
  import { TokenAvatar } from '../TokenAvatar';
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
2
  import type { BoxProps } from '@mui/material';
3
- export declare const SwapInProgress: React.FC<BoxProps>;
3
+ export declare const SendToWallet: React.FC<BoxProps>;
@@ -0,0 +1,49 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
+ import { isAddress } from '@ethersproject/address';
12
+ import { FormHelperText } from '@mui/material';
13
+ import { useEffect } from 'react';
14
+ import { useFormContext } from 'react-hook-form';
15
+ import { useTranslation } from 'react-i18next';
16
+ import { SwapFormKey, useWallet } from '../../providers';
17
+ import { useSettings } from '../../stores';
18
+ import { Card, CardTitle } from '../Card';
19
+ import { FormControl, Input } from './SendToWallet.style';
20
+ export const SendToWallet = (props) => {
21
+ var _a;
22
+ const { t } = useTranslation();
23
+ const { showDestinationWallet } = useSettings(['showDestinationWallet']);
24
+ const { account, provider } = useWallet();
25
+ const { register, trigger, formState: { errors }, } = useFormContext();
26
+ const { onChange, onBlur, name, ref } = register(SwapFormKey.ToAddress, {
27
+ validate: (value) => __awaiter(void 0, void 0, void 0, function* () {
28
+ try {
29
+ if (!value) {
30
+ return true;
31
+ }
32
+ const address = yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(value));
33
+ return (isAddress(address || value) ||
34
+ t('swap.error.title.walletAddressInvalid'));
35
+ }
36
+ catch (_b) {
37
+ return t('swap.error.title.walletEnsAddressInvalid');
38
+ }
39
+ }),
40
+ onBlur: () => trigger(SwapFormKey.ToAddress),
41
+ });
42
+ useEffect(() => {
43
+ trigger(SwapFormKey.ToAddress);
44
+ }, [account.chainId, trigger]);
45
+ if (!showDestinationWallet) {
46
+ return null;
47
+ }
48
+ return (_jsxs(Card, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.sendToWallet') }), _jsxs(FormControl, Object.assign({ fullWidth: true }, { children: [_jsx(Input, { ref: ref, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns') }), _jsx(FormHelperText, Object.assign({ error: !!errors.toAddress }, { children: (_a = errors.toAddress) === null || _a === void 0 ? void 0 : _a.message }))] }))] })));
49
+ };
@@ -0,0 +1,19 @@
1
+ /// <reference types="react" />
2
+ export declare const FormControl: import("@emotion/styled").StyledComponent<{
3
+ children?: import("react").ReactNode;
4
+ classes?: Partial<import("@mui/material").FormControlClasses> | undefined;
5
+ color?: "primary" | "secondary" | "error" | "warning" | "info" | "success" | undefined;
6
+ disabled?: boolean | undefined;
7
+ error?: boolean | undefined;
8
+ fullWidth?: boolean | undefined;
9
+ focused?: boolean | undefined;
10
+ hiddenLabel?: boolean | undefined;
11
+ margin?: "none" | "normal" | "dense" | undefined;
12
+ required?: boolean | undefined;
13
+ size?: "small" | "medium" | undefined;
14
+ sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
15
+ variant?: "outlined" | "filled" | "standard" | undefined;
16
+ } & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof import("react").HTMLAttributes<HTMLDivElement>> & {
17
+ ref?: import("react").RefObject<HTMLDivElement> | ((instance: HTMLDivElement | null) => void) | null | undefined;
18
+ }, keyof import("@mui/material/OverridableComponent").CommonProps | "color" | "children" | "disabled" | "sx" | "margin" | "fullWidth" | "size" | "variant" | "error" | "required" | "focused" | "hiddenLabel"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
19
+ export declare const Input: import("@emotion/styled").StyledComponent<import("@mui/material").InputBaseProps & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
@@ -0,0 +1,12 @@
1
+ import { FormControl as MuiFormControl, InputBase } from '@mui/material';
2
+ import { inputBaseClasses } from '@mui/material/InputBase';
3
+ import { styled } from '@mui/material/styles';
4
+ export const FormControl = styled(MuiFormControl)(({ theme }) => ({
5
+ padding: theme.spacing(1.5, 2, 1.5, 0),
6
+ }));
7
+ export const Input = styled(InputBase)(({ theme }) => ({
8
+ [`.${inputBaseClasses.input}`]: {
9
+ height: 32,
10
+ padding: theme.spacing(0, 0, 0, 2),
11
+ },
12
+ }));
@@ -0,0 +1 @@
1
+ export * from './SendToWallet';
@@ -0,0 +1 @@
1
+ export * from './SendToWallet';
@@ -54,7 +54,7 @@ export const StepTimer = ({ step }) => {
54
54
  ((_b = step.execution) === null || _b === void 0 ? void 0 : _b.status) === 'FAILED') {
55
55
  return null;
56
56
  }
57
- return isExpired ? (_jsx(_Fragment, { children: t('swap.networkIsBusy') })) : (
57
+ return isExpired ? (_jsx(_Fragment, { children: t('swap.inProgress') })) : (
58
58
  // eslint-disable-next-line react/jsx-no-useless-fragment
59
59
  _jsx(_Fragment, { children: `${minutes}:${seconds < 10 ? `0${seconds}` : seconds}` }));
60
60
  };
@@ -9,19 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { ChainId } from '@lifi/sdk';
12
- import { useWatch } from 'react-hook-form';
12
+ import { useFormState, useWatch } from 'react-hook-form';
13
13
  import { useTranslation } from 'react-i18next';
14
14
  import { useNavigate } from 'react-router-dom';
15
15
  import { useChains, useGasSufficiency } from '../../hooks';
16
- import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
17
- import { useWallet } from '../../providers/WalletProvider';
18
- import { useWidgetConfig } from '../../providers/WidgetProvider';
16
+ import { SwapFormKeyHelper, useWallet, useWidgetConfig } from '../../providers';
19
17
  import { navigationRoutes } from '../../utils';
20
18
  import { Button } from './SwapButton.style';
21
19
  export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
22
20
  var _a;
23
- const navigate = useNavigate();
24
21
  const { t } = useTranslation();
22
+ const navigate = useNavigate();
23
+ const { isValid, isValidating } = useFormState();
25
24
  const { getChainById } = useChains();
26
25
  const config = useWidgetConfig();
27
26
  const { account, switchChain, connect: walletConnect } = useWallet();
@@ -64,7 +63,11 @@ export const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
64
63
  };
65
64
  return (_jsx(Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick,
66
65
  // loading={isLoading || isFetching}
67
- disabled: (insufficientFunds || !!insufficientGas.length || loading) &&
66
+ disabled: (insufficientFunds ||
67
+ !!insufficientGas.length ||
68
+ loading ||
69
+ isValidating ||
70
+ !isValid) &&
68
71
  currentRoute &&
69
72
  !switchChainAllowed, fullWidth: true }, { children: getButtonText() })));
70
73
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import type { SwapFormTypeProps } from '../../providers/SwapFormProvider';
2
+ import type { SwapFormTypeProps } from '../../providers';
3
3
  export declare const FormPriceHelperText: React.FC<SwapFormTypeProps & {
4
4
  selected: boolean;
5
5
  }>;
@@ -3,7 +3,7 @@ import { FormHelperText, Skeleton, Typography } from '@mui/material';
3
3
  import { useWatch } from 'react-hook-form';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useTokenBalance } from '../../hooks';
6
- import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
6
+ import { SwapFormKeyHelper } from '../../providers';
7
7
  import { formatTokenPrice } from '../../utils';
8
8
  export const FormPriceHelperText = ({ formType, selected }) => {
9
9
  const { t } = useTranslation();
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import type { SwapFormTypeProps } from '../../providers/SwapFormProvider';
2
+ import type { SwapFormTypeProps } from '../../providers';
3
3
  export declare const SwapInput: React.FC<SwapFormTypeProps>;
@@ -3,7 +3,7 @@ import { useLayoutEffect, useRef } from 'react';
3
3
  import { useFormContext, useWatch } from 'react-hook-form';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useChain, useToken } from '../../hooks';
6
- import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
6
+ import { SwapFormKeyHelper } from '../../providers';
7
7
  import { fitInputText, formatAmount } from '../../utils';
8
8
  import { Card, CardTitle } from '../Card';
9
9
  import { TokenAvatar } from '../TokenAvatar';
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import type { SwapFormTypeProps } from '../../providers/SwapFormProvider';
2
+ import type { SwapFormTypeProps } from '../../providers';
3
3
  export declare const SwapInputAdornment: ({ formType }: SwapFormTypeProps) => JSX.Element;
@@ -3,7 +3,7 @@ import { InputAdornment, Skeleton } from '@mui/material';
3
3
  import { useFormContext, useWatch } from 'react-hook-form';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { useTokenBalance } from '../../hooks';
6
- import { SwapFormKeyHelper } from '../../providers/SwapFormProvider';
6
+ import { SwapFormKeyHelper } from '../../providers';
7
7
  import { Button } from './SwapInputAdornment.style';
8
8
  export const SwapInputAdornment = ({ formType }) => {
9
9
  const { t } = useTranslation();
@@ -20,14 +20,15 @@ export const SwapRouteCard = (_a) => {
20
20
  var _b, _c;
21
21
  var { route, active, dense } = _a, other = __rest(_a, ["route", "active", "dense"]);
22
22
  const { t } = useTranslation();
23
+ const alternativeTag = t(`swap.tags.ALTERNATIVE`);
23
24
  const label = ((_b = route.tags) === null || _b === void 0 ? void 0 : _b.length)
24
- ? t(`swap.tags.${route.tags[0].toLowerCase()}`).toUpperCase()
25
- : t(`swap.tags.general`).toUpperCase();
25
+ ? t(`swap.tags.${route.tags[0]}`)
26
+ : alternativeTag;
26
27
  return (_jsxs(Card, Object.assign({ dense: dense, indented: true }, other, { children: [_jsx(Box, Object.assign({ sx: {
27
28
  display: 'flex',
28
29
  alignItems: 'center',
29
30
  justifyContent: 'space-between',
30
- }, mb: 2 }, { children: _jsx(Label, Object.assign({ active: active }, { children: label })) })), _jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), mb: 2 }), !dense
31
+ }, mb: 2 }, { children: _jsx(Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })) })), _jsx(Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), mb: 2 }), !dense
31
32
  ? route.steps.map((step) => (_jsx(StepActions, { step: step, mb: 2 }, step.id)))
32
33
  : null, _jsxs(Box, Object.assign({ sx: {
33
34
  display: 'flex',
@@ -4,16 +4,16 @@ import { getContrastTextColor } from '../../utils';
4
4
  export const Label = styled(Typography, {
5
5
  shouldForwardProp: (prop) => prop !== 'active',
6
6
  })(({ theme, active }) => ({
7
- backgroundColor: active ? theme.palette.primary.main : 'transparent',
7
+ backgroundColor: active ? theme.palette.secondary.main : 'transparent',
8
8
  border: '1px solid',
9
9
  borderColor: active
10
- ? theme.palette.primary.main
10
+ ? theme.palette.secondary.main
11
11
  : theme.palette.mode === 'light'
12
12
  ? theme.palette.grey[500]
13
13
  : theme.palette.grey[600],
14
14
  borderRadius: theme.shape.borderRadiusSecondary,
15
15
  color: active
16
- ? getContrastTextColor(theme, theme.palette.primary.main)
16
+ ? getContrastTextColor(theme, theme.palette.secondary.main)
17
17
  : theme.palette.text.secondary,
18
18
  padding: theme.spacing(0.75),
19
19
  fontSize: 12,
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ import type { BoxProps } from '@mui/material';
3
+ export declare const SwapsInProgress: React.FC<BoxProps>;
@@ -4,13 +4,13 @@ import { Box, Stack } from '@mui/material';
4
4
  import { useCallback } from 'react';
5
5
  import { useTranslation } from 'react-i18next';
6
6
  import { useNavigate } from 'react-router-dom';
7
- import { useWallet } from '../../providers/WalletProvider';
7
+ import { useWallet } from '../../providers';
8
8
  import { useExecutingRoutes } from '../../stores';
9
9
  import { navigationRoutes } from '../../utils';
10
10
  import { CardTitle } from '../Card';
11
11
  import { TokenAvatar, TokenAvatarGroup } from '../TokenAvatar';
12
- import { ProgressCard, RouteCard } from './SwapInProgress.style';
13
- export const SwapInProgress = (props) => {
12
+ import { ProgressCard, RouteCard } from './SwapsInProgress.style';
13
+ export const SwapsInProgress = (props) => {
14
14
  const { t } = useTranslation();
15
15
  const navigate = useNavigate();
16
16
  const { account } = useWallet();
@@ -21,5 +21,5 @@ export const SwapInProgress = (props) => {
21
21
  if (!(executingRoutes === null || executingRoutes === void 0 ? void 0 : executingRoutes.length)) {
22
22
  return null;
23
23
  }
24
- return (_jsxs(ProgressCard, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.inProgress') }), _jsx(Stack, Object.assign({ spacing: 2, py: 2 }, { children: executingRoutes.map(({ route, status }) => (_jsx(RouteCard, { onClick: () => handleCardClick(route.id), avatar: _jsxs(TokenAvatarGroup, Object.assign({ total: 2 }, { children: [_jsx(TokenAvatar, { token: route.fromToken }), _jsx(TokenAvatar, { token: route.toToken })] })), action: _jsx(KeyboardArrowRightIcon, {}), title: _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: [route.fromToken.symbol, _jsx(ArrowForwardIcon, { fontSize: "small", sx: { paddingX: 0.5 } }), route.toToken.symbol] })) }, route.id))) }))] })));
24
+ return (_jsxs(ProgressCard, Object.assign({}, props, { children: [_jsx(CardTitle, { children: t('swap.activeTransfers') }), _jsx(Stack, Object.assign({ spacing: 2, py: 2 }, { children: executingRoutes.map(({ route, status }) => (_jsx(RouteCard, { onClick: () => handleCardClick(route.id), avatar: _jsxs(TokenAvatarGroup, Object.assign({ total: 2 }, { children: [_jsx(TokenAvatar, { token: route.fromToken }), _jsx(TokenAvatar, { token: route.toToken })] })), action: _jsx(KeyboardArrowRightIcon, {}), title: _jsxs(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: [route.fromToken.symbol, _jsx(ArrowForwardIcon, { fontSize: "small", sx: { paddingX: 0.5 } }), route.toToken.symbol] })) }, route.id))) }))] })));
25
25
  };
@@ -0,0 +1 @@
1
+ export * from './SwapsInProgress';
@@ -0,0 +1 @@
1
+ export * from './SwapsInProgress';
@@ -3,8 +3,7 @@ import { Box } from '@mui/material';
3
3
  import { useCallback, useRef } from 'react';
4
4
  import { useFormContext, useWatch } from 'react-hook-form';
5
5
  import { useDebouncedWatch, useTokenBalances, useTokenSearch, } from '../../hooks';
6
- import { SwapFormKey, SwapFormKeyHelper, } from '../../providers/SwapFormProvider';
7
- import { useWallet } from '../../providers/WalletProvider';
6
+ import { SwapFormKey, SwapFormKeyHelper, useWallet } from '../../providers';
8
7
  import { TokenNotFound } from './TokenNotFound';
9
8
  import { VirtualizedTokenList } from './VirtualizedTokenList';
10
9
  export const TokenList = ({ formType, height, onClick, }) => {
@@ -12,7 +12,7 @@ export const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollEleme
12
12
  const { getVirtualItems, getTotalSize, scrollToIndex } = useVirtualizer({
13
13
  count: tokens.length,
14
14
  getScrollElement: () => scrollElementRef.current,
15
- overscan: 5,
15
+ overscan: 10,
16
16
  paddingEnd: 12,
17
17
  estimateSize: (index) => {
18
18
  var _a, _b;
@@ -1,6 +1,6 @@
1
1
  import type { TokenAmount } from '@lifi/sdk';
2
2
  import type { MutableRefObject } from 'react';
3
- import type { SwapFormDirection } from '../../providers/SwapFormProvider';
3
+ import type { SwapFormDirection } from '../../providers';
4
4
  import type { Token } from '../../types';
5
5
  export interface TokenListProps {
6
6
  formType: SwapFormDirection;