@rango-dev/widget-embedded 0.17.1-next.3 → 0.17.1-next.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/QueueManager.d.ts +5 -2
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +0 -2
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +1 -6
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +56 -56
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
- package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.types.d.ts +0 -2
- 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 +1 -4
- package/dist/components/ConfirmWalletsModal/WalletList.type.d.ts.map +1 -1
- package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
- package/dist/components/Layout/Layout.d.ts.map +1 -1
- package/dist/components/Layout/Layout.types.d.ts +2 -2
- package/dist/components/Layout/Layout.types.d.ts.map +1 -1
- package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Quote/Quote.styles.d.ts +159 -0
- package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
- package/dist/components/Quote/Quote.types.d.ts +0 -1
- package/dist/components/Quote/Quote.types.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts +1 -0
- package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.d.ts.map +1 -1
- package/dist/components/Slippage/Slippage.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 +1 -1
- package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsCompleteModal.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.helpers.d.ts.map +1 -1
- package/dist/components/SwapDetailsModal/SwapDetailsModal.types.d.ts +1 -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.map +1 -1
- package/dist/components/TokenList/TokenList.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.helpers.d.ts +2 -2
- package/dist/components/TokenList/TokenList.helpers.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
- package/dist/components/TokenList/TokenList.types.d.ts +3 -9
- package/dist/components/TokenList/TokenList.types.d.ts.map +1 -1
- package/dist/components/TokenList/index.d.ts +0 -1
- package/dist/components/TokenList/index.d.ts.map +1 -1
- package/dist/components/UpdateUrl.d.ts +1 -6
- package/dist/components/UpdateUrl.d.ts.map +1 -1
- package/dist/components/WidgetEvents.d.ts.map +1 -1
- package/dist/constants/errors.d.ts.map +1 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.d.ts.map +1 -1
- package/dist/constants/navigationRoutes.d.ts +1 -2
- package/dist/constants/navigationRoutes.d.ts.map +1 -1
- package/dist/constants/searchParams.d.ts +2 -1
- package/dist/constants/searchParams.d.ts.map +1 -1
- package/dist/containers/App/App.d.ts +3 -0
- package/dist/containers/App/App.d.ts.map +1 -0
- package/dist/containers/App/App.styles.d.ts +158 -0
- package/dist/containers/App/App.styles.d.ts.map +1 -0
- package/dist/containers/App/index.d.ts +2 -0
- package/dist/containers/App/index.d.ts.map +1 -0
- package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +316 -0
- package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +3 -0
- package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
- package/dist/containers/Wallets/Wallets.d.ts +6 -0
- package/dist/containers/Wallets/Wallets.d.ts.map +1 -0
- package/dist/containers/Wallets/Wallets.types.d.ts +11 -0
- package/dist/containers/Wallets/Wallets.types.d.ts.map +1 -0
- package/dist/containers/Wallets/index.d.ts +2 -0
- package/dist/containers/Wallets/index.d.ts.map +1 -0
- package/dist/containers/Widget/Widget.d.ts +5 -0
- package/dist/containers/Widget/Widget.d.ts.map +1 -0
- package/dist/containers/Widget/Widget.types.d.ts +5 -0
- package/dist/containers/Widget/Widget.types.d.ts.map +1 -0
- package/dist/containers/Widget/index.d.ts +3 -0
- package/dist/containers/Widget/index.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts +6 -0
- package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts +20 -0
- package/dist/containers/WidgetInfo/WidgetInfo.helpers.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +21 -0
- package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -0
- package/dist/containers/WidgetInfo/index.d.ts +2 -0
- package/dist/containers/WidgetInfo/index.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts +5 -0
- package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts +7 -0
- package/dist/containers/WidgetProvider/WidgetProvider.types.d.ts.map +1 -0
- package/dist/containers/WidgetProvider/index.d.ts +2 -0
- package/dist/containers/WidgetProvider/index.d.ts.map +1 -0
- package/dist/hooks/useConfirmSwap/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts +6 -3
- package/dist/hooks/useConfirmSwap/useConfirmSwap.helpers.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts +1 -1
- package/dist/hooks/useConfirmSwap/useConfirmSwap.types.d.ts.map +1 -1
- package/dist/hooks/useForceAutoConnect.d.ts +2 -0
- package/dist/hooks/useForceAutoConnect.d.ts.map +1 -0
- package/dist/hooks/useLanguage.d.ts +1 -1
- package/dist/hooks/useLanguage.d.ts.map +1 -1
- package/dist/hooks/useNavigateBack.d.ts +1 -3
- package/dist/hooks/useNavigateBack.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.d.ts +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts +2 -2
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +3 -5
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts +1 -0
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.d.ts.map +1 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts +5 -1
- package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.d.ts.map +1 -1
- package/dist/hooks/useSwapInput.d.ts.map +1 -1
- package/dist/hooks/useSyncStoresWithConfig.d.ts +1 -2
- package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +1 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/hooks/useWalletList.d.ts.map +1 -1
- package/dist/index.d.ts +20 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +4 -4
- package/dist/pages/ConfirmSwapPage.d.ts +1 -6
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/HistoryPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LanguagePage.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcePage.d.ts +1 -2
- package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
- package/dist/pages/SelectBlockchainPage.d.ts.map +1 -1
- package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +1 -6
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/ThemePage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +1 -8
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/AppStore.d.ts +47 -0
- package/dist/store/AppStore.d.ts.map +1 -0
- package/dist/store/app.d.ts +41 -22
- package/dist/store/app.d.ts.map +1 -1
- package/dist/store/notification.d.ts +4 -3
- package/dist/store/notification.d.ts.map +1 -1
- package/dist/store/quote.d.ts +23 -16
- package/dist/store/quote.d.ts.map +1 -1
- package/dist/store/slices/config.d.ts +3 -2
- package/dist/store/slices/config.d.ts.map +1 -1
- package/dist/store/slices/data.d.ts +3 -0
- package/dist/store/slices/data.d.ts.map +1 -1
- package/dist/store/slices/settings.d.ts +39 -0
- package/dist/store/slices/settings.d.ts.map +1 -0
- package/dist/store/ui.d.ts +2 -1
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +14 -9
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +38 -5
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/swap.d.ts +4 -14
- package/dist/types/swap.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +15 -1
- package/dist/types/wallets.d.ts.map +1 -1
- package/dist/utils/colors.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +1 -0
- package/dist/utils/configs.d.ts.map +1 -1
- package/dist/utils/meta.d.ts +2 -1
- package/dist/utils/meta.d.ts.map +1 -1
- package/dist/utils/providers.d.ts +2 -2
- package/dist/utils/providers.d.ts.map +1 -1
- package/dist/utils/queue.d.ts +2 -2
- package/dist/utils/queue.d.ts.map +1 -1
- package/dist/utils/quote.d.ts +1 -1
- package/dist/utils/quote.d.ts.map +1 -1
- package/dist/utils/settings.d.ts +6 -2
- package/dist/utils/settings.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +16 -7
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/time.d.ts +1 -1
- package/dist/utils/time.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +7 -9
- package/dist/utils/wallets.d.ts.map +1 -1
- package/package.json +12 -10
- package/src/QueueManager.tsx +18 -17
- package/src/components/AppRouter.tsx +8 -32
- package/src/components/AppRoutes.tsx +57 -69
- package/src/components/BlockchainList/BlockchainList.tsx +4 -4
- package/src/components/BlockchainsSection/BlockchainsSection.tsx +4 -4
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +16 -19
- package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.types.ts +0 -2
- package/src/components/ConfirmWalletsModal/WalletList.tsx +6 -5
- package/src/components/ConfirmWalletsModal/WalletList.type.ts +1 -4
- package/src/components/HeaderButtons/HomeButtons.tsx +28 -18
- package/src/components/Layout/Layout.tsx +20 -7
- package/src/components/Layout/Layout.types.ts +2 -2
- package/src/components/NoResult/NoResult.helpers.ts +12 -12
- package/src/components/NoResult/NoResult.tsx +6 -6
- package/src/components/NotificationContent/NotificationContent.tsx +5 -3
- package/src/components/Quote/Quote.styles.ts +28 -1
- package/src/components/Quote/Quote.tsx +100 -34
- package/src/components/Quote/Quote.types.ts +0 -1
- package/src/components/Quote/QuoteSkeleton.tsx +1 -1
- package/src/components/QuoteWarningsAndErrors/QuoteErrorsModalItem.tsx +1 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.helpers.ts +11 -4
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts +8 -1
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.tsx +13 -13
- package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.types.ts +1 -0
- package/src/components/QuoteWarningsAndErrors/SlippageWariningModal.tsx +3 -3
- package/src/components/Slippage/Slippage.tsx +3 -5
- package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +0 -4
- package/src/components/SwapDetails/SwapDetails.helpers.tsx +1 -1
- package/src/components/SwapDetails/SwapDetails.tsx +19 -39
- package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.Warning.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsCompleteModal.tsx +4 -3
- package/src/components/SwapDetailsModal/SwapDetailsModal.Cancel.tsx +2 -2
- package/src/components/SwapDetailsModal/SwapDetailsModal.helpers.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.tsx +1 -1
- package/src/components/SwapDetailsModal/SwapDetailsModal.types.ts +1 -1
- package/src/components/SwapsGroup/SwapsGroup.styles.ts +8 -1
- package/src/components/SwapsGroup/SwapsGroup.tsx +0 -2
- package/src/components/TokenList/TokenList.helpers.ts +2 -2
- package/src/components/TokenList/TokenList.styles.ts +14 -2
- package/src/components/TokenList/TokenList.tsx +16 -19
- package/src/components/TokenList/TokenList.types.ts +3 -10
- package/src/components/TokenList/index.ts +0 -1
- package/src/components/UpdateUrl.tsx +23 -18
- package/src/components/WidgetEvents.tsx +4 -2
- package/src/constants/errors.ts +9 -5
- package/src/constants/index.ts +1 -0
- package/src/constants/navigationRoutes.ts +7 -8
- package/src/constants/searchParams.ts +1 -0
- package/src/containers/App/App.styles.ts +18 -0
- package/src/containers/App/App.tsx +52 -0
- package/src/containers/App/index.ts +1 -0
- package/src/containers/QuoteInfo/QuoteInfo.styles.ts +17 -1
- package/src/containers/QuoteInfo/QuoteInfo.tsx +44 -43
- package/src/containers/QuoteInfo/QuoteInfo.types.ts +3 -0
- package/src/{Wallets.tsx → containers/Wallets/Wallets.tsx} +48 -34
- package/src/containers/Wallets/Wallets.types.ts +12 -0
- package/src/containers/Wallets/index.ts +1 -0
- package/src/containers/Widget/Widget.tsx +19 -0
- package/src/containers/Widget/Widget.types.ts +5 -0
- package/src/containers/Widget/index.ts +2 -0
- package/src/containers/WidgetInfo/WidgetInfo.helpers.ts +64 -0
- package/src/containers/WidgetInfo/WidgetInfo.tsx +62 -0
- package/src/containers/WidgetInfo/WidgetInfo.types.ts +21 -0
- package/src/containers/WidgetInfo/index.ts +1 -0
- package/src/containers/WidgetProvider/WidgetProvider.tsx +28 -0
- package/src/containers/WidgetProvider/WidgetProvider.types.ts +7 -0
- package/src/containers/WidgetProvider/index.ts +1 -0
- package/src/hooks/useConfirmSwap/useConfirmSwap.helpers.ts +15 -11
- package/src/hooks/useConfirmSwap/useConfirmSwap.ts +25 -24
- package/src/hooks/useConfirmSwap/useConfirmSwap.types.ts +1 -1
- package/src/hooks/useForceAutoConnect.ts +27 -0
- package/src/hooks/useLanguage.ts +4 -5
- package/src/hooks/useNavigateBack.ts +3 -52
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.constants.ts +1 -1
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.ts +37 -7
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.mock.ts +60 -0
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.test.ts +78 -3
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.ts +15 -6
- package/src/hooks/usePrepareBlockchainList/usePrepareBlockchainList.types.ts +6 -1
- package/src/hooks/useSwapInput.ts +89 -30
- package/src/hooks/useSyncStoresWithConfig.ts +38 -22
- package/src/hooks/useTheme.ts +4 -5
- package/src/hooks/useWalletList.ts +3 -5
- package/src/index.ts +53 -5
- package/src/pages/ConfirmSwapPage.tsx +39 -24
- package/src/pages/HistoryPage.tsx +2 -7
- package/src/pages/Home.tsx +58 -88
- package/src/pages/LanguagePage.tsx +0 -5
- package/src/pages/LiquiditySourcePage.tsx +24 -37
- package/src/pages/SelectBlockchainPage.tsx +28 -21
- package/src/pages/SelectSwapItemsPage.tsx +10 -27
- package/src/pages/SettingsPage.tsx +28 -24
- package/src/pages/SwapDetailsPage.tsx +6 -7
- package/src/pages/ThemePage.tsx +2 -7
- package/src/pages/WalletsPage.tsx +4 -15
- package/src/services/httpService.ts +1 -1
- package/src/store/AppStore.tsx +41 -0
- package/src/store/app.ts +44 -6
- package/src/store/quote.ts +29 -26
- package/src/store/slices/config.ts +25 -15
- package/src/store/slices/data.ts +64 -29
- package/src/store/slices/settings.ts +168 -0
- package/src/store/wallets.ts +68 -37
- package/src/types/config.ts +50 -5
- package/src/types/swap.ts +4 -13
- package/src/types/wallets.ts +18 -1
- package/src/utils/colors.ts +2 -1
- package/src/utils/configs.ts +2 -1
- package/src/utils/date.ts +1 -1
- package/src/utils/meta.ts +8 -1
- package/src/utils/providers.ts +8 -5
- package/src/utils/queue.ts +2 -2
- package/src/utils/quote.ts +7 -7
- package/src/utils/settings.ts +17 -10
- package/src/utils/swap.ts +59 -55
- package/src/utils/time.ts +1 -1
- package/src/utils/wallets.ts +107 -149
- package/dist/Wallets.d.ts +0 -17
- package/dist/Wallets.d.ts.map +0 -1
- package/dist/Widget.d.ts +0 -9
- package/dist/Widget.d.ts.map +0 -1
- package/dist/store/meta.d.ts +0 -23
- package/dist/store/meta.d.ts.map +0 -1
- package/dist/store/settings.d.ts +0 -81
- package/dist/store/settings.d.ts.map +0 -1
- package/src/Widget.tsx +0 -119
- package/src/store/meta.ts +0 -39
- package/src/store/settings.ts +0 -158
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { PendingSwap } from '
|
|
2
|
-
import type { PendingSwapStep } from 'rango-types';
|
|
1
|
+
import type { PendingSwap, PendingSwapStep } from 'rango-types';
|
|
3
2
|
|
|
4
3
|
import { i18n } from '@lingui/core';
|
|
5
4
|
import { useManager } from '@rango-dev/queue-manager-react';
|
|
@@ -11,8 +10,6 @@ import { Layout } from '../components/Layout';
|
|
|
11
10
|
import { SearchInput } from '../components/SearchInput';
|
|
12
11
|
import { SwapsGroup } from '../components/SwapsGroup';
|
|
13
12
|
import { NotFoundContainer } from '../components/SwapsGroup/SwapsGroup.styles';
|
|
14
|
-
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
15
|
-
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
16
13
|
import { useUiStore } from '../store/ui';
|
|
17
14
|
import { groupSwapsByDate } from '../utils/date';
|
|
18
15
|
import { containsText } from '../utils/numbers';
|
|
@@ -51,7 +48,6 @@ const isStepContainsText = (steps: PendingSwapStep[], value: string) => {
|
|
|
51
48
|
export function HistoryPage() {
|
|
52
49
|
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
53
50
|
const navigate = useNavigate();
|
|
54
|
-
const { navigateBackFrom } = useNavigateBack();
|
|
55
51
|
const { manager, state } = useManager();
|
|
56
52
|
const list: PendingSwap[] = getPendingSwaps(manager).map(({ swap }) => swap);
|
|
57
53
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
@@ -78,7 +74,6 @@ export function HistoryPage() {
|
|
|
78
74
|
return (
|
|
79
75
|
<Layout
|
|
80
76
|
header={{
|
|
81
|
-
onBack: () => navigateBackFrom(navigationRoutes.swaps),
|
|
82
77
|
title: i18n.t('History'),
|
|
83
78
|
}}>
|
|
84
79
|
<Container>
|
|
@@ -108,7 +103,7 @@ export function HistoryPage() {
|
|
|
108
103
|
list={filteredList}
|
|
109
104
|
onSwapClick={(requestId) => {
|
|
110
105
|
setSelectedSwap(requestId);
|
|
111
|
-
navigate(
|
|
106
|
+
navigate(requestId);
|
|
112
107
|
}}
|
|
113
108
|
groupBy={groupSwapsByDate}
|
|
114
109
|
isLoading={loading}
|
package/src/pages/Home.tsx
CHANGED
|
@@ -9,8 +9,6 @@ import { SwitchFromAndToButton } from '../components/SwitchFromAndTo';
|
|
|
9
9
|
import { errorMessages } from '../constants/errors';
|
|
10
10
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
11
11
|
import {
|
|
12
|
-
BALANCE_MAX_DECIMALS,
|
|
13
|
-
BALANCE_MIN_DECIMALS,
|
|
14
12
|
PERCENTAGE_CHANGE_MAX_DECIMALS,
|
|
15
13
|
PERCENTAGE_CHANGE_MIN_DECIMALS,
|
|
16
14
|
TOKEN_AMOUNT_MAX_DECIMALS,
|
|
@@ -20,27 +18,22 @@ import {
|
|
|
20
18
|
} from '../constants/routing';
|
|
21
19
|
import { QuoteInfo } from '../containers/QuoteInfo';
|
|
22
20
|
import { useSwapInput } from '../hooks/useSwapInput';
|
|
23
|
-
import {
|
|
21
|
+
import { useAppStore } from '../store/AppStore';
|
|
24
22
|
import { useQuoteStore } from '../store/quote';
|
|
25
23
|
import { useUiStore } from '../store/ui';
|
|
26
24
|
import { useWalletsStore } from '../store/wallets';
|
|
27
|
-
import { ButtonState } from '../types';
|
|
28
25
|
import { numberToString } from '../utils/numbers';
|
|
29
26
|
import { getPriceImpact, getPriceImpactLevel } from '../utils/quote';
|
|
30
|
-
import {
|
|
31
|
-
|
|
32
|
-
getOutputRatio,
|
|
33
|
-
getPercentageChange,
|
|
34
|
-
getSwapButtonState,
|
|
35
|
-
hasHighValueLoss,
|
|
36
|
-
hasLimitError,
|
|
37
|
-
} from '../utils/swap';
|
|
38
|
-
import { getBalanceFromWallet } from '../utils/wallets';
|
|
27
|
+
import { canComputePriceImpact, getSwapButtonState } from '../utils/swap';
|
|
28
|
+
import { formatBalance } from '../utils/wallets';
|
|
39
29
|
|
|
40
30
|
const Container = styled('div', {
|
|
41
31
|
display: 'flex',
|
|
42
32
|
flexDirection: 'column',
|
|
43
33
|
overflowY: 'visible',
|
|
34
|
+
'& .quote__container': {
|
|
35
|
+
paddingTop: '$2',
|
|
36
|
+
},
|
|
44
37
|
});
|
|
45
38
|
|
|
46
39
|
const FromContainer = styled('div', {
|
|
@@ -76,18 +69,15 @@ export function Home() {
|
|
|
76
69
|
setQuoteWarningsConfirmed,
|
|
77
70
|
} = useQuoteStore();
|
|
78
71
|
|
|
79
|
-
const
|
|
72
|
+
const fetchMetaStatus = useAppStore().fetchStatus;
|
|
80
73
|
|
|
81
|
-
const connectedWallets = useWalletsStore
|
|
74
|
+
const { connectedWallets, getBalanceFor } = useWalletsStore();
|
|
82
75
|
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
83
76
|
const [showQuoteWarningModal, setShowQuoteWarningModal] = useState(false);
|
|
84
77
|
const layoutRef = useRef<HTMLDivElement>(null);
|
|
85
78
|
|
|
86
79
|
const needsToWarnEthOnPath = false;
|
|
87
80
|
|
|
88
|
-
const outToInRatio = getOutputRatio(inputUsdValue, outputUsdValue);
|
|
89
|
-
const highValueLoss = hasHighValueLoss(inputUsdValue, outToInRatio);
|
|
90
|
-
|
|
91
81
|
const priceImpactInputCanNotBeComputed = !canComputePriceImpact(
|
|
92
82
|
quote,
|
|
93
83
|
inputAmount,
|
|
@@ -99,48 +89,26 @@ export function Home() {
|
|
|
99
89
|
inputAmount,
|
|
100
90
|
outputUsdValue
|
|
101
91
|
);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
|
|
93
|
+
const swapButtonState = getSwapButtonState({
|
|
94
|
+
fetchMetaStatus,
|
|
105
95
|
fetchingQuote,
|
|
96
|
+
inputAmount,
|
|
106
97
|
quote,
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
98
|
+
anyWalletConnected: connectedWallets.length > 0,
|
|
99
|
+
error: quoteError,
|
|
100
|
+
warning: quoteWarning,
|
|
110
101
|
needsToWarnEthOnPath,
|
|
111
|
-
|
|
112
|
-
);
|
|
102
|
+
});
|
|
113
103
|
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
connectedWallets,
|
|
119
|
-
fromBlockchain?.name,
|
|
120
|
-
fromToken?.symbol,
|
|
121
|
-
fromToken?.address
|
|
122
|
-
)?.amount || '0',
|
|
123
|
-
BALANCE_MIN_DECIMALS,
|
|
124
|
-
BALANCE_MAX_DECIMALS
|
|
125
|
-
)
|
|
126
|
-
: '0';
|
|
104
|
+
const fromTokenBalance = fromToken ? getBalanceFor(fromToken) : null;
|
|
105
|
+
|
|
106
|
+
const fromTokenFormattedBalance =
|
|
107
|
+
formatBalance(fromTokenBalance)?.amount ?? '0';
|
|
127
108
|
|
|
128
109
|
const tokenBalanceReal =
|
|
129
110
|
!!fromBlockchain && !!fromToken
|
|
130
|
-
? numberToString(
|
|
131
|
-
getBalanceFromWallet(
|
|
132
|
-
connectedWallets,
|
|
133
|
-
fromBlockchain?.name,
|
|
134
|
-
fromToken?.symbol,
|
|
135
|
-
fromToken?.address
|
|
136
|
-
)?.amount || '0',
|
|
137
|
-
getBalanceFromWallet(
|
|
138
|
-
connectedWallets,
|
|
139
|
-
fromBlockchain?.name,
|
|
140
|
-
fromToken?.symbol,
|
|
141
|
-
fromToken?.address
|
|
142
|
-
)?.decimal
|
|
143
|
-
)
|
|
111
|
+
? numberToString(fromTokenBalance?.amount, fromTokenBalance?.decimals)
|
|
144
112
|
: '0';
|
|
145
113
|
|
|
146
114
|
useEffect(() => {
|
|
@@ -152,10 +120,8 @@ export function Home() {
|
|
|
152
120
|
const percentageChange =
|
|
153
121
|
!inputUsdValue || !outputUsdValue || !outputUsdValue.gt(0)
|
|
154
122
|
? null
|
|
155
|
-
:
|
|
156
|
-
|
|
157
|
-
outputUsdValue.toString()
|
|
158
|
-
);
|
|
123
|
+
: getPriceImpact(inputUsdValue.toString(), outputUsdValue.toString());
|
|
124
|
+
|
|
159
125
|
return (
|
|
160
126
|
<Layout
|
|
161
127
|
ref={layoutRef}
|
|
@@ -167,14 +133,13 @@ export function Home() {
|
|
|
167
133
|
size="large"
|
|
168
134
|
disabled={swapButtonState.disabled}
|
|
169
135
|
prefix={
|
|
170
|
-
|
|
171
|
-
swapButtonState.hasWarning && <WarningIcon />
|
|
136
|
+
swapButtonState.action === 'confirm-warning' && <WarningIcon />
|
|
172
137
|
}
|
|
173
138
|
fullWidth
|
|
174
139
|
onClick={() => {
|
|
175
|
-
if (swapButtonState.
|
|
140
|
+
if (swapButtonState.action === 'connect-wallet') {
|
|
176
141
|
navigate(navigationRoutes.wallets);
|
|
177
|
-
} else if (
|
|
142
|
+
} else if (swapButtonState.action === 'confirm-warning') {
|
|
178
143
|
setShowQuoteWarningModal(true);
|
|
179
144
|
} else {
|
|
180
145
|
navigate(navigationRoutes.confirmSwap);
|
|
@@ -184,7 +149,10 @@ export function Home() {
|
|
|
184
149
|
</Button>
|
|
185
150
|
}
|
|
186
151
|
header={{
|
|
187
|
-
|
|
152
|
+
onWallet: () => {
|
|
153
|
+
navigate(navigationRoutes.wallets);
|
|
154
|
+
},
|
|
155
|
+
hasBackButton: false,
|
|
188
156
|
title: i18n.t('Swap'),
|
|
189
157
|
suffix: (
|
|
190
158
|
<HomeButtons
|
|
@@ -200,11 +168,9 @@ export function Home() {
|
|
|
200
168
|
<FromContainer>
|
|
201
169
|
<SwapInput
|
|
202
170
|
label={i18n.t('From')}
|
|
203
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
204
|
-
//@ts-ignore
|
|
205
171
|
mode="From"
|
|
206
172
|
onInputChange={setInputAmount}
|
|
207
|
-
balance={
|
|
173
|
+
balance={fromTokenFormattedBalance}
|
|
208
174
|
chain={{
|
|
209
175
|
displayName: fromBlockchain?.displayName || '',
|
|
210
176
|
image: fromBlockchain?.logo || '',
|
|
@@ -213,7 +179,7 @@ export function Home() {
|
|
|
213
179
|
displayName: fromToken?.symbol || '',
|
|
214
180
|
image: fromToken?.image || '',
|
|
215
181
|
}}
|
|
216
|
-
onClickToken={() => navigate(
|
|
182
|
+
onClickToken={() => navigate(navigationRoutes.fromSwap)}
|
|
217
183
|
price={{
|
|
218
184
|
value: inputAmount,
|
|
219
185
|
usdValue: priceImpactInputCanNotBeComputed
|
|
@@ -227,10 +193,10 @@ export function Home() {
|
|
|
227
193
|
? errorMessages().unknownPriceError.impactTitle
|
|
228
194
|
: undefined,
|
|
229
195
|
}}
|
|
230
|
-
disabled={
|
|
231
|
-
loading={
|
|
196
|
+
disabled={fetchMetaStatus === 'failed'}
|
|
197
|
+
loading={fetchMetaStatus === 'loading'}
|
|
232
198
|
onSelectMaxBalance={() => {
|
|
233
|
-
if (
|
|
199
|
+
if (fromTokenFormattedBalance !== '0') {
|
|
234
200
|
setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
235
201
|
}
|
|
236
202
|
}}
|
|
@@ -241,6 +207,7 @@ export function Home() {
|
|
|
241
207
|
sharpBottomStyle={!!quote?.result || fetchingQuote}
|
|
242
208
|
label={i18n.t('To')}
|
|
243
209
|
mode="To"
|
|
210
|
+
fetchingQuote={fetchingQuote}
|
|
244
211
|
chain={{
|
|
245
212
|
displayName: toBlockchain?.displayName || '',
|
|
246
213
|
image: toBlockchain?.logo || '',
|
|
@@ -272,27 +239,30 @@ export function Home() {
|
|
|
272
239
|
? errorMessages().unknownPriceError.impactTitle
|
|
273
240
|
: undefined,
|
|
274
241
|
}}
|
|
275
|
-
onClickToken={() => navigate(
|
|
276
|
-
disabled={
|
|
277
|
-
loading={
|
|
242
|
+
onClickToken={() => navigate(navigationRoutes.toSwap)}
|
|
243
|
+
disabled={fetchMetaStatus === 'failed'}
|
|
244
|
+
loading={fetchMetaStatus === 'loading'}
|
|
278
245
|
/>
|
|
279
246
|
</InputsContainer>
|
|
280
|
-
<
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
247
|
+
<div className="quote__container">
|
|
248
|
+
<QuoteInfo
|
|
249
|
+
quote={quote}
|
|
250
|
+
loading={fetchingQuote}
|
|
251
|
+
error={quoteError}
|
|
252
|
+
warning={quoteWarning}
|
|
253
|
+
type="basic"
|
|
254
|
+
refetchQuote={fetchQuote}
|
|
255
|
+
showWarningModal={showQuoteWarningModal}
|
|
256
|
+
onOpenWarningModal={() => setShowQuoteWarningModal(true)}
|
|
257
|
+
onCloseWarningModal={() => setShowQuoteWarningModal(false)}
|
|
258
|
+
onConfirmWarningModal={() => {
|
|
259
|
+
setShowQuoteWarningModal(false);
|
|
260
|
+
setQuoteWarningsConfirmed(true);
|
|
261
|
+
navigate(navigationRoutes.confirmSwap);
|
|
262
|
+
}}
|
|
263
|
+
onChangeSettings={() => navigate(navigationRoutes.settings)}
|
|
264
|
+
/>
|
|
265
|
+
</div>
|
|
296
266
|
</Container>
|
|
297
267
|
</Layout>
|
|
298
268
|
);
|
|
@@ -10,13 +10,9 @@ import React from 'react';
|
|
|
10
10
|
|
|
11
11
|
import { Layout } from '../components/Layout';
|
|
12
12
|
import { SettingsContainer } from '../components/SettingsContainer';
|
|
13
|
-
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
14
13
|
import { useLanguage } from '../hooks/useLanguage';
|
|
15
|
-
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
16
14
|
|
|
17
15
|
export function LanguagePage() {
|
|
18
|
-
const { navigateBackFrom } = useNavigateBack();
|
|
19
|
-
|
|
20
16
|
const { activeLanguage, changeLanguage, languages } = useLanguage();
|
|
21
17
|
|
|
22
18
|
const languageList = languages.map((languageItem) => {
|
|
@@ -38,7 +34,6 @@ export function LanguagePage() {
|
|
|
38
34
|
return (
|
|
39
35
|
<Layout
|
|
40
36
|
header={{
|
|
41
|
-
onBack: () => navigateBackFrom(navigationRoutes.settings),
|
|
42
37
|
title: i18n.t('Language'),
|
|
43
38
|
}}>
|
|
44
39
|
<SettingsContainer>
|
|
@@ -23,32 +23,22 @@ import {
|
|
|
23
23
|
NotFoundContainer,
|
|
24
24
|
SettingsContainer,
|
|
25
25
|
} from '../components/SettingsContainer';
|
|
26
|
-
import {
|
|
27
|
-
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
28
|
-
import { useMetaStore } from '../store/meta';
|
|
29
|
-
import { useSettingsStore } from '../store/settings';
|
|
26
|
+
import { useAppStore } from '../store/AppStore';
|
|
30
27
|
import { containsText } from '../utils/numbers';
|
|
31
|
-
import {
|
|
32
|
-
getUniqueSwappersGroups,
|
|
33
|
-
sortLiquiditySourcesByGroupTitle,
|
|
34
|
-
} from '../utils/settings';
|
|
28
|
+
import { getUniqueSwappersGroups } from '../utils/settings';
|
|
35
29
|
|
|
36
30
|
interface PropTypes {
|
|
37
|
-
supportedSwappers?: string[];
|
|
38
31
|
sourceType: 'Exchanges' | 'Bridges';
|
|
39
32
|
}
|
|
40
33
|
|
|
41
|
-
export function LiquiditySourcePage({
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
export function LiquiditySourcePage({ sourceType }: PropTypes) {
|
|
35
|
+
const fetchStatus = useAppStore().fetchStatus;
|
|
36
|
+
const swappers = useAppStore().swappers();
|
|
37
|
+
const disabledLiquiditySources = useAppStore().disabledLiquiditySources;
|
|
45
38
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
46
|
-
const toggleLiquiditySource =
|
|
47
|
-
const { navigateBackFrom } = useNavigateBack();
|
|
48
|
-
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
49
|
-
|
|
39
|
+
const toggleLiquiditySource = useAppStore().toggleLiquiditySource;
|
|
50
40
|
const supportedUniqueSwappersGroups: Array<UniqueSwappersGroupType> =
|
|
51
|
-
getUniqueSwappersGroups(
|
|
41
|
+
getUniqueSwappersGroups(swappers, disabledLiquiditySources);
|
|
52
42
|
|
|
53
43
|
const validTypes: Array<LiquiditySourceType> = [];
|
|
54
44
|
if (sourceType === 'Exchanges') {
|
|
@@ -79,22 +69,20 @@ export function LiquiditySourcePage({
|
|
|
79
69
|
});
|
|
80
70
|
};
|
|
81
71
|
|
|
82
|
-
const list = liquiditySources
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
};
|
|
97
|
-
});
|
|
72
|
+
const list = liquiditySources.map((sourceItem) => {
|
|
73
|
+
const { selected, groupTitle, logo } = sourceItem;
|
|
74
|
+
return {
|
|
75
|
+
start: <Image src={logo} size={22} type="circular" />,
|
|
76
|
+
onClick: () => toggleLiquiditySource(groupTitle),
|
|
77
|
+
end: <Checkbox checked={selected} />,
|
|
78
|
+
title: (
|
|
79
|
+
<Typography variant="title" size="xmedium">
|
|
80
|
+
{i18n.t(groupTitle)}
|
|
81
|
+
</Typography>
|
|
82
|
+
),
|
|
83
|
+
...sourceItem,
|
|
84
|
+
};
|
|
85
|
+
});
|
|
98
86
|
|
|
99
87
|
const searchHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
100
88
|
const value = event.target.value;
|
|
@@ -111,7 +99,6 @@ export function LiquiditySourcePage({
|
|
|
111
99
|
return (
|
|
112
100
|
<Layout
|
|
113
101
|
header={{
|
|
114
|
-
onBack: () => navigateBackFrom(navigationRoutes.settings),
|
|
115
102
|
title: i18n.t(sourceType),
|
|
116
103
|
suffix: (
|
|
117
104
|
<LiquiditySourceSuffix>
|
|
@@ -131,7 +118,7 @@ export function LiquiditySourcePage({
|
|
|
131
118
|
placeholder={i18n.t('Search {sourceType}', { sourceType })}
|
|
132
119
|
onChange={searchHandler}
|
|
133
120
|
/>
|
|
134
|
-
{
|
|
121
|
+
{fetchStatus === 'loading' && <LoadingLiquiditySourceList />}
|
|
135
122
|
|
|
136
123
|
{!filteredList.length && !!searchedFor ? (
|
|
137
124
|
<NotFoundContainer>
|
|
@@ -141,7 +128,7 @@ export function LiquiditySourcePage({
|
|
|
141
128
|
/>
|
|
142
129
|
</NotFoundContainer>
|
|
143
130
|
) : (
|
|
144
|
-
|
|
131
|
+
fetchStatus === 'success' && (
|
|
145
132
|
<LiquiditySourceList>
|
|
146
133
|
{filteredList.map((sourceItem) => {
|
|
147
134
|
return (
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { i18n } from '@lingui/core';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Divider,
|
|
4
|
+
getCountCategories,
|
|
5
|
+
SelectableCategoryList
|
|
6
|
+
} from '@rango-dev/ui';
|
|
3
7
|
import React, { useState } from 'react';
|
|
4
8
|
|
|
5
9
|
import { BlockchainList } from '../components/BlockchainList';
|
|
6
10
|
import { Layout } from '../components/Layout';
|
|
7
11
|
import { SearchInput } from '../components/SearchInput';
|
|
8
|
-
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
9
12
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
10
|
-
import { useAppStore } from '../store/
|
|
11
|
-
import { useMetaStore } from '../store/meta';
|
|
13
|
+
import { useAppStore } from '../store/AppStore';
|
|
12
14
|
import { useQuoteStore } from '../store/quote';
|
|
13
15
|
|
|
14
16
|
interface PropTypes {
|
|
@@ -17,34 +19,40 @@ interface PropTypes {
|
|
|
17
19
|
|
|
18
20
|
export function SelectBlockchainPage(props: PropTypes) {
|
|
19
21
|
const { type } = props;
|
|
20
|
-
const
|
|
22
|
+
const navigateBack = useNavigateBack();
|
|
21
23
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
22
24
|
const [blockchainCategory, setBlockchainCategory] = useState<string>('ALL');
|
|
23
25
|
const setToBlockchain = useQuoteStore.use.setToBlockchain();
|
|
24
26
|
const setFromBlockchain = useQuoteStore.use.setFromBlockchain();
|
|
25
|
-
const
|
|
27
|
+
const fetchStatus = useAppStore().fetchStatus;
|
|
26
28
|
|
|
27
29
|
const blockchains = useAppStore().blockchains({
|
|
28
|
-
type: type
|
|
30
|
+
type: type
|
|
29
31
|
});
|
|
30
|
-
|
|
32
|
+
|
|
33
|
+
const countActiveCategories = getCountCategories(blockchains);
|
|
34
|
+
|
|
35
|
+
const showCategory = countActiveCategories !== 1;
|
|
31
36
|
|
|
32
37
|
return (
|
|
33
38
|
<Layout
|
|
34
39
|
header={{
|
|
35
|
-
|
|
36
|
-
navigateBackFrom(navigationRoutes[routeKey]);
|
|
37
|
-
},
|
|
38
|
-
title: i18n.t(`Select Blockchain`),
|
|
40
|
+
title: i18n.t(`Select Blockchain`)
|
|
39
41
|
}}>
|
|
40
42
|
<Divider size={12} />
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
|
|
44
|
+
{showCategory && (
|
|
45
|
+
<>
|
|
46
|
+
<SelectableCategoryList
|
|
47
|
+
setCategory={setBlockchainCategory}
|
|
48
|
+
category={blockchainCategory}
|
|
49
|
+
blockchains={blockchains}
|
|
50
|
+
isLoading={fetchStatus === 'loading'}
|
|
51
|
+
/>
|
|
52
|
+
<Divider size={24} />
|
|
53
|
+
</>
|
|
54
|
+
)}
|
|
55
|
+
|
|
48
56
|
<SearchInput
|
|
49
57
|
value={searchedFor}
|
|
50
58
|
autoFocus
|
|
@@ -67,8 +75,7 @@ export function SelectBlockchainPage(props: PropTypes) {
|
|
|
67
75
|
} else {
|
|
68
76
|
setToBlockchain(blockchain);
|
|
69
77
|
}
|
|
70
|
-
|
|
71
|
-
navigateBackFrom(navigationRoutes[routeKey]);
|
|
78
|
+
navigateBack();
|
|
72
79
|
}}
|
|
73
80
|
/>
|
|
74
81
|
</Layout>
|
|
@@ -11,10 +11,10 @@ import { SearchInput } from '../components/SearchInput';
|
|
|
11
11
|
import { TokenList } from '../components/TokenList/TokenList';
|
|
12
12
|
import { navigationRoutes } from '../constants/navigationRoutes';
|
|
13
13
|
import { useNavigateBack } from '../hooks/useNavigateBack';
|
|
14
|
-
import { useAppStore } from '../store/
|
|
14
|
+
import { useAppStore } from '../store/AppStore';
|
|
15
15
|
import { useQuoteStore } from '../store/quote';
|
|
16
16
|
import { useWalletsStore } from '../store/wallets';
|
|
17
|
-
import {
|
|
17
|
+
import { sortTokensByBalance } from '../utils/wallets';
|
|
18
18
|
|
|
19
19
|
interface PropTypes {
|
|
20
20
|
type: 'source' | 'destination';
|
|
@@ -23,7 +23,7 @@ interface PropTypes {
|
|
|
23
23
|
export function SelectSwapItemsPage(props: PropTypes) {
|
|
24
24
|
const { type } = props;
|
|
25
25
|
const navigate = useNavigate();
|
|
26
|
-
const
|
|
26
|
+
const navigateBack = useNavigateBack();
|
|
27
27
|
const {
|
|
28
28
|
fromBlockchain,
|
|
29
29
|
toBlockchain,
|
|
@@ -32,7 +32,7 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
32
32
|
setFromBlockchain,
|
|
33
33
|
setToBlockchain,
|
|
34
34
|
} = useQuoteStore();
|
|
35
|
-
const
|
|
35
|
+
const getBalanceFor = useWalletsStore.use.getBalanceFor();
|
|
36
36
|
const [searchedFor, setSearchedFor] = useState<string>('');
|
|
37
37
|
|
|
38
38
|
const selectedBlockchain = type === 'source' ? fromBlockchain : toBlockchain;
|
|
@@ -47,10 +47,7 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
47
47
|
blockchain: selectedBlockchainName,
|
|
48
48
|
searchFor: searchedFor,
|
|
49
49
|
});
|
|
50
|
-
const tokensList =
|
|
51
|
-
tokens,
|
|
52
|
-
connectedWallets
|
|
53
|
-
);
|
|
50
|
+
const tokensList = sortTokensByBalance(tokens, getBalanceFor);
|
|
54
51
|
|
|
55
52
|
// Actions
|
|
56
53
|
const updateBlockchain = (blockchain: BlockchainMeta) => {
|
|
@@ -63,36 +60,22 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
63
60
|
|
|
64
61
|
const updateToken = (token: Token) => {
|
|
65
62
|
if (type === 'source') {
|
|
66
|
-
setFromToken(token);
|
|
63
|
+
setFromToken({ token, meta: { blockchains, tokens } });
|
|
67
64
|
} else {
|
|
68
|
-
setToToken(token);
|
|
65
|
+
setToToken({ token, meta: { blockchains, tokens } });
|
|
69
66
|
}
|
|
70
67
|
};
|
|
71
68
|
|
|
72
69
|
return (
|
|
73
70
|
<Layout
|
|
74
71
|
header={{
|
|
75
|
-
|
|
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
|
-
}),
|
|
72
|
+
title: i18n.t('Swap {type}', { type }),
|
|
84
73
|
}}>
|
|
85
74
|
<BlockchainsSection
|
|
86
75
|
blockchains={blockchains}
|
|
87
76
|
type={type == 'source' ? 'from' : 'to'}
|
|
88
77
|
blockchain={type === 'source' ? fromBlockchain : toBlockchain}
|
|
89
|
-
onMoreClick={() =>
|
|
90
|
-
navigate(
|
|
91
|
-
type === 'source'
|
|
92
|
-
? navigationRoutes.fromBlockchain
|
|
93
|
-
: navigationRoutes.toBlockchain
|
|
94
|
-
)
|
|
95
|
-
}
|
|
78
|
+
onMoreClick={() => navigate(navigationRoutes.blockchains)}
|
|
96
79
|
onChange={(blockchain) => {
|
|
97
80
|
updateBlockchain(blockchain);
|
|
98
81
|
}}
|
|
@@ -123,7 +106,7 @@ export function SelectSwapItemsPage(props: PropTypes) {
|
|
|
123
106
|
updateBlockchain(tokenBlockchain);
|
|
124
107
|
}
|
|
125
108
|
|
|
126
|
-
|
|
109
|
+
navigateBack();
|
|
127
110
|
}}
|
|
128
111
|
/>
|
|
129
112
|
</Layout>
|