@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
|
@@ -1,9 +1,71 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
+
import type { Step } from '@rango-dev/ui/dist/widget/ui/src/components/BestRoute/BestRoute.types';
|
|
1
3
|
import type { BestRouteResponse, BlockchainMeta } from 'rango-sdk';
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
import {
|
|
6
|
+
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
7
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
8
|
+
USD_VALUE_MAX_DECIMALS,
|
|
9
|
+
USD_VALUE_MIN_DECIMALS,
|
|
10
|
+
} from '../../constants/routing';
|
|
11
|
+
import { getBlockchainShortNameFor } from '../../utils/meta';
|
|
12
|
+
import { numberToString } from '../../utils/numbers';
|
|
13
|
+
|
|
14
|
+
export function formatBestRoute(
|
|
15
|
+
bestRoute: BestRouteResponse,
|
|
16
|
+
blockchains: BlockchainMeta[]
|
|
17
|
+
): Step[] | undefined {
|
|
18
|
+
return bestRoute.result?.swaps.map((swap) => {
|
|
19
|
+
return {
|
|
20
|
+
swapper: { displayName: swap.swapperId, image: swap.swapperLogo },
|
|
21
|
+
from: {
|
|
22
|
+
token: { displayName: swap.from.symbol, image: swap.from.logo },
|
|
23
|
+
chain: {
|
|
24
|
+
displayName:
|
|
25
|
+
getBlockchainShortNameFor(swap.from.blockchain, blockchains) ?? '',
|
|
26
|
+
image: swap.from.blockchainLogo,
|
|
27
|
+
},
|
|
28
|
+
price: {
|
|
29
|
+
value: numberToString(
|
|
30
|
+
swap.fromAmount,
|
|
31
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
32
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
33
|
+
),
|
|
34
|
+
usdValue: numberToString(
|
|
35
|
+
swap.from.usdPrice?.toString(),
|
|
36
|
+
USD_VALUE_MIN_DECIMALS,
|
|
37
|
+
USD_VALUE_MAX_DECIMALS
|
|
38
|
+
),
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
to: {
|
|
42
|
+
token: { displayName: swap.to.symbol, image: swap.to.logo },
|
|
43
|
+
chain: {
|
|
44
|
+
displayName:
|
|
45
|
+
getBlockchainShortNameFor(swap.to.blockchain, blockchains) ?? '',
|
|
46
|
+
image: swap.to.blockchainLogo,
|
|
47
|
+
},
|
|
48
|
+
price: {
|
|
49
|
+
value: numberToString(
|
|
50
|
+
swap.toAmount,
|
|
51
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
52
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
53
|
+
),
|
|
54
|
+
usdValue: numberToString(
|
|
55
|
+
swap.to.usdPrice?.toString(),
|
|
56
|
+
USD_VALUE_MIN_DECIMALS,
|
|
57
|
+
USD_VALUE_MAX_DECIMALS
|
|
58
|
+
),
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export function getRequiredWallets(route: BestRouteResponse | null): string[] {
|
|
4
66
|
const wallets: string[] = [];
|
|
5
67
|
|
|
6
|
-
|
|
68
|
+
route?.result?.swaps.forEach((swap) => {
|
|
7
69
|
const currentStepFromBlockchain = swap.from.blockchain;
|
|
8
70
|
const currentStepToBlockchain = swap.to.blockchain;
|
|
9
71
|
let lastAddedWallet = wallets[wallets.length - 1];
|
|
@@ -18,11 +18,11 @@ import {
|
|
|
18
18
|
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
19
19
|
import { useNavigate } from 'react-router-dom';
|
|
20
20
|
|
|
21
|
-
import {
|
|
21
|
+
import { getConfirmSwapErrorMessage } from '../../constants/errors';
|
|
22
22
|
import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
23
|
+
import { getRouteWarningMessage } from '../../constants/warnings';
|
|
24
|
+
import { useBestRouteStore } from '../../store/bestRoute';
|
|
25
|
+
import { useMetaStore } from '../../store/meta';
|
|
26
26
|
import { useWalletsStore } from '../../store/wallets';
|
|
27
27
|
import { confirmSwapDisabled } from '../../utils/swap';
|
|
28
28
|
|
|
@@ -50,24 +50,23 @@ const NUMBER_OF_WALLETS_TO_DISPLAY = 2;
|
|
|
50
50
|
|
|
51
51
|
export function ConfirmWalletsModal(props: PropTypes) {
|
|
52
52
|
//TODO: move component's logics to a custom hook
|
|
53
|
-
const { open, onClose, onCancel, onCheckBalance, loading } = props;
|
|
54
|
-
const
|
|
55
|
-
const blockchains = useAppStore().blockchains();
|
|
53
|
+
const { open, onClose, onCancel, onCheckBalance, config, loading } = props;
|
|
54
|
+
const { blockchains } = useMetaStore.use.meta();
|
|
56
55
|
const {
|
|
57
|
-
|
|
58
|
-
setSelectedWallets:
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
bestRoute,
|
|
57
|
+
setSelectedWallets: selectRouteWallets,
|
|
58
|
+
routeWalletsConfirmed,
|
|
59
|
+
setRouteWalletConfirmed,
|
|
61
60
|
customDestination,
|
|
62
61
|
setCustomDestination,
|
|
63
|
-
} =
|
|
62
|
+
} = useBestRouteStore();
|
|
64
63
|
const { connectedWallets, selectWallets } = useWalletsStore();
|
|
65
64
|
|
|
66
65
|
const [showMoreWalletFor, setShowMoreWalletFor] = useState('');
|
|
67
66
|
const [balanceWarnings, setBalanceWarnings] = useState<string[]>([]);
|
|
68
67
|
const [error, setError] = useState('');
|
|
69
|
-
const [
|
|
70
|
-
ConfirmSwapWarnings['
|
|
68
|
+
const [routeWarning, setRouteWarning] = useState<
|
|
69
|
+
ConfirmSwapWarnings['route'] | null
|
|
71
70
|
>(null);
|
|
72
71
|
const [destination, setDestination] = useState(customDestination);
|
|
73
72
|
const [showCustomDestination, setShowCustomDestination] = useState(
|
|
@@ -75,15 +74,22 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
75
74
|
);
|
|
76
75
|
const customDestinationRef = useRef<HTMLDivElement | null>(null);
|
|
77
76
|
|
|
78
|
-
const requiredWallets = getRequiredWallets(
|
|
77
|
+
const requiredWallets = getRequiredWallets(bestRoute);
|
|
78
|
+
const customDestinationEnabled =
|
|
79
|
+
typeof config?.customDestination === 'undefined'
|
|
80
|
+
? true
|
|
81
|
+
: config.customDestination;
|
|
79
82
|
|
|
80
83
|
const lastStepToBlockchain = blockchains.find(
|
|
81
84
|
(blockchain) =>
|
|
82
85
|
blockchain.name ===
|
|
83
|
-
|
|
86
|
+
bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to
|
|
87
|
+
.blockchain
|
|
84
88
|
);
|
|
85
89
|
const isWalletRequiredFor = (blockchain: string) =>
|
|
86
|
-
!!
|
|
90
|
+
!!bestRoute?.result?.swaps.find(
|
|
91
|
+
(swap) => swap.from.blockchain === blockchain
|
|
92
|
+
);
|
|
87
93
|
|
|
88
94
|
const [selectableWallets, setSelectableWallets] = useState<ConnectedWallet[]>(
|
|
89
95
|
connectedWallets.filter((connectedWallet) => {
|
|
@@ -169,16 +175,16 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
169
175
|
(wallet) => wallet.selected
|
|
170
176
|
);
|
|
171
177
|
selectWallets(lastSelectedWallets);
|
|
172
|
-
|
|
178
|
+
selectRouteWallets(lastSelectedWallets);
|
|
173
179
|
setCustomDestination(destination);
|
|
174
|
-
|
|
180
|
+
setRouteWalletConfirmed(true);
|
|
175
181
|
onClose();
|
|
176
182
|
};
|
|
177
183
|
|
|
178
184
|
const onConfirmWallets = async () => {
|
|
179
185
|
setBalanceWarnings([]);
|
|
180
186
|
setError('');
|
|
181
|
-
|
|
187
|
+
setRouteWarning(null);
|
|
182
188
|
const selectedWallets = connectedWallets.filter((connectedWallet) =>
|
|
183
189
|
selectableWallets.find(
|
|
184
190
|
(selectableWallet) =>
|
|
@@ -195,11 +201,11 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
195
201
|
if (warnings?.balance?.messages) {
|
|
196
202
|
setBalanceWarnings(warnings.balance.messages);
|
|
197
203
|
}
|
|
198
|
-
if (warnings?.
|
|
199
|
-
|
|
204
|
+
if (warnings?.route) {
|
|
205
|
+
setRouteWarning(warnings.route);
|
|
200
206
|
}
|
|
201
207
|
if (result.error) {
|
|
202
|
-
setError(
|
|
208
|
+
setError(getConfirmSwapErrorMessage(result.error));
|
|
203
209
|
}
|
|
204
210
|
|
|
205
211
|
if (!result.error && (!warnings?.balance?.messages.length || 0 > 0)) {
|
|
@@ -243,7 +249,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
243
249
|
<Modal
|
|
244
250
|
open={open}
|
|
245
251
|
onClose={() => {
|
|
246
|
-
if (!
|
|
252
|
+
if (!routeWalletsConfirmed) {
|
|
247
253
|
navigate(navigationRoutes.home, { replace: true });
|
|
248
254
|
}
|
|
249
255
|
onClose();
|
|
@@ -259,7 +265,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
259
265
|
loading,
|
|
260
266
|
showCustomDestination,
|
|
261
267
|
destination,
|
|
262
|
-
|
|
268
|
+
bestRoute,
|
|
263
269
|
selectableWallets,
|
|
264
270
|
lastStepToBlockchain
|
|
265
271
|
)}
|
|
@@ -317,6 +323,9 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
317
323
|
chain={showMoreWalletFor}
|
|
318
324
|
isSelected={isSelected}
|
|
319
325
|
selectWallet={onChange}
|
|
326
|
+
multiWallets={config?.multiWallets ?? true}
|
|
327
|
+
supportedWallets={config?.wallets ?? []}
|
|
328
|
+
config={config}
|
|
320
329
|
onShowMore={setShowMoreWalletFor.bind(null, showMoreWalletFor)}
|
|
321
330
|
/>
|
|
322
331
|
</div>
|
|
@@ -330,12 +339,12 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
330
339
|
<Divider size={12} />
|
|
331
340
|
</>
|
|
332
341
|
)}
|
|
333
|
-
{
|
|
342
|
+
{routeWarning && (
|
|
334
343
|
<>
|
|
335
344
|
<Alert
|
|
336
345
|
variant="alarm"
|
|
337
346
|
type="warning"
|
|
338
|
-
title={
|
|
347
|
+
title={getRouteWarningMessage(routeWarning)}
|
|
339
348
|
/>
|
|
340
349
|
<Divider size={12} />
|
|
341
350
|
</>
|
|
@@ -374,6 +383,9 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
374
383
|
chain={requiredWallet}
|
|
375
384
|
isSelected={isSelected}
|
|
376
385
|
selectWallet={onChange}
|
|
386
|
+
multiWallets={config?.multiWallets ?? true}
|
|
387
|
+
supportedWallets={config?.wallets ?? []}
|
|
388
|
+
config={config}
|
|
377
389
|
limit={NUMBER_OF_WALLETS_TO_DISPLAY}
|
|
378
390
|
onShowMore={() =>
|
|
379
391
|
setShowMoreWalletFor(blockchain?.name ?? '')
|
|
@@ -381,7 +393,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
|
|
|
381
393
|
/>
|
|
382
394
|
</ListContainer>
|
|
383
395
|
{!isLastWallet && <Divider size={32} />}
|
|
384
|
-
{isLastWallet &&
|
|
396
|
+
{isLastWallet && customDestinationEnabled && (
|
|
385
397
|
<CustomDestination>
|
|
386
398
|
<CollapsibleRoot
|
|
387
399
|
ref={customDestinationRef}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WidgetConfig } from '../..';
|
|
2
|
+
import type { ConfirmSwap } from '../../hooks/useConfirmSwap';
|
|
2
3
|
|
|
3
4
|
export type PropTypes = {
|
|
4
5
|
open: boolean;
|
|
5
6
|
onClose: () => void;
|
|
6
7
|
onCancel: () => void;
|
|
7
8
|
onCheckBalance: ConfirmSwap['fetch'];
|
|
9
|
+
config?: WidgetConfig;
|
|
8
10
|
loading: boolean;
|
|
9
11
|
};
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
TIME_TO_CLOSE_MODAL,
|
|
24
24
|
TIME_TO_IGNORE_MODAL,
|
|
25
25
|
} from '../../pages/WalletsPage';
|
|
26
|
-
import {
|
|
26
|
+
import { useMetaStore } from '../../store/meta';
|
|
27
27
|
import { useWalletsStore } from '../../store/wallets';
|
|
28
28
|
import { getBlockchainDisplayNameFor } from '../../utils/meta';
|
|
29
29
|
import {
|
|
@@ -41,11 +41,10 @@ import {
|
|
|
41
41
|
} from './WalletList.styles';
|
|
42
42
|
|
|
43
43
|
export function WalletList(props: PropTypes) {
|
|
44
|
-
const { chain, isSelected, selectWallet, limit, onShowMore } = props;
|
|
45
|
-
const { config } = useAppStore();
|
|
44
|
+
const { config, chain, isSelected, selectWallet, limit, onShowMore } = props;
|
|
46
45
|
|
|
47
46
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
48
|
-
const { blockchains } =
|
|
47
|
+
const { blockchains } = useMetaStore.use.meta();
|
|
49
48
|
const [openWalletStateModal, setOpenWalletStateModal] =
|
|
50
49
|
useState<WalletType>('');
|
|
51
50
|
const [experimentalChainWallet, setExperimentalChainWallet] =
|
|
@@ -138,7 +137,7 @@ export function WalletList(props: PropTypes) {
|
|
|
138
137
|
});
|
|
139
138
|
const conciseAddress = address ? getConciseAddress(address) : '';
|
|
140
139
|
|
|
141
|
-
const experimentalChain = isExperimentalChain(blockchains
|
|
140
|
+
const experimentalChain = isExperimentalChain(blockchains, chain);
|
|
142
141
|
|
|
143
142
|
const experimentalChainNotAdded = !connectedWallets.find(
|
|
144
143
|
(connectedWallet) =>
|
|
@@ -181,7 +180,7 @@ export function WalletList(props: PropTypes) {
|
|
|
181
180
|
experimentalChainWallet?.chain
|
|
182
181
|
? getBlockchainDisplayNameFor(
|
|
183
182
|
experimentalChainWallet.chain,
|
|
184
|
-
blockchains
|
|
183
|
+
blockchains
|
|
185
184
|
)
|
|
186
185
|
: undefined;
|
|
187
186
|
return (
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { Wallet } from '../../types';
|
|
1
|
+
import type { Wallet, WidgetConfig } from '../../types';
|
|
2
2
|
|
|
3
3
|
export type PropTypes = {
|
|
4
4
|
chain: string;
|
|
5
|
+
supportedWallets: WidgetConfig['wallets'];
|
|
5
6
|
isSelected: (walletType: string, chain: string) => boolean;
|
|
6
7
|
selectWallet: (wallet: Wallet) => void;
|
|
8
|
+
multiWallets: boolean;
|
|
9
|
+
config?: WidgetConfig;
|
|
7
10
|
limit?: number;
|
|
8
11
|
onShowMore: () => void;
|
|
9
12
|
};
|
|
@@ -10,11 +10,11 @@ export const Container = styled('div', {
|
|
|
10
10
|
display: 'flex',
|
|
11
11
|
},
|
|
12
12
|
|
|
13
|
-
'.
|
|
13
|
+
'.route-summary': {
|
|
14
14
|
padding: '$15 $0',
|
|
15
15
|
},
|
|
16
16
|
|
|
17
|
-
'.
|
|
17
|
+
'.route-summary-item': {
|
|
18
18
|
display: 'flex',
|
|
19
19
|
justifyContent: 'space-between',
|
|
20
20
|
alignItems: 'center',
|
|
@@ -26,7 +26,7 @@ export const Container = styled('div', {
|
|
|
26
26
|
alignItems: 'center',
|
|
27
27
|
},
|
|
28
28
|
|
|
29
|
-
'.
|
|
29
|
+
'.route-summary-separator': {
|
|
30
30
|
width: '0px',
|
|
31
31
|
height: '$16',
|
|
32
32
|
borderLeft: '1px solid $neutral400',
|
|
@@ -6,8 +6,8 @@ import { Container, StepSeparator } from './LoadingSwapDetails.styles';
|
|
|
6
6
|
import { LoadingSwapDetailStep } from './LoadingSwapDetailStep';
|
|
7
7
|
|
|
8
8
|
export function LoadingSwapDetails() {
|
|
9
|
-
const
|
|
10
|
-
<div className="
|
|
9
|
+
const routeSummary = (
|
|
10
|
+
<div className="route-summary-item">
|
|
11
11
|
<div className="token-amount">
|
|
12
12
|
<ChainToken loading size="medium" chainImage="" tokenImage="" />
|
|
13
13
|
<Divider size={8} direction="horizontal" />
|
|
@@ -27,10 +27,10 @@ export function LoadingSwapDetails() {
|
|
|
27
27
|
<Skeleton width={60} height={10} variant="rounded" />
|
|
28
28
|
</div>
|
|
29
29
|
|
|
30
|
-
<div className="
|
|
31
|
-
{
|
|
32
|
-
<div className="
|
|
33
|
-
{
|
|
30
|
+
<div className="route-summary">
|
|
31
|
+
{routeSummary}
|
|
32
|
+
<div className="route-summary-separator"></div>
|
|
33
|
+
{routeSummary}
|
|
34
34
|
</div>
|
|
35
35
|
|
|
36
36
|
<div className="swaps-steps">
|
|
@@ -1,40 +1,33 @@
|
|
|
1
|
-
import type { Info } from './
|
|
1
|
+
import type { Info } from './NoRoutes.types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
|
|
5
5
|
import { errorMessages } from '../../constants/errors';
|
|
6
|
-
import {
|
|
7
|
-
type NoResultError,
|
|
8
|
-
QuoteErrorType,
|
|
9
|
-
type QuoteRequestFailed,
|
|
10
|
-
} from '../../types';
|
|
11
6
|
|
|
12
7
|
export function makeInfo(
|
|
13
|
-
|
|
8
|
+
diagnosisMessage: string | null,
|
|
14
9
|
disabledLiquiditySources: string[],
|
|
10
|
+
hasError: boolean,
|
|
15
11
|
toggleAllLiquiditySources: (shouldReset: boolean) => void,
|
|
16
|
-
|
|
12
|
+
refetchBestRoute: () => void
|
|
17
13
|
): Info {
|
|
18
|
-
if (
|
|
14
|
+
if (hasError) {
|
|
19
15
|
return {
|
|
20
16
|
alert: {
|
|
21
17
|
type: 'warning',
|
|
22
18
|
text: errorMessages().genericServerError,
|
|
23
19
|
action: {
|
|
24
|
-
onClick:
|
|
20
|
+
onClick: refetchBestRoute,
|
|
25
21
|
title: i18n.t('Retry'),
|
|
26
22
|
},
|
|
27
23
|
},
|
|
28
24
|
description: '',
|
|
29
25
|
};
|
|
30
|
-
} else if (
|
|
31
|
-
error?.type === QuoteErrorType.NO_RESULT &&
|
|
32
|
-
error.diagnosisMessage
|
|
33
|
-
) {
|
|
26
|
+
} else if (diagnosisMessage) {
|
|
34
27
|
return {
|
|
35
28
|
alert: {
|
|
36
29
|
type: 'error',
|
|
37
|
-
text:
|
|
30
|
+
text: diagnosisMessage,
|
|
38
31
|
action: null,
|
|
39
32
|
},
|
|
40
33
|
description: '',
|
|
@@ -54,6 +47,6 @@ export function makeInfo(
|
|
|
54
47
|
}
|
|
55
48
|
return {
|
|
56
49
|
alert: null,
|
|
57
|
-
description: errorMessages().
|
|
50
|
+
description: errorMessages().noRoutesError.description,
|
|
58
51
|
};
|
|
59
52
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PropTypes } from './
|
|
1
|
+
import type { PropTypes } from './NoRoutes.types';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
Alert,
|
|
@@ -11,25 +11,27 @@ import {
|
|
|
11
11
|
import React from 'react';
|
|
12
12
|
|
|
13
13
|
import { errorMessages } from '../../constants/errors';
|
|
14
|
-
import {
|
|
14
|
+
import { useMetaStore } from '../../store/meta';
|
|
15
15
|
import { useSettingsStore } from '../../store/settings';
|
|
16
16
|
|
|
17
|
-
import { makeInfo } from './
|
|
18
|
-
import { Container, Footer, PrefixIcon } from './
|
|
17
|
+
import { makeInfo } from './NoRoutes.helper';
|
|
18
|
+
import { Container, Footer, PrefixIcon } from './NoRoutes.styles';
|
|
19
19
|
|
|
20
|
-
export function
|
|
21
|
-
const { fetch, error } = props;
|
|
20
|
+
export function NoRoutes(props: PropTypes) {
|
|
21
|
+
const { diagnosisMessage, fetch, error } = props;
|
|
22
22
|
const disabledLiquiditySources =
|
|
23
23
|
useSettingsStore.use.disabledLiquiditySources();
|
|
24
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
24
25
|
const toggleAllLiquiditySources =
|
|
25
26
|
useSettingsStore.use.toggleAllLiquiditySources();
|
|
26
27
|
|
|
27
|
-
const
|
|
28
|
+
const hasError = error || loadingMetaStatus === 'failed';
|
|
28
29
|
|
|
29
30
|
const info = makeInfo(
|
|
30
|
-
|
|
31
|
+
diagnosisMessage ?? null,
|
|
31
32
|
disabledLiquiditySources,
|
|
32
|
-
|
|
33
|
+
hasError,
|
|
34
|
+
toggleAllLiquiditySources,
|
|
33
35
|
fetch
|
|
34
36
|
);
|
|
35
37
|
|
|
@@ -38,7 +40,7 @@ export function NoResult(props: PropTypes) {
|
|
|
38
40
|
<NoRouteIcon size={24} color="gray" />
|
|
39
41
|
<Divider size={4} />
|
|
40
42
|
<Typography variant="title" size="small">
|
|
41
|
-
{errorMessages().
|
|
43
|
+
{errorMessages().noRoutesError.title}
|
|
42
44
|
</Typography>
|
|
43
45
|
{!!info.description && (
|
|
44
46
|
<Typography
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NoRoutes } from './NoRoutes';
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import { useNavigate } from 'react-router-dom';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { useMetaStore } from '../../store/meta';
|
|
14
14
|
import { useNotificationStore } from '../../store/notification';
|
|
15
15
|
import { useUiStore } from '../../store/ui';
|
|
16
16
|
|
|
@@ -26,8 +26,7 @@ export function NotificationContent() {
|
|
|
26
26
|
const { getUnreadNotifications } = useNotificationStore();
|
|
27
27
|
|
|
28
28
|
const notifications: Notification[] = getUnreadNotifications();
|
|
29
|
-
const blockchains =
|
|
30
|
-
const tokens = useAppStore().tokens();
|
|
29
|
+
const { tokens, blockchains } = useMetaStore.use.meta();
|
|
31
30
|
const sortedNotification = notifications
|
|
32
31
|
.sort((a, b) => b.creationTime - a.creationTime)
|
|
33
32
|
.slice(0, MAX_NOTIFICATIONS_DISPLAYED);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { PropTypes } from './RouteErrors.types';
|
|
2
|
+
|
|
3
|
+
import { Alert, Divider, InfoIcon } from '@rango-dev/ui';
|
|
4
|
+
import React from 'react';
|
|
5
|
+
|
|
6
|
+
import { errorMessages } from '../../constants/errors';
|
|
7
|
+
import { useBestRouteStore } from '../../store/bestRoute';
|
|
8
|
+
import { hasLimitError, LimitErrorMessage } from '../../utils/swap';
|
|
9
|
+
|
|
10
|
+
import { Action, Alerts } from './RouteErrors.styles';
|
|
11
|
+
import { RouteErrorsModal } from './RouteErrorsModal';
|
|
12
|
+
|
|
13
|
+
const WARNING_LEVEL_LIMIT = -10;
|
|
14
|
+
|
|
15
|
+
export function RouteErrors(props: PropTypes) {
|
|
16
|
+
const { bestRoute } = useBestRouteStore();
|
|
17
|
+
const {
|
|
18
|
+
highValueLoss,
|
|
19
|
+
percentageChange,
|
|
20
|
+
priceImpactCanNotBeComputed,
|
|
21
|
+
openModal,
|
|
22
|
+
onToggle,
|
|
23
|
+
totalFeeInUsd,
|
|
24
|
+
outputUsdValue,
|
|
25
|
+
inputUsdValue,
|
|
26
|
+
loading,
|
|
27
|
+
extraSpace,
|
|
28
|
+
} = props;
|
|
29
|
+
const error = hasLimitError(bestRoute);
|
|
30
|
+
const { recommendation } = LimitErrorMessage(bestRoute);
|
|
31
|
+
|
|
32
|
+
const showWarnings = !error && (highValueLoss || priceImpactCanNotBeComputed);
|
|
33
|
+
const showAlerts = showWarnings || error;
|
|
34
|
+
|
|
35
|
+
return (
|
|
36
|
+
<>
|
|
37
|
+
{(loading || (extraSpace && !showAlerts)) && <Divider size={20} />}
|
|
38
|
+
{showAlerts && (
|
|
39
|
+
<Alerts>
|
|
40
|
+
{showWarnings && (
|
|
41
|
+
<>
|
|
42
|
+
<Alert
|
|
43
|
+
title={
|
|
44
|
+
highValueLoss
|
|
45
|
+
? errorMessages().highValueLossError.title
|
|
46
|
+
: errorMessages().unknownPriceError.title
|
|
47
|
+
}
|
|
48
|
+
type={
|
|
49
|
+
highValueLoss && !!percentageChange?.lt(WARNING_LEVEL_LIMIT)
|
|
50
|
+
? 'error'
|
|
51
|
+
: 'warning'
|
|
52
|
+
}
|
|
53
|
+
variant="alarm"
|
|
54
|
+
action={
|
|
55
|
+
<Action onClick={() => onToggle(true)}>
|
|
56
|
+
<InfoIcon size={12} color="gray" />
|
|
57
|
+
</Action>
|
|
58
|
+
}
|
|
59
|
+
/>
|
|
60
|
+
</>
|
|
61
|
+
)}
|
|
62
|
+
{error && (
|
|
63
|
+
<Alert type="error" variant="alarm" title={recommendation} />
|
|
64
|
+
)}
|
|
65
|
+
</Alerts>
|
|
66
|
+
)}
|
|
67
|
+
|
|
68
|
+
<RouteErrorsModal
|
|
69
|
+
highValueLoss={highValueLoss}
|
|
70
|
+
open={openModal}
|
|
71
|
+
onToggle={onToggle}
|
|
72
|
+
percentageChange={percentageChange}
|
|
73
|
+
inputUsdValue={inputUsdValue}
|
|
74
|
+
outputUsdValue={outputUsdValue}
|
|
75
|
+
totalFeeInUsd={totalFeeInUsd}
|
|
76
|
+
/>
|
|
77
|
+
</>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type BigNumber from 'bignumber.js';
|
|
2
|
+
|
|
3
|
+
export interface PropTypes {
|
|
4
|
+
openModal: boolean;
|
|
5
|
+
onToggle: (open: boolean) => void;
|
|
6
|
+
totalFeeInUsd: BigNumber | null;
|
|
7
|
+
outputUsdValue: BigNumber | null;
|
|
8
|
+
inputUsdValue: BigNumber | null;
|
|
9
|
+
percentageChange: BigNumber | null;
|
|
10
|
+
highValueLoss: boolean;
|
|
11
|
+
priceImpactCanNotBeComputed: boolean;
|
|
12
|
+
loading: boolean;
|
|
13
|
+
extraSpace: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
type ModalPropTypesKeys = keyof Omit<
|
|
17
|
+
PropTypes,
|
|
18
|
+
'priceImpactCanNotBeComputed' | 'openModal' | 'extraSpace' | 'loading'
|
|
19
|
+
>;
|
|
20
|
+
|
|
21
|
+
export type ModalPropTypes = Pick<PropTypes, ModalPropTypesKeys> & {
|
|
22
|
+
open: boolean;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export interface ModalContentData {
|
|
26
|
+
title: string;
|
|
27
|
+
value: string;
|
|
28
|
+
valueColor?: string;
|
|
29
|
+
}
|