@rango-dev/widget-embedded 0.17.1-next.9 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/dist/QueueManager.d.ts +1 -2
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/Wallets.d.ts +0 -1
- package/dist/Wallets.d.ts.map +1 -1
- package/dist/Widget.d.ts +1 -1
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +2 -0
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +6 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +3 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +3 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts +4 -1
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/NoRoutes/NoRoutes.d.ts +4 -0
- package/dist/components/NoRoutes/NoRoutes.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts +3 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -0
- package/dist/components/{NoResult/NoResult.styles.d.ts → NoRoutes/NoRoutes.styles.d.ts} +1 -1
- package/dist/components/{NoResult/NoResult.styles.d.ts.map → NoRoutes/NoRoutes.styles.d.ts.map} +1 -1
- package/dist/components/{NoResult/NoResult.types.d.ts → NoRoutes/NoRoutes.types.d.ts} +3 -3
- package/dist/components/NoRoutes/NoRoutes.types.d.ts.map +1 -0
- package/dist/components/NoRoutes/index.d.ts +2 -0
- package/dist/components/NoRoutes/index.d.ts.map +1 -0
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -0
- package/dist/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts → RouteErrors/RouteErrors.styles.d.ts} +1 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +24 -0
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -0
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts +4 -0
- package/dist/components/RouteErrors/RouteErrorsModalItem.d.ts.map +1 -0
- package/dist/components/RouteErrors/index.d.ts +2 -0
- package/dist/components/RouteErrors/index.d.ts.map +1 -0
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +6 -1
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +4 -4
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/constants/messages.d.ts +1 -1
- package/dist/constants/searchParams.d.ts +1 -2
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/constants/warnings.d.ts +2 -2
- package/dist/constants/warnings.d.ts.map +1 -1
- package/dist/hooks/{useConfirmSwap/useConfirmSwap.types.d.ts → useConfirmSwap.d.ts} +7 -5
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -0
- package/dist/hooks/{useFetchQuote.d.ts → useFetchBestRoute.d.ts} +3 -3
- package/dist/hooks/useFetchBestRoute.d.ts.map +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
- package/dist/hooks/useSwapInput.d.ts +2 -4
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +2 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts +6 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts +2 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +6 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +8 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/app.d.ts +23 -5
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/{quote.d.ts → bestRoute.d.ts} +27 -39
- package/dist/store/bestRoute.d.ts.map +1 -0
- package/dist/store/meta.d.ts +23 -0
- package/dist/store/meta.d.ts.map +1 -0
- package/dist/store/settings.d.ts +2 -3
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +2 -3
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +0 -3
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +4 -5
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +5 -5
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/routing.d.ts +65 -0
- package/dist/types/routing.d.ts.map +1 -0
- package/dist/utils/numbers.d.ts +1 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/{quote.d.ts → routing.d.ts} +12 -16
- package/dist/utils/routing.d.ts.map +1 -0
- package/dist/utils/settings.d.ts +2 -3
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +22 -25
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +2 -2
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/QueueManager.tsx +14 -14
- package/src/Wallets.tsx +15 -35
- package/src/Widget.tsx +24 -11
- package/src/components/AppRouter.tsx +5 -6
- package/src/components/AppRoutes.tsx +39 -6
- package/src/components/BlockchainList/BlockchainList.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +7 -7
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +64 -2
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +40 -28
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +3 -1
- package/src/components/ConfirmWalletsModal/WalletList.tsx +5 -6
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +4 -1
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +3 -3
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +6 -6
- package/src/components/{NoResult/NoResult.helpers.ts → NoRoutes/NoRoutes.helper.ts} +9 -16
- package/src/components/{NoResult/NoResult.styles.ts → NoRoutes/NoRoutes.styles.ts} +0 -2
- package/src/components/{NoResult/NoResult.tsx → NoRoutes/NoRoutes.tsx} +12 -10
- package/src/components/{NoResult/NoResult.types.ts → NoRoutes/NoRoutes.types.ts} +2 -3
- package/src/components/NoRoutes/index.ts +1 -0
- package/src/components/NotificationContent/NotificationContent.tsx +2 -3
- package/src/components/RouteErrors/RouteErrors.tsx +79 -0
- package/src/components/RouteErrors/RouteErrors.types.ts +29 -0
- package/src/components/RouteErrors/RouteErrorsModal.tsx +129 -0
- package/src/components/{QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx → RouteErrors/RouteErrorsModalItem.tsx} +3 -3
- package/src/components/RouteErrors/index.ts +1 -0
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +22 -18
- package/src/components/SwitchFromAndTo.tsx +2 -2
- package/src/components/TokenList/TokenList.tsx +6 -5
- package/src/components/UpdateUrl.tsx +26 -36
- package/src/components/WidgetEvents.tsx +2 -4
- package/src/constants/errors.ts +10 -8
- package/src/constants/messages.ts +1 -1
- package/src/constants/searchParams.ts +0 -1
- package/src/constants/warnings.ts +7 -7
- package/src/hooks/useConfirmSwap.ts +303 -0
- package/src/hooks/{useFetchQuote.ts → useFetchBestRoute.ts} +3 -3
- package/src/hooks/useNavigateBack.ts +3 -3
- package/src/hooks/useSwapInput.ts +23 -58
- package/src/hooks/useSyncStoresWithConfig.ts +19 -22
- package/src/hooks/useWalletList.ts +5 -3
- package/src/pages/ConfirmSwapPage.tsx +235 -58
- package/src/pages/HistoryPage.tsx +1 -1
- package/src/pages/Home.tsx +247 -58
- package/src/pages/LanguagePage.tsx +1 -1
- package/src/pages/LiquiditySourcePage.tsx +32 -23
- package/src/pages/SelectBlockchainPage.tsx +7 -6
- package/src/pages/SelectSwapItemsPage.tsx +5 -5
- package/src/pages/SettingsPage.tsx +13 -9
- package/src/pages/SwapDetailsPage.tsx +3 -3
- package/src/pages/ThemePage.tsx +1 -1
- package/src/pages/WalletsPage.tsx +12 -5
- package/src/store/app.ts +6 -18
- package/src/store/{quote.ts → bestRoute.ts} +60 -68
- package/src/store/meta.ts +39 -0
- package/src/store/settings.ts +4 -7
- package/src/store/slices/config.ts +15 -25
- package/src/store/slices/data.ts +29 -64
- package/src/store/wallets.ts +8 -11
- package/src/types/config.ts +5 -5
- package/src/types/index.ts +1 -1
- package/src/types/routing.ts +77 -0
- package/src/utils/numbers.ts +1 -1
- package/src/utils/routing.ts +321 -0
- package/src/utils/settings.ts +7 -8
- package/src/utils/swap.ts +85 -113
- package/src/utils/wallets.ts +17 -29
- package/dist/components/NoResult/NoResult.d.ts +0 -4
- package/dist/components/NoResult/NoResult.d.ts.map +0 -1
- package/dist/components/NoResult/NoResult.helpers.d.ts +0 -4
- package/dist/components/NoResult/NoResult.helpers.d.ts.map +0 -1
- package/dist/components/NoResult/NoResult.types.d.ts.map +0 -1
- package/dist/components/NoResult/index.d.ts +0 -2
- package/dist/components/NoResult/index.d.ts.map +0 -1
- package/dist/components/Quote/Quote.d.ts +0 -4
- package/dist/components/Quote/Quote.d.ts.map +0 -1
- package/dist/components/Quote/Quote.styles.d.ts +0 -1429
- package/dist/components/Quote/Quote.styles.d.ts.map +0 -1
- package/dist/components/Quote/Quote.types.d.ts +0 -22
- package/dist/components/Quote/Quote.types.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSkeleton.d.ts +0 -4
- package/dist/components/Quote/QuoteSkeleton.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSkeleton.styles.d.ts +0 -319
- package/dist/components/Quote/QuoteSkeleton.styles.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSkeleton.types.d.ts +0 -6
- package/dist/components/Quote/QuoteSkeleton.types.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSummary.d.ts +0 -11
- package/dist/components/Quote/QuoteSummary.d.ts.map +0 -1
- package/dist/components/Quote/QuoteSummary.styles.d.ts +0 -158
- package/dist/components/Quote/QuoteSummary.styles.d.ts.map +0 -1
- package/dist/components/Quote/index.d.ts +0 -4
- package/dist/components/Quote/index.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/HighValueLossWarningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts +0 -4
- package/dist/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts +0 -4
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts +0 -9
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +0 -22
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/SlippageWariningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts +0 -11
- package/dist/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.d.ts.map +0 -1
- package/dist/components/QuoteWarningsAndErrors/index.d.ts +0 -2
- package/dist/components/QuoteWarningsAndErrors/index.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts +0 -4
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +0 -472
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -17
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +0 -1
- package/dist/containers/QuoteInfo/index.d.ts +0 -2
- package/dist/containers/QuoteInfo/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/index.d.ts +0 -2
- package/dist/hooks/useConfirmSwap/index.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts +0 -3
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +0 -16
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +0 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +0 -1
- package/dist/hooks/useFetchQuote.d.ts.map +0 -1
- package/dist/hooks/useForceAutoConnect.d.ts +0 -2
- package/dist/hooks/useForceAutoConnect.d.ts.map +0 -1
- package/dist/store/AppStore.d.ts +0 -11
- package/dist/store/AppStore.d.ts.map +0 -1
- package/dist/store/quote.d.ts.map +0 -1
- package/dist/types/quote.d.ts +0 -82
- package/dist/types/quote.d.ts.map +0 -1
- package/dist/utils/quote.d.ts.map +0 -1
- package/src/components/NoResult/index.ts +0 -1
- package/src/components/Quote/Quote.styles.ts +0 -212
- package/src/components/Quote/Quote.tsx +0 -345
- package/src/components/Quote/Quote.types.ts +0 -16
- package/src/components/Quote/QuoteSkeleton.styles.ts +0 -110
- package/src/components/Quote/QuoteSkeleton.tsx +0 -108
- package/src/components/Quote/QuoteSkeleton.types.ts +0 -5
- package/src/components/Quote/QuoteSummary.styles.ts +0 -15
- package/src/components/Quote/QuoteSummary.tsx +0 -46
- package/src/components/Quote/index.ts +0 -3
- package/src/components/QuoteWarningsAndErrors/HighValueLossWarningModal.tsx +0 -107
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +0 -67
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +0 -103
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +0 -24
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +0 -77
- package/src/components/QuoteWarningsAndErrors/UnknownPriceWarningModal.tsx +0 -38
- package/src/components/QuoteWarningsAndErrors/index.ts +0 -1
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -15
- package/src/containers/QuoteInfo/QuoteInfo.tsx +0 -97
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -17
- package/src/containers/QuoteInfo/index.ts +0 -1
- package/src/hooks/useConfirmSwap/index.ts +0 -1
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +0 -168
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +0 -136
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +0 -19
- package/src/hooks/useForceAutoConnect.ts +0 -27
- package/src/store/AppStore.tsx +0 -35
- package/src/types/quote.ts +0 -107
- package/src/utils/quote.ts +0 -338
- /package/src/components/{QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts → RouteErrors/RouteErrors.styles.ts} +0 -0
package/src/pages/Home.tsx
CHANGED
|
@@ -1,16 +1,32 @@
|
|
|
1
|
+
import type { SwapResult } from 'rango-sdk';
|
|
2
|
+
|
|
1
3
|
import { i18n } from '@lingui/core';
|
|
2
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
Alert,
|
|
6
|
+
BestRoute,
|
|
7
|
+
BestRouteSkeleton,
|
|
8
|
+
Button,
|
|
9
|
+
Divider,
|
|
10
|
+
styled,
|
|
11
|
+
SwapInput,
|
|
12
|
+
Typography,
|
|
13
|
+
WarningIcon,
|
|
14
|
+
} from '@rango-dev/ui';
|
|
3
15
|
import React, { useEffect, useRef, useState } from 'react';
|
|
4
16
|
import { useNavigate } from 'react-router-dom';
|
|
5
17
|
|
|
6
18
|
import { HomeButtons } from '../components/HeaderButtons';
|
|
7
19
|
import { Layout } from '../components/Layout';
|
|
20
|
+
import { NoRoutes } from '../components/NoRoutes';
|
|
21
|
+
import { RouteErrors } from '../components/RouteErrors';
|
|
8
22
|
import { SwitchFromAndToButton } from '../components/SwitchFromAndTo';
|
|
9
23
|
import { errorMessages } from '../constants/errors';
|
|
10
24
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
11
25
|
import {
|
|
12
26
|
BALANCE_MAX_DECIMALS,
|
|
13
27
|
BALANCE_MIN_DECIMALS,
|
|
28
|
+
GAS_FEE_MAX_DECIMALS,
|
|
29
|
+
GAS_FEE_MIN_DECIMALS,
|
|
14
30
|
PERCENTAGE_CHANGE_MAX_DECIMALS,
|
|
15
31
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
16
32
|
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
@@ -18,22 +34,29 @@ import {
|
|
|
18
34
|
USD_VALUE_MAX_DECIMALS,
|
|
19
35
|
USD_VALUE_MIN_DECIMALS,
|
|
20
36
|
} from '../constants/routing';
|
|
21
|
-
import { QuoteInfo } from '../containers/QuoteInfo';
|
|
22
37
|
import { useSwapInput } from '../hooks/useSwapInput';
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
38
|
+
import { useBestRouteStore } from '../store/bestRoute';
|
|
39
|
+
import { useMetaStore } from '../store/meta';
|
|
25
40
|
import { useUiStore } from '../store/ui';
|
|
26
41
|
import { useWalletsStore } from '../store/wallets';
|
|
27
42
|
import { ButtonState } from '../types';
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
43
|
+
import { getContainer } from '../utils/common';
|
|
44
|
+
import { getBlockchainShortNameFor } from '../utils/meta';
|
|
45
|
+
import {
|
|
46
|
+
numberToString,
|
|
47
|
+
secondsToString,
|
|
48
|
+
totalArrivalTime,
|
|
49
|
+
} from '../utils/numbers';
|
|
50
|
+
import { getFormattedBestRoute, getPriceImpactLevel } from '../utils/routing';
|
|
30
51
|
import {
|
|
31
52
|
canComputePriceImpact,
|
|
32
53
|
getOutputRatio,
|
|
33
54
|
getPercentageChange,
|
|
34
55
|
getSwapButtonState,
|
|
35
|
-
|
|
56
|
+
getTotalFeeInUsd,
|
|
36
57
|
hasLimitError,
|
|
58
|
+
LimitErrorMessage,
|
|
59
|
+
outputRatioHasWarning,
|
|
37
60
|
} from '../utils/swap';
|
|
38
61
|
import { getBalanceFromWallet } from '../utils/wallets';
|
|
39
62
|
|
|
@@ -53,13 +76,27 @@ const InputsContainer = styled('div', {
|
|
|
53
76
|
gap: 5,
|
|
54
77
|
alignSelf: 'stretch',
|
|
55
78
|
});
|
|
79
|
+
|
|
80
|
+
const BestRouteContainer = styled('div', {
|
|
81
|
+
width: '100%',
|
|
82
|
+
paddingTop: '$2',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const FooterStepAlarm = styled('div', {
|
|
86
|
+
paddingBottom: '$15',
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const FooterAlert = styled('div', {
|
|
90
|
+
width: '100%',
|
|
91
|
+
display: 'flex',
|
|
92
|
+
});
|
|
93
|
+
|
|
56
94
|
export function Home() {
|
|
57
95
|
const navigate = useNavigate();
|
|
58
96
|
const {
|
|
59
|
-
fetch:
|
|
60
|
-
loading:
|
|
61
|
-
error:
|
|
62
|
-
warning: quoteWarning,
|
|
97
|
+
fetch: refetchBestRoute,
|
|
98
|
+
loading: fetchingBestRoute,
|
|
99
|
+
error: bestRouteError,
|
|
63
100
|
} = useSwapInput();
|
|
64
101
|
const {
|
|
65
102
|
fromToken,
|
|
@@ -71,40 +108,51 @@ export function Home() {
|
|
|
71
108
|
inputUsdValue,
|
|
72
109
|
outputAmount,
|
|
73
110
|
outputUsdValue,
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
} = useQuoteStore();
|
|
111
|
+
bestRoute,
|
|
112
|
+
resetRouteWallets,
|
|
113
|
+
} = useBestRouteStore();
|
|
78
114
|
|
|
79
|
-
const
|
|
115
|
+
const {
|
|
116
|
+
meta: { tokens, blockchains },
|
|
117
|
+
loadingStatus: loadingMetaStatus,
|
|
118
|
+
} = useMetaStore();
|
|
80
119
|
|
|
81
120
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
82
121
|
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
83
|
-
const [
|
|
122
|
+
const [openWarningModal, setOpenWarningModal] = useState(false);
|
|
123
|
+
const {
|
|
124
|
+
fromAmountRangeError,
|
|
125
|
+
swap: swapHasError,
|
|
126
|
+
recommendation,
|
|
127
|
+
} = LimitErrorMessage(bestRoute);
|
|
84
128
|
const layoutRef = useRef<HTMLDivElement>(null);
|
|
85
129
|
|
|
130
|
+
const showBestRoute =
|
|
131
|
+
!!Number(inputAmount) &&
|
|
132
|
+
(!!bestRoute || fetchingBestRoute || !!bestRouteError);
|
|
133
|
+
|
|
86
134
|
const needsToWarnEthOnPath = false;
|
|
87
135
|
|
|
88
136
|
const outToInRatio = getOutputRatio(inputUsdValue, outputUsdValue);
|
|
89
|
-
const highValueLoss =
|
|
137
|
+
const highValueLoss = outputRatioHasWarning(inputUsdValue, outToInRatio);
|
|
90
138
|
|
|
91
139
|
const priceImpactInputCanNotBeComputed = !canComputePriceImpact(
|
|
92
|
-
|
|
140
|
+
bestRoute,
|
|
93
141
|
inputAmount,
|
|
94
142
|
inputUsdValue
|
|
95
143
|
);
|
|
96
144
|
|
|
97
145
|
const priceImpactOutputCanNotBeComputed = !canComputePriceImpact(
|
|
98
|
-
|
|
146
|
+
bestRoute,
|
|
99
147
|
inputAmount,
|
|
100
148
|
outputUsdValue
|
|
101
149
|
);
|
|
102
150
|
const swapButtonState = getSwapButtonState(
|
|
103
|
-
|
|
151
|
+
loadingMetaStatus,
|
|
104
152
|
connectedWallets,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
hasLimitError(
|
|
153
|
+
fetchingBestRoute,
|
|
154
|
+
bestRoute,
|
|
155
|
+
hasLimitError(bestRoute),
|
|
108
156
|
highValueLoss,
|
|
109
157
|
priceImpactInputCanNotBeComputed || priceImpactOutputCanNotBeComputed,
|
|
110
158
|
needsToWarnEthOnPath,
|
|
@@ -145,7 +193,7 @@ export function Home() {
|
|
|
145
193
|
|
|
146
194
|
useEffect(() => {
|
|
147
195
|
setCurrentPage(navigationRoutes.home);
|
|
148
|
-
|
|
196
|
+
resetRouteWallets();
|
|
149
197
|
return setCurrentPage.bind(null, '');
|
|
150
198
|
}, []);
|
|
151
199
|
|
|
@@ -153,9 +201,83 @@ export function Home() {
|
|
|
153
201
|
!inputUsdValue || !outputUsdValue || !outputUsdValue.gt(0)
|
|
154
202
|
? null
|
|
155
203
|
: getPercentageChange(
|
|
156
|
-
inputUsdValue.
|
|
157
|
-
outputUsdValue.
|
|
204
|
+
inputUsdValue.toNumber(),
|
|
205
|
+
outputUsdValue.toNumber()
|
|
158
206
|
);
|
|
207
|
+
|
|
208
|
+
const getBestRouteSteps = (swaps: SwapResult[]) => {
|
|
209
|
+
return swaps.map((swap, index) => ({
|
|
210
|
+
swapper: { displayName: swap.swapperId, image: swap.swapperLogo },
|
|
211
|
+
from: {
|
|
212
|
+
token: { displayName: swap.from.symbol, image: swap.from.logo },
|
|
213
|
+
chain: {
|
|
214
|
+
displayName:
|
|
215
|
+
getBlockchainShortNameFor(swap.from.blockchain, blockchains) ?? '',
|
|
216
|
+
image: swap.from.blockchainLogo,
|
|
217
|
+
},
|
|
218
|
+
price: {
|
|
219
|
+
value:
|
|
220
|
+
index === 0
|
|
221
|
+
? numberToString(
|
|
222
|
+
inputAmount,
|
|
223
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
224
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
225
|
+
)
|
|
226
|
+
: swap.fromAmount,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
to: {
|
|
230
|
+
token: { displayName: swap.to.symbol, image: swap.to.logo },
|
|
231
|
+
chain: {
|
|
232
|
+
displayName:
|
|
233
|
+
getBlockchainShortNameFor(swap.to.blockchain, blockchains) ?? '',
|
|
234
|
+
image: swap.to.blockchainLogo,
|
|
235
|
+
},
|
|
236
|
+
price: {
|
|
237
|
+
value: swap.toAmount,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
alerts:
|
|
241
|
+
swap.swapperId === swapHasError?.swapperId ? (
|
|
242
|
+
<FooterStepAlarm>
|
|
243
|
+
<Alert
|
|
244
|
+
type="error"
|
|
245
|
+
title={recommendation}
|
|
246
|
+
footer={
|
|
247
|
+
<FooterAlert>
|
|
248
|
+
<Typography size="xsmall" variant="body" color="neutral700">
|
|
249
|
+
{fromAmountRangeError}
|
|
250
|
+
</Typography>
|
|
251
|
+
<Divider direction="horizontal" size={8} />
|
|
252
|
+
<Typography size="xsmall" variant="body" color="neutral700">
|
|
253
|
+
|
|
|
254
|
+
</Typography>
|
|
255
|
+
<Divider direction="horizontal" size={8} />
|
|
256
|
+
<Typography size="xsmall" variant="body" color="neutral700">
|
|
257
|
+
{i18n.t({
|
|
258
|
+
id: 'Yours: {amount} {symbol}',
|
|
259
|
+
values: {
|
|
260
|
+
amount: numberToString(
|
|
261
|
+
swapHasError?.fromAmount || null,
|
|
262
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
263
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
264
|
+
),
|
|
265
|
+
symbol: swap?.from.symbol,
|
|
266
|
+
},
|
|
267
|
+
})}
|
|
268
|
+
</Typography>
|
|
269
|
+
</FooterAlert>
|
|
270
|
+
}
|
|
271
|
+
/>
|
|
272
|
+
</FooterStepAlarm>
|
|
273
|
+
) : undefined,
|
|
274
|
+
}));
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
278
|
+
|
|
279
|
+
const bestRouteData = getFormattedBestRoute(bestRoute);
|
|
280
|
+
|
|
159
281
|
return (
|
|
160
282
|
<Layout
|
|
161
283
|
ref={layoutRef}
|
|
@@ -174,8 +296,8 @@ export function Home() {
|
|
|
174
296
|
onClick={() => {
|
|
175
297
|
if (swapButtonState.state === ButtonState.WAITFORCONNECTING) {
|
|
176
298
|
navigate(navigationRoutes.wallets);
|
|
177
|
-
} else if (
|
|
178
|
-
|
|
299
|
+
} else if (swapButtonState.state === ButtonState.NEEDTOCONFIRM) {
|
|
300
|
+
setOpenWarningModal(true);
|
|
179
301
|
} else {
|
|
180
302
|
navigate(navigationRoutes.confirmSwap);
|
|
181
303
|
}
|
|
@@ -189,7 +311,9 @@ export function Home() {
|
|
|
189
311
|
suffix: (
|
|
190
312
|
<HomeButtons
|
|
191
313
|
layoutRef={layoutRef.current}
|
|
192
|
-
onClickRefresh={
|
|
314
|
+
onClickRefresh={
|
|
315
|
+
!!bestRoute || bestRouteError ? refetchBestRoute : undefined
|
|
316
|
+
}
|
|
193
317
|
onClickHistory={() => navigate(navigationRoutes.swaps)}
|
|
194
318
|
onClickSettings={() => navigate(navigationRoutes.settings)}
|
|
195
319
|
/>
|
|
@@ -200,8 +324,6 @@ export function Home() {
|
|
|
200
324
|
<FromContainer>
|
|
201
325
|
<SwapInput
|
|
202
326
|
label={i18n.t('From')}
|
|
203
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
204
|
-
//@ts-ignore
|
|
205
327
|
mode="From"
|
|
206
328
|
onInputChange={setInputAmount}
|
|
207
329
|
balance={tokenBalance}
|
|
@@ -227,8 +349,8 @@ export function Home() {
|
|
|
227
349
|
? errorMessages().unknownPriceError.impactTitle
|
|
228
350
|
: undefined,
|
|
229
351
|
}}
|
|
230
|
-
disabled={
|
|
231
|
-
loading={
|
|
352
|
+
disabled={loadingMetaStatus === 'failed'}
|
|
353
|
+
loading={loadingMetaStatus === 'loading'}
|
|
232
354
|
onSelectMaxBalance={() => {
|
|
233
355
|
if (tokenBalance !== '0') {
|
|
234
356
|
setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
@@ -238,7 +360,7 @@ export function Home() {
|
|
|
238
360
|
<SwitchFromAndToButton />
|
|
239
361
|
</FromContainer>
|
|
240
362
|
<SwapInput
|
|
241
|
-
sharpBottomStyle={!!
|
|
363
|
+
sharpBottomStyle={!!bestRoute?.result || fetchingBestRoute}
|
|
242
364
|
label={i18n.t('To')}
|
|
243
365
|
mode="To"
|
|
244
366
|
chain={{
|
|
@@ -249,12 +371,18 @@ export function Home() {
|
|
|
249
371
|
displayName: toToken?.symbol || '',
|
|
250
372
|
image: toToken?.image || '',
|
|
251
373
|
}}
|
|
252
|
-
percentageChange={
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
374
|
+
percentageChange={
|
|
375
|
+
!!percentageChange?.lt(0)
|
|
376
|
+
? numberToString(
|
|
377
|
+
percentageChange,
|
|
378
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
379
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS
|
|
380
|
+
)
|
|
381
|
+
: null
|
|
382
|
+
}
|
|
383
|
+
warningLevel={getPriceImpactLevel(
|
|
384
|
+
percentageChange?.toNumber() ?? 0
|
|
256
385
|
)}
|
|
257
|
-
warningLevel={getPriceImpactLevel(percentageChange ?? 0)}
|
|
258
386
|
price={{
|
|
259
387
|
value: numberToString(
|
|
260
388
|
outputAmount,
|
|
@@ -273,27 +401,88 @@ export function Home() {
|
|
|
273
401
|
: undefined,
|
|
274
402
|
}}
|
|
275
403
|
onClickToken={() => navigate('to-swap')}
|
|
276
|
-
disabled={
|
|
277
|
-
loading={
|
|
404
|
+
disabled={loadingMetaStatus === 'failed'}
|
|
405
|
+
loading={loadingMetaStatus === 'loading'}
|
|
278
406
|
/>
|
|
279
407
|
</InputsContainer>
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
408
|
+
{fetchingBestRoute && (
|
|
409
|
+
<BestRouteContainer>
|
|
410
|
+
<BestRouteSkeleton type="basic" />
|
|
411
|
+
</BestRouteContainer>
|
|
412
|
+
)}
|
|
413
|
+
{showBestRoute &&
|
|
414
|
+
!fetchingBestRoute &&
|
|
415
|
+
bestRouteData?.result?.swaps?.length ? (
|
|
416
|
+
<BestRouteContainer>
|
|
417
|
+
<BestRoute
|
|
418
|
+
type="basic"
|
|
419
|
+
recommended={true}
|
|
420
|
+
tooltipContainer={getContainer()}
|
|
421
|
+
input={{
|
|
422
|
+
value: numberToString(
|
|
423
|
+
inputAmount,
|
|
424
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
425
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
426
|
+
),
|
|
427
|
+
usdValue: numberToString(
|
|
428
|
+
inputUsdValue,
|
|
429
|
+
USD_VALUE_MIN_DECIMALS,
|
|
430
|
+
USD_VALUE_MAX_DECIMALS
|
|
431
|
+
),
|
|
432
|
+
}}
|
|
433
|
+
output={{
|
|
434
|
+
value: numberToString(
|
|
435
|
+
outputAmount,
|
|
436
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
437
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
438
|
+
),
|
|
439
|
+
usdValue: numberToString(
|
|
440
|
+
outputUsdValue,
|
|
441
|
+
USD_VALUE_MIN_DECIMALS,
|
|
442
|
+
USD_VALUE_MAX_DECIMALS
|
|
443
|
+
),
|
|
444
|
+
}}
|
|
445
|
+
steps={getBestRouteSteps(bestRouteData.result.swaps)}
|
|
446
|
+
percentageChange={numberToString(
|
|
447
|
+
percentageChange,
|
|
448
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
449
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS
|
|
450
|
+
)}
|
|
451
|
+
totalFee={numberToString(
|
|
452
|
+
totalFeeInUsd,
|
|
453
|
+
GAS_FEE_MIN_DECIMALS,
|
|
454
|
+
GAS_FEE_MAX_DECIMALS
|
|
455
|
+
)}
|
|
456
|
+
totalTime={secondsToString(
|
|
457
|
+
totalArrivalTime(bestRoute?.result?.swaps)
|
|
458
|
+
)}
|
|
459
|
+
/>
|
|
460
|
+
</BestRouteContainer>
|
|
461
|
+
) : showBestRoute && !fetchingBestRoute ? (
|
|
462
|
+
<>
|
|
463
|
+
<Divider size={20} />
|
|
464
|
+
<NoRoutes
|
|
465
|
+
diagnosisMessage={bestRouteData?.diagnosisMessages?.[0]}
|
|
466
|
+
fetch={refetchBestRoute}
|
|
467
|
+
error={!!bestRouteError}
|
|
468
|
+
/>
|
|
469
|
+
</>
|
|
470
|
+
) : null}
|
|
296
471
|
</Container>
|
|
472
|
+
<RouteErrors
|
|
473
|
+
openModal={openWarningModal}
|
|
474
|
+
onToggle={setOpenWarningModal}
|
|
475
|
+
totalFeeInUsd={totalFeeInUsd}
|
|
476
|
+
outputUsdValue={outputUsdValue}
|
|
477
|
+
inputUsdValue={inputUsdValue}
|
|
478
|
+
percentageChange={percentageChange}
|
|
479
|
+
highValueLoss={highValueLoss}
|
|
480
|
+
priceImpactCanNotBeComputed={
|
|
481
|
+
priceImpactInputCanNotBeComputed || priceImpactOutputCanNotBeComputed
|
|
482
|
+
}
|
|
483
|
+
loading={fetchingBestRoute || loadingMetaStatus === 'loading'}
|
|
484
|
+
extraSpace={!!bestRoute?.result || !bestRoute}
|
|
485
|
+
/>
|
|
297
486
|
</Layout>
|
|
298
487
|
);
|
|
299
488
|
}
|
|
@@ -25,23 +25,30 @@ import {
|
|
|
25
25
|
} from '../components/SettingsContainer';
|
|
26
26
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
27
27
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
28
|
-
import {
|
|
28
|
+
import { useMetaStore } from '../store/meta';
|
|
29
29
|
import { useSettingsStore } from '../store/settings';
|
|
30
30
|
import { containsText } from '../utils/numbers';
|
|
31
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
getUniqueSwappersGroups,
|
|
33
|
+
sortLiquiditySourcesByGroupTitle,
|
|
34
|
+
} from '../utils/settings';
|
|
32
35
|
|
|
33
36
|
interface PropTypes {
|
|
37
|
+
supportedSwappers?: string[];
|
|
34
38
|
sourceType: 'Exchanges' | 'Bridges';
|
|
35
39
|
}
|
|
36
40
|
|
|
37
|
-
export function LiquiditySourcePage({
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
export function LiquiditySourcePage({
|
|
42
|
+
supportedSwappers,
|
|
43
|
+
sourceType,
|
|
44
|
+
}: PropTypes) {
|
|
40
45
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
41
46
|
const toggleLiquiditySource = useSettingsStore.use.toggleLiquiditySource();
|
|
42
47
|
const { navigateBackFrom } = useNavigateBack();
|
|
48
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
49
|
+
|
|
43
50
|
const supportedUniqueSwappersGroups: Array<UniqueSwappersGroupType> =
|
|
44
|
-
getUniqueSwappersGroups(
|
|
51
|
+
getUniqueSwappersGroups(supportedSwappers);
|
|
45
52
|
|
|
46
53
|
const validTypes: Array<LiquiditySourceType> = [];
|
|
47
54
|
if (sourceType === 'Exchanges') {
|
|
@@ -72,20 +79,22 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
|
|
|
72
79
|
});
|
|
73
80
|
};
|
|
74
81
|
|
|
75
|
-
const list = liquiditySources
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
<
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
82
|
+
const list = liquiditySources
|
|
83
|
+
.sort(sortLiquiditySourcesByGroupTitle)
|
|
84
|
+
.map((sourceItem) => {
|
|
85
|
+
const { selected, groupTitle, logo } = sourceItem;
|
|
86
|
+
return {
|
|
87
|
+
start: <Image src={logo} size={22} type="circular" />,
|
|
88
|
+
onClick: () => toggleLiquiditySource(groupTitle),
|
|
89
|
+
end: <Checkbox checked={selected} />,
|
|
90
|
+
title: (
|
|
91
|
+
<Typography variant="title" size="xmedium">
|
|
92
|
+
{i18n.t(groupTitle)}
|
|
93
|
+
</Typography>
|
|
94
|
+
),
|
|
95
|
+
...sourceItem,
|
|
96
|
+
};
|
|
97
|
+
});
|
|
89
98
|
|
|
90
99
|
const searchHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
91
100
|
const value = event.target.value;
|
|
@@ -102,7 +111,7 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
|
|
|
102
111
|
return (
|
|
103
112
|
<Layout
|
|
104
113
|
header={{
|
|
105
|
-
onBack: (
|
|
114
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
106
115
|
title: i18n.t(sourceType),
|
|
107
116
|
suffix: (
|
|
108
117
|
<LiquiditySourceSuffix>
|
|
@@ -122,7 +131,7 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
|
|
|
122
131
|
placeholder={i18n.t('Search {sourceType}', { sourceType })}
|
|
123
132
|
onChange={searchHandler}
|
|
124
133
|
/>
|
|
125
|
-
{
|
|
134
|
+
{loadingMetaStatus === 'loading' && <LoadingLiquiditySourceList />}
|
|
126
135
|
|
|
127
136
|
{!filteredList.length && !!searchedFor ? (
|
|
128
137
|
<NotFoundContainer>
|
|
@@ -132,7 +141,7 @@ export function LiquiditySourcePage({ sourceType }: PropTypes) {
|
|
|
132
141
|
/>
|
|
133
142
|
</NotFoundContainer>
|
|
134
143
|
) : (
|
|
135
|
-
|
|
144
|
+
loadingMetaStatus === 'success' && (
|
|
136
145
|
<LiquiditySourceList>
|
|
137
146
|
{filteredList.map((sourceItem) => {
|
|
138
147
|
return (
|
|
@@ -7,8 +7,9 @@ import { Layout } from '../components/Layout';
|
|
|
7
7
|
import { SearchInput } from '../components/SearchInput';
|
|
8
8
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
9
9
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
10
|
-
import { useAppStore } from '../store/
|
|
11
|
-
import {
|
|
10
|
+
import { useAppStore } from '../store/app';
|
|
11
|
+
import { useBestRouteStore } from '../store/bestRoute';
|
|
12
|
+
import { useMetaStore } from '../store/meta';
|
|
12
13
|
|
|
13
14
|
interface PropTypes {
|
|
14
15
|
type: 'source' | 'destination';
|
|
@@ -19,9 +20,9 @@ export function SelectBlockchainPage(props: PropTypes) {
|
|
|
19
20
|
const { navigateBackFrom } = useNavigateBack();
|
|
20
21
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
21
22
|
const [blockchainCategory, setBlockchainCategory] = useState<string>('ALL');
|
|
22
|
-
const setToBlockchain =
|
|
23
|
-
const setFromBlockchain =
|
|
24
|
-
const
|
|
23
|
+
const setToBlockchain = useBestRouteStore.use.setToBlockchain();
|
|
24
|
+
const setFromBlockchain = useBestRouteStore.use.setFromBlockchain();
|
|
25
|
+
const { loadingStatus } = useMetaStore();
|
|
25
26
|
|
|
26
27
|
const blockchains = useAppStore().blockchains({
|
|
27
28
|
type: type,
|
|
@@ -41,7 +42,7 @@ export function SelectBlockchainPage(props: PropTypes) {
|
|
|
41
42
|
setCategory={setBlockchainCategory}
|
|
42
43
|
category={blockchainCategory}
|
|
43
44
|
blockchains={blockchains}
|
|
44
|
-
isLoading={
|
|
45
|
+
isLoading={loadingStatus === 'loading'}
|
|
45
46
|
/>
|
|
46
47
|
<Divider size={24} />
|
|
47
48
|
<SearchInput
|
|
@@ -11,8 +11,8 @@ import { SearchInput } from '../components/SearchInput';
|
|
|
11
11
|
import { TokenList } from '../components/TokenList/TokenList';
|
|
12
12
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
13
13
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
14
|
-
import { useAppStore } from '../store/
|
|
15
|
-
import {
|
|
14
|
+
import { useAppStore } from '../store/app';
|
|
15
|
+
import { useBestRouteStore } from '../store/bestRoute';
|
|
16
16
|
import { useWalletsStore } from '../store/wallets';
|
|
17
17
|
import { getTokensBalanceFromWalletAndSort } from '../utils/wallets';
|
|
18
18
|
|
|
@@ -31,7 +31,7 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
31
31
|
setToToken,
|
|
32
32
|
setFromBlockchain,
|
|
33
33
|
setToBlockchain,
|
|
34
|
-
} =
|
|
34
|
+
} = useBestRouteStore();
|
|
35
35
|
const { connectedWallets } = useWalletsStore();
|
|
36
36
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
37
37
|
|
|
@@ -63,9 +63,9 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
63
63
|
|
|
64
64
|
const updateToken = (token: Token) => {
|
|
65
65
|
if (type === 'source') {
|
|
66
|
-
setFromToken(
|
|
66
|
+
setFromToken(token);
|
|
67
67
|
} else {
|
|
68
|
-
setToToken(
|
|
68
|
+
setToToken(token);
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
71
|
|
|
@@ -19,22 +19,26 @@ import { Slippage } from '../components/Slippage';
|
|
|
19
19
|
import { SlippageTooltipContainer as TooltipContainer } from '../components/Slippage/Slippage.styles';
|
|
20
20
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
21
21
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
22
|
-
import {
|
|
22
|
+
import { useMetaStore } from '../store/meta';
|
|
23
23
|
import { useSettingsStore } from '../store/settings';
|
|
24
24
|
import { getContainer } from '../utils/common';
|
|
25
25
|
import { getUniqueSwappersGroups } from '../utils/settings';
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
interface PropTypes {
|
|
28
|
+
supportedSwappers?: string[];
|
|
29
|
+
singleTheme?: boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function SettingsPage({ supportedSwappers, singleTheme }: PropTypes) {
|
|
28
33
|
const navigate = useNavigate();
|
|
29
|
-
const { theme } = useAppStore().config;
|
|
30
|
-
const fetchStatus = useAppStore().fetchStatus;
|
|
31
|
-
const swappers = useAppStore().swappers();
|
|
32
34
|
const { navigateBackFrom } = useNavigateBack();
|
|
33
35
|
|
|
34
36
|
const infiniteApprove = useSettingsStore.use.infiniteApprove();
|
|
35
37
|
const toggleInfiniteApprove = useSettingsStore.use.toggleInfiniteApprove();
|
|
38
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
36
39
|
|
|
37
|
-
const supportedUniqueSwappersGroups =
|
|
40
|
+
const supportedUniqueSwappersGroups =
|
|
41
|
+
getUniqueSwappersGroups(supportedSwappers);
|
|
38
42
|
|
|
39
43
|
const bridgeSources = supportedUniqueSwappersGroups.filter(
|
|
40
44
|
(uniqueItem) =>
|
|
@@ -54,7 +58,7 @@ export function SettingsPage() {
|
|
|
54
58
|
).length;
|
|
55
59
|
|
|
56
60
|
const handleEndItem = (totalSelected: number, total: number) => {
|
|
57
|
-
switch (
|
|
61
|
+
switch (loadingMetaStatus) {
|
|
58
62
|
case 'loading':
|
|
59
63
|
return <Skeleton variant="text" size="medium" width={50} />;
|
|
60
64
|
case 'failed':
|
|
@@ -163,7 +167,7 @@ export function SettingsPage() {
|
|
|
163
167
|
exchangeItem,
|
|
164
168
|
// languageItem
|
|
165
169
|
];
|
|
166
|
-
if (!
|
|
170
|
+
if (!singleTheme) {
|
|
167
171
|
settingItems.push(themeItem);
|
|
168
172
|
}
|
|
169
173
|
settingItems.push(infiniteApprovalItem);
|
|
@@ -171,7 +175,7 @@ export function SettingsPage() {
|
|
|
171
175
|
return (
|
|
172
176
|
<Layout
|
|
173
177
|
header={{
|
|
174
|
-
onBack: (
|
|
178
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
175
179
|
title: i18n.t('Setting'),
|
|
176
180
|
}}>
|
|
177
181
|
<SettingsContainer>
|