@rango-dev/widget-embedded 0.12.1-next.9 → 0.13.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 +55 -0
- package/dist/Widget.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +5 -2
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.helpers.d.ts.map +1 -1
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts +14 -4
- package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.d.ts.map +1 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +6 -1
- package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.helpers.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +94 -17
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +18 -3
- package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +25 -284
- package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +1 -0
- package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/HeaderButtons/UnreadNotificationsBadge.d.ts.map +1 -1
- package/dist/components/HeaderButtons/WalletButton.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.styles.d.ts +18 -3
- package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +6 -1
- package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetailStep.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts +3 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.d.ts.map +1 -0
- package/dist/components/{SelectableCategoryList/SelectableCategoryList.styles.d.ts → LoadingSwapDetails/LoadingSwapDetails.styles.d.ts} +21 -6
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts +4 -0
- package/dist/components/LoadingSwapDetails/LoadingSwapDetails.types.d.ts.map +1 -0
- package/dist/components/LoadingSwapDetails/index.d.ts +2 -0
- package/dist/components/LoadingSwapDetails/index.d.ts.map +1 -0
- package/dist/components/NoRoutes/NoRoutes.helper.d.ts.map +1 -1
- package/dist/components/NoRoutes/NoRoutes.styles.d.ts +18 -3
- package/dist/components/NoRoutes/NoRoutes.styles.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts +24 -4
- package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts +24 -4
- package/dist/components/RouteErrors/RouteErrors.styles.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrors.types.d.ts +3 -1
- package/dist/components/RouteErrors/RouteErrors.types.d.ts.map +1 -1
- package/dist/components/RouteErrors/RouteErrorsModal.d.ts.map +1 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts +6 -1
- package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +23 -151
- package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
- package/dist/components/SettingsContainer/index.d.ts +1 -1
- package/dist/components/SettingsContainer/index.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.styles.d.ts +24 -4
- package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +2 -9
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts +35 -153
- package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
- package/dist/components/SwapDetails/SwapDetails.types.d.ts +1 -1
- package/dist/components/SwapDetails/SwapDetails.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +6 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +2 -1
- package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.WalletState.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +6 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +2 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +24 -4
- package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
- package/dist/components/SwitchFromAndTo.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts +207 -9
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +1 -1
- package/dist/components/TokenList/TokenList.types.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/WalletModal/WalletModalContent.styles.d.ts +24 -4
- package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.d.ts +2 -2
- package/dist/constants/routing.d.ts +12 -2
- package/dist/constants/routing.d.ts.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/globalStyles.d.ts +1 -1
- package/dist/globalStyles.d.ts.map +1 -1
- package/dist/hooks/useNavigateBack.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList.d.ts +18 -0
- package/dist/hooks/usePrepareBlockchainList.d.ts.map +1 -0
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +3 -0
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts +3 -6
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletProviders.d.ts +3 -3
- package/dist/hooks/useWalletProviders.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts +1 -2
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts +1 -5
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/services/httpService.d.ts +0 -1
- package/dist/services/httpService.d.ts.map +1 -1
- package/dist/store/app.d.ts +26 -0
- package/dist/store/app.d.ts.map +1 -0
- package/dist/store/bestRoute.d.ts +4 -8
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/meta.d.ts +0 -2
- package/dist/store/meta.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +8 -0
- package/dist/store/slices/config.d.ts.map +1 -0
- package/dist/store/slices/data.d.ts +26 -0
- package/dist/store/slices/data.d.ts.map +1 -0
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +3 -0
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/common.d.ts +1 -0
- package/dist/utils/common.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +5 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +1 -0
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/numbers.d.ts +3 -1
- package/dist/utils/numbers.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +6 -3
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +1 -0
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +2 -2
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +8 -8
- package/readme.md +3 -1
- package/src/Widget.tsx +22 -3
- package/src/components/AppRouter.tsx +38 -7
- package/src/components/AppRoutes.tsx +4 -28
- package/src/components/BlockchainList/BlockchainList.helpers.ts +1 -1
- package/src/components/BlockchainList/BlockchainList.styles.ts +6 -5
- package/src/components/BlockchainList/BlockchainList.tsx +6 -9
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +29 -42
- package/src/components/ConfirmWalletsModal/ConfirmWallets.helpers.ts +33 -7
- package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +48 -7
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +59 -16
- package/src/components/ConfirmWalletsModal/WalletList.tsx +66 -22
- package/src/components/HeaderButtons/HeaderButtons.styles.ts +2 -2
- package/src/components/HeaderButtons/HeaderButtons.types.ts +1 -0
- package/src/components/HeaderButtons/HomeButtons.tsx +18 -5
- package/src/components/HeaderButtons/UnreadNotificationsBadge.tsx +1 -2
- package/src/components/HeaderButtons/WalletButton.tsx +4 -1
- package/src/components/Layout/Layout.styles.ts +5 -3
- package/src/components/Layout/Layout.tsx +5 -20
- package/src/components/LoadingSwapDetails/LoadingSwapDetailStep.tsx +41 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.styles.ts +78 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.tsx +53 -0
- package/src/components/LoadingSwapDetails/LoadingSwapDetails.types.ts +3 -0
- package/src/components/LoadingSwapDetails/index.ts +1 -0
- package/src/components/NoRoutes/NoRoutes.helper.ts +4 -2
- package/src/components/NotificationContent/NotificationContent.tsx +3 -7
- package/src/components/RouteErrors/RouteErrors.styles.ts +2 -1
- package/src/components/RouteErrors/RouteErrors.tsx +37 -26
- package/src/components/RouteErrors/RouteErrors.types.ts +3 -1
- package/src/components/RouteErrors/RouteErrorsModal.tsx +42 -14
- package/src/components/SettingsContainer/SettingsContainer.style.ts +2 -7
- package/src/components/SettingsContainer/index.ts +0 -1
- package/src/components/Slippage/Slippage.tsx +6 -2
- package/src/components/Slippage/SlippageTooltipContent.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +52 -16
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +19 -33
- package/src/components/SwapDetails/SwapDetails.styles.ts +10 -14
- package/src/components/SwapDetails/SwapDetails.tsx +143 -101
- package/src/components/SwapDetails/SwapDetails.types.ts +1 -1
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +5 -4
- package/src/components/SwapDetailsModal/SwapDetailsModal.WalletState.tsx +6 -7
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +3 -0
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +2 -1
- package/src/components/SwapsGroup/SwapsGroup.tsx +3 -2
- package/src/components/SwitchFromAndTo.tsx +1 -35
- package/src/components/TokenList/TokenList.helpers.ts +6 -8
- package/src/components/TokenList/TokenList.styles.ts +7 -1
- package/src/components/TokenList/TokenList.tsx +29 -23
- package/src/components/TokenList/TokenList.types.ts +1 -1
- package/src/components/UpdateUrl.tsx +7 -1
- package/src/components/WidgetEvents.tsx +9 -3
- package/src/constants/errors.ts +2 -2
- package/src/constants/routing.ts +17 -2
- package/src/constants.ts +1 -0
- package/src/globalStyles.ts +1 -4
- package/src/hooks/useFetchBestRoute.ts +2 -2
- package/src/hooks/useNavigateBack.ts +10 -0
- package/src/hooks/usePrepareBlockchainList.ts +125 -0
- package/src/hooks/useSwapInput.ts +17 -3
- package/src/hooks/useSyncStoresWithConfig.ts +102 -0
- package/src/hooks/useTheme.ts +37 -75
- package/src/hooks/useWalletProviders.ts +7 -7
- package/src/pages/ConfirmSwapPage.tsx +65 -36
- package/src/pages/HistoryPage.tsx +2 -2
- package/src/pages/Home.tsx +114 -50
- package/src/pages/LanguagePage.tsx +1 -1
- package/src/pages/LiquiditySourcePage.tsx +22 -18
- package/src/pages/SelectBlockchainPage.tsx +19 -20
- package/src/pages/SelectSwapItemsPage.tsx +66 -88
- package/src/pages/SettingsPage.tsx +42 -15
- package/src/pages/SwapDetailsPage.tsx +9 -2
- package/src/pages/ThemePage.tsx +1 -1
- package/src/pages/WalletsPage.tsx +11 -5
- package/src/services/httpService.ts +4 -5
- package/src/store/app.ts +15 -0
- package/src/store/bestRoute.ts +45 -71
- package/src/store/meta.ts +11 -29
- package/src/store/slices/config.ts +26 -0
- package/src/store/slices/data.ts +203 -0
- package/src/store/wallets.ts +0 -27
- package/src/types/config.ts +3 -0
- package/src/utils/common.ts +3 -0
- package/src/utils/configs.ts +8 -2
- package/src/utils/meta.ts +7 -0
- package/src/utils/numbers.ts +3 -2
- package/src/utils/routing.ts +76 -14
- package/src/utils/settings.ts +15 -0
- package/src/utils/swap.ts +82 -26
- package/src/utils/time.ts +69 -36
- package/src/utils/wallets.ts +49 -29
- package/dist/components/BlockchainsChip/BlockchainsChip.d.ts +0 -5
- package/dist/components/BlockchainsChip/BlockchainsChip.d.ts.map +0 -1
- package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts +0 -151
- package/dist/components/BlockchainsChip/BlockchainsChip.styles.d.ts.map +0 -1
- package/dist/components/BlockchainsChip/BlockchainsChip.types.d.ts +0 -6
- package/dist/components/BlockchainsChip/BlockchainsChip.types.d.ts.map +0 -1
- package/dist/components/BlockchainsChip/index.d.ts +0 -2
- package/dist/components/BlockchainsChip/index.d.ts.map +0 -1
- package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts +0 -3
- package/dist/components/BlockchainsSection/BlockchainSection.helpers.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.d.ts +0 -4
- package/dist/components/SelectableCategoryList/SelectableCategoryList.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts +0 -4
- package/dist/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/SelectableCategoryList.types.d.ts +0 -12
- package/dist/components/SelectableCategoryList/SelectableCategoryList.types.d.ts.map +0 -1
- package/dist/components/SelectableCategoryList/index.d.ts +0 -2
- package/dist/components/SelectableCategoryList/index.d.ts.map +0 -1
- package/src/components/BlockchainsChip/BlockchainsChip.styles.ts +0 -30
- package/src/components/BlockchainsChip/BlockchainsChip.tsx +0 -15
- package/src/components/BlockchainsChip/BlockchainsChip.types.ts +0 -4
- package/src/components/BlockchainsChip/index.ts +0 -1
- package/src/components/BlockchainsSection/BlockchainSection.helpers.ts +0 -20
- package/src/components/SelectableCategoryList/SelectableCategoryList.helpers.ts +0 -20
- package/src/components/SelectableCategoryList/SelectableCategoryList.styles.ts +0 -21
- package/src/components/SelectableCategoryList/SelectableCategoryList.tsx +0 -79
- package/src/components/SelectableCategoryList/SelectableCategoryList.types.ts +0 -12
- package/src/components/SelectableCategoryList/index.ts +0 -1
package/src/pages/Home.tsx
CHANGED
|
@@ -22,18 +22,32 @@ import { RouteErrors } from '../components/RouteErrors';
|
|
|
22
22
|
import { SwitchFromAndToButton } from '../components/SwitchFromAndTo';
|
|
23
23
|
import { errorMessages } from '../constants/errors';
|
|
24
24
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
25
|
+
import {
|
|
26
|
+
BALANCE_MAX_DECIMALS,
|
|
27
|
+
BALANCE_MIN_DECIMALS,
|
|
28
|
+
GAS_FEE_MAX_DECIMALS,
|
|
29
|
+
GAS_FEE_MIN_DECIMALS,
|
|
30
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS,
|
|
31
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
32
|
+
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
33
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
34
|
+
USD_VALUE_MAX_DECIMALS,
|
|
35
|
+
USD_VALUE_MIN_DECIMALS,
|
|
36
|
+
} from '../constants/routing';
|
|
25
37
|
import { useSwapInput } from '../hooks/useSwapInput';
|
|
26
38
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
27
39
|
import { useMetaStore } from '../store/meta';
|
|
28
40
|
import { useUiStore } from '../store/ui';
|
|
29
41
|
import { useWalletsStore } from '../store/wallets';
|
|
30
42
|
import { ButtonState } from '../types';
|
|
43
|
+
import { getContainer } from '../utils/common';
|
|
44
|
+
import { getBlockchainShortNameFor } from '../utils/meta';
|
|
31
45
|
import {
|
|
32
46
|
numberToString,
|
|
33
47
|
secondsToString,
|
|
34
48
|
totalArrivalTime,
|
|
35
49
|
} from '../utils/numbers';
|
|
36
|
-
import {
|
|
50
|
+
import { getFormattedBestRoute, getPriceImpactLevel } from '../utils/routing';
|
|
37
51
|
import {
|
|
38
52
|
canComputePriceImpact,
|
|
39
53
|
getOutputRatio,
|
|
@@ -77,12 +91,6 @@ const FooterAlert = styled('div', {
|
|
|
77
91
|
display: 'flex',
|
|
78
92
|
});
|
|
79
93
|
|
|
80
|
-
const BALANCE_PRECISION = 8;
|
|
81
|
-
const TWO_DECIMAL = 2;
|
|
82
|
-
const MAX_DECIMAL = 6;
|
|
83
|
-
const MIN_DECIMAL = 0;
|
|
84
|
-
const WARNING_LEVEL_LIMIT = -10;
|
|
85
|
-
|
|
86
94
|
export function Home() {
|
|
87
95
|
const navigate = useNavigate();
|
|
88
96
|
const {
|
|
@@ -105,7 +113,7 @@ export function Home() {
|
|
|
105
113
|
} = useBestRouteStore();
|
|
106
114
|
|
|
107
115
|
const {
|
|
108
|
-
meta: { tokens },
|
|
116
|
+
meta: { tokens, blockchains },
|
|
109
117
|
loadingStatus: loadingMetaStatus,
|
|
110
118
|
} = useMetaStore();
|
|
111
119
|
|
|
@@ -160,7 +168,8 @@ export function Home() {
|
|
|
160
168
|
fromToken?.symbol,
|
|
161
169
|
fromToken?.address
|
|
162
170
|
)?.amount || '0',
|
|
163
|
-
|
|
171
|
+
BALANCE_MIN_DECIMALS,
|
|
172
|
+
BALANCE_MAX_DECIMALS
|
|
164
173
|
)
|
|
165
174
|
: '0';
|
|
166
175
|
|
|
@@ -202,20 +211,26 @@ export function Home() {
|
|
|
202
211
|
from: {
|
|
203
212
|
token: { displayName: swap.from.symbol, image: swap.from.logo },
|
|
204
213
|
chain: {
|
|
205
|
-
displayName:
|
|
214
|
+
displayName:
|
|
215
|
+
getBlockchainShortNameFor(swap.from.blockchain, blockchains) ?? '',
|
|
206
216
|
image: swap.from.blockchainLogo,
|
|
207
217
|
},
|
|
208
218
|
price: {
|
|
209
219
|
value:
|
|
210
220
|
index === 0
|
|
211
|
-
? numberToString(
|
|
221
|
+
? numberToString(
|
|
222
|
+
inputAmount,
|
|
223
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
224
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
225
|
+
)
|
|
212
226
|
: swap.fromAmount,
|
|
213
227
|
},
|
|
214
228
|
},
|
|
215
229
|
to: {
|
|
216
230
|
token: { displayName: swap.to.symbol, image: swap.to.logo },
|
|
217
231
|
chain: {
|
|
218
|
-
displayName:
|
|
232
|
+
displayName:
|
|
233
|
+
getBlockchainShortNameFor(swap.to.blockchain, blockchains) ?? '',
|
|
219
234
|
image: swap.to.blockchainLogo,
|
|
220
235
|
},
|
|
221
236
|
price: {
|
|
@@ -239,9 +254,18 @@ export function Home() {
|
|
|
239
254
|
</Typography>
|
|
240
255
|
<Divider direction="horizontal" size={8} />
|
|
241
256
|
<Typography size="xsmall" variant="body" color="neutral900">
|
|
242
|
-
{
|
|
243
|
-
|
|
244
|
-
|
|
257
|
+
{i18n.t({
|
|
258
|
+
id: 'yourSymbol',
|
|
259
|
+
message: 'Yours: {amount} {symbol}',
|
|
260
|
+
values: {
|
|
261
|
+
amount: numberToString(
|
|
262
|
+
swapHasError?.fromAmount || null,
|
|
263
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
264
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
265
|
+
),
|
|
266
|
+
symbol: swap?.from.symbol,
|
|
267
|
+
},
|
|
268
|
+
})}
|
|
245
269
|
</Typography>
|
|
246
270
|
</FooterAlert>
|
|
247
271
|
}
|
|
@@ -253,7 +277,7 @@ export function Home() {
|
|
|
253
277
|
|
|
254
278
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
255
279
|
|
|
256
|
-
const bestRouteData =
|
|
280
|
+
const bestRouteData = getFormattedBestRoute(bestRoute);
|
|
257
281
|
|
|
258
282
|
return (
|
|
259
283
|
<Layout
|
|
@@ -300,7 +324,8 @@ export function Home() {
|
|
|
300
324
|
<InputsContainer>
|
|
301
325
|
<FromContainer>
|
|
302
326
|
<SwapInput
|
|
303
|
-
label=
|
|
327
|
+
label={i18n.t('From')}
|
|
328
|
+
mode="From"
|
|
304
329
|
onInputChange={setInputAmount}
|
|
305
330
|
balance={tokenBalance}
|
|
306
331
|
chain={{
|
|
@@ -316,9 +341,13 @@ export function Home() {
|
|
|
316
341
|
value: inputAmount,
|
|
317
342
|
usdValue: priceImpactInputCanNotBeComputed
|
|
318
343
|
? undefined
|
|
319
|
-
: numberToString(
|
|
344
|
+
: numberToString(
|
|
345
|
+
inputUsdValue,
|
|
346
|
+
USD_VALUE_MIN_DECIMALS,
|
|
347
|
+
USD_VALUE_MAX_DECIMALS
|
|
348
|
+
),
|
|
320
349
|
error: priceImpactInputCanNotBeComputed
|
|
321
|
-
? errorMessages.unknownPriceError.
|
|
350
|
+
? errorMessages.unknownPriceError.impactTitle
|
|
322
351
|
: undefined,
|
|
323
352
|
}}
|
|
324
353
|
disabled={loadingMetaStatus === 'failed'}
|
|
@@ -333,7 +362,8 @@ export function Home() {
|
|
|
333
362
|
</FromContainer>
|
|
334
363
|
<SwapInput
|
|
335
364
|
sharpBottomStyle={!!bestRoute?.result || fetchingBestRoute}
|
|
336
|
-
label=
|
|
365
|
+
label={i18n.t('To')}
|
|
366
|
+
mode="To"
|
|
337
367
|
chain={{
|
|
338
368
|
displayName: toBlockchain?.displayName || '',
|
|
339
369
|
image: toBlockchain?.logo || '',
|
|
@@ -344,19 +374,31 @@ export function Home() {
|
|
|
344
374
|
}}
|
|
345
375
|
percentageChange={
|
|
346
376
|
!!percentageChange?.lt(0)
|
|
347
|
-
? numberToString(
|
|
377
|
+
? numberToString(
|
|
378
|
+
percentageChange,
|
|
379
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
380
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS
|
|
381
|
+
)
|
|
348
382
|
: null
|
|
349
383
|
}
|
|
350
|
-
warningLevel={
|
|
351
|
-
|
|
352
|
-
}
|
|
384
|
+
warningLevel={getPriceImpactLevel(
|
|
385
|
+
percentageChange?.toNumber() ?? 0
|
|
386
|
+
)}
|
|
353
387
|
price={{
|
|
354
|
-
value: numberToString(
|
|
388
|
+
value: numberToString(
|
|
389
|
+
outputAmount,
|
|
390
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
391
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
392
|
+
),
|
|
355
393
|
usdValue: priceImpactOutputCanNotBeComputed
|
|
356
394
|
? undefined
|
|
357
|
-
: numberToString(
|
|
395
|
+
: numberToString(
|
|
396
|
+
outputUsdValue,
|
|
397
|
+
USD_VALUE_MIN_DECIMALS,
|
|
398
|
+
USD_VALUE_MAX_DECIMALS
|
|
399
|
+
),
|
|
358
400
|
error: priceImpactOutputCanNotBeComputed
|
|
359
|
-
? errorMessages.unknownPriceError.
|
|
401
|
+
? errorMessages.unknownPriceError.impactTitle
|
|
360
402
|
: undefined,
|
|
361
403
|
}}
|
|
362
404
|
onClickToken={() => navigate('to-swap')}
|
|
@@ -376,22 +418,45 @@ export function Home() {
|
|
|
376
418
|
<BestRoute
|
|
377
419
|
type="basic"
|
|
378
420
|
recommended={true}
|
|
421
|
+
tooltipContainer={getContainer()}
|
|
379
422
|
input={{
|
|
380
|
-
value: numberToString(
|
|
381
|
-
|
|
423
|
+
value: numberToString(
|
|
424
|
+
inputAmount,
|
|
425
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
426
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
427
|
+
),
|
|
428
|
+
usdValue: numberToString(
|
|
429
|
+
inputUsdValue,
|
|
430
|
+
USD_VALUE_MIN_DECIMALS,
|
|
431
|
+
USD_VALUE_MAX_DECIMALS
|
|
432
|
+
),
|
|
382
433
|
}}
|
|
383
434
|
output={{
|
|
384
|
-
value: numberToString(
|
|
385
|
-
|
|
435
|
+
value: numberToString(
|
|
436
|
+
outputAmount,
|
|
437
|
+
TOKEN_AMOUNT_MIN_DECIMALS,
|
|
438
|
+
TOKEN_AMOUNT_MAX_DECIMALS
|
|
439
|
+
),
|
|
440
|
+
usdValue: numberToString(
|
|
441
|
+
outputUsdValue,
|
|
442
|
+
USD_VALUE_MIN_DECIMALS,
|
|
443
|
+
USD_VALUE_MAX_DECIMALS
|
|
444
|
+
),
|
|
386
445
|
}}
|
|
387
446
|
steps={getBestRouteSteps(bestRouteData.result.swaps)}
|
|
388
447
|
percentageChange={numberToString(
|
|
389
448
|
percentageChange,
|
|
390
|
-
|
|
391
|
-
|
|
449
|
+
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
450
|
+
PERCENTAGE_CHANGE_MAX_DECIMALS
|
|
451
|
+
)}
|
|
452
|
+
totalFee={numberToString(
|
|
453
|
+
totalFeeInUsd,
|
|
454
|
+
GAS_FEE_MIN_DECIMALS,
|
|
455
|
+
GAS_FEE_MAX_DECIMALS
|
|
456
|
+
)}
|
|
457
|
+
totalTime={secondsToString(
|
|
458
|
+
totalArrivalTime(bestRoute?.result?.swaps)
|
|
392
459
|
)}
|
|
393
|
-
totalFee={numberToString(totalFeeInUsd, MIN_DECIMAL, TWO_DECIMAL)}
|
|
394
|
-
totalTime={secondsToString(totalArrivalTime(bestRoute))}
|
|
395
460
|
/>
|
|
396
461
|
</BestRouteContainer>
|
|
397
462
|
) : showBestRoute && !fetchingBestRoute ? (
|
|
@@ -405,21 +470,20 @@ export function Home() {
|
|
|
405
470
|
</>
|
|
406
471
|
) : null}
|
|
407
472
|
</Container>
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
)}
|
|
473
|
+
<RouteErrors
|
|
474
|
+
openModal={openWarningModal}
|
|
475
|
+
onToggle={setOpenWarningModal}
|
|
476
|
+
totalFeeInUsd={totalFeeInUsd}
|
|
477
|
+
outputUsdValue={outputUsdValue}
|
|
478
|
+
inputUsdValue={inputUsdValue}
|
|
479
|
+
percentageChange={percentageChange}
|
|
480
|
+
highValueLoss={highValueLoss}
|
|
481
|
+
priceImpactCanNotBeComputed={
|
|
482
|
+
priceImpactInputCanNotBeComputed || priceImpactOutputCanNotBeComputed
|
|
483
|
+
}
|
|
484
|
+
loading={fetchingBestRoute || loadingMetaStatus === 'loading'}
|
|
485
|
+
extraSpace={!!bestRoute?.result || !bestRoute}
|
|
486
|
+
/>
|
|
423
487
|
</Layout>
|
|
424
488
|
);
|
|
425
489
|
}
|
|
@@ -18,7 +18,6 @@ import { Layout } from '../components/Layout';
|
|
|
18
18
|
import { LoadingLiquiditySourceList } from '../components/LoadingLiquiditySourceList';
|
|
19
19
|
import { SearchInput } from '../components/SearchInput';
|
|
20
20
|
import {
|
|
21
|
-
LiquiditySourceDivider,
|
|
22
21
|
LiquiditySourceList,
|
|
23
22
|
LiquiditySourceSuffix,
|
|
24
23
|
NotFoundContainer,
|
|
@@ -29,7 +28,10 @@ import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
|
29
28
|
import { useMetaStore } from '../store/meta';
|
|
30
29
|
import { useSettingsStore } from '../store/settings';
|
|
31
30
|
import { containsText } from '../utils/numbers';
|
|
32
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
getUniqueSwappersGroups,
|
|
33
|
+
sortLiquiditySourcesByGroupTitle,
|
|
34
|
+
} from '../utils/settings';
|
|
33
35
|
|
|
34
36
|
interface PropTypes {
|
|
35
37
|
supportedSwappers?: string[];
|
|
@@ -77,20 +79,22 @@ export function LiquiditySourcePage({
|
|
|
77
79
|
});
|
|
78
80
|
};
|
|
79
81
|
|
|
80
|
-
const list = liquiditySources
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
+
});
|
|
94
98
|
|
|
95
99
|
const searchHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
96
100
|
const value = event.target.value;
|
|
@@ -124,7 +128,7 @@ export function LiquiditySourcePage({
|
|
|
124
128
|
fullWidth
|
|
125
129
|
color="light"
|
|
126
130
|
variant="contained"
|
|
127
|
-
placeholder={i18n.t('
|
|
131
|
+
placeholder={i18n.t('Search {sourceType}', { sourceType })}
|
|
128
132
|
onChange={searchHandler}
|
|
129
133
|
/>
|
|
130
134
|
{loadingMetaStatus === 'loading' && <LoadingLiquiditySourceList />}
|
|
@@ -146,8 +150,8 @@ export function LiquiditySourcePage({
|
|
|
146
150
|
style={{ height: '61px' }}
|
|
147
151
|
{...sourceItem}
|
|
148
152
|
selected={false}
|
|
153
|
+
hasDivider
|
|
149
154
|
/>
|
|
150
|
-
<LiquiditySourceDivider />
|
|
151
155
|
</React.Fragment>
|
|
152
156
|
);
|
|
153
157
|
})}
|
|
@@ -1,50 +1,48 @@
|
|
|
1
1
|
import { i18n } from '@lingui/core';
|
|
2
|
-
import { Divider } from '@rango-dev/ui';
|
|
2
|
+
import { Divider, SelectableCategoryList } from '@rango-dev/ui';
|
|
3
3
|
import React, { useState } from 'react';
|
|
4
4
|
|
|
5
5
|
import { BlockchainList } from '../components/BlockchainList';
|
|
6
6
|
import { Layout } from '../components/Layout';
|
|
7
7
|
import { SearchInput } from '../components/SearchInput';
|
|
8
|
-
import { SelectableCategoryList } from '../components/SelectableCategoryList';
|
|
9
8
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
10
9
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
10
|
+
import { useAppStore } from '../store/app';
|
|
11
11
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
12
12
|
import { useMetaStore } from '../store/meta';
|
|
13
13
|
|
|
14
14
|
interface PropTypes {
|
|
15
|
-
type: '
|
|
16
|
-
supportedBlockchains?: string[];
|
|
15
|
+
type: 'source' | 'destination';
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
export function SelectBlockchainPage(props: PropTypes) {
|
|
20
|
-
const { type
|
|
19
|
+
const { type } = props;
|
|
21
20
|
const { navigateBackFrom } = useNavigateBack();
|
|
22
21
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
23
22
|
const [blockchainCategory, setBlockchainCategory] = useState<string>('ALL');
|
|
24
23
|
const setToBlockchain = useBestRouteStore.use.setToBlockchain();
|
|
25
24
|
const setFromBlockchain = useBestRouteStore.use.setFromBlockchain();
|
|
25
|
+
const { loadingStatus } = useMetaStore();
|
|
26
26
|
|
|
27
|
-
const blockchains =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
supportedBlockchains.includes(chain.name)
|
|
32
|
-
)
|
|
33
|
-
: useMetaStore.use.meta().blockchains;
|
|
27
|
+
const blockchains = useAppStore().blockchains({
|
|
28
|
+
type: type,
|
|
29
|
+
});
|
|
30
|
+
const routeKey = type === 'source' ? 'fromBlockchain' : 'toBlockchain';
|
|
34
31
|
|
|
35
32
|
return (
|
|
36
33
|
<Layout
|
|
37
34
|
header={{
|
|
38
|
-
onBack:
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
),
|
|
35
|
+
onBack: () => {
|
|
36
|
+
navigateBackFrom(navigationRoutes[routeKey]);
|
|
37
|
+
},
|
|
42
38
|
title: i18n.t(`Select Blockchain`),
|
|
43
39
|
}}>
|
|
44
40
|
<Divider size={12} />
|
|
45
41
|
<SelectableCategoryList
|
|
46
42
|
setCategory={setBlockchainCategory}
|
|
47
43
|
category={blockchainCategory}
|
|
44
|
+
blockchains={blockchains}
|
|
45
|
+
isLoading={loadingStatus === 'loading'}
|
|
48
46
|
/>
|
|
49
47
|
<Divider size={24} />
|
|
50
48
|
<SearchInput
|
|
@@ -64,12 +62,13 @@ export function SelectBlockchainPage(props: PropTypes) {
|
|
|
64
62
|
searchedFor={searchedFor}
|
|
65
63
|
blockchainCategory={blockchainCategory}
|
|
66
64
|
onChange={(blockchain) => {
|
|
67
|
-
if (type === '
|
|
68
|
-
setFromBlockchain(blockchain
|
|
65
|
+
if (type === 'source') {
|
|
66
|
+
setFromBlockchain(blockchain);
|
|
69
67
|
} else {
|
|
70
|
-
setToBlockchain(blockchain
|
|
68
|
+
setToBlockchain(blockchain);
|
|
71
69
|
}
|
|
72
|
-
|
|
70
|
+
|
|
71
|
+
navigateBackFrom(navigationRoutes[routeKey]);
|
|
73
72
|
}}
|
|
74
73
|
/>
|
|
75
74
|
</Layout>
|
|
@@ -1,119 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
import type { Asset } from 'rango-sdk';
|
|
1
|
+
import type { BlockchainMeta, Token } from 'rango-sdk';
|
|
3
2
|
|
|
4
3
|
import { i18n } from '@lingui/core';
|
|
5
4
|
import { Divider } from '@rango-dev/ui';
|
|
6
|
-
import React, {
|
|
5
|
+
import React, { useState } from 'react';
|
|
7
6
|
import { useNavigate } from 'react-router-dom';
|
|
8
7
|
|
|
9
8
|
import { BlockchainsSection } from '../components/BlockchainsSection';
|
|
10
9
|
import { Layout } from '../components/Layout';
|
|
11
10
|
import { SearchInput } from '../components/SearchInput';
|
|
12
11
|
import { TokenList } from '../components/TokenList/TokenList';
|
|
13
|
-
import { filterTokens } from '../components/TokenList/TokenList.helpers';
|
|
14
12
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
15
13
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
14
|
+
import { useAppStore } from '../store/app';
|
|
16
15
|
import { useBestRouteStore } from '../store/bestRoute';
|
|
17
|
-
import { useMetaStore } from '../store/meta';
|
|
18
16
|
import { useWalletsStore } from '../store/wallets';
|
|
19
|
-
import {
|
|
17
|
+
import { getTokensBalanceFromWalletAndSort } from '../utils/wallets';
|
|
20
18
|
|
|
21
19
|
interface PropTypes {
|
|
22
|
-
type: '
|
|
23
|
-
supportedBlockchains?: string[];
|
|
24
|
-
supportedTokens?: Asset[];
|
|
25
|
-
pinnedTokens?: Asset[];
|
|
20
|
+
type: 'source' | 'destination';
|
|
26
21
|
}
|
|
27
22
|
|
|
28
23
|
export function SelectSwapItemsPage(props: PropTypes) {
|
|
29
|
-
const { type
|
|
24
|
+
const { type } = props;
|
|
30
25
|
const navigate = useNavigate();
|
|
31
26
|
const { navigateBackFrom } = useNavigateBack();
|
|
32
|
-
const {
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
const {
|
|
28
|
+
fromBlockchain,
|
|
29
|
+
toBlockchain,
|
|
30
|
+
setFromToken,
|
|
31
|
+
setToToken,
|
|
32
|
+
setFromBlockchain,
|
|
33
|
+
setToBlockchain,
|
|
34
|
+
} = useBestRouteStore();
|
|
35
|
+
const { connectedWallets } = useWalletsStore();
|
|
35
36
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
36
|
-
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
37
|
-
const setToToken = useBestRouteStore.use.setToToken();
|
|
38
|
-
const setToBlockchain = useBestRouteStore.use.setToBlockchain();
|
|
39
|
-
const setFromBlockchain = useBestRouteStore.use.setFromBlockchain();
|
|
40
|
-
const toBlockchain = useBestRouteStore.use.toBlockchain();
|
|
41
|
-
const fromBlockchain = useBestRouteStore.use.fromBlockchain();
|
|
42
|
-
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
43
|
-
const loadingWallet = useWalletsStore.use.loading();
|
|
44
|
-
const setTokensWithBalance = useMetaStore.use.setTokensWithBalance();
|
|
45
37
|
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
.meta()
|
|
49
|
-
.blockchains.filter((chain) =>
|
|
50
|
-
supportedBlockchains.includes(chain.name)
|
|
51
|
-
)
|
|
52
|
-
: useMetaStore.use.meta().blockchains;
|
|
53
|
-
const allTokens = supportedTokens
|
|
54
|
-
? tokens.filter((token) =>
|
|
55
|
-
tokens.some((supportedToken) => tokensAreEqual(supportedToken, token))
|
|
56
|
-
)
|
|
57
|
-
: tokens;
|
|
58
|
-
const supportedSourceTokens = supportedTokens
|
|
59
|
-
? sourceTokens.filter((token) =>
|
|
60
|
-
supportedTokens.some((supportedToken) =>
|
|
61
|
-
tokensAreEqual(supportedToken, token)
|
|
62
|
-
)
|
|
63
|
-
)
|
|
64
|
-
: sourceTokens;
|
|
38
|
+
const selectedBlockchain = type === 'source' ? fromBlockchain : toBlockchain;
|
|
39
|
+
const selectedBlockchainName = selectedBlockchain?.name ?? '';
|
|
65
40
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
(token) => ({
|
|
79
|
-
...token,
|
|
80
|
-
pin: pinnedTokens?.some((pinnedToken) =>
|
|
81
|
-
tokensAreEqual(pinnedToken, token)
|
|
82
|
-
),
|
|
83
|
-
})
|
|
41
|
+
// Tokens & Blockchains list
|
|
42
|
+
const blockchains = useAppStore().blockchains({
|
|
43
|
+
type: type,
|
|
44
|
+
});
|
|
45
|
+
const tokens = useAppStore().tokens({
|
|
46
|
+
type,
|
|
47
|
+
blockchain: selectedBlockchainName,
|
|
48
|
+
searchFor: searchedFor,
|
|
49
|
+
});
|
|
50
|
+
const tokensList = getTokensBalanceFromWalletAndSort(
|
|
51
|
+
tokens,
|
|
52
|
+
connectedWallets
|
|
84
53
|
);
|
|
85
54
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
55
|
+
// Actions
|
|
56
|
+
const updateBlockchain = (blockchain: BlockchainMeta) => {
|
|
57
|
+
if (type === 'source') {
|
|
58
|
+
setFromBlockchain(blockchain);
|
|
59
|
+
} else {
|
|
60
|
+
setToBlockchain(blockchain);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const updateToken = (token: Token) => {
|
|
65
|
+
if (type === 'source') {
|
|
66
|
+
setFromToken(token);
|
|
67
|
+
} else {
|
|
68
|
+
setToToken(token);
|
|
89
69
|
}
|
|
90
|
-
}
|
|
70
|
+
};
|
|
91
71
|
|
|
92
72
|
return (
|
|
93
73
|
<Layout
|
|
94
74
|
header={{
|
|
95
|
-
onBack:
|
|
96
|
-
|
|
75
|
+
onBack: () =>
|
|
76
|
+
navigateBackFrom(
|
|
77
|
+
type === 'source'
|
|
78
|
+
? navigationRoutes.fromSwap
|
|
79
|
+
: navigationRoutes.toSwap
|
|
80
|
+
),
|
|
81
|
+
title: i18n.t('Swap {type}', {
|
|
82
|
+
type: type === 'source' ? 'from' : 'to',
|
|
83
|
+
}),
|
|
97
84
|
}}>
|
|
98
85
|
<BlockchainsSection
|
|
99
86
|
blockchains={blockchains}
|
|
100
|
-
type={type}
|
|
101
|
-
blockchain={type === '
|
|
87
|
+
type={type == 'source' ? 'from' : 'to'}
|
|
88
|
+
blockchain={type === 'source' ? fromBlockchain : toBlockchain}
|
|
102
89
|
onMoreClick={() =>
|
|
103
90
|
navigate(
|
|
104
|
-
type === '
|
|
91
|
+
type === 'source'
|
|
105
92
|
? navigationRoutes.fromBlockchain
|
|
106
93
|
: navigationRoutes.toBlockchain
|
|
107
94
|
)
|
|
108
95
|
}
|
|
109
96
|
onChange={(blockchain) => {
|
|
110
|
-
|
|
111
|
-
if (type === 'from') {
|
|
112
|
-
setFromBlockchain(blockchain, true);
|
|
113
|
-
} else {
|
|
114
|
-
setToBlockchain(blockchain, true);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
97
|
+
updateBlockchain(blockchain);
|
|
117
98
|
}}
|
|
118
99
|
/>
|
|
119
100
|
<Divider size={24} />
|
|
@@ -129,22 +110,19 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
129
110
|
/>
|
|
130
111
|
<Divider size={16} />
|
|
131
112
|
<TokenList
|
|
132
|
-
list={
|
|
113
|
+
list={tokensList}
|
|
114
|
+
selectedBlockchain={selectedBlockchainName}
|
|
115
|
+
searchedFor={searchedFor}
|
|
133
116
|
onChange={(token) => {
|
|
134
|
-
|
|
117
|
+
updateToken(token);
|
|
118
|
+
|
|
119
|
+
const tokenBlockchain = blockchains.find(
|
|
135
120
|
(chain) => token.blockchain === chain.name
|
|
136
121
|
);
|
|
137
|
-
if (
|
|
138
|
-
|
|
139
|
-
if (!!blockchain) {
|
|
140
|
-
setFromBlockchain(blockchain, true);
|
|
141
|
-
}
|
|
142
|
-
} else {
|
|
143
|
-
setToToken(token);
|
|
144
|
-
if (!!blockchain) {
|
|
145
|
-
setToBlockchain(blockchain, true);
|
|
146
|
-
}
|
|
122
|
+
if (tokenBlockchain) {
|
|
123
|
+
updateBlockchain(tokenBlockchain);
|
|
147
124
|
}
|
|
125
|
+
|
|
148
126
|
navigateBackFrom(navigationRoutes.fromSwap);
|
|
149
127
|
}}
|
|
150
128
|
/>
|