@lifi/widget 1.16.0 → 1.17.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/AppDrawer.d.ts +3 -3
- package/AppProvider.d.ts +0 -4
- package/AppProvider.js +2 -10
- package/README.md +1 -1
- package/cjs/AppDrawer.d.ts +3 -3
- package/cjs/AppProvider.d.ts +0 -4
- package/cjs/AppProvider.js +3 -12
- package/cjs/components/AppContainer.js +2 -2
- package/cjs/components/ChainSelect/ChainSelect.style.js +4 -4
- package/cjs/components/ChainSelect/useChainSelect.d.ts +2 -2
- package/cjs/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
- package/cjs/components/Header/useHeaderActionStore.d.ts +0 -2
- package/cjs/components/Header/useHeaderActionStore.js +1 -5
- package/cjs/components/SelectChainAndToken.js +5 -5
- package/cjs/components/SwapButton/SwapButton.js +3 -23
- package/cjs/components/TokenList/TokenList.js +1 -1
- package/cjs/components/TokenList/TokenList.style.js +4 -3
- package/cjs/components/TokenList/TokenListItem.js +1 -1
- package/cjs/components/TokenList/TokenNotFound.d.ts +2 -1
- package/cjs/components/TokenList/TokenNotFound.js +12 -2
- package/cjs/components/TokenList/types.d.ts +2 -2
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/useChains.js +23 -10
- package/cjs/hooks/useFeaturedTokens.d.ts +1 -1
- package/cjs/hooks/useFeaturedTokens.js +6 -3
- package/cjs/hooks/useGasSufficiency.d.ts +1 -1
- package/cjs/hooks/useGasSufficiency.js +39 -28
- package/cjs/hooks/useInitializer.js +6 -0
- package/cjs/hooks/useRouteExecution.js +28 -12
- package/cjs/hooks/useSwapRoutes.js +10 -11
- package/cjs/hooks/useToken.d.ts +0 -1
- package/cjs/hooks/useToken.js +1 -2
- package/cjs/hooks/useTokenBalances.d.ts +1 -2
- package/cjs/hooks/useTokenBalances.js +5 -6
- package/cjs/hooks/useTokenSearch.js +3 -2
- package/cjs/hooks/useTokens.d.ts +1 -2
- package/cjs/hooks/useTokens.js +32 -9
- package/cjs/hooks/useTools.js +11 -5
- package/cjs/hooks/useWidgetEvents.d.ts +3 -3
- package/cjs/hooks/useWidgetEvents.js +2 -2
- package/cjs/i18n/en/translation.json +2 -3
- package/cjs/i18n/index.d.ts +1 -2
- package/cjs/index.d.ts +2 -1
- package/cjs/pages/MainPage/MainSwapButton.js +1 -1
- package/cjs/pages/SettingsPage/AdvancedPreferences.js +1 -1
- package/cjs/pages/SettingsPage/GasPriceSelect.js +1 -1
- package/cjs/pages/SettingsPage/RoutePrioritySelect.js +1 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.js +1 -1
- package/cjs/pages/SettingsPage/SlippageInput.js +1 -1
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +2 -3
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -3
- package/cjs/pages/SwapPage/SwapPage.js +11 -2
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +4 -3
- package/cjs/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/cjs/providers/SDKProvider/SDKProvider.js +27 -0
- package/cjs/providers/SDKProvider/index.d.ts +1 -0
- package/cjs/providers/SDKProvider/index.js +17 -0
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +4 -58
- package/cjs/providers/SwapFormProvider/types.d.ts +5 -5
- package/cjs/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/cjs/providers/TelemetryProvider/TelemetryProvider.js +11 -0
- package/cjs/providers/TelemetryProvider/index.d.ts +1 -0
- package/cjs/providers/TelemetryProvider/index.js +17 -0
- package/cjs/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/cjs/providers/WalletProvider/WalletProvider.js +59 -1
- package/cjs/providers/WidgetProvider/WidgetProvider.js +1 -12
- package/cjs/providers/WidgetProvider/index.d.ts +1 -0
- package/cjs/providers/WidgetProvider/index.js +1 -0
- package/cjs/providers/WidgetProvider/utils.d.ts +4 -0
- package/cjs/providers/WidgetProvider/utils.js +13 -0
- package/cjs/providers/index.d.ts +2 -0
- package/cjs/providers/index.js +2 -0
- package/cjs/stores/chains/index.d.ts +0 -1
- package/cjs/stores/chains/index.js +0 -1
- package/cjs/stores/chains/types.d.ts +1 -1
- package/cjs/stores/chains/useChainOrderStore.js +17 -14
- package/cjs/stores/route/utils.d.ts +2 -1
- package/cjs/stores/route/utils.js +17 -1
- package/cjs/stores/settings/index.d.ts +0 -1
- package/cjs/stores/settings/index.js +0 -1
- package/cjs/stores/settings/useAppearance.js +3 -1
- package/cjs/types/events.d.ts +15 -3
- package/cjs/types/events.js +4 -3
- package/cjs/types/widget.d.ts +29 -22
- package/cjs/utils/colors.d.ts +1 -1
- package/components/AppContainer.js +1 -1
- package/components/ChainSelect/ChainSelect.style.js +4 -4
- package/components/ChainSelect/useChainSelect.d.ts +2 -2
- package/components/GasSufficiencyMessage/GasSufficiencyMessage.js +3 -3
- package/components/Header/useHeaderActionStore.d.ts +0 -2
- package/components/Header/useHeaderActionStore.js +0 -3
- package/components/SelectChainAndToken.js +1 -1
- package/components/SwapButton/SwapButton.js +5 -25
- package/components/TokenList/TokenList.js +1 -1
- package/components/TokenList/TokenList.style.js +4 -3
- package/components/TokenList/TokenListItem.js +1 -1
- package/components/TokenList/TokenNotFound.d.ts +2 -1
- package/components/TokenList/TokenNotFound.js +12 -2
- package/components/TokenList/types.d.ts +2 -2
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/useChains.js +24 -11
- package/hooks/useFeaturedTokens.d.ts +1 -1
- package/hooks/useFeaturedTokens.js +6 -3
- package/hooks/useGasSufficiency.d.ts +1 -1
- package/hooks/useGasSufficiency.js +35 -24
- package/hooks/useInitializer.js +6 -0
- package/hooks/useRouteExecution.js +28 -12
- package/hooks/useSwapRoutes.js +3 -4
- package/hooks/useToken.d.ts +0 -1
- package/hooks/useToken.js +1 -2
- package/hooks/useTokenBalances.d.ts +1 -2
- package/hooks/useTokenBalances.js +4 -5
- package/hooks/useTokenSearch.js +3 -2
- package/hooks/useTokens.d.ts +1 -2
- package/hooks/useTokens.js +32 -9
- package/hooks/useTools.js +11 -5
- package/hooks/useWidgetEvents.d.ts +3 -3
- package/hooks/useWidgetEvents.js +2 -2
- package/i18n/en/translation.json +2 -3
- package/i18n/index.d.ts +1 -2
- package/index.d.ts +2 -1
- package/package.json +9 -8
- package/pages/MainPage/MainSwapButton.js +1 -1
- package/pages/SettingsPage/AdvancedPreferences.js +2 -2
- package/pages/SettingsPage/GasPriceSelect.js +2 -2
- package/pages/SettingsPage/RoutePrioritySelect.js +2 -2
- package/pages/SettingsPage/ShowDestinationWallet.js +2 -2
- package/pages/SettingsPage/SlippageInput.js +2 -2
- package/pages/SwapDetailsPage/SwapDetailsPage.js +3 -4
- package/pages/SwapHistoryPage/SwapHistoryPage.js +3 -4
- package/pages/SwapPage/SwapPage.js +11 -2
- package/pages/SwapRoutesPage/SwapRoutesPage.js +5 -4
- package/providers/SDKProvider/SDKProvider.d.ts +4 -0
- package/providers/SDKProvider/SDKProvider.js +19 -0
- package/providers/SDKProvider/index.d.ts +1 -0
- package/providers/SDKProvider/index.js +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +4 -58
- package/providers/SwapFormProvider/types.d.ts +5 -5
- package/providers/TelemetryProvider/TelemetryProvider.d.ts +4 -0
- package/providers/TelemetryProvider/TelemetryProvider.js +7 -0
- package/providers/TelemetryProvider/index.d.ts +1 -0
- package/providers/TelemetryProvider/index.js +1 -0
- package/providers/WalletProvider/WalletProvider.d.ts +1 -4
- package/providers/WalletProvider/WalletProvider.js +59 -1
- package/providers/WidgetProvider/WidgetProvider.js +3 -14
- package/providers/WidgetProvider/index.d.ts +1 -0
- package/providers/WidgetProvider/index.js +1 -0
- package/providers/WidgetProvider/utils.d.ts +4 -0
- package/providers/WidgetProvider/utils.js +9 -0
- package/providers/index.d.ts +2 -0
- package/providers/index.js +2 -0
- package/stores/chains/index.d.ts +0 -1
- package/stores/chains/index.js +0 -1
- package/stores/chains/types.d.ts +1 -1
- package/stores/chains/useChainOrderStore.js +17 -14
- package/stores/route/utils.d.ts +2 -1
- package/stores/route/utils.js +12 -0
- package/stores/settings/index.d.ts +0 -1
- package/stores/settings/index.js +0 -1
- package/stores/settings/useAppearance.js +3 -1
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/events.d.ts +15 -3
- package/types/events.js +4 -3
- package/types/widget.d.ts +29 -22
- package/utils/colors.d.ts +1 -1
- package/cjs/config/lifi.d.ts +0 -4
- package/cjs/config/lifi.js +0 -14
- package/cjs/stores/chains/useInitializeChainOrder.d.ts +0 -1
- package/cjs/stores/chains/useInitializeChainOrder.js +0 -12
- package/cjs/stores/settings/useSetSettings.d.ts +0 -5
- package/cjs/stores/settings/useSetSettings.js +0 -12
- package/config/lifi.d.ts +0 -4
- package/config/lifi.js +0 -7
- package/stores/chains/useInitializeChainOrder.d.ts +0 -1
- package/stores/chains/useInitializeChainOrder.js +0 -5
- package/stores/settings/useSetSettings.d.ts +0 -5
- package/stores/settings/useSetSettings.js +0 -5
|
@@ -1,4 +1,13 @@
|
|
|
1
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
|
+
};
|
|
2
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
13
|
};
|
|
@@ -8,35 +17,28 @@ const big_js_1 = __importDefault(require("big.js"));
|
|
|
8
17
|
const react_1 = require("react");
|
|
9
18
|
const react_hook_form_1 = require("react-hook-form");
|
|
10
19
|
const _1 = require(".");
|
|
11
|
-
const
|
|
12
|
-
const WalletProvider_1 = require("../providers/WalletProvider");
|
|
20
|
+
const providers_1 = require("../providers");
|
|
13
21
|
const useTokenBalances_1 = require("./useTokenBalances");
|
|
14
22
|
const useGasSufficiency = (route) => {
|
|
15
|
-
const
|
|
23
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
24
|
+
const { account } = (0, providers_1.useWallet)();
|
|
16
25
|
const [fromChainId, toChainId, fromToken] = (0, react_hook_form_1.useWatch)({
|
|
17
26
|
name: [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
27
|
+
providers_1.SwapFormKeyHelper.getChainKey('from'),
|
|
28
|
+
providers_1.SwapFormKeyHelper.getChainKey('to'),
|
|
29
|
+
providers_1.SwapFormKey.FromToken,
|
|
21
30
|
],
|
|
22
31
|
});
|
|
23
|
-
const fromAmount = (0, _1.useDebouncedWatch)(
|
|
32
|
+
const fromAmount = (0, _1.useDebouncedWatch)(providers_1.SwapFormKey.FromAmount, 250);
|
|
24
33
|
const { getChainById } = (0, _1.useChains)();
|
|
25
34
|
const { tokensWithBalance: fromChainTokenBalances } = (0, useTokenBalances_1.useTokenBalances)(fromChainId);
|
|
26
|
-
const
|
|
27
|
-
const
|
|
35
|
+
const [insufficientGas, setInsufficientGas] = (0, react_1.useState)();
|
|
36
|
+
const checkInsufficientGas = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
28
37
|
var _a;
|
|
29
|
-
if (!account.isActive ||
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
!fromChainTokenBalances ||
|
|
33
|
-
!toChainTokenBalances) {
|
|
34
|
-
return [];
|
|
38
|
+
if (!account.isActive || !route || !fromAmount) {
|
|
39
|
+
setInsufficientGas(undefined);
|
|
40
|
+
return;
|
|
35
41
|
}
|
|
36
|
-
const tokenBalancesByChain = {
|
|
37
|
-
[fromChainId]: fromChainTokenBalances,
|
|
38
|
-
[toChainId]: toChainTokenBalances,
|
|
39
|
-
};
|
|
40
42
|
const gasCosts = route.steps.reduce((groupedGasCosts, step) => {
|
|
41
43
|
if (step.estimate.gasCosts) {
|
|
42
44
|
const { token } = step.estimate.gasCosts[0];
|
|
@@ -61,30 +63,36 @@ const useGasSufficiency = (route) => {
|
|
|
61
63
|
route.fromToken.address === gasCosts[fromChainId].token.address) {
|
|
62
64
|
gasCosts[fromChainId].tokenAmount = (_a = gasCosts[fromChainId]) === null || _a === void 0 ? void 0 : _a.gasAmount.plus((0, big_js_1.default)(fromAmount));
|
|
63
65
|
}
|
|
66
|
+
const tokenBalances = yield lifi.getTokenBalances(account.address, Object.values(gasCosts).map((item) => item.token));
|
|
67
|
+
if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
|
|
68
|
+
setInsufficientGas(undefined);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
64
71
|
[fromChainId, toChainId].forEach((chainId) => {
|
|
65
|
-
var _a, _b, _c, _d, _e, _f
|
|
72
|
+
var _a, _b, _c, _d, _e, _f;
|
|
66
73
|
if (gasCosts[chainId]) {
|
|
67
|
-
const gasTokenBalance = (0, big_js_1.default)((
|
|
74
|
+
const gasTokenBalance = (0, big_js_1.default)((_b = (_a = tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.find((t) => t.chainId === gasCosts[chainId].token.chainId &&
|
|
75
|
+
t.address === gasCosts[chainId].token.address)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
|
|
68
76
|
const insufficientFromChainGas = gasTokenBalance.lte(0) ||
|
|
69
|
-
gasTokenBalance.lt((
|
|
70
|
-
gasTokenBalance.lt((
|
|
77
|
+
gasTokenBalance.lt((_c = gasCosts[chainId].gasAmount) !== null && _c !== void 0 ? _c : (0, big_js_1.default)(0)) ||
|
|
78
|
+
gasTokenBalance.lt((_d = gasCosts[chainId].tokenAmount) !== null && _d !== void 0 ? _d : (0, big_js_1.default)(0));
|
|
71
79
|
const insufficientFromChainGasAmount = insufficientFromChainGas
|
|
72
|
-
? (
|
|
80
|
+
? (_f = (_e = gasCosts[chainId].tokenAmount) === null || _e === void 0 ? void 0 : _e.minus(gasTokenBalance)) !== null && _f !== void 0 ? _f : gasCosts[chainId].gasAmount.minus(gasTokenBalance)
|
|
73
81
|
: undefined;
|
|
74
82
|
gasCosts[chainId] = Object.assign(Object.assign({}, gasCosts[chainId]), { insufficient: insufficientFromChainGas, insufficientAmount: insufficientFromChainGasAmount });
|
|
75
83
|
}
|
|
76
84
|
});
|
|
77
85
|
const gasCostResult = Object.values(gasCosts).filter((gasCost) => gasCost.insufficient);
|
|
78
|
-
|
|
79
|
-
}, [
|
|
86
|
+
setInsufficientGas(gasCostResult);
|
|
87
|
+
}), [
|
|
88
|
+
account.address,
|
|
80
89
|
account.isActive,
|
|
81
90
|
fromAmount,
|
|
82
91
|
fromChainId,
|
|
83
|
-
fromChainTokenBalances,
|
|
84
92
|
getChainById,
|
|
93
|
+
lifi,
|
|
85
94
|
route,
|
|
86
95
|
toChainId,
|
|
87
|
-
toChainTokenBalances,
|
|
88
96
|
]);
|
|
89
97
|
const insufficientFunds = (0, react_1.useMemo)(() => {
|
|
90
98
|
var _a, _b;
|
|
@@ -97,6 +105,9 @@ const useGasSufficiency = (route) => {
|
|
|
97
105
|
const balance = (0, big_js_1.default)((_b = (_a = fromChainTokenBalances === null || fromChainTokenBalances === void 0 ? void 0 : fromChainTokenBalances.find((t) => t.address === fromToken)) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
|
|
98
106
|
return (0, big_js_1.default)(fromAmount).gt(balance);
|
|
99
107
|
}, [account.isActive, fromAmount, fromChainTokenBalances, fromToken]);
|
|
108
|
+
(0, react_1.useEffect)(() => {
|
|
109
|
+
checkInsufficientGas();
|
|
110
|
+
}, [checkInsufficientGas]);
|
|
100
111
|
return {
|
|
101
112
|
insufficientGas,
|
|
102
113
|
insufficientFunds,
|
|
@@ -2,8 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useInitializer = void 0;
|
|
4
4
|
/* eslint-disable no-underscore-dangle */
|
|
5
|
+
const sdk_1 = require("@lifi/sdk");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const version_1 = require("../config/version");
|
|
5
8
|
const useTools_1 = require("./useTools");
|
|
6
9
|
const useInitializer = () => {
|
|
7
10
|
(0, useTools_1.useTools)();
|
|
11
|
+
(0, react_1.useEffect)(() => {
|
|
12
|
+
(0, sdk_1.checkPackageUpdates)(version_1.name, version_1.version);
|
|
13
|
+
}, []);
|
|
8
14
|
};
|
|
9
15
|
exports.useInitializer = useInitializer;
|
|
@@ -16,28 +16,42 @@ exports.useRouteExecution = void 0;
|
|
|
16
16
|
const react_query_1 = require("@tanstack/react-query");
|
|
17
17
|
const react_1 = require("react");
|
|
18
18
|
const shallow_1 = __importDefault(require("zustand/shallow"));
|
|
19
|
-
const
|
|
20
|
-
const WalletProvider_1 = require("../providers/WalletProvider");
|
|
19
|
+
const providers_1 = require("../providers");
|
|
21
20
|
const stores_1 = require("../stores");
|
|
22
21
|
const events_1 = require("../types/events");
|
|
23
22
|
const utils_1 = require("../utils");
|
|
24
23
|
const useWidgetEvents_1 = require("./useWidgetEvents");
|
|
25
24
|
const useRouteExecution = (routeId, executeInBackground) => {
|
|
26
|
-
const
|
|
25
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
26
|
+
const { account, switchChain } = (0, providers_1.useWallet)();
|
|
27
27
|
const resumedAfterMount = (0, react_1.useRef)(false);
|
|
28
28
|
const emitter = (0, useWidgetEvents_1.useWidgetEvents)();
|
|
29
29
|
const routeExecution = (0, stores_1.useRouteStore)((state) => state.routes[routeId]);
|
|
30
30
|
const [updateRoute, restartRoute, deleteRoute] = (0, stores_1.useRouteStore)((state) => [state.updateRoute, state.restartRoute, state.deleteRoute], shallow_1.default);
|
|
31
31
|
const updateCallback = (updatedRoute) => {
|
|
32
|
+
const routeExecution = stores_1.useRouteStore.getState().routes[updatedRoute.id];
|
|
33
|
+
if (!routeExecution) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
32
36
|
const clonedUpdatedRoute = (0, utils_1.deepClone)(updatedRoute);
|
|
33
|
-
console.log('Route updated.', clonedUpdatedRoute);
|
|
34
37
|
updateRoute(clonedUpdatedRoute);
|
|
38
|
+
const process = (0, stores_1.getUpdatedProcess)(routeExecution.route, clonedUpdatedRoute);
|
|
39
|
+
if (process) {
|
|
40
|
+
emitter.emit(events_1.WidgetEvent.RouteExecutionUpdated, {
|
|
41
|
+
route: clonedUpdatedRoute,
|
|
42
|
+
process,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
35
45
|
if ((0, stores_1.isRouteCompleted)(clonedUpdatedRoute)) {
|
|
36
|
-
emitter.emit(events_1.WidgetEvent.
|
|
46
|
+
emitter.emit(events_1.WidgetEvent.RouteExecutionCompleted, clonedUpdatedRoute);
|
|
37
47
|
}
|
|
38
|
-
if ((0, stores_1.isRouteFailed)(clonedUpdatedRoute)) {
|
|
39
|
-
emitter.emit(events_1.WidgetEvent.
|
|
48
|
+
if ((0, stores_1.isRouteFailed)(clonedUpdatedRoute) && process) {
|
|
49
|
+
emitter.emit(events_1.WidgetEvent.RouteExecutionFailed, {
|
|
50
|
+
route: clonedUpdatedRoute,
|
|
51
|
+
process,
|
|
52
|
+
});
|
|
40
53
|
}
|
|
54
|
+
console.log('Route updated.', clonedUpdatedRoute);
|
|
41
55
|
};
|
|
42
56
|
const switchChainHook = (requiredChainId) => __awaiter(void 0, void 0, void 0, function* () {
|
|
43
57
|
if (!account.isActive || !account.signer) {
|
|
@@ -59,7 +73,7 @@ const useRouteExecution = (routeId, executeInBackground) => {
|
|
|
59
73
|
if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
|
|
60
74
|
throw Error('Execution route not found.');
|
|
61
75
|
}
|
|
62
|
-
return
|
|
76
|
+
return lifi.executeRoute(account.signer, routeExecution.route, {
|
|
63
77
|
updateCallback,
|
|
64
78
|
switchChainHook,
|
|
65
79
|
infiniteApproval: false,
|
|
@@ -68,7 +82,9 @@ const useRouteExecution = (routeId, executeInBackground) => {
|
|
|
68
82
|
}, {
|
|
69
83
|
onMutate: () => {
|
|
70
84
|
console.log('Execution started.', routeId);
|
|
71
|
-
|
|
85
|
+
if (routeExecution) {
|
|
86
|
+
emitter.emit(events_1.WidgetEvent.RouteExecutionStarted, routeExecution.route);
|
|
87
|
+
}
|
|
72
88
|
},
|
|
73
89
|
});
|
|
74
90
|
const resumeRouteMutation = (0, react_query_1.useMutation)((resumedRoute) => {
|
|
@@ -78,7 +94,7 @@ const useRouteExecution = (routeId, executeInBackground) => {
|
|
|
78
94
|
if (!(routeExecution === null || routeExecution === void 0 ? void 0 : routeExecution.route)) {
|
|
79
95
|
throw Error('Execution route not found.');
|
|
80
96
|
}
|
|
81
|
-
return
|
|
97
|
+
return lifi.resumeRoute(account.signer, resumedRoute !== null && resumedRoute !== void 0 ? resumedRoute : routeExecution.route, {
|
|
82
98
|
updateCallback,
|
|
83
99
|
switchChainHook,
|
|
84
100
|
infiniteApproval: false,
|
|
@@ -138,11 +154,11 @@ const useRouteExecution = (routeId, executeInBackground) => {
|
|
|
138
154
|
if (!route || !(0, stores_1.isRouteActive)(route)) {
|
|
139
155
|
return;
|
|
140
156
|
}
|
|
141
|
-
|
|
157
|
+
lifi.updateRouteExecution(route, { executeInBackground: true });
|
|
142
158
|
console.log('Move route execution to background.', routeId);
|
|
143
159
|
resumedAfterMount.current = false;
|
|
144
160
|
};
|
|
145
|
-
}, [routeId]);
|
|
161
|
+
}, [lifi, routeId]);
|
|
146
162
|
return {
|
|
147
163
|
executeRoute,
|
|
148
164
|
restartRoute: restartRouteMutation,
|
|
@@ -18,14 +18,13 @@ const react_query_1 = require("@tanstack/react-query");
|
|
|
18
18
|
const big_js_1 = __importDefault(require("big.js"));
|
|
19
19
|
const react_hook_form_1 = require("react-hook-form");
|
|
20
20
|
const _1 = require(".");
|
|
21
|
-
const
|
|
22
|
-
const SwapFormProvider_1 = require("../providers/SwapFormProvider");
|
|
23
|
-
const WalletProvider_1 = require("../providers/WalletProvider");
|
|
21
|
+
const providers_1 = require("../providers");
|
|
24
22
|
const stores_1 = require("../stores");
|
|
25
23
|
const refetchTime = 60000;
|
|
26
24
|
const useSwapRoutes = () => {
|
|
27
25
|
var _a;
|
|
28
|
-
const
|
|
26
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
27
|
+
const { account, provider } = (0, providers_1.useWallet)();
|
|
29
28
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
30
29
|
const { slippage, enabledBridges, enabledExchanges, routePriority } = (0, stores_1.useSettings)([
|
|
31
30
|
'slippage',
|
|
@@ -35,14 +34,14 @@ const useSwapRoutes = () => {
|
|
|
35
34
|
]);
|
|
36
35
|
const [fromChainId, fromTokenAddress, toChainId, toTokenAddress, toAddress] = (0, react_hook_form_1.useWatch)({
|
|
37
36
|
name: [
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
providers_1.SwapFormKey.FromChain,
|
|
38
|
+
providers_1.SwapFormKey.FromToken,
|
|
39
|
+
providers_1.SwapFormKey.ToChain,
|
|
40
|
+
providers_1.SwapFormKey.ToToken,
|
|
41
|
+
providers_1.SwapFormKey.ToAddress,
|
|
43
42
|
],
|
|
44
43
|
});
|
|
45
|
-
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([
|
|
44
|
+
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([providers_1.SwapFormKey.FromAmount], 250);
|
|
46
45
|
const { token } = (0, _1.useToken)(fromChainId, fromTokenAddress);
|
|
47
46
|
const isEnabled =
|
|
48
47
|
// Boolean(account.address) &&
|
|
@@ -81,7 +80,7 @@ const useSwapRoutes = () => {
|
|
|
81
80
|
catch (_d) {
|
|
82
81
|
toWalletAddress = (0, address_1.isAddress)(toAddress) ? toAddress : fromAddress;
|
|
83
82
|
}
|
|
84
|
-
return
|
|
83
|
+
return lifi.getRoutes({
|
|
85
84
|
fromChainId,
|
|
86
85
|
fromAmount: (0, big_js_1.default)(Number(fromTokenAmount) * Math.pow(10, ((_c = token === null || token === void 0 ? void 0 : token.decimals) !== null && _c !== void 0 ? _c : 0))).toString(),
|
|
87
86
|
fromTokenAddress,
|
package/cjs/hooks/useToken.d.ts
CHANGED
package/cjs/hooks/useToken.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.useToken = void 0;
|
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const useTokens_1 = require("./useTokens");
|
|
6
6
|
const useToken = (chainId, tokenAddress) => {
|
|
7
|
-
const { tokens, isLoading
|
|
7
|
+
const { tokens, isLoading } = (0, useTokens_1.useTokens)(chainId);
|
|
8
8
|
const token = (0, react_1.useMemo)(() => {
|
|
9
9
|
const token = tokens === null || tokens === void 0 ? void 0 : tokens.find((token) => token.address === tokenAddress && token.chainId === chainId);
|
|
10
10
|
return token;
|
|
@@ -12,7 +12,6 @@ const useToken = (chainId, tokenAddress) => {
|
|
|
12
12
|
return {
|
|
13
13
|
token,
|
|
14
14
|
isLoading,
|
|
15
|
-
isFetching,
|
|
16
15
|
};
|
|
17
16
|
};
|
|
18
17
|
exports.useToken = useToken;
|
|
@@ -2,9 +2,8 @@ import type { Token } from '../types';
|
|
|
2
2
|
export declare const useTokenBalances: (selectedChainId: number) => {
|
|
3
3
|
tokens: Token[] | undefined;
|
|
4
4
|
tokensWithBalance: Token[] | undefined;
|
|
5
|
-
featuredTokens: import("@lifi/types").Token[]
|
|
5
|
+
featuredTokens: import("@lifi/types").Token[];
|
|
6
6
|
isLoading: boolean;
|
|
7
7
|
isBalanceLoading: boolean;
|
|
8
|
-
isBalanceFetched: boolean;
|
|
9
8
|
refetch: <TPageData>(options?: (import("@tanstack/react-query").RefetchOptions & import("@tanstack/react-query").RefetchQueryFilters<TPageData>) | undefined) => Promise<import("@tanstack/react-query").QueryObserverResult<Token[] | undefined, unknown>>;
|
|
10
9
|
};
|
|
@@ -13,24 +13,24 @@ exports.useTokenBalances = void 0;
|
|
|
13
13
|
/* eslint-disable consistent-return */
|
|
14
14
|
const react_query_1 = require("@tanstack/react-query");
|
|
15
15
|
const react_1 = require("react");
|
|
16
|
-
const
|
|
17
|
-
const WalletProvider_1 = require("../providers/WalletProvider");
|
|
16
|
+
const providers_1 = require("../providers");
|
|
18
17
|
const utils_1 = require("../utils");
|
|
19
18
|
const useFeaturedTokens_1 = require("./useFeaturedTokens");
|
|
20
19
|
const useTokens_1 = require("./useTokens");
|
|
21
20
|
const defaultRefetchInterval = 60000;
|
|
22
21
|
const minRefetchInterval = 1000;
|
|
23
22
|
const useTokenBalances = (selectedChainId) => {
|
|
24
|
-
const
|
|
23
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
24
|
+
const { account } = (0, providers_1.useWallet)();
|
|
25
25
|
const featuredTokens = (0, useFeaturedTokens_1.useFeaturedTokens)(selectedChainId);
|
|
26
26
|
const { tokens, isLoading } = (0, useTokens_1.useTokens)(selectedChainId);
|
|
27
27
|
const [refetchInterval, setRefetchInterval] = (0, react_1.useState)(defaultRefetchInterval);
|
|
28
28
|
const isBalanceLoadingEnabled = Boolean(account.address) && Boolean(tokens === null || tokens === void 0 ? void 0 : tokens.length);
|
|
29
|
-
const { data: tokensWithBalance, isLoading: isBalanceLoading,
|
|
29
|
+
const { data: tokensWithBalance, isLoading: isBalanceLoading, refetch, } = (0, react_query_1.useQuery)(['token-balances', account.address, selectedChainId, tokens === null || tokens === void 0 ? void 0 : tokens.length], ({ queryKey: [, accountAddress] }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
30
|
if (!accountAddress || !tokens) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
const tokenBalances = yield
|
|
33
|
+
const tokenBalances = yield lifi.getTokenBalances(accountAddress, tokens);
|
|
34
34
|
if (!(tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.length)) {
|
|
35
35
|
// Sometimes RPCs (e.g. Arbitrum) don't return balances on first call
|
|
36
36
|
// TODO: fix and remove backplane
|
|
@@ -73,7 +73,6 @@ const useTokenBalances = (selectedChainId) => {
|
|
|
73
73
|
featuredTokens,
|
|
74
74
|
isLoading,
|
|
75
75
|
isBalanceLoading: isBalanceLoading && isBalanceLoadingEnabled,
|
|
76
|
-
isBalanceFetched,
|
|
77
76
|
refetch,
|
|
78
77
|
};
|
|
79
78
|
};
|
|
@@ -11,11 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.useTokenSearch = void 0;
|
|
13
13
|
const react_query_1 = require("@tanstack/react-query");
|
|
14
|
-
const
|
|
14
|
+
const providers_1 = require("../providers");
|
|
15
15
|
const useTokenSearch = (token, chainId, enabled) => {
|
|
16
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
16
17
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
17
18
|
const { data, isLoading, isFetching, isFetched } = (0, react_query_1.useQuery)(['token-search', chainId, token], ({ queryKey: [, chainId, token], signal }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const data = yield
|
|
19
|
+
const data = yield lifi.getToken(chainId, token, {
|
|
19
20
|
signal,
|
|
20
21
|
});
|
|
21
22
|
if (data) {
|
package/cjs/hooks/useTokens.d.ts
CHANGED
package/cjs/hooks/useTokens.js
CHANGED
|
@@ -11,26 +11,49 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.useTokens = void 0;
|
|
13
13
|
const react_query_1 = require("@tanstack/react-query");
|
|
14
|
-
const
|
|
14
|
+
const providers_1 = require("../providers");
|
|
15
15
|
const useFeaturedTokens_1 = require("./useFeaturedTokens");
|
|
16
16
|
const useTokens = (selectedChainId) => {
|
|
17
|
+
var _a, _b, _c, _d;
|
|
18
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
17
19
|
const featuredTokens = (0, useFeaturedTokens_1.useFeaturedTokens)(selectedChainId);
|
|
18
|
-
const {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const { tokens, chains, disabledChains } = (0, providers_1.useWidgetConfig)();
|
|
21
|
+
const { data, isLoading } = (0, react_query_1.useQuery)([
|
|
22
|
+
'tokens',
|
|
23
|
+
selectedChainId,
|
|
24
|
+
featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.length,
|
|
25
|
+
(_a = tokens === null || tokens === void 0 ? void 0 : tokens.allow) === null || _a === void 0 ? void 0 : _a.length,
|
|
26
|
+
(_b = tokens === null || tokens === void 0 ? void 0 : tokens.deny) === null || _b === void 0 ? void 0 : _b.length,
|
|
27
|
+
(_c = chains === null || chains === void 0 ? void 0 : chains.allow) === null || _c === void 0 ? void 0 : _c.length,
|
|
28
|
+
(_d = chains === null || chains === void 0 ? void 0 : chains.deny) === null || _d === void 0 ? void 0 : _d.length,
|
|
29
|
+
], () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
var _e, _f, _g, _h, _j;
|
|
31
|
+
const chainAllowed = selectedChainId &&
|
|
32
|
+
(0, providers_1.isItemAllowed)(selectedChainId, chains, disabledChains);
|
|
33
|
+
if (!chainAllowed) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
let filteredTokens = (_e = tokens === null || tokens === void 0 ? void 0 : tokens.allow) === null || _e === void 0 ? void 0 : _e.filter((token) => token.chainId === selectedChainId);
|
|
37
|
+
if (!(filteredTokens === null || filteredTokens === void 0 ? void 0 : filteredTokens.length)) {
|
|
38
|
+
const data = yield lifi.getTokens({ chains: [selectedChainId] });
|
|
39
|
+
filteredTokens = (_f = data.tokens) === null || _f === void 0 ? void 0 : _f[selectedChainId];
|
|
40
|
+
}
|
|
41
|
+
const deniedTokenAddresses = (_g = tokens === null || tokens === void 0 ? void 0 : tokens.deny) === null || _g === void 0 ? void 0 : _g.filter((token) => token.chainId === selectedChainId).map((token) => token.address);
|
|
42
|
+
if (deniedTokenAddresses === null || deniedTokenAddresses === void 0 ? void 0 : deniedTokenAddresses.length) {
|
|
43
|
+
filteredTokens = filteredTokens === null || filteredTokens === void 0 ? void 0 : filteredTokens.filter((token) => !deniedTokenAddresses.includes(token.address));
|
|
44
|
+
}
|
|
21
45
|
const featuredTokenAddresses = new Set(featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.map((token) => token.address));
|
|
22
46
|
return [
|
|
23
|
-
...((
|
|
47
|
+
...((_h = featuredTokens === null || featuredTokens === void 0 ? void 0 : featuredTokens.map((token) => {
|
|
24
48
|
token.featured = true;
|
|
25
49
|
return token;
|
|
26
|
-
})) !== null &&
|
|
27
|
-
...((
|
|
50
|
+
})) !== null && _h !== void 0 ? _h : []),
|
|
51
|
+
...((_j = filteredTokens === null || filteredTokens === void 0 ? void 0 : filteredTokens.filter((token) => !featuredTokenAddresses.has(token.address))) !== null && _j !== void 0 ? _j : []),
|
|
28
52
|
];
|
|
29
53
|
}));
|
|
30
54
|
return {
|
|
31
|
-
tokens,
|
|
55
|
+
tokens: data,
|
|
32
56
|
isLoading,
|
|
33
|
-
isFetching,
|
|
34
57
|
};
|
|
35
58
|
};
|
|
36
59
|
exports.useTokens = useTokens;
|
package/cjs/hooks/useTools.js
CHANGED
|
@@ -3,14 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useTools = void 0;
|
|
4
4
|
const react_query_1 = require("@tanstack/react-query");
|
|
5
5
|
const react_1 = require("react");
|
|
6
|
-
const
|
|
6
|
+
const providers_1 = require("../providers");
|
|
7
7
|
const stores_1 = require("../stores");
|
|
8
8
|
const useTools = () => {
|
|
9
|
-
const
|
|
10
|
-
const {
|
|
9
|
+
const lifi = (0, providers_1.useLiFi)();
|
|
10
|
+
const { bridges, exchanges } = (0, providers_1.useWidgetConfig)();
|
|
11
|
+
const { data } = (0, react_query_1.useQuery)(['tools'], ({ signal }) => lifi.getTools(undefined, { signal }), {
|
|
11
12
|
onSuccess(data) {
|
|
12
|
-
initializeTools
|
|
13
|
-
initializeTools('
|
|
13
|
+
const { initializeTools } = stores_1.useSettingsStore.getState();
|
|
14
|
+
initializeTools('Bridges', data.bridges
|
|
15
|
+
.filter((bridge) => (0, providers_1.isItemAllowed)(bridge.key, bridges))
|
|
16
|
+
.map((bridge) => bridge.key));
|
|
17
|
+
initializeTools('Exchanges', data.exchanges
|
|
18
|
+
.filter((exchange) => (0, providers_1.isItemAllowed)(exchange.key, exchanges))
|
|
19
|
+
.map((exchange) => exchange.key));
|
|
14
20
|
},
|
|
15
21
|
});
|
|
16
22
|
const formattedTools = (0, react_1.useMemo)(() => ({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
export declare const useWidgetEvents: () =>
|
|
1
|
+
import type { Emitter } from 'mitt';
|
|
2
|
+
import type { WidgetEvents } from '../types';
|
|
3
|
+
export declare const useWidgetEvents: () => Emitter<WidgetEvents>;
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.useWidgetEvents = void 0;
|
|
7
|
-
const
|
|
7
|
+
const mitt_1 = __importDefault(require("mitt"));
|
|
8
8
|
const zustand_1 = __importDefault(require("zustand"));
|
|
9
|
-
const emitterStore = (0, zustand_1.default)()(() =>
|
|
9
|
+
const emitterStore = (0, zustand_1.default)()(() => (0, mitt_1.default)());
|
|
10
10
|
const useWidgetEvents = () => {
|
|
11
11
|
return emitterStore();
|
|
12
12
|
};
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
},
|
|
16
16
|
"button": {
|
|
17
17
|
"connectWallet": "Connect wallet",
|
|
18
|
-
"switchChain": "Switch chain",
|
|
19
18
|
"swap": "Swap",
|
|
20
19
|
"reviewSwap": "Review swap",
|
|
21
20
|
"startSwap": "Start swap",
|
|
@@ -56,7 +55,6 @@
|
|
|
56
55
|
"featuredTokens": "Featured tokens",
|
|
57
56
|
"otherTokens": "Other tokens",
|
|
58
57
|
"inProgress": "in progress",
|
|
59
|
-
"couldntFindTokens": "We couldn't find tokens on this chain or you don't have any.",
|
|
60
58
|
"stepSwap": "Swap",
|
|
61
59
|
"stepBridge": "Bridge",
|
|
62
60
|
"stepSwapAndBridge": "Swap and bridge",
|
|
@@ -92,7 +90,8 @@
|
|
|
92
90
|
"message": {
|
|
93
91
|
"routeNotFound": "Try another token combination.",
|
|
94
92
|
"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."
|
|
93
|
+
"emptyActiveSwaps": "Swaps in progress will appear here. Once completed, find them in swap history.",
|
|
94
|
+
"emptyTokenList": "We couldn't find tokens on {{chainName}} chain or you don't have any. Please try search again or choose another chain."
|
|
96
95
|
}
|
|
97
96
|
},
|
|
98
97
|
"warning": {
|
package/cjs/i18n/index.d.ts
CHANGED
|
@@ -18,7 +18,6 @@ export declare const resources: {
|
|
|
18
18
|
};
|
|
19
19
|
button: {
|
|
20
20
|
connectWallet: string;
|
|
21
|
-
switchChain: string;
|
|
22
21
|
swap: string;
|
|
23
22
|
reviewSwap: string;
|
|
24
23
|
startSwap: string;
|
|
@@ -59,7 +58,6 @@ export declare const resources: {
|
|
|
59
58
|
featuredTokens: string;
|
|
60
59
|
otherTokens: string;
|
|
61
60
|
inProgress: string;
|
|
62
|
-
couldntFindTokens: string;
|
|
63
61
|
stepSwap: string;
|
|
64
62
|
stepBridge: string;
|
|
65
63
|
stepSwapAndBridge: string;
|
|
@@ -96,6 +94,7 @@ export declare const resources: {
|
|
|
96
94
|
routeNotFound: string;
|
|
97
95
|
emptySwapHistory: string;
|
|
98
96
|
emptyActiveSwaps: string;
|
|
97
|
+
emptyTokenList: string;
|
|
99
98
|
};
|
|
100
99
|
};
|
|
101
100
|
warning: {
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import './fonts/inter.css';
|
|
3
|
+
export type { WidgetDrawer, WidgetDrawerProps } from './AppDrawer';
|
|
3
4
|
export { useWidgetEvents } from './hooks';
|
|
4
5
|
export * from './types';
|
|
5
6
|
export declare const LiFiWidget: import("react").FC<import("./AppProvider").AppProps>;
|
|
6
|
-
export declare const LiFiWidgetDrawer: import("react").ForwardRefExoticComponent<Pick<import("./AppDrawer").
|
|
7
|
+
export declare const LiFiWidgetDrawer: import("react").ForwardRefExoticComponent<Pick<import("./AppDrawer").WidgetDrawerProps, "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").WidgetDrawer>>;
|
|
@@ -31,6 +31,6 @@ const MainSwapButton = () => {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
});
|
|
34
|
-
return ((0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { onClick: handleClick, currentRoute: currentRoute, disable: isLoading || isFetching ||
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)(SwapButton_1.SwapButton, { onClick: handleClick, currentRoute: currentRoute, disable: isLoading || isFetching || isValidating || !isValid }));
|
|
35
35
|
};
|
|
36
36
|
exports.MainSwapButton = MainSwapButton;
|
|
@@ -10,7 +10,7 @@ const EnabledBridgesSelect_1 = require("./EnabledBridgesSelect");
|
|
|
10
10
|
const EnabledExchangesSelect_1 = require("./EnabledExchangesSelect");
|
|
11
11
|
const AdvancedPreferences = () => {
|
|
12
12
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
13
|
-
const
|
|
13
|
+
const setValue = (0, stores_1.useSettingsStore)((state) => state.setValue);
|
|
14
14
|
const { advancedPreferences } = (0, stores_1.useSettings)(['advancedPreferences']);
|
|
15
15
|
const handleAdvancedPreferences = (_, checked) => {
|
|
16
16
|
setValue('advancedPreferences', checked);
|
|
@@ -10,7 +10,7 @@ const Select_1 = require("../../components/Select");
|
|
|
10
10
|
const stores_1 = require("../../stores");
|
|
11
11
|
const GasPriceSelect = () => {
|
|
12
12
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
13
|
-
const
|
|
13
|
+
const setValue = (0, stores_1.useSettingsStore)((state) => state.setValue);
|
|
14
14
|
const { gasPrice } = (0, stores_1.useSettings)(['gasPrice']);
|
|
15
15
|
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, Object.assign({ flex: 1 }, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.gasPrice.title`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsxs)(Select_1.Select, Object.assign({ MenuProps: { elevation: 2 }, value: gasPrice, onChange: (event) => setValue('gasPrice', event.target.value), IconComponent: icons_material_1.KeyboardArrowDown, dense: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: "slow" }, { children: t(`settings.gasPrice.slow`) })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: "normal" }, { children: t(`settings.gasPrice.normal`) })), (0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: "fast" }, { children: t(`settings.gasPrice.fast`) }))] })) }))] })));
|
|
16
16
|
};
|
|
@@ -11,7 +11,7 @@ const Select_1 = require("../../components/Select");
|
|
|
11
11
|
const stores_1 = require("../../stores");
|
|
12
12
|
const RoutePrioritySelect = () => {
|
|
13
13
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
14
|
-
const
|
|
14
|
+
const setValue = (0, stores_1.useSettingsStore)((state) => state.setValue);
|
|
15
15
|
const { routePriority } = (0, stores_1.useSettings)(['routePriority']);
|
|
16
16
|
return ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`settings.routePriority`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ MenuProps: { elevation: 2 }, value: routePriority, onChange: (event) => setValue('routePriority', event.target.value), IconComponent: icons_material_1.KeyboardArrowDown, dense: true }, { children: sdk_1.Orders.map((order) => {
|
|
17
17
|
const tag = t(`swap.tags.${order.toUpperCase()}`);
|