@lifi/widget 1.13.7 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/components/Header/Header.js +2 -2
- package/cjs/components/Header/NavigationHeader.js +5 -7
- package/cjs/components/Header/WalletHeader.js +4 -5
- package/cjs/components/ReverseTokensButton/ReverseTokensButton.js +10 -10
- package/cjs/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
- package/cjs/components/SelectTokenButton/SelectTokenButton.js +3 -3
- package/cjs/components/{SwapInProgress/SwapInProgress.d.ts → SendToWallet/SendToWallet.d.ts} +1 -1
- package/cjs/components/SendToWallet/SendToWallet.js +53 -0
- package/cjs/components/SendToWallet/SendToWallet.style.d.ts +19 -0
- package/cjs/components/SendToWallet/SendToWallet.style.js +15 -0
- package/cjs/components/SendToWallet/index.d.ts +1 -0
- package/cjs/components/{SwapInProgress → SendToWallet}/index.js +1 -1
- package/cjs/components/Step/StepTimer.js +1 -1
- package/cjs/components/SwapButton/SwapButton.js +11 -8
- package/cjs/components/SwapInput/FormPriceHelperText.d.ts +1 -1
- package/cjs/components/SwapInput/FormPriceHelperText.js +4 -4
- package/cjs/components/SwapInput/SwapInput.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInput.js +4 -4
- package/cjs/components/SwapInput/SwapInputAdornment.d.ts +1 -1
- package/cjs/components/SwapInput/SwapInputAdornment.js +4 -4
- package/cjs/components/SwapRouteCard/SwapRouteCard.js +4 -3
- package/cjs/components/SwapRouteCard/SwapRouteCard.style.js +3 -3
- package/cjs/components/SwapsInProgress/SwapsInProgress.d.ts +3 -0
- package/cjs/components/SwapsInProgress/SwapsInProgress.js +29 -0
- package/cjs/components/{SwapInProgress/SwapInProgress.style.d.ts → SwapsInProgress/SwapsInProgress.style.d.ts} +0 -0
- package/cjs/components/{SwapInProgress/SwapInProgress.style.js → SwapsInProgress/SwapsInProgress.style.js} +0 -0
- package/cjs/components/SwapsInProgress/index.d.ts +1 -0
- package/cjs/components/SwapsInProgress/index.js +17 -0
- package/cjs/components/TokenList/TokenList.js +10 -11
- package/cjs/components/TokenList/VirtualizedTokenList.js +1 -1
- package/cjs/components/TokenList/types.d.ts +1 -1
- package/cjs/config/lifi.js +3 -1
- package/cjs/config/version.d.ts +1 -1
- package/cjs/config/version.js +1 -1
- package/cjs/hooks/index.d.ts +1 -0
- package/cjs/hooks/index.js +1 -0
- package/cjs/hooks/useNavigateBack.d.ts +4 -0
- package/cjs/hooks/useNavigateBack.js +18 -0
- package/cjs/hooks/useSwapRoutes.js +18 -7
- package/cjs/i18n/en/translation.json +13 -8
- package/cjs/i18n/index.d.ts +11 -6
- package/cjs/pages/MainPage/MainPage.js +3 -2
- package/cjs/pages/SelectTokenPage/ChainSelect.d.ts +1 -1
- package/cjs/pages/SelectTokenPage/ChainSelect.js +11 -12
- package/cjs/pages/SelectTokenPage/SearchTokenInput.js +3 -3
- package/cjs/pages/SelectTokenPage/SelectTokenPage.d.ts +1 -1
- package/cjs/pages/SelectTokenPage/SelectTokenPage.js +2 -6
- package/cjs/pages/SelectWalletPage/SelectWalletPage.js +6 -6
- package/cjs/pages/SettingsPage/AdvancedPreferences.js +2 -2
- package/cjs/pages/SettingsPage/ColorSchemeButtonGroup.js +2 -2
- package/cjs/pages/SettingsPage/SettingsPage.js +2 -1
- package/cjs/pages/SettingsPage/ShowDestinationWallet.d.ts +2 -0
- package/cjs/pages/SettingsPage/ShowDestinationWallet.js +22 -0
- package/cjs/pages/SwapDetailsPage/SwapDetailsPage.js +3 -2
- package/cjs/pages/SwapHistoryPage/SwapHistoryPage.js +2 -2
- package/cjs/pages/SwapPage/StatusBottomSheet.js +4 -5
- package/cjs/pages/SwapPage/SwapPage.js +2 -2
- package/cjs/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/cjs/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -0
- package/cjs/providers/SwapFormProvider/SwapFormProvider.js +10 -4
- package/cjs/providers/SwapFormProvider/types.d.ts +3 -1
- package/cjs/providers/SwapFormProvider/types.js +1 -0
- package/cjs/providers/WalletProvider/WalletProvider.js +5 -4
- package/cjs/providers/WalletProvider/types.d.ts +4 -2
- package/cjs/providers/WidgetProvider/WidgetProvider.js +4 -0
- package/cjs/providers/index.d.ts +4 -0
- package/cjs/providers/index.js +20 -0
- package/cjs/stores/route/useRouteStore.js +36 -0
- package/cjs/stores/settings/types.d.ts +2 -1
- package/cjs/stores/settings/useSettingsStore.d.ts +4 -2
- package/cjs/stores/settings/useSettingsStore.js +1 -0
- package/cjs/types/widget.d.ts +1 -0
- package/cjs/utils/format.js +7 -2
- package/components/Header/Header.js +1 -1
- package/components/Header/NavigationHeader.js +5 -7
- package/components/Header/WalletHeader.js +1 -2
- package/components/ReverseTokensButton/ReverseTokensButton.js +1 -1
- package/components/SelectTokenButton/SelectTokenButton.d.ts +1 -1
- package/components/SelectTokenButton/SelectTokenButton.js +1 -1
- package/components/{SwapInProgress/SwapInProgress.d.ts → SendToWallet/SendToWallet.d.ts} +1 -1
- package/components/SendToWallet/SendToWallet.js +49 -0
- package/components/SendToWallet/SendToWallet.style.d.ts +19 -0
- package/components/SendToWallet/SendToWallet.style.js +12 -0
- package/components/SendToWallet/index.d.ts +1 -0
- package/components/SendToWallet/index.js +1 -0
- package/components/Step/StepTimer.js +1 -1
- package/components/SwapButton/SwapButton.js +9 -6
- package/components/SwapInput/FormPriceHelperText.d.ts +1 -1
- package/components/SwapInput/FormPriceHelperText.js +1 -1
- package/components/SwapInput/SwapInput.d.ts +1 -1
- package/components/SwapInput/SwapInput.js +1 -1
- package/components/SwapInput/SwapInputAdornment.d.ts +1 -1
- package/components/SwapInput/SwapInputAdornment.js +1 -1
- package/components/SwapRouteCard/SwapRouteCard.js +4 -3
- package/components/SwapRouteCard/SwapRouteCard.style.js +3 -3
- package/components/SwapsInProgress/SwapsInProgress.d.ts +3 -0
- package/components/{SwapInProgress/SwapInProgress.js → SwapsInProgress/SwapsInProgress.js} +4 -4
- package/components/{SwapInProgress/SwapInProgress.style.d.ts → SwapsInProgress/SwapsInProgress.style.d.ts} +0 -0
- package/components/{SwapInProgress/SwapInProgress.style.js → SwapsInProgress/SwapsInProgress.style.js} +0 -0
- package/components/SwapsInProgress/index.d.ts +1 -0
- package/components/SwapsInProgress/index.js +1 -0
- package/components/TokenList/TokenList.js +1 -2
- package/components/TokenList/VirtualizedTokenList.js +1 -1
- package/components/TokenList/types.d.ts +1 -1
- package/config/lifi.js +3 -1
- package/config/version.d.ts +1 -1
- package/config/version.js +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/useNavigateBack.d.ts +4 -0
- package/hooks/useNavigateBack.js +14 -0
- package/hooks/useSwapRoutes.js +18 -7
- package/i18n/en/translation.json +13 -8
- package/i18n/index.d.ts +11 -6
- package/package.json +9 -12
- package/pages/MainPage/MainPage.js +3 -2
- package/pages/SelectTokenPage/ChainSelect.d.ts +1 -1
- package/pages/SelectTokenPage/ChainSelect.js +9 -10
- package/pages/SelectTokenPage/SearchTokenInput.js +1 -1
- package/pages/SelectTokenPage/SelectTokenPage.d.ts +1 -1
- package/pages/SelectTokenPage/SelectTokenPage.js +3 -7
- package/pages/SelectWalletPage/SelectWalletPage.js +5 -5
- package/pages/SettingsPage/AdvancedPreferences.js +2 -2
- package/pages/SettingsPage/ColorSchemeButtonGroup.js +1 -1
- package/pages/SettingsPage/SettingsPage.js +2 -1
- package/pages/SettingsPage/ShowDestinationWallet.d.ts +2 -0
- package/pages/SettingsPage/ShowDestinationWallet.js +18 -0
- package/pages/SwapDetailsPage/SwapDetailsPage.js +4 -3
- package/pages/SwapHistoryPage/SwapHistoryPage.js +1 -1
- package/pages/SwapPage/StatusBottomSheet.js +4 -5
- package/pages/SwapPage/SwapPage.js +4 -4
- package/pages/SwapRoutesPage/SwapRoutesPage.js +1 -1
- package/providers/SwapFormProvider/SwapFormProvider.d.ts +1 -0
- package/providers/SwapFormProvider/SwapFormProvider.js +10 -4
- package/providers/SwapFormProvider/types.d.ts +3 -1
- package/providers/SwapFormProvider/types.js +1 -0
- package/providers/WalletProvider/WalletProvider.js +5 -4
- package/providers/WalletProvider/types.d.ts +4 -2
- package/providers/WidgetProvider/WidgetProvider.js +5 -1
- package/providers/index.d.ts +4 -0
- package/providers/index.js +4 -0
- package/stores/route/useRouteStore.js +36 -0
- package/stores/settings/types.d.ts +2 -1
- package/stores/settings/useSettingsStore.d.ts +4 -2
- package/stores/settings/useSettingsStore.js +1 -0
- package/tsconfig.cjs.tsbuildinfo +1 -1
- package/types/widget.d.ts +1 -0
- package/utils/format.js +7 -2
- package/cjs/components/SwapInProgress/SwapInProgress.js +0 -29
- package/cjs/components/SwapInProgress/index.d.ts +0 -1
- package/components/SwapInProgress/index.d.ts +0 -1
- package/components/SwapInProgress/index.js +0 -1
package/cjs/hooks/index.js
CHANGED
|
@@ -21,6 +21,7 @@ __exportStar(require("./useDebouncedWatch"), exports);
|
|
|
21
21
|
__exportStar(require("./useFeaturedTokens"), exports);
|
|
22
22
|
__exportStar(require("./useGasSufficiency"), exports);
|
|
23
23
|
__exportStar(require("./useInitializer"), exports);
|
|
24
|
+
__exportStar(require("./useNavigateBack"), exports);
|
|
24
25
|
__exportStar(require("./useRouteExecution"), exports);
|
|
25
26
|
__exportStar(require("./useScrollableContainer"), exports);
|
|
26
27
|
__exportStar(require("./useSwapRoutes"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useNavigateBack = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const react_router_dom_1 = require("react-router-dom");
|
|
6
|
+
const useNavigateBack = () => {
|
|
7
|
+
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
8
|
+
const navigateBack = (0, react_1.useCallback)(() => {
|
|
9
|
+
if (window.history.state && window.history.state.idx > 0) {
|
|
10
|
+
navigate(-1);
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
navigate(window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/')) || '/', { replace: true });
|
|
14
|
+
}
|
|
15
|
+
}, [navigate]);
|
|
16
|
+
return { navigateBack, navigate };
|
|
17
|
+
};
|
|
18
|
+
exports.useNavigateBack = useNavigateBack;
|
|
@@ -13,6 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.useSwapRoutes = void 0;
|
|
16
|
+
const address_1 = require("@ethersproject/address");
|
|
16
17
|
const react_query_1 = require("@tanstack/react-query");
|
|
17
18
|
const big_js_1 = __importDefault(require("big.js"));
|
|
18
19
|
const react_hook_form_1 = require("react-hook-form");
|
|
@@ -24,7 +25,7 @@ const stores_1 = require("../stores");
|
|
|
24
25
|
const refetchTime = 60000;
|
|
25
26
|
const useSwapRoutes = () => {
|
|
26
27
|
var _a;
|
|
27
|
-
const { account } = (0, WalletProvider_1.useWallet)();
|
|
28
|
+
const { account, provider } = (0, WalletProvider_1.useWallet)();
|
|
28
29
|
const queryClient = (0, react_query_1.useQueryClient)();
|
|
29
30
|
const { slippage, enabledBridges, enabledExchanges, routePriority } = (0, stores_1.useSettings)([
|
|
30
31
|
'slippage',
|
|
@@ -32,12 +33,13 @@ const useSwapRoutes = () => {
|
|
|
32
33
|
'enabledBridges',
|
|
33
34
|
'enabledExchanges',
|
|
34
35
|
]);
|
|
35
|
-
const [fromChainId, fromTokenAddress, toChainId, toTokenAddress] = (0, react_hook_form_1.useWatch)({
|
|
36
|
+
const [fromChainId, fromTokenAddress, toChainId, toTokenAddress, toAddress] = (0, react_hook_form_1.useWatch)({
|
|
36
37
|
name: [
|
|
37
38
|
SwapFormProvider_1.SwapFormKey.FromChain,
|
|
38
39
|
SwapFormProvider_1.SwapFormKey.FromToken,
|
|
39
40
|
SwapFormProvider_1.SwapFormKey.ToChain,
|
|
40
41
|
SwapFormProvider_1.SwapFormKey.ToToken,
|
|
42
|
+
SwapFormProvider_1.SwapFormKey.ToAddress,
|
|
41
43
|
],
|
|
42
44
|
});
|
|
43
45
|
const [fromTokenAmount] = (0, _1.useDebouncedWatch)([SwapFormProvider_1.SwapFormKey.FromAmount], 250);
|
|
@@ -59,6 +61,7 @@ const useSwapRoutes = () => {
|
|
|
59
61
|
fromTokenAmount,
|
|
60
62
|
toChainId,
|
|
61
63
|
toTokenAddress,
|
|
64
|
+
toAddress,
|
|
62
65
|
slippage,
|
|
63
66
|
enabledBridges,
|
|
64
67
|
enabledExchanges,
|
|
@@ -68,16 +71,24 @@ const useSwapRoutes = () => {
|
|
|
68
71
|
const refetchInterval = previousDataUpdatedAt
|
|
69
72
|
? Math.min(Math.abs(refetchTime - (Date.now() - previousDataUpdatedAt)), refetchTime)
|
|
70
73
|
: refetchTime;
|
|
71
|
-
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, ({ queryKey: [_,
|
|
72
|
-
var _b;
|
|
74
|
+
const { data, isLoading, isFetching, isFetched, dataUpdatedAt, refetch } = (0, react_query_1.useQuery)(queryKey, ({ queryKey: [_, fromAddress, fromChainId, fromTokenAddress, fromTokenAmount, toChainId, toTokenAddress, toAddress, slippage, enabledBridges, enabledExchanges, routePriority,], signal, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
var _b, _c;
|
|
76
|
+
let toWalletAddress;
|
|
77
|
+
try {
|
|
78
|
+
toWalletAddress =
|
|
79
|
+
(_b = (yield (provider === null || provider === void 0 ? void 0 : provider.resolveName(toAddress)))) !== null && _b !== void 0 ? _b : ((0, address_1.isAddress)(toAddress) ? toAddress : fromAddress);
|
|
80
|
+
}
|
|
81
|
+
catch (_d) {
|
|
82
|
+
toWalletAddress = (0, address_1.isAddress)(toAddress) ? toAddress : fromAddress;
|
|
83
|
+
}
|
|
73
84
|
return lifi_1.LiFi.getRoutes({
|
|
74
85
|
fromChainId,
|
|
75
|
-
fromAmount: (0, big_js_1.default)(Number(fromTokenAmount) * Math.pow(10, ((
|
|
86
|
+
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(),
|
|
76
87
|
fromTokenAddress,
|
|
77
88
|
toChainId,
|
|
78
89
|
toTokenAddress,
|
|
79
|
-
fromAddress
|
|
80
|
-
toAddress:
|
|
90
|
+
fromAddress,
|
|
91
|
+
toAddress: toWalletAddress,
|
|
81
92
|
options: {
|
|
82
93
|
slippage: slippage / 100,
|
|
83
94
|
bridges: {
|
|
@@ -52,24 +52,26 @@
|
|
|
52
52
|
"selectChainAndToken": "Select chain and token",
|
|
53
53
|
"featuredTokens": "Featured tokens",
|
|
54
54
|
"otherTokens": "Other tokens",
|
|
55
|
-
"inProgress": "
|
|
55
|
+
"inProgress": "in progress",
|
|
56
|
+
"activeTransfers": "Active transfers",
|
|
56
57
|
"couldntFindTokens": "We couldn't find tokens on this chain or you don't have any.",
|
|
57
58
|
"stepSwap": "Swap",
|
|
58
59
|
"stepBridge": "Bridge",
|
|
59
60
|
"stepSwapAndBridge": "Swap and bridge",
|
|
60
61
|
"estimatedTime": "~{{value}} min.",
|
|
61
|
-
"networkIsBusy": "Network is busy...",
|
|
62
62
|
"crossStepDetails": "Bridge from {{from}} to {{to}} via {{tool}}",
|
|
63
63
|
"swapStepDetails": "Swap on {{chain}} via {{tool}}",
|
|
64
64
|
"tokenOnChain": "{{tokenSymbol}} on {{chainName}}",
|
|
65
65
|
"tokenOnChainAmount": "{{amount}} {{tokenSymbol}} on {{chainName}}",
|
|
66
66
|
"routeId": "Route ID",
|
|
67
|
+
"sendToWallet": "Send to a different wallet",
|
|
68
|
+
"walletAddressOrEns": "Wallet address or ENS name",
|
|
67
69
|
"tags": {
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
70
|
+
"RECOMMENDED": "RECOMMENDED",
|
|
71
|
+
"FASTEST": "FAST",
|
|
72
|
+
"CHEAPEST": "CHEAP",
|
|
73
|
+
"SAFEST": "SAFE",
|
|
74
|
+
"ALTERNATIVE": "ALTERNATIVE"
|
|
73
75
|
},
|
|
74
76
|
"success": {
|
|
75
77
|
"title": {
|
|
@@ -109,7 +111,9 @@
|
|
|
109
111
|
"transactionUnprepared": "Unable to prepare transaction.",
|
|
110
112
|
"unknown": "Something went wrong.",
|
|
111
113
|
"userRejectedSignatureRequest": "Signature required.",
|
|
112
|
-
"slippageTooLarge": "Slippage too large."
|
|
114
|
+
"slippageTooLarge": "Slippage too large.",
|
|
115
|
+
"walletAddressInvalid": "Wallet address is invalid.",
|
|
116
|
+
"walletEnsAddressInvalid": "Wallet address is invalid or network doesn't support ENS."
|
|
113
117
|
},
|
|
114
118
|
"message": {
|
|
115
119
|
"signatureRequired": "Your signature is required to complete the transaction. {{amount}} {{tokenSymbol}} on {{chainName}} remain in your wallet.",
|
|
@@ -156,6 +160,7 @@
|
|
|
156
160
|
"fast": "Fast"
|
|
157
161
|
},
|
|
158
162
|
"advancedPreferences": "Advanced preferences",
|
|
163
|
+
"showDestinationWallet": "Show destination wallet",
|
|
159
164
|
"enabledBridges": "Enabled bridges",
|
|
160
165
|
"selectEnabledBridges": "Select enabled bridges",
|
|
161
166
|
"enabledExchanges": "Enabled exchanges",
|
package/cjs/i18n/index.d.ts
CHANGED
|
@@ -56,23 +56,25 @@ export declare const resources: {
|
|
|
56
56
|
featuredTokens: string;
|
|
57
57
|
otherTokens: string;
|
|
58
58
|
inProgress: string;
|
|
59
|
+
activeTransfers: string;
|
|
59
60
|
couldntFindTokens: string;
|
|
60
61
|
stepSwap: string;
|
|
61
62
|
stepBridge: string;
|
|
62
63
|
stepSwapAndBridge: string;
|
|
63
64
|
estimatedTime: string;
|
|
64
|
-
networkIsBusy: string;
|
|
65
65
|
crossStepDetails: string;
|
|
66
66
|
swapStepDetails: string;
|
|
67
67
|
tokenOnChain: string;
|
|
68
68
|
tokenOnChainAmount: string;
|
|
69
69
|
routeId: string;
|
|
70
|
+
sendToWallet: string;
|
|
71
|
+
walletAddressOrEns: string;
|
|
70
72
|
tags: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
RECOMMENDED: string;
|
|
74
|
+
FASTEST: string;
|
|
75
|
+
CHEAPEST: string;
|
|
76
|
+
SAFEST: string;
|
|
77
|
+
ALTERNATIVE: string;
|
|
76
78
|
};
|
|
77
79
|
success: {
|
|
78
80
|
title: {
|
|
@@ -113,6 +115,8 @@ export declare const resources: {
|
|
|
113
115
|
unknown: string;
|
|
114
116
|
userRejectedSignatureRequest: string;
|
|
115
117
|
slippageTooLarge: string;
|
|
118
|
+
walletAddressInvalid: string;
|
|
119
|
+
walletEnsAddressInvalid: string;
|
|
116
120
|
};
|
|
117
121
|
message: {
|
|
118
122
|
signatureRequired: string;
|
|
@@ -159,6 +163,7 @@ export declare const resources: {
|
|
|
159
163
|
fast: string;
|
|
160
164
|
};
|
|
161
165
|
advancedPreferences: string;
|
|
166
|
+
showDestinationWallet: string;
|
|
162
167
|
enabledBridges: string;
|
|
163
168
|
selectEnabledBridges: string;
|
|
164
169
|
enabledExchanges: string;
|
|
@@ -4,12 +4,13 @@ exports.MainPage = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
6
|
const SelectChainAndToken_1 = require("../../components/SelectChainAndToken");
|
|
7
|
-
const
|
|
7
|
+
const SendToWallet_1 = require("../../components/SendToWallet");
|
|
8
8
|
const SwapInput_1 = require("../../components/SwapInput");
|
|
9
|
+
const SwapsInProgress_1 = require("../../components/SwapsInProgress");
|
|
9
10
|
const MainPage_style_1 = require("./MainPage.style");
|
|
10
11
|
const MainSwapButton_1 = require("./MainSwapButton");
|
|
11
12
|
const SwapRoutes_1 = require("./SwapRoutes");
|
|
12
13
|
const MainPage = () => {
|
|
13
|
-
return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(
|
|
14
|
+
return ((0, jsx_runtime_1.jsxs)(MainPage_style_1.FormContainer, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(SwapsInProgress_1.SwapsInProgress, { mx: 3, mt: 1, mb: 2 }), (0, jsx_runtime_1.jsx)(SelectChainAndToken_1.SelectChainAndToken, { mt: 1, mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mx: 3, mb: 3 }, { children: (0, jsx_runtime_1.jsx)(SwapInput_1.SwapInput, { formType: "from" }) })), (0, jsx_runtime_1.jsx)(SendToWallet_1.SendToWallet, { mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(SwapRoutes_1.SwapRoutes, { mx: 3, mb: 3 }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mx: 3, mb: 1 }, { children: (0, jsx_runtime_1.jsx)(MainSwapButton_1.MainSwapButton, {}) }))] })));
|
|
14
15
|
};
|
|
15
16
|
exports.MainPage = MainPage;
|
|
@@ -9,24 +9,23 @@ const react_i18next_1 = require("react-i18next");
|
|
|
9
9
|
const Card_1 = require("../../components/Card");
|
|
10
10
|
const Select_1 = require("../../components/Select");
|
|
11
11
|
const hooks_1 = require("../../hooks");
|
|
12
|
-
const
|
|
13
|
-
const WidgetProvider_1 = require("../../providers/WidgetProvider");
|
|
12
|
+
const providers_1 = require("../../providers");
|
|
14
13
|
const ChainSelect = ({ formType }) => {
|
|
15
14
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
16
15
|
const { setValue, register } = (0, react_hook_form_1.useFormContext)();
|
|
17
|
-
const { fromChain, toChain } = (0,
|
|
16
|
+
const { fromChain, toChain } = (0, providers_1.useWidgetConfig)();
|
|
18
17
|
const { chains, isLoading } = (0, hooks_1.useChains)();
|
|
19
|
-
const chainKey =
|
|
18
|
+
const chainKey = providers_1.SwapFormKeyHelper.getChainKey(formType);
|
|
20
19
|
const [chainId] = (0, react_hook_form_1.useWatch)({
|
|
21
20
|
name: [chainKey],
|
|
22
21
|
});
|
|
23
|
-
const { onChange, onBlur, name, ref } = register(chainKey
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
30
|
-
return !isLoading ? ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`swap.selectChain`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ ref: ref, labelId: chainKey, name: name, MenuProps: { elevation: 2 }, defaultValue: formType === 'from' ? fromChain : toChain, value: chainId, onChange:
|
|
22
|
+
const { onChange, onBlur, name, ref } = register(chainKey, {
|
|
23
|
+
onChange: () => {
|
|
24
|
+
setValue(providers_1.SwapFormKeyHelper.getTokenKey(formType), '');
|
|
25
|
+
setValue(providers_1.SwapFormKeyHelper.getAmountKey(formType), '');
|
|
26
|
+
setValue(providers_1.SwapFormKey.TokenSearchFilter, '');
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
return !isLoading ? ((0, jsx_runtime_1.jsxs)(Card_1.Card, { children: [(0, jsx_runtime_1.jsx)(Card_1.CardTitle, { children: t(`swap.selectChain`) }), (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(Select_1.Select, Object.assign({ ref: ref, labelId: chainKey, name: name, MenuProps: { elevation: 2 }, defaultValue: formType === 'from' ? fromChain : toChain, value: chainId, onChange: onChange, onBlur: onBlur, IconComponent: icons_material_1.KeyboardArrowDown }, { children: chains === null || chains === void 0 ? void 0 : chains.map((chain) => ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ value: chain.id }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemAvatar, { children: (0, jsx_runtime_1.jsx)(material_1.Avatar, Object.assign({ src: chain.logoURI, alt: chain.key }, { children: chain.name[0] })) }), chain.name] }), chain.key))) })) }))] })) : ((0, jsx_runtime_1.jsx)(material_1.Skeleton, { variant: "rectangular", width: "100%", height: 98, sx: { borderRadius: 1 } }));
|
|
31
30
|
};
|
|
32
31
|
exports.ChainSelect = ChainSelect;
|
|
@@ -8,14 +8,14 @@ const react_1 = require("react");
|
|
|
8
8
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
9
|
const react_i18next_1 = require("react-i18next");
|
|
10
10
|
const Card_1 = require("../../components/Card");
|
|
11
|
-
const
|
|
11
|
+
const providers_1 = require("../../providers");
|
|
12
12
|
const SearchTokenInput_style_1 = require("./SearchTokenInput.style");
|
|
13
13
|
const SearchTokenInput = () => {
|
|
14
14
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
15
15
|
const { register, setValue } = (0, react_hook_form_1.useFormContext)();
|
|
16
16
|
(0, react_1.useEffect)(() => () => {
|
|
17
|
-
setValue(
|
|
17
|
+
setValue(providers_1.SwapFormKey.TokenSearchFilter, '');
|
|
18
18
|
}, [setValue]);
|
|
19
|
-
return ((0, jsx_runtime_1.jsx)(Card_1.Card, { children: (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(SearchTokenInput_style_1.Input, { size: "small", placeholder: t(`swap.tokenSearch`), defaultValue: "", endAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Search, {}) })), inputProps: Object.assign({ inputMode: 'search' }, register(
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(Card_1.Card, { children: (0, jsx_runtime_1.jsx)(material_1.FormControl, Object.assign({ fullWidth: true }, { children: (0, jsx_runtime_1.jsx)(SearchTokenInput_style_1.Input, { size: "small", placeholder: t(`swap.tokenSearch`), defaultValue: "", endAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: (0, jsx_runtime_1.jsx)(icons_material_1.Search, {}) })), inputProps: Object.assign({ inputMode: 'search' }, register(providers_1.SwapFormKey.TokenSearchFilter)), autoComplete: "off" }) })) }));
|
|
20
20
|
};
|
|
21
21
|
exports.SearchTokenInput = SearchTokenInput;
|
|
@@ -4,24 +4,20 @@ exports.SelectTokenPage = void 0;
|
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const material_1 = require("@mui/material");
|
|
6
6
|
const react_1 = require("react");
|
|
7
|
-
const react_router_dom_1 = require("react-router-dom");
|
|
8
7
|
const TokenList_1 = require("../../components/TokenList");
|
|
9
8
|
const hooks_1 = require("../../hooks");
|
|
10
9
|
const ChainSelect_1 = require("./ChainSelect");
|
|
11
10
|
const SearchTokenInput_1 = require("./SearchTokenInput");
|
|
12
11
|
const SelectTokenPage = ({ formType, }) => {
|
|
13
12
|
(0, hooks_1.useScrollableOverflowHidden)();
|
|
14
|
-
const
|
|
13
|
+
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
15
14
|
const headerRef = (0, react_1.useRef)(null);
|
|
16
15
|
const contentHeight = (0, hooks_1.useContentHeight)();
|
|
17
16
|
const [headerHeight, setHeaderHeight] = (0, react_1.useState)(0);
|
|
18
|
-
const handleTokenClick = () => {
|
|
19
|
-
navigate(-1);
|
|
20
|
-
};
|
|
21
17
|
(0, react_1.useLayoutEffect)(() => {
|
|
22
18
|
var _a, _b;
|
|
23
19
|
setHeaderHeight(contentHeight - ((_b = (_a = headerRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) !== null && _b !== void 0 ? _b : 0));
|
|
24
20
|
}, [contentHeight]);
|
|
25
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Container, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ pt: 1, pb: 2, px: 3, ref: headerRef }, { children: [(0, jsx_runtime_1.jsx)(ChainSelect_1.ChainSelect, { formType: formType }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(SearchTokenInput_1.SearchTokenInput, {}) }))] })), (0, jsx_runtime_1.jsx)(TokenList_1.TokenList, { height: headerHeight, onClick:
|
|
21
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Container, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ pt: 1, pb: 2, px: 3, ref: headerRef }, { children: [(0, jsx_runtime_1.jsx)(ChainSelect_1.ChainSelect, { formType: formType }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(SearchTokenInput_1.SearchTokenInput, {}) }))] })), (0, jsx_runtime_1.jsx)(TokenList_1.TokenList, { height: headerHeight, onClick: navigateBack, formType: formType })] })));
|
|
26
22
|
};
|
|
27
23
|
exports.SelectTokenPage = SelectTokenPage;
|
|
@@ -15,15 +15,15 @@ const wallet_management_1 = require("@lifi/wallet-management");
|
|
|
15
15
|
const material_1 = require("@mui/material");
|
|
16
16
|
const react_1 = require("react");
|
|
17
17
|
const react_i18next_1 = require("react-i18next");
|
|
18
|
-
const react_router_dom_1 = require("react-router-dom");
|
|
19
18
|
const Dialog_1 = require("../../components/Dialog");
|
|
20
|
-
const
|
|
19
|
+
const hooks_1 = require("../../hooks");
|
|
20
|
+
const providers_1 = require("../../providers");
|
|
21
21
|
const SelectWalletPage_style_1 = require("./SelectWalletPage.style");
|
|
22
22
|
const SelectWalletPage = () => {
|
|
23
23
|
var _a;
|
|
24
24
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
25
|
-
const
|
|
26
|
-
const { connect } = (0,
|
|
25
|
+
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
26
|
+
const { connect } = (0, providers_1.useWallet)();
|
|
27
27
|
const [walletIdentity, setWalletIdentity] = (0, react_1.useState)({ show: false });
|
|
28
28
|
const closeDialog = () => {
|
|
29
29
|
setWalletIdentity((state) => (Object.assign(Object.assign({}, state), { show: false })));
|
|
@@ -40,9 +40,9 @@ const SelectWalletPage = () => {
|
|
|
40
40
|
});
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
|
|
43
|
+
navigateBack();
|
|
44
44
|
yield connect(wallet);
|
|
45
|
-
}), [connect,
|
|
45
|
+
}), [connect, navigateBack]);
|
|
46
46
|
return ((0, jsx_runtime_1.jsxs)(material_1.Container, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ sx: {
|
|
47
47
|
paddingLeft: 2,
|
|
48
48
|
paddingRight: 2,
|
|
@@ -15,10 +15,10 @@ const AdvancedPreferences = () => {
|
|
|
15
15
|
const handleAdvancedPreferences = (_, checked) => {
|
|
16
16
|
setValue('advancedPreferences', checked);
|
|
17
17
|
};
|
|
18
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ px: 3, pt:
|
|
18
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ px: 3, pt: 2 }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
|
|
19
19
|
display: 'flex',
|
|
20
20
|
justifyContent: 'space-between',
|
|
21
21
|
alignItems: 'center',
|
|
22
|
-
} }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle1", color: "text.primary", lineHeight: "normal" }, { children: t(`settings.advancedPreferences`) })) })), (0, jsx_runtime_1.jsx)(Switch_1.Switch, { checked: advancedPreferences, onChange: handleAdvancedPreferences })] })), advancedPreferences && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mt:
|
|
22
|
+
} }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle1", color: "text.primary", lineHeight: "normal" }, { children: t(`settings.advancedPreferences`) })) })), (0, jsx_runtime_1.jsx)(Switch_1.Switch, { checked: advancedPreferences, onChange: handleAdvancedPreferences })] })), advancedPreferences && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ mt: 2, mb: 1 }, { children: [(0, jsx_runtime_1.jsx)(EnabledBridgesSelect_1.EnabledBridgesSelect, {}), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ mt: 2 }, { children: (0, jsx_runtime_1.jsx)(EnabledExchangesSelect_1.EnabledExchangesSelect, {}) }))] })))] })));
|
|
23
23
|
};
|
|
24
24
|
exports.AdvancedPreferences = AdvancedPreferences;
|
|
@@ -5,12 +5,12 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
const icons_material_1 = require("@mui/icons-material");
|
|
6
6
|
const material_1 = require("@mui/material");
|
|
7
7
|
const react_i18next_1 = require("react-i18next");
|
|
8
|
-
const
|
|
8
|
+
const providers_1 = require("../../providers");
|
|
9
9
|
const stores_1 = require("../../stores");
|
|
10
10
|
const ColorSchemeButtonGroup_style_1 = require("./ColorSchemeButtonGroup.style");
|
|
11
11
|
const ColorSchemeButtonGroup = () => {
|
|
12
12
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
13
|
-
const { disableAppearance } = (0,
|
|
13
|
+
const { disableAppearance } = (0, providers_1.useWidgetConfig)();
|
|
14
14
|
const [appearance, setAppearance] = (0, stores_1.useAppearance)();
|
|
15
15
|
if (disableAppearance) {
|
|
16
16
|
return null;
|
|
@@ -7,8 +7,9 @@ const AdvancedPreferences_1 = require("./AdvancedPreferences");
|
|
|
7
7
|
const ColorSchemeButtonGroup_1 = require("./ColorSchemeButtonGroup");
|
|
8
8
|
const GasPriceSelect_1 = require("./GasPriceSelect");
|
|
9
9
|
const RoutePrioritySelect_1 = require("./RoutePrioritySelect");
|
|
10
|
+
const ShowDestinationWallet_1 = require("./ShowDestinationWallet");
|
|
10
11
|
const SlippageInput_1 = require("./SlippageInput");
|
|
11
12
|
const SettingsPage = () => {
|
|
12
|
-
return ((0, jsx_runtime_1.jsxs)(material_1.Container, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ px: 3, pt: 1 }, { children: [(0, jsx_runtime_1.jsx)(ColorSchemeButtonGroup_1.ColorSchemeButtonGroup, {}), (0, jsx_runtime_1.jsx)(RoutePrioritySelect_1.RoutePrioritySelect, {}), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' }, mt: 2 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ pr: 2, flex: 1 }, { children: (0, jsx_runtime_1.jsx)(SlippageInput_1.SlippageInput, {}) })), (0, jsx_runtime_1.jsx)(GasPriceSelect_1.GasPriceSelect, {})] }))] })), (0, jsx_runtime_1.jsx)(AdvancedPreferences_1.AdvancedPreferences, {})] })));
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)(material_1.Container, Object.assign({ disableGutters: true }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ px: 3, pt: 1 }, { children: [(0, jsx_runtime_1.jsx)(ColorSchemeButtonGroup_1.ColorSchemeButtonGroup, {}), (0, jsx_runtime_1.jsx)(RoutePrioritySelect_1.RoutePrioritySelect, {}), (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' }, mt: 2 }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ pr: 2, flex: 1 }, { children: (0, jsx_runtime_1.jsx)(SlippageInput_1.SlippageInput, {}) })), (0, jsx_runtime_1.jsx)(GasPriceSelect_1.GasPriceSelect, {})] }))] })), (0, jsx_runtime_1.jsx)(ShowDestinationWallet_1.ShowDestinationWallet, {}), (0, jsx_runtime_1.jsx)(AdvancedPreferences_1.AdvancedPreferences, {})] })));
|
|
13
14
|
};
|
|
14
15
|
exports.SettingsPage = SettingsPage;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ShowDestinationWallet = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const material_1 = require("@mui/material");
|
|
6
|
+
const react_i18next_1 = require("react-i18next");
|
|
7
|
+
const Switch_1 = require("../../components/Switch");
|
|
8
|
+
const stores_1 = require("../../stores");
|
|
9
|
+
const ShowDestinationWallet = () => {
|
|
10
|
+
const { t } = (0, react_i18next_1.useTranslation)();
|
|
11
|
+
const [setValue] = (0, stores_1.useSetSettings)();
|
|
12
|
+
const { showDestinationWallet } = (0, stores_1.useSettings)(['showDestinationWallet']);
|
|
13
|
+
const onChange = (_, checked) => {
|
|
14
|
+
setValue('showDestinationWallet', checked);
|
|
15
|
+
};
|
|
16
|
+
return ((0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ px: 3, pt: 2 }, { children: (0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ sx: {
|
|
17
|
+
display: 'flex',
|
|
18
|
+
justifyContent: 'space-between',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
} }, { children: [(0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ sx: { display: 'flex', alignItems: 'center' } }, { children: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "subtitle1", color: "text.primary", lineHeight: "normal" }, { children: t(`settings.showDestinationWallet`) })) })), (0, jsx_runtime_1.jsx)(Switch_1.Switch, { checked: showDestinationWallet, onChange: onChange })] })) })));
|
|
21
|
+
};
|
|
22
|
+
exports.ShowDestinationWallet = ShowDestinationWallet;
|
|
@@ -25,12 +25,13 @@ const Dialog_1 = require("../../components/Dialog");
|
|
|
25
25
|
const Header_1 = require("../../components/Header");
|
|
26
26
|
const Step_1 = require("../../components/Step");
|
|
27
27
|
const StepDivider_1 = require("../../components/StepDivider");
|
|
28
|
+
const hooks_1 = require("../../hooks");
|
|
28
29
|
const stores_1 = require("../../stores");
|
|
29
30
|
const SwapDetailsPage_style_1 = require("./SwapDetailsPage.style");
|
|
30
31
|
const SwapDetailsPage = () => {
|
|
31
32
|
var _a, _b;
|
|
32
33
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
33
|
-
const
|
|
34
|
+
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
34
35
|
const setHeaderAction = (0, Header_1.useSetHeaderAction)();
|
|
35
36
|
const { state } = (0, react_router_dom_1.useLocation)();
|
|
36
37
|
const [routeExecution, deleteRoute] = (0, stores_1.useRouteStore)((store) => [store.routes[state === null || state === void 0 ? void 0 : state.routeId], store.deleteRoute], shallow_1.default);
|
|
@@ -39,7 +40,7 @@ const SwapDetailsPage = () => {
|
|
|
39
40
|
setOpen((open) => !open);
|
|
40
41
|
}, []);
|
|
41
42
|
const handleDeleteRoute = () => {
|
|
42
|
-
|
|
43
|
+
navigateBack();
|
|
43
44
|
if (routeExecution) {
|
|
44
45
|
deleteRoute(routeExecution.route.id);
|
|
45
46
|
}
|
|
@@ -8,14 +8,14 @@ const react_1 = require("react");
|
|
|
8
8
|
const react_i18next_1 = require("react-i18next");
|
|
9
9
|
const Dialog_1 = require("../../components/Dialog");
|
|
10
10
|
const Header_1 = require("../../components/Header");
|
|
11
|
-
const
|
|
11
|
+
const providers_1 = require("../../providers");
|
|
12
12
|
const stores_1 = require("../../stores");
|
|
13
13
|
const route_1 = require("../../stores/route");
|
|
14
14
|
const SwapHistoryEmpty_1 = require("./SwapHistoryEmpty");
|
|
15
15
|
const SwapHistoryItem_1 = require("./SwapHistoryItem");
|
|
16
16
|
const SwapHistoryPage = () => {
|
|
17
17
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
|
-
const { account } = (0,
|
|
18
|
+
const { account } = (0, providers_1.useWallet)();
|
|
19
19
|
const swaps = (0, route_1.useSwapHistory)(account.address);
|
|
20
20
|
const deleteRoutes = (0, stores_1.useRouteStore)((store) => store.deleteRoutes);
|
|
21
21
|
const setHeaderAction = (0, Header_1.useSetHeaderAction)();
|
|
@@ -7,28 +7,27 @@ const material_1 = require("@mui/material");
|
|
|
7
7
|
const react_1 = require("react");
|
|
8
8
|
const react_hook_form_1 = require("react-hook-form");
|
|
9
9
|
const react_i18next_1 = require("react-i18next");
|
|
10
|
-
const react_router_dom_1 = require("react-router-dom");
|
|
11
10
|
const BottomSheet_1 = require("../../components/BottomSheet");
|
|
12
11
|
const Token_1 = require("../../components/Token");
|
|
13
12
|
const hooks_1 = require("../../hooks");
|
|
14
|
-
const
|
|
13
|
+
const providers_1 = require("../../providers");
|
|
15
14
|
const StatusBottomSheet_style_1 = require("./StatusBottomSheet.style");
|
|
16
15
|
const utils_1 = require("./utils");
|
|
17
16
|
const StatusBottomSheet = ({ status, route, }) => {
|
|
18
17
|
var _a, _b, _c, _d, _e;
|
|
19
18
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
20
|
-
const
|
|
19
|
+
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
21
20
|
const ref = (0, react_1.useRef)(null);
|
|
22
21
|
const { getChainById } = (0, hooks_1.useChains)();
|
|
23
22
|
const { token, refetch: refetchBalance } = (0, hooks_1.useTokenBalance)(route.toChainId, route.toToken.address);
|
|
24
23
|
const { setValue } = (0, react_hook_form_1.useFormContext)();
|
|
25
24
|
const clearFromAmount = () => {
|
|
26
25
|
refetchBalance();
|
|
27
|
-
setValue(
|
|
26
|
+
setValue(providers_1.SwapFormKey.FromAmount, '');
|
|
28
27
|
};
|
|
29
28
|
const handleDone = () => {
|
|
30
29
|
clearFromAmount();
|
|
31
|
-
|
|
30
|
+
navigateBack();
|
|
32
31
|
};
|
|
33
32
|
const handleClose = () => {
|
|
34
33
|
var _a;
|
|
@@ -16,10 +16,10 @@ const SwapPage_style_1 = require("./SwapPage.style");
|
|
|
16
16
|
const SwapPage = () => {
|
|
17
17
|
const { t } = (0, react_i18next_1.useTranslation)();
|
|
18
18
|
const { state } = (0, react_router_dom_1.useLocation)();
|
|
19
|
-
const
|
|
19
|
+
const { navigateBack } = (0, hooks_1.useNavigateBack)();
|
|
20
20
|
const { route, status, executeRoute, restartRoute, deleteRoute } = (0, hooks_1.useRouteExecution)(state === null || state === void 0 ? void 0 : state.routeId);
|
|
21
21
|
const handleRemoveRoute = () => {
|
|
22
|
-
|
|
22
|
+
navigateBack();
|
|
23
23
|
deleteRoute();
|
|
24
24
|
};
|
|
25
25
|
const handleSwapClick = () => {
|
|
@@ -15,7 +15,7 @@ const SwapRoutesPage = () => {
|
|
|
15
15
|
const navigate = (0, react_router_dom_1.useNavigate)();
|
|
16
16
|
const { pathname } = (0, react_router_dom_1.useLocation)();
|
|
17
17
|
const setHeaderAction = (0, Header_1.useSetHeaderAction)();
|
|
18
|
-
const { routes: swapRoutes, isLoading, isFetching,
|
|
18
|
+
const { routes: swapRoutes, isLoading, isFetching, dataUpdatedAt, refetchTime, refetch, } = (0, hooks_1.useSwapRoutes)();
|
|
19
19
|
const setExecutableRoute = (0, stores_1.useSetExecutableRoute)();
|
|
20
20
|
const handleRouteClick = (route) => {
|
|
21
21
|
setExecutableRoute(route);
|
|
@@ -10,15 +10,17 @@ const WidgetProvider_1 = require("../WidgetProvider");
|
|
|
10
10
|
const types_1 = require("./types");
|
|
11
11
|
exports.formDefaultValues = {
|
|
12
12
|
[types_1.SwapFormKey.FromAmount]: '',
|
|
13
|
+
[types_1.SwapFormKey.ToAddress]: '',
|
|
13
14
|
[types_1.SwapFormKey.TokenSearchFilter]: '',
|
|
14
15
|
};
|
|
15
16
|
const SwapFormProvider = ({ children, }) => {
|
|
16
17
|
const { account } = (0, WalletProvider_1.useWallet)();
|
|
17
|
-
const { fromChain, fromToken, fromAmount, toChain, toToken } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
18
|
+
const { fromChain, fromToken, fromAmount, toChain, toToken, toAddress } = (0, WidgetProvider_1.useWidgetConfig)();
|
|
18
19
|
const methods = (0, react_hook_form_1.useForm)({
|
|
19
20
|
defaultValues: Object.assign(Object.assign({}, exports.formDefaultValues), { fromChain: fromChain !== null && fromChain !== void 0 ? fromChain : sdk_1.ChainId.ETH, fromToken, fromAmount: (typeof fromAmount === 'number'
|
|
20
21
|
? fromAmount === null || fromAmount === void 0 ? void 0 : fromAmount.toPrecision()
|
|
21
|
-
: fromAmount) || exports.formDefaultValues.fromAmount, toChain: toChain !== null && toChain !== void 0 ? toChain : sdk_1.ChainId.ETH, toToken
|
|
22
|
+
: fromAmount) || exports.formDefaultValues.fromAmount, toChain: toChain !== null && toChain !== void 0 ? toChain : sdk_1.ChainId.ETH, toToken,
|
|
23
|
+
toAddress }),
|
|
22
24
|
});
|
|
23
25
|
// Set wallet chain as default if no chains are provided by config and if they were not changed during widget usage
|
|
24
26
|
(0, react_1.useEffect)(() => {
|
|
@@ -26,14 +28,18 @@ const SwapFormProvider = ({ children, }) => {
|
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
28
30
|
const { isDirty: isFromChainDirty, isTouched: isFromChainTouched } = methods.getFieldState(types_1.SwapFormKey.FromChain, methods.formState);
|
|
31
|
+
const { isDirty: isToChainDirty, isTouched: isToChainTouched } = methods.getFieldState(types_1.SwapFormKey.ToChain, methods.formState);
|
|
29
32
|
if (!fromChain && !isFromChainDirty && !isFromChainTouched) {
|
|
30
33
|
methods.setValue(types_1.SwapFormKey.FromChain, account.chainId, {
|
|
31
34
|
shouldDirty: false,
|
|
32
35
|
shouldTouch: false,
|
|
33
36
|
});
|
|
34
37
|
}
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
if (!toChain &&
|
|
39
|
+
!isToChainDirty &&
|
|
40
|
+
!isToChainTouched &&
|
|
41
|
+
!isFromChainDirty &&
|
|
42
|
+
!isFromChainTouched) {
|
|
37
43
|
methods.setValue(types_1.SwapFormKey.ToChain, account.chainId, {
|
|
38
44
|
shouldDirty: false,
|
|
39
45
|
shouldTouch: false,
|
|
@@ -4,7 +4,8 @@ export declare enum SwapFormKey {
|
|
|
4
4
|
FromToken = "fromToken",
|
|
5
5
|
TokenSearchFilter = "tokenSearchFilter",
|
|
6
6
|
ToChain = "toChain",
|
|
7
|
-
ToToken = "toToken"
|
|
7
|
+
ToToken = "toToken",
|
|
8
|
+
ToAddress = "toAddress"
|
|
8
9
|
}
|
|
9
10
|
export declare type SwapFormValues = {
|
|
10
11
|
[SwapFormKey.FromAmount]: string;
|
|
@@ -13,6 +14,7 @@ export declare type SwapFormValues = {
|
|
|
13
14
|
[SwapFormKey.TokenSearchFilter]: string;
|
|
14
15
|
[SwapFormKey.ToChain]: number;
|
|
15
16
|
[SwapFormKey.ToToken]: string;
|
|
17
|
+
[SwapFormKey.ToAddress]: string;
|
|
16
18
|
};
|
|
17
19
|
export declare type SwapFormDirection = 'from' | 'to';
|
|
18
20
|
export declare const SwapFormKeyHelper: {
|
|
@@ -9,6 +9,7 @@ var SwapFormKey;
|
|
|
9
9
|
SwapFormKey["TokenSearchFilter"] = "tokenSearchFilter";
|
|
10
10
|
SwapFormKey["ToChain"] = "toChain";
|
|
11
11
|
SwapFormKey["ToToken"] = "toToken";
|
|
12
|
+
SwapFormKey["ToAddress"] = "toAddress";
|
|
12
13
|
})(SwapFormKey = exports.SwapFormKey || (exports.SwapFormKey = {}));
|
|
13
14
|
exports.SwapFormKeyHelper = {
|
|
14
15
|
getChainKey: (formType) => `${formType}Chain`,
|