@rango-dev/widget-embedded 0.1.10-next.89 → 0.1.10-next.92
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/numbers.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +1 -1
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +500 -100
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +500 -100
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +506 -106
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +5 -1
- package/src/App.tsx +20 -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/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/numbers.ts +1 -0
- package/src/utils/swap.ts +1 -1
- package/src/utils/wallets.ts +1 -1
- package/dist/swapBox.d.ts +0 -3
- package/dist/swapBox.d.ts.map +0 -1
- package/src/swapBox.tsx +0 -65
|
@@ -1,19 +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 } from '@rango-dev/wallets-shared';
|
|
9
|
+
import { Network, isEvmAddress, KEPLR_COMPATIBLE_WALLETS, WalletType, getCosmosExperimentalChainInfo, convertEvmBlockchainMetaToEvmChainInfo } from '@rango-dev/wallets-shared';
|
|
10
10
|
import { isCosmosBlockchain } from 'rango-types';
|
|
11
|
-
import { readAccountAddress, useWallets, Provider, Events } from '@rango-dev/wallets-core';
|
|
11
|
+
import { readAccountAddress, useWallets, Provider as Provider$1, Events } from '@rango-dev/wallets-core';
|
|
12
|
+
import { useTranslation, initReactI18next } from 'react-i18next';
|
|
12
13
|
import { styled as styled$1 } from '@rango-dev/ui/src/theme';
|
|
13
14
|
import { allProviders } from '@rango-dev/provider-all';
|
|
14
15
|
import { shallow } from 'zustand/shallow';
|
|
15
|
-
import { useManager } from '@rango-dev/queue-manager-react';
|
|
16
|
+
import { useManager, Provider } from '@rango-dev/queue-manager-react';
|
|
16
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';
|
|
17
22
|
|
|
18
23
|
const navigationRoutes = {
|
|
19
24
|
home: '/',
|
|
@@ -38,6 +43,24 @@ function removeDuplicateFrom(array) {
|
|
|
38
43
|
function areEqual(array1, array2) {
|
|
39
44
|
return array1.length === array2.length && array1.every((v, i) => v === array2[i]);
|
|
40
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
|
+
}
|
|
41
64
|
|
|
42
65
|
const getBestRouteToTokenUsdPrice = bestRoute => bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to.usdPrice;
|
|
43
66
|
function isNumberOfSwapsChanged(route1, route2) {
|
|
@@ -994,11 +1017,22 @@ const HeaderContainer = /*#__PURE__*/styled('div', {
|
|
|
994
1017
|
});
|
|
995
1018
|
function Header(props) {
|
|
996
1019
|
const {
|
|
997
|
-
onClickRefresh
|
|
1020
|
+
onClickRefresh,
|
|
1021
|
+
title,
|
|
1022
|
+
titleSize,
|
|
1023
|
+
titleWeight
|
|
998
1024
|
} = props;
|
|
1025
|
+
const {
|
|
1026
|
+
t
|
|
1027
|
+
} = useTranslation();
|
|
1028
|
+
const titleStyle = css({
|
|
1029
|
+
fontSize: `${titleSize}px !important`,
|
|
1030
|
+
fontWeight: `${titleWeight} !important`
|
|
1031
|
+
});
|
|
999
1032
|
return React.createElement(HeaderContainer, null, React.createElement(Typography, {
|
|
1000
|
-
variant: "h4"
|
|
1001
|
-
|
|
1033
|
+
variant: "h4",
|
|
1034
|
+
className: titleStyle()
|
|
1035
|
+
}, t(title.toLocaleLowerCase()) || title), React.createElement(HeaderButtons, {
|
|
1002
1036
|
onClickRefresh: onClickRefresh
|
|
1003
1037
|
}));
|
|
1004
1038
|
}
|
|
@@ -1076,6 +1110,11 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
1076
1110
|
address: wallet.address,
|
|
1077
1111
|
walletType: wallet.walletType
|
|
1078
1112
|
})
|
|
1113
|
+
})),
|
|
1114
|
+
clearConnectedWallet: () => set(() => ({
|
|
1115
|
+
accounts: [],
|
|
1116
|
+
balances: [],
|
|
1117
|
+
selectedWallets: []
|
|
1079
1118
|
}))
|
|
1080
1119
|
}))));
|
|
1081
1120
|
|
|
@@ -1139,6 +1178,9 @@ function TokenInfo(props) {
|
|
|
1139
1178
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
1140
1179
|
const balances = useWalletsStore.use.balances();
|
|
1141
1180
|
const navigate = useNavigate();
|
|
1181
|
+
const {
|
|
1182
|
+
t
|
|
1183
|
+
} = useTranslation();
|
|
1142
1184
|
const tokenBalance = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(balances, fromChain?.name, fromToken?.symbol, fromToken?.address)?.amount || '0', 8) : '0';
|
|
1143
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';
|
|
1144
1186
|
const ItemSuffix = React.createElement("div", {
|
|
@@ -1153,7 +1195,7 @@ function TokenInfo(props) {
|
|
|
1153
1195
|
}), React.createElement(AngleDownIcon, null));
|
|
1154
1196
|
return React.createElement(Box, null, React.createElement("div", null, React.createElement(Typography, {
|
|
1155
1197
|
variant: "body2"
|
|
1156
|
-
}, 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", {
|
|
1157
1199
|
className: "balance",
|
|
1158
1200
|
onClick: () => {
|
|
1159
1201
|
if (tokenBalance !== '0') setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
@@ -1163,7 +1205,7 @@ function TokenInfo(props) {
|
|
|
1163
1205
|
size: "small"
|
|
1164
1206
|
}, React.createElement(Typography, {
|
|
1165
1207
|
variant: "body2"
|
|
1166
|
-
},
|
|
1208
|
+
}, `${t('Max')}: ${tokenBalance} ${fromToken?.symbol || ''}`)))), React.createElement("div", {
|
|
1167
1209
|
className: "form"
|
|
1168
1210
|
}, React.createElement(Button, {
|
|
1169
1211
|
onClick: () => {
|
|
@@ -1181,7 +1223,7 @@ function TokenInfo(props) {
|
|
|
1181
1223
|
style: {
|
|
1182
1224
|
marginRight: '.5rem'
|
|
1183
1225
|
}
|
|
1184
|
-
}, loadingStatus === 'success' && chain ? chain.displayName : 'Chain'), React.createElement(Button, {
|
|
1226
|
+
}, loadingStatus === 'success' && chain ? chain.displayName : t('Chain')), React.createElement(Button, {
|
|
1185
1227
|
onClick: () => {
|
|
1186
1228
|
navigate(`/${props.type.toLowerCase()}-token`);
|
|
1187
1229
|
},
|
|
@@ -1197,7 +1239,7 @@ function TokenInfo(props) {
|
|
|
1197
1239
|
style: {
|
|
1198
1240
|
marginRight: '.5rem'
|
|
1199
1241
|
}
|
|
1200
|
-
}, 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, {
|
|
1201
1243
|
type: "number",
|
|
1202
1244
|
size: "large",
|
|
1203
1245
|
autoFocus: true,
|
|
@@ -1252,9 +1294,12 @@ const StyledAnchor = /*#__PURE__*/styled$1('a', {
|
|
|
1252
1294
|
textDecoration: 'none'
|
|
1253
1295
|
});
|
|
1254
1296
|
function BottomLogo() {
|
|
1297
|
+
const {
|
|
1298
|
+
t
|
|
1299
|
+
} = useTranslation();
|
|
1255
1300
|
return React.createElement(Container$1, null, React.createElement(Typography, {
|
|
1256
1301
|
variant: "caption"
|
|
1257
|
-
},
|
|
1302
|
+
}, t('Powered By')), React.createElement(StyledAnchor, {
|
|
1258
1303
|
href: "https://rango.exchange",
|
|
1259
1304
|
target: "_blank"
|
|
1260
1305
|
}, React.createElement(Logo, {
|
|
@@ -1344,7 +1389,12 @@ const Alerts = /*#__PURE__*/styled('div', {
|
|
|
1344
1389
|
width: '100%',
|
|
1345
1390
|
paddingTop: '$16'
|
|
1346
1391
|
});
|
|
1347
|
-
function Home() {
|
|
1392
|
+
function Home(props) {
|
|
1393
|
+
const {
|
|
1394
|
+
title = 'SWAP',
|
|
1395
|
+
titleSize = 18,
|
|
1396
|
+
titleWeight = 600
|
|
1397
|
+
} = props;
|
|
1348
1398
|
const waningMessage = '';
|
|
1349
1399
|
const isRouterInContext = useInRouterContext();
|
|
1350
1400
|
const navigate = useNavigate();
|
|
@@ -1357,9 +1407,9 @@ function Home() {
|
|
|
1357
1407
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
1358
1408
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
1359
1409
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
1410
|
+
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1360
1411
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1361
1412
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
1362
|
-
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1363
1413
|
const outputAmount = useBestRouteStore.use.outputAmount();
|
|
1364
1414
|
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
1365
1415
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
@@ -1391,6 +1441,9 @@ function Home() {
|
|
|
1391
1441
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
1392
1442
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
1393
1443
|
return React.createElement(Container$2, null, React.createElement(Header, {
|
|
1444
|
+
title: title,
|
|
1445
|
+
titleSize: titleSize,
|
|
1446
|
+
titleWeight: titleWeight,
|
|
1394
1447
|
onClickRefresh: fetchBestRoute
|
|
1395
1448
|
}), React.createElement(TokenInfo, {
|
|
1396
1449
|
type: "From",
|
|
@@ -1446,7 +1499,11 @@ function Home() {
|
|
|
1446
1499
|
}, swapButtonState.title), React.createElement(BottomLogo, null)));
|
|
1447
1500
|
}
|
|
1448
1501
|
|
|
1449
|
-
const Route =
|
|
1502
|
+
const Route = _ref => {
|
|
1503
|
+
let {
|
|
1504
|
+
children,
|
|
1505
|
+
...props
|
|
1506
|
+
} = _ref;
|
|
1450
1507
|
const location = useLocation$1();
|
|
1451
1508
|
const navigate = useNavigate$1();
|
|
1452
1509
|
const ref = useRef(true);
|
|
@@ -1456,16 +1513,17 @@ const Route = props => {
|
|
|
1456
1513
|
});
|
|
1457
1514
|
ref.current = false;
|
|
1458
1515
|
}, []);
|
|
1459
|
-
if ([navigationRoutes.confirmWallets, navigationRoutes.confirmSwap].includes(location.pathname) && ref.current) return React.createElement(Home,
|
|
1460
|
-
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);
|
|
1461
1518
|
};
|
|
1462
|
-
function AppRouter(
|
|
1519
|
+
function AppRouter(_ref2) {
|
|
1463
1520
|
let {
|
|
1464
|
-
children
|
|
1465
|
-
|
|
1521
|
+
children,
|
|
1522
|
+
...props
|
|
1523
|
+
} = _ref2;
|
|
1466
1524
|
const isRouterInContext = useInRouterContext$1();
|
|
1467
1525
|
const Router = isRouterInContext ? Route : MemoryRouter;
|
|
1468
|
-
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));
|
|
1469
1527
|
}
|
|
1470
1528
|
|
|
1471
1529
|
const StyledButton = /*#__PURE__*/styled(Button, {
|
|
@@ -1860,10 +1918,11 @@ function HistoryPage() {
|
|
|
1860
1918
|
});
|
|
1861
1919
|
}
|
|
1862
1920
|
|
|
1863
|
-
function LiquiditySourcePage() {
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
} =
|
|
1921
|
+
function LiquiditySourcePage(_ref) {
|
|
1922
|
+
let {
|
|
1923
|
+
supportedSwappers
|
|
1924
|
+
} = _ref;
|
|
1925
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
1867
1926
|
const toggleLiquiditySource = useSettingsStore.use.toggleLiquiditySource();
|
|
1868
1927
|
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
1869
1928
|
const toggleAllLiquiditySources = useSettingsStore.use.toggleAllLiquiditySources();
|
|
@@ -1887,7 +1946,7 @@ function LiquiditySourcePage() {
|
|
|
1887
1946
|
});
|
|
1888
1947
|
return React.createElement(LiquiditySourcesSelector, {
|
|
1889
1948
|
toggleAll: toggleAllLiquiditySources,
|
|
1890
|
-
list: uniqueSwappersGroups,
|
|
1949
|
+
list: supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups,
|
|
1891
1950
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
1892
1951
|
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources)
|
|
1893
1952
|
});
|
|
@@ -1895,11 +1954,10 @@ function LiquiditySourcePage() {
|
|
|
1895
1954
|
|
|
1896
1955
|
function SelectChainPage(props) {
|
|
1897
1956
|
const {
|
|
1898
|
-
type
|
|
1957
|
+
type,
|
|
1958
|
+
supportedChains
|
|
1899
1959
|
} = props;
|
|
1900
|
-
const
|
|
1901
|
-
blockchains
|
|
1902
|
-
} = useMetaStore.use.meta();
|
|
1960
|
+
const blockchains = supportedChains === 'all' ? useMetaStore.use.meta().blockchains : supportedChains;
|
|
1903
1961
|
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
1904
1962
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
1905
1963
|
const toChain = useBestRouteStore.use.toChain();
|
|
@@ -1926,15 +1984,14 @@ function SelectChainPage(props) {
|
|
|
1926
1984
|
}
|
|
1927
1985
|
|
|
1928
1986
|
function SelectTokenPage(props) {
|
|
1929
|
-
const {
|
|
1930
|
-
type
|
|
1931
|
-
} = props;
|
|
1932
1987
|
const {
|
|
1933
1988
|
navigateBackFrom
|
|
1934
1989
|
} = useNavigateBack();
|
|
1935
1990
|
const {
|
|
1936
|
-
|
|
1937
|
-
|
|
1991
|
+
type,
|
|
1992
|
+
supportedTokens
|
|
1993
|
+
} = props;
|
|
1994
|
+
const tokens = supportedTokens === 'all' ? useMetaStore.use.meta().tokens : supportedTokens;
|
|
1938
1995
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
1939
1996
|
const toChain = useBestRouteStore.use.toChain();
|
|
1940
1997
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
@@ -1971,7 +2028,10 @@ function SelectTokenPage(props) {
|
|
|
1971
2028
|
});
|
|
1972
2029
|
}
|
|
1973
2030
|
|
|
1974
|
-
function SettingsPage() {
|
|
2031
|
+
function SettingsPage(_ref) {
|
|
2032
|
+
let {
|
|
2033
|
+
supportedSwappers
|
|
2034
|
+
} = _ref;
|
|
1975
2035
|
const slippage = useSettingsStore.use.slippage();
|
|
1976
2036
|
const setSlippage = useSettingsStore.use.setSlippage();
|
|
1977
2037
|
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
@@ -1979,9 +2039,7 @@ function SettingsPage() {
|
|
|
1979
2039
|
const setCustomSlippage = useSettingsStore.use.setCustomSlippage();
|
|
1980
2040
|
const theme = useSettingsStore.use.theme();
|
|
1981
2041
|
const setTheme = useSettingsStore.use.setTheme();
|
|
1982
|
-
const
|
|
1983
|
-
swappers
|
|
1984
|
-
} = useMetaStore.use.meta();
|
|
2042
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
1985
2043
|
const navigate = useNavigate();
|
|
1986
2044
|
const {
|
|
1987
2045
|
navigateBackFrom
|
|
@@ -2003,14 +2061,16 @@ function SettingsPage() {
|
|
|
2003
2061
|
}
|
|
2004
2062
|
}
|
|
2005
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;
|
|
2006
2066
|
return React.createElement(Settings, {
|
|
2007
2067
|
slippages: SLIPPAGES,
|
|
2008
2068
|
selectedSlippage: slippage,
|
|
2009
2069
|
onSlippageChange: slippage => setSlippage(slippage),
|
|
2010
|
-
liquiditySources: uniqueSwappersGroups,
|
|
2011
|
-
selectedLiquiditySources: uniqueSwappersGroups.filter(s => s.selected),
|
|
2012
2070
|
onLiquiditySourcesClick: navigate.bind(null, navigationRoutes.liquiditySources),
|
|
2013
2071
|
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
2072
|
+
liquiditySources: supportedUniqueSwappersGroups,
|
|
2073
|
+
selectedLiquiditySources: supportedUniqueSwappersGroups.filter(s => s.selected),
|
|
2014
2074
|
customSlippage: customSlippage || NaN,
|
|
2015
2075
|
onCustomSlippageChange: setCustomSlippage,
|
|
2016
2076
|
minSlippage: MIN_SLIPPGAE,
|
|
@@ -2033,7 +2093,11 @@ const ListContainer = /*#__PURE__*/styled('div', {
|
|
|
2033
2093
|
const AlertContainer = /*#__PURE__*/styled('div', {
|
|
2034
2094
|
paddingBottom: '$16'
|
|
2035
2095
|
});
|
|
2036
|
-
function WalletsPage() {
|
|
2096
|
+
function WalletsPage(_ref) {
|
|
2097
|
+
let {
|
|
2098
|
+
supportedWallets,
|
|
2099
|
+
multiWallets
|
|
2100
|
+
} = _ref;
|
|
2037
2101
|
const {
|
|
2038
2102
|
navigateBackFrom
|
|
2039
2103
|
} = useNavigateBack();
|
|
@@ -2043,9 +2107,12 @@ function WalletsPage() {
|
|
|
2043
2107
|
getWalletInfo,
|
|
2044
2108
|
connect
|
|
2045
2109
|
} = useWallets();
|
|
2046
|
-
const wallets = getlistWallet(state, getWalletInfo, Object.values(WalletType));
|
|
2110
|
+
const wallets = getlistWallet(state, getWalletInfo, supportedWallets === 'all' ? Object.values(WalletType) : supportedWallets);
|
|
2047
2111
|
const [walletErrorMessage, setWalletErrorMessage] = useState('');
|
|
2048
2112
|
const toggleConnectWalletsButton = useUiStore.use.toggleConnectWalletsButton();
|
|
2113
|
+
const {
|
|
2114
|
+
t
|
|
2115
|
+
} = useTranslation();
|
|
2049
2116
|
const onSelectWallet = async type => {
|
|
2050
2117
|
const wallet = state(type);
|
|
2051
2118
|
try {
|
|
@@ -2053,6 +2120,9 @@ function WalletsPage() {
|
|
|
2053
2120
|
if (wallet.connected) {
|
|
2054
2121
|
await disconnect(type);
|
|
2055
2122
|
} else {
|
|
2123
|
+
if (!multiWallets && !!wallets.find(w => w.state === WalletState.CONNECTED)) {
|
|
2124
|
+
return;
|
|
2125
|
+
}
|
|
2056
2126
|
await connect(type);
|
|
2057
2127
|
}
|
|
2058
2128
|
} catch (e) {
|
|
@@ -2064,7 +2134,7 @@ function WalletsPage() {
|
|
|
2064
2134
|
return () => toggleConnectWalletsButton();
|
|
2065
2135
|
}, []);
|
|
2066
2136
|
return React.createElement(SecondaryPage, {
|
|
2067
|
-
title:
|
|
2137
|
+
title: t('Select Wallet'),
|
|
2068
2138
|
textField: false,
|
|
2069
2139
|
onBack: navigateBackFrom.bind(null, navigationRoutes.wallets)
|
|
2070
2140
|
}, React.createElement(React.Fragment, null, walletErrorMessage && React.createElement(AlertContainer, null, React.createElement(Alert, {
|
|
@@ -2170,51 +2240,80 @@ function SwapDetailsPage() {
|
|
|
2170
2240
|
});
|
|
2171
2241
|
}
|
|
2172
2242
|
|
|
2173
|
-
const AppRoutes =
|
|
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
|
-
|
|
2217
|
-
}
|
|
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
|
+
};
|
|
2218
2317
|
|
|
2219
2318
|
const Header$1 = /*#__PURE__*/styled('div', {
|
|
2220
2319
|
display: 'flex',
|
|
@@ -2228,7 +2327,10 @@ const WalletImage = /*#__PURE__*/styled('img', {
|
|
|
2228
2327
|
marginRight: '$6',
|
|
2229
2328
|
borderRadius: '99999px'
|
|
2230
2329
|
});
|
|
2231
|
-
function Layout() {
|
|
2330
|
+
function Layout(_ref) {
|
|
2331
|
+
let {
|
|
2332
|
+
configs
|
|
2333
|
+
} = _ref;
|
|
2232
2334
|
const navigate = useNavigate();
|
|
2233
2335
|
const {
|
|
2234
2336
|
balances,
|
|
@@ -2239,8 +2341,34 @@ function Layout() {
|
|
|
2239
2341
|
getWalletInfo
|
|
2240
2342
|
} = useWallets();
|
|
2241
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();
|
|
2242
2356
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
2243
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]);
|
|
2244
2372
|
return React.createElement(React.Fragment, null, React.createElement(Header$1, null, React.createElement(Button, {
|
|
2245
2373
|
size: "small",
|
|
2246
2374
|
suffix: React.createElement(AddWalletIcon, {
|
|
@@ -2256,7 +2384,7 @@ function Layout() {
|
|
|
2256
2384
|
src: walletImage
|
|
2257
2385
|
})) : React.createElement(React.Fragment, null), React.createElement(Typography, {
|
|
2258
2386
|
variant: "body2"
|
|
2259
|
-
}, !accounts?.length ? 'Connect Wallet' : `$${totalBalance || 0}`))), React.createElement(AppRoutes,
|
|
2387
|
+
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`))), React.createElement(AppRoutes, Object.assign({}, configs)));
|
|
2260
2388
|
}
|
|
2261
2389
|
|
|
2262
2390
|
const globalStyles = /*#__PURE__*/globalCss({
|
|
@@ -2275,52 +2403,298 @@ const globalStyles = /*#__PURE__*/globalCss({
|
|
|
2275
2403
|
}
|
|
2276
2404
|
}
|
|
2277
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
|
+
}
|
|
2278
2424
|
|
|
2279
|
-
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;
|
|
2280
2436
|
const theme = useSettingsStore.use.theme();
|
|
2281
2437
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
2282
|
-
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);
|
|
2283
2500
|
useEffect(() => {
|
|
2284
2501
|
(async () => {
|
|
2285
2502
|
await fetchMeta();
|
|
2286
2503
|
})();
|
|
2287
2504
|
const switchTheme = event => {
|
|
2288
|
-
if (event.matches) setOSTheme(
|
|
2505
|
+
if (event.matches) setOSTheme(customeDarkTheme);else setOSTheme(customeLightTheme);
|
|
2289
2506
|
};
|
|
2290
2507
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
2291
|
-
setOSTheme(
|
|
2508
|
+
setOSTheme(customeDarkTheme);
|
|
2292
2509
|
}
|
|
2293
2510
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', switchTheme);
|
|
2294
2511
|
return () => {
|
|
2295
2512
|
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', switchTheme);
|
|
2296
2513
|
};
|
|
2297
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]);
|
|
2298
2523
|
const getActiveTheme = () => {
|
|
2299
|
-
if (theme === 'auto') return OSTheme;else return theme === 'dark' ?
|
|
2524
|
+
if (theme === 'auto') return OSTheme;else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
2300
2525
|
};
|
|
2301
2526
|
return {
|
|
2302
2527
|
activeTheme: getActiveTheme()
|
|
2303
2528
|
};
|
|
2304
2529
|
}
|
|
2305
2530
|
|
|
2306
|
-
|
|
2307
|
-
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;
|
|
2308
2674
|
globalStyles();
|
|
2675
|
+
globalFont(configs?.fontFamily || 'Roboto');
|
|
2309
2676
|
const {
|
|
2310
2677
|
activeTheme
|
|
2311
|
-
} = useTheme(
|
|
2678
|
+
} = useTheme({
|
|
2679
|
+
...configs.colors,
|
|
2680
|
+
borderRadius: configs?.borderRadius,
|
|
2681
|
+
fontFamily: configs?.fontFamily
|
|
2682
|
+
});
|
|
2312
2683
|
const {
|
|
2313
2684
|
blockchains
|
|
2314
2685
|
} = useMetaStore.use.meta();
|
|
2315
2686
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
2316
2687
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
2688
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
2689
|
+
const {
|
|
2690
|
+
changeLanguage
|
|
2691
|
+
} = useSelectLanguage();
|
|
2692
|
+
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
2317
2693
|
const evmBasedChainNames = blockchains.filter(isEvmBlockchain).map(chain => chain.name);
|
|
2318
|
-
const onUpdateState = (type, event, value, supportedChains) => {
|
|
2694
|
+
const onUpdateState = (type, event, value, _, supportedChains) => {
|
|
2319
2695
|
if (event === Events.ACCOUNTS) {
|
|
2320
2696
|
if (value) {
|
|
2321
|
-
const supportedChainNames =
|
|
2322
|
-
//@ts-ignore
|
|
2323
|
-
walletAndSupportedChainsNames(supportedChains);
|
|
2697
|
+
const supportedChainNames = walletAndSupportedChainsNames(supportedChains);
|
|
2324
2698
|
const data = prepareAccountsForWalletStore(type, value, evmBasedChainNames, supportedChainNames);
|
|
2325
2699
|
connectWallet(data);
|
|
2326
2700
|
} else {
|
|
@@ -2328,14 +2702,40 @@ const SwapBox = () => {
|
|
|
2328
2702
|
}
|
|
2329
2703
|
}
|
|
2330
2704
|
};
|
|
2331
|
-
|
|
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, {
|
|
2332
2721
|
allBlockChains: blockchains,
|
|
2333
2722
|
providers: providers,
|
|
2334
2723
|
onUpdateState: onUpdateState
|
|
2335
2724
|
}, React.createElement("div", {
|
|
2336
2725
|
id: "pageContainer",
|
|
2337
2726
|
className: activeTheme
|
|
2338
|
-
}, 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
|
+
}))))));
|
|
2339
2739
|
};
|
|
2340
2740
|
|
|
2341
2741
|
export { SwapBox };
|