@rango-dev/widget-embedded 0.1.10-next.100 → 0.1.10-next.114
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/dist/App.d.ts.map +1 -1
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +6 -1
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/HeaderButtons.d.ts +4 -1
- package/dist/components/HeaderButtons.d.ts.map +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts +9 -0
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -0
- package/dist/components/TokenPreview.d.ts +1 -1
- package/dist/components/TokenPreview.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/warnings/BalanceWarnings.d.ts.map +1 -1
- package/dist/components/warnings/MinRequiredSlippage.d.ts +1 -1
- package/dist/components/warnings/MinRequiredSlippage.d.ts.map +1 -1
- package/dist/constants/navigationRoutes.d.ts +0 -1
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/globalStyles.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/HistoryPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
- package/dist/pages/SelectTokenPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +1 -0
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts +2 -0
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +14 -0
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/routing.d.ts +1 -1
- package/dist/types/swap.d.ts +6 -0
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/utils/common.d.ts +1 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/date.d.ts +3 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/routing.d.ts +1 -0
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +16 -5
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +4 -0
- package/dist/utils/time.d.ts.map +1 -0
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +1039 -709
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +1039 -709
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +1048 -718
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +12 -11
- package/readme.md +1 -2
- package/src/App.tsx +30 -5
- package/src/QueueManager.tsx +5 -2
- package/src/components/AppRouter.tsx +24 -13
- package/src/components/AppRoutes.tsx +15 -12
- package/src/components/HeaderButtons.tsx +9 -2
- package/src/components/Layout.tsx +37 -5
- package/src/components/SwapDetailsPlaceholder.tsx +32 -0
- package/src/components/TokenPreview.tsx +7 -4
- package/src/components/UpdateUrl.tsx +1 -3
- package/src/components/warnings/BalanceWarnings.tsx +1 -0
- package/src/components/warnings/MinRequiredSlippage.tsx +9 -4
- package/src/constants/navigationRoutes.ts +0 -1
- package/src/globalStyles.ts +2 -1
- package/src/hooks/useConfirmSwap.ts +2 -1
- package/src/hooks/useNavigateBack.ts +3 -3
- package/src/lib.tsx +25 -3
- package/src/pages/ConfirmSwapPage.tsx +128 -20
- package/src/pages/HistoryPage.tsx +4 -4
- package/src/pages/Home.tsx +19 -8
- package/src/pages/LiquiditySourcesPage.tsx +2 -0
- package/src/pages/SelectTokenPage.tsx +3 -1
- package/src/pages/SettingsPage.tsx +3 -0
- package/src/pages/SwapDetailsPage.tsx +142 -6
- package/src/pages/WalletsPage.tsx +27 -8
- package/src/store/bestRoute.ts +110 -12
- package/src/store/ui.ts +4 -0
- package/src/store/wallets.ts +4 -1
- package/src/types/routing.ts +1 -1
- package/src/types/swap.ts +7 -0
- package/src/utils/common.ts +14 -0
- package/src/utils/date.ts +62 -0
- package/src/utils/routing.ts +23 -13
- package/src/utils/swap.ts +101 -10
- package/src/utils/time.ts +52 -0
- package/src/utils/wallets.ts +5 -2
- package/dist/components/Header.d.ts +0 -10
- package/dist/components/Header.d.ts.map +0 -1
- package/dist/pages/ConfirmWalletsPage.d.ts +0 -3
- package/dist/pages/ConfirmWalletsPage.d.ts.map +0 -1
- package/src/components/Header.tsx +0 -37
- package/src/pages/ConfirmWalletsPage.tsx +0 -127
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
import { WalletState,
|
|
1
|
+
import { WalletState, InfoCircleIcon, AngleDownIcon, Typography, Spacer, Button, TextField, styled, Tooltip, RetryIcon, HistoryIcon, SettingsIcon, Header as Header$1, VerticalSwapIcon, BestRoute, Alert, ChevronRightIcon, GasIcon, ConfirmSwap, History, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Spinner, LoadingFailedAlert, Wallet, SwapHistory, AddWalletIcon, globalCss, createTheme, SwapContainer } from '@rango-dev/ui';
|
|
2
2
|
import React, { useRef, useEffect, useState, useLayoutEffect } from 'react';
|
|
3
3
|
import { useInRouterContext as useInRouterContext$1, MemoryRouter, useLocation as useLocation$1, useNavigate as useNavigate$1 } from 'react-router';
|
|
4
|
+
import { PendingSwapNetworkStatus, useQueueManager, getCurrentStep, getCurrentBlockchainOfOrNull, getRelatedWalletOrNull, cancelSwap, swapQueueDef, checkWaitingForNetworkChange } from '@rango-dev/queue-manager-rango-preset';
|
|
5
|
+
import { isCosmosBlockchain, isEvmBlockchain } from 'rango-types';
|
|
4
6
|
import { useSearchParams, useLocation, createSearchParams, useNavigate, useInRouterContext, useRoutes } from 'react-router-dom';
|
|
5
7
|
import { create } from 'zustand';
|
|
6
8
|
import BigNumber, { BigNumber as BigNumber$1 } from 'bignumber.js';
|
|
7
|
-
import { Network, isEvmAddress,
|
|
8
|
-
import { isCosmosBlockchain } from 'rango-types';
|
|
9
|
+
import { Network, isEvmAddress, KEPLR_COMPATIBLE_WALLETS, detectInstallLink, WalletType, getCosmosExperimentalChainInfo, detectMobileScreens, convertEvmBlockchainMetaToEvmChainInfo } from '@rango-dev/wallets-shared';
|
|
9
10
|
import { readAccountAddress, useWallets, Provider as Provider$1, Events } from '@rango-dev/wallets-core';
|
|
10
11
|
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
|
11
|
-
import { RangoClient, isEvmBlockchain } from 'rango-sdk';
|
|
12
|
+
import { RangoClient, isEvmBlockchain as isEvmBlockchain$1 } from 'rango-sdk';
|
|
12
13
|
import { shallow } from 'zustand/shallow';
|
|
13
14
|
import { useTranslation, initReactI18next } from 'react-i18next';
|
|
14
15
|
import { styled as styled$1 } from '@rango-dev/ui/src/theme';
|
|
15
16
|
import { allProviders } from '@rango-dev/provider-all';
|
|
16
|
-
import { useManager, Provider } from '@rango-dev/queue-manager-react';
|
|
17
17
|
import i18n, { t } from 'i18next';
|
|
18
|
+
import { useManager, Provider } from '@rango-dev/queue-manager-react';
|
|
19
|
+
import dayjs from 'dayjs';
|
|
18
20
|
import copy from 'copy-to-clipboard';
|
|
19
|
-
import { cancelSwap, swapQueueDef } from '@rango-dev/queue-manager-rango-preset';
|
|
20
21
|
import Backend from 'i18next-http-backend';
|
|
21
22
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
22
23
|
|
|
@@ -31,7 +32,6 @@ const navigationRoutes = {
|
|
|
31
32
|
swaps: '/swaps',
|
|
32
33
|
wallets: '/wallets',
|
|
33
34
|
confirmSwap: '/confirm-swap',
|
|
34
|
-
confirmWallets: '/confirm-wallets',
|
|
35
35
|
swapDetails: '/swaps/:requestId'
|
|
36
36
|
};
|
|
37
37
|
|
|
@@ -61,6 +61,22 @@ function shadeColor(color, percent) {
|
|
|
61
61
|
var BB = B.toString(16).length == 1 ? '0' + B.toString(16) : B.toString(16);
|
|
62
62
|
return '#' + RR + GG + BB;
|
|
63
63
|
}
|
|
64
|
+
function debounce(fn, time) {
|
|
65
|
+
let timeoutId;
|
|
66
|
+
return wrapper;
|
|
67
|
+
function wrapper() {
|
|
68
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
69
|
+
args[_key] = arguments[_key];
|
|
70
|
+
}
|
|
71
|
+
if (timeoutId) {
|
|
72
|
+
clearTimeout(timeoutId);
|
|
73
|
+
}
|
|
74
|
+
timeoutId = setTimeout(() => {
|
|
75
|
+
timeoutId = null;
|
|
76
|
+
fn(...args);
|
|
77
|
+
}, time);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
64
80
|
|
|
65
81
|
const secondsToString = s => {
|
|
66
82
|
const seconds = (s % 60).toString().padStart(2, '0');
|
|
@@ -327,7 +343,7 @@ function getSortedTokens(chain, tokens, balances, otherChainTokens) {
|
|
|
327
343
|
return sortTokens(getTokensWithBalance(filteredTokens, balances));
|
|
328
344
|
}
|
|
329
345
|
function tokensAreEqual(tokenA, tokenB) {
|
|
330
|
-
return tokenA?.blockchain === tokenB?.blockchain && tokenA?.
|
|
346
|
+
return tokenA?.blockchain === tokenB?.blockchain && tokenA?.symbol === tokenB?.symbol && tokenA?.address === tokenB?.address;
|
|
331
347
|
}
|
|
332
348
|
function getDefaultToken(sortedTokens, otherToken) {
|
|
333
349
|
let selectedToken;
|
|
@@ -453,6 +469,7 @@ function calculatePendingSwap(inputAmount, bestRoute, wallets, settings, validat
|
|
|
453
469
|
finishTime: null,
|
|
454
470
|
requestId: bestRoute.requestId || '',
|
|
455
471
|
inputAmount: inputAmount,
|
|
472
|
+
//@ts-ignore
|
|
456
473
|
wallets,
|
|
457
474
|
status: 'running',
|
|
458
475
|
isPaused: false,
|
|
@@ -467,6 +484,7 @@ function calculatePendingSwap(inputAmount, bestRoute, wallets, settings, validat
|
|
|
467
484
|
settings: settings,
|
|
468
485
|
simulationResult: simulationResult,
|
|
469
486
|
validateBalanceOrFee,
|
|
487
|
+
//@ts-ignore
|
|
470
488
|
steps: bestRoute.result?.swaps?.map((swap, index) => {
|
|
471
489
|
const swapper = meta.swappers.find(swapper => swapper.id === swap.swapperId);
|
|
472
490
|
const swapperType = swapper?.types[0];
|
|
@@ -552,11 +570,10 @@ function hasHighFee(totalFeeInUsd) {
|
|
|
552
570
|
}
|
|
553
571
|
function getMinRequiredSlippage(route) {
|
|
554
572
|
const slippages = route.result?.swaps.map(slippage => slippage.recommendedSlippage);
|
|
555
|
-
return slippages?.map(s =>
|
|
573
|
+
return slippages?.map(s => s?.slippage || '0')?.filter(s => parseFloat(s) > 0)?.sort((a, b) => parseFloat(b) - parseFloat(a))?.find(() => true) || null;
|
|
556
574
|
}
|
|
557
575
|
function hasProperSlippage(userSlippage, minRequiredSlippage) {
|
|
558
576
|
if (!minRequiredSlippage) return true;
|
|
559
|
-
//@ts-ignore
|
|
560
577
|
return parseFloat(userSlippage) >= parseFloat(minRequiredSlippage);
|
|
561
578
|
}
|
|
562
579
|
function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites) {
|
|
@@ -569,6 +586,7 @@ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, se
|
|
|
569
586
|
addresses: [wallet.address]
|
|
570
587
|
});
|
|
571
588
|
});
|
|
589
|
+
const filteredBlockchains = selectedWallets.map(wallet => wallet.chain);
|
|
572
590
|
const requestBody = {
|
|
573
591
|
amount: inputAmount.toString(),
|
|
574
592
|
checkPrerequisites,
|
|
@@ -586,8 +604,10 @@ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, se
|
|
|
586
604
|
selectedWallets: selectedWalletsMap,
|
|
587
605
|
swapperGroups: disabledLiquiditySources,
|
|
588
606
|
swappersGroupsExclude: true,
|
|
589
|
-
|
|
590
|
-
|
|
607
|
+
slippage: slippage.toString(),
|
|
608
|
+
...(checkPrerequisites && {
|
|
609
|
+
blockchains: filteredBlockchains
|
|
610
|
+
})
|
|
591
611
|
};
|
|
592
612
|
return requestBody;
|
|
593
613
|
}
|
|
@@ -633,6 +653,61 @@ function calcOutputUsdValue(outputAmount, tokenPrice) {
|
|
|
633
653
|
const amount = !!outputAmount ? new BigNumber(outputAmount) : ZERO;
|
|
634
654
|
return amount.multipliedBy(tokenPrice || 0);
|
|
635
655
|
}
|
|
656
|
+
function isNetworkStatusInWarningState(pendingSwapStep) {
|
|
657
|
+
return !!pendingSwapStep && pendingSwapStep.networkStatus !== null && pendingSwapStep.networkStatus !== PendingSwapNetworkStatus.NetworkChanged;
|
|
658
|
+
}
|
|
659
|
+
function getSwapMessages(pendingSwap, currentStep) {
|
|
660
|
+
const textForRemove = 'bellow button or';
|
|
661
|
+
let message = pendingSwap.extraMessage;
|
|
662
|
+
let detailedMessage = pendingSwap.extraMessageDetail;
|
|
663
|
+
if (pendingSwap.networkStatusExtraMessageDetail?.includes(textForRemove)) {
|
|
664
|
+
pendingSwap.networkStatusExtraMessageDetail = pendingSwap.networkStatusExtraMessageDetail.replace(textForRemove, '');
|
|
665
|
+
}
|
|
666
|
+
const networkWarningState = isNetworkStatusInWarningState(currentStep);
|
|
667
|
+
if (networkWarningState) {
|
|
668
|
+
message = pendingSwap.networkStatusExtraMessage || '';
|
|
669
|
+
detailedMessage = pendingSwap.networkStatusExtraMessageDetail || '';
|
|
670
|
+
switch (currentStep?.networkStatus) {
|
|
671
|
+
case PendingSwapNetworkStatus.WaitingForConnectingWallet:
|
|
672
|
+
message = message || 'Waiting for connecting wallet';
|
|
673
|
+
break;
|
|
674
|
+
case PendingSwapNetworkStatus.WaitingForQueue:
|
|
675
|
+
message = message || 'Waiting for other running tasks to be finished';
|
|
676
|
+
break;
|
|
677
|
+
case PendingSwapNetworkStatus.WaitingForNetworkChange:
|
|
678
|
+
message = message || 'Waiting for changing wallet network';
|
|
679
|
+
break;
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
detailedMessage = detailedMessage || '';
|
|
683
|
+
message = message || '';
|
|
684
|
+
const isRpc = message?.indexOf('code') !== -1 && message?.indexOf('reason') !== -1;
|
|
685
|
+
return {
|
|
686
|
+
shortMessage: message,
|
|
687
|
+
detailedMessage: {
|
|
688
|
+
content: detailedMessage,
|
|
689
|
+
long: isRpc
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
function getLastConvertedTokenInFailedSwap(pendingSwap) {
|
|
694
|
+
let resultToken = null;
|
|
695
|
+
if (pendingSwap.status === 'failed') {
|
|
696
|
+
const lastSuccessStep = pendingSwap.steps.slice().reverse().filter(step => step.status === 'success')[0];
|
|
697
|
+
if (lastSuccessStep) {
|
|
698
|
+
resultToken = {
|
|
699
|
+
blockchain: lastSuccessStep.toBlockchain,
|
|
700
|
+
symbol: lastSuccessStep.toSymbol,
|
|
701
|
+
outputAmount: lastSuccessStep.outputAmount,
|
|
702
|
+
address: lastSuccessStep.toSymbolAddress
|
|
703
|
+
};
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
return resultToken;
|
|
707
|
+
}
|
|
708
|
+
function shouldRetrySwap(pendingSwap) {
|
|
709
|
+
return pendingSwap.status === 'failed' && !!pendingSwap.finishTime && new Date().getTime() - parseInt(pendingSwap.finishTime) < 4 * 3600 * 1000;
|
|
710
|
+
}
|
|
636
711
|
|
|
637
712
|
function searchParamsToToken(tokens, searchParams, chain) {
|
|
638
713
|
if (!chain) return null;
|
|
@@ -670,22 +745,13 @@ function getRequiredBalanceOfWallet(selectedWallet, fee) {
|
|
|
670
745
|
return relatedFeeStatus.requiredAssets;
|
|
671
746
|
}
|
|
672
747
|
function isRouteParametersChanged(prevParams, currentParams) {
|
|
673
|
-
return prevParams.fromChain?.name !== currentParams.fromChain?.name || prevParams.toChain?.name !== currentParams.toChain?.name || prevParams.fromToken?.symbol !== currentParams.fromToken?.symbol || prevParams.toToken?.symbol !== currentParams.toToken?.symbol || prevParams.fromToken?.blockchain !== currentParams.fromToken?.blockchain || prevParams.toToken?.blockchain !== currentParams.toToken?.blockchain || prevParams.fromToken?.address !== currentParams.fromToken?.address || prevParams.toToken?.address !== currentParams.toToken?.address || prevParams.inputAmount !== currentParams.inputAmount || prevParams.slippage !== currentParams.slippage || prevParams.customSlippage !== currentParams.customSlippage || prevParams.disabledLiquiditySources?.length !== currentParams.disabledLiquiditySources?.length;
|
|
674
|
-
}
|
|
675
|
-
function getBestRouteWithCalculatedFees(bestRoute, tokens) {
|
|
676
|
-
if (!bestRoute || !bestRoute.result) return null;
|
|
677
|
-
const swapsWithFee = (bestRoute?.result?.swaps || []).map(swap => ({
|
|
678
|
-
...swap,
|
|
679
|
-
feeInUsd: numberToString(getUsdFeeOfStep(swap, tokens), 0, 2)
|
|
680
|
-
}));
|
|
681
|
-
return {
|
|
682
|
-
...bestRoute,
|
|
683
|
-
result: {
|
|
684
|
-
...bestRoute.result,
|
|
685
|
-
swaps: swapsWithFee
|
|
686
|
-
}
|
|
687
|
-
};
|
|
748
|
+
return !!currentParams.fromToken && !!currentParams.toToken && (prevParams.fromChain?.name !== currentParams.fromChain?.name || prevParams.toChain?.name !== currentParams.toChain?.name || prevParams.fromToken?.symbol !== currentParams.fromToken?.symbol || prevParams.toToken?.symbol !== currentParams.toToken?.symbol || prevParams.fromToken?.blockchain !== currentParams.fromToken?.blockchain || prevParams.toToken?.blockchain !== currentParams.toToken?.blockchain || prevParams.fromToken?.address !== currentParams.fromToken?.address || prevParams.toToken?.address !== currentParams.toToken?.address || prevParams.inputAmount !== currentParams.inputAmount || prevParams.slippage !== currentParams.slippage || prevParams.customSlippage !== currentParams.customSlippage || prevParams.disabledLiquiditySources?.length !== currentParams.disabledLiquiditySources?.length);
|
|
688
749
|
}
|
|
750
|
+
//todo: refactor bestRoute store and add loadingStatus
|
|
751
|
+
const getBestRouteStatus = (loading, error) => {
|
|
752
|
+
if (loading) return 'loading';
|
|
753
|
+
if (error) return 'failed';else return 'success';
|
|
754
|
+
};
|
|
689
755
|
|
|
690
756
|
const createSelectors = _store => {
|
|
691
757
|
let store = _store;
|
|
@@ -836,7 +902,7 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
836
902
|
}
|
|
837
903
|
});
|
|
838
904
|
return {
|
|
839
|
-
selectedWallets:
|
|
905
|
+
selectedWallets: selectedWallets
|
|
840
906
|
};
|
|
841
907
|
}),
|
|
842
908
|
setSelectedWallet: wallet => set(state => ({
|
|
@@ -868,6 +934,7 @@ useWalletsStore.subscribe(state => state.balances, balances => {
|
|
|
868
934
|
}, {
|
|
869
935
|
equalityFn: shallow
|
|
870
936
|
});
|
|
937
|
+
const fetchingBalanceSelector = state => !!state.balances.find(wallet => wallet.loading);
|
|
871
938
|
|
|
872
939
|
const getUsdValue = (token, amount) => new BigNumber(amount || ZERO).multipliedBy(token?.usdPrice || 0);
|
|
873
940
|
const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/subscribeWithSelector(set => ({
|
|
@@ -887,6 +954,7 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
887
954
|
setBestRoute: bestRoute => set(state => {
|
|
888
955
|
let outputAmount = null;
|
|
889
956
|
let outputUsdValue = ZERO;
|
|
957
|
+
if (!state.inputAmount || state.inputAmount === '0') return {};
|
|
890
958
|
if (!!bestRoute) {
|
|
891
959
|
outputAmount = !!bestRoute.result?.outputAmount ? new BigNumber(bestRoute.result?.outputAmount) : null;
|
|
892
960
|
outputUsdValue = calcOutputUsdValue(bestRoute.result?.outputAmount, getBestRouteToTokenUsdPrice(bestRoute) || state.toToken?.usdPrice);
|
|
@@ -943,6 +1011,7 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
943
1011
|
toToken: token
|
|
944
1012
|
})),
|
|
945
1013
|
setInputAmount: amount => {
|
|
1014
|
+
console.log(amount, typeof amount);
|
|
946
1015
|
set(state => ({
|
|
947
1016
|
inputAmount: amount,
|
|
948
1017
|
...(!amount && {
|
|
@@ -954,6 +1023,47 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
954
1023
|
inputUsdValue: getUsdValue(state.fromToken, amount)
|
|
955
1024
|
})
|
|
956
1025
|
}));
|
|
1026
|
+
},
|
|
1027
|
+
retry: pendingSwap => {
|
|
1028
|
+
const {
|
|
1029
|
+
tokens,
|
|
1030
|
+
blockchains
|
|
1031
|
+
} = useMetaStore.getState().meta;
|
|
1032
|
+
const balances = useWalletsStore.getState().balances;
|
|
1033
|
+
const failedIndex = pendingSwap.status === 'failed' ? pendingSwap.steps.findIndex(s => s.status === 'failed') : null;
|
|
1034
|
+
if (failedIndex === null || failedIndex < 0) return;
|
|
1035
|
+
const firstStep = pendingSwap.steps[0];
|
|
1036
|
+
const lastStep = pendingSwap.steps[pendingSwap.steps.length - 1];
|
|
1037
|
+
const fromChain = blockchains.find(blockchain => blockchain.name === firstStep.fromBlockchain) || null;
|
|
1038
|
+
const toChain = blockchains.find(blockchain => blockchain.name === lastStep.toBlockchain) || null;
|
|
1039
|
+
const fromToken = tokens.find(token => tokensAreEqual(token, {
|
|
1040
|
+
blockchain: firstStep.fromBlockchain,
|
|
1041
|
+
symbol: firstStep.fromSymbol,
|
|
1042
|
+
address: firstStep.fromSymbolAddress
|
|
1043
|
+
}));
|
|
1044
|
+
const toToken = tokens.find(token => tokensAreEqual(token, {
|
|
1045
|
+
blockchain: lastStep.toBlockchain,
|
|
1046
|
+
symbol: lastStep.toSymbol,
|
|
1047
|
+
address: lastStep.toSymbolAddress
|
|
1048
|
+
}));
|
|
1049
|
+
const sortedSourceTokens = getSortedTokens(fromChain, tokens, balances, []);
|
|
1050
|
+
const sortedDestinationTokens = getSortedTokens(toChain, tokens, balances, []);
|
|
1051
|
+
const inputAmount = pendingSwap.inputAmount;
|
|
1052
|
+
set({
|
|
1053
|
+
fromChain,
|
|
1054
|
+
fromToken,
|
|
1055
|
+
inputAmount,
|
|
1056
|
+
outputAmount: null,
|
|
1057
|
+
inputUsdValue: getUsdValue(fromToken || null, inputAmount),
|
|
1058
|
+
outputUsdValue: new BigNumber(0),
|
|
1059
|
+
toChain,
|
|
1060
|
+
toToken,
|
|
1061
|
+
bestRoute: null,
|
|
1062
|
+
loading: false,
|
|
1063
|
+
error: '',
|
|
1064
|
+
sourceTokens: sortedSourceTokens,
|
|
1065
|
+
destinationTokens: sortedDestinationTokens
|
|
1066
|
+
});
|
|
957
1067
|
}
|
|
958
1068
|
}))));
|
|
959
1069
|
const bestRoute = (bestRouteStore, settingsStore) => {
|
|
@@ -969,12 +1079,12 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
969
1079
|
customSlippage,
|
|
970
1080
|
disabledLiquiditySources
|
|
971
1081
|
} = settingsStore.getState();
|
|
972
|
-
if (!fromToken || !toToken || !inputAmount) return;
|
|
1082
|
+
if (!fromToken || !toToken || !inputAmount || inputAmount === '0') return;
|
|
973
1083
|
abortController?.abort();
|
|
974
1084
|
abortController = new AbortController();
|
|
975
1085
|
const userSlippage = !!customSlippage ? customSlippage : slippage;
|
|
976
1086
|
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false);
|
|
977
|
-
bestRouteStore.setState({
|
|
1087
|
+
if (!bestRouteStore.getState().loading) bestRouteStore.setState({
|
|
978
1088
|
loading: true,
|
|
979
1089
|
bestRoute: null,
|
|
980
1090
|
outputAmount: null,
|
|
@@ -999,13 +1109,36 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
999
1109
|
});
|
|
1000
1110
|
});
|
|
1001
1111
|
};
|
|
1112
|
+
const debouncedFetchBestRoute = debounce(fetchBestRoute, 600);
|
|
1113
|
+
const bestRouteParamsListener = () => {
|
|
1114
|
+
const {
|
|
1115
|
+
fromToken,
|
|
1116
|
+
toToken,
|
|
1117
|
+
inputAmount,
|
|
1118
|
+
inputUsdValue
|
|
1119
|
+
} = useBestRouteStore.getState();
|
|
1120
|
+
if (!inputAmount || inputAmount === '0') return;
|
|
1121
|
+
if (tokensAreEqual(fromToken, toToken)) return bestRouteStore.setState({
|
|
1122
|
+
loading: false,
|
|
1123
|
+
bestRoute: null,
|
|
1124
|
+
outputAmount: new BigNumber(inputAmount),
|
|
1125
|
+
outputUsdValue: inputUsdValue
|
|
1126
|
+
});
|
|
1127
|
+
if (!bestRouteStore.getState().loading) bestRouteStore.setState({
|
|
1128
|
+
loading: true,
|
|
1129
|
+
bestRoute: null,
|
|
1130
|
+
outputAmount: null,
|
|
1131
|
+
outputUsdValue: new BigNumber(0)
|
|
1132
|
+
});
|
|
1133
|
+
debouncedFetchBestRoute();
|
|
1134
|
+
};
|
|
1002
1135
|
useBestRouteStore.subscribe(state => ({
|
|
1003
1136
|
fromChain: state.fromChain,
|
|
1004
1137
|
fromToken: state.fromToken,
|
|
1005
1138
|
toChain: state.toChain,
|
|
1006
1139
|
toToken: state.toToken,
|
|
1007
1140
|
inputAmount: state.inputAmount
|
|
1008
|
-
}),
|
|
1141
|
+
}), bestRouteParamsListener, {
|
|
1009
1142
|
equalityFn: (prevState, state) => {
|
|
1010
1143
|
if (isRouteParametersChanged(prevState, state)) return false;else return true;
|
|
1011
1144
|
}
|
|
@@ -1014,7 +1147,7 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1014
1147
|
slippage: state.slippage,
|
|
1015
1148
|
customSlippage: state.customSlippage,
|
|
1016
1149
|
disabledLiquiditySources: state.disabledLiquiditySources
|
|
1017
|
-
}),
|
|
1150
|
+
}), bestRouteParamsListener, {
|
|
1018
1151
|
equalityFn: (prevState, state) => {
|
|
1019
1152
|
if (isRouteParametersChanged(prevState, state)) return false;else return true;
|
|
1020
1153
|
}
|
|
@@ -1039,11 +1172,15 @@ var SearchParams;
|
|
|
1039
1172
|
const useUiStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()(set => ({
|
|
1040
1173
|
connectWalletsButtonDisabled: false,
|
|
1041
1174
|
selectedSwapRequestId: null,
|
|
1175
|
+
currentPage: '',
|
|
1042
1176
|
toggleConnectWalletsButton: () => set(state => ({
|
|
1043
1177
|
connectWalletsButtonDisabled: !state.connectWalletsButtonDisabled
|
|
1044
1178
|
})),
|
|
1045
1179
|
setSelectedSwap: requestId => set({
|
|
1046
1180
|
selectedSwapRequestId: requestId
|
|
1181
|
+
}),
|
|
1182
|
+
setCurrentPage: path => set({
|
|
1183
|
+
currentPage: path
|
|
1047
1184
|
})
|
|
1048
1185
|
})));
|
|
1049
1186
|
|
|
@@ -1084,7 +1221,7 @@ function UpdateUrl() {
|
|
|
1084
1221
|
toChainString = '',
|
|
1085
1222
|
toTokenString = '',
|
|
1086
1223
|
fromAmount = '';
|
|
1087
|
-
if (loadingStatus !== 'success' &&
|
|
1224
|
+
if (loadingStatus !== 'success' && location.pathname != navigationRoutes.confirmSwap) {
|
|
1088
1225
|
fromChainString = searchParamsRef.current[SearchParams.FROM_CHAIN];
|
|
1089
1226
|
fromTokenString = searchParamsRef.current[SearchParams.FROM_TOKEN];
|
|
1090
1227
|
toChainString = searchParamsRef.current[SearchParams.TO_CHAIN];
|
|
@@ -1177,67 +1314,6 @@ function UpdateUrl() {
|
|
|
1177
1314
|
return null;
|
|
1178
1315
|
}
|
|
1179
1316
|
|
|
1180
|
-
const ButtonsContainer = /*#__PURE__*/styled('div', {
|
|
1181
|
-
display: 'flex'
|
|
1182
|
-
});
|
|
1183
|
-
function HeaderButtons(props) {
|
|
1184
|
-
const {
|
|
1185
|
-
onClickRefresh
|
|
1186
|
-
} = props;
|
|
1187
|
-
const navigate = useNavigate();
|
|
1188
|
-
return React.createElement(ButtonsContainer, null, React.createElement(Tooltip, {
|
|
1189
|
-
content: "Refresh"
|
|
1190
|
-
}, React.createElement(Button, {
|
|
1191
|
-
variant: "ghost",
|
|
1192
|
-
onClick: onClickRefresh
|
|
1193
|
-
}, React.createElement(RetryIcon, {
|
|
1194
|
-
size: 24
|
|
1195
|
-
}))), React.createElement(Tooltip, {
|
|
1196
|
-
content: "Transactions History"
|
|
1197
|
-
}, React.createElement(Button, {
|
|
1198
|
-
variant: "ghost",
|
|
1199
|
-
onClick: () => navigate(navigationRoutes.swaps)
|
|
1200
|
-
}, React.createElement(HistoryIcon, {
|
|
1201
|
-
size: 24
|
|
1202
|
-
}))), React.createElement(Tooltip, {
|
|
1203
|
-
content: "Settings"
|
|
1204
|
-
}, React.createElement(Button, {
|
|
1205
|
-
variant: "ghost",
|
|
1206
|
-
onClick: () => navigate(navigationRoutes.settings)
|
|
1207
|
-
}, React.createElement(SettingsIcon, {
|
|
1208
|
-
size: 24
|
|
1209
|
-
}))));
|
|
1210
|
-
}
|
|
1211
|
-
|
|
1212
|
-
const HeaderContainer = /*#__PURE__*/styled('div', {
|
|
1213
|
-
display: 'flex',
|
|
1214
|
-
justifyContent: 'space-between',
|
|
1215
|
-
alignItems: 'center',
|
|
1216
|
-
width: '100%',
|
|
1217
|
-
padding: '$16 0'
|
|
1218
|
-
});
|
|
1219
|
-
function Header(props) {
|
|
1220
|
-
const {
|
|
1221
|
-
onClickRefresh,
|
|
1222
|
-
title,
|
|
1223
|
-
titleSize,
|
|
1224
|
-
titleWeight
|
|
1225
|
-
} = props;
|
|
1226
|
-
const {
|
|
1227
|
-
t
|
|
1228
|
-
} = useTranslation();
|
|
1229
|
-
const titleStyle = css({
|
|
1230
|
-
fontSize: `${titleSize}px !important`,
|
|
1231
|
-
fontWeight: `${titleWeight} !important`
|
|
1232
|
-
});
|
|
1233
|
-
return React.createElement(HeaderContainer, null, React.createElement(Typography, {
|
|
1234
|
-
variant: "h4",
|
|
1235
|
-
className: titleStyle()
|
|
1236
|
-
}, title ? t(title.toLocaleLowerCase()) : ''), React.createElement(HeaderButtons, {
|
|
1237
|
-
onClickRefresh: onClickRefresh
|
|
1238
|
-
}));
|
|
1239
|
-
}
|
|
1240
|
-
|
|
1241
1317
|
const Box = /*#__PURE__*/styled('div', {
|
|
1242
1318
|
display: 'flex',
|
|
1243
1319
|
flexDirection: 'column',
|
|
@@ -1525,6 +1601,39 @@ const errorMessages = {
|
|
|
1525
1601
|
genericServerError: 'Error connecting server, please reload the app and try again'
|
|
1526
1602
|
};
|
|
1527
1603
|
|
|
1604
|
+
const ButtonsContainer = /*#__PURE__*/styled('div', {
|
|
1605
|
+
display: 'flex'
|
|
1606
|
+
});
|
|
1607
|
+
function HeaderButtons(props) {
|
|
1608
|
+
const {
|
|
1609
|
+
onClickRefresh
|
|
1610
|
+
} = props;
|
|
1611
|
+
const navigate = useNavigate();
|
|
1612
|
+
return React.createElement(ButtonsContainer, null, React.createElement(Tooltip, {
|
|
1613
|
+
content: "Refresh"
|
|
1614
|
+
}, React.createElement(Button, {
|
|
1615
|
+
variant: "ghost",
|
|
1616
|
+
onClick: onClickRefresh,
|
|
1617
|
+
disabled: !onClickRefresh
|
|
1618
|
+
}, React.createElement(RetryIcon, {
|
|
1619
|
+
size: 24
|
|
1620
|
+
}))), React.createElement(Tooltip, {
|
|
1621
|
+
content: "Transactions History"
|
|
1622
|
+
}, React.createElement(Button, {
|
|
1623
|
+
variant: "ghost",
|
|
1624
|
+
onClick: () => navigate(navigationRoutes.swaps)
|
|
1625
|
+
}, React.createElement(HistoryIcon, {
|
|
1626
|
+
size: 24
|
|
1627
|
+
}))), React.createElement(Tooltip, {
|
|
1628
|
+
content: "Settings"
|
|
1629
|
+
}, React.createElement(Button, {
|
|
1630
|
+
variant: "ghost",
|
|
1631
|
+
onClick: () => navigate(navigationRoutes.settings)
|
|
1632
|
+
}, React.createElement(SettingsIcon, {
|
|
1633
|
+
size: 24
|
|
1634
|
+
}))));
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1528
1637
|
const Container$2 = /*#__PURE__*/styled('div', {
|
|
1529
1638
|
display: 'flex',
|
|
1530
1639
|
flexDirection: 'column'
|
|
@@ -1549,9 +1658,7 @@ const Alerts = /*#__PURE__*/styled('div', {
|
|
|
1549
1658
|
});
|
|
1550
1659
|
function Home(props) {
|
|
1551
1660
|
const {
|
|
1552
|
-
title = 'SWAP'
|
|
1553
|
-
titleSize = 18,
|
|
1554
|
-
titleWeight = 600
|
|
1661
|
+
title = 'SWAP'
|
|
1555
1662
|
} = props;
|
|
1556
1663
|
const isRouterInContext = useInRouterContext();
|
|
1557
1664
|
const navigate = useNavigate();
|
|
@@ -1575,6 +1682,7 @@ function Home(props) {
|
|
|
1575
1682
|
const bestRouteError = useBestRouteStore.use.error();
|
|
1576
1683
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
1577
1684
|
const accounts = useWalletsStore.use.accounts();
|
|
1685
|
+
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
1578
1686
|
const swithFromAndTo = () => {
|
|
1579
1687
|
setFromChain(toChain);
|
|
1580
1688
|
setFromToken(toToken);
|
|
@@ -1598,11 +1706,15 @@ function Home(props) {
|
|
|
1598
1706
|
const swapButtonState = getSwapButtonState(loadingMetaStatus, accounts, fetchingBestRoute, bestRoute, hasLimitError(bestRoute), highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputIsZero);
|
|
1599
1707
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
1600
1708
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
1601
|
-
|
|
1709
|
+
useEffect(() => {
|
|
1710
|
+
setCurrentPage(navigationRoutes.home);
|
|
1711
|
+
return setCurrentPage.bind(null, '');
|
|
1712
|
+
}, []);
|
|
1713
|
+
return React.createElement(Container$2, null, React.createElement(Header$1, {
|
|
1602
1714
|
title: title,
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1715
|
+
suffix: React.createElement(HeaderButtons, {
|
|
1716
|
+
onClickRefresh: !!bestRoute ? fetchBestRoute : undefined
|
|
1717
|
+
})
|
|
1606
1718
|
}), React.createElement(FromContainer, null, React.createElement(TokenInfo, {
|
|
1607
1719
|
type: "From",
|
|
1608
1720
|
chain: fromChain,
|
|
@@ -1613,7 +1725,7 @@ function Home(props) {
|
|
|
1613
1725
|
variant: "ghost",
|
|
1614
1726
|
onClick: swithFromAndTo
|
|
1615
1727
|
}, React.createElement(VerticalSwapIcon, {
|
|
1616
|
-
size:
|
|
1728
|
+
size: 32
|
|
1617
1729
|
}), isRouterInContext && React.createElement(SwithFromAndTo, {
|
|
1618
1730
|
count: count
|
|
1619
1731
|
})))), React.createElement(TokenInfo, {
|
|
@@ -1647,7 +1759,7 @@ function Home(props) {
|
|
|
1647
1759
|
disabled: swapButtonState.disabled,
|
|
1648
1760
|
onClick: () => {
|
|
1649
1761
|
if (swapButtonState.title === 'Connect Wallet') navigate(navigationRoutes.wallets);else {
|
|
1650
|
-
navigate(navigationRoutes.
|
|
1762
|
+
navigate(navigationRoutes.confirmSwap, {
|
|
1651
1763
|
replace: true
|
|
1652
1764
|
});
|
|
1653
1765
|
}
|
|
@@ -1664,12 +1776,12 @@ const Route = _ref => {
|
|
|
1664
1776
|
const navigate = useNavigate$1();
|
|
1665
1777
|
const ref = useRef(true);
|
|
1666
1778
|
useEffect(() => {
|
|
1667
|
-
if (
|
|
1779
|
+
if (location.pathname === navigationRoutes.confirmSwap && ref.current) navigate(navigationRoutes.home + location.search, {
|
|
1668
1780
|
state: 'redirect'
|
|
1669
1781
|
});
|
|
1670
1782
|
ref.current = false;
|
|
1671
1783
|
}, []);
|
|
1672
|
-
if (
|
|
1784
|
+
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React.createElement(Home, Object.assign({}, props));
|
|
1673
1785
|
return React.createElement(React.Fragment, null, " ", children);
|
|
1674
1786
|
};
|
|
1675
1787
|
function AppRouter(_ref2) {
|
|
@@ -1679,52 +1791,34 @@ function AppRouter(_ref2) {
|
|
|
1679
1791
|
} = _ref2;
|
|
1680
1792
|
const isRouterInContext = useInRouterContext$1();
|
|
1681
1793
|
const Router = isRouterInContext ? Route : MemoryRouter;
|
|
1682
|
-
return React.createElement(React.Fragment, null, React.createElement(Router, Object.assign({}, props), children), isRouterInContext && React.createElement(UpdateUrl, null));
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
|
-
function ChangeSlippageButton() {
|
|
1686
|
-
const navigate = useNavigate();
|
|
1687
|
-
return React.createElement(Button, {
|
|
1688
|
-
type: "primary",
|
|
1689
|
-
variant: "outlined",
|
|
1690
|
-
size: "small",
|
|
1691
|
-
onClick: () => navigate(navigationRoutes.settings)
|
|
1692
|
-
}, "Change Slippage");
|
|
1693
|
-
}
|
|
1694
|
-
|
|
1695
|
-
function HighSlippageWarning(props) {
|
|
1696
|
-
const {
|
|
1697
|
-
selectedSlippage
|
|
1698
|
-
} = props;
|
|
1699
|
-
return React.createElement(Alert, {
|
|
1700
|
-
type: "warning",
|
|
1701
|
-
footer: React.createElement(ChangeSlippageButton, null)
|
|
1702
|
-
}, "Caution, your slippage is high (=", selectedSlippage, "). Your trade may be front run.");
|
|
1703
|
-
}
|
|
1704
|
-
|
|
1705
|
-
function ConfirmSwapExtraMessages(props) {
|
|
1706
1794
|
const {
|
|
1707
|
-
|
|
1708
|
-
} =
|
|
1709
|
-
const
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1795
|
+
blockchains
|
|
1796
|
+
} = useMetaStore.use.meta();
|
|
1797
|
+
const evmChains = blockchains.filter(isEvmBlockchain);
|
|
1798
|
+
useQueueManager({
|
|
1799
|
+
lastConnectedWallet: props.lastConnectedWallet,
|
|
1800
|
+
clearDisconnectedWallet: props.clearDisconnectedWallet,
|
|
1801
|
+
disconnectedWallet: props.disconnectedWallet,
|
|
1802
|
+
evmChains,
|
|
1803
|
+
notifier: () => {}
|
|
1804
|
+
});
|
|
1805
|
+
return React.createElement(React.Fragment, null, React.createElement(Router, Object.assign({}, props), children), isRouterInContext && React.createElement(UpdateUrl, null));
|
|
1713
1806
|
}
|
|
1714
1807
|
|
|
1715
1808
|
function useNavigateBack() {
|
|
1716
1809
|
const isRouterInContext = useInRouterContext();
|
|
1717
1810
|
const navigate = useNavigate();
|
|
1718
1811
|
const navigateBackFrom = currentRoute => {
|
|
1812
|
+
if (currentRoute === navigationRoutes.swapDetails) return navigate(navigationRoutes.swaps, {
|
|
1813
|
+
replace: true
|
|
1814
|
+
});
|
|
1719
1815
|
if (!isRouterInContext || window.history.state && window.history.state.idx > 0) navigate(-1);else {
|
|
1720
|
-
if ([navigationRoutes.fromChain, navigationRoutes.fromToken, navigationRoutes.toChain, navigationRoutes.toToken, navigationRoutes.settings, navigationRoutes.wallets, navigationRoutes.swaps, navigationRoutes.
|
|
1816
|
+
if ([navigationRoutes.fromChain, navigationRoutes.fromToken, navigationRoutes.toChain, navigationRoutes.toToken, navigationRoutes.settings, navigationRoutes.wallets, navigationRoutes.swaps, navigationRoutes.confirmSwap].includes(currentRoute)) navigate(navigationRoutes.home, {
|
|
1721
1817
|
replace: true
|
|
1722
1818
|
});else if (currentRoute === navigationRoutes.liquiditySources) navigate(navigationRoutes.settings, {
|
|
1723
1819
|
replace: true
|
|
1724
1820
|
});else if (currentRoute === navigationRoutes.swapDetails) navigate(navigationRoutes.swaps, {
|
|
1725
1821
|
replace: true
|
|
1726
|
-
});else if (currentRoute === navigationRoutes.confirmSwap) navigate(navigationRoutes.confirmWallets, {
|
|
1727
|
-
replace: true
|
|
1728
1822
|
});
|
|
1729
1823
|
}
|
|
1730
1824
|
};
|
|
@@ -1733,122 +1827,192 @@ function useNavigateBack() {
|
|
|
1733
1827
|
};
|
|
1734
1828
|
}
|
|
1735
1829
|
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
ConfirmSwapErrorTypes[ConfirmSwapErrorTypes["REQUEST_FAILED"] = 2] = "REQUEST_FAILED";
|
|
1741
|
-
ConfirmSwapErrorTypes[ConfirmSwapErrorTypes["INSUFFICIENT_SLIPPAGE"] = 3] = "INSUFFICIENT_SLIPPAGE";
|
|
1742
|
-
})(ConfirmSwapErrorTypes || (ConfirmSwapErrorTypes = {}));
|
|
1743
|
-
var ConfirmSwapWarningTypes;
|
|
1744
|
-
(function (ConfirmSwapWarningTypes) {
|
|
1745
|
-
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["ROUTE_UPDATED"] = 0] = "ROUTE_UPDATED";
|
|
1746
|
-
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["ROUTE_SWAPPERS_UPDATED"] = 1] = "ROUTE_SWAPPERS_UPDATED";
|
|
1747
|
-
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["ROUTE_COINS_UPDATED"] = 2] = "ROUTE_COINS_UPDATED";
|
|
1748
|
-
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["ROUTE_AND_OUTPUT_AMOUNT_UPDATED"] = 3] = "ROUTE_AND_OUTPUT_AMOUNT_UPDATED";
|
|
1749
|
-
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["INSUFFICIENT_BALANCE"] = 4] = "INSUFFICIENT_BALANCE";
|
|
1750
|
-
})(ConfirmSwapWarningTypes || (ConfirmSwapWarningTypes = {}));
|
|
1751
|
-
|
|
1752
|
-
function MinRequiredSlippage(_ref) {
|
|
1753
|
-
let {
|
|
1754
|
-
minRequiredSlippage
|
|
1755
|
-
} = _ref;
|
|
1756
|
-
return React.createElement(Typography, {
|
|
1757
|
-
variant: "body2"
|
|
1758
|
-
}, "We recommend you to increase slippage to at least \u00A0", minRequiredSlippage, "\u00A0 for this route.", React.createElement(ChangeSlippageButton, null));
|
|
1759
|
-
}
|
|
1760
|
-
|
|
1761
|
-
function ConfirmSwapErrors(errors) {
|
|
1762
|
-
return errors.flatMap(error => {
|
|
1763
|
-
switch (error.type) {
|
|
1764
|
-
case ConfirmSwapErrorTypes.NO_ROUTE:
|
|
1765
|
-
return React.createElement(Typography, {
|
|
1766
|
-
variant: "body2"
|
|
1767
|
-
}, "No routes found. Please try again later.");
|
|
1768
|
-
case ConfirmSwapErrorTypes.REQUEST_FAILED:
|
|
1769
|
-
return React.createElement(Typography, {
|
|
1770
|
-
variant: "body2"
|
|
1771
|
-
}, `Failed to confirm swap ${error.status ? `'status': ${error.status})` : ''}, please try again.`);
|
|
1772
|
-
case ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS:
|
|
1773
|
-
return React.createElement(Typography, {
|
|
1774
|
-
variant: "body2"
|
|
1775
|
-
}, "Route updated and price impact is too high, try again later!");
|
|
1776
|
-
case ConfirmSwapErrorTypes.INSUFFICIENT_SLIPPAGE:
|
|
1777
|
-
return React.createElement(MinRequiredSlippage, {
|
|
1778
|
-
minRequiredSlippage: error.minRequiredSlippage
|
|
1779
|
-
});
|
|
1780
|
-
default:
|
|
1781
|
-
return [];
|
|
1782
|
-
}
|
|
1783
|
-
});
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
const List = /*#__PURE__*/styled('ul', {
|
|
1787
|
-
variants: {
|
|
1788
|
-
showListStyle: {
|
|
1789
|
-
true: {
|
|
1790
|
-
paddingLeft: '$24'
|
|
1791
|
-
}
|
|
1792
|
-
}
|
|
1793
|
-
}
|
|
1830
|
+
const Box$1 = /*#__PURE__*/styled('div', {
|
|
1831
|
+
display: 'flex',
|
|
1832
|
+
flexDirection: 'column',
|
|
1833
|
+
width: '100%'
|
|
1794
1834
|
});
|
|
1795
|
-
const
|
|
1835
|
+
const Container$3 = /*#__PURE__*/styled('div', {
|
|
1836
|
+
boxSizing: 'border-box',
|
|
1837
|
+
borderRadius: '$5',
|
|
1838
|
+
padding: '$8 $16 $16 $16',
|
|
1796
1839
|
variants: {
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1840
|
+
type: {
|
|
1841
|
+
filled: {
|
|
1842
|
+
backgroundColor: '$neutrals300'
|
|
1843
|
+
},
|
|
1844
|
+
outlined: {
|
|
1845
|
+
border: '1px solid $neutrals300'
|
|
1801
1846
|
}
|
|
1802
1847
|
}
|
|
1803
|
-
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1848
|
+
},
|
|
1849
|
+
defaultVariants: {
|
|
1850
|
+
type: 'filled'
|
|
1851
|
+
},
|
|
1852
|
+
'.head': {
|
|
1853
|
+
display: 'flex',
|
|
1854
|
+
justifyContent: 'space-between',
|
|
1855
|
+
alignItems: 'center',
|
|
1856
|
+
minHeight: '32px'
|
|
1857
|
+
},
|
|
1858
|
+
'.form': {
|
|
1859
|
+
display: 'flex',
|
|
1860
|
+
width: '100%',
|
|
1861
|
+
padding: '$2 0',
|
|
1862
|
+
'.selectors': {
|
|
1863
|
+
width: '35%',
|
|
1864
|
+
'._text': {
|
|
1865
|
+
whiteSpace: 'nowrap',
|
|
1866
|
+
overflow: 'hidden',
|
|
1867
|
+
textOverflow: 'ellipsis'
|
|
1868
|
+
}
|
|
1869
|
+
},
|
|
1870
|
+
'.amount': {
|
|
1871
|
+
width: '30%'
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
});
|
|
1875
|
+
const StyledImage$1 = /*#__PURE__*/styled('img', {
|
|
1876
|
+
width: '$24',
|
|
1877
|
+
maxHeight: '$24'
|
|
1878
|
+
});
|
|
1879
|
+
const ImagePlaceholder$1 = /*#__PURE__*/styled('span', {
|
|
1880
|
+
width: '24px',
|
|
1881
|
+
height: '24px',
|
|
1882
|
+
backgroundColor: '$neutrals300',
|
|
1883
|
+
borderRadius: '99999px'
|
|
1884
|
+
});
|
|
1885
|
+
const OutputContainer$1 = /*#__PURE__*/styled('div', {
|
|
1886
|
+
windth: '100%',
|
|
1887
|
+
height: '$48',
|
|
1888
|
+
borderRadius: '$5',
|
|
1889
|
+
backgroundColor: '$background',
|
|
1890
|
+
border: '1px solid transparent',
|
|
1891
|
+
position: 'relative',
|
|
1892
|
+
display: 'flex',
|
|
1893
|
+
alignItems: 'center',
|
|
1894
|
+
paddingLeft: '$8',
|
|
1895
|
+
paddingRight: '$8'
|
|
1896
|
+
});
|
|
1897
|
+
function TokenPreview(props) {
|
|
1898
|
+
const {
|
|
1899
|
+
chain,
|
|
1900
|
+
token,
|
|
1901
|
+
loadingStatus
|
|
1902
|
+
} = props;
|
|
1903
|
+
const {
|
|
1904
|
+
t
|
|
1905
|
+
} = useTranslation();
|
|
1906
|
+
const ItemSuffix = React.createElement("div", {
|
|
1907
|
+
style: {
|
|
1908
|
+
display: 'flex',
|
|
1909
|
+
justifyContent: 'center',
|
|
1910
|
+
alignItems: 'center'
|
|
1911
|
+
}
|
|
1912
|
+
}, loadingStatus === 'failed' && React.createElement(InfoCircleIcon, {
|
|
1913
|
+
color: "error",
|
|
1914
|
+
size: 24
|
|
1915
|
+
}));
|
|
1916
|
+
return React.createElement(Box$1, null, React.createElement(Container$3, {
|
|
1917
|
+
type: 'outlined'
|
|
1918
|
+
}, React.createElement("div", {
|
|
1919
|
+
className: "head"
|
|
1920
|
+
}, React.createElement(Typography, {
|
|
1921
|
+
variant: "body2",
|
|
1922
|
+
color: "neutrals800"
|
|
1923
|
+
}, props.label), props.usdValue && React.createElement(Typography, {
|
|
1924
|
+
variant: "caption",
|
|
1925
|
+
color: "neutrals600"
|
|
1926
|
+
}, `$${numberToString(props.usdValue)}`)), React.createElement("div", {
|
|
1927
|
+
className: "form"
|
|
1928
|
+
}, React.createElement(Button, {
|
|
1929
|
+
className: "selectors",
|
|
1930
|
+
variant: "outlined",
|
|
1931
|
+
loading: loadingStatus === 'loading',
|
|
1932
|
+
prefix: loadingStatus === 'success' && chain ? React.createElement(StyledImage$1, {
|
|
1933
|
+
src: chain.logo
|
|
1934
|
+
}) : React.createElement(ImagePlaceholder$1, null),
|
|
1935
|
+
suffix: ItemSuffix,
|
|
1936
|
+
align: "start",
|
|
1937
|
+
size: "large"
|
|
1938
|
+
}, loadingStatus === 'success' && chain ? chain.displayName : t('Chain')), React.createElement(Spacer, {
|
|
1939
|
+
size: 12
|
|
1940
|
+
}), React.createElement(Button, {
|
|
1941
|
+
className: "selectors",
|
|
1942
|
+
variant: "outlined",
|
|
1943
|
+
loading: loadingStatus === 'loading',
|
|
1944
|
+
prefix: loadingStatus === 'success' && token ? React.createElement(StyledImage$1, {
|
|
1945
|
+
src: token.image
|
|
1946
|
+
}) : React.createElement(ImagePlaceholder$1, null),
|
|
1947
|
+
suffix: ItemSuffix,
|
|
1948
|
+
size: "large",
|
|
1949
|
+
align: "start"
|
|
1950
|
+
}, loadingStatus === 'success' && token ? token.symbol : t('Token')), React.createElement(Spacer, {
|
|
1951
|
+
size: 12
|
|
1952
|
+
}), React.createElement("div", {
|
|
1953
|
+
className: "amount"
|
|
1954
|
+
}, React.createElement(OutputContainer$1, null, React.createElement(Typography, {
|
|
1955
|
+
variant: "h4"
|
|
1956
|
+
}, props.amount))))));
|
|
1820
1957
|
}
|
|
1821
1958
|
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1959
|
+
const Container$4 = /*#__PURE__*/styled('div', {
|
|
1960
|
+
display: 'flex',
|
|
1961
|
+
alignItems: 'center',
|
|
1962
|
+
justifyContent: 'space-between',
|
|
1963
|
+
padding: '$8',
|
|
1964
|
+
borderRadius: '$5',
|
|
1965
|
+
backgroundColor: '$neutrals300',
|
|
1966
|
+
color: '$neutrals800',
|
|
1967
|
+
fontSize: '$12',
|
|
1968
|
+
'.routes': {
|
|
1969
|
+
display: 'flex',
|
|
1970
|
+
alignItems: 'center'
|
|
1971
|
+
},
|
|
1972
|
+
'.fee': {
|
|
1973
|
+
display: 'flex',
|
|
1974
|
+
alignItems: 'center'
|
|
1975
|
+
}
|
|
1976
|
+
});
|
|
1977
|
+
function RoutesOverview(props) {
|
|
1978
|
+
if (!props.routes) return null;
|
|
1979
|
+
const swaps = props.routes.result?.swaps;
|
|
1980
|
+
return React.createElement(Container$4, null, React.createElement("div", {
|
|
1981
|
+
className: "routes"
|
|
1982
|
+
}, swaps?.map((swap, idx) => {
|
|
1983
|
+
const isLast = idx + 1 == swaps.length;
|
|
1984
|
+
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
1985
|
+
className: "route"
|
|
1986
|
+
}, swap.from.symbol), React.createElement(ChevronRightIcon, {
|
|
1987
|
+
size: 12
|
|
1988
|
+
}), isLast ? React.createElement("div", {
|
|
1989
|
+
className: "route"
|
|
1990
|
+
}, swap.to.symbol) : null);
|
|
1991
|
+
})), props.totalFee ? React.createElement("div", {
|
|
1992
|
+
className: "fee"
|
|
1993
|
+
}, React.createElement(GasIcon, {
|
|
1994
|
+
size: 12
|
|
1995
|
+
}), React.createElement(Spacer, {
|
|
1996
|
+
size: 4
|
|
1997
|
+
}), "$", props.totalFee) : null);
|
|
1850
1998
|
}
|
|
1851
1999
|
|
|
2000
|
+
var ConfirmSwapErrorTypes;
|
|
2001
|
+
(function (ConfirmSwapErrorTypes) {
|
|
2002
|
+
ConfirmSwapErrorTypes[ConfirmSwapErrorTypes["NO_ROUTE"] = 0] = "NO_ROUTE";
|
|
2003
|
+
ConfirmSwapErrorTypes[ConfirmSwapErrorTypes["ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS"] = 1] = "ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS";
|
|
2004
|
+
ConfirmSwapErrorTypes[ConfirmSwapErrorTypes["REQUEST_FAILED"] = 2] = "REQUEST_FAILED";
|
|
2005
|
+
ConfirmSwapErrorTypes[ConfirmSwapErrorTypes["INSUFFICIENT_SLIPPAGE"] = 3] = "INSUFFICIENT_SLIPPAGE";
|
|
2006
|
+
})(ConfirmSwapErrorTypes || (ConfirmSwapErrorTypes = {}));
|
|
2007
|
+
var ConfirmSwapWarningTypes;
|
|
2008
|
+
(function (ConfirmSwapWarningTypes) {
|
|
2009
|
+
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["ROUTE_UPDATED"] = 0] = "ROUTE_UPDATED";
|
|
2010
|
+
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["ROUTE_SWAPPERS_UPDATED"] = 1] = "ROUTE_SWAPPERS_UPDATED";
|
|
2011
|
+
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["ROUTE_COINS_UPDATED"] = 2] = "ROUTE_COINS_UPDATED";
|
|
2012
|
+
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["ROUTE_AND_OUTPUT_AMOUNT_UPDATED"] = 3] = "ROUTE_AND_OUTPUT_AMOUNT_UPDATED";
|
|
2013
|
+
ConfirmSwapWarningTypes[ConfirmSwapWarningTypes["INSUFFICIENT_BALANCE"] = 4] = "INSUFFICIENT_BALANCE";
|
|
2014
|
+
})(ConfirmSwapWarningTypes || (ConfirmSwapWarningTypes = {}));
|
|
2015
|
+
|
|
1852
2016
|
function useConfirmSwap() {
|
|
1853
2017
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
1854
2018
|
const toToken = useBestRouteStore.use.toToken();
|
|
@@ -1889,6 +2053,7 @@ function useConfirmSwap() {
|
|
|
1889
2053
|
proceedAnywayRef.current = false;
|
|
1890
2054
|
if (confiremedRouteRef.current) {
|
|
1891
2055
|
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2056
|
+
//@ts-ignore
|
|
1892
2057
|
return newSwap;
|
|
1893
2058
|
}
|
|
1894
2059
|
return;
|
|
@@ -1951,6 +2116,7 @@ function useConfirmSwap() {
|
|
|
1951
2116
|
disabledSwappersGroups: disabledLiquiditySources
|
|
1952
2117
|
};
|
|
1953
2118
|
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2119
|
+
//@ts-ignore
|
|
1954
2120
|
return newSwap;
|
|
1955
2121
|
} else if (!proceedAnywayRef.current) {
|
|
1956
2122
|
proceedAnywayRef.current = true;
|
|
@@ -1980,66 +2146,266 @@ function useConfirmSwap() {
|
|
|
1980
2146
|
};
|
|
1981
2147
|
}
|
|
1982
2148
|
|
|
1983
|
-
function
|
|
1984
|
-
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
1985
|
-
const {
|
|
1986
|
-
navigateBackFrom
|
|
1987
|
-
} = useNavigateBack();
|
|
1988
|
-
const {
|
|
1989
|
-
manager
|
|
1990
|
-
} = useManager();
|
|
2149
|
+
function ChangeSlippageButton() {
|
|
1991
2150
|
const navigate = useNavigate();
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
const customSlippage = useSettingsStore.use.customSlippage();
|
|
1999
|
-
const selectedSlippage = customSlippage || slippage;
|
|
2000
|
-
const {
|
|
2001
|
-
loading,
|
|
2002
|
-
errors,
|
|
2003
|
-
warnings,
|
|
2004
|
-
confirmSwap
|
|
2005
|
-
} = useConfirmSwap();
|
|
2006
|
-
const showHighSlippageWarning = !errors.find(error => error.type === ConfirmSwapErrorTypes.INSUFFICIENT_SLIPPAGE);
|
|
2007
|
-
return React.createElement(ConfirmSwap, {
|
|
2008
|
-
onConfirm: () => {
|
|
2009
|
-
confirmSwap?.().then(swap => {
|
|
2010
|
-
if (swap) {
|
|
2011
|
-
manager?.create('swap', {
|
|
2012
|
-
swapDetails: swap
|
|
2013
|
-
}, {
|
|
2014
|
-
id: swap.requestId
|
|
2015
|
-
});
|
|
2016
|
-
setSelectedSwap(swap.requestId);
|
|
2017
|
-
navigate(navigationRoutes.swaps + `/${swap.requestId}`, {
|
|
2018
|
-
replace: true
|
|
2019
|
-
});
|
|
2020
|
-
}
|
|
2021
|
-
});
|
|
2022
|
-
},
|
|
2023
|
-
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
2024
|
-
bestRoute: getBestRouteWithCalculatedFees(bestRoute, tokens),
|
|
2025
|
-
loading: loading,
|
|
2026
|
-
errors: ConfirmSwapErrors(errors),
|
|
2027
|
-
warnings: ConfirmSwapWarnings(warnings),
|
|
2028
|
-
extraMessages: showHighSlippageWarning && React.createElement(ConfirmSwapExtraMessages, {
|
|
2029
|
-
selectedSlippage: selectedSlippage
|
|
2030
|
-
}),
|
|
2031
|
-
confirmButtonTitle: warnings.length > 0 || errors.length > 0 ? 'Proceed anyway!' : 'Confirm swap!',
|
|
2032
|
-
confirmButtonDisabled: fetchingBestRoute
|
|
2033
|
-
});
|
|
2151
|
+
return React.createElement(Button, {
|
|
2152
|
+
type: "primary",
|
|
2153
|
+
variant: "outlined",
|
|
2154
|
+
size: "small",
|
|
2155
|
+
onClick: () => navigate(navigationRoutes.settings)
|
|
2156
|
+
}, "Change Slippage");
|
|
2034
2157
|
}
|
|
2035
2158
|
|
|
2036
|
-
const
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2159
|
+
const StyledMessage = /*#__PURE__*/styled(Typography, {
|
|
2160
|
+
color: '$error500 !important'
|
|
2161
|
+
});
|
|
2162
|
+
function MinRequiredSlippage(_ref) {
|
|
2163
|
+
let {
|
|
2164
|
+
minRequiredSlippage
|
|
2165
|
+
} = _ref;
|
|
2166
|
+
return React.createElement(StyledMessage, {
|
|
2167
|
+
variant: "body2"
|
|
2168
|
+
}, "We recommend you to increase slippage to at least \u00A0", minRequiredSlippage, "\u00A0 for this route.", React.createElement(Spacer, {
|
|
2169
|
+
size: 8,
|
|
2170
|
+
direction: "vertical"
|
|
2171
|
+
}), React.createElement(ChangeSlippageButton, null));
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
function ConfirmSwapErrors(errors) {
|
|
2175
|
+
return errors.flatMap(error => {
|
|
2176
|
+
switch (error.type) {
|
|
2177
|
+
case ConfirmSwapErrorTypes.NO_ROUTE:
|
|
2178
|
+
return React.createElement(Typography, {
|
|
2179
|
+
variant: "body2"
|
|
2180
|
+
}, "No routes found. Please try again later.");
|
|
2181
|
+
case ConfirmSwapErrorTypes.REQUEST_FAILED:
|
|
2182
|
+
return React.createElement(Typography, {
|
|
2183
|
+
variant: "body2"
|
|
2184
|
+
}, `Failed to confirm swap ${error.status ? `'status': ${error.status})` : ''}, please try again.`);
|
|
2185
|
+
case ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS:
|
|
2186
|
+
return React.createElement(Typography, {
|
|
2187
|
+
variant: "body2"
|
|
2188
|
+
}, "Route updated and price impact is too high, try again later!");
|
|
2189
|
+
case ConfirmSwapErrorTypes.INSUFFICIENT_SLIPPAGE:
|
|
2190
|
+
return React.createElement(MinRequiredSlippage, {
|
|
2191
|
+
minRequiredSlippage: error.minRequiredSlippage
|
|
2192
|
+
});
|
|
2193
|
+
default:
|
|
2194
|
+
return [];
|
|
2195
|
+
}
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
const List = /*#__PURE__*/styled('ul', {
|
|
2200
|
+
variants: {
|
|
2201
|
+
showListStyle: {
|
|
2202
|
+
true: {
|
|
2203
|
+
paddingLeft: '$24'
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
}
|
|
2207
|
+
});
|
|
2208
|
+
const ListItem = /*#__PURE__*/styled('li', {
|
|
2209
|
+
variants: {
|
|
2210
|
+
showListStyle: {
|
|
2211
|
+
true: {
|
|
2212
|
+
listStyleType: 'disc',
|
|
2213
|
+
listStylePosition: 'outside'
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
2216
|
+
}
|
|
2217
|
+
});
|
|
2218
|
+
const Message = /*#__PURE__*/styled(Typography, {
|
|
2219
|
+
display: 'block',
|
|
2220
|
+
color: '$warning500 !important'
|
|
2221
|
+
});
|
|
2222
|
+
function BalanceWarnings(_ref) {
|
|
2223
|
+
let {
|
|
2224
|
+
messages
|
|
2225
|
+
} = _ref;
|
|
2226
|
+
const showListStyle = messages.length > 1;
|
|
2227
|
+
return React.createElement(List, {
|
|
2228
|
+
showListStyle: showListStyle
|
|
2229
|
+
}, messages.map(warning => React.createElement(ListItem, {
|
|
2230
|
+
showListStyle: showListStyle
|
|
2231
|
+
}, React.createElement(Message, {
|
|
2232
|
+
variant: "body2"
|
|
2233
|
+
}, warning))));
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
function ConfirmSwapWarnings(warnings) {
|
|
2237
|
+
return warnings.flatMap(warning => {
|
|
2238
|
+
switch (warning.type) {
|
|
2239
|
+
case ConfirmSwapWarningTypes.ROUTE_UPDATED:
|
|
2240
|
+
return React.createElement(Typography, {
|
|
2241
|
+
variant: "body2"
|
|
2242
|
+
}, "Route has been updated.");
|
|
2243
|
+
case ConfirmSwapWarningTypes.ROUTE_AND_OUTPUT_AMOUNT_UPDATED:
|
|
2244
|
+
return React.createElement(Typography, {
|
|
2245
|
+
variant: "body2"
|
|
2246
|
+
}, `Output amount changed to ${warning.newOutputAmount}
|
|
2247
|
+
(${warning.percentageChange}% change).`);
|
|
2248
|
+
case ConfirmSwapWarningTypes.ROUTE_SWAPPERS_UPDATED:
|
|
2249
|
+
return React.createElement(Typography, {
|
|
2250
|
+
variant: "body2"
|
|
2251
|
+
}, "Route swappers has been updated.");
|
|
2252
|
+
case ConfirmSwapWarningTypes.ROUTE_COINS_UPDATED:
|
|
2253
|
+
return React.createElement(Typography, {
|
|
2254
|
+
variant: "body2"
|
|
2255
|
+
}, "Route internal coins has been updated.");
|
|
2256
|
+
case ConfirmSwapWarningTypes.INSUFFICIENT_BALANCE:
|
|
2257
|
+
return React.createElement(BalanceWarnings, {
|
|
2258
|
+
messages: warning.messages
|
|
2259
|
+
});
|
|
2260
|
+
default:
|
|
2261
|
+
return [];
|
|
2262
|
+
}
|
|
2263
|
+
});
|
|
2264
|
+
}
|
|
2265
|
+
|
|
2266
|
+
function HighSlippageWarning(props) {
|
|
2267
|
+
const {
|
|
2268
|
+
selectedSlippage
|
|
2269
|
+
} = props;
|
|
2270
|
+
return React.createElement(Alert, {
|
|
2271
|
+
type: "warning",
|
|
2272
|
+
footer: React.createElement(ChangeSlippageButton, null)
|
|
2273
|
+
}, "Caution, your slippage is high (=", selectedSlippage, "). Your trade may be front run.");
|
|
2274
|
+
}
|
|
2275
|
+
|
|
2276
|
+
function ConfirmSwapExtraMessages(props) {
|
|
2277
|
+
const {
|
|
2278
|
+
selectedSlippage
|
|
2279
|
+
} = props;
|
|
2280
|
+
const highSlippage = selectedSlippage >= HIGH_SLIPPAGE;
|
|
2281
|
+
return React.createElement(React.Fragment, null, highSlippage && React.createElement(HighSlippageWarning, {
|
|
2282
|
+
selectedSlippage: selectedSlippage
|
|
2283
|
+
}));
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
function ConfirmSwapPage() {
|
|
2287
|
+
const navigate = useNavigate();
|
|
2288
|
+
const {
|
|
2289
|
+
navigateBackFrom
|
|
2290
|
+
} = useNavigateBack();
|
|
2291
|
+
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
2292
|
+
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
2293
|
+
const fetchingBestRouteError = useBestRouteStore.use.error();
|
|
2294
|
+
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
2295
|
+
const {
|
|
2296
|
+
blockchains,
|
|
2297
|
+
tokens
|
|
2298
|
+
} = useMetaStore.use.meta();
|
|
2299
|
+
const accounts = useWalletsStore.use.accounts();
|
|
2300
|
+
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
2301
|
+
const initSelectedWallets = useWalletsStore.use.initSelectedWallets();
|
|
2302
|
+
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
2303
|
+
const slippage = useSettingsStore.use.slippage();
|
|
2304
|
+
const customSlippage = useSettingsStore.use.customSlippage();
|
|
2305
|
+
const bestRouteloadingStatus = getBestRouteStatus(fetchingBestRoute, !!fetchingBestRouteError);
|
|
2306
|
+
const {
|
|
2307
|
+
manager
|
|
2308
|
+
} = useManager();
|
|
2309
|
+
const {
|
|
2310
|
+
loading,
|
|
2311
|
+
errors,
|
|
2312
|
+
warnings,
|
|
2313
|
+
confirmSwap
|
|
2314
|
+
} = useConfirmSwap();
|
|
2315
|
+
const selectedSlippage = customSlippage || slippage;
|
|
2316
|
+
const showHighSlippageWarning = !errors.find(error => error.type === ConfirmSwapErrorTypes.INSUFFICIENT_SLIPPAGE);
|
|
2317
|
+
const {
|
|
2318
|
+
getWalletInfo,
|
|
2319
|
+
connect
|
|
2320
|
+
} = useWallets();
|
|
2321
|
+
const confirmDisabled = fetchingBestRoute || !requiredWallets(bestRoute).every(chain => selectedWallets.map(wallet => wallet.chain).includes(chain));
|
|
2322
|
+
const firstStep = bestRoute?.result?.swaps[0];
|
|
2323
|
+
const lastStep = bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1];
|
|
2324
|
+
const fromAmount = decimalNumber(firstStep?.fromAmount, 3);
|
|
2325
|
+
const toAmount = decimalNumber(lastStep?.toAmount, 3);
|
|
2326
|
+
useEffect(() => {
|
|
2327
|
+
initSelectedWallets();
|
|
2328
|
+
}, []);
|
|
2329
|
+
const selectableWallets = getSelectableWallets(accounts, selectedWallets, getWalletInfo);
|
|
2330
|
+
const handleConnectChain = wallet => {
|
|
2331
|
+
const network = wallet;
|
|
2332
|
+
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
2333
|
+
};
|
|
2334
|
+
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
2335
|
+
return React.createElement(ConfirmSwap, {
|
|
2336
|
+
requiredWallets: getRequiredChains(bestRoute),
|
|
2337
|
+
selectableWallets: selectableWallets,
|
|
2338
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
2339
|
+
onConfirm: () => {
|
|
2340
|
+
confirmSwap?.().then(swap => {
|
|
2341
|
+
if (swap) {
|
|
2342
|
+
manager?.create('swap', {
|
|
2343
|
+
swapDetails: swap
|
|
2344
|
+
}, {
|
|
2345
|
+
id: swap.requestId
|
|
2346
|
+
});
|
|
2347
|
+
setSelectedSwap(swap.requestId);
|
|
2348
|
+
navigate(navigationRoutes.swaps + `/${swap.requestId}`, {
|
|
2349
|
+
replace: true
|
|
2350
|
+
});
|
|
2351
|
+
}
|
|
2352
|
+
});
|
|
2353
|
+
},
|
|
2354
|
+
onChange: wallet => setSelectedWallet(wallet),
|
|
2355
|
+
confirmDisabled: confirmDisabled,
|
|
2356
|
+
handleConnectChain: wallet => handleConnectChain(wallet),
|
|
2357
|
+
isExperimentalChain: wallet => getKeplrCompatibleConnectedWallets(selectableWallets).length > 0 ? isExperimentalChain(blockchains, wallet) : false,
|
|
2358
|
+
previewInputs: React.createElement(React.Fragment, null, React.createElement(TokenPreview, {
|
|
2359
|
+
chain: {
|
|
2360
|
+
displayName: firstStep?.from.blockchain || '',
|
|
2361
|
+
logo: firstStep?.from.blockchainLogo || ''
|
|
2362
|
+
},
|
|
2363
|
+
token: {
|
|
2364
|
+
symbol: firstStep?.from.symbol || '',
|
|
2365
|
+
image: firstStep?.from.logo || ''
|
|
2366
|
+
},
|
|
2367
|
+
usdValue: calcOutputUsdValue(fromAmount, firstStep?.from.usdPrice),
|
|
2368
|
+
amount: fromAmount,
|
|
2369
|
+
label: t('From'),
|
|
2370
|
+
loadingStatus: bestRouteloadingStatus
|
|
2371
|
+
}), React.createElement(Spacer, {
|
|
2372
|
+
size: 12,
|
|
2373
|
+
direction: "vertical"
|
|
2374
|
+
}), React.createElement(TokenPreview, {
|
|
2375
|
+
chain: {
|
|
2376
|
+
displayName: lastStep?.to.blockchain || '',
|
|
2377
|
+
logo: lastStep?.to.blockchainLogo || ''
|
|
2378
|
+
},
|
|
2379
|
+
token: {
|
|
2380
|
+
symbol: lastStep?.to.symbol || '',
|
|
2381
|
+
image: lastStep?.to.logo || ''
|
|
2382
|
+
},
|
|
2383
|
+
usdValue: calcOutputUsdValue(toAmount, lastStep?.to.usdPrice),
|
|
2384
|
+
amount: toAmount,
|
|
2385
|
+
label: t('To'),
|
|
2386
|
+
loadingStatus: bestRouteloadingStatus
|
|
2387
|
+
})),
|
|
2388
|
+
previewRoutes: React.createElement(RoutesOverview, {
|
|
2389
|
+
routes: bestRoute,
|
|
2390
|
+
totalFee: numberToString(totalFeeInUsd, 0, 2)
|
|
2391
|
+
}),
|
|
2392
|
+
loading: loading,
|
|
2393
|
+
errors: ConfirmSwapErrors(errors),
|
|
2394
|
+
warnings: ConfirmSwapWarnings(warnings),
|
|
2395
|
+
extraMessages: showHighSlippageWarning && React.createElement(ConfirmSwapExtraMessages, {
|
|
2396
|
+
selectedSlippage: selectedSlippage
|
|
2397
|
+
}),
|
|
2398
|
+
confirmButtonTitle: warnings.length > 0 || errors.length > 0 ? 'Proceed anyway!' : 'Confirm swap!'
|
|
2399
|
+
});
|
|
2400
|
+
}
|
|
2401
|
+
|
|
2402
|
+
const getPendingSwaps = manager => {
|
|
2403
|
+
const result = [];
|
|
2404
|
+
manager?.getAll().forEach((q, id) => {
|
|
2405
|
+
const storage = q.list.getStorage();
|
|
2406
|
+
if (storage?.swapDetails) {
|
|
2407
|
+
result.push({
|
|
2408
|
+
id,
|
|
2043
2409
|
swap: storage?.swapDetails
|
|
2044
2410
|
});
|
|
2045
2411
|
}
|
|
@@ -2047,6 +2413,31 @@ const getPendingSwaps = manager => {
|
|
|
2047
2413
|
return result.sort((a, b) => Number(b.swap.creationTime) - Number(a.swap.creationTime));
|
|
2048
2414
|
};
|
|
2049
2415
|
|
|
2416
|
+
const groupSwapsByDate = swaps => {
|
|
2417
|
+
const output = new Map([['today', {
|
|
2418
|
+
title: 'Today',
|
|
2419
|
+
swaps: []
|
|
2420
|
+
}], ['week', {
|
|
2421
|
+
title: 'This week',
|
|
2422
|
+
swaps: []
|
|
2423
|
+
}], ['month', {
|
|
2424
|
+
title: 'This month',
|
|
2425
|
+
swaps: []
|
|
2426
|
+
}], ['year', {
|
|
2427
|
+
title: 'This year',
|
|
2428
|
+
swaps: []
|
|
2429
|
+
}], ['history', {
|
|
2430
|
+
title: 'History',
|
|
2431
|
+
swaps: []
|
|
2432
|
+
}]]);
|
|
2433
|
+
const now = dayjs();
|
|
2434
|
+
swaps.forEach(swap => {
|
|
2435
|
+
const swapDate = dayjs(Number(swap.creationTime));
|
|
2436
|
+
if (now.isSame(swapDate, 'day')) output.get('today')?.swaps.push(swap);else if (now.isSame(swapDate, 'week')) output.get('week')?.swaps.push(swap);else if (now.isSame(swapDate, 'month')) output.get('month')?.swaps.push(swap);else if (now.isSame(swapDate, 'year')) output.get('year')?.swaps.push(swap);else output.get('history')?.swaps.push(swap);
|
|
2437
|
+
});
|
|
2438
|
+
return Array.from(output.values());
|
|
2439
|
+
};
|
|
2440
|
+
|
|
2050
2441
|
function HistoryPage() {
|
|
2051
2442
|
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
2052
2443
|
const navigate = useNavigate();
|
|
@@ -2062,16 +2453,14 @@ function HistoryPage() {
|
|
|
2062
2453
|
} = _ref;
|
|
2063
2454
|
return swap;
|
|
2064
2455
|
});
|
|
2065
|
-
return React.createElement(History
|
|
2066
|
-
//todo: move PendingSwap type to rango-types
|
|
2067
|
-
//@ts-ignore
|
|
2068
|
-
, {
|
|
2069
|
-
//todo: move PendingSwap type to rango-types
|
|
2070
|
-
//@ts-ignore
|
|
2456
|
+
return React.createElement(History, {
|
|
2071
2457
|
list: pendingSwaps,
|
|
2458
|
+
groupBy: groupSwapsByDate,
|
|
2072
2459
|
onSwapClick: requestId => {
|
|
2073
2460
|
setSelectedSwap(requestId);
|
|
2074
|
-
navigate(navigationRoutes.swaps + `/${requestId}
|
|
2461
|
+
navigate(navigationRoutes.swaps + `/${requestId}`, {
|
|
2462
|
+
replace: true
|
|
2463
|
+
});
|
|
2075
2464
|
},
|
|
2076
2465
|
onBack: navigateBackFrom.bind(null, navigationRoutes.swaps)
|
|
2077
2466
|
});
|
|
@@ -2082,6 +2471,7 @@ function LiquiditySourcePage(_ref) {
|
|
|
2082
2471
|
supportedSwappers
|
|
2083
2472
|
} = _ref;
|
|
2084
2473
|
const swappers = useMetaStore.use.meta().swappers;
|
|
2474
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2085
2475
|
const toggleLiquiditySource = useSettingsStore.use.toggleLiquiditySource();
|
|
2086
2476
|
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
2087
2477
|
const toggleAllLiquiditySources = useSettingsStore.use.toggleAllLiquiditySources();
|
|
@@ -2107,7 +2497,8 @@ function LiquiditySourcePage(_ref) {
|
|
|
2107
2497
|
toggleAll: toggleAllLiquiditySources,
|
|
2108
2498
|
list: supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups,
|
|
2109
2499
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
2110
|
-
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources)
|
|
2500
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources),
|
|
2501
|
+
loadingStatus: loadingMetaStatus
|
|
2111
2502
|
});
|
|
2112
2503
|
}
|
|
2113
2504
|
|
|
@@ -2150,403 +2541,168 @@ function SelectTokenPage(props) {
|
|
|
2150
2541
|
const destinationTokens = useBestRouteStore.use.destinationTokens();
|
|
2151
2542
|
const supportedSourceTokens = supportedTokens === 'all' ? sourceTokens : sourceTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token)));
|
|
2152
2543
|
const supportedDestinationTokens = supportedTokens === 'all' ? destinationTokens : destinationTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token)));
|
|
2153
|
-
console.log(supportedSourceTokens);
|
|
2154
2544
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
2155
2545
|
const toToken = useBestRouteStore.use.toToken();
|
|
2156
2546
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
2157
2547
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
2548
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2158
2549
|
return React.createElement(TokenSelector, {
|
|
2159
2550
|
type: type === 'from' ? 'Source' : 'Destination',
|
|
2160
2551
|
list: type == 'from' ? supportedSourceTokens : supportedDestinationTokens,
|
|
2161
2552
|
selected: type === 'from' ? fromToken : toToken,
|
|
2162
2553
|
onChange: token => {
|
|
2163
|
-
if (type === 'from') setFromToken(token);else setToToken(token);
|
|
2164
|
-
navigateBackFrom(navigationRoutes.fromToken);
|
|
2165
|
-
},
|
|
2166
|
-
onBack: navigateBackFrom.bind(null, navigationRoutes.fromToken)
|
|
2167
|
-
|
|
2168
|
-
}
|
|
2169
|
-
|
|
2170
|
-
function SettingsPage(_ref) {
|
|
2171
|
-
let {
|
|
2172
|
-
supportedSwappers
|
|
2173
|
-
} = _ref;
|
|
2174
|
-
const slippage = useSettingsStore.use.slippage();
|
|
2175
|
-
const setSlippage = useSettingsStore.use.setSlippage();
|
|
2176
|
-
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
2177
|
-
const customSlippage = useSettingsStore.use.customSlippage();
|
|
2178
|
-
const setCustomSlippage = useSettingsStore.use.setCustomSlippage();
|
|
2179
|
-
const theme = useSettingsStore.use.theme();
|
|
2180
|
-
const setTheme = useSettingsStore.use.setTheme();
|
|
2181
|
-
const swappers = useMetaStore.use.meta().swappers;
|
|
2182
|
-
const navigate = useNavigate();
|
|
2183
|
-
const {
|
|
2184
|
-
navigateBackFrom
|
|
2185
|
-
} = useNavigateBack();
|
|
2186
|
-
const infiniteApprove = useSettingsStore.use.infiniteApprove();
|
|
2187
|
-
const toggleInfiniteApprove = useSettingsStore.use.toggleInfiniteApprove();
|
|
2188
|
-
const uniqueSwappersGroups = [];
|
|
2189
|
-
removeDuplicateFrom(swappers.map(s => s.swapperGroup)).map(swapperGroup => {
|
|
2190
|
-
return swappers.find(s => s.swapperGroup === swapperGroup);
|
|
2191
|
-
}).find(s => {
|
|
2192
|
-
if (s) {
|
|
2193
|
-
for (const type of s.types) {
|
|
2194
|
-
uniqueSwappersGroups.push({
|
|
2195
|
-
title: s.swapperGroup,
|
|
2196
|
-
logo: s.logo,
|
|
2197
|
-
type,
|
|
2198
|
-
selected: !disabledLiquiditySources.includes(s.swapperGroup)
|
|
2199
|
-
});
|
|
2200
|
-
}
|
|
2201
|
-
}
|
|
2202
|
-
});
|
|
2203
|
-
supportedSwappers !== 'all' && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0);
|
|
2204
|
-
const supportedUniqueSwappersGroups = supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups;
|
|
2205
|
-
return React.createElement(Settings, {
|
|
2206
|
-
slippages: SLIPPAGES,
|
|
2207
|
-
selectedSlippage: slippage,
|
|
2208
|
-
onSlippageChange: slippage => setSlippage(slippage),
|
|
2209
|
-
onLiquiditySourcesClick: () => navigate(navigationRoutes.liquiditySources),
|
|
2210
|
-
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
2211
|
-
liquiditySources: supportedUniqueSwappersGroups,
|
|
2212
|
-
selectedLiquiditySources: supportedUniqueSwappersGroups.filter(s => s.selected),
|
|
2213
|
-
customSlippage: customSlippage || NaN,
|
|
2214
|
-
onCustomSlippageChange: setCustomSlippage,
|
|
2215
|
-
minSlippage: MIN_SLIPPGAE,
|
|
2216
|
-
maxSlippage: MAX_SLIPPAGE,
|
|
2217
|
-
selectedTheme: theme,
|
|
2218
|
-
onThemeChange: setTheme,
|
|
2219
|
-
infiniteApprove: infiniteApprove,
|
|
2220
|
-
toggleInfiniteApprove: toggleInfiniteApprove
|
|
2221
|
-
});
|
|
2222
|
-
}
|
|
2223
|
-
|
|
2224
|
-
const ListContainer = /*#__PURE__*/styled('div', {
|
|
2225
|
-
display: 'grid',
|
|
2226
|
-
gap: '.5rem',
|
|
2227
|
-
gridTemplateColumns: ' repeat(2, minmax(0, 1fr))',
|
|
2228
|
-
height: '450px',
|
|
2229
|
-
alignContent: 'baseline',
|
|
2230
|
-
padding: '0.5rem'
|
|
2231
|
-
});
|
|
2232
|
-
const AlertContainer = /*#__PURE__*/styled('div', {
|
|
2233
|
-
paddingBottom: '$16'
|
|
2234
|
-
});
|
|
2235
|
-
function WalletsPage(_ref) {
|
|
2236
|
-
let {
|
|
2237
|
-
supportedWallets,
|
|
2238
|
-
multiWallets
|
|
2239
|
-
} = _ref;
|
|
2240
|
-
const {
|
|
2241
|
-
navigateBackFrom
|
|
2242
|
-
} = useNavigateBack();
|
|
2243
|
-
const {
|
|
2244
|
-
state,
|
|
2245
|
-
disconnect,
|
|
2246
|
-
getWalletInfo,
|
|
2247
|
-
connect
|
|
2248
|
-
} = useWallets();
|
|
2249
|
-
const wallets = getlistWallet(state, getWalletInfo, supportedWallets === 'all' ? Object.values(WalletType) : supportedWallets);
|
|
2250
|
-
const walletsRef = useRef();
|
|
2251
|
-
let sortedWallets = detectMobileScreens() ? wallets.filter(wallet => wallet.showOnMobile) : wallets;
|
|
2252
|
-
sortedWallets = sortWalletsBasedOnState(sortedWallets);
|
|
2253
|
-
const [walletErrorMessage, setWalletErrorMessage] = useState('');
|
|
2254
|
-
const toggleConnectWalletsButton = useUiStore.use.toggleConnectWalletsButton();
|
|
2255
|
-
const {
|
|
2256
|
-
t
|
|
2257
|
-
} = useTranslation();
|
|
2258
|
-
const onSelectWallet = async type => {
|
|
2259
|
-
const wallet = state(type);
|
|
2260
|
-
try {
|
|
2261
|
-
if (walletErrorMessage) setWalletErrorMessage('');
|
|
2262
|
-
if (wallet.connected) {
|
|
2263
|
-
await disconnect(type);
|
|
2264
|
-
} else {
|
|
2265
|
-
if (!multiWallets && !!wallets.find(w => w.state === WalletState.CONNECTED)) {
|
|
2266
|
-
return;
|
|
2267
|
-
}
|
|
2268
|
-
await connect(type);
|
|
2269
|
-
}
|
|
2270
|
-
} catch (e) {
|
|
2271
|
-
setWalletErrorMessage('Error: ' + e?.message);
|
|
2272
|
-
}
|
|
2273
|
-
};
|
|
2274
|
-
const disconnectConnectingWallets = () => {
|
|
2275
|
-
const connectingWallets = walletsRef.current?.filter(wallet => wallet.state === WalletState.CONNECTING) || [];
|
|
2276
|
-
for (const wallet of connectingWallets) {
|
|
2277
|
-
disconnect(wallet.type);
|
|
2278
|
-
}
|
|
2279
|
-
};
|
|
2280
|
-
useEffect(() => {
|
|
2281
|
-
toggleConnectWalletsButton();
|
|
2282
|
-
return () => {
|
|
2283
|
-
disconnectConnectingWallets();
|
|
2284
|
-
toggleConnectWalletsButton();
|
|
2285
|
-
};
|
|
2286
|
-
}, []);
|
|
2287
|
-
useEffect(() => {
|
|
2288
|
-
walletsRef.current = wallets;
|
|
2289
|
-
}, [wallets]);
|
|
2290
|
-
return React.createElement(SecondaryPage, {
|
|
2291
|
-
title: t('Select Wallet') || '',
|
|
2292
|
-
textField: false,
|
|
2293
|
-
onBack: navigateBackFrom.bind(null, navigationRoutes.wallets)
|
|
2294
|
-
}, React.createElement(React.Fragment, null, walletErrorMessage && React.createElement(AlertContainer, null, React.createElement(Alert, {
|
|
2295
|
-
type: "error"
|
|
2296
|
-
}, walletErrorMessage)), React.createElement(ListContainer, null, sortedWallets.map((wallet, index) => React.createElement(Wallet, Object.assign({}, wallet, {
|
|
2297
|
-
key: `${index}-${wallet.type}`,
|
|
2298
|
-
onClick: onSelectWallet
|
|
2299
|
-
}))))));
|
|
2300
|
-
}
|
|
2301
|
-
|
|
2302
|
-
const Box$1 = /*#__PURE__*/styled('div', {
|
|
2303
|
-
display: 'flex',
|
|
2304
|
-
flexDirection: 'column',
|
|
2305
|
-
width: '100%'
|
|
2306
|
-
});
|
|
2307
|
-
const Container$3 = /*#__PURE__*/styled('div', {
|
|
2308
|
-
boxSizing: 'border-box',
|
|
2309
|
-
borderRadius: '$5',
|
|
2310
|
-
padding: '$8 $16 $16 $16',
|
|
2311
|
-
variants: {
|
|
2312
|
-
type: {
|
|
2313
|
-
filled: {
|
|
2314
|
-
backgroundColor: '$neutrals300'
|
|
2315
|
-
},
|
|
2316
|
-
outlined: {
|
|
2317
|
-
border: '1px solid $neutrals300'
|
|
2318
|
-
}
|
|
2319
|
-
}
|
|
2320
|
-
},
|
|
2321
|
-
defaultVariants: {
|
|
2322
|
-
type: 'filled'
|
|
2323
|
-
},
|
|
2324
|
-
'.head': {
|
|
2325
|
-
display: 'flex',
|
|
2326
|
-
justifyContent: 'space-between',
|
|
2327
|
-
alignItems: 'center',
|
|
2328
|
-
minHeight: '32px'
|
|
2329
|
-
},
|
|
2330
|
-
'.form': {
|
|
2331
|
-
display: 'flex',
|
|
2332
|
-
width: '100%',
|
|
2333
|
-
padding: '$2 0',
|
|
2334
|
-
'.selectors': {
|
|
2335
|
-
width: '35%',
|
|
2336
|
-
'._text': {
|
|
2337
|
-
whiteSpace: 'nowrap',
|
|
2338
|
-
overflow: 'hidden',
|
|
2339
|
-
textOverflow: 'ellipsis'
|
|
2340
|
-
}
|
|
2341
|
-
},
|
|
2342
|
-
'.amount': {
|
|
2343
|
-
width: '30%'
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
});
|
|
2347
|
-
const StyledImage$1 = /*#__PURE__*/styled('img', {
|
|
2348
|
-
width: '$24',
|
|
2349
|
-
maxHeight: '$24'
|
|
2350
|
-
});
|
|
2351
|
-
const ImagePlaceholder$1 = /*#__PURE__*/styled('span', {
|
|
2352
|
-
width: '24px',
|
|
2353
|
-
height: '24px',
|
|
2354
|
-
backgroundColor: '$neutrals300',
|
|
2355
|
-
borderRadius: '99999px'
|
|
2356
|
-
});
|
|
2357
|
-
const OutputContainer$1 = /*#__PURE__*/styled('div', {
|
|
2358
|
-
windth: '100%',
|
|
2359
|
-
height: '$48',
|
|
2360
|
-
borderRadius: '$5',
|
|
2361
|
-
backgroundColor: '$background',
|
|
2362
|
-
border: '1px solid transparent',
|
|
2363
|
-
position: 'relative',
|
|
2364
|
-
display: 'flex',
|
|
2365
|
-
alignItems: 'center',
|
|
2366
|
-
paddingLeft: '$8',
|
|
2367
|
-
paddingRight: '$8'
|
|
2368
|
-
});
|
|
2369
|
-
function TokenPreview(props) {
|
|
2370
|
-
const {
|
|
2371
|
-
chain,
|
|
2372
|
-
token,
|
|
2373
|
-
loadingStatus
|
|
2374
|
-
} = props;
|
|
2375
|
-
const {
|
|
2376
|
-
t
|
|
2377
|
-
} = useTranslation();
|
|
2378
|
-
const ItemSuffix = React.createElement("div", {
|
|
2379
|
-
style: {
|
|
2380
|
-
display: 'flex',
|
|
2381
|
-
justifyContent: 'center',
|
|
2382
|
-
alignItems: 'center'
|
|
2383
|
-
}
|
|
2384
|
-
}, loadingStatus === 'failed' && React.createElement(InfoCircleIcon, {
|
|
2385
|
-
color: "error",
|
|
2386
|
-
size: 24
|
|
2387
|
-
}));
|
|
2388
|
-
return React.createElement(Box$1, null, React.createElement(Container$3, {
|
|
2389
|
-
type: 'outlined'
|
|
2390
|
-
}, React.createElement("div", {
|
|
2391
|
-
className: "head"
|
|
2392
|
-
}, React.createElement(Typography, {
|
|
2393
|
-
variant: "body2",
|
|
2394
|
-
color: "neutrals800"
|
|
2395
|
-
}, props.label), React.createElement(Typography, {
|
|
2396
|
-
variant: "caption",
|
|
2397
|
-
color: "neutrals600"
|
|
2398
|
-
}, `$${numberToString(props.usdValue)}`)), React.createElement("div", {
|
|
2399
|
-
className: "form"
|
|
2400
|
-
}, React.createElement(Button, {
|
|
2401
|
-
className: "selectors",
|
|
2402
|
-
variant: "outlined",
|
|
2403
|
-
loading: loadingStatus === 'loading',
|
|
2404
|
-
prefix: loadingStatus === 'success' && chain ? React.createElement(StyledImage$1, {
|
|
2405
|
-
src: chain.logo
|
|
2406
|
-
}) : React.createElement(ImagePlaceholder$1, null),
|
|
2407
|
-
suffix: ItemSuffix,
|
|
2408
|
-
align: "start",
|
|
2409
|
-
size: "large"
|
|
2410
|
-
}, loadingStatus === 'success' && chain ? chain.displayName : t('Chain')), React.createElement(Spacer, {
|
|
2411
|
-
size: 12
|
|
2412
|
-
}), React.createElement(Button, {
|
|
2413
|
-
className: "selectors",
|
|
2414
|
-
variant: "outlined",
|
|
2415
|
-
loading: loadingStatus === 'loading',
|
|
2416
|
-
prefix: loadingStatus === 'success' && token ? React.createElement(StyledImage$1, {
|
|
2417
|
-
src: token.image
|
|
2418
|
-
}) : React.createElement(ImagePlaceholder$1, null),
|
|
2419
|
-
suffix: ItemSuffix,
|
|
2420
|
-
size: "large",
|
|
2421
|
-
align: "start"
|
|
2422
|
-
}, loadingStatus === 'success' && token ? token.symbol : t('Token')), React.createElement(Spacer, {
|
|
2423
|
-
size: 12
|
|
2424
|
-
}), React.createElement("div", {
|
|
2425
|
-
className: "amount"
|
|
2426
|
-
}, React.createElement(OutputContainer$1, null, React.createElement(Typography, {
|
|
2427
|
-
variant: "h4"
|
|
2428
|
-
}, props.amount))))));
|
|
2429
|
-
}
|
|
2430
|
-
|
|
2431
|
-
const Container$4 = /*#__PURE__*/styled('div', {
|
|
2432
|
-
display: 'flex',
|
|
2433
|
-
alignItems: 'center',
|
|
2434
|
-
justifyContent: 'space-between',
|
|
2435
|
-
padding: '$8',
|
|
2436
|
-
borderRadius: '$5',
|
|
2437
|
-
backgroundColor: '$neutrals300',
|
|
2438
|
-
color: '$neutrals800',
|
|
2439
|
-
fontSize: '$12',
|
|
2440
|
-
'.routes': {
|
|
2441
|
-
display: 'flex',
|
|
2442
|
-
alignItems: 'center'
|
|
2443
|
-
},
|
|
2444
|
-
'.fee': {
|
|
2445
|
-
display: 'flex',
|
|
2446
|
-
alignItems: 'center'
|
|
2447
|
-
}
|
|
2448
|
-
});
|
|
2449
|
-
function RoutesOverview(props) {
|
|
2450
|
-
if (!props.routes) return null;
|
|
2451
|
-
const swaps = props.routes.result?.swaps;
|
|
2452
|
-
return React.createElement(Container$4, null, React.createElement("div", {
|
|
2453
|
-
className: "routes"
|
|
2454
|
-
}, swaps?.map((swap, idx) => {
|
|
2455
|
-
const isLast = idx + 1 == swaps.length;
|
|
2456
|
-
return React.createElement(React.Fragment, null, React.createElement("div", {
|
|
2457
|
-
className: "route"
|
|
2458
|
-
}, swap.from.symbol), React.createElement(ChevronRightIcon, {
|
|
2459
|
-
size: 12
|
|
2460
|
-
}), isLast ? React.createElement("div", {
|
|
2461
|
-
className: "route"
|
|
2462
|
-
}, swap.to.symbol) : null);
|
|
2463
|
-
})), props.totalFee ? React.createElement("div", {
|
|
2464
|
-
className: "fee"
|
|
2465
|
-
}, React.createElement(GasIcon, {
|
|
2466
|
-
size: 12
|
|
2467
|
-
}), React.createElement(Spacer, {
|
|
2468
|
-
size: 4
|
|
2469
|
-
}), "$", props.totalFee) : null);
|
|
2554
|
+
if (type === 'from') setFromToken(token);else setToToken(token);
|
|
2555
|
+
navigateBackFrom(navigationRoutes.fromToken);
|
|
2556
|
+
},
|
|
2557
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.fromToken),
|
|
2558
|
+
loadingStatus: loadingMetaStatus
|
|
2559
|
+
});
|
|
2470
2560
|
}
|
|
2471
2561
|
|
|
2472
|
-
function
|
|
2562
|
+
function SettingsPage(_ref) {
|
|
2563
|
+
let {
|
|
2564
|
+
supportedSwappers
|
|
2565
|
+
} = _ref;
|
|
2566
|
+
const slippage = useSettingsStore.use.slippage();
|
|
2567
|
+
const setSlippage = useSettingsStore.use.setSlippage();
|
|
2568
|
+
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
2569
|
+
const customSlippage = useSettingsStore.use.customSlippage();
|
|
2570
|
+
const setCustomSlippage = useSettingsStore.use.setCustomSlippage();
|
|
2571
|
+
const theme = useSettingsStore.use.theme();
|
|
2572
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
2573
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
2473
2574
|
const navigate = useNavigate();
|
|
2474
2575
|
const {
|
|
2475
2576
|
navigateBackFrom
|
|
2476
2577
|
} = useNavigateBack();
|
|
2477
|
-
const
|
|
2578
|
+
const infiniteApprove = useSettingsStore.use.infiniteApprove();
|
|
2579
|
+
const toggleInfiniteApprove = useSettingsStore.use.toggleInfiniteApprove();
|
|
2580
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2581
|
+
const uniqueSwappersGroups = [];
|
|
2582
|
+
removeDuplicateFrom(swappers.map(s => s.swapperGroup)).map(swapperGroup => {
|
|
2583
|
+
return swappers.find(s => s.swapperGroup === swapperGroup);
|
|
2584
|
+
}).find(s => {
|
|
2585
|
+
if (s) {
|
|
2586
|
+
for (const type of s.types) {
|
|
2587
|
+
uniqueSwappersGroups.push({
|
|
2588
|
+
title: s.swapperGroup,
|
|
2589
|
+
logo: s.logo,
|
|
2590
|
+
type,
|
|
2591
|
+
selected: !disabledLiquiditySources.includes(s.swapperGroup)
|
|
2592
|
+
});
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
});
|
|
2596
|
+
supportedSwappers !== 'all' && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0);
|
|
2597
|
+
const supportedUniqueSwappersGroups = supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups;
|
|
2598
|
+
return React.createElement(Settings, {
|
|
2599
|
+
slippages: SLIPPAGES,
|
|
2600
|
+
selectedSlippage: slippage,
|
|
2601
|
+
onSlippageChange: slippage => setSlippage(slippage),
|
|
2602
|
+
onLiquiditySourcesClick: () => navigate(navigationRoutes.liquiditySources),
|
|
2603
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
2604
|
+
liquiditySources: supportedUniqueSwappersGroups,
|
|
2605
|
+
selectedLiquiditySources: supportedUniqueSwappersGroups.filter(s => s.selected),
|
|
2606
|
+
customSlippage: customSlippage || NaN,
|
|
2607
|
+
onCustomSlippageChange: setCustomSlippage,
|
|
2608
|
+
minSlippage: MIN_SLIPPGAE,
|
|
2609
|
+
maxSlippage: MAX_SLIPPAGE,
|
|
2610
|
+
selectedTheme: theme,
|
|
2611
|
+
onThemeChange: setTheme,
|
|
2612
|
+
infiniteApprove: infiniteApprove,
|
|
2613
|
+
toggleInfiniteApprove: toggleInfiniteApprove,
|
|
2614
|
+
loadingStatus: loadingMetaStatus
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
const ListContainer = /*#__PURE__*/styled('div', {
|
|
2619
|
+
display: 'grid',
|
|
2620
|
+
gap: '.5rem',
|
|
2621
|
+
gridTemplateColumns: ' repeat(2, minmax(0, 1fr))',
|
|
2622
|
+
alignContent: 'baseline',
|
|
2623
|
+
padding: '0.5rem',
|
|
2624
|
+
overflowY: 'auto'
|
|
2625
|
+
});
|
|
2626
|
+
const LoaderContainer = /*#__PURE__*/styled('div', {
|
|
2627
|
+
display: 'flex',
|
|
2628
|
+
justifyContent: 'center',
|
|
2629
|
+
width: '100%',
|
|
2630
|
+
position: 'absolute',
|
|
2631
|
+
top: '50%'
|
|
2632
|
+
});
|
|
2633
|
+
const AlertContainer = /*#__PURE__*/styled('div', {
|
|
2634
|
+
paddingBottom: '$16'
|
|
2635
|
+
});
|
|
2636
|
+
function WalletsPage(_ref) {
|
|
2637
|
+
let {
|
|
2638
|
+
supportedWallets,
|
|
2639
|
+
multiWallets
|
|
2640
|
+
} = _ref;
|
|
2478
2641
|
const {
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
} = useMetaStore.use.meta();
|
|
2482
|
-
const accounts = useWalletsStore.use.accounts();
|
|
2483
|
-
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
2484
|
-
const initSelectedWallets = useWalletsStore.use.initSelectedWallets();
|
|
2485
|
-
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
2642
|
+
navigateBackFrom
|
|
2643
|
+
} = useNavigateBack();
|
|
2486
2644
|
const {
|
|
2645
|
+
state,
|
|
2646
|
+
disconnect,
|
|
2487
2647
|
getWalletInfo,
|
|
2488
2648
|
connect
|
|
2489
2649
|
} = useWallets();
|
|
2490
|
-
const
|
|
2491
|
-
const
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
const
|
|
2650
|
+
const wallets = getlistWallet(state, getWalletInfo, supportedWallets === 'all' ? Object.values(WalletType) : supportedWallets);
|
|
2651
|
+
const walletsRef = useRef();
|
|
2652
|
+
let sortedWallets = detectMobileScreens() ? wallets.filter(wallet => wallet.showOnMobile) : wallets;
|
|
2653
|
+
sortedWallets = sortWalletsBasedOnState(sortedWallets);
|
|
2654
|
+
const [walletErrorMessage, setWalletErrorMessage] = useState('');
|
|
2655
|
+
const toggleConnectWalletsButton = useUiStore.use.toggleConnectWalletsButton();
|
|
2656
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2657
|
+
const {
|
|
2658
|
+
t
|
|
2659
|
+
} = useTranslation();
|
|
2660
|
+
const onSelectWallet = async type => {
|
|
2661
|
+
const wallet = state(type);
|
|
2662
|
+
try {
|
|
2663
|
+
if (walletErrorMessage) setWalletErrorMessage('');
|
|
2664
|
+
if (wallet.connected) {
|
|
2665
|
+
await disconnect(type);
|
|
2666
|
+
} else {
|
|
2667
|
+
if (!multiWallets && !!wallets.find(w => w.state === WalletState.CONNECTED)) {
|
|
2668
|
+
return;
|
|
2669
|
+
}
|
|
2670
|
+
await connect(type);
|
|
2671
|
+
}
|
|
2672
|
+
} catch (e) {
|
|
2673
|
+
setWalletErrorMessage('Error: ' + e?.message);
|
|
2674
|
+
}
|
|
2675
|
+
};
|
|
2676
|
+
const disconnectConnectingWallets = () => {
|
|
2677
|
+
const connectingWallets = walletsRef.current?.filter(wallet => wallet.state === WalletState.CONNECTING) || [];
|
|
2678
|
+
for (const wallet of connectingWallets) {
|
|
2679
|
+
disconnect(wallet.type);
|
|
2680
|
+
}
|
|
2681
|
+
};
|
|
2495
2682
|
useEffect(() => {
|
|
2496
|
-
|
|
2683
|
+
toggleConnectWalletsButton();
|
|
2684
|
+
return () => {
|
|
2685
|
+
disconnectConnectingWallets();
|
|
2686
|
+
toggleConnectWalletsButton();
|
|
2687
|
+
};
|
|
2497
2688
|
}, []);
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
previewInputs: React.createElement(React.Fragment, null, React.createElement(TokenPreview, {
|
|
2516
|
-
chain: {
|
|
2517
|
-
displayName: firstStep?.from.blockchain || '',
|
|
2518
|
-
logo: firstStep?.from.blockchainLogo || ''
|
|
2519
|
-
},
|
|
2520
|
-
token: {
|
|
2521
|
-
symbol: firstStep?.from.symbol || '',
|
|
2522
|
-
image: firstStep?.from.logo || ''
|
|
2523
|
-
},
|
|
2524
|
-
usdValue: calcOutputUsdValue(fromAmount, firstStep?.from.usdPrice),
|
|
2525
|
-
amount: fromAmount,
|
|
2526
|
-
label: t('From'),
|
|
2527
|
-
loadingStatus: 'success'
|
|
2528
|
-
}), React.createElement(Spacer, {
|
|
2529
|
-
size: 12,
|
|
2530
|
-
direction: "vertical"
|
|
2531
|
-
}), React.createElement(TokenPreview, {
|
|
2532
|
-
chain: {
|
|
2533
|
-
displayName: lastStep?.to.blockchain || '',
|
|
2534
|
-
logo: lastStep?.to.blockchainLogo || ''
|
|
2535
|
-
},
|
|
2536
|
-
token: {
|
|
2537
|
-
symbol: lastStep?.to.symbol || '',
|
|
2538
|
-
image: lastStep?.to.logo || ''
|
|
2539
|
-
},
|
|
2540
|
-
usdValue: calcOutputUsdValue(toAmount, lastStep?.to.usdPrice),
|
|
2541
|
-
amount: toAmount,
|
|
2542
|
-
label: t('To'),
|
|
2543
|
-
loadingStatus: 'success'
|
|
2544
|
-
})),
|
|
2545
|
-
previewRoutes: React.createElement(RoutesOverview, {
|
|
2546
|
-
routes: bestRoute,
|
|
2547
|
-
totalFee: numberToString(totalFeeInUsd, 0, 2)
|
|
2548
|
-
})
|
|
2549
|
-
});
|
|
2689
|
+
useEffect(() => {
|
|
2690
|
+
walletsRef.current = wallets;
|
|
2691
|
+
}, [wallets]);
|
|
2692
|
+
return React.createElement(SecondaryPage, {
|
|
2693
|
+
title: t('Select Wallet') || '',
|
|
2694
|
+
textField: false,
|
|
2695
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.wallets)
|
|
2696
|
+
}, React.createElement(React.Fragment, null, walletErrorMessage && React.createElement(AlertContainer, null, React.createElement(Alert, {
|
|
2697
|
+
type: "error"
|
|
2698
|
+
}, walletErrorMessage)), loadingMetaStatus === 'loading' && React.createElement(LoaderContainer, {
|
|
2699
|
+
className: "loader"
|
|
2700
|
+
}, React.createElement(Spinner, {
|
|
2701
|
+
size: 24
|
|
2702
|
+
})), loadingMetaStatus === 'failed' && React.createElement(LoadingFailedAlert, null), React.createElement(ListContainer, null, loadingMetaStatus === 'success' && sortedWallets.map((wallet, index) => React.createElement(Wallet, Object.assign({}, wallet, {
|
|
2703
|
+
key: `${index}-${wallet.type}`,
|
|
2704
|
+
onClick: onSelectWallet
|
|
2705
|
+
}))))));
|
|
2550
2706
|
}
|
|
2551
2707
|
|
|
2552
2708
|
function useCopyToClipboard(resetInterval) {
|
|
@@ -2567,15 +2723,87 @@ function useCopyToClipboard(resetInterval) {
|
|
|
2567
2723
|
return [isCopied, handleCopy];
|
|
2568
2724
|
}
|
|
2569
2725
|
|
|
2726
|
+
function timeSince(timeMillis) {
|
|
2727
|
+
const seconds = Math.floor((new Date().getTime() - timeMillis) / 1000);
|
|
2728
|
+
let intervalType;
|
|
2729
|
+
let interval = Math.floor(seconds / 31536000);
|
|
2730
|
+
if (interval >= 1) {
|
|
2731
|
+
intervalType = 'year';
|
|
2732
|
+
} else {
|
|
2733
|
+
interval = Math.floor(seconds / 2592000);
|
|
2734
|
+
if (interval >= 1) {
|
|
2735
|
+
intervalType = 'month';
|
|
2736
|
+
} else {
|
|
2737
|
+
interval = Math.floor(seconds / 86400);
|
|
2738
|
+
if (interval >= 1) {
|
|
2739
|
+
intervalType = 'day';
|
|
2740
|
+
} else {
|
|
2741
|
+
interval = Math.floor(seconds / 3600);
|
|
2742
|
+
if (interval >= 1) {
|
|
2743
|
+
intervalType = 'hour';
|
|
2744
|
+
} else {
|
|
2745
|
+
interval = Math.floor(seconds / 60);
|
|
2746
|
+
if (interval >= 1) {
|
|
2747
|
+
intervalType = 'minute';
|
|
2748
|
+
} else {
|
|
2749
|
+
interval = seconds;
|
|
2750
|
+
intervalType = 'second';
|
|
2751
|
+
}
|
|
2752
|
+
}
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
}
|
|
2756
|
+
if (interval > 1 || interval === 0) {
|
|
2757
|
+
intervalType += 's';
|
|
2758
|
+
}
|
|
2759
|
+
return interval + ' ' + intervalType;
|
|
2760
|
+
}
|
|
2761
|
+
function getSwapDate(pendingSwap) {
|
|
2762
|
+
return pendingSwap.finishTime ? `Finished ${timeSince(parseInt(pendingSwap.finishTime))} ago @ ${new Date(parseInt(pendingSwap.finishTime)).toLocaleString()}` : `Started ${timeSince(parseInt(pendingSwap.creationTime))} ago @ ${new Date(parseInt(pendingSwap.creationTime)).toLocaleString()}`;
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
const PlaceholderContainer = /*#__PURE__*/styled('div', {
|
|
2766
|
+
height: '450px'
|
|
2767
|
+
});
|
|
2768
|
+
function SwapDetailsPlaceholder(props) {
|
|
2769
|
+
const {
|
|
2770
|
+
requestId,
|
|
2771
|
+
loading,
|
|
2772
|
+
onBack
|
|
2773
|
+
} = props;
|
|
2774
|
+
return React.createElement(SecondaryPage, {
|
|
2775
|
+
title: "Swap Details",
|
|
2776
|
+
textField: false,
|
|
2777
|
+
onBack: onBack
|
|
2778
|
+
}, React.createElement(PlaceholderContainer, null, loading ? React.createElement(LoaderContainer, null, React.createElement(Spinner, {
|
|
2779
|
+
size: 24
|
|
2780
|
+
})) : React.createElement(Alert, {
|
|
2781
|
+
type: "secondary",
|
|
2782
|
+
title: `Swap with request ID = ${requestId} not found.`
|
|
2783
|
+
})));
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2570
2786
|
function SwapDetailsPage() {
|
|
2571
2787
|
const selectedSwapRequestId = useUiStore.use.selectedSwapRequestId();
|
|
2788
|
+
const {
|
|
2789
|
+
canSwitchNetworkTo,
|
|
2790
|
+
connect
|
|
2791
|
+
} = useWallets();
|
|
2792
|
+
const retry = useBestRouteStore.use.retry();
|
|
2793
|
+
const navigate = useNavigate();
|
|
2572
2794
|
const {
|
|
2573
2795
|
navigateBackFrom
|
|
2574
2796
|
} = useNavigateBack();
|
|
2797
|
+
const [isCopied, handleCopy] = useCopyToClipboard(2000);
|
|
2575
2798
|
const {
|
|
2576
2799
|
manager
|
|
2577
2800
|
} = useManager();
|
|
2578
|
-
const [
|
|
2801
|
+
const [loading, setLoading] = useState(true);
|
|
2802
|
+
useEffect(() => {
|
|
2803
|
+
setTimeout(() => {
|
|
2804
|
+
setLoading(false);
|
|
2805
|
+
}, 5000);
|
|
2806
|
+
}, []);
|
|
2579
2807
|
const pendingSwaps = getPendingSwaps(manager);
|
|
2580
2808
|
const selectedSwap = pendingSwaps.find(_ref => {
|
|
2581
2809
|
let {
|
|
@@ -2583,92 +2811,161 @@ function SwapDetailsPage() {
|
|
|
2583
2811
|
} = _ref;
|
|
2584
2812
|
return swap.requestId === selectedSwapRequestId;
|
|
2585
2813
|
});
|
|
2586
|
-
//TODO: implement swap cancellation (move queueManager logic to queueManager/rango-preset)
|
|
2587
2814
|
const onCancel = () => {
|
|
2588
|
-
const swap =
|
|
2815
|
+
const swap = manager?.get(selectedSwap?.id);
|
|
2589
2816
|
if (swap) cancelSwap(swap);
|
|
2590
2817
|
};
|
|
2591
|
-
|
|
2818
|
+
const swap = selectedSwap?.swap;
|
|
2819
|
+
if (!swap) return React.createElement(SwapDetailsPlaceholder, {
|
|
2820
|
+
requestId: selectedSwapRequestId || '',
|
|
2821
|
+
loading: loading,
|
|
2822
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.swapDetails)
|
|
2823
|
+
});
|
|
2824
|
+
const firstStep = swap.steps[0];
|
|
2825
|
+
const lastStep = swap.steps[swap.steps.length - 1];
|
|
2826
|
+
const fromAmount = numberToString(swap.inputAmount);
|
|
2827
|
+
const toAmount = numberToString(swap.simulationResult.outputAmount);
|
|
2828
|
+
const currentStep = getCurrentStep(swap);
|
|
2829
|
+
const currentStepBlockchain = currentStep ? getCurrentBlockchainOfOrNull(swap, currentStep) : null;
|
|
2830
|
+
const currentStepWallet = currentStep ? getRelatedWalletOrNull(swap, currentStep) : null;
|
|
2831
|
+
const currentStepNetworkStatus = currentStep?.networkStatus;
|
|
2832
|
+
const swapMessages = getSwapMessages(swap, currentStep);
|
|
2833
|
+
const networkWarningState = isNetworkStatusInWarningState(currentStep);
|
|
2834
|
+
const swapDate = getSwapDate(swap);
|
|
2835
|
+
const shouldRetry = shouldRetrySwap(swap);
|
|
2836
|
+
const switchNetwork = !!currentStepBlockchain && !!currentStepWallet?.walletType && currentStepNetworkStatus === PendingSwapNetworkStatus.WaitingForNetworkChange && canSwitchNetworkTo(currentStepWallet?.walletType, currentStepBlockchain) ? connect.bind(null, currentStepWallet.walletType, currentStepBlockchain) : undefined;
|
|
2837
|
+
const lastConvertedTokenInFailedSwap = getLastConvertedTokenInFailedSwap(swap);
|
|
2838
|
+
return React.createElement(SwapHistory, Object.assign({
|
|
2592
2839
|
onBack: navigateBackFrom.bind(null, navigationRoutes.swapDetails),
|
|
2840
|
+
previewInputs: React.createElement(React.Fragment, null, React.createElement(TokenPreview, {
|
|
2841
|
+
chain: {
|
|
2842
|
+
displayName: firstStep?.fromBlockchain || '',
|
|
2843
|
+
// @ts-ignore
|
|
2844
|
+
logo: firstStep?.fromBlockchainLogo || ''
|
|
2845
|
+
},
|
|
2846
|
+
token: {
|
|
2847
|
+
symbol: firstStep?.fromSymbol || '',
|
|
2848
|
+
image: firstStep?.fromLogo || ''
|
|
2849
|
+
},
|
|
2850
|
+
amount: fromAmount,
|
|
2851
|
+
label: t('From'),
|
|
2852
|
+
loadingStatus: 'success'
|
|
2853
|
+
}), React.createElement(Spacer, {
|
|
2854
|
+
size: 12,
|
|
2855
|
+
direction: "vertical"
|
|
2856
|
+
}), React.createElement(TokenPreview, {
|
|
2857
|
+
chain: {
|
|
2858
|
+
displayName: lastStep?.toBlockchain || '',
|
|
2859
|
+
// @ts-ignore
|
|
2860
|
+
logo: lastStep?.toBlockchainLogo || ''
|
|
2861
|
+
},
|
|
2862
|
+
token: {
|
|
2863
|
+
symbol: lastStep?.toSymbol || '',
|
|
2864
|
+
image: lastStep?.toLogo || ''
|
|
2865
|
+
},
|
|
2866
|
+
amount: toAmount,
|
|
2867
|
+
label: t('To'),
|
|
2868
|
+
loadingStatus: 'success'
|
|
2869
|
+
})),
|
|
2593
2870
|
//todo: move PendingSwap type to rango-types
|
|
2594
2871
|
//@ts-ignore
|
|
2595
|
-
pendingSwap:
|
|
2872
|
+
pendingSwap: swap,
|
|
2596
2873
|
onCopy: handleCopy,
|
|
2597
2874
|
isCopied: isCopied,
|
|
2598
|
-
onCancel: onCancel
|
|
2599
|
-
|
|
2875
|
+
onCancel: onCancel,
|
|
2876
|
+
shortMessage: swapMessages.shortMessage,
|
|
2877
|
+
detailedMessage: swapMessages.detailedMessage,
|
|
2878
|
+
currentStepBlockchain: currentStepBlockchain || '',
|
|
2879
|
+
switchNetwork: switchNetwork,
|
|
2880
|
+
type: networkWarningState ? 'warning' : swap.extraMessageSeverity || undefined,
|
|
2881
|
+
date: swapDate
|
|
2882
|
+
}, shouldRetry && {
|
|
2883
|
+
onRetry: () => {
|
|
2884
|
+
retry(swap);
|
|
2885
|
+
setTimeout(() => {
|
|
2886
|
+
navigate(navigationRoutes.home);
|
|
2887
|
+
}, 0);
|
|
2888
|
+
}
|
|
2889
|
+
}, lastConvertedTokenInFailedSwap && {
|
|
2890
|
+
lastConvertedTokenInFailedSwap: {
|
|
2891
|
+
blockchain: lastConvertedTokenInFailedSwap.blockchain,
|
|
2892
|
+
outputAmount: lastConvertedTokenInFailedSwap.outputAmount || '',
|
|
2893
|
+
symbol: lastConvertedTokenInFailedSwap.symbol
|
|
2894
|
+
}
|
|
2895
|
+
}));
|
|
2600
2896
|
}
|
|
2601
2897
|
|
|
2898
|
+
const getAbsolutePath = path => path.replace('/', '');
|
|
2602
2899
|
function AppRoutes(props) {
|
|
2603
2900
|
const {
|
|
2604
2901
|
configs
|
|
2605
2902
|
} = props;
|
|
2606
2903
|
return useRoutes([{
|
|
2607
|
-
path: navigationRoutes.home,
|
|
2904
|
+
path: getAbsolutePath(navigationRoutes.home),
|
|
2608
2905
|
element: React.createElement(Home, {
|
|
2609
2906
|
title: configs?.title,
|
|
2610
2907
|
titleSize: configs?.titleSize,
|
|
2611
2908
|
titleWeight: configs?.titleWeight
|
|
2612
2909
|
})
|
|
2613
2910
|
}, {
|
|
2614
|
-
path: navigationRoutes.fromChain,
|
|
2911
|
+
path: getAbsolutePath(navigationRoutes.fromChain),
|
|
2615
2912
|
element: React.createElement(SelectChainPage, {
|
|
2616
2913
|
type: "from",
|
|
2617
2914
|
supportedChains: configs?.fromChains || 'all'
|
|
2618
2915
|
})
|
|
2619
2916
|
}, {
|
|
2620
|
-
path: navigationRoutes.toChain,
|
|
2917
|
+
path: getAbsolutePath(navigationRoutes.toChain),
|
|
2621
2918
|
element: React.createElement(SelectChainPage, {
|
|
2622
2919
|
type: "to",
|
|
2623
2920
|
supportedChains: configs?.toChains || 'all'
|
|
2624
2921
|
})
|
|
2625
2922
|
}, {
|
|
2626
|
-
path: navigationRoutes.fromToken
|
|
2923
|
+
path: getAbsolutePath(navigationRoutes.fromToken),
|
|
2627
2924
|
element: React.createElement(SelectTokenPage, {
|
|
2628
2925
|
type: "from",
|
|
2629
2926
|
supportedTokens: configs?.fromTokens || 'all'
|
|
2630
2927
|
})
|
|
2631
2928
|
}, {
|
|
2632
|
-
path: navigationRoutes.toToken,
|
|
2929
|
+
path: getAbsolutePath(navigationRoutes.toToken),
|
|
2633
2930
|
element: React.createElement(SelectTokenPage, {
|
|
2634
2931
|
type: "to",
|
|
2635
2932
|
supportedTokens: configs?.toTokens || 'all'
|
|
2636
2933
|
})
|
|
2637
2934
|
}, {
|
|
2638
|
-
path: navigationRoutes.settings,
|
|
2935
|
+
path: getAbsolutePath(navigationRoutes.settings),
|
|
2639
2936
|
element: React.createElement(SettingsPage, {
|
|
2640
2937
|
supportedSwappers: configs?.liquiditySources || 'all'
|
|
2641
2938
|
})
|
|
2642
2939
|
}, {
|
|
2643
|
-
path: navigationRoutes.liquiditySources,
|
|
2940
|
+
path: getAbsolutePath(navigationRoutes.liquiditySources),
|
|
2644
2941
|
element: React.createElement(LiquiditySourcePage, {
|
|
2645
2942
|
supportedSwappers: configs?.liquiditySources || 'all'
|
|
2646
2943
|
})
|
|
2647
2944
|
}, {
|
|
2648
|
-
path: navigationRoutes.swaps,
|
|
2945
|
+
path: getAbsolutePath(navigationRoutes.swaps),
|
|
2649
2946
|
element: React.createElement(HistoryPage, null)
|
|
2650
2947
|
}, {
|
|
2651
2948
|
path: navigationRoutes.swapDetails,
|
|
2652
2949
|
element: React.createElement(SwapDetailsPage, null)
|
|
2653
2950
|
}, {
|
|
2654
|
-
path: navigationRoutes.wallets,
|
|
2951
|
+
path: getAbsolutePath(navigationRoutes.wallets),
|
|
2655
2952
|
element: React.createElement(WalletsPage, {
|
|
2656
2953
|
supportedWallets: configs?.wallets || 'all',
|
|
2657
2954
|
multiWallets: typeof configs?.multiWallets === 'undefined' ? true : configs.multiWallets
|
|
2658
2955
|
})
|
|
2659
2956
|
}, {
|
|
2660
|
-
path: navigationRoutes.confirmSwap,
|
|
2957
|
+
path: getAbsolutePath(navigationRoutes.confirmSwap),
|
|
2661
2958
|
element: React.createElement(ConfirmSwapPage, null)
|
|
2662
|
-
}, {
|
|
2663
|
-
path: navigationRoutes.confirmWallets,
|
|
2664
|
-
element: React.createElement(ConfirmWalletsPage, null)
|
|
2665
2959
|
}]);
|
|
2666
2960
|
}
|
|
2667
2961
|
|
|
2668
|
-
const Header
|
|
2962
|
+
const Header = /*#__PURE__*/styled('div', {
|
|
2669
2963
|
display: 'flex',
|
|
2670
2964
|
width: '100%',
|
|
2671
|
-
justifyContent: 'end'
|
|
2965
|
+
justifyContent: 'end',
|
|
2966
|
+
'.balance': {
|
|
2967
|
+
display: 'flex'
|
|
2968
|
+
}
|
|
2672
2969
|
});
|
|
2673
2970
|
const WalletImage = /*#__PURE__*/styled('img', {
|
|
2674
2971
|
width: '$24',
|
|
@@ -2698,6 +2995,8 @@ function Layout(_ref) {
|
|
|
2698
2995
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2699
2996
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
2700
2997
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
2998
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2999
|
+
const fetchingBalance = useWalletsStore(fetchingBalanceSelector);
|
|
2701
3000
|
const {
|
|
2702
3001
|
t
|
|
2703
3002
|
} = useTranslation();
|
|
@@ -2712,22 +3011,32 @@ function Layout(_ref) {
|
|
|
2712
3011
|
setFromToken(configs?.fromToken || null);
|
|
2713
3012
|
setFromChain(configs?.fromChain || null);
|
|
2714
3013
|
}, [configs?.fromToken, configs?.fromChain]);
|
|
2715
|
-
|
|
3014
|
+
useEffect(() => {
|
|
3015
|
+
setToChain(null);
|
|
3016
|
+
setFromChain(null);
|
|
3017
|
+
setFromToken(null);
|
|
3018
|
+
setToToken(null);
|
|
3019
|
+
}, [configs?.fromChains, configs?.toChains, configs?.fromTokens, configs?.toTokens]);
|
|
3020
|
+
return React.createElement(React.Fragment, null, React.createElement(Header, null, React.createElement(Button, {
|
|
2716
3021
|
size: "small",
|
|
2717
3022
|
suffix: React.createElement(AddWalletIcon, {
|
|
2718
3023
|
size: 20
|
|
2719
3024
|
}),
|
|
2720
3025
|
variant: "ghost",
|
|
2721
3026
|
flexContent: true,
|
|
3027
|
+
loading: loadingMetaStatus === 'loading',
|
|
3028
|
+
disabled: loadingMetaStatus === 'failed',
|
|
2722
3029
|
onClick: () => {
|
|
2723
3030
|
if (!connectWalletsButtonDisabled) navigate(navigationRoutes.wallets);
|
|
2724
3031
|
}
|
|
2725
3032
|
}, connectedWalletsImages?.length ? connectedWalletsImages.map((walletImage, index) => React.createElement(WalletImage, {
|
|
2726
3033
|
key: index,
|
|
2727
3034
|
src: walletImage
|
|
2728
|
-
})) : React.createElement(React.Fragment, null), React.createElement(
|
|
3035
|
+
})) : React.createElement(React.Fragment, null), React.createElement("div", {
|
|
3036
|
+
className: "balance"
|
|
3037
|
+
}, React.createElement(Typography, {
|
|
2729
3038
|
variant: "body2"
|
|
2730
|
-
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`))), React.createElement(AppRoutes, {
|
|
3039
|
+
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React.createElement(Spinner, null)))), React.createElement(AppRoutes, {
|
|
2731
3040
|
configs: configs
|
|
2732
3041
|
}));
|
|
2733
3042
|
}
|
|
@@ -2735,10 +3044,12 @@ function Layout(_ref) {
|
|
|
2735
3044
|
const globalStyles = /*#__PURE__*/globalCss({
|
|
2736
3045
|
'*': {
|
|
2737
3046
|
'&::-webkit-scrollbar': {
|
|
2738
|
-
width: '$8'
|
|
3047
|
+
width: '$8',
|
|
3048
|
+
height: '$8'
|
|
2739
3049
|
},
|
|
2740
3050
|
'&::-webkit-scrollbar-thumb': {
|
|
2741
|
-
backgroundColor: '$neutrals400'
|
|
3051
|
+
backgroundColor: '$neutrals400',
|
|
3052
|
+
borderRadius: '$10'
|
|
2742
3053
|
},
|
|
2743
3054
|
'&::-webkit-scrollbar-thumb:hover': {
|
|
2744
3055
|
backgroundColor: '$neutrals500'
|
|
@@ -2979,7 +3290,7 @@ function QueueManager(props) {
|
|
|
2979
3290
|
};
|
|
2980
3291
|
// TODO: this code copy & pasted from rango, should be refactored.
|
|
2981
3292
|
const allBlockchains = blockchains.filter(blockchain => blockchain.enabled).reduce((blockchainsObj, blockchain) => (blockchainsObj[blockchain.name] = blockchain, blockchainsObj), {});
|
|
2982
|
-
const evmBasedChains = blockchains.filter(isEvmBlockchain);
|
|
3293
|
+
const evmBasedChains = blockchains.filter(isEvmBlockchain$1);
|
|
2983
3294
|
const getSupportedChainNames = type => {
|
|
2984
3295
|
const {
|
|
2985
3296
|
supportedChains
|
|
@@ -3012,7 +3323,9 @@ function QueueManager(props) {
|
|
|
3012
3323
|
//@ts-ignore
|
|
3013
3324
|
queuesDefs: [swapQueueDef],
|
|
3014
3325
|
context: context,
|
|
3015
|
-
onPersistedDataLoaded:
|
|
3326
|
+
onPersistedDataLoaded: manager => {
|
|
3327
|
+
checkWaitingForNetworkChange(manager);
|
|
3328
|
+
},
|
|
3016
3329
|
isPaused: false
|
|
3017
3330
|
}, props.children);
|
|
3018
3331
|
}
|
|
@@ -3040,8 +3353,10 @@ const SwapBox = _ref => {
|
|
|
3040
3353
|
changeLanguage
|
|
3041
3354
|
} = useSelectLanguage();
|
|
3042
3355
|
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
3043
|
-
const
|
|
3044
|
-
const
|
|
3356
|
+
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] = useState('');
|
|
3357
|
+
const [disconnectedWallet, setDisconnectedWallet] = useState();
|
|
3358
|
+
const evmBasedChainNames = blockchains.filter(isEvmBlockchain$1).map(chain => chain.name);
|
|
3359
|
+
const onUpdateState = (type, event, value, state, supportedChains) => {
|
|
3045
3360
|
if (event === Events.ACCOUNTS) {
|
|
3046
3361
|
if (value) {
|
|
3047
3362
|
const supportedChainNames = walletAndSupportedChainsNames(supportedChains);
|
|
@@ -3051,6 +3366,16 @@ const SwapBox = _ref => {
|
|
|
3051
3366
|
disconnectWallet(type);
|
|
3052
3367
|
}
|
|
3053
3368
|
}
|
|
3369
|
+
if (event === Events.ACCOUNTS && state.connected) {
|
|
3370
|
+
const key = `${type}-${state.network}-${value}`;
|
|
3371
|
+
if (state.connected) {
|
|
3372
|
+
setLastConnectedWalletWithNetwork(key);
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
if (event === Events.NETWORK && state.network) {
|
|
3376
|
+
const key = `${type}-${state.network}`;
|
|
3377
|
+
setLastConnectedWalletWithNetwork(key);
|
|
3378
|
+
}
|
|
3054
3379
|
};
|
|
3055
3380
|
let providers = allProviders();
|
|
3056
3381
|
useEffect(() => {
|
|
@@ -3082,7 +3407,12 @@ const SwapBox = _ref => {
|
|
|
3082
3407
|
}, React.createElement(AppRouter, {
|
|
3083
3408
|
title: configs.title,
|
|
3084
3409
|
titleSize: configs.titleSize,
|
|
3085
|
-
titleWeight: configs.titleWeight
|
|
3410
|
+
titleWeight: configs.titleWeight,
|
|
3411
|
+
lastConnectedWallet: lastConnectedWalletWithNetwork,
|
|
3412
|
+
disconnectedWallet: disconnectedWallet,
|
|
3413
|
+
clearDisconnectedWallet: () => {
|
|
3414
|
+
setDisconnectedWallet(undefined);
|
|
3415
|
+
}
|
|
3086
3416
|
}, React.createElement(Layout, {
|
|
3087
3417
|
configs: configs
|
|
3088
3418
|
}))))));
|