@lifi/widget 1.14.0 → 1.15.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.
- package/cjs/components/Header/Header.js +2 -2
- package/cjs/components/Header/NavigationHeader.js +5 -7
- package/cjs/components/Header/WalletHeader.js +4 -5
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +10 -10
- package/cjs/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +3 -3
- package/cjs/components/{SwapInProgress/SwapInProgress.d.ts → SendToWallet/SendToWallet.d.ts} +1 -1
- package/cjs/components/SendToWallet/SendToWallet.js +53 -0
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +19 -0
- package/cjs/components/SendToWallet/SendToWallet.style.js +15 -0
- package/cjs/components/SendToWallet/index.d.ts +1 -0
- package/cjs/components/{SwapInProgress → SendToWallet}/index.js +1 -1
- package/cjs/components/Step/StepTimer.js +1 -1
- package/cjs/components/SwapButton/SwapButton.js +11 -8
- package/cjs/components/SwapInput/FormPriceHelperText.d.ts +1 -1
- package/cjs/components/SwapInput/FormPriceHelperText.js +4 -4
- package/cjs/components/SwapInput/SwapInput.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInput.js +4 -4
- package/cjs/components/SwapInput/SwapInputAdornment.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.js +4 -4
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +4 -3
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +3 -3
- package/cjs/components/SwapsInProgress/SwapsInProgress.d.ts +3 -0
- package/cjs/components/SwapsInProgress/SwapsInProgress.js +29 -0
- package/cjs/components/{SwapInProgress/SwapInProgress.style.d.ts → SwapsInProgress/SwapsInProgress.style.d.ts} +0 -0
- package/cjs/components/{SwapInProgress/SwapInProgress.style.js → SwapsInProgress/SwapsInProgress.style.js} +0 -0
- package/cjs/components/SwapsInProgress/index.d.ts +1 -0
- package/cjs/components/SwapsInProgress/index.js +17 -0
- package/cjs/components/TokenList/TokenList.js +10 -11
- package/cjs/components/TokenList/VirtualizedTokenList.js +1 -1
- package/cjs/components/TokenList/types.d.ts +1 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +1 -0
- package/cjs/hooks/index.js +1 -0
- package/cjs/hooks/useNavigateBack.d.ts +4 -0
- package/cjs/hooks/useNavigateBack.js +18 -0
- package/cjs/hooks/useSwapRoutes.js +18 -7
- package/cjs/i18n/en/translation.json +13 -8
- package/cjs/i18n/index.d.ts +11 -6
- package/cjs/pages/MainPage/MainPage.js +3 -2
- package/cjs/pages/SelectTokenPage/ChainSelect.d.ts +1 -1
- package/cjs/pages/SelectTokenPage/ChainSelect.js +11 -12
- package/cjs/pages/SelectTokenPage/SearchTokenInput.js +3 -3
- package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +1 -1
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -6
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +6 -6
- package/cjs/pages/SettingsPage/AdvancedPreferences.js +2 -2
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
- package/cjs/pages/SettingsPage/SettingsPage.js +2 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +2 -0
- package/cjs/pages/SettingsPage/ShowDestinationWallet.js +22 -0
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +3 -2
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/cjs/pages/SwapPage/StatusBottomSheet.js +4 -5
- package/cjs/pages/SwapPage/SwapPage.js +2 -2
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/cjs/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -0
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +10 -4
- package/cjs/providers/SwapFormProvider/types.d.ts +3 -1
- package/cjs/providers/SwapFormProvider/types.js +1 -0
- package/cjs/providers/WalletProvider/WalletProvider.js +10 -4
- package/cjs/providers/WalletProvider/types.d.ts +4 -2
- package/cjs/providers/index.d.ts +4 -0
- package/cjs/providers/index.js +20 -0
- package/cjs/stores/settings/types.d.ts +2 -1
- package/cjs/stores/settings/useSettingsStore.d.ts +4 -2
- package/cjs/stores/settings/useSettingsStore.js +1 -0
- package/cjs/types/widget.d.ts +1 -0
- package/cjs/utils/format.js +7 -2
- package/components/Header/Header.js +1 -1
- package/components/Header/NavigationHeader.js +5 -7
- package/components/Header/WalletHeader.js +1 -2
- package/components/ReverseTokensButton/ReverseTokensButton.js +1 -1
- package/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
- package/components/SelectTokenButton/SelectTokenButton.js +1 -1
- package/components/{SwapInProgress/SwapInProgress.d.ts → SendToWallet/SendToWallet.d.ts} +1 -1
- package/components/SendToWallet/SendToWallet.js +49 -0
- package/components/SendToWallet/SendToWallet.style.d.ts +19 -0
- package/components/SendToWallet/SendToWallet.style.js +12 -0
- package/components/SendToWallet/index.d.ts +1 -0
- package/components/SendToWallet/index.js +1 -0
- package/components/Step/StepTimer.js +1 -1
- package/components/SwapButton/SwapButton.js +9 -6
- package/components/SwapInput/FormPriceHelperText.d.ts +1 -1
- package/components/SwapInput/FormPriceHelperText.js +1 -1
- package/components/SwapInput/SwapInput.d.ts +1 -1
- package/components/SwapInput/SwapInput.js +1 -1
- package/components/SwapInput/SwapInputAdornment.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.js +1 -1
- package/components/SwapRouteCard/SwapRouteCard.js +4 -3
- package/components/SwapRouteCard/SwapRouteCard.style.js +3 -3
- package/components/SwapsInProgress/SwapsInProgress.d.ts +3 -0
- package/components/{SwapInProgress/SwapInProgress.js → SwapsInProgress/SwapsInProgress.js} +4 -4
- package/components/{SwapInProgress/SwapInProgress.style.d.ts → SwapsInProgress/SwapsInProgress.style.d.ts} +0 -0
- package/components/{SwapInProgress/SwapInProgress.style.js → SwapsInProgress/SwapsInProgress.style.js} +0 -0
- package/components/SwapsInProgress/index.d.ts +1 -0
- package/components/SwapsInProgress/index.js +1 -0
- package/components/TokenList/TokenList.js +1 -2
- package/components/TokenList/VirtualizedTokenList.js +1 -1
- package/components/TokenList/types.d.ts +1 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useNavigateBack.d.ts +4 -0
- package/hooks/useNavigateBack.js +14 -0
- package/hooks/useSwapRoutes.js +18 -7
- package/i18n/en/translation.json +13 -8
- package/i18n/index.d.ts +11 -6
- package/package.json +9 -12
- package/pages/MainPage/MainPage.js +3 -2
- package/pages/SelectTokenPage/ChainSelect.d.ts +1 -1
- package/pages/SelectTokenPage/ChainSelect.js +9 -10
- package/pages/SelectTokenPage/SearchTokenInput.js +1 -1
- package/pages/SelectTokenPage/SelectTokenPage.d.ts +1 -1
- package/pages/SelectTokenPage/SelectTokenPage.js +3 -7
- package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
- package/pages/SettingsPage/AdvancedPreferences.js +2 -2
- package/pages/SettingsPage/ColorSchemeButtonGroup.js +1 -1
- package/pages/SettingsPage/SettingsPage.js +2 -1
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +2 -0
- package/pages/SettingsPage/ShowDestinationWallet.js +18 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -3
- package/pages/SwapHistoryPage/SwapHistoryPage.js +1 -1
- package/pages/SwapPage/StatusBottomSheet.js +4 -5
- package/pages/SwapPage/SwapPage.js +4 -4
- package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +10 -4
- package/providers/SwapFormProvider/types.d.ts +3 -1
- package/providers/SwapFormProvider/types.js +1 -0
- package/providers/WalletProvider/WalletProvider.js +10 -4
- package/providers/WalletProvider/types.d.ts +4 -2
- package/providers/index.d.ts +4 -0
- package/providers/index.js +4 -0
- package/stores/settings/types.d.ts +2 -1
- package/stores/settings/useSettingsStore.d.ts +4 -2
- package/stores/settings/useSettingsStore.js +1 -0
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +1 -0
- package/utils/format.js +7 -2
- package/cjs/components/SwapInProgress/SwapInProgress.js +0 -29
- package/cjs/components/SwapInProgress/index.d.ts +0 -1
- package/components/SwapInProgress/index.d.ts +0 -1
- package/components/SwapInProgress/index.js +0 -1
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Header = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
-
const
|
|
6
|
+
const providers_1 = require("../../providers");
|
|
7
7
|
const utils_1 = require("../../utils");
|
|
8
8
|
const Header_style_1 = require("./Header.style");
|
|
9
9
|
const NavigationHeader_1 = require("./NavigationHeader");
|
|
@@ -21,7 +21,7 @@ const HeaderContainer = ({ children }) => {
|
|
|
21
21
|
return ((0, jsx_runtime_1.jsx)(Header_style_1.Container, Object.assign({ id: utils_1.ElementId.Header, sticky: stickyHeaderRoutes.some((route) => pathname.includes(route)) }, { children: children })));
|
|
22
22
|
};
|
|
23
23
|
const Header = () => {
|
|
24
|
-
const { walletManagement } = (0,
|
|
24
|
+
const { walletManagement } = (0, providers_1.useWidgetConfig)();
|
|
25
25
|
return ((0, jsx_runtime_1.jsxs)(HeaderContainer, { children: [!walletManagement ? (0, jsx_runtime_1.jsx)(WalletHeader_1.WalletHeader, {}) : null, (0, jsx_runtime_1.jsx)(NavigationHeader_1.NavigationHeader, {})] }));
|
|
26
26
|
};
|
|
27
27
|
exports.Header = Header;
|
|
@@ -6,7 +6,8 @@ const icons_material_1 = require("@mui/icons-material");
|
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
8
|
const react_router_dom_1 = require("react-router-dom");
|
|
9
|
-
const
|
|
9
|
+
const hooks_1 = require("../../hooks");
|
|
10
|
+
const providers_1 = require("../../providers");
|
|
10
11
|
const utils_1 = require("../../utils");
|
|
11
12
|
const Header_style_1 = require("./Header.style");
|
|
12
13
|
const useHeaderActionStore_1 = require("./useHeaderActionStore");
|
|
@@ -22,15 +23,12 @@ const backButtonRoutes = [
|
|
|
22
23
|
];
|
|
23
24
|
const NavigationHeader = () => {
|
|
24
25
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
25
|
-
const navigate = (0,
|
|
26
|
-
const { account } = (0,
|
|
26
|
+
const { navigate, navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
27
|
+
const { account } = (0, providers_1.useWallet)();
|
|
27
28
|
const { element } = (0, useHeaderActionStore_1.useHeaderActionStore)();
|
|
28
29
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
29
30
|
const path = pathname.substring(pathname.lastIndexOf('/') + 1);
|
|
30
31
|
const hasPath = utils_1.navigationRoutesValues.includes(path);
|
|
31
|
-
const handleBack = () => {
|
|
32
|
-
navigate(-1);
|
|
33
|
-
};
|
|
34
32
|
const handleHeaderTitle = () => {
|
|
35
33
|
switch (path) {
|
|
36
34
|
case utils_1.navigationRoutes.selectWallet:
|
|
@@ -53,6 +51,6 @@ const NavigationHeader = () => {
|
|
|
53
51
|
return t(`header.swap`);
|
|
54
52
|
}
|
|
55
53
|
};
|
|
56
|
-
return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick:
|
|
54
|
+
return ((0, jsx_runtime_1.jsxs)(Header_style_1.HeaderAppBar, Object.assign({ elevation: 0 }, { children: [backButtonRoutes.includes(path) ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "start", onClick: navigateBack }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.ArrowBack, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ fontSize: hasPath ? 18 : 24, align: hasPath ? 'center' : 'left', fontWeight: "700", flex: 1, noWrap: true }, { children: handleHeaderTitle() })), (0, jsx_runtime_1.jsxs)(react_router_dom_1.Routes, { children: [(0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: utils_1.navigationRoutes.home, element: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [account.isActive ? ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "swap-history", edge: "start", onClick: () => navigate(utils_1.navigationRoutes.swapHistory) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.History, {}) }))) : null, (0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ size: "medium", "aria-label": "settings", edge: "end", onClick: () => navigate(utils_1.navigationRoutes.settings) }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.SettingsOutlined, {}) }))] }) }), (0, jsx_runtime_1.jsx)(react_router_dom_1.Route, { path: "*", element: element || (0, jsx_runtime_1.jsx)(material_1.Box, { width: 28, height: 40 }) })] })] })));
|
|
57
55
|
};
|
|
58
56
|
exports.NavigationHeader = NavigationHeader;
|
|
@@ -15,13 +15,12 @@ const icons_material_1 = require("@mui/icons-material");
|
|
|
15
15
|
const material_1 = require("@mui/material");
|
|
16
16
|
const react_i18next_1 = require("react-i18next");
|
|
17
17
|
const react_router_dom_1 = require("react-router-dom");
|
|
18
|
-
const
|
|
19
|
-
const WidgetProvider_1 = require("../../providers/WidgetProvider");
|
|
18
|
+
const providers_1 = require("../../providers");
|
|
20
19
|
const utils_1 = require("../../utils");
|
|
21
20
|
const Header_style_1 = require("./Header.style");
|
|
22
21
|
const WalletHeader = () => {
|
|
23
22
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
24
|
-
const { account, disconnect } = (0,
|
|
23
|
+
const { account, disconnect } = (0, providers_1.useWallet)();
|
|
25
24
|
const walletAddress = account.address
|
|
26
25
|
? `${account.address.substring(0, 7)}...${account.address.substring(account.address.length - 7)}`
|
|
27
26
|
: null;
|
|
@@ -34,8 +33,8 @@ const WalletHeader = () => {
|
|
|
34
33
|
exports.WalletHeader = WalletHeader;
|
|
35
34
|
const ConnectButton = () => {
|
|
36
35
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
37
|
-
const config = (0,
|
|
38
|
-
const { connect: walletConnect } = (0,
|
|
36
|
+
const config = (0, providers_1.useWidgetConfig)();
|
|
37
|
+
const { connect: walletConnect } = (0, providers_1.useWallet)();
|
|
39
38
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
40
39
|
const connect = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
40
|
if (config.walletManagement) {
|
|
@@ -4,22 +4,22 @@ exports.ReverseTokensButton = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
|
-
const
|
|
7
|
+
const providers_1 = require("../../providers");
|
|
8
8
|
const ReverseTokensButton_style_1 = require("./ReverseTokensButton.style");
|
|
9
9
|
const ReverseTokensButton = ({ vertical, }) => {
|
|
10
10
|
const { setValue, getValues } = (0, react_hook_form_1.useFormContext)();
|
|
11
11
|
const handleClick = () => {
|
|
12
12
|
const [fromChain, fromToken, toChain, toToken] = getValues([
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
providers_1.SwapFormKey.FromChain,
|
|
14
|
+
providers_1.SwapFormKey.FromToken,
|
|
15
|
+
providers_1.SwapFormKey.ToChain,
|
|
16
|
+
providers_1.SwapFormKey.ToToken,
|
|
17
17
|
]);
|
|
18
|
-
setValue(
|
|
19
|
-
setValue(
|
|
20
|
-
setValue(
|
|
21
|
-
setValue(
|
|
22
|
-
setValue(
|
|
18
|
+
setValue(providers_1.SwapFormKey.FromAmount, '');
|
|
19
|
+
setValue(providers_1.SwapFormKey.FromChain, toChain);
|
|
20
|
+
setValue(providers_1.SwapFormKey.FromToken, toToken);
|
|
21
|
+
setValue(providers_1.SwapFormKey.ToChain, fromChain);
|
|
22
|
+
setValue(providers_1.SwapFormKey.ToToken, fromToken);
|
|
23
23
|
};
|
|
24
24
|
return ((0, jsx_runtime_1.jsx)(ReverseTokensButton_style_1.IconButton, Object.assign({ onClick: handleClick, size: "small", "aria-label": "swap-destinations" }, { children: vertical ? (0, jsx_runtime_1.jsx)(icons_material_1.SwapVert, {}) : (0, jsx_runtime_1.jsx)(icons_material_1.SwapHoriz, {}) })));
|
|
25
25
|
};
|
|
@@ -8,7 +8,7 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
8
8
|
const react_i18next_1 = require("react-i18next");
|
|
9
9
|
const react_router_dom_1 = require("react-router-dom");
|
|
10
10
|
const hooks_1 = require("../../hooks");
|
|
11
|
-
const
|
|
11
|
+
const providers_1 = require("../../providers");
|
|
12
12
|
const utils_1 = require("../../utils");
|
|
13
13
|
const Card_1 = require("../Card");
|
|
14
14
|
const TokenAvatar_1 = require("../TokenAvatar");
|
|
@@ -18,8 +18,8 @@ const SelectTokenButton = ({ formType, compact }) => {
|
|
|
18
18
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
19
19
|
const [chainId, tokenAddress] = (0, react_hook_form_1.useWatch)({
|
|
20
20
|
name: [
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
providers_1.SwapFormKeyHelper.getChainKey(formType),
|
|
22
|
+
providers_1.SwapFormKeyHelper.getTokenKey(formType),
|
|
23
23
|
],
|
|
24
24
|
});
|
|
25
25
|
const { chain, isLoading: isChainLoading } = (0, hooks_1.useChain)(chainId);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SendToWallet = void 0;
|
|
13
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
14
|
+
const address_1 = require("@ethersproject/address");
|
|
15
|
+
const material_1 = require("@mui/material");
|
|
16
|
+
const react_1 = require("react");
|
|
17
|
+
const react_hook_form_1 = require("react-hook-form");
|
|
18
|
+
const react_i18next_1 = require("react-i18next");
|
|
19
|
+
const providers_1 = require("../../providers");
|
|
20
|
+
const stores_1 = require("../../stores");
|
|
21
|
+
const Card_1 = require("../Card");
|
|
22
|
+
const SendToWallet_style_1 = require("./SendToWallet.style");
|
|
23
|
+
const SendToWallet = (props) => {
|
|
24
|
+
var _a;
|
|
25
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
26
|
+
const { showDestinationWallet } = (0, stores_1.useSettings)(['showDestinationWallet']);
|
|
27
|
+
const { account, provider } = (0, providers_1.useWallet)();
|
|
28
|
+
const { register, trigger, formState: { errors }, } = (0, react_hook_form_1.useFormContext)();
|
|
29
|
+
const { onChange, onBlur, name, ref } = register(providers_1.SwapFormKey.ToAddress, {
|
|
30
|
+
validate: (value) => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
try {
|
|
32
|
+
if (!value) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
const address = yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(value));
|
|
36
|
+
return ((0, address_1.isAddress)(address || value) ||
|
|
37
|
+
t('swap.error.title.walletAddressInvalid'));
|
|
38
|
+
}
|
|
39
|
+
catch (_b) {
|
|
40
|
+
return t('swap.error.title.walletEnsAddressInvalid');
|
|
41
|
+
}
|
|
42
|
+
}),
|
|
43
|
+
onBlur: () => trigger(providers_1.SwapFormKey.ToAddress),
|
|
44
|
+
});
|
|
45
|
+
(0, react_1.useEffect)(() => {
|
|
46
|
+
trigger(providers_1.SwapFormKey.ToAddress);
|
|
47
|
+
}, [account.chainId, trigger]);
|
|
48
|
+
if (!showDestinationWallet) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.sendToWallet') }), (0, jsx_runtime_1.jsxs)(SendToWallet_style_1.FormControl, Object.assign({ fullWidth: true }, { children: [(0, jsx_runtime_1.jsx)(SendToWallet_style_1.Input, { ref: ref, size: "small", autoComplete: "off", autoCorrect: "off", autoCapitalize: "off", spellCheck: "false", onChange: onChange, onBlur: onBlur, name: name, placeholder: t('swap.walletAddressOrEns') }), (0, jsx_runtime_1.jsx)(material_1.FormHelperText, Object.assign({ error: !!errors.toAddress }, { children: (_a = errors.toAddress) === null || _a === void 0 ? void 0 : _a.message }))] }))] })));
|
|
52
|
+
};
|
|
53
|
+
exports.SendToWallet = SendToWallet;
|
|
@@ -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,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Input = exports.FormControl = void 0;
|
|
4
|
+
const material_1 = require("@mui/material");
|
|
5
|
+
const InputBase_1 = require("@mui/material/InputBase");
|
|
6
|
+
const styles_1 = require("@mui/material/styles");
|
|
7
|
+
exports.FormControl = (0, styles_1.styled)(material_1.FormControl)(({ theme }) => ({
|
|
8
|
+
padding: theme.spacing(1.5, 2, 1.5, 0),
|
|
9
|
+
}));
|
|
10
|
+
exports.Input = (0, styles_1.styled)(material_1.InputBase)(({ theme }) => ({
|
|
11
|
+
[`.${InputBase_1.inputBaseClasses.input}`]: {
|
|
12
|
+
height: 32,
|
|
13
|
+
padding: theme.spacing(0, 0, 0, 2),
|
|
14
|
+
},
|
|
15
|
+
}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SendToWallet';
|
|
@@ -14,4 +14,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./SendToWallet"), exports);
|
|
@@ -57,7 +57,7 @@ const StepTimer = ({ step }) => {
|
|
|
57
57
|
((_b = step.execution) === null || _b === void 0 ? void 0 : _b.status) === 'FAILED') {
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
|
-
return isExpired ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: t('swap.
|
|
60
|
+
return isExpired ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: t('swap.inProgress') })) : (
|
|
61
61
|
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
62
62
|
(0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: `${minutes}:${seconds < 10 ? `0${seconds}` : seconds}` }));
|
|
63
63
|
};
|
|
@@ -16,21 +16,20 @@ const react_hook_form_1 = require("react-hook-form");
|
|
|
16
16
|
const react_i18next_1 = require("react-i18next");
|
|
17
17
|
const react_router_dom_1 = require("react-router-dom");
|
|
18
18
|
const hooks_1 = require("../../hooks");
|
|
19
|
-
const
|
|
20
|
-
const WalletProvider_1 = require("../../providers/WalletProvider");
|
|
21
|
-
const WidgetProvider_1 = require("../../providers/WidgetProvider");
|
|
19
|
+
const providers_1 = require("../../providers");
|
|
22
20
|
const utils_1 = require("../../utils");
|
|
23
21
|
const SwapButton_style_1 = require("./SwapButton.style");
|
|
24
22
|
const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
25
23
|
var _a;
|
|
26
|
-
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
27
24
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
25
|
+
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
26
|
+
const { isValid, isValidating } = (0, react_hook_form_1.useFormState)();
|
|
28
27
|
const { getChainById } = (0, hooks_1.useChains)();
|
|
29
|
-
const config = (0,
|
|
30
|
-
const { account, switchChain, connect: walletConnect } = (0,
|
|
28
|
+
const config = (0, providers_1.useWidgetConfig)();
|
|
29
|
+
const { account, switchChain, connect: walletConnect } = (0, providers_1.useWallet)();
|
|
31
30
|
const { insufficientFunds, insufficientGas } = (0, hooks_1.useGasSufficiency)(currentRoute);
|
|
32
31
|
const [chainId] = (0, react_hook_form_1.useWatch)({
|
|
33
|
-
name: [
|
|
32
|
+
name: [providers_1.SwapFormKeyHelper.getChainKey('from')],
|
|
34
33
|
});
|
|
35
34
|
// Allow switching chain only if execution is not started
|
|
36
35
|
const switchChainAllowed = ((_a = getChainById(chainId || sdk_1.ChainId.ETH)) === null || _a === void 0 ? void 0 : _a.id) !== account.chainId &&
|
|
@@ -67,7 +66,11 @@ const SwapButton = ({ onClick, currentRoute, text, loading, }) => {
|
|
|
67
66
|
};
|
|
68
67
|
return ((0, jsx_runtime_1.jsx)(SwapButton_style_1.Button, Object.assign({ variant: "contained", color: account.isActive ? 'primary' : 'success', onClick: handleSwapButtonClick,
|
|
69
68
|
// loading={isLoading || isFetching}
|
|
70
|
-
disabled: (insufficientFunds ||
|
|
69
|
+
disabled: (insufficientFunds ||
|
|
70
|
+
!!insufficientGas.length ||
|
|
71
|
+
loading ||
|
|
72
|
+
isValidating ||
|
|
73
|
+
!isValid) &&
|
|
71
74
|
currentRoute &&
|
|
72
75
|
!switchChainAllowed, fullWidth: true }, { children: getButtonText() })));
|
|
73
76
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { SwapFormTypeProps } from '../../providers
|
|
2
|
+
import type { SwapFormTypeProps } from '../../providers';
|
|
3
3
|
export declare const FormPriceHelperText: React.FC<SwapFormTypeProps & {
|
|
4
4
|
selected: boolean;
|
|
5
5
|
}>;
|
|
@@ -6,15 +6,15 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
|
-
const
|
|
9
|
+
const providers_1 = require("../../providers");
|
|
10
10
|
const utils_1 = require("../../utils");
|
|
11
11
|
const FormPriceHelperText = ({ formType, selected }) => {
|
|
12
12
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
13
13
|
const [amount, chainId, tokenAddress] = (0, react_hook_form_1.useWatch)({
|
|
14
14
|
name: [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
providers_1.SwapFormKeyHelper.getAmountKey(formType),
|
|
16
|
+
providers_1.SwapFormKeyHelper.getChainKey(formType),
|
|
17
|
+
providers_1.SwapFormKeyHelper.getTokenKey(formType),
|
|
18
18
|
],
|
|
19
19
|
});
|
|
20
20
|
const { token, isLoading } = (0, hooks_1.useTokenBalance)(chainId, tokenAddress);
|
|
@@ -6,7 +6,7 @@ const react_1 = require("react");
|
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
|
-
const
|
|
9
|
+
const providers_1 = require("../../providers");
|
|
10
10
|
const utils_1 = require("../../utils");
|
|
11
11
|
const Card_1 = require("../Card");
|
|
12
12
|
const TokenAvatar_1 = require("../TokenAvatar");
|
|
@@ -17,12 +17,12 @@ const SwapInput = ({ formType }) => {
|
|
|
17
17
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
18
|
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
19
19
|
const ref = (0, react_1.useRef)(null);
|
|
20
|
-
const amountKey =
|
|
20
|
+
const amountKey = providers_1.SwapFormKeyHelper.getAmountKey(formType);
|
|
21
21
|
const [amount, chainId, tokenAddress] = (0, react_hook_form_1.useWatch)({
|
|
22
22
|
name: [
|
|
23
23
|
amountKey,
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
providers_1.SwapFormKeyHelper.getChainKey(formType),
|
|
25
|
+
providers_1.SwapFormKeyHelper.getTokenKey(formType),
|
|
26
26
|
],
|
|
27
27
|
});
|
|
28
28
|
const { chain } = (0, hooks_1.useChain)(chainId);
|
|
@@ -6,21 +6,21 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const react_hook_form_1 = require("react-hook-form");
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
|
-
const
|
|
9
|
+
const providers_1 = require("../../providers");
|
|
10
10
|
const SwapInputAdornment_style_1 = require("./SwapInputAdornment.style");
|
|
11
11
|
const SwapInputAdornment = ({ formType }) => {
|
|
12
12
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
13
13
|
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
14
14
|
const [chainId, tokenAddress] = (0, react_hook_form_1.useWatch)({
|
|
15
15
|
name: [
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
providers_1.SwapFormKeyHelper.getChainKey(formType),
|
|
17
|
+
providers_1.SwapFormKeyHelper.getTokenKey(formType),
|
|
18
18
|
],
|
|
19
19
|
});
|
|
20
20
|
const { token, isLoading } = (0, hooks_1.useTokenBalance)(chainId, tokenAddress);
|
|
21
21
|
const handleMax = () => {
|
|
22
22
|
var _a;
|
|
23
|
-
setValue(
|
|
23
|
+
setValue(providers_1.SwapFormKeyHelper.getAmountKey(formType), (_a = token === null || token === void 0 ? void 0 : token.amount) !== null && _a !== void 0 ? _a : '');
|
|
24
24
|
};
|
|
25
25
|
return ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: isLoading && tokenAddress ? ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: 46, height: 20, sx: { borderRadius: 0.5 } })) : formType === 'from' && (token === null || token === void 0 ? void 0 : token.amount) ? ((0, jsx_runtime_1.jsx)(SwapInputAdornment_style_1.Button, Object.assign({ onClick: handleMax, variant: "outlined" }, { children: t('button.max') }))) : null })));
|
|
26
26
|
};
|
|
@@ -23,14 +23,15 @@ const SwapRouteCard = (_a) => {
|
|
|
23
23
|
var _b, _c;
|
|
24
24
|
var { route, active, dense } = _a, other = __rest(_a, ["route", "active", "dense"]);
|
|
25
25
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
26
|
+
const alternativeTag = t(`swap.tags.ALTERNATIVE`);
|
|
26
27
|
const label = ((_b = route.tags) === null || _b === void 0 ? void 0 : _b.length)
|
|
27
|
-
? t(`swap.tags.${route.tags[0]
|
|
28
|
-
:
|
|
28
|
+
? t(`swap.tags.${route.tags[0]}`)
|
|
29
|
+
: alternativeTag;
|
|
29
30
|
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({ dense: dense, indented: true }, other, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: {
|
|
30
31
|
display: 'flex',
|
|
31
32
|
alignItems: 'center',
|
|
32
33
|
justifyContent: 'space-between',
|
|
33
|
-
}, mb: 2 }, { children: (0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.Label, Object.assign({ active: active }, { children: label })) })), (0, jsx_runtime_1.jsx)(Token_1.Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), mb: 2 }), !dense
|
|
34
|
+
}, mb: 2 }, { children: (0, jsx_runtime_1.jsx)(SwapRouteCard_style_1.Label, Object.assign({ active: active !== null && active !== void 0 ? active : label !== alternativeTag }, { children: label })) })), (0, jsx_runtime_1.jsx)(Token_1.Token, { token: Object.assign(Object.assign({}, route.toToken), { amount: route.toAmount }), mb: 2 }), !dense
|
|
34
35
|
? route.steps.map((step) => ((0, jsx_runtime_1.jsx)(StepActions_1.StepActions, { step: step, mb: 2 }, step.id)))
|
|
35
36
|
: null, (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
|
|
36
37
|
display: 'flex',
|
|
@@ -7,16 +7,16 @@ const utils_1 = require("../../utils");
|
|
|
7
7
|
exports.Label = (0, styles_1.styled)(material_1.Typography, {
|
|
8
8
|
shouldForwardProp: (prop) => prop !== 'active',
|
|
9
9
|
})(({ theme, active }) => ({
|
|
10
|
-
backgroundColor: active ? theme.palette.
|
|
10
|
+
backgroundColor: active ? theme.palette.secondary.main : 'transparent',
|
|
11
11
|
border: '1px solid',
|
|
12
12
|
borderColor: active
|
|
13
|
-
? theme.palette.
|
|
13
|
+
? theme.palette.secondary.main
|
|
14
14
|
: theme.palette.mode === 'light'
|
|
15
15
|
? theme.palette.grey[500]
|
|
16
16
|
: theme.palette.grey[600],
|
|
17
17
|
borderRadius: theme.shape.borderRadiusSecondary,
|
|
18
18
|
color: active
|
|
19
|
-
? (0, utils_1.getContrastTextColor)(theme, theme.palette.
|
|
19
|
+
? (0, utils_1.getContrastTextColor)(theme, theme.palette.secondary.main)
|
|
20
20
|
: theme.palette.text.secondary,
|
|
21
21
|
padding: theme.spacing(0.75),
|
|
22
22
|
fontSize: 12,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SwapsInProgress = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const icons_material_1 = require("@mui/icons-material");
|
|
6
|
+
const material_1 = require("@mui/material");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const react_i18next_1 = require("react-i18next");
|
|
9
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
10
|
+
const providers_1 = require("../../providers");
|
|
11
|
+
const stores_1 = require("../../stores");
|
|
12
|
+
const utils_1 = require("../../utils");
|
|
13
|
+
const Card_1 = require("../Card");
|
|
14
|
+
const TokenAvatar_1 = require("../TokenAvatar");
|
|
15
|
+
const SwapsInProgress_style_1 = require("./SwapsInProgress.style");
|
|
16
|
+
const SwapsInProgress = (props) => {
|
|
17
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
|
+
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
19
|
+
const { account } = (0, providers_1.useWallet)();
|
|
20
|
+
const executingRoutes = (0, stores_1.useExecutingRoutes)(account.address);
|
|
21
|
+
const handleCardClick = (0, react_1.useCallback)((routeId) => {
|
|
22
|
+
navigate(utils_1.navigationRoutes.swapExecution, { state: { routeId } });
|
|
23
|
+
}, [navigate]);
|
|
24
|
+
if (!(executingRoutes === null || executingRoutes === void 0 ? void 0 : executingRoutes.length)) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)(SwapsInProgress_style_1.ProgressCard, Object.assign({}, props, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t('swap.activeTransfers') }), (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({ spacing: 2, py: 2 }, { children: executingRoutes.map(({ route, status }) => ((0, jsx_runtime_1.jsx)(SwapsInProgress_style_1.RouteCard, { onClick: () => handleCardClick(route.id), avatar: (0, jsx_runtime_1.jsxs)(TokenAvatar_1.TokenAvatarGroup, Object.assign({ total: 2 }, { children: [(0, jsx_runtime_1.jsx)(TokenAvatar_1.TokenAvatar, { token: route.fromToken }), (0, jsx_runtime_1.jsx)(TokenAvatar_1.TokenAvatar, { token: route.toToken })] })), action: (0, jsx_runtime_1.jsx)(icons_material_1.KeyboardArrowRight, {}), title: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: [route.fromToken.symbol, (0, jsx_runtime_1.jsx)(icons_material_1.ArrowForward, { fontSize: "small", sx: { paddingX: 0.5 } }), route.toToken.symbol] })) }, route.id))) }))] })));
|
|
28
|
+
};
|
|
29
|
+
exports.SwapsInProgress = SwapsInProgress;
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SwapsInProgress';
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./SwapsInProgress"), exports);
|
|
@@ -6,19 +6,18 @@ const material_1 = require("@mui/material");
|
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const react_hook_form_1 = require("react-hook-form");
|
|
8
8
|
const hooks_1 = require("../../hooks");
|
|
9
|
-
const
|
|
10
|
-
const WalletProvider_1 = require("../../providers/WalletProvider");
|
|
9
|
+
const providers_1 = require("../../providers");
|
|
11
10
|
const TokenNotFound_1 = require("./TokenNotFound");
|
|
12
11
|
const VirtualizedTokenList_1 = require("./VirtualizedTokenList");
|
|
13
12
|
const TokenList = ({ formType, height, onClick, }) => {
|
|
14
13
|
var _a, _b;
|
|
15
14
|
const parentRef = (0, react_1.useRef)(null);
|
|
16
|
-
const { account } = (0,
|
|
15
|
+
const { account } = (0, providers_1.useWallet)();
|
|
17
16
|
const { setValue, getValues } = (0, react_hook_form_1.useFormContext)();
|
|
18
17
|
const [selectedChainId] = (0, react_hook_form_1.useWatch)({
|
|
19
|
-
name: [
|
|
18
|
+
name: [providers_1.SwapFormKeyHelper.getChainKey(formType)],
|
|
20
19
|
});
|
|
21
|
-
const [tokenSearchFilter] = (0, hooks_1.useDebouncedWatch)([
|
|
20
|
+
const [tokenSearchFilter] = (0, hooks_1.useDebouncedWatch)([providers_1.SwapFormKey.TokenSearchFilter], 250);
|
|
22
21
|
const { tokens: chainTokens, tokensWithBalance, isLoading: isTokensLoading, isBalanceLoading, featuredTokens, } = (0, hooks_1.useTokenBalances)(selectedChainId);
|
|
23
22
|
let filteredTokens = ((_a = tokensWithBalance !== null && tokensWithBalance !== void 0 ? tokensWithBalance : chainTokens) !== null && _a !== void 0 ? _a : []);
|
|
24
23
|
const searchFilter = (_b = tokenSearchFilter === null || tokenSearchFilter === void 0 ? void 0 : tokenSearchFilter.toUpperCase()) !== null && _b !== void 0 ? _b : '';
|
|
@@ -36,17 +35,17 @@ const TokenList = ({ formType, height, onClick, }) => {
|
|
|
36
35
|
? [searchedToken]
|
|
37
36
|
: filteredTokens;
|
|
38
37
|
const handleTokenClick = (0, react_1.useCallback)((tokenAddress) => {
|
|
39
|
-
setValue(
|
|
40
|
-
setValue(
|
|
38
|
+
setValue(providers_1.SwapFormKeyHelper.getTokenKey(formType), tokenAddress);
|
|
39
|
+
setValue(providers_1.SwapFormKeyHelper.getAmountKey(formType), '');
|
|
41
40
|
const oppositeFormType = formType === 'from' ? 'to' : 'from';
|
|
42
41
|
const [selectedOppositeToken, selectedOppositeChain, selectedChain] = getValues([
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
providers_1.SwapFormKeyHelper.getTokenKey(oppositeFormType),
|
|
43
|
+
providers_1.SwapFormKeyHelper.getChainKey(oppositeFormType),
|
|
44
|
+
providers_1.SwapFormKeyHelper.getChainKey(formType),
|
|
46
45
|
]);
|
|
47
46
|
if (selectedOppositeToken === tokenAddress &&
|
|
48
47
|
selectedOppositeChain === selectedChain) {
|
|
49
|
-
setValue(
|
|
48
|
+
setValue(providers_1.SwapFormKeyHelper.getTokenKey(oppositeFormType), '');
|
|
50
49
|
}
|
|
51
50
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
52
51
|
}, [formType, getValues, onClick, setValue]);
|
|
@@ -15,7 +15,7 @@ const VirtualizedTokenList = ({ tokens, featuredTokensLength, scrollElementRef,
|
|
|
15
15
|
const { getVirtualItems, getTotalSize, scrollToIndex } = (0, react_virtual_1.useVirtualizer)({
|
|
16
16
|
count: tokens.length,
|
|
17
17
|
getScrollElement: () => scrollElementRef.current,
|
|
18
|
-
overscan:
|
|
18
|
+
overscan: 10,
|
|
19
19
|
paddingEnd: 12,
|
|
20
20
|
estimateSize: (index) => {
|
|
21
21
|
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
|
|
3
|
+
import type { SwapFormDirection } from '../../providers';
|
|
4
4
|
import type { Token } from '../../types';
|
|
5
5
|
export interface TokenListProps {
|
|
6
6
|
formType: SwapFormDirection;
|
package/cjs/config/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const name = "@lifi/widget";
|
|
2
|
-
export declare const version = "1.
|
|
2
|
+
export declare const version = "1.15.1";
|
package/cjs/config/version.js
CHANGED
package/cjs/hooks/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './useDebouncedWatch';
|
|
|
5
5
|
export * from './useFeaturedTokens';
|
|
6
6
|
export * from './useGasSufficiency';
|
|
7
7
|
export * from './useInitializer';
|
|
8
|
+
export * from './useNavigateBack';
|
|
8
9
|
export * from './useRouteExecution';
|
|
9
10
|
export * from './useScrollableContainer';
|
|
10
11
|
export * from './useSwapRoutes';
|
package/cjs/hooks/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __exportStar(require("./useDebouncedWatch"), exports);
|
|
|
21
21
|
__exportStar(require("./useFeaturedTokens"), exports);
|
|
22
22
|
__exportStar(require("./useGasSufficiency"), exports);
|
|
23
23
|
__exportStar(require("./useInitializer"), exports);
|
|
24
|
+
__exportStar(require("./useNavigateBack"), exports);
|
|
24
25
|
__exportStar(require("./useRouteExecution"), exports);
|
|
25
26
|
__exportStar(require("./useScrollableContainer"), exports);
|
|
26
27
|
__exportStar(require("./useSwapRoutes"), exports);
|