@rango-dev/widget-embedded 0.1.10-next.106 → 0.1.10-next.114
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/App.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/HeaderButtons.d.ts +4 -1
- package/dist/components/HeaderButtons.d.ts.map +1 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/SwapDetailsPlaceholder.d.ts +9 -0
- package/dist/components/SwapDetailsPlaceholder.d.ts.map +1 -0
- package/dist/components/TokenPreview.d.ts +1 -1
- package/dist/components/TokenPreview.d.ts.map +1 -1
- package/dist/globalStyles.d.ts.map +1 -1
- 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/LiquiditySourcesPage.d.ts.map +1 -1
- package/dist/pages/SelectTokenPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +1 -0
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts +1 -1
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/ui.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +14 -0
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/utils/date.d.ts +3 -0
- package/dist/utils/date.d.ts.map +1 -0
- package/dist/utils/routing.d.ts +1 -0
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +249 -115
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +249 -115
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +250 -116
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +4 -3
- package/readme.md +1 -2
- package/src/App.tsx +4 -1
- package/src/components/AppRoutes.tsx +15 -10
- package/src/components/HeaderButtons.tsx +9 -2
- package/src/components/Layout.tsx +25 -6
- package/src/components/SwapDetailsPlaceholder.tsx +32 -0
- package/src/components/TokenPreview.tsx +7 -4
- package/src/globalStyles.ts +2 -1
- package/src/pages/ConfirmSwapPage.tsx +9 -2
- package/src/pages/HistoryPage.tsx +4 -4
- package/src/pages/Home.tsx +18 -7
- package/src/pages/LiquiditySourcesPage.tsx +2 -0
- package/src/pages/SelectTokenPage.tsx +3 -0
- package/src/pages/SettingsPage.tsx +3 -0
- package/src/pages/SwapDetailsPage.tsx +63 -4
- package/src/pages/WalletsPage.tsx +27 -8
- package/src/store/bestRoute.ts +40 -13
- package/src/store/ui.ts +4 -0
- package/src/store/wallets.ts +4 -1
- package/src/utils/date.ts +62 -0
- package/src/utils/routing.ts +23 -13
- package/src/utils/swap.ts +3 -1
- package/dist/components/Header.d.ts +0 -10
- package/dist/components/Header.d.ts.map +0 -1
- package/src/components/Header.tsx +0 -37
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WalletState,
|
|
1
|
+
import { WalletState, InfoCircleIcon, AngleDownIcon, Typography, Spacer, Button, TextField, styled, Tooltip, RetryIcon, HistoryIcon, SettingsIcon, Header as Header$1, VerticalSwapIcon, BestRoute, Alert, ChevronRightIcon, GasIcon, ConfirmSwap, History, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Spinner, LoadingFailedAlert, Wallet, SwapHistory, AddWalletIcon, globalCss, createTheme, SwapContainer } from '@rango-dev/ui';
|
|
2
2
|
import React, { useRef, useEffect, useState, useLayoutEffect } from 'react';
|
|
3
3
|
import { useInRouterContext as useInRouterContext$1, MemoryRouter, useLocation as useLocation$1, useNavigate as useNavigate$1 } from 'react-router';
|
|
4
4
|
import { PendingSwapNetworkStatus, useQueueManager, getCurrentStep, getCurrentBlockchainOfOrNull, getRelatedWalletOrNull, cancelSwap, swapQueueDef, checkWaitingForNetworkChange } from '@rango-dev/queue-manager-rango-preset';
|
|
@@ -16,6 +16,7 @@ import { styled as styled$1 } from '@rango-dev/ui/src/theme';
|
|
|
16
16
|
import { allProviders } from '@rango-dev/provider-all';
|
|
17
17
|
import i18n, { t } from 'i18next';
|
|
18
18
|
import { useManager, Provider } from '@rango-dev/queue-manager-react';
|
|
19
|
+
import dayjs from 'dayjs';
|
|
19
20
|
import copy from 'copy-to-clipboard';
|
|
20
21
|
import Backend from 'i18next-http-backend';
|
|
21
22
|
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
@@ -585,6 +586,7 @@ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, se
|
|
|
585
586
|
addresses: [wallet.address]
|
|
586
587
|
});
|
|
587
588
|
});
|
|
589
|
+
const filteredBlockchains = selectedWallets.map(wallet => wallet.chain);
|
|
588
590
|
const requestBody = {
|
|
589
591
|
amount: inputAmount.toString(),
|
|
590
592
|
checkPrerequisites,
|
|
@@ -602,8 +604,10 @@ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, se
|
|
|
602
604
|
selectedWallets: selectedWalletsMap,
|
|
603
605
|
swapperGroups: disabledLiquiditySources,
|
|
604
606
|
swappersGroupsExclude: true,
|
|
605
|
-
|
|
606
|
-
|
|
607
|
+
slippage: slippage.toString(),
|
|
608
|
+
...(checkPrerequisites && {
|
|
609
|
+
blockchains: filteredBlockchains
|
|
610
|
+
})
|
|
607
611
|
};
|
|
608
612
|
return requestBody;
|
|
609
613
|
}
|
|
@@ -741,8 +745,13 @@ function getRequiredBalanceOfWallet(selectedWallet, fee) {
|
|
|
741
745
|
return relatedFeeStatus.requiredAssets;
|
|
742
746
|
}
|
|
743
747
|
function isRouteParametersChanged(prevParams, currentParams) {
|
|
744
|
-
return prevParams.fromChain?.name !== currentParams.fromChain?.name || prevParams.toChain?.name !== currentParams.toChain?.name || prevParams.fromToken?.symbol !== currentParams.fromToken?.symbol || prevParams.toToken?.symbol !== currentParams.toToken?.symbol || prevParams.fromToken?.blockchain !== currentParams.fromToken?.blockchain || prevParams.toToken?.blockchain !== currentParams.toToken?.blockchain || prevParams.fromToken?.address !== currentParams.fromToken?.address || prevParams.toToken?.address !== currentParams.toToken?.address || prevParams.inputAmount !== currentParams.inputAmount || prevParams.slippage !== currentParams.slippage || prevParams.customSlippage !== currentParams.customSlippage || prevParams.disabledLiquiditySources?.length !== currentParams.disabledLiquiditySources?.length;
|
|
748
|
+
return !!currentParams.fromToken && !!currentParams.toToken && (prevParams.fromChain?.name !== currentParams.fromChain?.name || prevParams.toChain?.name !== currentParams.toChain?.name || prevParams.fromToken?.symbol !== currentParams.fromToken?.symbol || prevParams.toToken?.symbol !== currentParams.toToken?.symbol || prevParams.fromToken?.blockchain !== currentParams.fromToken?.blockchain || prevParams.toToken?.blockchain !== currentParams.toToken?.blockchain || prevParams.fromToken?.address !== currentParams.fromToken?.address || prevParams.toToken?.address !== currentParams.toToken?.address || prevParams.inputAmount !== currentParams.inputAmount || prevParams.slippage !== currentParams.slippage || prevParams.customSlippage !== currentParams.customSlippage || prevParams.disabledLiquiditySources?.length !== currentParams.disabledLiquiditySources?.length);
|
|
745
749
|
}
|
|
750
|
+
//todo: refactor bestRoute store and add loadingStatus
|
|
751
|
+
const getBestRouteStatus = (loading, error) => {
|
|
752
|
+
if (loading) return 'loading';
|
|
753
|
+
if (error) return 'failed';else return 'success';
|
|
754
|
+
};
|
|
746
755
|
|
|
747
756
|
const createSelectors = _store => {
|
|
748
757
|
let store = _store;
|
|
@@ -893,7 +902,7 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
893
902
|
}
|
|
894
903
|
});
|
|
895
904
|
return {
|
|
896
|
-
selectedWallets:
|
|
905
|
+
selectedWallets: selectedWallets
|
|
897
906
|
};
|
|
898
907
|
}),
|
|
899
908
|
setSelectedWallet: wallet => set(state => ({
|
|
@@ -925,6 +934,7 @@ useWalletsStore.subscribe(state => state.balances, balances => {
|
|
|
925
934
|
}, {
|
|
926
935
|
equalityFn: shallow
|
|
927
936
|
});
|
|
937
|
+
const fetchingBalanceSelector = state => !!state.balances.find(wallet => wallet.loading);
|
|
928
938
|
|
|
929
939
|
const getUsdValue = (token, amount) => new BigNumber(amount || ZERO).multipliedBy(token?.usdPrice || 0);
|
|
930
940
|
const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/subscribeWithSelector(set => ({
|
|
@@ -944,6 +954,7 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
944
954
|
setBestRoute: bestRoute => set(state => {
|
|
945
955
|
let outputAmount = null;
|
|
946
956
|
let outputUsdValue = ZERO;
|
|
957
|
+
if (!state.inputAmount || state.inputAmount === '0') return {};
|
|
947
958
|
if (!!bestRoute) {
|
|
948
959
|
outputAmount = !!bestRoute.result?.outputAmount ? new BigNumber(bestRoute.result?.outputAmount) : null;
|
|
949
960
|
outputUsdValue = calcOutputUsdValue(bestRoute.result?.outputAmount, getBestRouteToTokenUsdPrice(bestRoute) || state.toToken?.usdPrice);
|
|
@@ -1000,6 +1011,7 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
1000
1011
|
toToken: token
|
|
1001
1012
|
})),
|
|
1002
1013
|
setInputAmount: amount => {
|
|
1014
|
+
console.log(amount, typeof amount);
|
|
1003
1015
|
set(state => ({
|
|
1004
1016
|
inputAmount: amount,
|
|
1005
1017
|
...(!amount && {
|
|
@@ -1042,7 +1054,7 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
1042
1054
|
fromToken,
|
|
1043
1055
|
inputAmount,
|
|
1044
1056
|
outputAmount: null,
|
|
1045
|
-
inputUsdValue:
|
|
1057
|
+
inputUsdValue: getUsdValue(fromToken || null, inputAmount),
|
|
1046
1058
|
outputUsdValue: new BigNumber(0),
|
|
1047
1059
|
toChain,
|
|
1048
1060
|
toToken,
|
|
@@ -1056,7 +1068,7 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
1056
1068
|
}))));
|
|
1057
1069
|
const bestRoute = (bestRouteStore, settingsStore) => {
|
|
1058
1070
|
let abortController = null;
|
|
1059
|
-
const fetchBestRoute =
|
|
1071
|
+
const fetchBestRoute = () => {
|
|
1060
1072
|
const {
|
|
1061
1073
|
fromToken,
|
|
1062
1074
|
toToken,
|
|
@@ -1067,12 +1079,12 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1067
1079
|
customSlippage,
|
|
1068
1080
|
disabledLiquiditySources
|
|
1069
1081
|
} = settingsStore.getState();
|
|
1070
|
-
if (!fromToken || !toToken || !inputAmount) return;
|
|
1082
|
+
if (!fromToken || !toToken || !inputAmount || inputAmount === '0') return;
|
|
1071
1083
|
abortController?.abort();
|
|
1072
1084
|
abortController = new AbortController();
|
|
1073
1085
|
const userSlippage = !!customSlippage ? customSlippage : slippage;
|
|
1074
1086
|
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false);
|
|
1075
|
-
bestRouteStore.setState({
|
|
1087
|
+
if (!bestRouteStore.getState().loading) bestRouteStore.setState({
|
|
1076
1088
|
loading: true,
|
|
1077
1089
|
bestRoute: null,
|
|
1078
1090
|
outputAmount: null,
|
|
@@ -1096,14 +1108,37 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1096
1108
|
loading: false
|
|
1097
1109
|
});
|
|
1098
1110
|
});
|
|
1099
|
-
}
|
|
1111
|
+
};
|
|
1112
|
+
const debouncedFetchBestRoute = debounce(fetchBestRoute, 600);
|
|
1113
|
+
const bestRouteParamsListener = () => {
|
|
1114
|
+
const {
|
|
1115
|
+
fromToken,
|
|
1116
|
+
toToken,
|
|
1117
|
+
inputAmount,
|
|
1118
|
+
inputUsdValue
|
|
1119
|
+
} = useBestRouteStore.getState();
|
|
1120
|
+
if (!inputAmount || inputAmount === '0') return;
|
|
1121
|
+
if (tokensAreEqual(fromToken, toToken)) return bestRouteStore.setState({
|
|
1122
|
+
loading: false,
|
|
1123
|
+
bestRoute: null,
|
|
1124
|
+
outputAmount: new BigNumber(inputAmount),
|
|
1125
|
+
outputUsdValue: inputUsdValue
|
|
1126
|
+
});
|
|
1127
|
+
if (!bestRouteStore.getState().loading) bestRouteStore.setState({
|
|
1128
|
+
loading: true,
|
|
1129
|
+
bestRoute: null,
|
|
1130
|
+
outputAmount: null,
|
|
1131
|
+
outputUsdValue: new BigNumber(0)
|
|
1132
|
+
});
|
|
1133
|
+
debouncedFetchBestRoute();
|
|
1134
|
+
};
|
|
1100
1135
|
useBestRouteStore.subscribe(state => ({
|
|
1101
1136
|
fromChain: state.fromChain,
|
|
1102
1137
|
fromToken: state.fromToken,
|
|
1103
1138
|
toChain: state.toChain,
|
|
1104
1139
|
toToken: state.toToken,
|
|
1105
1140
|
inputAmount: state.inputAmount
|
|
1106
|
-
}),
|
|
1141
|
+
}), bestRouteParamsListener, {
|
|
1107
1142
|
equalityFn: (prevState, state) => {
|
|
1108
1143
|
if (isRouteParametersChanged(prevState, state)) return false;else return true;
|
|
1109
1144
|
}
|
|
@@ -1112,7 +1147,7 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1112
1147
|
slippage: state.slippage,
|
|
1113
1148
|
customSlippage: state.customSlippage,
|
|
1114
1149
|
disabledLiquiditySources: state.disabledLiquiditySources
|
|
1115
|
-
}),
|
|
1150
|
+
}), bestRouteParamsListener, {
|
|
1116
1151
|
equalityFn: (prevState, state) => {
|
|
1117
1152
|
if (isRouteParametersChanged(prevState, state)) return false;else return true;
|
|
1118
1153
|
}
|
|
@@ -1137,11 +1172,15 @@ var SearchParams;
|
|
|
1137
1172
|
const useUiStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()(set => ({
|
|
1138
1173
|
connectWalletsButtonDisabled: false,
|
|
1139
1174
|
selectedSwapRequestId: null,
|
|
1175
|
+
currentPage: '',
|
|
1140
1176
|
toggleConnectWalletsButton: () => set(state => ({
|
|
1141
1177
|
connectWalletsButtonDisabled: !state.connectWalletsButtonDisabled
|
|
1142
1178
|
})),
|
|
1143
1179
|
setSelectedSwap: requestId => set({
|
|
1144
1180
|
selectedSwapRequestId: requestId
|
|
1181
|
+
}),
|
|
1182
|
+
setCurrentPage: path => set({
|
|
1183
|
+
currentPage: path
|
|
1145
1184
|
})
|
|
1146
1185
|
})));
|
|
1147
1186
|
|
|
@@ -1275,67 +1314,6 @@ function UpdateUrl() {
|
|
|
1275
1314
|
return null;
|
|
1276
1315
|
}
|
|
1277
1316
|
|
|
1278
|
-
const ButtonsContainer = /*#__PURE__*/styled('div', {
|
|
1279
|
-
display: 'flex'
|
|
1280
|
-
});
|
|
1281
|
-
function HeaderButtons(props) {
|
|
1282
|
-
const {
|
|
1283
|
-
onClickRefresh
|
|
1284
|
-
} = props;
|
|
1285
|
-
const navigate = useNavigate();
|
|
1286
|
-
return React.createElement(ButtonsContainer, null, React.createElement(Tooltip, {
|
|
1287
|
-
content: "Refresh"
|
|
1288
|
-
}, React.createElement(Button, {
|
|
1289
|
-
variant: "ghost",
|
|
1290
|
-
onClick: onClickRefresh
|
|
1291
|
-
}, React.createElement(RetryIcon, {
|
|
1292
|
-
size: 24
|
|
1293
|
-
}))), React.createElement(Tooltip, {
|
|
1294
|
-
content: "Transactions History"
|
|
1295
|
-
}, React.createElement(Button, {
|
|
1296
|
-
variant: "ghost",
|
|
1297
|
-
onClick: () => navigate(navigationRoutes.swaps)
|
|
1298
|
-
}, React.createElement(HistoryIcon, {
|
|
1299
|
-
size: 24
|
|
1300
|
-
}))), React.createElement(Tooltip, {
|
|
1301
|
-
content: "Settings"
|
|
1302
|
-
}, React.createElement(Button, {
|
|
1303
|
-
variant: "ghost",
|
|
1304
|
-
onClick: () => navigate(navigationRoutes.settings)
|
|
1305
|
-
}, React.createElement(SettingsIcon, {
|
|
1306
|
-
size: 24
|
|
1307
|
-
}))));
|
|
1308
|
-
}
|
|
1309
|
-
|
|
1310
|
-
const HeaderContainer = /*#__PURE__*/styled('div', {
|
|
1311
|
-
display: 'flex',
|
|
1312
|
-
justifyContent: 'space-between',
|
|
1313
|
-
alignItems: 'center',
|
|
1314
|
-
width: '100%',
|
|
1315
|
-
padding: '$16 0'
|
|
1316
|
-
});
|
|
1317
|
-
function Header(props) {
|
|
1318
|
-
const {
|
|
1319
|
-
onClickRefresh,
|
|
1320
|
-
title,
|
|
1321
|
-
titleSize,
|
|
1322
|
-
titleWeight
|
|
1323
|
-
} = props;
|
|
1324
|
-
const {
|
|
1325
|
-
t
|
|
1326
|
-
} = useTranslation();
|
|
1327
|
-
const titleStyle = css({
|
|
1328
|
-
fontSize: `${titleSize}px !important`,
|
|
1329
|
-
fontWeight: `${titleWeight} !important`
|
|
1330
|
-
});
|
|
1331
|
-
return React.createElement(HeaderContainer, null, React.createElement(Typography, {
|
|
1332
|
-
variant: "h4",
|
|
1333
|
-
className: titleStyle()
|
|
1334
|
-
}, title ? t(title.toLocaleLowerCase()) : ''), React.createElement(HeaderButtons, {
|
|
1335
|
-
onClickRefresh: onClickRefresh
|
|
1336
|
-
}));
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
1317
|
const Box = /*#__PURE__*/styled('div', {
|
|
1340
1318
|
display: 'flex',
|
|
1341
1319
|
flexDirection: 'column',
|
|
@@ -1623,6 +1601,39 @@ const errorMessages = {
|
|
|
1623
1601
|
genericServerError: 'Error connecting server, please reload the app and try again'
|
|
1624
1602
|
};
|
|
1625
1603
|
|
|
1604
|
+
const ButtonsContainer = /*#__PURE__*/styled('div', {
|
|
1605
|
+
display: 'flex'
|
|
1606
|
+
});
|
|
1607
|
+
function HeaderButtons(props) {
|
|
1608
|
+
const {
|
|
1609
|
+
onClickRefresh
|
|
1610
|
+
} = props;
|
|
1611
|
+
const navigate = useNavigate();
|
|
1612
|
+
return React.createElement(ButtonsContainer, null, React.createElement(Tooltip, {
|
|
1613
|
+
content: "Refresh"
|
|
1614
|
+
}, React.createElement(Button, {
|
|
1615
|
+
variant: "ghost",
|
|
1616
|
+
onClick: onClickRefresh,
|
|
1617
|
+
disabled: !onClickRefresh
|
|
1618
|
+
}, React.createElement(RetryIcon, {
|
|
1619
|
+
size: 24
|
|
1620
|
+
}))), React.createElement(Tooltip, {
|
|
1621
|
+
content: "Transactions History"
|
|
1622
|
+
}, React.createElement(Button, {
|
|
1623
|
+
variant: "ghost",
|
|
1624
|
+
onClick: () => navigate(navigationRoutes.swaps)
|
|
1625
|
+
}, React.createElement(HistoryIcon, {
|
|
1626
|
+
size: 24
|
|
1627
|
+
}))), React.createElement(Tooltip, {
|
|
1628
|
+
content: "Settings"
|
|
1629
|
+
}, React.createElement(Button, {
|
|
1630
|
+
variant: "ghost",
|
|
1631
|
+
onClick: () => navigate(navigationRoutes.settings)
|
|
1632
|
+
}, React.createElement(SettingsIcon, {
|
|
1633
|
+
size: 24
|
|
1634
|
+
}))));
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1626
1637
|
const Container$2 = /*#__PURE__*/styled('div', {
|
|
1627
1638
|
display: 'flex',
|
|
1628
1639
|
flexDirection: 'column'
|
|
@@ -1647,9 +1658,7 @@ const Alerts = /*#__PURE__*/styled('div', {
|
|
|
1647
1658
|
});
|
|
1648
1659
|
function Home(props) {
|
|
1649
1660
|
const {
|
|
1650
|
-
title = 'SWAP'
|
|
1651
|
-
titleSize = 18,
|
|
1652
|
-
titleWeight = 600
|
|
1661
|
+
title = 'SWAP'
|
|
1653
1662
|
} = props;
|
|
1654
1663
|
const isRouterInContext = useInRouterContext();
|
|
1655
1664
|
const navigate = useNavigate();
|
|
@@ -1673,6 +1682,7 @@ function Home(props) {
|
|
|
1673
1682
|
const bestRouteError = useBestRouteStore.use.error();
|
|
1674
1683
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
1675
1684
|
const accounts = useWalletsStore.use.accounts();
|
|
1685
|
+
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
1676
1686
|
const swithFromAndTo = () => {
|
|
1677
1687
|
setFromChain(toChain);
|
|
1678
1688
|
setFromToken(toToken);
|
|
@@ -1696,11 +1706,15 @@ function Home(props) {
|
|
|
1696
1706
|
const swapButtonState = getSwapButtonState(loadingMetaStatus, accounts, fetchingBestRoute, bestRoute, hasLimitError(bestRoute), highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputIsZero);
|
|
1697
1707
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
1698
1708
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
1699
|
-
|
|
1709
|
+
useEffect(() => {
|
|
1710
|
+
setCurrentPage(navigationRoutes.home);
|
|
1711
|
+
return setCurrentPage.bind(null, '');
|
|
1712
|
+
}, []);
|
|
1713
|
+
return React.createElement(Container$2, null, React.createElement(Header$1, {
|
|
1700
1714
|
title: title,
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1715
|
+
suffix: React.createElement(HeaderButtons, {
|
|
1716
|
+
onClickRefresh: !!bestRoute ? fetchBestRoute : undefined
|
|
1717
|
+
})
|
|
1704
1718
|
}), React.createElement(FromContainer, null, React.createElement(TokenInfo, {
|
|
1705
1719
|
type: "From",
|
|
1706
1720
|
chain: fromChain,
|
|
@@ -1711,7 +1725,7 @@ function Home(props) {
|
|
|
1711
1725
|
variant: "ghost",
|
|
1712
1726
|
onClick: swithFromAndTo
|
|
1713
1727
|
}, React.createElement(VerticalSwapIcon, {
|
|
1714
|
-
size:
|
|
1728
|
+
size: 32
|
|
1715
1729
|
}), isRouterInContext && React.createElement(SwithFromAndTo, {
|
|
1716
1730
|
count: count
|
|
1717
1731
|
})))), React.createElement(TokenInfo, {
|
|
@@ -1906,7 +1920,7 @@ function TokenPreview(props) {
|
|
|
1906
1920
|
}, React.createElement(Typography, {
|
|
1907
1921
|
variant: "body2",
|
|
1908
1922
|
color: "neutrals800"
|
|
1909
|
-
}, props.label), React.createElement(Typography, {
|
|
1923
|
+
}, props.label), props.usdValue && React.createElement(Typography, {
|
|
1910
1924
|
variant: "caption",
|
|
1911
1925
|
color: "neutrals600"
|
|
1912
1926
|
}, `$${numberToString(props.usdValue)}`)), React.createElement("div", {
|
|
@@ -2276,6 +2290,7 @@ function ConfirmSwapPage() {
|
|
|
2276
2290
|
} = useNavigateBack();
|
|
2277
2291
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
2278
2292
|
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
2293
|
+
const fetchingBestRouteError = useBestRouteStore.use.error();
|
|
2279
2294
|
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
2280
2295
|
const {
|
|
2281
2296
|
blockchains,
|
|
@@ -2287,6 +2302,7 @@ function ConfirmSwapPage() {
|
|
|
2287
2302
|
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
2288
2303
|
const slippage = useSettingsStore.use.slippage();
|
|
2289
2304
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
2305
|
+
const bestRouteloadingStatus = getBestRouteStatus(fetchingBestRoute, !!fetchingBestRouteError);
|
|
2290
2306
|
const {
|
|
2291
2307
|
manager
|
|
2292
2308
|
} = useManager();
|
|
@@ -2351,7 +2367,7 @@ function ConfirmSwapPage() {
|
|
|
2351
2367
|
usdValue: calcOutputUsdValue(fromAmount, firstStep?.from.usdPrice),
|
|
2352
2368
|
amount: fromAmount,
|
|
2353
2369
|
label: t('From'),
|
|
2354
|
-
loadingStatus:
|
|
2370
|
+
loadingStatus: bestRouteloadingStatus
|
|
2355
2371
|
}), React.createElement(Spacer, {
|
|
2356
2372
|
size: 12,
|
|
2357
2373
|
direction: "vertical"
|
|
@@ -2367,7 +2383,7 @@ function ConfirmSwapPage() {
|
|
|
2367
2383
|
usdValue: calcOutputUsdValue(toAmount, lastStep?.to.usdPrice),
|
|
2368
2384
|
amount: toAmount,
|
|
2369
2385
|
label: t('To'),
|
|
2370
|
-
loadingStatus:
|
|
2386
|
+
loadingStatus: bestRouteloadingStatus
|
|
2371
2387
|
})),
|
|
2372
2388
|
previewRoutes: React.createElement(RoutesOverview, {
|
|
2373
2389
|
routes: bestRoute,
|
|
@@ -2397,6 +2413,31 @@ const getPendingSwaps = manager => {
|
|
|
2397
2413
|
return result.sort((a, b) => Number(b.swap.creationTime) - Number(a.swap.creationTime));
|
|
2398
2414
|
};
|
|
2399
2415
|
|
|
2416
|
+
const groupSwapsByDate = swaps => {
|
|
2417
|
+
const output = new Map([['today', {
|
|
2418
|
+
title: 'Today',
|
|
2419
|
+
swaps: []
|
|
2420
|
+
}], ['week', {
|
|
2421
|
+
title: 'This week',
|
|
2422
|
+
swaps: []
|
|
2423
|
+
}], ['month', {
|
|
2424
|
+
title: 'This month',
|
|
2425
|
+
swaps: []
|
|
2426
|
+
}], ['year', {
|
|
2427
|
+
title: 'This year',
|
|
2428
|
+
swaps: []
|
|
2429
|
+
}], ['history', {
|
|
2430
|
+
title: 'History',
|
|
2431
|
+
swaps: []
|
|
2432
|
+
}]]);
|
|
2433
|
+
const now = dayjs();
|
|
2434
|
+
swaps.forEach(swap => {
|
|
2435
|
+
const swapDate = dayjs(Number(swap.creationTime));
|
|
2436
|
+
if (now.isSame(swapDate, 'day')) output.get('today')?.swaps.push(swap);else if (now.isSame(swapDate, 'week')) output.get('week')?.swaps.push(swap);else if (now.isSame(swapDate, 'month')) output.get('month')?.swaps.push(swap);else if (now.isSame(swapDate, 'year')) output.get('year')?.swaps.push(swap);else output.get('history')?.swaps.push(swap);
|
|
2437
|
+
});
|
|
2438
|
+
return Array.from(output.values());
|
|
2439
|
+
};
|
|
2440
|
+
|
|
2400
2441
|
function HistoryPage() {
|
|
2401
2442
|
const setSelectedSwap = useUiStore.use.setSelectedSwap();
|
|
2402
2443
|
const navigate = useNavigate();
|
|
@@ -2412,16 +2453,14 @@ function HistoryPage() {
|
|
|
2412
2453
|
} = _ref;
|
|
2413
2454
|
return swap;
|
|
2414
2455
|
});
|
|
2415
|
-
return React.createElement(History
|
|
2416
|
-
//todo: move PendingSwap type to rango-types
|
|
2417
|
-
//@ts-ignore
|
|
2418
|
-
, {
|
|
2419
|
-
//todo: move PendingSwap type to rango-types
|
|
2420
|
-
//@ts-ignore
|
|
2456
|
+
return React.createElement(History, {
|
|
2421
2457
|
list: pendingSwaps,
|
|
2458
|
+
groupBy: groupSwapsByDate,
|
|
2422
2459
|
onSwapClick: requestId => {
|
|
2423
2460
|
setSelectedSwap(requestId);
|
|
2424
|
-
navigate(navigationRoutes.swaps + `/${requestId}
|
|
2461
|
+
navigate(navigationRoutes.swaps + `/${requestId}`, {
|
|
2462
|
+
replace: true
|
|
2463
|
+
});
|
|
2425
2464
|
},
|
|
2426
2465
|
onBack: navigateBackFrom.bind(null, navigationRoutes.swaps)
|
|
2427
2466
|
});
|
|
@@ -2432,6 +2471,7 @@ function LiquiditySourcePage(_ref) {
|
|
|
2432
2471
|
supportedSwappers
|
|
2433
2472
|
} = _ref;
|
|
2434
2473
|
const swappers = useMetaStore.use.meta().swappers;
|
|
2474
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2435
2475
|
const toggleLiquiditySource = useSettingsStore.use.toggleLiquiditySource();
|
|
2436
2476
|
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
2437
2477
|
const toggleAllLiquiditySources = useSettingsStore.use.toggleAllLiquiditySources();
|
|
@@ -2457,7 +2497,8 @@ function LiquiditySourcePage(_ref) {
|
|
|
2457
2497
|
toggleAll: toggleAllLiquiditySources,
|
|
2458
2498
|
list: supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups,
|
|
2459
2499
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
2460
|
-
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources)
|
|
2500
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources),
|
|
2501
|
+
loadingStatus: loadingMetaStatus
|
|
2461
2502
|
});
|
|
2462
2503
|
}
|
|
2463
2504
|
|
|
@@ -2504,6 +2545,7 @@ function SelectTokenPage(props) {
|
|
|
2504
2545
|
const toToken = useBestRouteStore.use.toToken();
|
|
2505
2546
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
2506
2547
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
2548
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2507
2549
|
return React.createElement(TokenSelector, {
|
|
2508
2550
|
type: type === 'from' ? 'Source' : 'Destination',
|
|
2509
2551
|
list: type == 'from' ? supportedSourceTokens : supportedDestinationTokens,
|
|
@@ -2512,7 +2554,8 @@ function SelectTokenPage(props) {
|
|
|
2512
2554
|
if (type === 'from') setFromToken(token);else setToToken(token);
|
|
2513
2555
|
navigateBackFrom(navigationRoutes.fromToken);
|
|
2514
2556
|
},
|
|
2515
|
-
onBack: navigateBackFrom.bind(null, navigationRoutes.fromToken)
|
|
2557
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.fromToken),
|
|
2558
|
+
loadingStatus: loadingMetaStatus
|
|
2516
2559
|
});
|
|
2517
2560
|
}
|
|
2518
2561
|
|
|
@@ -2534,6 +2577,7 @@ function SettingsPage(_ref) {
|
|
|
2534
2577
|
} = useNavigateBack();
|
|
2535
2578
|
const infiniteApprove = useSettingsStore.use.infiniteApprove();
|
|
2536
2579
|
const toggleInfiniteApprove = useSettingsStore.use.toggleInfiniteApprove();
|
|
2580
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2537
2581
|
const uniqueSwappersGroups = [];
|
|
2538
2582
|
removeDuplicateFrom(swappers.map(s => s.swapperGroup)).map(swapperGroup => {
|
|
2539
2583
|
return swappers.find(s => s.swapperGroup === swapperGroup);
|
|
@@ -2566,7 +2610,8 @@ function SettingsPage(_ref) {
|
|
|
2566
2610
|
selectedTheme: theme,
|
|
2567
2611
|
onThemeChange: setTheme,
|
|
2568
2612
|
infiniteApprove: infiniteApprove,
|
|
2569
|
-
toggleInfiniteApprove: toggleInfiniteApprove
|
|
2613
|
+
toggleInfiniteApprove: toggleInfiniteApprove,
|
|
2614
|
+
loadingStatus: loadingMetaStatus
|
|
2570
2615
|
});
|
|
2571
2616
|
}
|
|
2572
2617
|
|
|
@@ -2574,9 +2619,16 @@ const ListContainer = /*#__PURE__*/styled('div', {
|
|
|
2574
2619
|
display: 'grid',
|
|
2575
2620
|
gap: '.5rem',
|
|
2576
2621
|
gridTemplateColumns: ' repeat(2, minmax(0, 1fr))',
|
|
2577
|
-
height: '450px',
|
|
2578
2622
|
alignContent: 'baseline',
|
|
2579
|
-
padding: '0.5rem'
|
|
2623
|
+
padding: '0.5rem',
|
|
2624
|
+
overflowY: 'auto'
|
|
2625
|
+
});
|
|
2626
|
+
const LoaderContainer = /*#__PURE__*/styled('div', {
|
|
2627
|
+
display: 'flex',
|
|
2628
|
+
justifyContent: 'center',
|
|
2629
|
+
width: '100%',
|
|
2630
|
+
position: 'absolute',
|
|
2631
|
+
top: '50%'
|
|
2580
2632
|
});
|
|
2581
2633
|
const AlertContainer = /*#__PURE__*/styled('div', {
|
|
2582
2634
|
paddingBottom: '$16'
|
|
@@ -2601,6 +2653,7 @@ function WalletsPage(_ref) {
|
|
|
2601
2653
|
sortedWallets = sortWalletsBasedOnState(sortedWallets);
|
|
2602
2654
|
const [walletErrorMessage, setWalletErrorMessage] = useState('');
|
|
2603
2655
|
const toggleConnectWalletsButton = useUiStore.use.toggleConnectWalletsButton();
|
|
2656
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2604
2657
|
const {
|
|
2605
2658
|
t
|
|
2606
2659
|
} = useTranslation();
|
|
@@ -2642,7 +2695,11 @@ function WalletsPage(_ref) {
|
|
|
2642
2695
|
onBack: navigateBackFrom.bind(null, navigationRoutes.wallets)
|
|
2643
2696
|
}, React.createElement(React.Fragment, null, walletErrorMessage && React.createElement(AlertContainer, null, React.createElement(Alert, {
|
|
2644
2697
|
type: "error"
|
|
2645
|
-
}, walletErrorMessage)),
|
|
2698
|
+
}, walletErrorMessage)), loadingMetaStatus === 'loading' && React.createElement(LoaderContainer, {
|
|
2699
|
+
className: "loader"
|
|
2700
|
+
}, React.createElement(Spinner, {
|
|
2701
|
+
size: 24
|
|
2702
|
+
})), loadingMetaStatus === 'failed' && React.createElement(LoadingFailedAlert, null), React.createElement(ListContainer, null, loadingMetaStatus === 'success' && sortedWallets.map((wallet, index) => React.createElement(Wallet, Object.assign({}, wallet, {
|
|
2646
2703
|
key: `${index}-${wallet.type}`,
|
|
2647
2704
|
onClick: onSelectWallet
|
|
2648
2705
|
}))))));
|
|
@@ -2705,6 +2762,27 @@ function getSwapDate(pendingSwap) {
|
|
|
2705
2762
|
return pendingSwap.finishTime ? `Finished ${timeSince(parseInt(pendingSwap.finishTime))} ago @ ${new Date(parseInt(pendingSwap.finishTime)).toLocaleString()}` : `Started ${timeSince(parseInt(pendingSwap.creationTime))} ago @ ${new Date(parseInt(pendingSwap.creationTime)).toLocaleString()}`;
|
|
2706
2763
|
}
|
|
2707
2764
|
|
|
2765
|
+
const PlaceholderContainer = /*#__PURE__*/styled('div', {
|
|
2766
|
+
height: '450px'
|
|
2767
|
+
});
|
|
2768
|
+
function SwapDetailsPlaceholder(props) {
|
|
2769
|
+
const {
|
|
2770
|
+
requestId,
|
|
2771
|
+
loading,
|
|
2772
|
+
onBack
|
|
2773
|
+
} = props;
|
|
2774
|
+
return React.createElement(SecondaryPage, {
|
|
2775
|
+
title: "Swap Details",
|
|
2776
|
+
textField: false,
|
|
2777
|
+
onBack: onBack
|
|
2778
|
+
}, React.createElement(PlaceholderContainer, null, loading ? React.createElement(LoaderContainer, null, React.createElement(Spinner, {
|
|
2779
|
+
size: 24
|
|
2780
|
+
})) : React.createElement(Alert, {
|
|
2781
|
+
type: "secondary",
|
|
2782
|
+
title: `Swap with request ID = ${requestId} not found.`
|
|
2783
|
+
})));
|
|
2784
|
+
}
|
|
2785
|
+
|
|
2708
2786
|
function SwapDetailsPage() {
|
|
2709
2787
|
const selectedSwapRequestId = useUiStore.use.selectedSwapRequestId();
|
|
2710
2788
|
const {
|
|
@@ -2720,6 +2798,12 @@ function SwapDetailsPage() {
|
|
|
2720
2798
|
const {
|
|
2721
2799
|
manager
|
|
2722
2800
|
} = useManager();
|
|
2801
|
+
const [loading, setLoading] = useState(true);
|
|
2802
|
+
useEffect(() => {
|
|
2803
|
+
setTimeout(() => {
|
|
2804
|
+
setLoading(false);
|
|
2805
|
+
}, 5000);
|
|
2806
|
+
}, []);
|
|
2723
2807
|
const pendingSwaps = getPendingSwaps(manager);
|
|
2724
2808
|
const selectedSwap = pendingSwaps.find(_ref => {
|
|
2725
2809
|
let {
|
|
@@ -2732,7 +2816,15 @@ function SwapDetailsPage() {
|
|
|
2732
2816
|
if (swap) cancelSwap(swap);
|
|
2733
2817
|
};
|
|
2734
2818
|
const swap = selectedSwap?.swap;
|
|
2735
|
-
if (!swap) return
|
|
2819
|
+
if (!swap) return React.createElement(SwapDetailsPlaceholder, {
|
|
2820
|
+
requestId: selectedSwapRequestId || '',
|
|
2821
|
+
loading: loading,
|
|
2822
|
+
onBack: navigateBackFrom.bind(null, navigationRoutes.swapDetails)
|
|
2823
|
+
});
|
|
2824
|
+
const firstStep = swap.steps[0];
|
|
2825
|
+
const lastStep = swap.steps[swap.steps.length - 1];
|
|
2826
|
+
const fromAmount = numberToString(swap.inputAmount);
|
|
2827
|
+
const toAmount = numberToString(swap.simulationResult.outputAmount);
|
|
2736
2828
|
const currentStep = getCurrentStep(swap);
|
|
2737
2829
|
const currentStepBlockchain = currentStep ? getCurrentBlockchainOfOrNull(swap, currentStep) : null;
|
|
2738
2830
|
const currentStepWallet = currentStep ? getRelatedWalletOrNull(swap, currentStep) : null;
|
|
@@ -2745,6 +2837,36 @@ function SwapDetailsPage() {
|
|
|
2745
2837
|
const lastConvertedTokenInFailedSwap = getLastConvertedTokenInFailedSwap(swap);
|
|
2746
2838
|
return React.createElement(SwapHistory, Object.assign({
|
|
2747
2839
|
onBack: navigateBackFrom.bind(null, navigationRoutes.swapDetails),
|
|
2840
|
+
previewInputs: React.createElement(React.Fragment, null, React.createElement(TokenPreview, {
|
|
2841
|
+
chain: {
|
|
2842
|
+
displayName: firstStep?.fromBlockchain || '',
|
|
2843
|
+
// @ts-ignore
|
|
2844
|
+
logo: firstStep?.fromBlockchainLogo || ''
|
|
2845
|
+
},
|
|
2846
|
+
token: {
|
|
2847
|
+
symbol: firstStep?.fromSymbol || '',
|
|
2848
|
+
image: firstStep?.fromLogo || ''
|
|
2849
|
+
},
|
|
2850
|
+
amount: fromAmount,
|
|
2851
|
+
label: t('From'),
|
|
2852
|
+
loadingStatus: 'success'
|
|
2853
|
+
}), React.createElement(Spacer, {
|
|
2854
|
+
size: 12,
|
|
2855
|
+
direction: "vertical"
|
|
2856
|
+
}), React.createElement(TokenPreview, {
|
|
2857
|
+
chain: {
|
|
2858
|
+
displayName: lastStep?.toBlockchain || '',
|
|
2859
|
+
// @ts-ignore
|
|
2860
|
+
logo: lastStep?.toBlockchainLogo || ''
|
|
2861
|
+
},
|
|
2862
|
+
token: {
|
|
2863
|
+
symbol: lastStep?.toSymbol || '',
|
|
2864
|
+
image: lastStep?.toLogo || ''
|
|
2865
|
+
},
|
|
2866
|
+
amount: toAmount,
|
|
2867
|
+
label: t('To'),
|
|
2868
|
+
loadingStatus: 'success'
|
|
2869
|
+
})),
|
|
2748
2870
|
//todo: move PendingSwap type to rango-types
|
|
2749
2871
|
//@ts-ignore
|
|
2750
2872
|
pendingSwap: swap,
|
|
@@ -2767,79 +2889,83 @@ function SwapDetailsPage() {
|
|
|
2767
2889
|
}, lastConvertedTokenInFailedSwap && {
|
|
2768
2890
|
lastConvertedTokenInFailedSwap: {
|
|
2769
2891
|
blockchain: lastConvertedTokenInFailedSwap.blockchain,
|
|
2770
|
-
outputAmount: lastConvertedTokenInFailedSwap.outputAmount,
|
|
2892
|
+
outputAmount: lastConvertedTokenInFailedSwap.outputAmount || '',
|
|
2771
2893
|
symbol: lastConvertedTokenInFailedSwap.symbol
|
|
2772
2894
|
}
|
|
2773
2895
|
}));
|
|
2774
2896
|
}
|
|
2775
2897
|
|
|
2898
|
+
const getAbsolutePath = path => path.replace('/', '');
|
|
2776
2899
|
function AppRoutes(props) {
|
|
2777
2900
|
const {
|
|
2778
2901
|
configs
|
|
2779
2902
|
} = props;
|
|
2780
2903
|
return useRoutes([{
|
|
2781
|
-
path: navigationRoutes.home,
|
|
2904
|
+
path: getAbsolutePath(navigationRoutes.home),
|
|
2782
2905
|
element: React.createElement(Home, {
|
|
2783
2906
|
title: configs?.title,
|
|
2784
2907
|
titleSize: configs?.titleSize,
|
|
2785
2908
|
titleWeight: configs?.titleWeight
|
|
2786
2909
|
})
|
|
2787
2910
|
}, {
|
|
2788
|
-
path: navigationRoutes.fromChain,
|
|
2911
|
+
path: getAbsolutePath(navigationRoutes.fromChain),
|
|
2789
2912
|
element: React.createElement(SelectChainPage, {
|
|
2790
2913
|
type: "from",
|
|
2791
2914
|
supportedChains: configs?.fromChains || 'all'
|
|
2792
2915
|
})
|
|
2793
2916
|
}, {
|
|
2794
|
-
path: navigationRoutes.toChain,
|
|
2917
|
+
path: getAbsolutePath(navigationRoutes.toChain),
|
|
2795
2918
|
element: React.createElement(SelectChainPage, {
|
|
2796
2919
|
type: "to",
|
|
2797
2920
|
supportedChains: configs?.toChains || 'all'
|
|
2798
2921
|
})
|
|
2799
2922
|
}, {
|
|
2800
|
-
path: navigationRoutes.fromToken
|
|
2923
|
+
path: getAbsolutePath(navigationRoutes.fromToken),
|
|
2801
2924
|
element: React.createElement(SelectTokenPage, {
|
|
2802
2925
|
type: "from",
|
|
2803
2926
|
supportedTokens: configs?.fromTokens || 'all'
|
|
2804
2927
|
})
|
|
2805
2928
|
}, {
|
|
2806
|
-
path: navigationRoutes.toToken,
|
|
2929
|
+
path: getAbsolutePath(navigationRoutes.toToken),
|
|
2807
2930
|
element: React.createElement(SelectTokenPage, {
|
|
2808
2931
|
type: "to",
|
|
2809
2932
|
supportedTokens: configs?.toTokens || 'all'
|
|
2810
2933
|
})
|
|
2811
2934
|
}, {
|
|
2812
|
-
path: navigationRoutes.settings,
|
|
2935
|
+
path: getAbsolutePath(navigationRoutes.settings),
|
|
2813
2936
|
element: React.createElement(SettingsPage, {
|
|
2814
2937
|
supportedSwappers: configs?.liquiditySources || 'all'
|
|
2815
2938
|
})
|
|
2816
2939
|
}, {
|
|
2817
|
-
path: navigationRoutes.liquiditySources,
|
|
2940
|
+
path: getAbsolutePath(navigationRoutes.liquiditySources),
|
|
2818
2941
|
element: React.createElement(LiquiditySourcePage, {
|
|
2819
2942
|
supportedSwappers: configs?.liquiditySources || 'all'
|
|
2820
2943
|
})
|
|
2821
2944
|
}, {
|
|
2822
|
-
path: navigationRoutes.swaps,
|
|
2945
|
+
path: getAbsolutePath(navigationRoutes.swaps),
|
|
2823
2946
|
element: React.createElement(HistoryPage, null)
|
|
2824
2947
|
}, {
|
|
2825
2948
|
path: navigationRoutes.swapDetails,
|
|
2826
2949
|
element: React.createElement(SwapDetailsPage, null)
|
|
2827
2950
|
}, {
|
|
2828
|
-
path: navigationRoutes.wallets,
|
|
2951
|
+
path: getAbsolutePath(navigationRoutes.wallets),
|
|
2829
2952
|
element: React.createElement(WalletsPage, {
|
|
2830
2953
|
supportedWallets: configs?.wallets || 'all',
|
|
2831
2954
|
multiWallets: typeof configs?.multiWallets === 'undefined' ? true : configs.multiWallets
|
|
2832
2955
|
})
|
|
2833
2956
|
}, {
|
|
2834
|
-
path: navigationRoutes.confirmSwap,
|
|
2957
|
+
path: getAbsolutePath(navigationRoutes.confirmSwap),
|
|
2835
2958
|
element: React.createElement(ConfirmSwapPage, null)
|
|
2836
2959
|
}]);
|
|
2837
2960
|
}
|
|
2838
2961
|
|
|
2839
|
-
const Header
|
|
2962
|
+
const Header = /*#__PURE__*/styled('div', {
|
|
2840
2963
|
display: 'flex',
|
|
2841
2964
|
width: '100%',
|
|
2842
|
-
justifyContent: 'end'
|
|
2965
|
+
justifyContent: 'end',
|
|
2966
|
+
'.balance': {
|
|
2967
|
+
display: 'flex'
|
|
2968
|
+
}
|
|
2843
2969
|
});
|
|
2844
2970
|
const WalletImage = /*#__PURE__*/styled('img', {
|
|
2845
2971
|
width: '$24',
|
|
@@ -2869,6 +2995,8 @@ function Layout(_ref) {
|
|
|
2869
2995
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2870
2996
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
2871
2997
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
2998
|
+
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2999
|
+
const fetchingBalance = useWalletsStore(fetchingBalanceSelector);
|
|
2872
3000
|
const {
|
|
2873
3001
|
t
|
|
2874
3002
|
} = useTranslation();
|
|
@@ -2889,22 +3017,26 @@ function Layout(_ref) {
|
|
|
2889
3017
|
setFromToken(null);
|
|
2890
3018
|
setToToken(null);
|
|
2891
3019
|
}, [configs?.fromChains, configs?.toChains, configs?.fromTokens, configs?.toTokens]);
|
|
2892
|
-
return React.createElement(React.Fragment, null, React.createElement(Header
|
|
3020
|
+
return React.createElement(React.Fragment, null, React.createElement(Header, null, React.createElement(Button, {
|
|
2893
3021
|
size: "small",
|
|
2894
3022
|
suffix: React.createElement(AddWalletIcon, {
|
|
2895
3023
|
size: 20
|
|
2896
3024
|
}),
|
|
2897
3025
|
variant: "ghost",
|
|
2898
3026
|
flexContent: true,
|
|
3027
|
+
loading: loadingMetaStatus === 'loading',
|
|
3028
|
+
disabled: loadingMetaStatus === 'failed',
|
|
2899
3029
|
onClick: () => {
|
|
2900
3030
|
if (!connectWalletsButtonDisabled) navigate(navigationRoutes.wallets);
|
|
2901
3031
|
}
|
|
2902
3032
|
}, connectedWalletsImages?.length ? connectedWalletsImages.map((walletImage, index) => React.createElement(WalletImage, {
|
|
2903
3033
|
key: index,
|
|
2904
3034
|
src: walletImage
|
|
2905
|
-
})) : React.createElement(React.Fragment, null), React.createElement(
|
|
3035
|
+
})) : React.createElement(React.Fragment, null), React.createElement("div", {
|
|
3036
|
+
className: "balance"
|
|
3037
|
+
}, React.createElement(Typography, {
|
|
2906
3038
|
variant: "body2"
|
|
2907
|
-
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`))), React.createElement(AppRoutes, {
|
|
3039
|
+
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React.createElement(Spinner, null)))), React.createElement(AppRoutes, {
|
|
2908
3040
|
configs: configs
|
|
2909
3041
|
}));
|
|
2910
3042
|
}
|
|
@@ -2912,10 +3044,12 @@ function Layout(_ref) {
|
|
|
2912
3044
|
const globalStyles = /*#__PURE__*/globalCss({
|
|
2913
3045
|
'*': {
|
|
2914
3046
|
'&::-webkit-scrollbar': {
|
|
2915
|
-
width: '$8'
|
|
3047
|
+
width: '$8',
|
|
3048
|
+
height: '$8'
|
|
2916
3049
|
},
|
|
2917
3050
|
'&::-webkit-scrollbar-thumb': {
|
|
2918
|
-
backgroundColor: '$neutrals400'
|
|
3051
|
+
backgroundColor: '$neutrals400',
|
|
3052
|
+
borderRadius: '$10'
|
|
2919
3053
|
},
|
|
2920
3054
|
'&::-webkit-scrollbar-thumb:hover': {
|
|
2921
3055
|
backgroundColor: '$neutrals500'
|