@lifi/widget 1.14.1 → 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.
- 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/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 +3 -2
- 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/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 +3 -2
- 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
|
@@ -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
|
}
|
|
@@ -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);
|
|
@@ -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',
|
package/cjs/types/widget.d.ts
CHANGED
package/cjs/utils/format.js
CHANGED
|
@@ -68,8 +68,13 @@ const formatAmount = (amount = '', returnInitial = false) => {
|
|
|
68
68
|
if (parsedAmount < 0) {
|
|
69
69
|
return Math.abs(parsedAmount).toString();
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
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
|
|
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
|
|
6
|
-
import {
|
|
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 =
|
|
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:
|
|
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
|
|
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
|
|
4
|
+
import { SwapFormKey } from '../../providers';
|
|
5
5
|
import { IconButton } from './ReverseTokensButton.style';
|
|
6
6
|
export const ReverseTokensButton = ({ vertical, }) => {
|
|
7
7
|
const { setValue, getValues } = useFormContext();
|
|
@@ -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
|
|
8
|
+
import { SwapFormKeyHelper } from '../../providers';
|
|
9
9
|
import { navigationRoutes } from '../../utils';
|
|
10
10
|
import { Card, CardTitle } from '../Card';
|
|
11
11
|
import { TokenAvatar } from '../TokenAvatar';
|
|
@@ -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.
|
|
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
|
|
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 ||
|
|
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
|
|
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
|
|
6
|
+
import { SwapFormKeyHelper } from '../../providers';
|
|
7
7
|
import { formatTokenPrice } from '../../utils';
|
|
8
8
|
export const FormPriceHelperText = ({ formType, selected }) => {
|
|
9
9
|
const { t } = useTranslation();
|
|
@@ -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
|
|
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';
|
|
@@ -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
|
|
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]
|
|
25
|
-
:
|
|
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.
|
|
7
|
+
backgroundColor: active ? theme.palette.secondary.main : 'transparent',
|
|
8
8
|
border: '1px solid',
|
|
9
9
|
borderColor: active
|
|
10
|
-
? theme.palette.
|
|
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.
|
|
16
|
+
? getContrastTextColor(theme, theme.palette.secondary.main)
|
|
17
17
|
: theme.palette.text.secondary,
|
|
18
18
|
padding: theme.spacing(0.75),
|
|
19
19
|
fontSize: 12,
|
|
@@ -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
|
|
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 './
|
|
13
|
-
export const
|
|
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.
|
|
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
|
};
|
|
File without changes
|
|
File without changes
|
|
@@ -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
|
|
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, }) => {
|
|
@@ -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/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.0";
|
package/config/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/widget';
|
|
2
|
-
export const version = '1.
|
|
2
|
+
export const version = '1.15.0';
|
package/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/hooks/index.js
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';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
export const useNavigateBack = () => {
|
|
4
|
+
const navigate = useNavigate();
|
|
5
|
+
const navigateBack = useCallback(() => {
|
|
6
|
+
if (window.history.state && window.history.state.idx > 0) {
|
|
7
|
+
navigate(-1);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
navigate(window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')) || '/', { replace: true });
|
|
11
|
+
}
|
|
12
|
+
}, [navigate]);
|
|
13
|
+
return { navigateBack, navigate };
|
|
14
|
+
};
|