@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
|
@@ -17,11 +17,16 @@ var rangoSdk = require('rango-sdk');
|
|
|
17
17
|
var walletsShared = require('@rango-dev/wallets-shared');
|
|
18
18
|
var rangoTypes = require('rango-types');
|
|
19
19
|
var walletsCore = require('@rango-dev/wallets-core');
|
|
20
|
+
var reactI18next = require('react-i18next');
|
|
20
21
|
var theme = require('@rango-dev/ui/src/theme');
|
|
21
22
|
var providerAll = require('@rango-dev/provider-all');
|
|
22
23
|
var shallow = require('zustand/shallow');
|
|
23
24
|
var queueManagerReact = require('@rango-dev/queue-manager-react');
|
|
24
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');
|
|
25
30
|
|
|
26
31
|
const navigationRoutes = {
|
|
27
32
|
home: '/',
|
|
@@ -46,6 +51,24 @@ function removeDuplicateFrom(array) {
|
|
|
46
51
|
function areEqual(array1, array2) {
|
|
47
52
|
return array1.length === array2.length && array1.every((v, i) => v === array2[i]);
|
|
48
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
|
+
}
|
|
49
72
|
|
|
50
73
|
const getBestRouteToTokenUsdPrice = bestRoute => bestRoute?.result?.swaps[bestRoute?.result?.swaps.length - 1].to.usdPrice;
|
|
51
74
|
function isNumberOfSwapsChanged(route1, route2) {
|
|
@@ -1002,11 +1025,22 @@ const HeaderContainer = /*#__PURE__*/ui.styled('div', {
|
|
|
1002
1025
|
});
|
|
1003
1026
|
function Header(props) {
|
|
1004
1027
|
const {
|
|
1005
|
-
onClickRefresh
|
|
1028
|
+
onClickRefresh,
|
|
1029
|
+
title,
|
|
1030
|
+
titleSize,
|
|
1031
|
+
titleWeight
|
|
1006
1032
|
} = props;
|
|
1033
|
+
const {
|
|
1034
|
+
t
|
|
1035
|
+
} = reactI18next.useTranslation();
|
|
1036
|
+
const titleStyle = ui.css({
|
|
1037
|
+
fontSize: `${titleSize}px !important`,
|
|
1038
|
+
fontWeight: `${titleWeight} !important`
|
|
1039
|
+
});
|
|
1007
1040
|
return React__default.createElement(HeaderContainer, null, React__default.createElement(ui.Typography, {
|
|
1008
|
-
variant: "h4"
|
|
1009
|
-
|
|
1041
|
+
variant: "h4",
|
|
1042
|
+
className: titleStyle()
|
|
1043
|
+
}, t(title.toLocaleLowerCase()) || title), React__default.createElement(HeaderButtons, {
|
|
1010
1044
|
onClickRefresh: onClickRefresh
|
|
1011
1045
|
}));
|
|
1012
1046
|
}
|
|
@@ -1084,6 +1118,11 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.creat
|
|
|
1084
1118
|
address: wallet.address,
|
|
1085
1119
|
walletType: wallet.walletType
|
|
1086
1120
|
})
|
|
1121
|
+
})),
|
|
1122
|
+
clearConnectedWallet: () => set(() => ({
|
|
1123
|
+
accounts: [],
|
|
1124
|
+
balances: [],
|
|
1125
|
+
selectedWallets: []
|
|
1087
1126
|
}))
|
|
1088
1127
|
}))));
|
|
1089
1128
|
|
|
@@ -1147,6 +1186,9 @@ function TokenInfo(props) {
|
|
|
1147
1186
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
1148
1187
|
const balances = useWalletsStore.use.balances();
|
|
1149
1188
|
const navigate = reactRouterDom.useNavigate();
|
|
1189
|
+
const {
|
|
1190
|
+
t
|
|
1191
|
+
} = reactI18next.useTranslation();
|
|
1150
1192
|
const tokenBalance = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(balances, fromChain?.name, fromToken?.symbol, fromToken?.address)?.amount || '0', 8) : '0';
|
|
1151
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';
|
|
1152
1194
|
const ItemSuffix = React__default.createElement("div", {
|
|
@@ -1161,7 +1203,7 @@ function TokenInfo(props) {
|
|
|
1161
1203
|
}), React__default.createElement(ui.AngleDownIcon, null));
|
|
1162
1204
|
return React__default.createElement(Box, null, React__default.createElement("div", null, React__default.createElement(ui.Typography, {
|
|
1163
1205
|
variant: "body2"
|
|
1164
|
-
}, 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", {
|
|
1165
1207
|
className: "balance",
|
|
1166
1208
|
onClick: () => {
|
|
1167
1209
|
if (tokenBalance !== '0') setInputAmount(tokenBalanceReal.split(',').join(''));
|
|
@@ -1171,7 +1213,7 @@ function TokenInfo(props) {
|
|
|
1171
1213
|
size: "small"
|
|
1172
1214
|
}, React__default.createElement(ui.Typography, {
|
|
1173
1215
|
variant: "body2"
|
|
1174
|
-
},
|
|
1216
|
+
}, `${t('Max')}: ${tokenBalance} ${fromToken?.symbol || ''}`)))), React__default.createElement("div", {
|
|
1175
1217
|
className: "form"
|
|
1176
1218
|
}, React__default.createElement(ui.Button, {
|
|
1177
1219
|
onClick: () => {
|
|
@@ -1189,7 +1231,7 @@ function TokenInfo(props) {
|
|
|
1189
1231
|
style: {
|
|
1190
1232
|
marginRight: '.5rem'
|
|
1191
1233
|
}
|
|
1192
|
-
}, loadingStatus === 'success' && chain ? chain.displayName : 'Chain'), React__default.createElement(ui.Button, {
|
|
1234
|
+
}, loadingStatus === 'success' && chain ? chain.displayName : t('Chain')), React__default.createElement(ui.Button, {
|
|
1193
1235
|
onClick: () => {
|
|
1194
1236
|
navigate(`/${props.type.toLowerCase()}-token`);
|
|
1195
1237
|
},
|
|
@@ -1205,7 +1247,7 @@ function TokenInfo(props) {
|
|
|
1205
1247
|
style: {
|
|
1206
1248
|
marginRight: '.5rem'
|
|
1207
1249
|
}
|
|
1208
|
-
}, 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, {
|
|
1209
1251
|
type: "number",
|
|
1210
1252
|
size: "large",
|
|
1211
1253
|
autoFocus: true,
|
|
@@ -1260,9 +1302,12 @@ const StyledAnchor = /*#__PURE__*/theme.styled('a', {
|
|
|
1260
1302
|
textDecoration: 'none'
|
|
1261
1303
|
});
|
|
1262
1304
|
function BottomLogo() {
|
|
1305
|
+
const {
|
|
1306
|
+
t
|
|
1307
|
+
} = reactI18next.useTranslation();
|
|
1263
1308
|
return React__default.createElement(Container$1, null, React__default.createElement(ui.Typography, {
|
|
1264
1309
|
variant: "caption"
|
|
1265
|
-
},
|
|
1310
|
+
}, t('Powered By')), React__default.createElement(StyledAnchor, {
|
|
1266
1311
|
href: "https://rango.exchange",
|
|
1267
1312
|
target: "_blank"
|
|
1268
1313
|
}, React__default.createElement(Logo, {
|
|
@@ -1352,7 +1397,12 @@ const Alerts = /*#__PURE__*/ui.styled('div', {
|
|
|
1352
1397
|
width: '100%',
|
|
1353
1398
|
paddingTop: '$16'
|
|
1354
1399
|
});
|
|
1355
|
-
function Home() {
|
|
1400
|
+
function Home(props) {
|
|
1401
|
+
const {
|
|
1402
|
+
title = 'SWAP',
|
|
1403
|
+
titleSize = 18,
|
|
1404
|
+
titleWeight = 600
|
|
1405
|
+
} = props;
|
|
1356
1406
|
const waningMessage = '';
|
|
1357
1407
|
const isRouterInContext = reactRouterDom.useInRouterContext();
|
|
1358
1408
|
const navigate = reactRouterDom.useNavigate();
|
|
@@ -1365,9 +1415,9 @@ function Home() {
|
|
|
1365
1415
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
1366
1416
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
1367
1417
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
1418
|
+
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1368
1419
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1369
1420
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
1370
|
-
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1371
1421
|
const outputAmount = useBestRouteStore.use.outputAmount();
|
|
1372
1422
|
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
1373
1423
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
@@ -1399,6 +1449,9 @@ function Home() {
|
|
|
1399
1449
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
1400
1450
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
1401
1451
|
return React__default.createElement(Container$2, null, React__default.createElement(Header, {
|
|
1452
|
+
title: title,
|
|
1453
|
+
titleSize: titleSize,
|
|
1454
|
+
titleWeight: titleWeight,
|
|
1402
1455
|
onClickRefresh: fetchBestRoute
|
|
1403
1456
|
}), React__default.createElement(TokenInfo, {
|
|
1404
1457
|
type: "From",
|
|
@@ -1454,7 +1507,11 @@ function Home() {
|
|
|
1454
1507
|
}, swapButtonState.title), React__default.createElement(BottomLogo, null)));
|
|
1455
1508
|
}
|
|
1456
1509
|
|
|
1457
|
-
const Route =
|
|
1510
|
+
const Route = _ref => {
|
|
1511
|
+
let {
|
|
1512
|
+
children,
|
|
1513
|
+
...props
|
|
1514
|
+
} = _ref;
|
|
1458
1515
|
const location = reactRouter.useLocation();
|
|
1459
1516
|
const navigate = reactRouter.useNavigate();
|
|
1460
1517
|
const ref = React.useRef(true);
|
|
@@ -1464,16 +1521,17 @@ const Route = props => {
|
|
|
1464
1521
|
});
|
|
1465
1522
|
ref.current = false;
|
|
1466
1523
|
}, []);
|
|
1467
|
-
if ([navigationRoutes.confirmWallets, navigationRoutes.confirmSwap].includes(location.pathname) && ref.current) return React__default.createElement(Home,
|
|
1468
|
-
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);
|
|
1469
1526
|
};
|
|
1470
|
-
function AppRouter(
|
|
1527
|
+
function AppRouter(_ref2) {
|
|
1471
1528
|
let {
|
|
1472
|
-
children
|
|
1473
|
-
|
|
1529
|
+
children,
|
|
1530
|
+
...props
|
|
1531
|
+
} = _ref2;
|
|
1474
1532
|
const isRouterInContext = reactRouter.useInRouterContext();
|
|
1475
1533
|
const Router = isRouterInContext ? Route : reactRouter.MemoryRouter;
|
|
1476
|
-
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));
|
|
1477
1535
|
}
|
|
1478
1536
|
|
|
1479
1537
|
const StyledButton = /*#__PURE__*/ui.styled(ui.Button, {
|
|
@@ -1868,10 +1926,11 @@ function HistoryPage() {
|
|
|
1868
1926
|
});
|
|
1869
1927
|
}
|
|
1870
1928
|
|
|
1871
|
-
function LiquiditySourcePage() {
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
} =
|
|
1929
|
+
function LiquiditySourcePage(_ref) {
|
|
1930
|
+
let {
|
|
1931
|
+
supportedSwappers
|
|
1932
|
+
} = _ref;
|
|
1933
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
1875
1934
|
const toggleLiquiditySource = useSettingsStore.use.toggleLiquiditySource();
|
|
1876
1935
|
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
1877
1936
|
const toggleAllLiquiditySources = useSettingsStore.use.toggleAllLiquiditySources();
|
|
@@ -1895,7 +1954,7 @@ function LiquiditySourcePage() {
|
|
|
1895
1954
|
});
|
|
1896
1955
|
return React__default.createElement(ui.LiquiditySourcesSelector, {
|
|
1897
1956
|
toggleAll: toggleAllLiquiditySources,
|
|
1898
|
-
list: uniqueSwappersGroups,
|
|
1957
|
+
list: supportedSwappers !== 'all' ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s.title === item.title && s.type === item.type).length > 0) : uniqueSwappersGroups,
|
|
1899
1958
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
1900
1959
|
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources)
|
|
1901
1960
|
});
|
|
@@ -1903,11 +1962,10 @@ function LiquiditySourcePage() {
|
|
|
1903
1962
|
|
|
1904
1963
|
function SelectChainPage(props) {
|
|
1905
1964
|
const {
|
|
1906
|
-
type
|
|
1965
|
+
type,
|
|
1966
|
+
supportedChains
|
|
1907
1967
|
} = props;
|
|
1908
|
-
const
|
|
1909
|
-
blockchains
|
|
1910
|
-
} = useMetaStore.use.meta();
|
|
1968
|
+
const blockchains = supportedChains === 'all' ? useMetaStore.use.meta().blockchains : supportedChains;
|
|
1911
1969
|
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
1912
1970
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
1913
1971
|
const toChain = useBestRouteStore.use.toChain();
|
|
@@ -1934,15 +1992,14 @@ function SelectChainPage(props) {
|
|
|
1934
1992
|
}
|
|
1935
1993
|
|
|
1936
1994
|
function SelectTokenPage(props) {
|
|
1937
|
-
const {
|
|
1938
|
-
type
|
|
1939
|
-
} = props;
|
|
1940
1995
|
const {
|
|
1941
1996
|
navigateBackFrom
|
|
1942
1997
|
} = useNavigateBack();
|
|
1943
1998
|
const {
|
|
1944
|
-
|
|
1945
|
-
|
|
1999
|
+
type,
|
|
2000
|
+
supportedTokens
|
|
2001
|
+
} = props;
|
|
2002
|
+
const tokens = supportedTokens === 'all' ? useMetaStore.use.meta().tokens : supportedTokens;
|
|
1946
2003
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
1947
2004
|
const toChain = useBestRouteStore.use.toChain();
|
|
1948
2005
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
@@ -1979,7 +2036,10 @@ function SelectTokenPage(props) {
|
|
|
1979
2036
|
});
|
|
1980
2037
|
}
|
|
1981
2038
|
|
|
1982
|
-
function SettingsPage() {
|
|
2039
|
+
function SettingsPage(_ref) {
|
|
2040
|
+
let {
|
|
2041
|
+
supportedSwappers
|
|
2042
|
+
} = _ref;
|
|
1983
2043
|
const slippage = useSettingsStore.use.slippage();
|
|
1984
2044
|
const setSlippage = useSettingsStore.use.setSlippage();
|
|
1985
2045
|
const disabledLiquiditySources = useSettingsStore.use.disabledLiquiditySources();
|
|
@@ -1987,9 +2047,7 @@ function SettingsPage() {
|
|
|
1987
2047
|
const setCustomSlippage = useSettingsStore.use.setCustomSlippage();
|
|
1988
2048
|
const theme = useSettingsStore.use.theme();
|
|
1989
2049
|
const setTheme = useSettingsStore.use.setTheme();
|
|
1990
|
-
const
|
|
1991
|
-
swappers
|
|
1992
|
-
} = useMetaStore.use.meta();
|
|
2050
|
+
const swappers = useMetaStore.use.meta().swappers;
|
|
1993
2051
|
const navigate = reactRouterDom.useNavigate();
|
|
1994
2052
|
const {
|
|
1995
2053
|
navigateBackFrom
|
|
@@ -2011,14 +2069,16 @@ function SettingsPage() {
|
|
|
2011
2069
|
}
|
|
2012
2070
|
}
|
|
2013
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;
|
|
2014
2074
|
return React__default.createElement(ui.Settings, {
|
|
2015
2075
|
slippages: SLIPPAGES,
|
|
2016
2076
|
selectedSlippage: slippage,
|
|
2017
2077
|
onSlippageChange: slippage => setSlippage(slippage),
|
|
2018
|
-
liquiditySources: uniqueSwappersGroups,
|
|
2019
|
-
selectedLiquiditySources: uniqueSwappersGroups.filter(s => s.selected),
|
|
2020
2078
|
onLiquiditySourcesClick: navigate.bind(null, navigationRoutes.liquiditySources),
|
|
2021
2079
|
onBack: navigateBackFrom.bind(null, navigationRoutes.settings),
|
|
2080
|
+
liquiditySources: supportedUniqueSwappersGroups,
|
|
2081
|
+
selectedLiquiditySources: supportedUniqueSwappersGroups.filter(s => s.selected),
|
|
2022
2082
|
customSlippage: customSlippage || NaN,
|
|
2023
2083
|
onCustomSlippageChange: setCustomSlippage,
|
|
2024
2084
|
minSlippage: MIN_SLIPPGAE,
|
|
@@ -2041,7 +2101,11 @@ const ListContainer = /*#__PURE__*/ui.styled('div', {
|
|
|
2041
2101
|
const AlertContainer = /*#__PURE__*/ui.styled('div', {
|
|
2042
2102
|
paddingBottom: '$16'
|
|
2043
2103
|
});
|
|
2044
|
-
function WalletsPage() {
|
|
2104
|
+
function WalletsPage(_ref) {
|
|
2105
|
+
let {
|
|
2106
|
+
supportedWallets,
|
|
2107
|
+
multiWallets
|
|
2108
|
+
} = _ref;
|
|
2045
2109
|
const {
|
|
2046
2110
|
navigateBackFrom
|
|
2047
2111
|
} = useNavigateBack();
|
|
@@ -2051,9 +2115,12 @@ function WalletsPage() {
|
|
|
2051
2115
|
getWalletInfo,
|
|
2052
2116
|
connect
|
|
2053
2117
|
} = walletsCore.useWallets();
|
|
2054
|
-
const wallets = getlistWallet(state, getWalletInfo, Object.values(walletsShared.WalletType));
|
|
2118
|
+
const wallets = getlistWallet(state, getWalletInfo, supportedWallets === 'all' ? Object.values(walletsShared.WalletType) : supportedWallets);
|
|
2055
2119
|
const [walletErrorMessage, setWalletErrorMessage] = React.useState('');
|
|
2056
2120
|
const toggleConnectWalletsButton = useUiStore.use.toggleConnectWalletsButton();
|
|
2121
|
+
const {
|
|
2122
|
+
t
|
|
2123
|
+
} = reactI18next.useTranslation();
|
|
2057
2124
|
const onSelectWallet = async type => {
|
|
2058
2125
|
const wallet = state(type);
|
|
2059
2126
|
try {
|
|
@@ -2061,6 +2128,9 @@ function WalletsPage() {
|
|
|
2061
2128
|
if (wallet.connected) {
|
|
2062
2129
|
await disconnect(type);
|
|
2063
2130
|
} else {
|
|
2131
|
+
if (!multiWallets && !!wallets.find(w => w.state === ui.WalletState.CONNECTED)) {
|
|
2132
|
+
return;
|
|
2133
|
+
}
|
|
2064
2134
|
await connect(type);
|
|
2065
2135
|
}
|
|
2066
2136
|
} catch (e) {
|
|
@@ -2072,7 +2142,7 @@ function WalletsPage() {
|
|
|
2072
2142
|
return () => toggleConnectWalletsButton();
|
|
2073
2143
|
}, []);
|
|
2074
2144
|
return React__default.createElement(ui.SecondaryPage, {
|
|
2075
|
-
title:
|
|
2145
|
+
title: t('Select Wallet'),
|
|
2076
2146
|
textField: false,
|
|
2077
2147
|
onBack: navigateBackFrom.bind(null, navigationRoutes.wallets)
|
|
2078
2148
|
}, React__default.createElement(React__default.Fragment, null, walletErrorMessage && React__default.createElement(AlertContainer, null, React__default.createElement(ui.Alert, {
|
|
@@ -2178,51 +2248,80 @@ function SwapDetailsPage() {
|
|
|
2178
2248
|
});
|
|
2179
2249
|
}
|
|
2180
2250
|
|
|
2181
|
-
const AppRoutes =
|
|
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
|
-
|
|
2225
|
-
}
|
|
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
|
+
};
|
|
2226
2325
|
|
|
2227
2326
|
const Header$1 = /*#__PURE__*/ui.styled('div', {
|
|
2228
2327
|
display: 'flex',
|
|
@@ -2236,7 +2335,10 @@ const WalletImage = /*#__PURE__*/ui.styled('img', {
|
|
|
2236
2335
|
marginRight: '$6',
|
|
2237
2336
|
borderRadius: '99999px'
|
|
2238
2337
|
});
|
|
2239
|
-
function Layout() {
|
|
2338
|
+
function Layout(_ref) {
|
|
2339
|
+
let {
|
|
2340
|
+
configs
|
|
2341
|
+
} = _ref;
|
|
2240
2342
|
const navigate = reactRouterDom.useNavigate();
|
|
2241
2343
|
const {
|
|
2242
2344
|
balances,
|
|
@@ -2247,8 +2349,34 @@ function Layout() {
|
|
|
2247
2349
|
getWalletInfo
|
|
2248
2350
|
} = walletsCore.useWallets();
|
|
2249
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();
|
|
2250
2364
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
2251
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]);
|
|
2252
2380
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(Header$1, null, React__default.createElement(ui.Button, {
|
|
2253
2381
|
size: "small",
|
|
2254
2382
|
suffix: React__default.createElement(ui.AddWalletIcon, {
|
|
@@ -2264,7 +2392,7 @@ function Layout() {
|
|
|
2264
2392
|
src: walletImage
|
|
2265
2393
|
})) : React__default.createElement(React__default.Fragment, null), React__default.createElement(ui.Typography, {
|
|
2266
2394
|
variant: "body2"
|
|
2267
|
-
}, !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)));
|
|
2268
2396
|
}
|
|
2269
2397
|
|
|
2270
2398
|
const globalStyles = /*#__PURE__*/ui.globalCss({
|
|
@@ -2283,52 +2411,298 @@ const globalStyles = /*#__PURE__*/ui.globalCss({
|
|
|
2283
2411
|
}
|
|
2284
2412
|
}
|
|
2285
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
|
+
}
|
|
2286
2432
|
|
|
2287
|
-
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;
|
|
2288
2444
|
const theme = useSettingsStore.use.theme();
|
|
2289
2445
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
2290
|
-
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);
|
|
2291
2508
|
React.useEffect(() => {
|
|
2292
2509
|
(async () => {
|
|
2293
2510
|
await fetchMeta();
|
|
2294
2511
|
})();
|
|
2295
2512
|
const switchTheme = event => {
|
|
2296
|
-
if (event.matches) setOSTheme(
|
|
2513
|
+
if (event.matches) setOSTheme(customeDarkTheme);else setOSTheme(customeLightTheme);
|
|
2297
2514
|
};
|
|
2298
2515
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
|
2299
|
-
setOSTheme(
|
|
2516
|
+
setOSTheme(customeDarkTheme);
|
|
2300
2517
|
}
|
|
2301
2518
|
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', switchTheme);
|
|
2302
2519
|
return () => {
|
|
2303
2520
|
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', switchTheme);
|
|
2304
2521
|
};
|
|
2305
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]);
|
|
2306
2531
|
const getActiveTheme = () => {
|
|
2307
|
-
if (theme === 'auto') return OSTheme;else return theme === 'dark' ?
|
|
2532
|
+
if (theme === 'auto') return OSTheme;else return theme === 'dark' ? customeDarkTheme : customeLightTheme;
|
|
2308
2533
|
};
|
|
2309
2534
|
return {
|
|
2310
2535
|
activeTheme: getActiveTheme()
|
|
2311
2536
|
};
|
|
2312
2537
|
}
|
|
2313
2538
|
|
|
2314
|
-
|
|
2315
|
-
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;
|
|
2316
2682
|
globalStyles();
|
|
2683
|
+
globalFont(configs?.fontFamily || 'Roboto');
|
|
2317
2684
|
const {
|
|
2318
2685
|
activeTheme
|
|
2319
|
-
} = useTheme(
|
|
2686
|
+
} = useTheme({
|
|
2687
|
+
...configs.colors,
|
|
2688
|
+
borderRadius: configs?.borderRadius,
|
|
2689
|
+
fontFamily: configs?.fontFamily
|
|
2690
|
+
});
|
|
2320
2691
|
const {
|
|
2321
2692
|
blockchains
|
|
2322
2693
|
} = useMetaStore.use.meta();
|
|
2323
2694
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
2324
2695
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
2696
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
2697
|
+
const {
|
|
2698
|
+
changeLanguage
|
|
2699
|
+
} = useSelectLanguage();
|
|
2700
|
+
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
2325
2701
|
const evmBasedChainNames = blockchains.filter(rangoSdk.isEvmBlockchain).map(chain => chain.name);
|
|
2326
|
-
const onUpdateState = (type, event, value, supportedChains) => {
|
|
2702
|
+
const onUpdateState = (type, event, value, _, supportedChains) => {
|
|
2327
2703
|
if (event === walletsCore.Events.ACCOUNTS) {
|
|
2328
2704
|
if (value) {
|
|
2329
|
-
const supportedChainNames =
|
|
2330
|
-
//@ts-ignore
|
|
2331
|
-
walletAndSupportedChainsNames(supportedChains);
|
|
2705
|
+
const supportedChainNames = walletAndSupportedChainsNames(supportedChains);
|
|
2332
2706
|
const data = prepareAccountsForWalletStore(type, value, evmBasedChainNames, supportedChainNames);
|
|
2333
2707
|
connectWallet(data);
|
|
2334
2708
|
} else {
|
|
@@ -2336,6 +2710,21 @@ const SwapBox = () => {
|
|
|
2336
2710
|
}
|
|
2337
2711
|
}
|
|
2338
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]);
|
|
2339
2728
|
return React__default.createElement(walletsCore.Provider, {
|
|
2340
2729
|
allBlockChains: blockchains,
|
|
2341
2730
|
providers: providers,
|
|
@@ -2343,7 +2732,18 @@ const SwapBox = () => {
|
|
|
2343
2732
|
}, React__default.createElement("div", {
|
|
2344
2733
|
id: "pageContainer",
|
|
2345
2734
|
className: activeTheme
|
|
2346
|
-
}, 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
|
+
}))))));
|
|
2347
2747
|
};
|
|
2348
2748
|
|
|
2349
2749
|
exports.SwapBox = SwapBox;
|