@lifi/widget 1.15.1 → 1.16.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/App.js +21 -0
- package/cjs/App.js +21 -0
- package/cjs/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/cjs/components/ActiveSwaps/ActiveSwapItem.js +45 -0
- package/cjs/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
- package/cjs/components/ActiveSwaps/ActiveSwaps.js +30 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
- package/cjs/components/ActiveSwaps/ActiveSwaps.style.js +40 -0
- package/cjs/components/ActiveSwaps/index.d.ts +2 -0
- package/cjs/components/ActiveSwaps/index.js +18 -0
- package/cjs/components/Card/Card.d.ts +7 -4
- package/cjs/components/Card/Card.js +38 -28
- package/cjs/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
- package/cjs/components/ChainSelect/ChainSelect.js +35 -0
- package/cjs/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
- package/cjs/components/ChainSelect/ChainSelect.style.js +19 -0
- package/cjs/components/ChainSelect/index.d.ts +2 -0
- package/cjs/components/ChainSelect/index.js +18 -0
- package/cjs/components/ChainSelect/useChainSelect.d.ts +8 -0
- package/cjs/components/ChainSelect/useChainSelect.js +33 -0
- package/cjs/components/Header/Header.js +1 -9
- package/cjs/components/Header/NavigationHeader.js +6 -11
- package/cjs/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/cjs/components/PoweredBy/PoweredBy.style.js +1 -0
- package/cjs/components/SendToWallet/SendToWallet.js +6 -6
- package/cjs/components/Step/CircularProgress.js +1 -1
- package/cjs/components/Step/CircularProgress.style.js +1 -1
- package/cjs/components/Step/StepProcess.js +1 -5
- package/cjs/components/Step/StepProcess.style.d.ts +1 -1
- package/cjs/components/Step/StepTimer.d.ts +1 -0
- package/cjs/components/Step/StepTimer.js +6 -6
- package/cjs/components/SwapButton/SwapButton.js +5 -12
- package/cjs/components/SwapButton/types.d.ts +2 -2
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +1 -1
- package/cjs/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/cjs/components/TokenList/TokenList.js +6 -2
- package/cjs/config/theme.js +24 -23
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +2 -0
- package/cjs/hooks/index.js +2 -0
- package/cjs/hooks/useChains.d.ts +1 -97
- package/cjs/hooks/useChains.js +8 -15
- package/cjs/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
- package/cjs/{components/Step/utils.js → hooks/useProcessMessage.js} +16 -10
- package/cjs/hooks/useRouteExecution.d.ts +1 -1
- package/cjs/hooks/useRouteExecution.js +20 -29
- package/cjs/hooks/useWidgetEvents.d.ts +3 -0
- package/cjs/hooks/useWidgetEvents.js +13 -0
- package/cjs/i18n/en/translation.json +13 -8
- package/cjs/i18n/index.d.ts +10 -5
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -1
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +18 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
- package/cjs/pages/ActiveSwapsPage/ActiveSwapsPage.js +21 -0
- package/cjs/pages/ActiveSwapsPage/index.d.ts +1 -0
- package/cjs/{components/SwapsInProgress → pages/ActiveSwapsPage}/index.js +1 -1
- package/cjs/pages/MainPage/MainPage.js +2 -3
- package/cjs/pages/MainPage/MainSwapButton.js +3 -1
- package/cjs/pages/MainPage/SwapRoutes.js +4 -1
- package/cjs/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.js +33 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
- package/cjs/pages/SelectChainPage/SelectChainPage.style.js +20 -0
- package/cjs/pages/SelectChainPage/index.d.ts +1 -0
- package/cjs/pages/SelectChainPage/index.js +17 -0
- package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +4 -4
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/cjs/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/cjs/pages/SettingsPage/EnabledBridgesSelect.js +3 -6
- package/cjs/pages/SettingsPage/EnabledExchangesSelect.js +3 -5
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +5 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
- package/cjs/pages/SwapPage/StatusBottomSheet.js +25 -36
- package/cjs/pages/SwapPage/SwapPage.js +5 -1
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +39 -11
- package/cjs/providers/WidgetProvider/WidgetProvider.js +3 -7
- package/cjs/stores/chains/index.d.ts +4 -0
- package/cjs/stores/chains/index.js +20 -0
- package/cjs/stores/chains/types.d.ts +8 -0
- package/cjs/stores/chains/types.js +2 -0
- package/cjs/stores/chains/useChainOrder.d.ts +1 -0
- package/cjs/stores/chains/useChainOrder.js +12 -0
- package/cjs/stores/chains/useChainOrderStore.d.ts +19 -0
- package/cjs/stores/chains/useChainOrderStore.js +42 -0
- package/cjs/stores/chains/useInitializeChainOrder.d.ts +1 -0
- package/cjs/stores/chains/useInitializeChainOrder.js +12 -0
- package/cjs/stores/route/index.d.ts +2 -1
- package/cjs/stores/route/index.js +2 -1
- package/cjs/stores/route/useExecutingRoutesIds.d.ts +1 -0
- package/cjs/stores/route/useExecutingRoutesIds.js +20 -0
- package/cjs/stores/route/useRouteStore.js +5 -4
- package/cjs/stores/route/utils.d.ts +4 -0
- package/cjs/stores/route/utils.js +21 -0
- package/cjs/stores/settings/useSettingsStore.js +5 -2
- package/cjs/types/events.d.ts +5 -0
- package/cjs/types/events.js +9 -0
- package/cjs/types/index.d.ts +1 -0
- package/cjs/types/index.js +1 -0
- package/cjs/types/widget.d.ts +2 -1
- package/cjs/utils/navigationRoutes.d.ts +5 -0
- package/cjs/utils/navigationRoutes.js +31 -4
- package/components/ActiveSwaps/ActiveSwapItem.d.ts +5 -0
- package/components/ActiveSwaps/ActiveSwapItem.js +41 -0
- package/components/{SwapsInProgress/SwapsInProgress.d.ts → ActiveSwaps/ActiveSwaps.d.ts} +1 -1
- package/components/ActiveSwaps/ActiveSwaps.js +26 -0
- package/components/ActiveSwaps/ActiveSwaps.style.d.ts +78 -0
- package/components/ActiveSwaps/ActiveSwaps.style.js +37 -0
- package/components/ActiveSwaps/index.d.ts +2 -0
- package/components/ActiveSwaps/index.js +2 -0
- package/components/Card/Card.d.ts +7 -4
- package/components/Card/Card.js +39 -29
- package/{pages/SelectTokenPage → components/ChainSelect}/ChainSelect.d.ts +0 -0
- package/components/ChainSelect/ChainSelect.js +31 -0
- package/components/{SwapsInProgress/SwapsInProgress.style.d.ts → ChainSelect/ChainSelect.style.d.ts} +10 -19
- package/components/ChainSelect/ChainSelect.style.js +16 -0
- package/components/ChainSelect/index.d.ts +2 -0
- package/components/ChainSelect/index.js +2 -0
- package/components/ChainSelect/useChainSelect.d.ts +8 -0
- package/components/ChainSelect/useChainSelect.js +29 -0
- package/components/Header/Header.js +1 -9
- package/components/Header/NavigationHeader.js +6 -11
- package/components/PoweredBy/PoweredBy.style.d.ts +1 -1
- package/components/PoweredBy/PoweredBy.style.js +1 -0
- package/components/SendToWallet/SendToWallet.js +6 -6
- package/components/Step/CircularProgress.js +3 -3
- package/components/Step/CircularProgress.style.js +1 -1
- package/components/Step/StepProcess.js +2 -6
- package/components/Step/StepProcess.style.d.ts +1 -1
- package/components/Step/StepTimer.d.ts +1 -0
- package/components/Step/StepTimer.js +6 -6
- package/components/SwapButton/SwapButton.js +6 -13
- package/components/SwapButton/types.d.ts +2 -2
- package/components/SwapRouteCard/SwapRouteCard.js +1 -1
- package/components/TokenAvatar/TokenAvatar.style.js +0 -3
- package/components/TokenList/TokenList.js +6 -2
- package/config/theme.js +24 -23
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +2 -0
- package/hooks/useChains.d.ts +1 -97
- package/hooks/useChains.js +8 -15
- package/{components/Step/utils.d.ts → hooks/useProcessMessage.d.ts} +4 -0
- package/{pages/SwapPage/utils.js → hooks/useProcessMessage.js} +15 -10
- package/hooks/useRouteExecution.d.ts +1 -1
- package/hooks/useRouteExecution.js +21 -30
- package/hooks/useWidgetEvents.d.ts +3 -0
- package/hooks/useWidgetEvents.js +6 -0
- package/i18n/en/translation.json +13 -8
- package/i18n/index.d.ts +10 -5
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +14 -13
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.d.ts +2 -0
- package/pages/ActiveSwapsPage/ActiveSwapsEmpty.js +14 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.d.ts +2 -0
- package/pages/ActiveSwapsPage/ActiveSwapsPage.js +17 -0
- package/pages/ActiveSwapsPage/index.d.ts +1 -0
- package/pages/ActiveSwapsPage/index.js +1 -0
- package/pages/MainPage/MainPage.js +2 -3
- package/pages/MainPage/MainSwapButton.js +3 -1
- package/pages/MainPage/SwapRoutes.js +4 -1
- package/pages/SelectChainPage/SelectChainPage.d.ts +3 -0
- package/pages/SelectChainPage/SelectChainPage.js +29 -0
- package/pages/SelectChainPage/SelectChainPage.style.d.ts +21 -0
- package/pages/SelectChainPage/SelectChainPage.style.js +17 -0
- package/pages/SelectChainPage/index.d.ts +1 -0
- package/pages/SelectChainPage/index.js +1 -0
- package/pages/SelectTokenPage/SelectTokenPage.d.ts +2 -4
- package/pages/SelectTokenPage/SelectTokenPage.js +2 -2
- package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
- package/pages/SelectWalletPage/SelectWalletPage.style.d.ts +2 -27
- package/pages/SelectWalletPage/SelectWalletPage.style.js +4 -14
- package/pages/SettingsPage/ColorSchemeButtonGroup.style.d.ts +1 -1
- package/pages/SettingsPage/EnabledBridgesSelect.js +4 -7
- package/pages/SettingsPage/EnabledExchangesSelect.js +4 -6
- package/pages/SettingsPage/RoutePrioritySelect.js +5 -1
- package/pages/SwapDetailsPage/SwapDetailsPage.js +1 -1
- package/pages/SwapPage/StatusBottomSheet.js +27 -38
- package/pages/SwapPage/SwapPage.js +5 -1
- package/providers/SwapFormProvider/SwapFormProvider.js +39 -11
- package/providers/WidgetProvider/WidgetProvider.js +3 -7
- package/stores/chains/index.d.ts +4 -0
- package/stores/chains/index.js +4 -0
- package/stores/chains/types.d.ts +8 -0
- package/stores/chains/types.js +1 -0
- package/stores/chains/useChainOrder.d.ts +1 -0
- package/stores/chains/useChainOrder.js +5 -0
- package/stores/chains/useChainOrderStore.d.ts +19 -0
- package/stores/chains/useChainOrderStore.js +36 -0
- package/stores/chains/useInitializeChainOrder.d.ts +1 -0
- package/stores/chains/useInitializeChainOrder.js +5 -0
- package/stores/route/index.d.ts +2 -1
- package/stores/route/index.js +2 -1
- package/stores/route/useExecutingRoutesIds.d.ts +1 -0
- package/stores/route/useExecutingRoutesIds.js +13 -0
- package/stores/route/useRouteStore.js +5 -4
- package/stores/route/utils.d.ts +4 -0
- package/stores/route/utils.js +15 -0
- package/stores/settings/useSettingsStore.js +5 -2
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +5 -0
- package/types/events.js +6 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/widget.d.ts +2 -1
- package/utils/navigationRoutes.d.ts +5 -0
- package/utils/navigationRoutes.js +30 -3
- package/cjs/components/SwapButton/SwapButton.style.d.ts +0 -65
- package/cjs/components/SwapButton/SwapButton.style.js +0 -15
- package/cjs/components/SwapsInProgress/SwapsInProgress.js +0 -29
- package/cjs/components/SwapsInProgress/SwapsInProgress.style.js +0 -17
- package/cjs/components/SwapsInProgress/index.d.ts +0 -1
- package/cjs/pages/SelectTokenPage/ChainSelect.js +0 -31
- package/cjs/pages/SwapPage/utils.d.ts +0 -6
- package/cjs/pages/SwapPage/utils.js +0 -93
- package/cjs/stores/route/useExecutingRoutes.d.ts +0 -2
- package/cjs/stores/route/useExecutingRoutes.js +0 -13
- package/components/Step/utils.js +0 -89
- package/components/SwapButton/SwapButton.style.d.ts +0 -65
- package/components/SwapButton/SwapButton.style.js +0 -12
- package/components/SwapsInProgress/SwapsInProgress.js +0 -25
- package/components/SwapsInProgress/SwapsInProgress.style.js +0 -14
- package/components/SwapsInProgress/index.d.ts +0 -1
- package/components/SwapsInProgress/index.js +0 -1
- package/pages/SelectTokenPage/ChainSelect.js +0 -27
- package/pages/SwapPage/utils.d.ts +0 -6
- package/stores/route/useExecutingRoutes.d.ts +0 -2
- package/stores/route/useExecutingRoutes.js +0 -6
package/hooks/useChains.js
CHANGED
|
@@ -7,27 +7,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
-
var t = {};
|
|
12
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
-
t[p] = s[p];
|
|
14
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
-
t[p[i]] = s[p[i]];
|
|
18
|
-
}
|
|
19
|
-
return t;
|
|
20
|
-
};
|
|
21
10
|
import { useQuery } from '@tanstack/react-query';
|
|
22
11
|
import { useCallback } from 'react';
|
|
23
12
|
import { LiFi } from '../config/lifi';
|
|
24
13
|
import { useWidgetConfig } from '../providers/WidgetProvider';
|
|
14
|
+
import { useSetChainOrder } from '../stores/chains';
|
|
25
15
|
export const useChains = () => {
|
|
26
16
|
const { disabledChains } = useWidgetConfig();
|
|
27
|
-
const
|
|
17
|
+
const [, initializeChains] = useSetChainOrder();
|
|
18
|
+
const { data, isLoading } = useQuery(['chains'], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
19
|
const chains = yield LiFi.getChains();
|
|
29
|
-
|
|
30
|
-
|
|
20
|
+
const filteredChains = chains.filter((chain) => !(disabledChains === null || disabledChains === void 0 ? void 0 : disabledChains.includes(chain.id)));
|
|
21
|
+
initializeChains(filteredChains.map((chain) => chain.id));
|
|
22
|
+
return filteredChains;
|
|
23
|
+
}));
|
|
31
24
|
const getChainById = useCallback((chainId) => {
|
|
32
25
|
const chain = data === null || data === void 0 ? void 0 : data.find((chain) => chain.id === chainId);
|
|
33
26
|
// if (!chain) {
|
|
@@ -35,5 +28,5 @@ export const useChains = () => {
|
|
|
35
28
|
// }
|
|
36
29
|
return chain;
|
|
37
30
|
}, [data]);
|
|
38
|
-
return
|
|
31
|
+
return { chains: data, getChainById, isLoading };
|
|
39
32
|
};
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import type { EVMChain, Process, Step } from '@lifi/sdk';
|
|
2
2
|
import type { TFunction } from 'react-i18next';
|
|
3
|
+
export declare const useProcessMessage: (step?: Step, process?: Process) => {
|
|
4
|
+
title?: string | undefined;
|
|
5
|
+
message?: string | undefined;
|
|
6
|
+
};
|
|
3
7
|
export declare function getProcessMessage(t: TFunction<'translation', undefined>, getChainById: (chainId: number) => EVMChain | undefined, step: Step, process: Process): {
|
|
4
8
|
title?: string;
|
|
5
9
|
message?: string;
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import { LifiErrorCode
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
import { LifiErrorCode } from '@lifi/sdk';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { formatTokenAmount } from '../utils';
|
|
4
|
+
import { useChains } from './useChains';
|
|
5
|
+
export const useProcessMessage = (step, process) => {
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
const { getChainById } = useChains();
|
|
8
|
+
if (!step || !process) {
|
|
9
|
+
return {};
|
|
10
|
+
}
|
|
11
|
+
return getProcessMessage(t, getChainById, step, process);
|
|
7
12
|
};
|
|
8
13
|
const processMessages = {
|
|
9
14
|
TOKEN_ALLOWANCE: {
|
|
@@ -12,7 +17,7 @@ const processMessages = {
|
|
|
12
17
|
DONE: (t) => t(`swap.process.tokenAllowance.done`),
|
|
13
18
|
},
|
|
14
19
|
SWITCH_CHAIN: {
|
|
15
|
-
|
|
20
|
+
ACTION_REQUIRED: (t) => t(`swap.process.switchChain.actionRequired`),
|
|
16
21
|
DONE: (t) => t(`swap.process.switchChain.done`),
|
|
17
22
|
},
|
|
18
23
|
SWAP: {
|
|
@@ -67,9 +72,9 @@ export function getProcessMessage(t, getChainById, step, process) {
|
|
|
67
72
|
title = t(`swap.error.title.slippageTooLarge`);
|
|
68
73
|
message = t(`swap.error.message.slippageTooLarge`);
|
|
69
74
|
break;
|
|
70
|
-
case
|
|
71
|
-
title = t(`swap.error.title.
|
|
72
|
-
message = t(`swap.error.message.
|
|
75
|
+
case LifiErrorCode.TransactionRejected:
|
|
76
|
+
title = t(`swap.error.title.transactionRejected`);
|
|
77
|
+
message = t(`swap.error.message.transactionRejected`, {
|
|
73
78
|
amount: formatTokenAmount(step.action.fromAmount, step.action.fromToken.decimals),
|
|
74
79
|
tokenSymbol: step.action.fromToken.symbol,
|
|
75
80
|
chainName: (_b = (_a = getChainById(step.action.fromChainId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : '',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Route } from '@lifi/sdk';
|
|
2
|
-
export declare const useRouteExecution: (routeId: string) => {
|
|
2
|
+
export declare const useRouteExecution: (routeId: string, executeInBackground?: boolean) => {
|
|
3
3
|
executeRoute: () => void;
|
|
4
4
|
restartRoute: () => void;
|
|
5
5
|
deleteRoute: () => void;
|
|
@@ -12,17 +12,26 @@ import { useCallback, useEffect, useRef } from 'react';
|
|
|
12
12
|
import shallow from 'zustand/shallow';
|
|
13
13
|
import { LiFi } from '../config/lifi';
|
|
14
14
|
import { useWallet } from '../providers/WalletProvider';
|
|
15
|
-
import { useRouteStore } from '../stores';
|
|
15
|
+
import { isRouteActive, isRouteCompleted, isRouteFailed, useRouteStore, } from '../stores';
|
|
16
|
+
import { WidgetEvent } from '../types/events';
|
|
16
17
|
import { deepClone } from '../utils';
|
|
17
|
-
|
|
18
|
+
import { useWidgetEvents } from './useWidgetEvents';
|
|
19
|
+
export const useRouteExecution = (routeId, executeInBackground) => {
|
|
18
20
|
const { account, switchChain } = useWallet();
|
|
19
21
|
const resumedAfterMount = useRef(false);
|
|
22
|
+
const emitter = useWidgetEvents();
|
|
20
23
|
const routeExecution = useRouteStore((state) => state.routes[routeId]);
|
|
21
24
|
const [updateRoute, restartRoute, deleteRoute] = useRouteStore((state) => [state.updateRoute, state.restartRoute, state.deleteRoute], shallow);
|
|
22
25
|
const updateCallback = (updatedRoute) => {
|
|
23
26
|
const clonedUpdatedRoute = deepClone(updatedRoute);
|
|
24
27
|
console.log('Route updated.', clonedUpdatedRoute);
|
|
25
28
|
updateRoute(clonedUpdatedRoute);
|
|
29
|
+
if (isRouteCompleted(clonedUpdatedRoute)) {
|
|
30
|
+
emitter.emit(WidgetEvent.SwapCompleted);
|
|
31
|
+
}
|
|
32
|
+
if (isRouteFailed(clonedUpdatedRoute)) {
|
|
33
|
+
emitter.emit(WidgetEvent.SwapFailed);
|
|
34
|
+
}
|
|
26
35
|
};
|
|
27
36
|
const switchChainHook = (requiredChainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
37
|
if (!account.isActive || !account.signer) {
|
|
@@ -48,16 +57,12 @@ export const useRouteExecution = (routeId) => {
|
|
|
48
57
|
updateCallback,
|
|
49
58
|
switchChainHook,
|
|
50
59
|
infiniteApproval: false,
|
|
60
|
+
executeInBackground,
|
|
51
61
|
});
|
|
52
62
|
}, {
|
|
53
63
|
onMutate: () => {
|
|
54
64
|
console.log('Execution started.', routeId);
|
|
55
|
-
|
|
56
|
-
onError: () => {
|
|
57
|
-
console.warn('Execution failed.', routeId);
|
|
58
|
-
},
|
|
59
|
-
onSuccess: (route) => {
|
|
60
|
-
console.log('Executed successfully.', routeId);
|
|
65
|
+
emitter.emit(WidgetEvent.SwapStarted);
|
|
61
66
|
},
|
|
62
67
|
});
|
|
63
68
|
const resumeRouteMutation = useMutation((resumedRoute) => {
|
|
@@ -71,26 +76,21 @@ export const useRouteExecution = (routeId) => {
|
|
|
71
76
|
updateCallback,
|
|
72
77
|
switchChainHook,
|
|
73
78
|
infiniteApproval: false,
|
|
79
|
+
executeInBackground,
|
|
74
80
|
});
|
|
75
81
|
}, {
|
|
76
82
|
onMutate: () => {
|
|
77
83
|
console.log('Resumed to execution.', routeId);
|
|
78
84
|
},
|
|
79
|
-
onError: () => {
|
|
80
|
-
console.warn('Resumed execution failed.', routeId);
|
|
81
|
-
},
|
|
82
|
-
onSuccess: (route) => {
|
|
83
|
-
console.log('Resumed execution successful.', route);
|
|
84
|
-
},
|
|
85
85
|
});
|
|
86
86
|
const executeRoute = useCallback(() => {
|
|
87
87
|
executeRouteMutation.mutateAsync(undefined, {
|
|
88
88
|
onError: () => {
|
|
89
|
-
console.warn('
|
|
89
|
+
console.warn('Execution failed!', routeId);
|
|
90
90
|
// Notification.showNotification(NotificationType.SwapExecution_ERROR);
|
|
91
91
|
},
|
|
92
92
|
onSuccess: (route) => {
|
|
93
|
-
console.log('
|
|
93
|
+
console.log('Executed successfully!', route);
|
|
94
94
|
// Notification.showNotification(NotificationType.TRANSACTION_SUCCESSFULL);
|
|
95
95
|
},
|
|
96
96
|
});
|
|
@@ -98,10 +98,10 @@ export const useRouteExecution = (routeId) => {
|
|
|
98
98
|
const resumeRoute = useCallback((route) => {
|
|
99
99
|
resumeRouteMutation.mutateAsync(route, {
|
|
100
100
|
onError: () => {
|
|
101
|
-
console.warn('
|
|
101
|
+
console.warn('Resumed execution failed.', routeId);
|
|
102
102
|
},
|
|
103
103
|
onSuccess: (route) => {
|
|
104
|
-
console.log('
|
|
104
|
+
console.log('Resumed execution successful.', route);
|
|
105
105
|
},
|
|
106
106
|
});
|
|
107
107
|
}, [resumeRouteMutation, routeId]);
|
|
@@ -117,7 +117,7 @@ export const useRouteExecution = (routeId) => {
|
|
|
117
117
|
// Resume route execution after page reload
|
|
118
118
|
useEffect(() => {
|
|
119
119
|
// Check if route is eligible for automatic resuming
|
|
120
|
-
if (
|
|
120
|
+
if (isRouteActive(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route) &&
|
|
121
121
|
account.isActive &&
|
|
122
122
|
!resumedAfterMount.current) {
|
|
123
123
|
resumedAfterMount.current = true;
|
|
@@ -129,10 +129,10 @@ export const useRouteExecution = (routeId) => {
|
|
|
129
129
|
return () => {
|
|
130
130
|
var _a;
|
|
131
131
|
const route = (_a = useRouteStore.getState().routes[routeId]) === null || _a === void 0 ? void 0 : _a.route;
|
|
132
|
-
if (!route || !
|
|
132
|
+
if (!route || !isRouteActive(route)) {
|
|
133
133
|
return;
|
|
134
134
|
}
|
|
135
|
-
LiFi.
|
|
135
|
+
LiFi.updateRouteExecution(route, { executeInBackground: true });
|
|
136
136
|
console.log('Move route execution to background.', routeId);
|
|
137
137
|
resumedAfterMount.current = false;
|
|
138
138
|
};
|
|
@@ -145,12 +145,3 @@ export const useRouteExecution = (routeId) => {
|
|
|
145
145
|
status: routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.status,
|
|
146
146
|
};
|
|
147
147
|
};
|
|
148
|
-
const isActiveRoute = (route) => {
|
|
149
|
-
if (!route) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
const allDone = route.steps.every((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'DONE'; });
|
|
153
|
-
const isFailed = route.steps.some((step) => { var _a; return ((_a = step.execution) === null || _a === void 0 ? void 0 : _a.status) === 'FAILED'; });
|
|
154
|
-
const alreadyStarted = route.steps.some((step) => step.execution);
|
|
155
|
-
return !allDone && !isFailed && alreadyStarted;
|
|
156
|
-
};
|
package/i18n/en/translation.json
CHANGED
|
@@ -6,10 +6,12 @@
|
|
|
6
6
|
"swap": "Swap",
|
|
7
7
|
"from": "Swap from",
|
|
8
8
|
"to": "Swap to",
|
|
9
|
+
"selectChain": "Select chain",
|
|
9
10
|
"settings": "Settings",
|
|
10
11
|
"routes": "You get",
|
|
11
12
|
"swapHistory": "Swap history",
|
|
12
|
-
"swapDetails": "Swap details"
|
|
13
|
+
"swapDetails": "Swap details",
|
|
14
|
+
"activeSwaps": "Active swaps"
|
|
13
15
|
},
|
|
14
16
|
"button": {
|
|
15
17
|
"connectWallet": "Connect wallet",
|
|
@@ -31,6 +33,7 @@
|
|
|
31
33
|
"delete": "Delete",
|
|
32
34
|
"hide": "Hide",
|
|
33
35
|
"max": "max",
|
|
36
|
+
"showAll": "Show all",
|
|
34
37
|
"contactSupport": "Contact support",
|
|
35
38
|
"lifiSwap": "LI.FI Swap"
|
|
36
39
|
},
|
|
@@ -53,7 +56,6 @@
|
|
|
53
56
|
"featuredTokens": "Featured tokens",
|
|
54
57
|
"otherTokens": "Other tokens",
|
|
55
58
|
"inProgress": "in progress",
|
|
56
|
-
"activeTransfers": "Active transfers",
|
|
57
59
|
"couldntFindTokens": "We couldn't find tokens on this chain or you don't have any.",
|
|
58
60
|
"stepSwap": "Swap",
|
|
59
61
|
"stepBridge": "Bridge",
|
|
@@ -63,7 +65,7 @@
|
|
|
63
65
|
"swapStepDetails": "Swap on {{chain}} via {{tool}}",
|
|
64
66
|
"tokenOnChain": "{{tokenSymbol}} on {{chainName}}",
|
|
65
67
|
"tokenOnChainAmount": "{{amount}} {{tokenSymbol}} on {{chainName}}",
|
|
66
|
-
"
|
|
68
|
+
"supportId": "Support ID",
|
|
67
69
|
"sendToWallet": "Send to a different wallet",
|
|
68
70
|
"walletAddressOrEns": "Wallet address or ENS name",
|
|
69
71
|
"tags": {
|
|
@@ -84,11 +86,13 @@
|
|
|
84
86
|
"info": {
|
|
85
87
|
"title": {
|
|
86
88
|
"routeNotFound": "No routes available",
|
|
87
|
-
"emptySwapHistory": "No recent swaps"
|
|
89
|
+
"emptySwapHistory": "No recent swaps",
|
|
90
|
+
"emptyActiveSwaps": "No active swaps"
|
|
88
91
|
},
|
|
89
92
|
"message": {
|
|
90
93
|
"routeNotFound": "Try another token combination.",
|
|
91
|
-
"emptySwapHistory": "Swap history is only stored locally and will be deleted if you clear your browser data."
|
|
94
|
+
"emptySwapHistory": "Swap history is only stored locally and will be deleted if you clear your browser data.",
|
|
95
|
+
"emptyActiveSwaps": "Swaps in progress will appear here. Once completed, find them in swap history."
|
|
92
96
|
}
|
|
93
97
|
},
|
|
94
98
|
"warning": {
|
|
@@ -105,18 +109,19 @@
|
|
|
105
109
|
},
|
|
106
110
|
"error": {
|
|
107
111
|
"title": {
|
|
112
|
+
"failed": "Swap failed.",
|
|
108
113
|
"chainSwitch": "Chain switch required.",
|
|
109
114
|
"transactionFailed": "Transaction has failed.",
|
|
110
115
|
"transactionUnderpriced": "Transaction is underpriced.",
|
|
111
116
|
"transactionUnprepared": "Unable to prepare transaction.",
|
|
117
|
+
"transactionRejected": "Signature required.",
|
|
112
118
|
"unknown": "Something went wrong.",
|
|
113
|
-
"userRejectedSignatureRequest": "Signature required.",
|
|
114
119
|
"slippageTooLarge": "Slippage too large.",
|
|
115
120
|
"walletAddressInvalid": "Wallet address is invalid.",
|
|
116
121
|
"walletEnsAddressInvalid": "Wallet address is invalid or network doesn't support ENS."
|
|
117
122
|
},
|
|
118
123
|
"message": {
|
|
119
|
-
"
|
|
124
|
+
"transactionRejected": "Your signature is required to complete the transaction. {{amount}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
|
|
120
125
|
"transactionFailed": "Please check the block explorer for more information.",
|
|
121
126
|
"transactionNotSent": "Transaction was not sent, your funds are still in your wallet ({{amount}} {{tokenSymbol}} on {{chainName}}).",
|
|
122
127
|
"slippageTooLarge": "The slippage is larger than the defined threshold. Please request a new route to get a fresh quote."
|
|
@@ -129,7 +134,7 @@
|
|
|
129
134
|
"done": "Token allowance approved."
|
|
130
135
|
},
|
|
131
136
|
"switchChain": {
|
|
132
|
-
"
|
|
137
|
+
"actionRequired": "Chain switch required.",
|
|
133
138
|
"done": "Chain switched successfully."
|
|
134
139
|
},
|
|
135
140
|
"swap": {
|
package/i18n/index.d.ts
CHANGED
|
@@ -9,10 +9,12 @@ export declare const resources: {
|
|
|
9
9
|
swap: string;
|
|
10
10
|
from: string;
|
|
11
11
|
to: string;
|
|
12
|
+
selectChain: string;
|
|
12
13
|
settings: string;
|
|
13
14
|
routes: string;
|
|
14
15
|
swapHistory: string;
|
|
15
16
|
swapDetails: string;
|
|
17
|
+
activeSwaps: string;
|
|
16
18
|
};
|
|
17
19
|
button: {
|
|
18
20
|
connectWallet: string;
|
|
@@ -34,6 +36,7 @@ export declare const resources: {
|
|
|
34
36
|
delete: string;
|
|
35
37
|
hide: string;
|
|
36
38
|
max: string;
|
|
39
|
+
showAll: string;
|
|
37
40
|
contactSupport: string;
|
|
38
41
|
lifiSwap: string;
|
|
39
42
|
};
|
|
@@ -56,7 +59,6 @@ export declare const resources: {
|
|
|
56
59
|
featuredTokens: string;
|
|
57
60
|
otherTokens: string;
|
|
58
61
|
inProgress: string;
|
|
59
|
-
activeTransfers: string;
|
|
60
62
|
couldntFindTokens: string;
|
|
61
63
|
stepSwap: string;
|
|
62
64
|
stepBridge: string;
|
|
@@ -66,7 +68,7 @@ export declare const resources: {
|
|
|
66
68
|
swapStepDetails: string;
|
|
67
69
|
tokenOnChain: string;
|
|
68
70
|
tokenOnChainAmount: string;
|
|
69
|
-
|
|
71
|
+
supportId: string;
|
|
70
72
|
sendToWallet: string;
|
|
71
73
|
walletAddressOrEns: string;
|
|
72
74
|
tags: {
|
|
@@ -88,10 +90,12 @@ export declare const resources: {
|
|
|
88
90
|
title: {
|
|
89
91
|
routeNotFound: string;
|
|
90
92
|
emptySwapHistory: string;
|
|
93
|
+
emptyActiveSwaps: string;
|
|
91
94
|
};
|
|
92
95
|
message: {
|
|
93
96
|
routeNotFound: string;
|
|
94
97
|
emptySwapHistory: string;
|
|
98
|
+
emptyActiveSwaps: string;
|
|
95
99
|
};
|
|
96
100
|
};
|
|
97
101
|
warning: {
|
|
@@ -108,18 +112,19 @@ export declare const resources: {
|
|
|
108
112
|
};
|
|
109
113
|
error: {
|
|
110
114
|
title: {
|
|
115
|
+
failed: string;
|
|
111
116
|
chainSwitch: string;
|
|
112
117
|
transactionFailed: string;
|
|
113
118
|
transactionUnderpriced: string;
|
|
114
119
|
transactionUnprepared: string;
|
|
120
|
+
transactionRejected: string;
|
|
115
121
|
unknown: string;
|
|
116
|
-
userRejectedSignatureRequest: string;
|
|
117
122
|
slippageTooLarge: string;
|
|
118
123
|
walletAddressInvalid: string;
|
|
119
124
|
walletEnsAddressInvalid: string;
|
|
120
125
|
};
|
|
121
126
|
message: {
|
|
122
|
-
|
|
127
|
+
transactionRejected: string;
|
|
123
128
|
transactionFailed: string;
|
|
124
129
|
transactionNotSent: string;
|
|
125
130
|
slippageTooLarge: string;
|
|
@@ -132,7 +137,7 @@ export declare const resources: {
|
|
|
132
137
|
done: string;
|
|
133
138
|
};
|
|
134
139
|
switchChain: {
|
|
135
|
-
|
|
140
|
+
actionRequired: string;
|
|
136
141
|
done: string;
|
|
137
142
|
};
|
|
138
143
|
swap: {
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './fonts/inter.css';
|
|
3
|
+
export { useWidgetEvents } from './hooks';
|
|
3
4
|
export * from './types';
|
|
4
5
|
export declare const LiFiWidget: import("react").FC<import("./AppProvider").AppProps>;
|
|
5
6
|
export declare const LiFiWidgetDrawer: import("react").ForwardRefExoticComponent<Pick<import("./AppDrawer").AppDrawerProps, "className" | "style" | "classes" | "slot" | "title" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "id" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "role" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "children" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "key" | "transitionDuration" | "variant" | "open" | "anchor" | "elementRef" | "components" | "componentsProps" | "BackdropComponent" | "BackdropProps" | "closeAfterTransition" | "container" | "disableAutoFocus" | "disableEnforceFocus" | "disableEscapeKeyDown" | "disablePortal" | "disableRestoreFocus" | "disableScrollLock" | "hideBackdrop" | "keepMounted" | "onBackdropClick" | "onClose" | "config" | "elevation" | "ModalProps" | "PaperProps" | "SlideProps"> & import("react").RefAttributes<import("./AppDrawer").AppDrawerBase>>;
|
package/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { App } from './App';
|
|
|
2
2
|
import { AppDrawer } from './AppDrawer';
|
|
3
3
|
import './fonts/inter.css';
|
|
4
4
|
import { configureReactI18next } from './i18n';
|
|
5
|
+
export { useWidgetEvents } from './hooks';
|
|
5
6
|
export * from './types';
|
|
6
7
|
configureReactI18next();
|
|
7
8
|
// ClassNameGenerator.configure((componentName) =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lifi/widget",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "LI.FI Widget for cross-chain bridging and swapping. It will drive your multi-chain strategy and attract new users from everywhere.",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -37,28 +37,29 @@
|
|
|
37
37
|
"lifi"
|
|
38
38
|
],
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@emotion/react": "^11.10.
|
|
41
|
-
"@emotion/styled": "^11.10.
|
|
40
|
+
"@emotion/react": "^11.10.4",
|
|
41
|
+
"@emotion/styled": "^11.10.4",
|
|
42
42
|
"@ethersproject/address": "^5.7.0",
|
|
43
43
|
"@ethersproject/experimental": "^5.7.0",
|
|
44
44
|
"@ethersproject/providers": "^5.7.0",
|
|
45
|
-
"@lifi/sdk": "^1.
|
|
46
|
-
"@lifi/wallet-management": "^1.1.
|
|
47
|
-
"@mui/icons-material": "^5.10.
|
|
48
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
49
|
-
"@mui/material": "^5.10.
|
|
50
|
-
"@sentry/integrations": "^7.
|
|
51
|
-
"@sentry/react": "^7.
|
|
52
|
-
"@sentry/tracing": "^7.
|
|
53
|
-
"@tanstack/react-query": "^4.2.
|
|
45
|
+
"@lifi/sdk": "^1.5.0",
|
|
46
|
+
"@lifi/wallet-management": "^1.1.9",
|
|
47
|
+
"@mui/icons-material": "^5.10.3",
|
|
48
|
+
"@mui/lab": "^5.0.0-alpha.98",
|
|
49
|
+
"@mui/material": "^5.10.4",
|
|
50
|
+
"@sentry/integrations": "^7.12.1",
|
|
51
|
+
"@sentry/react": "^7.12.1",
|
|
52
|
+
"@sentry/tracing": "^7.12.1",
|
|
53
|
+
"@tanstack/react-query": "^4.2.3",
|
|
54
54
|
"@tanstack/react-virtual": "^3.0.0-beta.17",
|
|
55
55
|
"big.js": "^6.2.1",
|
|
56
|
+
"events": "^3.3.0",
|
|
56
57
|
"i18next": "^21.9.1",
|
|
57
58
|
"immer": "^9.0.15",
|
|
58
59
|
"react": "^18.2.0",
|
|
59
60
|
"react-dom": "^18.2.0",
|
|
60
61
|
"react-hook-form": "^7.34.2",
|
|
61
|
-
"react-i18next": "^11.18.
|
|
62
|
+
"react-i18next": "^11.18.5",
|
|
62
63
|
"react-router-dom": "^6.3.0",
|
|
63
64
|
"react-timer-hook": "^3.0.5",
|
|
64
65
|
"zustand": "^4.1.1"
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SwapHoriz as SwapHorizIcon } from '@mui/icons-material';
|
|
3
|
+
import { Container, Typography } from '@mui/material';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
export const ActiveSwapsEmpty = () => {
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
return (_jsxs(Container, Object.assign({ sx: {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
flex: 1,
|
|
10
|
+
flexDirection: 'column',
|
|
11
|
+
alignItems: 'center',
|
|
12
|
+
justifyContent: 'center',
|
|
13
|
+
} }, { children: [_jsx(Typography, Object.assign({ fontSize: 48 }, { children: _jsx(SwapHorizIcon, { fontSize: "inherit" }) })), _jsx(Typography, Object.assign({ fontSize: 18, fontWeight: 700 }, { children: t('swap.info.title.emptyActiveSwaps') })), _jsx(Typography, Object.assign({ fontSize: 14, color: "text.secondary", textAlign: "center", mt: 2 }, { children: t('swap.info.message.emptyActiveSwaps') }))] })));
|
|
14
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Container, List } from '@mui/material';
|
|
3
|
+
import { ActiveSwapItem } from '../../components/ActiveSwaps';
|
|
4
|
+
import { useWallet } from '../../providers';
|
|
5
|
+
import { useExecutingRoutesIds } from '../../stores';
|
|
6
|
+
import { ActiveSwapsEmpty } from './ActiveSwapsEmpty';
|
|
7
|
+
export const ActiveSwapsPage = () => {
|
|
8
|
+
const { account } = useWallet();
|
|
9
|
+
const executingRoutes = useExecutingRoutesIds(account.address);
|
|
10
|
+
if (!executingRoutes.length) {
|
|
11
|
+
return _jsx(ActiveSwapsEmpty, {});
|
|
12
|
+
}
|
|
13
|
+
return (_jsx(Container, Object.assign({ disableGutters: true }, { children: _jsx(List, Object.assign({ sx: {
|
|
14
|
+
paddingLeft: 1.5,
|
|
15
|
+
paddingRight: 1.5,
|
|
16
|
+
} }, { children: executingRoutes.map((routeId) => (_jsx(ActiveSwapItem, { routeId: routeId }, routeId))) })) })));
|
|
17
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ActiveSwapsPage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ActiveSwapsPage';
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box } from '@mui/material';
|
|
3
|
+
import { ActiveSwaps } from '../../components/ActiveSwaps';
|
|
3
4
|
import { SelectChainAndToken } from '../../components/SelectChainAndToken';
|
|
4
|
-
import { SendToWallet } from '../../components/SendToWallet';
|
|
5
5
|
import { SwapInput } from '../../components/SwapInput';
|
|
6
|
-
import { SwapsInProgress } from '../../components/SwapsInProgress';
|
|
7
6
|
import { FormContainer } from './MainPage.style';
|
|
8
7
|
import { MainSwapButton } from './MainSwapButton';
|
|
9
8
|
import { SwapRoutes } from './SwapRoutes';
|
|
10
9
|
export const MainPage = () => {
|
|
11
|
-
return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(
|
|
10
|
+
return (_jsxs(FormContainer, Object.assign({ disableGutters: true }, { children: [_jsx(ActiveSwaps, { mx: 3, mt: 1, mb: 2 }), _jsx(SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 3 }, { children: _jsx(SwapInput, { formType: "from" }) })), _jsx(SwapRoutes, { mx: 3, mb: 3 }), _jsx(Box, Object.assign({ mx: 3, mb: 1 }, { children: _jsx(MainSwapButton, {}) }))] })));
|
|
12
11
|
};
|
|
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { useFormState } from 'react-hook-form';
|
|
11
12
|
import { useNavigate } from 'react-router-dom';
|
|
12
13
|
import { SwapButton } from '../../components/SwapButton';
|
|
13
14
|
import { useSwapRoutes } from '../../hooks';
|
|
@@ -15,6 +16,7 @@ import { useSetExecutableRoute } from '../../stores';
|
|
|
15
16
|
import { navigationRoutes } from '../../utils';
|
|
16
17
|
export const MainSwapButton = () => {
|
|
17
18
|
const navigate = useNavigate();
|
|
19
|
+
const { isValid, isValidating } = useFormState();
|
|
18
20
|
const setExecutableRoute = useSetExecutableRoute();
|
|
19
21
|
const { routes: swapRoutes, isLoading, isFetching } = useSwapRoutes();
|
|
20
22
|
const currentRoute = swapRoutes === null || swapRoutes === void 0 ? void 0 : swapRoutes[0];
|
|
@@ -26,5 +28,5 @@ export const MainSwapButton = () => {
|
|
|
26
28
|
});
|
|
27
29
|
}
|
|
28
30
|
});
|
|
29
|
-
return (_jsx(SwapButton, { onClick: handleClick, currentRoute: currentRoute,
|
|
31
|
+
return (_jsx(SwapButton, { onClick: handleClick, currentRoute: currentRoute, disable: isLoading || isFetching || !currentRoute || isValidating || !isValid }));
|
|
30
32
|
};
|
|
@@ -3,11 +3,13 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { KeyboardArrowRight as KeyboardArrowRightIcon } from '@mui/icons-material';
|
|
4
4
|
import { Box, IconButton } from '@mui/material';
|
|
5
5
|
import { useCallback } from 'react';
|
|
6
|
+
import { useFormState } from 'react-hook-form';
|
|
6
7
|
import { useTranslation } from 'react-i18next';
|
|
7
8
|
import { useNavigate } from 'react-router-dom';
|
|
8
9
|
import { Card, CardTitle } from '../../components/Card';
|
|
9
10
|
import { GasSufficiencyMessage } from '../../components/GasSufficiencyMessage';
|
|
10
11
|
import { ProgressToNextUpdate } from '../../components/ProgressToNextUpdate';
|
|
12
|
+
import { SendToWallet } from '../../components/SendToWallet';
|
|
11
13
|
import { SwapRouteCard, SwapRouteCardSkeleton, SwapRouteNotFoundCard, } from '../../components/SwapRouteCard';
|
|
12
14
|
import { useSwapRoutes } from '../../hooks';
|
|
13
15
|
import { navigationRoutes } from '../../utils';
|
|
@@ -15,6 +17,7 @@ import { Stack } from './SwapRoutes.style';
|
|
|
15
17
|
export const SwapRoutes = (props) => {
|
|
16
18
|
const { t } = useTranslation();
|
|
17
19
|
const navigate = useNavigate();
|
|
20
|
+
const { isValid, isValidating } = useFormState();
|
|
18
21
|
const { routes, isLoading, isFetching, isFetched, dataUpdatedAt, refetchTime, refetch, } = useSwapRoutes();
|
|
19
22
|
const handleCardClick = useCallback(() => {
|
|
20
23
|
navigate(navigationRoutes.swapRoutes);
|
|
@@ -32,5 +35,5 @@ export const SwapRoutes = (props) => {
|
|
|
32
35
|
borderWidth: !routeNotFound && (isFetching || (routes && routes.length > 1))
|
|
33
36
|
? 1
|
|
34
37
|
: 0,
|
|
35
|
-
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, active: true, dense: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], dense: true })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes" }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })), _jsx(GasSufficiencyMessage, Object.assign({ route: !isFetching ? currentRoute : undefined }, props))] }));
|
|
38
|
+
} }, { children: isLoading || isFetching ? (_jsxs(_Fragment, { children: [_jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true }), _jsx(SwapRouteCardSkeleton, { minWidth: "80%", dense: true })] })) : !currentRoute ? (_jsx(SwapRouteNotFoundCard, { minWidth: "100%", dense: true })) : (_jsxs(_Fragment, { children: [_jsx(SwapRouteCard, { minWidth: routes.length > 1 ? '80%' : '100%', route: currentRoute, active: true, dense: true }), routes.length > 1 ? (_jsx(SwapRouteCard, { minWidth: "80%", route: routes[1], dense: true })) : null] })) })), _jsx(Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: !routeNotFound ? (_jsx(Box, Object.assign({ py: 1, pr: 1 }, { children: _jsx(IconButton, Object.assign({ onClick: handleCardClick, size: "medium", "aria-label": "swap-routes", disabled: isValidating || !isValid }, { children: _jsx(KeyboardArrowRightIcon, {}) })) }))) : null }))] }))] })), _jsx(GasSufficiencyMessage, Object.assign({ route: !isFetching ? currentRoute : undefined }, props)), _jsx(SendToWallet, { mx: 3, mb: 3 })] }));
|
|
36
39
|
};
|