@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
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import type { ModalPropTypes } from './RouteErrors.types';
|
|
2
|
+
|
|
3
|
+
import { i18n } from '@lingui/core';
|
|
4
|
+
import {
|
|
5
|
+
Button,
|
|
6
|
+
Divider,
|
|
7
|
+
MessageBox,
|
|
8
|
+
Modal,
|
|
9
|
+
Typography,
|
|
10
|
+
WarningIcon,
|
|
11
|
+
} from '@rango-dev/ui';
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { useNavigate } from 'react-router-dom';
|
|
14
|
+
|
|
15
|
+
import { errorMessages } from '../../constants/errors';
|
|
16
|
+
import { navigationRoutes } from '../../constants/navigationRoutes';
|
|
17
|
+
import {
|
|
18
|
+
GAS_FEE_MAX_DECIMALS,
|
|
19
|
+
GAS_FEE_MIN_DECIMALS,
|
|
20
|
+
HIGHT_PRICE_IMPACT,
|
|
21
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS,
|
|
22
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
23
|
+
USD_VALUE_MAX_DECIMALS,
|
|
24
|
+
USD_VALUE_MIN_DECIMALS,
|
|
25
|
+
} from '../../constants/routing';
|
|
26
|
+
import { numberToString } from '../../utils/numbers';
|
|
27
|
+
|
|
28
|
+
import { Flex } from './RouteErrors.styles';
|
|
29
|
+
import { RouteErrorsModalItem } from './RouteErrorsModalItem';
|
|
30
|
+
|
|
31
|
+
export function RouteErrorsModal(props: ModalPropTypes) {
|
|
32
|
+
const {
|
|
33
|
+
highValueLoss,
|
|
34
|
+
open,
|
|
35
|
+
onToggle,
|
|
36
|
+
percentageChange,
|
|
37
|
+
inputUsdValue,
|
|
38
|
+
outputUsdValue,
|
|
39
|
+
totalFeeInUsd,
|
|
40
|
+
} = props;
|
|
41
|
+
const navigate = useNavigate();
|
|
42
|
+
const type =
|
|
43
|
+
highValueLoss && !!percentageChange?.lt(HIGHT_PRICE_IMPACT)
|
|
44
|
+
? 'error'
|
|
45
|
+
: 'warning';
|
|
46
|
+
const highValueLossData = [
|
|
47
|
+
{
|
|
48
|
+
title: i18n.t('Swapping'),
|
|
49
|
+
value: numberToString(
|
|
50
|
+
inputUsdValue,
|
|
51
|
+
USD_VALUE_MIN_DECIMALS,
|
|
52
|
+
USD_VALUE_MAX_DECIMALS
|
|
53
|
+
),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: i18n.t('Gas cost'),
|
|
57
|
+
value: numberToString(
|
|
58
|
+
totalFeeInUsd,
|
|
59
|
+
GAS_FEE_MIN_DECIMALS,
|
|
60
|
+
GAS_FEE_MAX_DECIMALS
|
|
61
|
+
),
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: i18n.t('Receiving'),
|
|
65
|
+
value: numberToString(
|
|
66
|
+
outputUsdValue,
|
|
67
|
+
USD_VALUE_MIN_DECIMALS,
|
|
68
|
+
USD_VALUE_MAX_DECIMALS
|
|
69
|
+
),
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
title: i18n.t('Price impact'),
|
|
73
|
+
value: numberToString(
|
|
74
|
+
percentageChange,
|
|
75
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
76
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS
|
|
77
|
+
),
|
|
78
|
+
valueColor: `${type}500`,
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Modal
|
|
84
|
+
open={open}
|
|
85
|
+
onClose={() => onToggle(false)}
|
|
86
|
+
container={document.getElementById('swap-box') || document.body}>
|
|
87
|
+
{highValueLoss ? (
|
|
88
|
+
<MessageBox
|
|
89
|
+
type={type}
|
|
90
|
+
title={errorMessages().highValueLossError.impactTitle}
|
|
91
|
+
description={errorMessages().highValueLossError.description}
|
|
92
|
+
/>
|
|
93
|
+
) : (
|
|
94
|
+
<MessageBox
|
|
95
|
+
type={type}
|
|
96
|
+
title={errorMessages().unknownPriceError.impactTitle}
|
|
97
|
+
description={errorMessages().unknownPriceError.description}
|
|
98
|
+
/>
|
|
99
|
+
)}
|
|
100
|
+
{highValueLoss && (
|
|
101
|
+
<Flex>
|
|
102
|
+
<Divider size={20} />
|
|
103
|
+
<Typography size="small" variant="title">
|
|
104
|
+
{i18n.t('Details')}
|
|
105
|
+
</Typography>
|
|
106
|
+
<Flex>
|
|
107
|
+
{highValueLossData.map((item, index) => {
|
|
108
|
+
const key = index;
|
|
109
|
+
return <RouteErrorsModalItem key={key} {...item} />;
|
|
110
|
+
})}
|
|
111
|
+
</Flex>
|
|
112
|
+
</Flex>
|
|
113
|
+
)}
|
|
114
|
+
<Divider size={32} />
|
|
115
|
+
<Button
|
|
116
|
+
type="primary"
|
|
117
|
+
size="large"
|
|
118
|
+
prefix={<WarningIcon />}
|
|
119
|
+
fullWidth
|
|
120
|
+
onClick={() => {
|
|
121
|
+
navigate(navigationRoutes.confirmSwap);
|
|
122
|
+
}}>
|
|
123
|
+
{highValueLoss
|
|
124
|
+
? errorMessages().highValueLossError.confirmMessage
|
|
125
|
+
: errorMessages().unknownPriceError.confirmMessage}
|
|
126
|
+
</Button>
|
|
127
|
+
</Modal>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { ModalContentData } from './
|
|
1
|
+
import type { ModalContentData } from './RouteErrors.types';
|
|
2
2
|
|
|
3
3
|
import { Typography } from '@rango-dev/ui';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
|
|
6
|
-
import { Item } from './
|
|
6
|
+
import { Item } from './RouteErrors.styles';
|
|
7
7
|
|
|
8
|
-
export function
|
|
8
|
+
export function RouteErrorsModalItem(props: ModalContentData) {
|
|
9
9
|
const { title, value, valueColor } = props;
|
|
10
10
|
|
|
11
11
|
return (
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { RouteErrors } from './RouteErrors';
|
|
@@ -31,7 +31,7 @@ export function SwapDetailsPlaceholder(props: SwapDetailsPlaceholderPropTypes) {
|
|
|
31
31
|
noPadding
|
|
32
32
|
header={{
|
|
33
33
|
title: i18n.t('Swap and Bridge'),
|
|
34
|
-
onBack: (
|
|
34
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.swapDetails),
|
|
35
35
|
suffix: <SuffixContainer />,
|
|
36
36
|
}}>
|
|
37
37
|
{showSkeleton && (
|
|
@@ -13,7 +13,8 @@ import {
|
|
|
13
13
|
CopyIcon,
|
|
14
14
|
Divider,
|
|
15
15
|
IconButton,
|
|
16
|
-
|
|
16
|
+
RouteCost,
|
|
17
|
+
RouteSummary,
|
|
17
18
|
StepDetails,
|
|
18
19
|
Typography,
|
|
19
20
|
useCopyToClipboard,
|
|
@@ -34,17 +35,18 @@ import {
|
|
|
34
35
|
USD_VALUE_MIN_DECIMALS,
|
|
35
36
|
} from '../../constants/routing';
|
|
36
37
|
import { useNavigateBack } from '../../hooks/useNavigateBack';
|
|
37
|
-
import {
|
|
38
|
+
import { useBestRouteStore } from '../../store/bestRoute';
|
|
39
|
+
import { useMetaStore } from '../../store/meta';
|
|
38
40
|
import { useNotificationStore } from '../../store/notification';
|
|
39
|
-
import { useQuoteStore } from '../../store/quote';
|
|
40
41
|
import {
|
|
41
42
|
numberToString,
|
|
42
43
|
secondsToString,
|
|
43
44
|
totalArrivalTime,
|
|
44
45
|
} from '../../utils/numbers';
|
|
45
|
-
import {
|
|
46
|
+
import { getPriceImpactLevel } from '../../utils/routing';
|
|
46
47
|
import {
|
|
47
48
|
getLastConvertedTokenInFailedSwap,
|
|
49
|
+
getPercentageChange,
|
|
48
50
|
getSwapMessages,
|
|
49
51
|
shouldRetrySwap,
|
|
50
52
|
} from '../../utils/swap';
|
|
@@ -52,7 +54,6 @@ import { getSwapDate } from '../../utils/time';
|
|
|
52
54
|
import { getConciseAddress, getUsdPrice } from '../../utils/wallets';
|
|
53
55
|
import { SuffixContainer } from '../HeaderButtons/HeaderButtons.styles';
|
|
54
56
|
import { Layout } from '../Layout';
|
|
55
|
-
import { QuoteSummary } from '../Quote';
|
|
56
57
|
import {
|
|
57
58
|
SwapDetailsCompleteModal,
|
|
58
59
|
SwapDetailsModal,
|
|
@@ -64,9 +65,7 @@ import { Container, HeaderDetails, StepsList } from './SwapDetails.styles';
|
|
|
64
65
|
export function SwapDetails(props: SwapDetailsProps) {
|
|
65
66
|
const { swap, requestId, onDelete, onCancel: onCancelProps } = props;
|
|
66
67
|
const { canSwitchNetworkTo, connect, getWalletInfo } = useWallets();
|
|
67
|
-
const
|
|
68
|
-
const tokens = useAppStore().tokens();
|
|
69
|
-
const retry = useQuoteStore.use.retry();
|
|
68
|
+
const retry = useBestRouteStore.use.retry();
|
|
70
69
|
const navigate = useNavigate();
|
|
71
70
|
const { navigateBackFrom } = useNavigateBack();
|
|
72
71
|
const [_, handleCopy] = useCopyToClipboard(RESET_INTERVAL);
|
|
@@ -75,6 +74,9 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
75
74
|
const [showCompletedModal, setShowCompletedModal] = useState<
|
|
76
75
|
'success' | 'failed' | null
|
|
77
76
|
>(null);
|
|
77
|
+
const {
|
|
78
|
+
meta: { tokens, blockchains },
|
|
79
|
+
} = useMetaStore();
|
|
78
80
|
|
|
79
81
|
const onCancel = () => {
|
|
80
82
|
onCancelProps();
|
|
@@ -149,7 +151,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
149
151
|
showNetworkModal: currentStepNetworkStatus,
|
|
150
152
|
setNetworkModal: setModalState,
|
|
151
153
|
message: stepMessage,
|
|
152
|
-
blockchains
|
|
154
|
+
blockchains,
|
|
153
155
|
});
|
|
154
156
|
const numberOfSteps = steps.length;
|
|
155
157
|
const [firstStep, lastStep] = [swap.steps[0], swap.steps[numberOfSteps - 1]];
|
|
@@ -199,7 +201,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
199
201
|
USD_VALUE_MAX_DECIMALS
|
|
200
202
|
);
|
|
201
203
|
|
|
202
|
-
const percentageChange =
|
|
204
|
+
const percentageChange = getPercentageChange(inputUsdValue, outputUsdValue);
|
|
203
205
|
|
|
204
206
|
const completeModalDesc =
|
|
205
207
|
swap.status === 'success'
|
|
@@ -237,7 +239,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
237
239
|
noPadding
|
|
238
240
|
header={{
|
|
239
241
|
title: i18n.t('Swap and Bridge'),
|
|
240
|
-
onBack: (
|
|
242
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.swapDetails),
|
|
241
243
|
onCancel:
|
|
242
244
|
swap.status === 'running' ? () => setModalState('cancel') : undefined,
|
|
243
245
|
suffix: swap.status !== 'running' && (
|
|
@@ -263,7 +265,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
263
265
|
type="primary"
|
|
264
266
|
size="large"
|
|
265
267
|
onClick={() => {
|
|
266
|
-
retry(swap
|
|
268
|
+
retry(swap);
|
|
267
269
|
setTimeout(() => {
|
|
268
270
|
navigate(navigationRoutes.home);
|
|
269
271
|
}, 0);
|
|
@@ -300,7 +302,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
300
302
|
</HeaderDetails>
|
|
301
303
|
|
|
302
304
|
<div className="output">
|
|
303
|
-
<
|
|
305
|
+
<RouteCost
|
|
304
306
|
fee={numberToString(
|
|
305
307
|
String(totalFee),
|
|
306
308
|
GAS_FEE_MIN_DECIMALS,
|
|
@@ -309,7 +311,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
309
311
|
time={secondsToString(totalArrivalTime(swap.steps))}
|
|
310
312
|
steps={numberOfSteps}
|
|
311
313
|
/>
|
|
312
|
-
<
|
|
314
|
+
<RouteSummary
|
|
313
315
|
from={{
|
|
314
316
|
price: {
|
|
315
317
|
value: numberToString(
|
|
@@ -347,11 +349,13 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
347
349
|
},
|
|
348
350
|
}}
|
|
349
351
|
percentageChange={numberToString(
|
|
350
|
-
|
|
352
|
+
percentageChange,
|
|
351
353
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
352
354
|
PERCENTAGE_CHANGE_MAX_DECIMALS
|
|
353
355
|
)}
|
|
354
|
-
warningLevel={getPriceImpactLevel(
|
|
356
|
+
warningLevel={getPriceImpactLevel(
|
|
357
|
+
percentageChange?.toNumber() ?? 0
|
|
358
|
+
)}
|
|
355
359
|
/>
|
|
356
360
|
</div>
|
|
357
361
|
<div className="title-steps">
|
|
@@ -373,7 +377,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
373
377
|
<StepDetails
|
|
374
378
|
key={key}
|
|
375
379
|
step={step}
|
|
376
|
-
type="
|
|
380
|
+
type="route-progress"
|
|
377
381
|
ref={listRef}
|
|
378
382
|
state={state}
|
|
379
383
|
hasSeparator={index !== 0}
|
|
@@ -405,7 +409,7 @@ export function SwapDetails(props: SwapDetailsProps) {
|
|
|
405
409
|
)}
|
|
406
410
|
usdValue={outputUsdValue}
|
|
407
411
|
percentageChange={numberToString(
|
|
408
|
-
|
|
412
|
+
percentageChange,
|
|
409
413
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
410
414
|
PERCENTAGE_CHANGE_MAX_DECIMALS
|
|
411
415
|
)}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReverseIcon, styled } from '@rango-dev/ui';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { useBestRouteStore } from '../store/bestRoute';
|
|
5
5
|
|
|
6
6
|
const SwitchButtonContainer = styled('div', {
|
|
7
7
|
position: 'absolute',
|
|
@@ -27,7 +27,7 @@ const StyledButton = styled('div', {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
export function SwitchFromAndToButton() {
|
|
30
|
-
const switchFromAndTo =
|
|
30
|
+
const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
<SwitchButtonContainer>
|
|
@@ -21,7 +21,8 @@ import {
|
|
|
21
21
|
} from '@rango-dev/ui';
|
|
22
22
|
import React, { forwardRef, useEffect, useState } from 'react';
|
|
23
23
|
|
|
24
|
-
import { useAppStore } from '../../store/
|
|
24
|
+
import { useAppStore } from '../../store/app';
|
|
25
|
+
import { useMetaStore } from '../../store/meta';
|
|
25
26
|
import { useWalletsStore } from '../../store/wallets';
|
|
26
27
|
import { generateRangeColors } from '../../utils/colors';
|
|
27
28
|
|
|
@@ -86,10 +87,10 @@ export function TokenList(props: PropTypes) {
|
|
|
86
87
|
const { list, searchedFor = '', onChange, selectedBlockchain } = props;
|
|
87
88
|
|
|
88
89
|
const [tokens, setTokens] = useState<TokenWithBalance[]>(list);
|
|
89
|
-
const
|
|
90
|
-
const blockchains = useAppStore().blockchains();
|
|
90
|
+
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
91
91
|
const [hasNextPage, setHasNextPage] = useState<boolean>(true);
|
|
92
92
|
const loadingWallet = useWalletsStore.use.loading();
|
|
93
|
+
const { blockchains } = useMetaStore.use.meta();
|
|
93
94
|
const { isTokenPinned } = useAppStore();
|
|
94
95
|
|
|
95
96
|
// eslint-disable-next-line react/display-name
|
|
@@ -267,8 +268,8 @@ export function TokenList(props: PropTypes) {
|
|
|
267
268
|
{i18n.t('Select Token')}
|
|
268
269
|
</Typography>
|
|
269
270
|
<Divider size={4} />
|
|
270
|
-
{
|
|
271
|
-
{
|
|
271
|
+
{loadingStatus === 'loading' && <LoadingTokenList size={PAGE_SIZE} />}
|
|
272
|
+
{loadingStatus === 'success' && <List>{renderList()}</List>}
|
|
272
273
|
</Container>
|
|
273
274
|
);
|
|
274
275
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { WidgetConfig } from '../types';
|
|
2
|
+
|
|
1
3
|
import { useEffect, useRef } from 'react';
|
|
2
4
|
import {
|
|
3
5
|
createSearchParams,
|
|
@@ -8,32 +10,33 @@ import {
|
|
|
8
10
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
9
11
|
import { SearchParams } from '../constants/searchParams';
|
|
10
12
|
import { useSyncStoresWithConfig } from '../hooks/useSyncStoresWithConfig';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
+
import { useBestRouteStore } from '../store/bestRoute';
|
|
14
|
+
import { useMetaStore } from '../store/meta';
|
|
13
15
|
import { useUiStore } from '../store/ui';
|
|
14
|
-
import { searchParamsToToken } from '../utils/
|
|
16
|
+
import { searchParamsToToken } from '../utils/routing';
|
|
17
|
+
|
|
18
|
+
type Props = { config: WidgetConfig | undefined };
|
|
15
19
|
|
|
16
|
-
export function UpdateUrl() {
|
|
20
|
+
export function UpdateUrl(props: Props) {
|
|
17
21
|
const firstRender = useRef(true);
|
|
18
22
|
const [searchParams, setSearchParams] = useSearchParams();
|
|
19
23
|
const location = useLocation();
|
|
20
24
|
const firstRenderSearchParams = useRef(location.search);
|
|
21
25
|
const searchParamsRef = useRef<Record<string, string>>({});
|
|
22
|
-
const fromBlockchain =
|
|
23
|
-
const toBlockchain =
|
|
24
|
-
const fromToken =
|
|
25
|
-
const toToken =
|
|
26
|
-
const setFromBlockchain =
|
|
27
|
-
const setFromToken =
|
|
28
|
-
const setToBlockchain =
|
|
29
|
-
const setToToken =
|
|
30
|
-
const inputAmount =
|
|
31
|
-
const setInputAmount =
|
|
32
|
-
const
|
|
33
|
-
const blockchains =
|
|
34
|
-
const tokens = useAppStore().tokens();
|
|
26
|
+
const fromBlockchain = useBestRouteStore.use.fromBlockchain();
|
|
27
|
+
const toBlockchain = useBestRouteStore.use.toBlockchain();
|
|
28
|
+
const fromToken = useBestRouteStore.use.fromToken();
|
|
29
|
+
const toToken = useBestRouteStore.use.toToken();
|
|
30
|
+
const setFromBlockchain = useBestRouteStore.use.setFromBlockchain();
|
|
31
|
+
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
32
|
+
const setToBlockchain = useBestRouteStore.use.setToBlockchain();
|
|
33
|
+
const setToToken = useBestRouteStore.use.setToToken();
|
|
34
|
+
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
35
|
+
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
36
|
+
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
37
|
+
const { blockchains, tokens } = useMetaStore.use.meta();
|
|
35
38
|
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
36
|
-
useSyncStoresWithConfig();
|
|
39
|
+
useSyncStoresWithConfig(props.config);
|
|
37
40
|
|
|
38
41
|
useEffect(() => {
|
|
39
42
|
const params: Record<string, string> = {};
|
|
@@ -57,8 +60,7 @@ export function UpdateUrl() {
|
|
|
57
60
|
toChainString = '',
|
|
58
61
|
toTokenString = '',
|
|
59
62
|
fromAmount = '';
|
|
60
|
-
|
|
61
|
-
if (fetchMetaStatus !== 'success') {
|
|
63
|
+
if (loadingStatus !== 'success') {
|
|
62
64
|
fromChainString = searchParamsRef.current[SearchParams.FROM_CHAIN];
|
|
63
65
|
fromTokenString = searchParamsRef.current[SearchParams.FROM_TOKEN];
|
|
64
66
|
toChainString = searchParamsRef.current[SearchParams.TO_CHAIN];
|
|
@@ -92,9 +94,6 @@ export function UpdateUrl() {
|
|
|
92
94
|
...(fromAmount && {
|
|
93
95
|
[SearchParams.FROM_AMOUNT]: fromAmount.toString(),
|
|
94
96
|
}),
|
|
95
|
-
...(autoConnect && {
|
|
96
|
-
[SearchParams.AUTO_CONNECT]: autoConnect,
|
|
97
|
-
}),
|
|
98
97
|
},
|
|
99
98
|
{ replace: true }
|
|
100
99
|
);
|
|
@@ -110,7 +109,7 @@ export function UpdateUrl() {
|
|
|
110
109
|
]);
|
|
111
110
|
|
|
112
111
|
useEffect(() => {
|
|
113
|
-
if (
|
|
112
|
+
if (loadingStatus === 'success') {
|
|
114
113
|
const fromChainString = searchParams.get(SearchParams.FROM_CHAIN);
|
|
115
114
|
const fromTokenString = searchParams.get(SearchParams.FROM_TOKEN);
|
|
116
115
|
const toChainString = searchParams.get(SearchParams.TO_CHAIN);
|
|
@@ -135,29 +134,20 @@ export function UpdateUrl() {
|
|
|
135
134
|
if (!!fromBlockchain) {
|
|
136
135
|
setFromBlockchain(fromBlockchain);
|
|
137
136
|
if (!!fromToken) {
|
|
138
|
-
setFromToken(
|
|
139
|
-
token: fromToken,
|
|
140
|
-
meta: {
|
|
141
|
-
blockchains: blockchains,
|
|
142
|
-
tokens: tokens,
|
|
143
|
-
},
|
|
144
|
-
});
|
|
137
|
+
setFromToken(fromToken);
|
|
145
138
|
}
|
|
146
139
|
}
|
|
147
140
|
if (!!toBlockchain) {
|
|
148
141
|
setToBlockchain(toBlockchain);
|
|
149
142
|
if (!!toToken) {
|
|
150
|
-
setToToken(
|
|
151
|
-
token: toToken,
|
|
152
|
-
meta: { blockchains: blockchains, tokens: tokens },
|
|
153
|
-
});
|
|
143
|
+
setToToken(toToken);
|
|
154
144
|
}
|
|
155
145
|
}
|
|
156
146
|
if (fromAmount) {
|
|
157
147
|
setInputAmount(fromAmount);
|
|
158
148
|
}
|
|
159
149
|
}
|
|
160
|
-
}, [
|
|
150
|
+
}, [loadingStatus]);
|
|
161
151
|
|
|
162
152
|
return null;
|
|
163
153
|
}
|
|
@@ -8,13 +8,11 @@ import {
|
|
|
8
8
|
} from '@rango-dev/queue-manager-rango-preset';
|
|
9
9
|
import { useEffect } from 'react';
|
|
10
10
|
|
|
11
|
-
import { useAppStore } from '../store/AppStore';
|
|
12
11
|
import { useNotificationStore } from '../store/notification';
|
|
13
12
|
import { useWalletsStore } from '../store/wallets';
|
|
14
13
|
import { validBlockedStatuses } from '../types/notification';
|
|
15
14
|
|
|
16
15
|
export function WidgetEvents() {
|
|
17
|
-
const tokens = useAppStore().tokens();
|
|
18
16
|
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
19
17
|
const getWalletsDetails = useWalletsStore.use.getWalletsDetails();
|
|
20
18
|
const setNotification = useNotificationStore.use.setNotification();
|
|
@@ -40,8 +38,8 @@ export function WidgetEvents() {
|
|
|
40
38
|
(wallet) => wallet.chain === step?.toBlockchain
|
|
41
39
|
);
|
|
42
40
|
|
|
43
|
-
fromAccount && getWalletsDetails([fromAccount]
|
|
44
|
-
toAccount && getWalletsDetails([toAccount]
|
|
41
|
+
fromAccount && getWalletsDetails([fromAccount]);
|
|
42
|
+
toAccount && getWalletsDetails([toAccount]);
|
|
45
43
|
}
|
|
46
44
|
if (
|
|
47
45
|
(event.type === StepEventType.TX_EXECUTION_BLOCKED &&
|
package/src/constants/errors.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ConfirmSwapError } from '../types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { ConfirmSwapErrorTypes } from '../types';
|
|
6
6
|
|
|
7
7
|
export const errorMessages = () => {
|
|
8
8
|
return {
|
|
@@ -13,7 +13,7 @@ export const errorMessages = () => {
|
|
|
13
13
|
'You have limited the liquidity sources and this might result in Rango finding no routes. Please consider resetting your liquidity sources'
|
|
14
14
|
),
|
|
15
15
|
},
|
|
16
|
-
|
|
16
|
+
noRoutesError: {
|
|
17
17
|
title: i18n.t('No Routes Found'),
|
|
18
18
|
description: i18n.t(
|
|
19
19
|
"Reasons why Rango couldn't find a route: low liquidity on token, very low input amount or no routes available for the selected input/output token combination."
|
|
@@ -31,7 +31,7 @@ export const errorMessages = () => {
|
|
|
31
31
|
),
|
|
32
32
|
confirmMessage: i18n.t('Confirm High price impact'),
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
routeUpdatedWithHighValueLoss: {
|
|
35
35
|
title: i18n.t(
|
|
36
36
|
'Route updated and price impact is too high, try again later!'
|
|
37
37
|
),
|
|
@@ -47,12 +47,14 @@ export const errorMessages = () => {
|
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
49
|
|
|
50
|
-
export function
|
|
50
|
+
export function getConfirmSwapErrorMessage(error: ConfirmSwapError) {
|
|
51
51
|
switch (error.type) {
|
|
52
|
-
case
|
|
53
|
-
return error.diagnosisMessage ?? errorMessages().
|
|
54
|
-
case
|
|
52
|
+
case ConfirmSwapErrorTypes.NO_ROUTE:
|
|
53
|
+
return error.diagnosisMessage ?? errorMessages().noRoutesError.title;
|
|
54
|
+
case ConfirmSwapErrorTypes.REQUEST_FAILED:
|
|
55
55
|
return errorMessages().genericServerError;
|
|
56
|
+
case ConfirmSwapErrorTypes.ROUTE_UPDATED_WITH_HIGH_VALUE_LOSS:
|
|
57
|
+
return errorMessages().routeUpdatedWithHighValueLoss.title;
|
|
56
58
|
default:
|
|
57
59
|
return '';
|
|
58
60
|
}
|
|
@@ -5,6 +5,6 @@ export const swapButtonTitles = () => {
|
|
|
5
5
|
connectWallet: i18n.t('Connect Wallet'),
|
|
6
6
|
swap: i18n.t('Swap'),
|
|
7
7
|
swapAnyway: i18n.t('Swap anyway'),
|
|
8
|
-
|
|
8
|
+
ethRouteWarning: i18n.t('The route goes through Ethereum. Continue?'),
|
|
9
9
|
};
|
|
10
10
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RouteWarning } from '../types';
|
|
2
2
|
|
|
3
3
|
import { i18n } from '@lingui/core';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { RouteWarningType } from '../types';
|
|
6
6
|
|
|
7
|
-
export function
|
|
7
|
+
export function getRouteWarningMessage(warning: RouteWarning) {
|
|
8
8
|
switch (warning.type) {
|
|
9
|
-
case
|
|
9
|
+
case RouteWarningType.ROUTE_UPDATED:
|
|
10
10
|
return i18n.t('Route has been updated.');
|
|
11
|
-
case
|
|
11
|
+
case RouteWarningType.ROUTE_AND_OUTPUT_AMOUNT_UPDATED:
|
|
12
12
|
return i18n.t(
|
|
13
13
|
'Output amount changed to {newOutputAmount} ({percentageChange}% change).',
|
|
14
14
|
{
|
|
@@ -16,9 +16,9 @@ export function getQuoteUpdateWarningMessage(warning: QuoteUpdateWarning) {
|
|
|
16
16
|
percentageChange: warning.percentageChange,
|
|
17
17
|
}
|
|
18
18
|
);
|
|
19
|
-
case
|
|
19
|
+
case RouteWarningType.ROUTE_SWAPPERS_UPDATED:
|
|
20
20
|
return i18n.t('Route swappers has been updated.');
|
|
21
|
-
case
|
|
21
|
+
case RouteWarningType.ROUTE_COINS_UPDATED:
|
|
22
22
|
return i18n.t('Route internal coins has been updated.');
|
|
23
23
|
default:
|
|
24
24
|
return '';
|