@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
|
@@ -15,12 +15,18 @@ var BigNumber__default = _interopDefault(BigNumber);
|
|
|
15
15
|
var middleware = require('zustand/middleware');
|
|
16
16
|
var rangoSdk = require('rango-sdk');
|
|
17
17
|
var walletsShared = require('@rango-dev/wallets-shared');
|
|
18
|
+
var rangoTypes = require('rango-types');
|
|
18
19
|
var walletsCore = require('@rango-dev/wallets-core');
|
|
20
|
+
var reactI18next = require('react-i18next');
|
|
19
21
|
var theme = require('@rango-dev/ui/src/theme');
|
|
20
22
|
var providerAll = require('@rango-dev/provider-all');
|
|
21
23
|
var shallow = require('zustand/shallow');
|
|
22
24
|
var queueManagerReact = require('@rango-dev/queue-manager-react');
|
|
23
25
|
var copy = _interopDefault(require('copy-to-clipboard'));
|
|
26
|
+
var i18n = _interopDefault(require('i18next'));
|
|
27
|
+
var Backend = _interopDefault(require('i18next-http-backend'));
|
|
28
|
+
var LanguageDetector = _interopDefault(require('i18next-browser-languagedetector'));
|
|
29
|
+
var queueManagerRangoPreset = require('@rango-dev/queue-manager-rango-preset');
|
|
24
30
|
|
|
25
31
|
const navigationRoutes = {
|
|
26
32
|
home: '/',
|
|
@@ -45,6 +51,24 @@ function removeDuplicateFrom(array) {
|
|
|
45
51
|
function areEqual(array1, array2) {
|
|
46
52
|
return array1.length === array2.length && array1.every((v, i) => v === array2[i]);
|
|
47
53
|
}
|
|
54
|
+
function shadeColor(color, percent) {
|
|
55
|
+
var R = parseInt(color.substring(1, 3), 16);
|
|
56
|
+
var G = parseInt(color.substring(3, 5), 16);
|
|
57
|
+
var B = parseInt(color.substring(5, 7), 16);
|
|
58
|
+
R = R * (100 + percent) / 100;
|
|
59
|
+
G = G * (100 + percent) / 100;
|
|
60
|
+
B = B * (100 + percent) / 100;
|
|
61
|
+
R = R < 255 ? R : 255;
|
|
62
|
+
G = G < 255 ? G : 255;
|
|
63
|
+
B = B < 255 ? B : 255;
|
|
64
|
+
R = Math.round(R);
|
|
65
|
+
G = Math.round(G);
|
|
66
|
+
B = Math.round(B);
|
|
67
|
+
var RR = R.toString(16).length == 1 ? '0' + R.toString(16) : R.toString(16);
|
|
68
|
+
var GG = G.toString(16).length == 1 ? '0' + G.toString(16) : G.toString(16);
|
|
69
|
+
var BB = B.toString(16).length == 1 ? '0' + B.toString(16) : B.toString(16);
|
|
70
|
+
return '#' + RR + GG + BB;
|
|
71
|
+
}
|
|
48
72
|
|
|
49
73
|
const getBestRouteToTokenUsdPrice = bestRoute => bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to.usdPrice;
|
|
50
74
|
function isNumberOfSwapsChanged(route1, route2) {
|
|
@@ -392,7 +416,7 @@ const isExperimentalChain = (blockchains, wallet) => {
|
|
|
392
416
|
const cosmosExperimentalChainInfo = walletsShared.getCosmosExperimentalChainInfo(Object.entries(blockchains).map(_ref => {
|
|
393
417
|
let [, blockchainMeta] = _ref;
|
|
394
418
|
return blockchainMeta;
|
|
395
|
-
}).filter(
|
|
419
|
+
}).filter(rangoTypes.isCosmosBlockchain));
|
|
396
420
|
return cosmosExperimentalChainInfo && !!cosmosExperimentalChainInfo[wallet];
|
|
397
421
|
};
|
|
398
422
|
const getKeplrCompatibleConnectedWallets = selectableWallets => {
|
|
@@ -1001,11 +1025,22 @@ const HeaderContainer = /*#__PURE__*/ui.styled('div', {
|
|
|
1001
1025
|
});
|
|
1002
1026
|
function Header(props) {
|
|
1003
1027
|
const {
|
|
1004
|
-
onClickRefresh
|
|
1028
|
+
onClickRefresh,
|
|
1029
|
+
title,
|
|
1030
|
+
titleSize,
|
|
1031
|
+
titleWeight
|
|
1005
1032
|
} = props;
|
|
1033
|
+
const {
|
|
1034
|
+
t
|
|
1035
|
+
} = reactI18next.useTranslation();
|
|
1036
|
+
const titleStyle = ui.css({
|
|
1037
|
+
fontSize: `${titleSize}px !important`,
|
|
1038
|
+
fontWeight: `${titleWeight} !important`
|
|
1039
|
+
});
|
|
1006
1040
|
return React__default.createElement(HeaderContainer, null, React__default.createElement(ui.Typography, {
|
|
1007
|
-
variant: "h4"
|
|
1008
|
-
|
|
1041
|
+
variant: "h4",
|
|
1042
|
+
className: titleStyle()
|
|
1043
|
+
}, t(title.toLocaleLowerCase()) || title), React__default.createElement(HeaderButtons, {
|
|
1009
1044
|
onClickRefresh: onClickRefresh
|
|
1010
1045
|
}));
|
|
1011
1046
|
}
|
|
@@ -1083,6 +1118,11 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.creat
|
|
|
1083
1118
|
address: wallet.address,
|
|
1084
1119
|
walletType: wallet.walletType
|
|
1085
1120
|
})
|
|
1121
|
+
})),
|
|
1122
|
+
clearConnectedWallet: () => set(() => ({
|
|
1123
|
+
accounts: [],
|
|
1124
|
+
balances: [],
|
|
1125
|
+
selectedWallets: []
|
|
1086
1126
|
}))
|
|
1087
1127
|
}))));
|
|
1088
1128
|
|
|
@@ -1146,6 +1186,9 @@ function TokenInfo(props) {
|
|
|
1146
1186
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
1147
1187
|
const balances = useWalletsStore.use.balances();
|
|
1148
1188
|
const navigate = reactRouterDom.useNavigate();
|
|
1189
|
+
const {
|
|
1190
|
+
t
|
|
1191
|
+
} = reactI18next.useTranslation();
|
|
1149
1192
|
const tokenBalance = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(balances, fromChain?.name, fromToken?.symbol, fromToken?.address)?.amount || '0', 8) : '0';
|
|
1150
1193
|
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';
|
|
1151
1194
|
const ItemSuffix = React__default.createElement("div", {
|
|
@@ -1160,7 +1203,7 @@ function TokenInfo(props) {
|
|
|
1160
1203
|
}), React__default.createElement(ui.AngleDownIcon, null));
|
|
1161
1204
|
return React__default.createElement(Box, null, React__default.createElement("div", null, React__default.createElement(ui.Typography, {
|
|
1162
1205
|
variant: "body2"
|
|
1163
|
-
}, type)), React__default.createElement(Container, null, props.type === 'From' && React__default.createElement(Options, null, React__default.createElement("div", {
|
|
1206
|
+
}, t(type))), React__default.createElement(Container, null, props.type === 'From' && React__default.createElement(Options, null, React__default.createElement("div", {
|
|
1164
1207
|
className: "balance",
|
|
1165
1208
|
onClick: () => {
|
|
1166
1209
|
if (tokenBalance !== '0') setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
@@ -1170,7 +1213,7 @@ function TokenInfo(props) {
|
|
|
1170
1213
|
size: "small"
|
|
1171
1214
|
}, React__default.createElement(ui.Typography, {
|
|
1172
1215
|
variant: "body2"
|
|
1173
|
-
},
|
|
1216
|
+
}, `${t('Max')}: ${tokenBalance} ${fromToken?.symbol || ''}`)))), React__default.createElement("div", {
|
|
1174
1217
|
className: "form"
|
|
1175
1218
|
}, React__default.createElement(ui.Button, {
|
|
1176
1219
|
onClick: () => {
|
|
@@ -1188,7 +1231,7 @@ function TokenInfo(props) {
|
|
|
1188
1231
|
style: {
|
|
1189
1232
|
marginRight: '.5rem'
|
|
1190
1233
|
}
|
|
1191
|
-
}, loadingStatus === 'success' && chain ? chain.displayName : 'Chain'), React__default.createElement(ui.Button, {
|
|
1234
|
+
}, loadingStatus === 'success' && chain ? chain.displayName : t('Chain')), React__default.createElement(ui.Button, {
|
|
1192
1235
|
onClick: () => {
|
|
1193
1236
|
navigate(`/${props.type.toLowerCase()}-token`);
|
|
1194
1237
|
},
|
|
@@ -1204,7 +1247,7 @@ function TokenInfo(props) {
|
|
|
1204
1247
|
style: {
|
|
1205
1248
|
marginRight: '.5rem'
|
|
1206
1249
|
}
|
|
1207
|
-
}, loadingStatus === 'success' && token ? token.symbol : 'Token'), props.type === 'From' ? React__default.createElement(ui.TextField, {
|
|
1250
|
+
}, loadingStatus === 'success' && token ? token.symbol : t('Token')), props.type === 'From' ? React__default.createElement(ui.TextField, {
|
|
1208
1251
|
type: "number",
|
|
1209
1252
|
size: "large",
|
|
1210
1253
|
autoFocus: true,
|
|
@@ -1259,9 +1302,12 @@ const StyledAnchor = /*#__PURE__*/theme.styled('a', {
|
|
|
1259
1302
|
textDecoration: 'none'
|
|
1260
1303
|
});
|
|
1261
1304
|
function BottomLogo() {
|
|
1305
|
+
const {
|
|
1306
|
+
t
|
|
1307
|
+
} = reactI18next.useTranslation();
|
|
1262
1308
|
return React__default.createElement(Container$1, null, React__default.createElement(ui.Typography, {
|
|
1263
1309
|
variant: "caption"
|
|
1264
|
-
},
|
|
1310
|
+
}, t('Powered By')), React__default.createElement(StyledAnchor, {
|
|
1265
1311
|
href: "https://rango.exchange",
|
|
1266
1312
|
target: "_blank"
|
|
1267
1313
|
}, React__default.createElement(Logo, {
|
|
@@ -1351,7 +1397,12 @@ const Alerts = /*#__PURE__*/ui.styled('div', {
|
|
|
1351
1397
|
width: '100%',
|
|
1352
1398
|
paddingTop: '$16'
|
|
1353
1399
|
});
|
|
1354
|
-
function Home() {
|
|
1400
|
+
function Home(props) {
|
|
1401
|
+
const {
|
|
1402
|
+
title = 'SWAP',
|
|
1403
|
+
titleSize = 18,
|
|
1404
|
+
titleWeight = 600
|
|
1405
|
+
} = props;
|
|
1355
1406
|
const waningMessage = '';
|
|
1356
1407
|
const isRouterInContext = reactRouterDom.useInRouterContext();
|
|
1357
1408
|
const navigate = reactRouterDom.useNavigate();
|
|
@@ -1364,9 +1415,9 @@ function Home() {
|
|
|
1364
1415
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
1365
1416
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
1366
1417
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
1418
|
+
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1367
1419
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1368
1420
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
1369
|
-
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1370
1421
|
const outputAmount = useBestRouteStore.use.outputAmount();
|
|
1371
1422
|
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
1372
1423
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
@@ -1398,6 +1449,9 @@ function Home() {
|
|
|
1398
1449
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
1399
1450
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
1400
1451
|
return React__default.createElement(Container$2, null, React__default.createElement(Header, {
|
|
1452
|
+
title: title,
|
|
1453
|
+
titleSize: titleSize,
|
|
1454
|
+
titleWeight: titleWeight,
|
|
1401
1455
|
onClickRefresh: fetchBestRoute
|
|
1402
1456
|
}), React__default.createElement(TokenInfo, {
|
|
1403
1457
|
type: "From",
|
|
@@ -1453,7 +1507,11 @@ function Home() {
|
|
|
1453
1507
|
}, swapButtonState.title), React__default.createElement(BottomLogo, null)));
|
|
1454
1508
|
}
|
|
1455
1509
|
|
|
1456
|
-
const Route =
|
|
1510
|
+
const Route = _ref => {
|
|
1511
|
+
let {
|
|
1512
|
+
children,
|
|
1513
|
+
...props
|
|
1514
|
+
} = _ref;
|
|
1457
1515
|
const location = reactRouter.useLocation();
|
|
1458
1516
|
const navigate = reactRouter.useNavigate();
|
|
1459
1517
|
const ref = React.useRef(true);
|
|
@@ -1463,16 +1521,17 @@ const Route = props => {
|
|
|
1463
1521
|
});
|
|
1464
1522
|
ref.current = false;
|
|
1465
1523
|
}, []);
|
|
1466
|
-
if ([navigationRoutes.confirmWallets, navigationRoutes.confirmSwap].includes(location.pathname) && ref.current) return React__default.createElement(Home,
|
|
1467
|
-
return React__default.createElement(React__default.Fragment, null, " ",
|
|
1524
|
+
if ([navigationRoutes.confirmWallets, navigationRoutes.confirmSwap].includes(location.pathname) && ref.current) return React__default.createElement(Home, Object.assign({}, props));
|
|
1525
|
+
return React__default.createElement(React__default.Fragment, null, " ", children);
|
|
1468
1526
|
};
|
|
1469
|
-
function AppRouter(
|
|
1527
|
+
function AppRouter(_ref2) {
|
|
1470
1528
|
let {
|
|
1471
|
-
children
|
|
1472
|
-
|
|
1529
|
+
children,
|
|
1530
|
+
...props
|
|
1531
|
+
} = _ref2;
|
|
1473
1532
|
const isRouterInContext = reactRouter.useInRouterContext();
|
|
1474
1533
|
const Router = isRouterInContext ? Route : reactRouter.MemoryRouter;
|
|
1475
|
-
return React__default.createElement(React__default.Fragment, null, React__default.createElement(Router,
|
|
1534
|
+
return React__default.createElement(React__default.Fragment, null, React__default.createElement(Router, Object.assign({}, props), children), isRouterInContext && React__default.createElement(UpdateUrl, null));
|
|
1476
1535
|
}
|
|
1477
1536
|
|
|
1478
1537
|
const StyledButton = /*#__PURE__*/ui.styled(ui.Button, {
|
|
@@ -1576,7 +1635,7 @@ const confirmSwap = async () => {
|
|
|
1576
1635
|
meta
|
|
1577
1636
|
} = useMetaStore.getState();
|
|
1578
1637
|
const userSlippage = customSlippage || slippage;
|
|
1579
|
-
if (!fromToken || !toToken || !inputAmount || !initialRoute) return;
|
|
1638
|
+
if (!fromToken || !toToken || !inputAmount || !initialRoute) return undefined;
|
|
1580
1639
|
if (proceedAnyway) {
|
|
1581
1640
|
const swapSettings = {
|
|
1582
1641
|
slippage: userSlippage.toString(),
|
|
@@ -1867,10 +1926,11 @@ function HistoryPage() {
|
|
|
1867
1926
|
});
|
|
1868
1927
|
}
|
|
1869
1928
|
|
|
1870
|
-
function LiquiditySourcePage() {
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
} =
|
|
1929
|
+
function LiquiditySourcePage(_ref) {
|
|
1930
|
+
let {
|
|
1931
|
+
supportedSwappers
|
|
1932
|
+
} = _ref;
|
|
1933
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
1874
1934
|
const toggleLiquiditySource = useSettingsStore.use.toggleLiquiditySource();
|
|
1875
1935
|
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
1876
1936
|
const toggleAllLiquiditySources = useSettingsStore.use.toggleAllLiquiditySources();
|
|
@@ -1894,7 +1954,7 @@ function LiquiditySourcePage() {
|
|
|
1894
1954
|
});
|
|
1895
1955
|
return React__default.createElement(ui.LiquiditySourcesSelector, {
|
|
1896
1956
|
toggleAll: toggleAllLiquiditySources,
|
|
1897
|
-
list: uniqueSwappersGroups,
|
|
1957
|
+
list: supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups,
|
|
1898
1958
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
1899
1959
|
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources)
|
|
1900
1960
|
});
|
|
@@ -1902,11 +1962,10 @@ function LiquiditySourcePage() {
|
|
|
1902
1962
|
|
|
1903
1963
|
function SelectChainPage(props) {
|
|
1904
1964
|
const {
|
|
1905
|
-
type
|
|
1965
|
+
type,
|
|
1966
|
+
supportedChains
|
|
1906
1967
|
} = props;
|
|
1907
|
-
const
|
|
1908
|
-
blockchains
|
|
1909
|
-
} = useMetaStore.use.meta();
|
|
1968
|
+
const blockchains = supportedChains === 'all' ? useMetaStore.use.meta().blockchains : supportedChains;
|
|
1910
1969
|
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
1911
1970
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
1912
1971
|
const toChain = useBestRouteStore.use.toChain();
|
|
@@ -1933,15 +1992,14 @@ function SelectChainPage(props) {
|
|
|
1933
1992
|
}
|
|
1934
1993
|
|
|
1935
1994
|
function SelectTokenPage(props) {
|
|
1936
|
-
const {
|
|
1937
|
-
type
|
|
1938
|
-
} = props;
|
|
1939
1995
|
const {
|
|
1940
1996
|
navigateBackFrom
|
|
1941
1997
|
} = useNavigateBack();
|
|
1942
1998
|
const {
|
|
1943
|
-
|
|
1944
|
-
|
|
1999
|
+
type,
|
|
2000
|
+
supportedTokens
|
|
2001
|
+
} = props;
|
|
2002
|
+
const tokens = supportedTokens === 'all' ? useMetaStore.use.meta().tokens : supportedTokens;
|
|
1945
2003
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
1946
2004
|
const toChain = useBestRouteStore.use.toChain();
|
|
1947
2005
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
@@ -1978,7 +2036,10 @@ function SelectTokenPage(props) {
|
|
|
1978
2036
|
});
|
|
1979
2037
|
}
|
|
1980
2038
|
|
|
1981
|
-
function SettingsPage() {
|
|
2039
|
+
function SettingsPage(_ref) {
|
|
2040
|
+
let {
|
|
2041
|
+
supportedSwappers
|
|
2042
|
+
} = _ref;
|
|
1982
2043
|
const slippage = useSettingsStore.use.slippage();
|
|
1983
2044
|
const setSlippage = useSettingsStore.use.setSlippage();
|
|
1984
2045
|
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
@@ -1986,9 +2047,7 @@ function SettingsPage() {
|
|
|
1986
2047
|
const setCustomSlippage = useSettingsStore.use.setCustomSlippage();
|
|
1987
2048
|
const theme = useSettingsStore.use.theme();
|
|
1988
2049
|
const setTheme = useSettingsStore.use.setTheme();
|
|
1989
|
-
const
|
|
1990
|
-
swappers
|
|
1991
|
-
} = useMetaStore.use.meta();
|
|
2050
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
1992
2051
|
const navigate = reactRouterDom.useNavigate();
|
|
1993
2052
|
const {
|
|
1994
2053
|
navigateBackFrom
|
|
@@ -2010,14 +2069,16 @@ function SettingsPage() {
|
|
|
2010
2069
|
}
|
|
2011
2070
|
}
|
|
2012
2071
|
});
|
|
2072
|
+
supportedSwappers !== 'all' && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0);
|
|
2073
|
+
const supportedUniqueSwappersGroups = supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups;
|
|
2013
2074
|
return React__default.createElement(ui.Settings, {
|
|
2014
2075
|
slippages: SLIPPAGES,
|
|
2015
2076
|
selectedSlippage: slippage,
|
|
2016
2077
|
onSlippageChange: slippage => setSlippage(slippage),
|
|
2017
|
-
liquiditySources: uniqueSwappersGroups,
|
|
2018
|
-
selectedLiquiditySources: uniqueSwappersGroups.filter(s => s.selected),
|
|
2019
2078
|
onLiquiditySourcesClick: navigate.bind(null, navigationRoutes.liquiditySources),
|
|
2020
2079
|
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
2080
|
+
liquiditySources: supportedUniqueSwappersGroups,
|
|
2081
|
+
selectedLiquiditySources: supportedUniqueSwappersGroups.filter(s => s.selected),
|
|
2021
2082
|
customSlippage: customSlippage || NaN,
|
|
2022
2083
|
onCustomSlippageChange: setCustomSlippage,
|
|
2023
2084
|
minSlippage: MIN_SLIPPGAE,
|
|
@@ -2040,7 +2101,11 @@ const ListContainer = /*#__PURE__*/ui.styled('div', {
|
|
|
2040
2101
|
const AlertContainer = /*#__PURE__*/ui.styled('div', {
|
|
2041
2102
|
paddingBottom: '$16'
|
|
2042
2103
|
});
|
|
2043
|
-
function WalletsPage() {
|
|
2104
|
+
function WalletsPage(_ref) {
|
|
2105
|
+
let {
|
|
2106
|
+
supportedWallets,
|
|
2107
|
+
multiWallets
|
|
2108
|
+
} = _ref;
|
|
2044
2109
|
const {
|
|
2045
2110
|
navigateBackFrom
|
|
2046
2111
|
} = useNavigateBack();
|
|
@@ -2050,9 +2115,12 @@ function WalletsPage() {
|
|
|
2050
2115
|
getWalletInfo,
|
|
2051
2116
|
connect
|
|
2052
2117
|
} = walletsCore.useWallets();
|
|
2053
|
-
const wallets = getlistWallet(state, getWalletInfo, Object.values(walletsShared.WalletType));
|
|
2118
|
+
const wallets = getlistWallet(state, getWalletInfo, supportedWallets === 'all' ? Object.values(walletsShared.WalletType) : supportedWallets);
|
|
2054
2119
|
const [walletErrorMessage, setWalletErrorMessage] = React.useState('');
|
|
2055
2120
|
const toggleConnectWalletsButton = useUiStore.use.toggleConnectWalletsButton();
|
|
2121
|
+
const {
|
|
2122
|
+
t
|
|
2123
|
+
} = reactI18next.useTranslation();
|
|
2056
2124
|
const onSelectWallet = async type => {
|
|
2057
2125
|
const wallet = state(type);
|
|
2058
2126
|
try {
|
|
@@ -2060,6 +2128,9 @@ function WalletsPage() {
|
|
|
2060
2128
|
if (wallet.connected) {
|
|
2061
2129
|
await disconnect(type);
|
|
2062
2130
|
} else {
|
|
2131
|
+
if (!multiWallets && !!wallets.find(w => w.state === ui.WalletState.CONNECTED)) {
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2063
2134
|
await connect(type);
|
|
2064
2135
|
}
|
|
2065
2136
|
} catch (e) {
|
|
@@ -2071,7 +2142,7 @@ function WalletsPage() {
|
|
|
2071
2142
|
return () => toggleConnectWalletsButton();
|
|
2072
2143
|
}, []);
|
|
2073
2144
|
return React__default.createElement(ui.SecondaryPage, {
|
|
2074
|
-
title:
|
|
2145
|
+
title: t('Select Wallet'),
|
|
2075
2146
|
textField: false,
|
|
2076
2147
|
onBack: navigateBackFrom.bind(null, navigationRoutes.wallets)
|
|
2077
2148
|
}, React__default.createElement(React__default.Fragment, null, walletErrorMessage && React__default.createElement(AlertContainer, null, React__default.createElement(ui.Alert, {
|
|
@@ -2177,51 +2248,80 @@ function SwapDetailsPage() {
|
|
|
2177
2248
|
});
|
|
2178
2249
|
}
|
|
2179
2250
|
|
|
2180
|
-
const AppRoutes =
|
|
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
|
-
|
|
2218
|
-
}, {
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
}
|
|
2251
|
+
const AppRoutes = _ref => {
|
|
2252
|
+
let {
|
|
2253
|
+
fromChains = 'all',
|
|
2254
|
+
toChains = 'all',
|
|
2255
|
+
fromTokens = 'all',
|
|
2256
|
+
toTokens = 'all',
|
|
2257
|
+
liquiditySources = 'all',
|
|
2258
|
+
wallets = 'all',
|
|
2259
|
+
title,
|
|
2260
|
+
multiWallets = true,
|
|
2261
|
+
titleSize,
|
|
2262
|
+
titleWeight
|
|
2263
|
+
} = _ref;
|
|
2264
|
+
return reactRouterDom.useRoutes([{
|
|
2265
|
+
path: navigationRoutes.home,
|
|
2266
|
+
element: React__default.createElement(Home, {
|
|
2267
|
+
title: title,
|
|
2268
|
+
titleSize: titleSize,
|
|
2269
|
+
titleWeight: titleWeight
|
|
2270
|
+
})
|
|
2271
|
+
}, {
|
|
2272
|
+
path: navigationRoutes.fromChain,
|
|
2273
|
+
element: React__default.createElement(SelectChainPage, {
|
|
2274
|
+
type: "from",
|
|
2275
|
+
supportedChains: fromChains
|
|
2276
|
+
})
|
|
2277
|
+
}, {
|
|
2278
|
+
path: navigationRoutes.toChain,
|
|
2279
|
+
element: React__default.createElement(SelectChainPage, {
|
|
2280
|
+
type: "to",
|
|
2281
|
+
supportedChains: toChains
|
|
2282
|
+
})
|
|
2283
|
+
}, {
|
|
2284
|
+
path: navigationRoutes.fromToken + '/*',
|
|
2285
|
+
element: React__default.createElement(SelectTokenPage, {
|
|
2286
|
+
type: "from",
|
|
2287
|
+
supportedTokens: fromTokens
|
|
2288
|
+
})
|
|
2289
|
+
}, {
|
|
2290
|
+
path: navigationRoutes.toToken,
|
|
2291
|
+
element: React__default.createElement(SelectTokenPage, {
|
|
2292
|
+
type: "to",
|
|
2293
|
+
supportedTokens: toTokens
|
|
2294
|
+
})
|
|
2295
|
+
}, {
|
|
2296
|
+
path: navigationRoutes.settings,
|
|
2297
|
+
element: React__default.createElement(SettingsPage, {
|
|
2298
|
+
supportedSwappers: liquiditySources
|
|
2299
|
+
})
|
|
2300
|
+
}, {
|
|
2301
|
+
path: navigationRoutes.liquiditySources,
|
|
2302
|
+
element: React__default.createElement(LiquiditySourcePage, {
|
|
2303
|
+
supportedSwappers: liquiditySources
|
|
2304
|
+
})
|
|
2305
|
+
}, {
|
|
2306
|
+
path: navigationRoutes.swaps,
|
|
2307
|
+
element: React__default.createElement(HistoryPage, null)
|
|
2308
|
+
}, {
|
|
2309
|
+
path: navigationRoutes.swapDetails,
|
|
2310
|
+
element: React__default.createElement(SwapDetailsPage, null)
|
|
2311
|
+
}, {
|
|
2312
|
+
path: navigationRoutes.wallets,
|
|
2313
|
+
element: React__default.createElement(WalletsPage, {
|
|
2314
|
+
supportedWallets: wallets,
|
|
2315
|
+
multiWallets: multiWallets
|
|
2316
|
+
})
|
|
2317
|
+
}, {
|
|
2318
|
+
path: navigationRoutes.confirmSwap,
|
|
2319
|
+
element: React__default.createElement(ConfirmSwapPage, null)
|
|
2320
|
+
}, {
|
|
2321
|
+
path: navigationRoutes.confirmWallets,
|
|
2322
|
+
element: React__default.createElement(ConfirmWalletsPage, null)
|
|
2323
|
+
}]);
|
|
2324
|
+
};
|
|
2225
2325
|
|
|
2226
2326
|
const Header$1 = /*#__PURE__*/ui.styled('div', {
|
|
2227
2327
|
display: 'flex',
|
|
@@ -2235,7 +2335,10 @@ const WalletImage = /*#__PURE__*/ui.styled('img', {
|
|
|
2235
2335
|
marginRight: '$6',
|
|
2236
2336
|
borderRadius: '99999px'
|
|
2237
2337
|
});
|
|
2238
|
-
function Layout() {
|
|
2338
|
+
function Layout(_ref) {
|
|
2339
|
+
let {
|
|
2340
|
+
configs
|
|
2341
|
+
} = _ref;
|
|
2239
2342
|
const navigate = reactRouterDom.useNavigate();
|
|
2240
2343
|
const {
|
|
2241
2344
|
balances,
|
|
@@ -2246,8 +2349,34 @@ function Layout() {
|
|
|
2246
2349
|
getWalletInfo
|
|
2247
2350
|
} = walletsCore.useWallets();
|
|
2248
2351
|
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(accounts, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2352
|
+
const {
|
|
2353
|
+
fromChain,
|
|
2354
|
+
toChain,
|
|
2355
|
+
toToken,
|
|
2356
|
+
fromToken,
|
|
2357
|
+
fromAmount
|
|
2358
|
+
} = configs;
|
|
2359
|
+
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
2360
|
+
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
2361
|
+
const setToChain = useBestRouteStore.use.setToChain();
|
|
2362
|
+
const setToToken = useBestRouteStore.use.setToToken();
|
|
2363
|
+
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2249
2364
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
2250
2365
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
2366
|
+
const {
|
|
2367
|
+
t
|
|
2368
|
+
} = reactI18next.useTranslation();
|
|
2369
|
+
React.useEffect(() => {
|
|
2370
|
+
setToChain(toChain);
|
|
2371
|
+
setToToken(toToken);
|
|
2372
|
+
}, [toChain, toToken]);
|
|
2373
|
+
React.useEffect(() => {
|
|
2374
|
+
setInputAmount(fromAmount.toString());
|
|
2375
|
+
}, [fromAmount]);
|
|
2376
|
+
React.useEffect(() => {
|
|
2377
|
+
setFromToken(fromToken);
|
|
2378
|
+
setFromChain(fromChain);
|
|
2379
|
+
}, [fromToken, fromChain]);
|
|
2251
2380
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(Header$1, null, React__default.createElement(ui.Button, {
|
|
2252
2381
|
size: "small",
|
|
2253
2382
|
suffix: React__default.createElement(ui.AddWalletIcon, {
|
|
@@ -2263,7 +2392,7 @@ function Layout() {
|
|
|
2263
2392
|
src: walletImage
|
|
2264
2393
|
})) : React__default.createElement(React__default.Fragment, null), React__default.createElement(ui.Typography, {
|
|
2265
2394
|
variant: "body2"
|
|
2266
|
-
}, !accounts?.length ? 'Connect Wallet' : `$${totalBalance || 0}`))), React__default.createElement(AppRoutes,
|
|
2395
|
+
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`))), React__default.createElement(AppRoutes, Object.assign({}, configs)));
|
|
2267
2396
|
}
|
|
2268
2397
|
|
|
2269
2398
|
const globalStyles = /*#__PURE__*/ui.globalCss({
|
|
@@ -2282,52 +2411,298 @@ const globalStyles = /*#__PURE__*/ui.globalCss({
|
|
|
2282
2411
|
}
|
|
2283
2412
|
}
|
|
2284
2413
|
});
|
|
2414
|
+
const globalFont = fontFamily => ui.globalCss({
|
|
2415
|
+
'@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')"],
|
|
2416
|
+
[`.font_${fontFamily.replace(/ /g, '')} ._text`]: {
|
|
2417
|
+
fontFamily
|
|
2418
|
+
}
|
|
2419
|
+
})();
|
|
2420
|
+
|
|
2421
|
+
function usePrevious(value) {
|
|
2422
|
+
// The ref object is a generic container whose current property is mutable ...
|
|
2423
|
+
// ... and can hold any value, similar to an instance property on a class
|
|
2424
|
+
const ref = React.useRef();
|
|
2425
|
+
// Store current value in ref
|
|
2426
|
+
React.useEffect(() => {
|
|
2427
|
+
ref.current = value;
|
|
2428
|
+
}, [value]); // Only re-run if value changes
|
|
2429
|
+
// Return previous value (happens before update in useEffect above)
|
|
2430
|
+
return ref.current;
|
|
2431
|
+
}
|
|
2285
2432
|
|
|
2286
|
-
function useTheme() {
|
|
2433
|
+
function useTheme(_ref) {
|
|
2434
|
+
let {
|
|
2435
|
+
primary = '#5FA425',
|
|
2436
|
+
background = '#fff',
|
|
2437
|
+
foreground = '#000',
|
|
2438
|
+
error = '#FF0000',
|
|
2439
|
+
warning = '#F5A623',
|
|
2440
|
+
success = '#0070F3',
|
|
2441
|
+
fontFamily = 'Robot',
|
|
2442
|
+
borderRadius = 5
|
|
2443
|
+
} = _ref;
|
|
2287
2444
|
const theme = useSettingsStore.use.theme();
|
|
2288
2445
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
2289
|
-
const
|
|
2446
|
+
const colors = {
|
|
2447
|
+
neutrals200: '#FAFAFA',
|
|
2448
|
+
neutrals300: '#EAEAEA',
|
|
2449
|
+
neutrals400: '#999999',
|
|
2450
|
+
neutrals500: '#888888',
|
|
2451
|
+
neutrals600: '#666666',
|
|
2452
|
+
neutrals700: '#444444',
|
|
2453
|
+
neutrals800: '#333333',
|
|
2454
|
+
neutrals900: '#111111',
|
|
2455
|
+
primary,
|
|
2456
|
+
primary100: shadeColor(primary, 15),
|
|
2457
|
+
primary200: shadeColor(primary, -10),
|
|
2458
|
+
primary300: shadeColor(primary, -15),
|
|
2459
|
+
primary400: shadeColor(primary, -20),
|
|
2460
|
+
primary500: shadeColor(primary, -25),
|
|
2461
|
+
primary600: shadeColor(primary, -30),
|
|
2462
|
+
primary700: shadeColor(primary, -35),
|
|
2463
|
+
primary800: shadeColor(primary, -40),
|
|
2464
|
+
primary900: shadeColor(primary, -45),
|
|
2465
|
+
background,
|
|
2466
|
+
foreground,
|
|
2467
|
+
error,
|
|
2468
|
+
error100: shadeColor(error, 50),
|
|
2469
|
+
error300: shadeColor(error, -10),
|
|
2470
|
+
error500: shadeColor(error, -20),
|
|
2471
|
+
error700: shadeColor(error, -30),
|
|
2472
|
+
warning,
|
|
2473
|
+
warning100: shadeColor(warning, 50),
|
|
2474
|
+
warning300: shadeColor(warning, -10),
|
|
2475
|
+
warning500: shadeColor(warning, -20),
|
|
2476
|
+
warning700: shadeColor(warning, -30),
|
|
2477
|
+
success,
|
|
2478
|
+
success100: shadeColor(success, 50),
|
|
2479
|
+
success300: shadeColor(success, -10),
|
|
2480
|
+
success500: shadeColor(success, -20),
|
|
2481
|
+
success700: shadeColor(success, -30)
|
|
2482
|
+
};
|
|
2483
|
+
const customeLightTheme = ui.createTheme({
|
|
2484
|
+
colors,
|
|
2485
|
+
radii: {
|
|
2486
|
+
5: `${borderRadius}px`
|
|
2487
|
+
}
|
|
2488
|
+
});
|
|
2489
|
+
const customeDarkTheme = ui.createTheme({
|
|
2490
|
+
colors: {
|
|
2491
|
+
...colors,
|
|
2492
|
+
neutrals200: '#111111',
|
|
2493
|
+
neutrals300: '#333333',
|
|
2494
|
+
neutrals400: '#444444',
|
|
2495
|
+
neutrals500: '#666666',
|
|
2496
|
+
neutrals600: '#888888',
|
|
2497
|
+
neutrals700: '#999999',
|
|
2498
|
+
neutrals800: '#EAEAEA',
|
|
2499
|
+
neutrals900: '#FAFAFA',
|
|
2500
|
+
foreground: background,
|
|
2501
|
+
background: foreground
|
|
2502
|
+
},
|
|
2503
|
+
radii: {
|
|
2504
|
+
5: `${borderRadius}px`
|
|
2505
|
+
}
|
|
2506
|
+
});
|
|
2507
|
+
const [OSTheme, setOSTheme] = React.useState(customeLightTheme);
|
|
2290
2508
|
React.useEffect(() => {
|
|
2291
2509
|
(async () => {
|
|
2292
2510
|
await fetchMeta();
|
|
2293
2511
|
})();
|
|
2294
2512
|
const switchTheme = event => {
|
|
2295
|
-
if (event.matches) setOSTheme(
|
|
2513
|
+
if (event.matches) setOSTheme(customeDarkTheme);else setOSTheme(customeLightTheme);
|
|
2296
2514
|
};
|
|
2297
2515
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
2298
|
-
setOSTheme(
|
|
2516
|
+
setOSTheme(customeDarkTheme);
|
|
2299
2517
|
}
|
|
2300
2518
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', switchTheme);
|
|
2301
2519
|
return () => {
|
|
2302
2520
|
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', switchTheme);
|
|
2303
2521
|
};
|
|
2304
2522
|
}, []);
|
|
2523
|
+
const prevFont = usePrevious(fontFamily);
|
|
2524
|
+
React.useLayoutEffect(() => {
|
|
2525
|
+
const {
|
|
2526
|
+
classList
|
|
2527
|
+
} = document.body;
|
|
2528
|
+
if (prevFont) classList.remove(`font_${prevFont.replace(/ /g, '')}`);
|
|
2529
|
+
classList.add(`font_${fontFamily.replace(/ /g, '')}`);
|
|
2530
|
+
}, [fontFamily]);
|
|
2305
2531
|
const getActiveTheme = () => {
|
|
2306
|
-
if (theme === 'auto') return OSTheme;else return theme === 'dark' ?
|
|
2532
|
+
if (theme === 'auto') return OSTheme;else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
2307
2533
|
};
|
|
2308
2534
|
return {
|
|
2309
2535
|
activeTheme: getActiveTheme()
|
|
2310
2536
|
};
|
|
2311
2537
|
}
|
|
2312
2538
|
|
|
2313
|
-
|
|
2314
|
-
const
|
|
2539
|
+
function useSelectLanguage() {
|
|
2540
|
+
const {
|
|
2541
|
+
i18n
|
|
2542
|
+
} = reactI18next.useTranslation();
|
|
2543
|
+
// @ts-ignore
|
|
2544
|
+
const currentLanguage = i18n?.language || 'en';
|
|
2545
|
+
const changeLanguage = value => {
|
|
2546
|
+
if (currentLanguage !== value) {
|
|
2547
|
+
// @ts-ignore
|
|
2548
|
+
i18n.changeLanguage(value);
|
|
2549
|
+
}
|
|
2550
|
+
};
|
|
2551
|
+
return {
|
|
2552
|
+
changeLanguage,
|
|
2553
|
+
currentLanguage
|
|
2554
|
+
};
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
var swap = "SWAP";
|
|
2558
|
+
var From = "From";
|
|
2559
|
+
var To = "To";
|
|
2560
|
+
var Max = "Max";
|
|
2561
|
+
var Chain = "Chain";
|
|
2562
|
+
var Token = "Token";
|
|
2563
|
+
var Source = "Source";
|
|
2564
|
+
var Destination = "Destination";
|
|
2565
|
+
var en = {
|
|
2566
|
+
swap: swap,
|
|
2567
|
+
"Connect Wallet": "Connect Wallet",
|
|
2568
|
+
"Powered By": "Powered By",
|
|
2569
|
+
From: From,
|
|
2570
|
+
To: To,
|
|
2571
|
+
Max: Max,
|
|
2572
|
+
Chain: Chain,
|
|
2573
|
+
Token: Token,
|
|
2574
|
+
Source: Source,
|
|
2575
|
+
Destination: Destination,
|
|
2576
|
+
"Select Wallet": "Select Wallet"
|
|
2577
|
+
};
|
|
2578
|
+
|
|
2579
|
+
var swap$1 = "TAKAS";
|
|
2580
|
+
var From$1 = "İtibaren";
|
|
2581
|
+
var To$1 = "İle";
|
|
2582
|
+
var Max$1 = "maks.";
|
|
2583
|
+
var Chain$1 = "Zincir";
|
|
2584
|
+
var Token$1 = "Jeton";
|
|
2585
|
+
var tr = {
|
|
2586
|
+
swap: swap$1,
|
|
2587
|
+
"Select Wallet": "Cüzdan Seç",
|
|
2588
|
+
"Powered By": "Tarafından desteklenmektedir",
|
|
2589
|
+
"Connect Wallet": "Cüzdanı Bağla",
|
|
2590
|
+
From: From$1,
|
|
2591
|
+
To: To$1,
|
|
2592
|
+
Max: Max$1,
|
|
2593
|
+
Chain: Chain$1,
|
|
2594
|
+
Token: Token$1
|
|
2595
|
+
};
|
|
2596
|
+
|
|
2597
|
+
const languages = ['en', 'tr'];
|
|
2598
|
+
i18n.use(Backend)
|
|
2599
|
+
// detect user language
|
|
2600
|
+
.use(LanguageDetector)
|
|
2601
|
+
// pass the i18n instance to react-i18next.
|
|
2602
|
+
.use(reactI18next.initReactI18next).init({
|
|
2603
|
+
resources: {
|
|
2604
|
+
en: {
|
|
2605
|
+
translation: en
|
|
2606
|
+
},
|
|
2607
|
+
tr: {
|
|
2608
|
+
translation: tr
|
|
2609
|
+
}
|
|
2610
|
+
},
|
|
2611
|
+
fallbackLng: 'en',
|
|
2612
|
+
debug: true,
|
|
2613
|
+
whitelist: languages
|
|
2614
|
+
});
|
|
2615
|
+
|
|
2616
|
+
function QueueManager(props) {
|
|
2617
|
+
const {
|
|
2618
|
+
providers,
|
|
2619
|
+
getSigners,
|
|
2620
|
+
state,
|
|
2621
|
+
connect,
|
|
2622
|
+
canSwitchNetworkTo,
|
|
2623
|
+
getWalletInfo
|
|
2624
|
+
} = walletsCore.useWallets();
|
|
2625
|
+
const {
|
|
2626
|
+
blockchains
|
|
2627
|
+
} = useMetaStore.use.meta();
|
|
2628
|
+
const balances = useWalletsStore.use.balances();
|
|
2629
|
+
const wallets = {
|
|
2630
|
+
blockchains: balances.map(wallet => ({
|
|
2631
|
+
accounts: [wallet],
|
|
2632
|
+
name: wallet.chain
|
|
2633
|
+
}))
|
|
2634
|
+
};
|
|
2635
|
+
const switchNetwork = (wallet, network) => {
|
|
2636
|
+
if (!canSwitchNetworkTo(wallet, network)) {
|
|
2637
|
+
return undefined;
|
|
2638
|
+
}
|
|
2639
|
+
return connect(wallet, network);
|
|
2640
|
+
};
|
|
2641
|
+
// TODO: this code copy & pasted from rango, should be refactored.
|
|
2642
|
+
const allBlockchains = blockchains.filter(blockchain => blockchain.enabled).reduce((blockchainsObj, blockchain) => (blockchainsObj[blockchain.name] = blockchain, blockchainsObj), {});
|
|
2643
|
+
const evmBasedChains = blockchains.filter(rangoSdk.isEvmBlockchain);
|
|
2644
|
+
const getSupportedChainNames = type => {
|
|
2645
|
+
const {
|
|
2646
|
+
supportedChains
|
|
2647
|
+
} = getWalletInfo(type);
|
|
2648
|
+
return walletAndSupportedChainsNames(supportedChains);
|
|
2649
|
+
};
|
|
2650
|
+
const allProviders = providers();
|
|
2651
|
+
const context = {
|
|
2652
|
+
meta: {
|
|
2653
|
+
blockchains: allBlockchains,
|
|
2654
|
+
evmBasedChains: evmBasedChains,
|
|
2655
|
+
evmNetworkChainInfo: walletsShared.convertEvmBlockchainMetaToEvmChainInfo(evmBasedChains),
|
|
2656
|
+
getSupportedChainNames
|
|
2657
|
+
},
|
|
2658
|
+
getSigners,
|
|
2659
|
+
//todo: remove Network type
|
|
2660
|
+
//@ts-ignore
|
|
2661
|
+
wallets,
|
|
2662
|
+
providers: allProviders,
|
|
2663
|
+
switchNetwork,
|
|
2664
|
+
connect,
|
|
2665
|
+
state,
|
|
2666
|
+
notifier: message => {
|
|
2667
|
+
console.log('[notifier]', message);
|
|
2668
|
+
}
|
|
2669
|
+
};
|
|
2670
|
+
return React__default.createElement(queueManagerReact.Provider, {
|
|
2671
|
+
queuesDefs: [queueManagerRangoPreset.swapQueueDef],
|
|
2672
|
+
context: context,
|
|
2673
|
+
onPersistedDataLoaded: _manager => {},
|
|
2674
|
+
isPaused: false
|
|
2675
|
+
}, props.children);
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
const SwapBox = _ref => {
|
|
2679
|
+
let {
|
|
2680
|
+
configs
|
|
2681
|
+
} = _ref;
|
|
2315
2682
|
globalStyles();
|
|
2683
|
+
globalFont(configs?.fontFamily || 'Roboto');
|
|
2316
2684
|
const {
|
|
2317
2685
|
activeTheme
|
|
2318
|
-
} = useTheme(
|
|
2686
|
+
} = useTheme({
|
|
2687
|
+
...configs.colors,
|
|
2688
|
+
borderRadius: configs?.borderRadius,
|
|
2689
|
+
fontFamily: configs?.fontFamily
|
|
2690
|
+
});
|
|
2319
2691
|
const {
|
|
2320
2692
|
blockchains
|
|
2321
2693
|
} = useMetaStore.use.meta();
|
|
2322
2694
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
2323
2695
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
2696
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
2697
|
+
const {
|
|
2698
|
+
changeLanguage
|
|
2699
|
+
} = useSelectLanguage();
|
|
2700
|
+
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
2324
2701
|
const evmBasedChainNames = blockchains.filter(rangoSdk.isEvmBlockchain).map(chain => chain.name);
|
|
2325
|
-
const onUpdateState = (type, event, value, supportedChains) => {
|
|
2702
|
+
const onUpdateState = (type, event, value, _, supportedChains) => {
|
|
2326
2703
|
if (event === walletsCore.Events.ACCOUNTS) {
|
|
2327
2704
|
if (value) {
|
|
2328
|
-
const supportedChainNames =
|
|
2329
|
-
//@ts-ignore
|
|
2330
|
-
walletAndSupportedChainsNames(supportedChains);
|
|
2705
|
+
const supportedChainNames = walletAndSupportedChainsNames(supportedChains);
|
|
2331
2706
|
const data = prepareAccountsForWalletStore(type, value, evmBasedChainNames, supportedChainNames);
|
|
2332
2707
|
connectWallet(data);
|
|
2333
2708
|
} else {
|
|
@@ -2335,6 +2710,21 @@ const SwapBox = () => {
|
|
|
2335
2710
|
}
|
|
2336
2711
|
}
|
|
2337
2712
|
};
|
|
2713
|
+
let providers = providerAll.allProviders();
|
|
2714
|
+
React.useEffect(() => {
|
|
2715
|
+
if (configs.theme !== 'auto') setTheme(configs.theme);
|
|
2716
|
+
}, [configs.theme]);
|
|
2717
|
+
React.useEffect(() => {
|
|
2718
|
+
const wallets = configs.wallets;
|
|
2719
|
+
clearConnectedWallet();
|
|
2720
|
+
providers = wallets === 'all' ? providerAll.allProviders() : providerAll.allProviders().filter(provider => {
|
|
2721
|
+
const type = provider.config.type;
|
|
2722
|
+
return wallets.find(w => w === type);
|
|
2723
|
+
});
|
|
2724
|
+
}, [configs?.wallets]);
|
|
2725
|
+
React.useEffect(() => {
|
|
2726
|
+
changeLanguage(configs?.languege);
|
|
2727
|
+
}, [configs?.languege]);
|
|
2338
2728
|
return React__default.createElement(walletsCore.Provider, {
|
|
2339
2729
|
allBlockChains: blockchains,
|
|
2340
2730
|
providers: providers,
|
|
@@ -2342,7 +2732,18 @@ const SwapBox = () => {
|
|
|
2342
2732
|
}, React__default.createElement("div", {
|
|
2343
2733
|
id: "pageContainer",
|
|
2344
2734
|
className: activeTheme
|
|
2345
|
-
}, React__default.createElement(
|
|
2735
|
+
}, React__default.createElement(QueueManager, null, React__default.createElement(ui.SwapContainer, {
|
|
2736
|
+
style: {
|
|
2737
|
+
width: configs?.width || 'auto',
|
|
2738
|
+
height: configs?.height || 'auto'
|
|
2739
|
+
}
|
|
2740
|
+
}, React__default.createElement(AppRouter, {
|
|
2741
|
+
title: configs.title,
|
|
2742
|
+
titleSize: configs.titleSize,
|
|
2743
|
+
titleWeight: configs.titleWeight
|
|
2744
|
+
}, React__default.createElement(Layout, {
|
|
2745
|
+
configs: configs
|
|
2746
|
+
}))))));
|
|
2346
2747
|
};
|
|
2347
2748
|
|
|
2348
2749
|
exports.SwapBox = SwapBox;
|