@rango-dev/widget-embedded 0.1.10-next.88 → 0.1.10-next.91
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 +4 -16
- package/dist/App.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +7 -1
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +2 -1
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/BottomLogo.d.ts.map +1 -1
- package/dist/components/Header.d.ts +3 -0
- package/dist/components/Header.d.ts.map +1 -1
- package/dist/components/Layout.d.ts +5 -1
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/globalStyles.d.ts +1 -0
- package/dist/globalStyles.d.ts.map +1 -1
- package/dist/hooks/usePrevious.d.ts +2 -0
- package/dist/hooks/usePrevious.d.ts.map +1 -0
- package/dist/hooks/useSelectLanguage.d.ts +5 -0
- package/dist/hooks/useSelectLanguage.d.ts.map +1 -0
- package/dist/hooks/useTheme.d.ts +5 -1
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/i18n.d.ts +3 -0
- package/dist/i18n.d.ts.map +1 -0
- package/dist/lib.d.ts +6 -1
- package/dist/lib.d.ts.map +1 -1
- package/dist/pages/Home.d.ts +7 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcesPage.d.ts +6 -1
- package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
- package/dist/pages/SelectChainPage.d.ts +2 -0
- package/dist/pages/SelectChainPage.d.ts.map +1 -1
- package/dist/pages/SelectTokenPage.d.ts +1 -0
- package/dist/pages/SelectTokenPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +6 -1
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +7 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/config.d.ts +40 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.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/swap.d.ts +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +503 -102
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +503 -102
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +508 -107
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +8 -3
- package/src/App.tsx +25 -30
- package/src/app.css +0 -1
- package/src/components/AppRouter.tsx +16 -6
- package/src/components/AppRoutes.tsx +40 -9
- package/src/components/BottomLogo.tsx +4 -1
- package/src/components/Header.tsx +15 -3
- package/src/components/Layout.tsx +30 -4
- package/src/components/TokenInfo.tsx +68 -23
- package/src/globalStyles.ts +10 -0
- package/src/hooks/usePrevious.ts +13 -0
- package/src/hooks/useSelectLanguage.ts +15 -0
- package/src/hooks/useTheme.ts +101 -11
- package/src/i18n.js +30 -0
- package/src/languages/en.json +13 -0
- package/src/languages/tr.json +11 -0
- package/src/lib.tsx +66 -12
- package/src/pages/Home.tsx +15 -3
- package/src/pages/LiquiditySourcesPage.tsx +16 -4
- package/src/pages/SelectChainPage.tsx +7 -3
- package/src/pages/SelectTokenPage.tsx +6 -2
- package/src/pages/SettingsPage.tsx +29 -5
- package/src/pages/WalletsPage.tsx +17 -3
- package/src/store/confirmSwap.ts +1 -1
- package/src/store/wallets.ts +8 -0
- package/src/types/config.ts +44 -0
- package/src/types/index.ts +1 -0
- package/src/utils/common.ts +30 -2
- package/src/utils/swap.ts +1 -1
- package/src/utils/wallets.ts +2 -2
|
@@ -1,18 +1,24 @@
|
|
|
1
|
-
import { WalletState, Tooltip, Button, RetryIcon, HistoryIcon, SettingsIcon, styled, Typography, InfoCircleIcon, AngleDownIcon, TextField, VerticalSwapIcon, BestRoute, Alert, ConfirmSwap, History, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Wallet, ConfirmWallets, SwapHistory, AddWalletIcon, globalCss,
|
|
2
|
-
import React, { useRef, useEffect, useState } from 'react';
|
|
1
|
+
import { WalletState, Tooltip, Button, RetryIcon, HistoryIcon, SettingsIcon, styled, css, Typography, InfoCircleIcon, AngleDownIcon, TextField, VerticalSwapIcon, BestRoute, Alert, ConfirmSwap, History, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Wallet, ConfirmWallets, SwapHistory, AddWalletIcon, globalCss, createTheme, SwapContainer } from '@rango-dev/ui';
|
|
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 { useSearchParams, useLocation, createSearchParams, useNavigate, useInRouterContext, useRoutes } from 'react-router-dom';
|
|
5
5
|
import { create } from 'zustand';
|
|
6
6
|
import BigNumber, { BigNumber as BigNumber$1 } from 'bignumber.js';
|
|
7
7
|
import { persist, subscribeWithSelector } from 'zustand/middleware';
|
|
8
8
|
import { RangoClient, isEvmBlockchain } from 'rango-sdk';
|
|
9
|
-
import { Network, isEvmAddress, KEPLR_COMPATIBLE_WALLETS, WalletType, getCosmosExperimentalChainInfo,
|
|
10
|
-
import {
|
|
9
|
+
import { Network, isEvmAddress, KEPLR_COMPATIBLE_WALLETS, WalletType, getCosmosExperimentalChainInfo, convertEvmBlockchainMetaToEvmChainInfo } from '@rango-dev/wallets-shared';
|
|
10
|
+
import { isCosmosBlockchain } from 'rango-types';
|
|
11
|
+
import { readAccountAddress, useWallets, Provider as Provider$1, Events } from '@rango-dev/wallets-core';
|
|
12
|
+
import { useTranslation, initReactI18next } from 'react-i18next';
|
|
11
13
|
import { styled as styled$1 } from '@rango-dev/ui/src/theme';
|
|
12
14
|
import { allProviders } from '@rango-dev/provider-all';
|
|
13
15
|
import { shallow } from 'zustand/shallow';
|
|
14
|
-
import { useManager } from '@rango-dev/queue-manager-react';
|
|
16
|
+
import { useManager, Provider } from '@rango-dev/queue-manager-react';
|
|
15
17
|
import copy from 'copy-to-clipboard';
|
|
18
|
+
import i18n from 'i18next';
|
|
19
|
+
import Backend from 'i18next-http-backend';
|
|
20
|
+
import LanguageDetector from 'i18next-browser-languagedetector';
|
|
21
|
+
import { swapQueueDef } from '@rango-dev/queue-manager-rango-preset';
|
|
16
22
|
|
|
17
23
|
const navigationRoutes = {
|
|
18
24
|
home: '/',
|
|
@@ -37,6 +43,24 @@ function removeDuplicateFrom(array) {
|
|
|
37
43
|
function areEqual(array1, array2) {
|
|
38
44
|
return array1.length === array2.length && array1.every((v, i) => v === array2[i]);
|
|
39
45
|
}
|
|
46
|
+
function shadeColor(color, percent) {
|
|
47
|
+
var R = parseInt(color.substring(1, 3), 16);
|
|
48
|
+
var G = parseInt(color.substring(3, 5), 16);
|
|
49
|
+
var B = parseInt(color.substring(5, 7), 16);
|
|
50
|
+
R = R * (100 + percent) / 100;
|
|
51
|
+
G = G * (100 + percent) / 100;
|
|
52
|
+
B = B * (100 + percent) / 100;
|
|
53
|
+
R = R < 255 ? R : 255;
|
|
54
|
+
G = G < 255 ? G : 255;
|
|
55
|
+
B = B < 255 ? B : 255;
|
|
56
|
+
R = Math.round(R);
|
|
57
|
+
G = Math.round(G);
|
|
58
|
+
B = Math.round(B);
|
|
59
|
+
var RR = R.toString(16).length == 1 ? '0' + R.toString(16) : R.toString(16);
|
|
60
|
+
var GG = G.toString(16).length == 1 ? '0' + G.toString(16) : G.toString(16);
|
|
61
|
+
var BB = B.toString(16).length == 1 ? '0' + B.toString(16) : B.toString(16);
|
|
62
|
+
return '#' + RR + GG + BB;
|
|
63
|
+
}
|
|
40
64
|
|
|
41
65
|
const getBestRouteToTokenUsdPrice = bestRoute => bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to.usdPrice;
|
|
42
66
|
function isNumberOfSwapsChanged(route1, route2) {
|
|
@@ -993,11 +1017,22 @@ const HeaderContainer = /*#__PURE__*/styled('div', {
|
|
|
993
1017
|
});
|
|
994
1018
|
function Header(props) {
|
|
995
1019
|
const {
|
|
996
|
-
onClickRefresh
|
|
1020
|
+
onClickRefresh,
|
|
1021
|
+
title,
|
|
1022
|
+
titleSize,
|
|
1023
|
+
titleWeight
|
|
997
1024
|
} = props;
|
|
1025
|
+
const {
|
|
1026
|
+
t
|
|
1027
|
+
} = useTranslation();
|
|
1028
|
+
const titleStyle = css({
|
|
1029
|
+
fontSize: `${titleSize}px !important`,
|
|
1030
|
+
fontWeight: `${titleWeight} !important`
|
|
1031
|
+
});
|
|
998
1032
|
return React.createElement(HeaderContainer, null, React.createElement(Typography, {
|
|
999
|
-
variant: "h4"
|
|
1000
|
-
|
|
1033
|
+
variant: "h4",
|
|
1034
|
+
className: titleStyle()
|
|
1035
|
+
}, t(title.toLocaleLowerCase()) || title), React.createElement(HeaderButtons, {
|
|
1001
1036
|
onClickRefresh: onClickRefresh
|
|
1002
1037
|
}));
|
|
1003
1038
|
}
|
|
@@ -1075,6 +1110,11 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
1075
1110
|
address: wallet.address,
|
|
1076
1111
|
walletType: wallet.walletType
|
|
1077
1112
|
})
|
|
1113
|
+
})),
|
|
1114
|
+
clearConnectedWallet: () => set(() => ({
|
|
1115
|
+
accounts: [],
|
|
1116
|
+
balances: [],
|
|
1117
|
+
selectedWallets: []
|
|
1078
1118
|
}))
|
|
1079
1119
|
}))));
|
|
1080
1120
|
|
|
@@ -1138,6 +1178,9 @@ function TokenInfo(props) {
|
|
|
1138
1178
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
1139
1179
|
const balances = useWalletsStore.use.balances();
|
|
1140
1180
|
const navigate = useNavigate();
|
|
1181
|
+
const {
|
|
1182
|
+
t
|
|
1183
|
+
} = useTranslation();
|
|
1141
1184
|
const tokenBalance = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(balances, fromChain?.name, fromToken?.symbol, fromToken?.address)?.amount || '0', 8) : '0';
|
|
1142
1185
|
const tokenBalanceReal = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(balances, fromChain?.name, fromToken?.symbol, fromToken?.address)?.amount || '0', getBalanceFromWallet(balances, fromChain?.name, fromToken?.symbol, fromToken?.address)?.decimal) : '0';
|
|
1143
1186
|
const ItemSuffix = React.createElement("div", {
|
|
@@ -1152,7 +1195,7 @@ function TokenInfo(props) {
|
|
|
1152
1195
|
}), React.createElement(AngleDownIcon, null));
|
|
1153
1196
|
return React.createElement(Box, null, React.createElement("div", null, React.createElement(Typography, {
|
|
1154
1197
|
variant: "body2"
|
|
1155
|
-
}, type)), React.createElement(Container, null, props.type === 'From' && React.createElement(Options, null, React.createElement("div", {
|
|
1198
|
+
}, t(type))), React.createElement(Container, null, props.type === 'From' && React.createElement(Options, null, React.createElement("div", {
|
|
1156
1199
|
className: "balance",
|
|
1157
1200
|
onClick: () => {
|
|
1158
1201
|
if (tokenBalance !== '0') setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
@@ -1162,7 +1205,7 @@ function TokenInfo(props) {
|
|
|
1162
1205
|
size: "small"
|
|
1163
1206
|
}, React.createElement(Typography, {
|
|
1164
1207
|
variant: "body2"
|
|
1165
|
-
},
|
|
1208
|
+
}, `${t('Max')}: ${tokenBalance} ${fromToken?.symbol || ''}`)))), React.createElement("div", {
|
|
1166
1209
|
className: "form"
|
|
1167
1210
|
}, React.createElement(Button, {
|
|
1168
1211
|
onClick: () => {
|
|
@@ -1180,7 +1223,7 @@ function TokenInfo(props) {
|
|
|
1180
1223
|
style: {
|
|
1181
1224
|
marginRight: '.5rem'
|
|
1182
1225
|
}
|
|
1183
|
-
}, loadingStatus === 'success' && chain ? chain.displayName : 'Chain'), React.createElement(Button, {
|
|
1226
|
+
}, loadingStatus === 'success' && chain ? chain.displayName : t('Chain')), React.createElement(Button, {
|
|
1184
1227
|
onClick: () => {
|
|
1185
1228
|
navigate(`/${props.type.toLowerCase()}-token`);
|
|
1186
1229
|
},
|
|
@@ -1196,7 +1239,7 @@ function TokenInfo(props) {
|
|
|
1196
1239
|
style: {
|
|
1197
1240
|
marginRight: '.5rem'
|
|
1198
1241
|
}
|
|
1199
|
-
}, loadingStatus === 'success' && token ? token.symbol : 'Token'), props.type === 'From' ? React.createElement(TextField, {
|
|
1242
|
+
}, loadingStatus === 'success' && token ? token.symbol : t('Token')), props.type === 'From' ? React.createElement(TextField, {
|
|
1200
1243
|
type: "number",
|
|
1201
1244
|
size: "large",
|
|
1202
1245
|
autoFocus: true,
|
|
@@ -1251,9 +1294,12 @@ const StyledAnchor = /*#__PURE__*/styled$1('a', {
|
|
|
1251
1294
|
textDecoration: 'none'
|
|
1252
1295
|
});
|
|
1253
1296
|
function BottomLogo() {
|
|
1297
|
+
const {
|
|
1298
|
+
t
|
|
1299
|
+
} = useTranslation();
|
|
1254
1300
|
return React.createElement(Container$1, null, React.createElement(Typography, {
|
|
1255
1301
|
variant: "caption"
|
|
1256
|
-
},
|
|
1302
|
+
}, t('Powered By')), React.createElement(StyledAnchor, {
|
|
1257
1303
|
href: "https://rango.exchange",
|
|
1258
1304
|
target: "_blank"
|
|
1259
1305
|
}, React.createElement(Logo, {
|
|
@@ -1343,7 +1389,12 @@ const Alerts = /*#__PURE__*/styled('div', {
|
|
|
1343
1389
|
width: '100%',
|
|
1344
1390
|
paddingTop: '$16'
|
|
1345
1391
|
});
|
|
1346
|
-
function Home() {
|
|
1392
|
+
function Home(props) {
|
|
1393
|
+
const {
|
|
1394
|
+
title = 'SWAP',
|
|
1395
|
+
titleSize = 18,
|
|
1396
|
+
titleWeight = 600
|
|
1397
|
+
} = props;
|
|
1347
1398
|
const waningMessage = '';
|
|
1348
1399
|
const isRouterInContext = useInRouterContext();
|
|
1349
1400
|
const navigate = useNavigate();
|
|
@@ -1356,9 +1407,9 @@ function Home() {
|
|
|
1356
1407
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
1357
1408
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
1358
1409
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
1410
|
+
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1359
1411
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1360
1412
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
1361
|
-
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1362
1413
|
const outputAmount = useBestRouteStore.use.outputAmount();
|
|
1363
1414
|
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
1364
1415
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
@@ -1390,6 +1441,9 @@ function Home() {
|
|
|
1390
1441
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
1391
1442
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
1392
1443
|
return React.createElement(Container$2, null, React.createElement(Header, {
|
|
1444
|
+
title: title,
|
|
1445
|
+
titleSize: titleSize,
|
|
1446
|
+
titleWeight: titleWeight,
|
|
1393
1447
|
onClickRefresh: fetchBestRoute
|
|
1394
1448
|
}), React.createElement(TokenInfo, {
|
|
1395
1449
|
type: "From",
|
|
@@ -1445,7 +1499,11 @@ function Home() {
|
|
|
1445
1499
|
}, swapButtonState.title), React.createElement(BottomLogo, null)));
|
|
1446
1500
|
}
|
|
1447
1501
|
|
|
1448
|
-
const Route =
|
|
1502
|
+
const Route = _ref => {
|
|
1503
|
+
let {
|
|
1504
|
+
children,
|
|
1505
|
+
...props
|
|
1506
|
+
} = _ref;
|
|
1449
1507
|
const location = useLocation$1();
|
|
1450
1508
|
const navigate = useNavigate$1();
|
|
1451
1509
|
const ref = useRef(true);
|
|
@@ -1455,16 +1513,17 @@ const Route = props => {
|
|
|
1455
1513
|
});
|
|
1456
1514
|
ref.current = false;
|
|
1457
1515
|
}, []);
|
|
1458
|
-
if ([navigationRoutes.confirmWallets, navigationRoutes.confirmSwap].includes(location.pathname) && ref.current) return React.createElement(Home,
|
|
1459
|
-
return React.createElement(React.Fragment, null, " ",
|
|
1516
|
+
if ([navigationRoutes.confirmWallets, navigationRoutes.confirmSwap].includes(location.pathname) && ref.current) return React.createElement(Home, Object.assign({}, props));
|
|
1517
|
+
return React.createElement(React.Fragment, null, " ", children);
|
|
1460
1518
|
};
|
|
1461
|
-
function AppRouter(
|
|
1519
|
+
function AppRouter(_ref2) {
|
|
1462
1520
|
let {
|
|
1463
|
-
children
|
|
1464
|
-
|
|
1521
|
+
children,
|
|
1522
|
+
...props
|
|
1523
|
+
} = _ref2;
|
|
1465
1524
|
const isRouterInContext = useInRouterContext$1();
|
|
1466
1525
|
const Router = isRouterInContext ? Route : MemoryRouter;
|
|
1467
|
-
return React.createElement(React.Fragment, null, React.createElement(Router,
|
|
1526
|
+
return React.createElement(React.Fragment, null, React.createElement(Router, Object.assign({}, props), children), isRouterInContext && React.createElement(UpdateUrl, null));
|
|
1468
1527
|
}
|
|
1469
1528
|
|
|
1470
1529
|
const StyledButton = /*#__PURE__*/styled(Button, {
|
|
@@ -1568,7 +1627,7 @@ const confirmSwap = async () => {
|
|
|
1568
1627
|
meta
|
|
1569
1628
|
} = useMetaStore.getState();
|
|
1570
1629
|
const userSlippage = customSlippage || slippage;
|
|
1571
|
-
if (!fromToken || !toToken || !inputAmount || !initialRoute) return;
|
|
1630
|
+
if (!fromToken || !toToken || !inputAmount || !initialRoute) return undefined;
|
|
1572
1631
|
if (proceedAnyway) {
|
|
1573
1632
|
const swapSettings = {
|
|
1574
1633
|
slippage: userSlippage.toString(),
|
|
@@ -1859,10 +1918,11 @@ function HistoryPage() {
|
|
|
1859
1918
|
});
|
|
1860
1919
|
}
|
|
1861
1920
|
|
|
1862
|
-
function LiquiditySourcePage() {
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
} =
|
|
1921
|
+
function LiquiditySourcePage(_ref) {
|
|
1922
|
+
let {
|
|
1923
|
+
supportedSwappers
|
|
1924
|
+
} = _ref;
|
|
1925
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
1866
1926
|
const toggleLiquiditySource = useSettingsStore.use.toggleLiquiditySource();
|
|
1867
1927
|
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
1868
1928
|
const toggleAllLiquiditySources = useSettingsStore.use.toggleAllLiquiditySources();
|
|
@@ -1886,7 +1946,7 @@ function LiquiditySourcePage() {
|
|
|
1886
1946
|
});
|
|
1887
1947
|
return React.createElement(LiquiditySourcesSelector, {
|
|
1888
1948
|
toggleAll: toggleAllLiquiditySources,
|
|
1889
|
-
list: uniqueSwappersGroups,
|
|
1949
|
+
list: supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups,
|
|
1890
1950
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
1891
1951
|
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources)
|
|
1892
1952
|
});
|
|
@@ -1894,11 +1954,10 @@ function LiquiditySourcePage() {
|
|
|
1894
1954
|
|
|
1895
1955
|
function SelectChainPage(props) {
|
|
1896
1956
|
const {
|
|
1897
|
-
type
|
|
1957
|
+
type,
|
|
1958
|
+
supportedChains
|
|
1898
1959
|
} = props;
|
|
1899
|
-
const
|
|
1900
|
-
blockchains
|
|
1901
|
-
} = useMetaStore.use.meta();
|
|
1960
|
+
const blockchains = supportedChains === 'all' ? useMetaStore.use.meta().blockchains : supportedChains;
|
|
1902
1961
|
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
1903
1962
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
1904
1963
|
const toChain = useBestRouteStore.use.toChain();
|
|
@@ -1925,15 +1984,14 @@ function SelectChainPage(props) {
|
|
|
1925
1984
|
}
|
|
1926
1985
|
|
|
1927
1986
|
function SelectTokenPage(props) {
|
|
1928
|
-
const {
|
|
1929
|
-
type
|
|
1930
|
-
} = props;
|
|
1931
1987
|
const {
|
|
1932
1988
|
navigateBackFrom
|
|
1933
1989
|
} = useNavigateBack();
|
|
1934
1990
|
const {
|
|
1935
|
-
|
|
1936
|
-
|
|
1991
|
+
type,
|
|
1992
|
+
supportedTokens
|
|
1993
|
+
} = props;
|
|
1994
|
+
const tokens = supportedTokens === 'all' ? useMetaStore.use.meta().tokens : supportedTokens;
|
|
1937
1995
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
1938
1996
|
const toChain = useBestRouteStore.use.toChain();
|
|
1939
1997
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
@@ -1970,7 +2028,10 @@ function SelectTokenPage(props) {
|
|
|
1970
2028
|
});
|
|
1971
2029
|
}
|
|
1972
2030
|
|
|
1973
|
-
function SettingsPage() {
|
|
2031
|
+
function SettingsPage(_ref) {
|
|
2032
|
+
let {
|
|
2033
|
+
supportedSwappers
|
|
2034
|
+
} = _ref;
|
|
1974
2035
|
const slippage = useSettingsStore.use.slippage();
|
|
1975
2036
|
const setSlippage = useSettingsStore.use.setSlippage();
|
|
1976
2037
|
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
@@ -1978,9 +2039,7 @@ function SettingsPage() {
|
|
|
1978
2039
|
const setCustomSlippage = useSettingsStore.use.setCustomSlippage();
|
|
1979
2040
|
const theme = useSettingsStore.use.theme();
|
|
1980
2041
|
const setTheme = useSettingsStore.use.setTheme();
|
|
1981
|
-
const
|
|
1982
|
-
swappers
|
|
1983
|
-
} = useMetaStore.use.meta();
|
|
2042
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
1984
2043
|
const navigate = useNavigate();
|
|
1985
2044
|
const {
|
|
1986
2045
|
navigateBackFrom
|
|
@@ -2002,14 +2061,16 @@ function SettingsPage() {
|
|
|
2002
2061
|
}
|
|
2003
2062
|
}
|
|
2004
2063
|
});
|
|
2064
|
+
supportedSwappers !== 'all' && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0);
|
|
2065
|
+
const supportedUniqueSwappersGroups = supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups;
|
|
2005
2066
|
return React.createElement(Settings, {
|
|
2006
2067
|
slippages: SLIPPAGES,
|
|
2007
2068
|
selectedSlippage: slippage,
|
|
2008
2069
|
onSlippageChange: slippage => setSlippage(slippage),
|
|
2009
|
-
liquiditySources: uniqueSwappersGroups,
|
|
2010
|
-
selectedLiquiditySources: uniqueSwappersGroups.filter(s => s.selected),
|
|
2011
2070
|
onLiquiditySourcesClick: navigate.bind(null, navigationRoutes.liquiditySources),
|
|
2012
2071
|
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
2072
|
+
liquiditySources: supportedUniqueSwappersGroups,
|
|
2073
|
+
selectedLiquiditySources: supportedUniqueSwappersGroups.filter(s => s.selected),
|
|
2013
2074
|
customSlippage: customSlippage || NaN,
|
|
2014
2075
|
onCustomSlippageChange: setCustomSlippage,
|
|
2015
2076
|
minSlippage: MIN_SLIPPGAE,
|
|
@@ -2032,7 +2093,11 @@ const ListContainer = /*#__PURE__*/styled('div', {
|
|
|
2032
2093
|
const AlertContainer = /*#__PURE__*/styled('div', {
|
|
2033
2094
|
paddingBottom: '$16'
|
|
2034
2095
|
});
|
|
2035
|
-
function WalletsPage() {
|
|
2096
|
+
function WalletsPage(_ref) {
|
|
2097
|
+
let {
|
|
2098
|
+
supportedWallets,
|
|
2099
|
+
multiWallets
|
|
2100
|
+
} = _ref;
|
|
2036
2101
|
const {
|
|
2037
2102
|
navigateBackFrom
|
|
2038
2103
|
} = useNavigateBack();
|
|
@@ -2042,9 +2107,12 @@ function WalletsPage() {
|
|
|
2042
2107
|
getWalletInfo,
|
|
2043
2108
|
connect
|
|
2044
2109
|
} = useWallets();
|
|
2045
|
-
const wallets = getlistWallet(state, getWalletInfo, Object.values(WalletType));
|
|
2110
|
+
const wallets = getlistWallet(state, getWalletInfo, supportedWallets === 'all' ? Object.values(WalletType) : supportedWallets);
|
|
2046
2111
|
const [walletErrorMessage, setWalletErrorMessage] = useState('');
|
|
2047
2112
|
const toggleConnectWalletsButton = useUiStore.use.toggleConnectWalletsButton();
|
|
2113
|
+
const {
|
|
2114
|
+
t
|
|
2115
|
+
} = useTranslation();
|
|
2048
2116
|
const onSelectWallet = async type => {
|
|
2049
2117
|
const wallet = state(type);
|
|
2050
2118
|
try {
|
|
@@ -2052,6 +2120,9 @@ function WalletsPage() {
|
|
|
2052
2120
|
if (wallet.connected) {
|
|
2053
2121
|
await disconnect(type);
|
|
2054
2122
|
} else {
|
|
2123
|
+
if (!multiWallets && !!wallets.find(w => w.state === WalletState.CONNECTED)) {
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2055
2126
|
await connect(type);
|
|
2056
2127
|
}
|
|
2057
2128
|
} catch (e) {
|
|
@@ -2063,7 +2134,7 @@ function WalletsPage() {
|
|
|
2063
2134
|
return () => toggleConnectWalletsButton();
|
|
2064
2135
|
}, []);
|
|
2065
2136
|
return React.createElement(SecondaryPage, {
|
|
2066
|
-
title:
|
|
2137
|
+
title: t('Select Wallet'),
|
|
2067
2138
|
textField: false,
|
|
2068
2139
|
onBack: navigateBackFrom.bind(null, navigationRoutes.wallets)
|
|
2069
2140
|
}, React.createElement(React.Fragment, null, walletErrorMessage && React.createElement(AlertContainer, null, React.createElement(Alert, {
|
|
@@ -2169,51 +2240,80 @@ function SwapDetailsPage() {
|
|
|
2169
2240
|
});
|
|
2170
2241
|
}
|
|
2171
2242
|
|
|
2172
|
-
const AppRoutes =
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
}
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
}, {
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
}, {
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2210
|
-
}, {
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
}
|
|
2243
|
+
const AppRoutes = _ref => {
|
|
2244
|
+
let {
|
|
2245
|
+
fromChains = 'all',
|
|
2246
|
+
toChains = 'all',
|
|
2247
|
+
fromTokens = 'all',
|
|
2248
|
+
toTokens = 'all',
|
|
2249
|
+
liquiditySources = 'all',
|
|
2250
|
+
wallets = 'all',
|
|
2251
|
+
title,
|
|
2252
|
+
multiWallets = true,
|
|
2253
|
+
titleSize,
|
|
2254
|
+
titleWeight
|
|
2255
|
+
} = _ref;
|
|
2256
|
+
return useRoutes([{
|
|
2257
|
+
path: navigationRoutes.home,
|
|
2258
|
+
element: React.createElement(Home, {
|
|
2259
|
+
title: title,
|
|
2260
|
+
titleSize: titleSize,
|
|
2261
|
+
titleWeight: titleWeight
|
|
2262
|
+
})
|
|
2263
|
+
}, {
|
|
2264
|
+
path: navigationRoutes.fromChain,
|
|
2265
|
+
element: React.createElement(SelectChainPage, {
|
|
2266
|
+
type: "from",
|
|
2267
|
+
supportedChains: fromChains
|
|
2268
|
+
})
|
|
2269
|
+
}, {
|
|
2270
|
+
path: navigationRoutes.toChain,
|
|
2271
|
+
element: React.createElement(SelectChainPage, {
|
|
2272
|
+
type: "to",
|
|
2273
|
+
supportedChains: toChains
|
|
2274
|
+
})
|
|
2275
|
+
}, {
|
|
2276
|
+
path: navigationRoutes.fromToken + '/*',
|
|
2277
|
+
element: React.createElement(SelectTokenPage, {
|
|
2278
|
+
type: "from",
|
|
2279
|
+
supportedTokens: fromTokens
|
|
2280
|
+
})
|
|
2281
|
+
}, {
|
|
2282
|
+
path: navigationRoutes.toToken,
|
|
2283
|
+
element: React.createElement(SelectTokenPage, {
|
|
2284
|
+
type: "to",
|
|
2285
|
+
supportedTokens: toTokens
|
|
2286
|
+
})
|
|
2287
|
+
}, {
|
|
2288
|
+
path: navigationRoutes.settings,
|
|
2289
|
+
element: React.createElement(SettingsPage, {
|
|
2290
|
+
supportedSwappers: liquiditySources
|
|
2291
|
+
})
|
|
2292
|
+
}, {
|
|
2293
|
+
path: navigationRoutes.liquiditySources,
|
|
2294
|
+
element: React.createElement(LiquiditySourcePage, {
|
|
2295
|
+
supportedSwappers: liquiditySources
|
|
2296
|
+
})
|
|
2297
|
+
}, {
|
|
2298
|
+
path: navigationRoutes.swaps,
|
|
2299
|
+
element: React.createElement(HistoryPage, null)
|
|
2300
|
+
}, {
|
|
2301
|
+
path: navigationRoutes.swapDetails,
|
|
2302
|
+
element: React.createElement(SwapDetailsPage, null)
|
|
2303
|
+
}, {
|
|
2304
|
+
path: navigationRoutes.wallets,
|
|
2305
|
+
element: React.createElement(WalletsPage, {
|
|
2306
|
+
supportedWallets: wallets,
|
|
2307
|
+
multiWallets: multiWallets
|
|
2308
|
+
})
|
|
2309
|
+
}, {
|
|
2310
|
+
path: navigationRoutes.confirmSwap,
|
|
2311
|
+
element: React.createElement(ConfirmSwapPage, null)
|
|
2312
|
+
}, {
|
|
2313
|
+
path: navigationRoutes.confirmWallets,
|
|
2314
|
+
element: React.createElement(ConfirmWalletsPage, null)
|
|
2315
|
+
}]);
|
|
2316
|
+
};
|
|
2217
2317
|
|
|
2218
2318
|
const Header$1 = /*#__PURE__*/styled('div', {
|
|
2219
2319
|
display: 'flex',
|
|
@@ -2227,7 +2327,10 @@ const WalletImage = /*#__PURE__*/styled('img', {
|
|
|
2227
2327
|
marginRight: '$6',
|
|
2228
2328
|
borderRadius: '99999px'
|
|
2229
2329
|
});
|
|
2230
|
-
function Layout() {
|
|
2330
|
+
function Layout(_ref) {
|
|
2331
|
+
let {
|
|
2332
|
+
configs
|
|
2333
|
+
} = _ref;
|
|
2231
2334
|
const navigate = useNavigate();
|
|
2232
2335
|
const {
|
|
2233
2336
|
balances,
|
|
@@ -2238,8 +2341,34 @@ function Layout() {
|
|
|
2238
2341
|
getWalletInfo
|
|
2239
2342
|
} = useWallets();
|
|
2240
2343
|
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(accounts, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2344
|
+
const {
|
|
2345
|
+
fromChain,
|
|
2346
|
+
toChain,
|
|
2347
|
+
toToken,
|
|
2348
|
+
fromToken,
|
|
2349
|
+
fromAmount
|
|
2350
|
+
} = configs;
|
|
2351
|
+
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
2352
|
+
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
2353
|
+
const setToChain = useBestRouteStore.use.setToChain();
|
|
2354
|
+
const setToToken = useBestRouteStore.use.setToToken();
|
|
2355
|
+
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2241
2356
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
2242
2357
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
2358
|
+
const {
|
|
2359
|
+
t
|
|
2360
|
+
} = useTranslation();
|
|
2361
|
+
useEffect(() => {
|
|
2362
|
+
setToChain(toChain);
|
|
2363
|
+
setToToken(toToken);
|
|
2364
|
+
}, [toChain, toToken]);
|
|
2365
|
+
useEffect(() => {
|
|
2366
|
+
setInputAmount(fromAmount.toString());
|
|
2367
|
+
}, [fromAmount]);
|
|
2368
|
+
useEffect(() => {
|
|
2369
|
+
setFromToken(fromToken);
|
|
2370
|
+
setFromChain(fromChain);
|
|
2371
|
+
}, [fromToken, fromChain]);
|
|
2243
2372
|
return React.createElement(React.Fragment, null, React.createElement(Header$1, null, React.createElement(Button, {
|
|
2244
2373
|
size: "small",
|
|
2245
2374
|
suffix: React.createElement(AddWalletIcon, {
|
|
@@ -2255,7 +2384,7 @@ function Layout() {
|
|
|
2255
2384
|
src: walletImage
|
|
2256
2385
|
})) : React.createElement(React.Fragment, null), React.createElement(Typography, {
|
|
2257
2386
|
variant: "body2"
|
|
2258
|
-
}, !accounts?.length ? 'Connect Wallet' : `$${totalBalance || 0}`))), React.createElement(AppRoutes,
|
|
2387
|
+
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`))), React.createElement(AppRoutes, Object.assign({}, configs)));
|
|
2259
2388
|
}
|
|
2260
2389
|
|
|
2261
2390
|
const globalStyles = /*#__PURE__*/globalCss({
|
|
@@ -2274,52 +2403,298 @@ const globalStyles = /*#__PURE__*/globalCss({
|
|
|
2274
2403
|
}
|
|
2275
2404
|
}
|
|
2276
2405
|
});
|
|
2406
|
+
const globalFont = fontFamily => globalCss({
|
|
2407
|
+
'@import': ["url('https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap')", "url('https://fonts.cdnfonts.com/css/times-new-roman')"],
|
|
2408
|
+
[`.font_${fontFamily.replace(/ /g, '')} ._text`]: {
|
|
2409
|
+
fontFamily
|
|
2410
|
+
}
|
|
2411
|
+
})();
|
|
2412
|
+
|
|
2413
|
+
function usePrevious(value) {
|
|
2414
|
+
// The ref object is a generic container whose current property is mutable ...
|
|
2415
|
+
// ... and can hold any value, similar to an instance property on a class
|
|
2416
|
+
const ref = useRef();
|
|
2417
|
+
// Store current value in ref
|
|
2418
|
+
useEffect(() => {
|
|
2419
|
+
ref.current = value;
|
|
2420
|
+
}, [value]); // Only re-run if value changes
|
|
2421
|
+
// Return previous value (happens before update in useEffect above)
|
|
2422
|
+
return ref.current;
|
|
2423
|
+
}
|
|
2277
2424
|
|
|
2278
|
-
function useTheme() {
|
|
2425
|
+
function useTheme(_ref) {
|
|
2426
|
+
let {
|
|
2427
|
+
primary = '#5FA425',
|
|
2428
|
+
background = '#fff',
|
|
2429
|
+
foreground = '#000',
|
|
2430
|
+
error = '#FF0000',
|
|
2431
|
+
warning = '#F5A623',
|
|
2432
|
+
success = '#0070F3',
|
|
2433
|
+
fontFamily = 'Robot',
|
|
2434
|
+
borderRadius = 5
|
|
2435
|
+
} = _ref;
|
|
2279
2436
|
const theme = useSettingsStore.use.theme();
|
|
2280
2437
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
2281
|
-
const
|
|
2438
|
+
const colors = {
|
|
2439
|
+
neutrals200: '#FAFAFA',
|
|
2440
|
+
neutrals300: '#EAEAEA',
|
|
2441
|
+
neutrals400: '#999999',
|
|
2442
|
+
neutrals500: '#888888',
|
|
2443
|
+
neutrals600: '#666666',
|
|
2444
|
+
neutrals700: '#444444',
|
|
2445
|
+
neutrals800: '#333333',
|
|
2446
|
+
neutrals900: '#111111',
|
|
2447
|
+
primary,
|
|
2448
|
+
primary100: shadeColor(primary, 15),
|
|
2449
|
+
primary200: shadeColor(primary, -10),
|
|
2450
|
+
primary300: shadeColor(primary, -15),
|
|
2451
|
+
primary400: shadeColor(primary, -20),
|
|
2452
|
+
primary500: shadeColor(primary, -25),
|
|
2453
|
+
primary600: shadeColor(primary, -30),
|
|
2454
|
+
primary700: shadeColor(primary, -35),
|
|
2455
|
+
primary800: shadeColor(primary, -40),
|
|
2456
|
+
primary900: shadeColor(primary, -45),
|
|
2457
|
+
background,
|
|
2458
|
+
foreground,
|
|
2459
|
+
error,
|
|
2460
|
+
error100: shadeColor(error, 50),
|
|
2461
|
+
error300: shadeColor(error, -10),
|
|
2462
|
+
error500: shadeColor(error, -20),
|
|
2463
|
+
error700: shadeColor(error, -30),
|
|
2464
|
+
warning,
|
|
2465
|
+
warning100: shadeColor(warning, 50),
|
|
2466
|
+
warning300: shadeColor(warning, -10),
|
|
2467
|
+
warning500: shadeColor(warning, -20),
|
|
2468
|
+
warning700: shadeColor(warning, -30),
|
|
2469
|
+
success,
|
|
2470
|
+
success100: shadeColor(success, 50),
|
|
2471
|
+
success300: shadeColor(success, -10),
|
|
2472
|
+
success500: shadeColor(success, -20),
|
|
2473
|
+
success700: shadeColor(success, -30)
|
|
2474
|
+
};
|
|
2475
|
+
const customeLightTheme = createTheme({
|
|
2476
|
+
colors,
|
|
2477
|
+
radii: {
|
|
2478
|
+
5: `${borderRadius}px`
|
|
2479
|
+
}
|
|
2480
|
+
});
|
|
2481
|
+
const customeDarkTheme = createTheme({
|
|
2482
|
+
colors: {
|
|
2483
|
+
...colors,
|
|
2484
|
+
neutrals200: '#111111',
|
|
2485
|
+
neutrals300: '#333333',
|
|
2486
|
+
neutrals400: '#444444',
|
|
2487
|
+
neutrals500: '#666666',
|
|
2488
|
+
neutrals600: '#888888',
|
|
2489
|
+
neutrals700: '#999999',
|
|
2490
|
+
neutrals800: '#EAEAEA',
|
|
2491
|
+
neutrals900: '#FAFAFA',
|
|
2492
|
+
foreground: background,
|
|
2493
|
+
background: foreground
|
|
2494
|
+
},
|
|
2495
|
+
radii: {
|
|
2496
|
+
5: `${borderRadius}px`
|
|
2497
|
+
}
|
|
2498
|
+
});
|
|
2499
|
+
const [OSTheme, setOSTheme] = useState(customeLightTheme);
|
|
2282
2500
|
useEffect(() => {
|
|
2283
2501
|
(async () => {
|
|
2284
2502
|
await fetchMeta();
|
|
2285
2503
|
})();
|
|
2286
2504
|
const switchTheme = event => {
|
|
2287
|
-
if (event.matches) setOSTheme(
|
|
2505
|
+
if (event.matches) setOSTheme(customeDarkTheme);else setOSTheme(customeLightTheme);
|
|
2288
2506
|
};
|
|
2289
2507
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
2290
|
-
setOSTheme(
|
|
2508
|
+
setOSTheme(customeDarkTheme);
|
|
2291
2509
|
}
|
|
2292
2510
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', switchTheme);
|
|
2293
2511
|
return () => {
|
|
2294
2512
|
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', switchTheme);
|
|
2295
2513
|
};
|
|
2296
2514
|
}, []);
|
|
2515
|
+
const prevFont = usePrevious(fontFamily);
|
|
2516
|
+
useLayoutEffect(() => {
|
|
2517
|
+
const {
|
|
2518
|
+
classList
|
|
2519
|
+
} = document.body;
|
|
2520
|
+
if (prevFont) classList.remove(`font_${prevFont.replace(/ /g, '')}`);
|
|
2521
|
+
classList.add(`font_${fontFamily.replace(/ /g, '')}`);
|
|
2522
|
+
}, [fontFamily]);
|
|
2297
2523
|
const getActiveTheme = () => {
|
|
2298
|
-
if (theme === 'auto') return OSTheme;else return theme === 'dark' ?
|
|
2524
|
+
if (theme === 'auto') return OSTheme;else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
2299
2525
|
};
|
|
2300
2526
|
return {
|
|
2301
2527
|
activeTheme: getActiveTheme()
|
|
2302
2528
|
};
|
|
2303
2529
|
}
|
|
2304
2530
|
|
|
2305
|
-
|
|
2306
|
-
const
|
|
2531
|
+
function useSelectLanguage() {
|
|
2532
|
+
const {
|
|
2533
|
+
i18n
|
|
2534
|
+
} = useTranslation();
|
|
2535
|
+
// @ts-ignore
|
|
2536
|
+
const currentLanguage = i18n?.language || 'en';
|
|
2537
|
+
const changeLanguage = value => {
|
|
2538
|
+
if (currentLanguage !== value) {
|
|
2539
|
+
// @ts-ignore
|
|
2540
|
+
i18n.changeLanguage(value);
|
|
2541
|
+
}
|
|
2542
|
+
};
|
|
2543
|
+
return {
|
|
2544
|
+
changeLanguage,
|
|
2545
|
+
currentLanguage
|
|
2546
|
+
};
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
var swap = "SWAP";
|
|
2550
|
+
var From = "From";
|
|
2551
|
+
var To = "To";
|
|
2552
|
+
var Max = "Max";
|
|
2553
|
+
var Chain = "Chain";
|
|
2554
|
+
var Token = "Token";
|
|
2555
|
+
var Source = "Source";
|
|
2556
|
+
var Destination = "Destination";
|
|
2557
|
+
var en = {
|
|
2558
|
+
swap: swap,
|
|
2559
|
+
"Connect Wallet": "Connect Wallet",
|
|
2560
|
+
"Powered By": "Powered By",
|
|
2561
|
+
From: From,
|
|
2562
|
+
To: To,
|
|
2563
|
+
Max: Max,
|
|
2564
|
+
Chain: Chain,
|
|
2565
|
+
Token: Token,
|
|
2566
|
+
Source: Source,
|
|
2567
|
+
Destination: Destination,
|
|
2568
|
+
"Select Wallet": "Select Wallet"
|
|
2569
|
+
};
|
|
2570
|
+
|
|
2571
|
+
var swap$1 = "TAKAS";
|
|
2572
|
+
var From$1 = "İtibaren";
|
|
2573
|
+
var To$1 = "İle";
|
|
2574
|
+
var Max$1 = "maks.";
|
|
2575
|
+
var Chain$1 = "Zincir";
|
|
2576
|
+
var Token$1 = "Jeton";
|
|
2577
|
+
var tr = {
|
|
2578
|
+
swap: swap$1,
|
|
2579
|
+
"Select Wallet": "Cüzdan Seç",
|
|
2580
|
+
"Powered By": "Tarafından desteklenmektedir",
|
|
2581
|
+
"Connect Wallet": "Cüzdanı Bağla",
|
|
2582
|
+
From: From$1,
|
|
2583
|
+
To: To$1,
|
|
2584
|
+
Max: Max$1,
|
|
2585
|
+
Chain: Chain$1,
|
|
2586
|
+
Token: Token$1
|
|
2587
|
+
};
|
|
2588
|
+
|
|
2589
|
+
const languages = ['en', 'tr'];
|
|
2590
|
+
i18n.use(Backend)
|
|
2591
|
+
// detect user language
|
|
2592
|
+
.use(LanguageDetector)
|
|
2593
|
+
// pass the i18n instance to react-i18next.
|
|
2594
|
+
.use(initReactI18next).init({
|
|
2595
|
+
resources: {
|
|
2596
|
+
en: {
|
|
2597
|
+
translation: en
|
|
2598
|
+
},
|
|
2599
|
+
tr: {
|
|
2600
|
+
translation: tr
|
|
2601
|
+
}
|
|
2602
|
+
},
|
|
2603
|
+
fallbackLng: 'en',
|
|
2604
|
+
debug: true,
|
|
2605
|
+
whitelist: languages
|
|
2606
|
+
});
|
|
2607
|
+
|
|
2608
|
+
function QueueManager(props) {
|
|
2609
|
+
const {
|
|
2610
|
+
providers,
|
|
2611
|
+
getSigners,
|
|
2612
|
+
state,
|
|
2613
|
+
connect,
|
|
2614
|
+
canSwitchNetworkTo,
|
|
2615
|
+
getWalletInfo
|
|
2616
|
+
} = useWallets();
|
|
2617
|
+
const {
|
|
2618
|
+
blockchains
|
|
2619
|
+
} = useMetaStore.use.meta();
|
|
2620
|
+
const balances = useWalletsStore.use.balances();
|
|
2621
|
+
const wallets = {
|
|
2622
|
+
blockchains: balances.map(wallet => ({
|
|
2623
|
+
accounts: [wallet],
|
|
2624
|
+
name: wallet.chain
|
|
2625
|
+
}))
|
|
2626
|
+
};
|
|
2627
|
+
const switchNetwork = (wallet, network) => {
|
|
2628
|
+
if (!canSwitchNetworkTo(wallet, network)) {
|
|
2629
|
+
return undefined;
|
|
2630
|
+
}
|
|
2631
|
+
return connect(wallet, network);
|
|
2632
|
+
};
|
|
2633
|
+
// TODO: this code copy & pasted from rango, should be refactored.
|
|
2634
|
+
const allBlockchains = blockchains.filter(blockchain => blockchain.enabled).reduce((blockchainsObj, blockchain) => (blockchainsObj[blockchain.name] = blockchain, blockchainsObj), {});
|
|
2635
|
+
const evmBasedChains = blockchains.filter(isEvmBlockchain);
|
|
2636
|
+
const getSupportedChainNames = type => {
|
|
2637
|
+
const {
|
|
2638
|
+
supportedChains
|
|
2639
|
+
} = getWalletInfo(type);
|
|
2640
|
+
return walletAndSupportedChainsNames(supportedChains);
|
|
2641
|
+
};
|
|
2642
|
+
const allProviders = providers();
|
|
2643
|
+
const context = {
|
|
2644
|
+
meta: {
|
|
2645
|
+
blockchains: allBlockchains,
|
|
2646
|
+
evmBasedChains: evmBasedChains,
|
|
2647
|
+
evmNetworkChainInfo: convertEvmBlockchainMetaToEvmChainInfo(evmBasedChains),
|
|
2648
|
+
getSupportedChainNames
|
|
2649
|
+
},
|
|
2650
|
+
getSigners,
|
|
2651
|
+
//todo: remove Network type
|
|
2652
|
+
//@ts-ignore
|
|
2653
|
+
wallets,
|
|
2654
|
+
providers: allProviders,
|
|
2655
|
+
switchNetwork,
|
|
2656
|
+
connect,
|
|
2657
|
+
state,
|
|
2658
|
+
notifier: message => {
|
|
2659
|
+
console.log('[notifier]', message);
|
|
2660
|
+
}
|
|
2661
|
+
};
|
|
2662
|
+
return React.createElement(Provider, {
|
|
2663
|
+
queuesDefs: [swapQueueDef],
|
|
2664
|
+
context: context,
|
|
2665
|
+
onPersistedDataLoaded: _manager => {},
|
|
2666
|
+
isPaused: false
|
|
2667
|
+
}, props.children);
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
const SwapBox = _ref => {
|
|
2671
|
+
let {
|
|
2672
|
+
configs
|
|
2673
|
+
} = _ref;
|
|
2307
2674
|
globalStyles();
|
|
2675
|
+
globalFont(configs?.fontFamily || 'Roboto');
|
|
2308
2676
|
const {
|
|
2309
2677
|
activeTheme
|
|
2310
|
-
} = useTheme(
|
|
2678
|
+
} = useTheme({
|
|
2679
|
+
...configs.colors,
|
|
2680
|
+
borderRadius: configs?.borderRadius,
|
|
2681
|
+
fontFamily: configs?.fontFamily
|
|
2682
|
+
});
|
|
2311
2683
|
const {
|
|
2312
2684
|
blockchains
|
|
2313
2685
|
} = useMetaStore.use.meta();
|
|
2314
2686
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
2315
2687
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
2688
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
2689
|
+
const {
|
|
2690
|
+
changeLanguage
|
|
2691
|
+
} = useSelectLanguage();
|
|
2692
|
+
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
2316
2693
|
const evmBasedChainNames = blockchains.filter(isEvmBlockchain).map(chain => chain.name);
|
|
2317
|
-
const onUpdateState = (type, event, value, supportedChains) => {
|
|
2694
|
+
const onUpdateState = (type, event, value, _, supportedChains) => {
|
|
2318
2695
|
if (event === Events.ACCOUNTS) {
|
|
2319
2696
|
if (value) {
|
|
2320
|
-
const supportedChainNames =
|
|
2321
|
-
//@ts-ignore
|
|
2322
|
-
walletAndSupportedChainsNames(supportedChains);
|
|
2697
|
+
const supportedChainNames = walletAndSupportedChainsNames(supportedChains);
|
|
2323
2698
|
const data = prepareAccountsForWalletStore(type, value, evmBasedChainNames, supportedChainNames);
|
|
2324
2699
|
connectWallet(data);
|
|
2325
2700
|
} else {
|
|
@@ -2327,14 +2702,40 @@ const SwapBox = () => {
|
|
|
2327
2702
|
}
|
|
2328
2703
|
}
|
|
2329
2704
|
};
|
|
2330
|
-
|
|
2705
|
+
let providers = allProviders();
|
|
2706
|
+
useEffect(() => {
|
|
2707
|
+
if (configs.theme !== 'auto') setTheme(configs.theme);
|
|
2708
|
+
}, [configs.theme]);
|
|
2709
|
+
useEffect(() => {
|
|
2710
|
+
const wallets = configs.wallets;
|
|
2711
|
+
clearConnectedWallet();
|
|
2712
|
+
providers = wallets === 'all' ? allProviders() : allProviders().filter(provider => {
|
|
2713
|
+
const type = provider.config.type;
|
|
2714
|
+
return wallets.find(w => w === type);
|
|
2715
|
+
});
|
|
2716
|
+
}, [configs?.wallets]);
|
|
2717
|
+
useEffect(() => {
|
|
2718
|
+
changeLanguage(configs?.languege);
|
|
2719
|
+
}, [configs?.languege]);
|
|
2720
|
+
return React.createElement(Provider$1, {
|
|
2331
2721
|
allBlockChains: blockchains,
|
|
2332
2722
|
providers: providers,
|
|
2333
2723
|
onUpdateState: onUpdateState
|
|
2334
2724
|
}, React.createElement("div", {
|
|
2335
2725
|
id: "pageContainer",
|
|
2336
2726
|
className: activeTheme
|
|
2337
|
-
}, React.createElement(
|
|
2727
|
+
}, React.createElement(QueueManager, null, React.createElement(SwapContainer, {
|
|
2728
|
+
style: {
|
|
2729
|
+
width: configs?.width || 'auto',
|
|
2730
|
+
height: configs?.height || 'auto'
|
|
2731
|
+
}
|
|
2732
|
+
}, React.createElement(AppRouter, {
|
|
2733
|
+
title: configs.title,
|
|
2734
|
+
titleSize: configs.titleSize,
|
|
2735
|
+
titleWeight: configs.titleWeight
|
|
2736
|
+
}, React.createElement(Layout, {
|
|
2737
|
+
configs: configs
|
|
2738
|
+
}))))));
|
|
2338
2739
|
};
|
|
2339
2740
|
|
|
2340
2741
|
export { SwapBox };
|