@rango-dev/widget-embedded 0.1.11-next.0 → 0.1.11-next.10
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 +3 -3
- package/dist/App.d.ts.map +1 -1
- package/dist/QueueManager.d.ts.map +1 -1
- package/dist/components/AppRouter.d.ts +1 -7
- package/dist/components/AppRouter.d.ts.map +1 -1
- package/dist/components/AppRoutes.d.ts +2 -2
- package/dist/components/AppRoutes.d.ts.map +1 -1
- package/dist/components/Layout.d.ts +3 -3
- package/dist/components/Layout.d.ts.map +1 -1
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/components/TokenPreview.d.ts.map +1 -1
- package/dist/hooks/useConfirmSwap.d.ts.map +1 -1
- package/dist/hooks/useTheme.d.ts +2 -5
- package/dist/hooks/useTheme.d.ts.map +1 -1
- package/dist/lib.d.ts +2 -2
- package/dist/lib.d.ts.map +1 -1
- package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
- package/dist/pages/Home.d.ts +1 -7
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/pages/LiquiditySourcesPage.d.ts +1 -2
- package/dist/pages/LiquiditySourcesPage.d.ts.map +1 -1
- package/dist/pages/SelectChainPage.d.ts +1 -2
- package/dist/pages/SelectChainPage.d.ts.map +1 -1
- package/dist/pages/SelectTokenPage.d.ts +2 -2
- package/dist/pages/SelectTokenPage.d.ts.map +1 -1
- package/dist/pages/SettingsPage.d.ts +1 -2
- package/dist/pages/SettingsPage.d.ts.map +1 -1
- package/dist/pages/SwapDetailsPage.d.ts.map +1 -1
- package/dist/pages/WalletsPage.d.ts +1 -1
- package/dist/pages/WalletsPage.d.ts.map +1 -1
- package/dist/services/httpService.d.ts +2 -1
- package/dist/services/httpService.d.ts.map +1 -1
- package/dist/store/bestRoute.d.ts.map +1 -1
- package/dist/store/meta.d.ts.map +1 -1
- package/dist/store/settings.d.ts +2 -0
- package/dist/store/settings.d.ts.map +1 -1
- package/dist/types/config.d.ts +27 -29
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/configs.d.ts +7 -0
- package/dist/utils/configs.d.ts.map +1 -0
- package/dist/utils/swap.d.ts +2 -6
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +138 -189
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +138 -189
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +138 -189
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +6 -4
- package/readme.md +1 -1
- package/src/App.tsx +36 -14
- package/src/QueueManager.tsx +9 -3
- package/src/components/AppRouter.tsx +7 -16
- package/src/components/AppRoutes.tsx +13 -32
- package/src/components/HeaderButtons.tsx +1 -1
- package/src/components/Layout.tsx +37 -27
- package/src/components/TokenInfo.tsx +4 -8
- package/src/components/TokenPreview.tsx +3 -7
- package/src/hooks/useConfirmSwap.ts +6 -5
- package/src/hooks/useTheme.ts +21 -9
- package/src/lib.tsx +30 -36
- package/src/pages/ConfirmSwapPage.tsx +2 -0
- package/src/pages/Home.tsx +2 -8
- package/src/pages/LiquiditySourcesPage.tsx +3 -6
- package/src/pages/SelectChainPage.tsx +6 -6
- package/src/pages/SelectTokenPage.tsx +16 -18
- package/src/pages/SettingsPage.tsx +8 -18
- package/src/pages/SwapDetailsPage.tsx +2 -4
- package/src/pages/WalletsPage.tsx +2 -2
- package/src/services/httpService.ts +12 -3
- package/src/store/bestRoute.ts +4 -3
- package/src/store/meta.ts +6 -4
- package/src/store/settings.ts +7 -0
- package/src/store/wallets.ts +1 -1
- package/src/types/config.ts +28 -29
- package/src/utils/configs.ts +24 -0
- package/src/utils/swap.ts +3 -96
|
@@ -470,80 +470,6 @@ function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, has
|
|
|
470
470
|
function canComputePriceImpact(bestRoute, inputAmount, inputUsdValue, outputUsdValue) {
|
|
471
471
|
return !((inputUsdValue.lte(ZERO) || outputUsdValue.lte(ZERO)) && !!bestRoute?.result && !!inputAmount && inputAmount !== '0' && parseFloat(inputAmount || '0') !== 0 && !!bestRoute.result);
|
|
472
472
|
}
|
|
473
|
-
function calculatePendingSwap(inputAmount, bestRoute, wallets, settings, validateBalanceOrFee, meta) {
|
|
474
|
-
const simulationResult = bestRoute.result;
|
|
475
|
-
if (!simulationResult) throw Error('Simulation result should not be null');
|
|
476
|
-
return {
|
|
477
|
-
creationTime: new Date().getTime().toString(),
|
|
478
|
-
finishTime: null,
|
|
479
|
-
requestId: bestRoute.requestId || '',
|
|
480
|
-
inputAmount: inputAmount,
|
|
481
|
-
//@ts-ignore
|
|
482
|
-
wallets,
|
|
483
|
-
status: 'running',
|
|
484
|
-
isPaused: false,
|
|
485
|
-
extraMessage: null,
|
|
486
|
-
extraMessageSeverity: null,
|
|
487
|
-
extraMessageDetail: null,
|
|
488
|
-
extraMessageErrorCode: null,
|
|
489
|
-
networkStatusExtraMessage: null,
|
|
490
|
-
networkStatusExtraMessageDetail: null,
|
|
491
|
-
lastNotificationTime: null,
|
|
492
|
-
//@ts-ignore
|
|
493
|
-
settings: settings,
|
|
494
|
-
simulationResult: simulationResult,
|
|
495
|
-
validateBalanceOrFee,
|
|
496
|
-
//@ts-ignore
|
|
497
|
-
steps: bestRoute.result?.swaps?.map((swap, index) => {
|
|
498
|
-
const swapper = meta.swappers.find(swapper => swapper.id === swap.swapperId);
|
|
499
|
-
const swapperType = swapper?.types[0];
|
|
500
|
-
const fromBlockchain = meta.blockchains.find(blockchain => blockchain.name === swap.from.blockchain);
|
|
501
|
-
const toBlockchain = meta.blockchains.find(blockchain => blockchain.name === swap.to.blockchain);
|
|
502
|
-
return {
|
|
503
|
-
id: index + 1,
|
|
504
|
-
fromBlockchain: swap.from.blockchain,
|
|
505
|
-
fromSymbol: swap.from.symbol,
|
|
506
|
-
fromSymbolAddress: swap.from.address,
|
|
507
|
-
fromDecimals: swap.from.decimals,
|
|
508
|
-
fromAmountPrecision: swap.fromAmountPrecision,
|
|
509
|
-
fromAmountMinValue: swap.fromAmountMinValue,
|
|
510
|
-
fromAmountMaxValue: swap.fromAmountMaxValue,
|
|
511
|
-
toBlockchain: swap.to.blockchain,
|
|
512
|
-
fromLogo: swap.from.logo,
|
|
513
|
-
toSymbol: swap.to.symbol,
|
|
514
|
-
toSymbolAddress: swap.to.address,
|
|
515
|
-
toDecimals: swap.to.decimals,
|
|
516
|
-
toLogo: swap.to.logo,
|
|
517
|
-
startTransactionTime: new Date().getTime(),
|
|
518
|
-
swapperId: swap.swapperId,
|
|
519
|
-
feeInUsd: numberToString(getUsdFeeOfStep(swap, meta.tokens), null, 2),
|
|
520
|
-
expectedOutputAmountHumanReadable: swap.toAmount,
|
|
521
|
-
outputAmount: '',
|
|
522
|
-
status: 'created',
|
|
523
|
-
networkStatus: null,
|
|
524
|
-
executedTransactionId: null,
|
|
525
|
-
externalTransactionId: null,
|
|
526
|
-
explorerUrl: null,
|
|
527
|
-
trackingCode: null,
|
|
528
|
-
cosmosTransaction: null,
|
|
529
|
-
solanaTransaction: null,
|
|
530
|
-
starknetTransaction: null,
|
|
531
|
-
starknetApprovalTransaction: null,
|
|
532
|
-
tronTransaction: null,
|
|
533
|
-
tronApprovalTransaction: null,
|
|
534
|
-
evmTransaction: null,
|
|
535
|
-
evmApprovalTransaction: null,
|
|
536
|
-
transferTransaction: null,
|
|
537
|
-
diagnosisUrl: null,
|
|
538
|
-
internalSteps: null,
|
|
539
|
-
fromBlockchainLogo: fromBlockchain?.logo || '',
|
|
540
|
-
toBlockchainLogo: toBlockchain?.logo || '',
|
|
541
|
-
swapperLogo: swapper?.logo || '',
|
|
542
|
-
swapperType: swapperType || ''
|
|
543
|
-
};
|
|
544
|
-
}) || []
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
473
|
function requiredWallets(route) {
|
|
548
474
|
const wallets = [];
|
|
549
475
|
route?.result?.swaps.forEach(swap => {
|
|
@@ -585,7 +511,7 @@ function hasProperSlippage(userSlippage, minRequiredSlippage) {
|
|
|
585
511
|
if (!minRequiredSlippage) return true;
|
|
586
512
|
return parseFloat(userSlippage) >= parseFloat(minRequiredSlippage);
|
|
587
513
|
}
|
|
588
|
-
function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites) {
|
|
514
|
+
function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites, affiliateRef) {
|
|
589
515
|
const selectedWalletsMap = selectedWallets.reduce((selectedWalletsMap, selectedWallet) => (selectedWalletsMap[selectedWallet.chain] = selectedWallet.address, selectedWalletsMap), {});
|
|
590
516
|
const connectedWallets = [];
|
|
591
517
|
wallets.forEach(wallet => {
|
|
@@ -598,6 +524,7 @@ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, se
|
|
|
598
524
|
const filteredBlockchains = selectedWallets.map(wallet => wallet.chain);
|
|
599
525
|
const requestBody = {
|
|
600
526
|
amount: inputAmount.toString(),
|
|
527
|
+
affiliateRef,
|
|
601
528
|
checkPrerequisites,
|
|
602
529
|
from: {
|
|
603
530
|
address: fromToken.address,
|
|
@@ -784,7 +711,20 @@ const createSelectors = _store => {
|
|
|
784
711
|
return store;
|
|
785
712
|
};
|
|
786
713
|
|
|
787
|
-
const
|
|
714
|
+
const RANGO_PUBLIC_API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32';
|
|
715
|
+
let configs = {
|
|
716
|
+
API_KEY: RANGO_PUBLIC_API_KEY
|
|
717
|
+
};
|
|
718
|
+
function getConfig(name) {
|
|
719
|
+
return configs[name];
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
let rango = undefined;
|
|
723
|
+
const httpService = () => {
|
|
724
|
+
if (rango) return rango;
|
|
725
|
+
rango = new rangoSdk.RangoClient(getConfig('API_KEY'));
|
|
726
|
+
return rango;
|
|
727
|
+
};
|
|
788
728
|
|
|
789
729
|
const SLIPPAGES = [0.5, 1, 3, 5, 8, 13, 20];
|
|
790
730
|
const DEFAULT_SLIPPAGE = 1;
|
|
@@ -802,7 +742,7 @@ const useMetaStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.create()
|
|
|
802
742
|
loadingStatus: 'loading',
|
|
803
743
|
fetchMeta: async () => {
|
|
804
744
|
try {
|
|
805
|
-
const response = await httpService.getAllMetadata();
|
|
745
|
+
const response = await httpService().getAllMetadata();
|
|
806
746
|
const chainThatHasTokenInMetaResponse = removeDuplicateFrom(response.tokens.map(t => t.blockchain));
|
|
807
747
|
const enabledChains = response.blockchains.filter(chain => chain.enabled && chainThatHasTokenInMetaResponse.includes(chain.name));
|
|
808
748
|
response.blockchains = enabledChains.sort((a, b) => a.sort - b.sort);
|
|
@@ -822,6 +762,7 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.crea
|
|
|
822
762
|
slippage: DEFAULT_SLIPPAGE,
|
|
823
763
|
customSlippage: null,
|
|
824
764
|
infiniteApprove: false,
|
|
765
|
+
affiliateRef: null,
|
|
825
766
|
disabledLiquiditySources: [],
|
|
826
767
|
theme: 'auto',
|
|
827
768
|
setSlippage: slippage => set(() => ({
|
|
@@ -830,6 +771,9 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.crea
|
|
|
830
771
|
setCustomSlippage: customSlippage => set(() => ({
|
|
831
772
|
customSlippage: customSlippage
|
|
832
773
|
})),
|
|
774
|
+
setAffiliateRef: affiliateRef => set(() => ({
|
|
775
|
+
affiliateRef
|
|
776
|
+
})),
|
|
833
777
|
toggleAllLiquiditySources: () => set(state => {
|
|
834
778
|
const {
|
|
835
779
|
swappers
|
|
@@ -880,7 +824,7 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.creat
|
|
|
880
824
|
}));
|
|
881
825
|
accounts.forEach(async account => {
|
|
882
826
|
try {
|
|
883
|
-
const response = await httpService.getWalletsDetails([{
|
|
827
|
+
const response = await httpService().getWalletsDetails([{
|
|
884
828
|
address: account.address,
|
|
885
829
|
blockchain: account.chain
|
|
886
830
|
}]);
|
|
@@ -1108,20 +1052,21 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1108
1052
|
const {
|
|
1109
1053
|
slippage,
|
|
1110
1054
|
customSlippage,
|
|
1111
|
-
disabledLiquiditySources
|
|
1055
|
+
disabledLiquiditySources,
|
|
1056
|
+
affiliateRef
|
|
1112
1057
|
} = settingsStore.getState();
|
|
1113
1058
|
if (!fromToken || !toToken || !inputAmount || inputAmount === '0') return;
|
|
1114
1059
|
abortController?.abort();
|
|
1115
1060
|
abortController = new AbortController();
|
|
1116
1061
|
const userSlippage = !!customSlippage ? customSlippage : slippage;
|
|
1117
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false);
|
|
1062
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false, affiliateRef);
|
|
1118
1063
|
if (!bestRouteStore.getState().loading) bestRouteStore.setState({
|
|
1119
1064
|
loading: true,
|
|
1120
1065
|
bestRoute: null,
|
|
1121
1066
|
outputAmount: null,
|
|
1122
1067
|
outputUsdValue: new BigNumber__default(0)
|
|
1123
1068
|
});
|
|
1124
|
-
httpService.getBestRoute(requestBody, {
|
|
1069
|
+
httpService().getBestRoute(requestBody, {
|
|
1125
1070
|
signal: abortController.signal
|
|
1126
1071
|
}).then(res => {
|
|
1127
1072
|
const {
|
|
@@ -1420,10 +1365,6 @@ const Container = /*#__PURE__*/ui.styled('div', {
|
|
|
1420
1365
|
}
|
|
1421
1366
|
}
|
|
1422
1367
|
});
|
|
1423
|
-
const StyledImage = /*#__PURE__*/ui.styled('img', {
|
|
1424
|
-
width: '$24',
|
|
1425
|
-
maxHeight: '$24'
|
|
1426
|
-
});
|
|
1427
1368
|
const Options = /*#__PURE__*/ui.styled('div', {
|
|
1428
1369
|
display: 'flex',
|
|
1429
1370
|
justifyContent: 'flex-end',
|
|
@@ -1520,8 +1461,9 @@ function TokenInfo(props) {
|
|
|
1520
1461
|
variant: "outlined",
|
|
1521
1462
|
disabled: loadingStatus === 'failed',
|
|
1522
1463
|
loading: loadingStatus === 'loading',
|
|
1523
|
-
prefix: loadingStatus === 'success' && chain ? React__default.createElement(
|
|
1524
|
-
src: chain.logo
|
|
1464
|
+
prefix: loadingStatus === 'success' && chain ? React__default.createElement(ui.Image, {
|
|
1465
|
+
src: chain.logo,
|
|
1466
|
+
size: 24
|
|
1525
1467
|
}) : React__default.createElement(ImagePlaceholder, null),
|
|
1526
1468
|
suffix: ItemSuffix,
|
|
1527
1469
|
align: "start",
|
|
@@ -1536,8 +1478,9 @@ function TokenInfo(props) {
|
|
|
1536
1478
|
variant: "outlined",
|
|
1537
1479
|
disabled: loadingStatus === 'failed' || type === 'From' && !fromChain || type === 'To' && !toChain,
|
|
1538
1480
|
loading: loadingStatus === 'loading',
|
|
1539
|
-
prefix: loadingStatus === 'success' && token ? React__default.createElement(
|
|
1540
|
-
src: token.image
|
|
1481
|
+
prefix: loadingStatus === 'success' && token ? React__default.createElement(ui.Image, {
|
|
1482
|
+
src: token.image,
|
|
1483
|
+
size: 24
|
|
1541
1484
|
}) : React__default.createElement(ImagePlaceholder, null),
|
|
1542
1485
|
suffix: ItemSuffix,
|
|
1543
1486
|
size: "large",
|
|
@@ -1682,7 +1625,8 @@ function HeaderButtons(props) {
|
|
|
1682
1625
|
onClick: onClickRefresh,
|
|
1683
1626
|
disabled: !onClickRefresh
|
|
1684
1627
|
}, React__default.createElement(ui.RetryIcon, {
|
|
1685
|
-
size: 24
|
|
1628
|
+
size: 24,
|
|
1629
|
+
disabled: !onClickRefresh
|
|
1686
1630
|
}))), React__default.createElement(ui.Tooltip, {
|
|
1687
1631
|
content: "Transactions History"
|
|
1688
1632
|
}, React__default.createElement(ui.Button, {
|
|
@@ -1722,10 +1666,7 @@ const Alerts = /*#__PURE__*/ui.styled('div', {
|
|
|
1722
1666
|
width: '100%',
|
|
1723
1667
|
paddingTop: '$16'
|
|
1724
1668
|
});
|
|
1725
|
-
function Home(
|
|
1726
|
-
const {
|
|
1727
|
-
title = 'SWAP'
|
|
1728
|
-
} = props;
|
|
1669
|
+
function Home() {
|
|
1729
1670
|
const isRouterInContext = reactRouterDom.useInRouterContext();
|
|
1730
1671
|
const navigate = reactRouterDom.useNavigate();
|
|
1731
1672
|
const [count, setCount] = React.useState(0);
|
|
@@ -1766,7 +1707,7 @@ function Home(props) {
|
|
|
1766
1707
|
return setCurrentPage.bind(null, '');
|
|
1767
1708
|
}, []);
|
|
1768
1709
|
return React__default.createElement(Container$2, null, React__default.createElement(ui.Header, {
|
|
1769
|
-
title:
|
|
1710
|
+
title: "SWAP",
|
|
1770
1711
|
suffix: React__default.createElement(HeaderButtons, {
|
|
1771
1712
|
onClickRefresh: !!bestRoute ? fetchBestRoute : undefined
|
|
1772
1713
|
})
|
|
@@ -1827,8 +1768,7 @@ function Home(props) {
|
|
|
1827
1768
|
|
|
1828
1769
|
const Route = _ref => {
|
|
1829
1770
|
let {
|
|
1830
|
-
children
|
|
1831
|
-
...props
|
|
1771
|
+
children
|
|
1832
1772
|
} = _ref;
|
|
1833
1773
|
const location = reactRouter.useLocation();
|
|
1834
1774
|
const navigate = reactRouter.useNavigate();
|
|
@@ -1839,7 +1779,7 @@ const Route = _ref => {
|
|
|
1839
1779
|
});
|
|
1840
1780
|
ref.current = false;
|
|
1841
1781
|
}, []);
|
|
1842
|
-
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React__default.createElement(Home,
|
|
1782
|
+
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React__default.createElement(Home, null);
|
|
1843
1783
|
return React__default.createElement(React__default.Fragment, null, " ", children);
|
|
1844
1784
|
};
|
|
1845
1785
|
function AppRouter(_ref2) {
|
|
@@ -1933,10 +1873,6 @@ const Container$3 = /*#__PURE__*/ui.styled('div', {
|
|
|
1933
1873
|
}
|
|
1934
1874
|
}
|
|
1935
1875
|
});
|
|
1936
|
-
const StyledImage$1 = /*#__PURE__*/ui.styled('img', {
|
|
1937
|
-
width: '$24',
|
|
1938
|
-
maxHeight: '$24'
|
|
1939
|
-
});
|
|
1940
1876
|
const ImagePlaceholder$1 = /*#__PURE__*/ui.styled('span', {
|
|
1941
1877
|
width: '24px',
|
|
1942
1878
|
height: '24px',
|
|
@@ -1992,8 +1928,9 @@ function TokenPreview(props) {
|
|
|
1992
1928
|
className: "selectors",
|
|
1993
1929
|
variant: "outlined",
|
|
1994
1930
|
loading: loadingStatus === 'loading',
|
|
1995
|
-
prefix: loadingStatus === 'success' && chain ? React__default.createElement(
|
|
1996
|
-
src: chain.logo
|
|
1931
|
+
prefix: loadingStatus === 'success' && chain ? React__default.createElement(ui.Image, {
|
|
1932
|
+
src: chain.logo,
|
|
1933
|
+
size: 24
|
|
1997
1934
|
}) : React__default.createElement(ImagePlaceholder$1, null),
|
|
1998
1935
|
suffix: ItemSuffix,
|
|
1999
1936
|
align: "start",
|
|
@@ -2004,8 +1941,9 @@ function TokenPreview(props) {
|
|
|
2004
1941
|
className: "selectors",
|
|
2005
1942
|
variant: "outlined",
|
|
2006
1943
|
loading: loadingStatus === 'loading',
|
|
2007
|
-
prefix: loadingStatus === 'success' && token ? React__default.createElement(
|
|
2008
|
-
src: token.image
|
|
1944
|
+
prefix: loadingStatus === 'success' && token ? React__default.createElement(ui.Image, {
|
|
1945
|
+
src: token.image,
|
|
1946
|
+
size: 24
|
|
2009
1947
|
}) : React__default.createElement(ImagePlaceholder$1, null),
|
|
2010
1948
|
suffix: ItemSuffix,
|
|
2011
1949
|
size: "large",
|
|
@@ -2083,6 +2021,7 @@ function useConfirmSwap() {
|
|
|
2083
2021
|
const initialRoute = useBestRouteStore.use.bestRoute();
|
|
2084
2022
|
const setBestRoute = useBestRouteStore.use.setBestRoute();
|
|
2085
2023
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
2024
|
+
const affiliateRef = useSettingsStore.use.affiliateRef();
|
|
2086
2025
|
const accounts = useWalletsStore.use.accounts();
|
|
2087
2026
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
2088
2027
|
const meta = useMetaStore.use.meta();
|
|
@@ -2115,17 +2054,16 @@ function useConfirmSwap() {
|
|
|
2115
2054
|
if (warnings.length > 0) setWarnings([]);
|
|
2116
2055
|
proceedAnywayRef.current = false;
|
|
2117
2056
|
if (confiremedRouteRef.current) {
|
|
2118
|
-
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2119
|
-
//@ts-ignore
|
|
2057
|
+
const newSwap = queueManagerRangoPreset.calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2120
2058
|
return newSwap;
|
|
2121
2059
|
}
|
|
2122
2060
|
return;
|
|
2123
2061
|
}
|
|
2124
2062
|
abortControllerRef.current = new AbortController();
|
|
2125
2063
|
setLoading(true);
|
|
2126
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true);
|
|
2064
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true, affiliateRef);
|
|
2127
2065
|
try {
|
|
2128
|
-
const confiremedRoute = await httpService.getBestRoute(requestBody, {
|
|
2066
|
+
const confiremedRoute = await httpService().getBestRoute(requestBody, {
|
|
2129
2067
|
signal: abortControllerRef.current?.signal
|
|
2130
2068
|
});
|
|
2131
2069
|
abortControllerRef.current = null;
|
|
@@ -2178,8 +2116,7 @@ function useConfirmSwap() {
|
|
|
2178
2116
|
slippage: userSlippage.toString(),
|
|
2179
2117
|
disabledSwappersGroups: disabledLiquiditySources
|
|
2180
2118
|
};
|
|
2181
|
-
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2182
|
-
//@ts-ignore
|
|
2119
|
+
const newSwap = queueManagerRangoPreset.calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2183
2120
|
return newSwap;
|
|
2184
2121
|
} else if (!proceedAnywayRef.current) {
|
|
2185
2122
|
proceedAnywayRef.current = true;
|
|
@@ -2397,7 +2334,10 @@ function ConfirmSwapPage() {
|
|
|
2397
2334
|
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
2398
2335
|
};
|
|
2399
2336
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
2400
|
-
return React__default.createElement(ui.ConfirmSwap
|
|
2337
|
+
return React__default.createElement(ui.ConfirmSwap
|
|
2338
|
+
// @ts-ignore
|
|
2339
|
+
, {
|
|
2340
|
+
// @ts-ignore
|
|
2401
2341
|
requiredWallets: getRequiredChains(bestRoute),
|
|
2402
2342
|
selectableWallets: selectableWallets,
|
|
2403
2343
|
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
@@ -2406,7 +2346,9 @@ function ConfirmSwapPage() {
|
|
|
2406
2346
|
if (swap) {
|
|
2407
2347
|
manager?.create('swap', {
|
|
2408
2348
|
swapDetails: swap
|
|
2409
|
-
},
|
|
2349
|
+
},
|
|
2350
|
+
// @ts-ignore
|
|
2351
|
+
{
|
|
2410
2352
|
id: swap.requestId
|
|
2411
2353
|
});
|
|
2412
2354
|
setSelectedSwap(swap.requestId);
|
|
@@ -2564,7 +2506,7 @@ function LiquiditySourcePage(_ref) {
|
|
|
2564
2506
|
});
|
|
2565
2507
|
return React__default.createElement(ui.LiquiditySourcesSelector, {
|
|
2566
2508
|
toggleAll: toggleAllLiquiditySources,
|
|
2567
|
-
list: supportedSwappers
|
|
2509
|
+
list: supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups,
|
|
2568
2510
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
2569
2511
|
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources),
|
|
2570
2512
|
loadingStatus: loadingMetaStatus
|
|
@@ -2576,7 +2518,7 @@ function SelectChainPage(props) {
|
|
|
2576
2518
|
type,
|
|
2577
2519
|
supportedChains
|
|
2578
2520
|
} = props;
|
|
2579
|
-
const blockchains = supportedChains
|
|
2521
|
+
const blockchains = supportedChains ? useMetaStore.use.meta().blockchains.filter(chain => supportedChains.includes(chain.name)) : useMetaStore.use.meta().blockchains;
|
|
2580
2522
|
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
2581
2523
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
2582
2524
|
const toChain = useBestRouteStore.use.toChain();
|
|
@@ -2608,8 +2550,8 @@ function SelectTokenPage(props) {
|
|
|
2608
2550
|
} = props;
|
|
2609
2551
|
const sourceTokens = useBestRouteStore.use.sourceTokens();
|
|
2610
2552
|
const destinationTokens = useBestRouteStore.use.destinationTokens();
|
|
2611
|
-
const supportedSourceTokens = supportedTokens
|
|
2612
|
-
const supportedDestinationTokens = supportedTokens
|
|
2553
|
+
const supportedSourceTokens = supportedTokens ? sourceTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : sourceTokens;
|
|
2554
|
+
const supportedDestinationTokens = supportedTokens ? destinationTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : destinationTokens;
|
|
2613
2555
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
2614
2556
|
const toToken = useBestRouteStore.use.toToken();
|
|
2615
2557
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
@@ -2662,8 +2604,8 @@ function SettingsPage(_ref) {
|
|
|
2662
2604
|
}
|
|
2663
2605
|
}
|
|
2664
2606
|
});
|
|
2665
|
-
supportedSwappers
|
|
2666
|
-
const supportedUniqueSwappersGroups = supportedSwappers
|
|
2607
|
+
supportedSwappers && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0);
|
|
2608
|
+
const supportedUniqueSwappersGroups = supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups;
|
|
2667
2609
|
return React__default.createElement(ui.Settings, {
|
|
2668
2610
|
slippages: SLIPPAGES,
|
|
2669
2611
|
selectedSlippage: slippage,
|
|
@@ -2716,7 +2658,7 @@ function WalletsPage(_ref) {
|
|
|
2716
2658
|
getWalletInfo,
|
|
2717
2659
|
connect
|
|
2718
2660
|
} = walletsCore.useWallets();
|
|
2719
|
-
const wallets = getlistWallet(state, getWalletInfo, supportedWallets
|
|
2661
|
+
const wallets = getlistWallet(state, getWalletInfo, supportedWallets || Object.values(walletsShared.WalletType));
|
|
2720
2662
|
const walletsRef = React.useRef();
|
|
2721
2663
|
let sortedWallets = walletsShared.detectMobileScreens() ? wallets.filter(wallet => wallet.showOnMobile) : wallets;
|
|
2722
2664
|
sortedWallets = sortWalletsBasedOnState(sortedWallets);
|
|
@@ -2925,7 +2867,7 @@ function SwapDetailsPage() {
|
|
|
2925
2867
|
}), React__default.createElement(TokenPreview, {
|
|
2926
2868
|
chain: {
|
|
2927
2869
|
displayName: lastStep?.toBlockchain || '',
|
|
2928
|
-
|
|
2870
|
+
//@ts-ignore
|
|
2929
2871
|
logo: lastStep?.toBlockchainLogo || ''
|
|
2930
2872
|
},
|
|
2931
2873
|
token: {
|
|
@@ -2937,7 +2879,6 @@ function SwapDetailsPage() {
|
|
|
2937
2879
|
loadingStatus: 'success'
|
|
2938
2880
|
})),
|
|
2939
2881
|
//todo: move PendingSwap type to rango-types
|
|
2940
|
-
//@ts-ignore
|
|
2941
2882
|
pendingSwap: swap,
|
|
2942
2883
|
onCopy: handleCopy,
|
|
2943
2884
|
isCopied: isCopied,
|
|
@@ -2967,48 +2908,44 @@ function SwapDetailsPage() {
|
|
|
2967
2908
|
const getAbsolutePath = path => path.replace('/', '');
|
|
2968
2909
|
function AppRoutes(props) {
|
|
2969
2910
|
const {
|
|
2970
|
-
|
|
2911
|
+
config
|
|
2971
2912
|
} = props;
|
|
2972
2913
|
return reactRouterDom.useRoutes([{
|
|
2973
2914
|
path: getAbsolutePath(navigationRoutes.home),
|
|
2974
|
-
element: React__default.createElement(Home,
|
|
2975
|
-
title: configs?.title,
|
|
2976
|
-
titleSize: configs?.titleSize,
|
|
2977
|
-
titleWeight: configs?.titleWeight
|
|
2978
|
-
})
|
|
2915
|
+
element: React__default.createElement(Home, null)
|
|
2979
2916
|
}, {
|
|
2980
2917
|
path: getAbsolutePath(navigationRoutes.fromChain),
|
|
2981
2918
|
element: React__default.createElement(SelectChainPage, {
|
|
2982
2919
|
type: "from",
|
|
2983
|
-
supportedChains:
|
|
2920
|
+
supportedChains: config?.from?.blockchains
|
|
2984
2921
|
})
|
|
2985
2922
|
}, {
|
|
2986
2923
|
path: getAbsolutePath(navigationRoutes.toChain),
|
|
2987
2924
|
element: React__default.createElement(SelectChainPage, {
|
|
2988
2925
|
type: "to",
|
|
2989
|
-
supportedChains:
|
|
2926
|
+
supportedChains: config?.to?.blockchains
|
|
2990
2927
|
})
|
|
2991
2928
|
}, {
|
|
2992
2929
|
path: getAbsolutePath(navigationRoutes.fromToken),
|
|
2993
2930
|
element: React__default.createElement(SelectTokenPage, {
|
|
2994
2931
|
type: "from",
|
|
2995
|
-
supportedTokens:
|
|
2932
|
+
supportedTokens: config?.from?.tokens
|
|
2996
2933
|
})
|
|
2997
2934
|
}, {
|
|
2998
2935
|
path: getAbsolutePath(navigationRoutes.toToken),
|
|
2999
2936
|
element: React__default.createElement(SelectTokenPage, {
|
|
3000
2937
|
type: "to",
|
|
3001
|
-
supportedTokens:
|
|
2938
|
+
supportedTokens: config?.to?.tokens
|
|
3002
2939
|
})
|
|
3003
2940
|
}, {
|
|
3004
2941
|
path: getAbsolutePath(navigationRoutes.settings),
|
|
3005
2942
|
element: React__default.createElement(SettingsPage, {
|
|
3006
|
-
supportedSwappers:
|
|
2943
|
+
supportedSwappers: config?.liquiditySources
|
|
3007
2944
|
})
|
|
3008
2945
|
}, {
|
|
3009
2946
|
path: getAbsolutePath(navigationRoutes.liquiditySources),
|
|
3010
2947
|
element: React__default.createElement(LiquiditySourcePage, {
|
|
3011
|
-
supportedSwappers:
|
|
2948
|
+
supportedSwappers: config?.liquiditySources
|
|
3012
2949
|
})
|
|
3013
2950
|
}, {
|
|
3014
2951
|
path: getAbsolutePath(navigationRoutes.swaps),
|
|
@@ -3019,8 +2956,8 @@ function AppRoutes(props) {
|
|
|
3019
2956
|
}, {
|
|
3020
2957
|
path: getAbsolutePath(navigationRoutes.wallets),
|
|
3021
2958
|
element: React__default.createElement(WalletsPage, {
|
|
3022
|
-
supportedWallets:
|
|
3023
|
-
multiWallets: typeof
|
|
2959
|
+
supportedWallets: config?.wallets,
|
|
2960
|
+
multiWallets: typeof config?.multiWallets === 'undefined' ? true : config.multiWallets
|
|
3024
2961
|
})
|
|
3025
2962
|
}, {
|
|
3026
2963
|
path: getAbsolutePath(navigationRoutes.confirmSwap),
|
|
@@ -3036,16 +2973,14 @@ const Header = /*#__PURE__*/ui.styled('div', {
|
|
|
3036
2973
|
display: 'flex'
|
|
3037
2974
|
}
|
|
3038
2975
|
});
|
|
3039
|
-
const
|
|
3040
|
-
width: '$24',
|
|
3041
|
-
height: '$24',
|
|
2976
|
+
const WalletImageContainer = /*#__PURE__*/ui.styled('div', {
|
|
3042
2977
|
marginLeft: -15,
|
|
3043
2978
|
marginRight: '$6',
|
|
3044
2979
|
borderRadius: '99999px'
|
|
3045
2980
|
});
|
|
3046
2981
|
function Layout(_ref) {
|
|
3047
2982
|
let {
|
|
3048
|
-
|
|
2983
|
+
config
|
|
3049
2984
|
} = _ref;
|
|
3050
2985
|
const navigate = reactRouterDom.useNavigate();
|
|
3051
2986
|
const {
|
|
@@ -3057,11 +2992,16 @@ function Layout(_ref) {
|
|
|
3057
2992
|
getWalletInfo
|
|
3058
2993
|
} = walletsCore.useWallets();
|
|
3059
2994
|
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(accounts, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2995
|
+
const {
|
|
2996
|
+
blockchains,
|
|
2997
|
+
tokens
|
|
2998
|
+
} = useMetaStore.use.meta();
|
|
3060
2999
|
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
3061
3000
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
3062
3001
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
3063
3002
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
3064
3003
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
3004
|
+
const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
|
|
3065
3005
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
3066
3006
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
3067
3007
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
@@ -3070,22 +3010,23 @@ function Layout(_ref) {
|
|
|
3070
3010
|
t
|
|
3071
3011
|
} = reactI18next.useTranslation();
|
|
3072
3012
|
React.useEffect(() => {
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3013
|
+
const chain = blockchains.find(chain => chain.name === config?.to?.blockchain);
|
|
3014
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.to?.token || null));
|
|
3015
|
+
setToChain(chain || null);
|
|
3016
|
+
setToToken(token || null);
|
|
3017
|
+
}, [config?.to?.token, config?.to?.blockchain]);
|
|
3076
3018
|
React.useEffect(() => {
|
|
3077
|
-
setInputAmount(
|
|
3078
|
-
}, [
|
|
3019
|
+
setInputAmount(config?.amount?.toString() || '');
|
|
3020
|
+
}, [config?.amount]);
|
|
3079
3021
|
React.useEffect(() => {
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3022
|
+
const chain = blockchains.find(chain => chain.name === config?.from?.blockchain);
|
|
3023
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.from?.token || null));
|
|
3024
|
+
setFromChain(chain || null);
|
|
3025
|
+
setFromToken(token || null);
|
|
3026
|
+
}, [config?.from?.token, config?.from?.blockchain]);
|
|
3083
3027
|
React.useEffect(() => {
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
setFromToken(null);
|
|
3087
|
-
setToToken(null);
|
|
3088
|
-
}, [configs?.fromChains, configs?.toChains, configs?.fromTokens, configs?.toTokens]);
|
|
3028
|
+
setAffiliateRef(config?.affiliateRef || null);
|
|
3029
|
+
}, [config?.affiliateRef]);
|
|
3089
3030
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(Header, null, React__default.createElement(ui.Button, {
|
|
3090
3031
|
size: "small",
|
|
3091
3032
|
suffix: React__default.createElement(ui.AddWalletIcon, {
|
|
@@ -3098,15 +3039,17 @@ function Layout(_ref) {
|
|
|
3098
3039
|
onClick: () => {
|
|
3099
3040
|
if (!connectWalletsButtonDisabled) navigate(navigationRoutes.wallets);
|
|
3100
3041
|
}
|
|
3101
|
-
}, connectedWalletsImages?.length ? connectedWalletsImages.map((walletImage, index) => React__default.createElement(
|
|
3102
|
-
key: index
|
|
3103
|
-
|
|
3104
|
-
|
|
3042
|
+
}, connectedWalletsImages?.length ? connectedWalletsImages.map((walletImage, index) => React__default.createElement(WalletImageContainer, {
|
|
3043
|
+
key: index
|
|
3044
|
+
}, React__default.createElement(ui.Image, {
|
|
3045
|
+
src: walletImage,
|
|
3046
|
+
size: 24
|
|
3047
|
+
}))) : React__default.createElement(React__default.Fragment, null), React__default.createElement("div", {
|
|
3105
3048
|
className: "balance"
|
|
3106
3049
|
}, React__default.createElement(ui.Typography, {
|
|
3107
3050
|
variant: "body2"
|
|
3108
3051
|
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React__default.createElement(ui.Spinner, null)))), React__default.createElement(AppRoutes, {
|
|
3109
|
-
|
|
3052
|
+
config: config
|
|
3110
3053
|
}));
|
|
3111
3054
|
}
|
|
3112
3055
|
|
|
@@ -3149,17 +3092,20 @@ function usePrevious(value) {
|
|
|
3149
3092
|
|
|
3150
3093
|
function useTheme(_ref) {
|
|
3151
3094
|
let {
|
|
3152
|
-
|
|
3153
|
-
background = '#fff',
|
|
3154
|
-
foreground = '#000',
|
|
3155
|
-
error = '#FF0000',
|
|
3156
|
-
warning = '#F5A623',
|
|
3157
|
-
success = '#0070F3',
|
|
3095
|
+
colors: themeColors,
|
|
3158
3096
|
fontFamily = 'Robot',
|
|
3159
|
-
borderRadius = 8
|
|
3097
|
+
borderRadius = 8,
|
|
3098
|
+
mode = 'auto'
|
|
3160
3099
|
} = _ref;
|
|
3161
3100
|
const theme = useSettingsStore.use.theme();
|
|
3162
3101
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
3102
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
3103
|
+
const primary = themeColors?.primary || '#5FA425',
|
|
3104
|
+
background = themeColors?.background || '#fff',
|
|
3105
|
+
foreground = themeColors?.foreground || '#000',
|
|
3106
|
+
error = themeColors?.error || '#FF0000',
|
|
3107
|
+
warning = themeColors?.warning || '#F5A623',
|
|
3108
|
+
success = themeColors?.success || '#0070F3';
|
|
3163
3109
|
const colors = {
|
|
3164
3110
|
neutrals200: '#FAFAFA',
|
|
3165
3111
|
neutrals300: '#f2f2f2',
|
|
@@ -3201,6 +3147,9 @@ function useTheme(_ref) {
|
|
|
3201
3147
|
colors,
|
|
3202
3148
|
radii: {
|
|
3203
3149
|
5: `${borderRadius}px`
|
|
3150
|
+
},
|
|
3151
|
+
shadows: {
|
|
3152
|
+
s: '0px 3px 5px 3px #f0f2f5, 0px 6px 10px 3px #f0f2f5, 0px 1px 18px 3px #f0f2f5'
|
|
3204
3153
|
}
|
|
3205
3154
|
});
|
|
3206
3155
|
const customeDarkTheme = ui.createTheme({
|
|
@@ -3219,6 +3168,9 @@ function useTheme(_ref) {
|
|
|
3219
3168
|
},
|
|
3220
3169
|
radii: {
|
|
3221
3170
|
5: `${borderRadius}px`
|
|
3171
|
+
},
|
|
3172
|
+
shadows: {
|
|
3173
|
+
s: '0px 3px 5px 3px #222, 0px 6px 10px 3px #222, 0px 1px 18px 3px #222'
|
|
3222
3174
|
}
|
|
3223
3175
|
});
|
|
3224
3176
|
const [OSTheme, setOSTheme] = React.useState(customeLightTheme);
|
|
@@ -3237,6 +3189,9 @@ function useTheme(_ref) {
|
|
|
3237
3189
|
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', switchTheme);
|
|
3238
3190
|
};
|
|
3239
3191
|
}, []);
|
|
3192
|
+
React.useEffect(() => {
|
|
3193
|
+
if (mode !== 'auto') setTheme(mode);
|
|
3194
|
+
}, [mode]);
|
|
3240
3195
|
const prevFont = usePrevious(fontFamily);
|
|
3241
3196
|
React.useLayoutEffect(() => {
|
|
3242
3197
|
const {
|
|
@@ -3341,6 +3296,11 @@ function QueueManager(props) {
|
|
|
3341
3296
|
canSwitchNetworkTo,
|
|
3342
3297
|
getWalletInfo
|
|
3343
3298
|
} = walletsCore.useWallets();
|
|
3299
|
+
const swapQueueDef = React.useMemo(() => {
|
|
3300
|
+
return queueManagerRangoPreset.makeQueueDefinition({
|
|
3301
|
+
API_KEY: getConfig('API_KEY')
|
|
3302
|
+
});
|
|
3303
|
+
}, []);
|
|
3344
3304
|
const {
|
|
3345
3305
|
blockchains
|
|
3346
3306
|
} = useMetaStore.use.meta();
|
|
@@ -3390,7 +3350,7 @@ function QueueManager(props) {
|
|
|
3390
3350
|
//@ts-ignore
|
|
3391
3351
|
, {
|
|
3392
3352
|
//@ts-ignore
|
|
3393
|
-
queuesDefs: [
|
|
3353
|
+
queuesDefs: [swapQueueDef],
|
|
3394
3354
|
context: context,
|
|
3395
3355
|
onPersistedDataLoaded: manager => {
|
|
3396
3356
|
queueManagerRangoPreset.checkWaitingForNetworkChange(manager);
|
|
@@ -3401,29 +3361,27 @@ function QueueManager(props) {
|
|
|
3401
3361
|
|
|
3402
3362
|
const SwapBox = _ref => {
|
|
3403
3363
|
let {
|
|
3404
|
-
|
|
3364
|
+
config
|
|
3405
3365
|
} = _ref;
|
|
3406
3366
|
globalStyles();
|
|
3407
|
-
globalFont(
|
|
3367
|
+
globalFont(config?.theme?.fontFamily || 'Roboto');
|
|
3408
3368
|
const {
|
|
3409
3369
|
activeTheme
|
|
3410
3370
|
} = useTheme({
|
|
3411
|
-
...
|
|
3412
|
-
borderRadius: configs?.borderRadius,
|
|
3413
|
-
fontFamily: configs?.fontFamily
|
|
3371
|
+
...config?.theme
|
|
3414
3372
|
});
|
|
3415
3373
|
const {
|
|
3416
3374
|
blockchains
|
|
3417
3375
|
} = useMetaStore.use.meta();
|
|
3418
3376
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
3419
3377
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
3420
|
-
const setTheme = useSettingsStore.use.setTheme();
|
|
3421
3378
|
const {
|
|
3422
3379
|
changeLanguage
|
|
3423
3380
|
} = useSelectLanguage();
|
|
3424
3381
|
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
3425
3382
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] = React.useState('');
|
|
3426
3383
|
const [disconnectedWallet, setDisconnectedWallet] = React.useState();
|
|
3384
|
+
const currentPage = useUiStore.use.currentPage();
|
|
3427
3385
|
const evmBasedChainNames = blockchains.filter(rangoSdk.isEvmBlockchain).map(chain => chain.name);
|
|
3428
3386
|
const onUpdateState = (type, event, value, state, supportedChains) => {
|
|
3429
3387
|
if (event === walletsCore.Events.ACCOUNTS) {
|
|
@@ -3448,19 +3406,16 @@ const SwapBox = _ref => {
|
|
|
3448
3406
|
};
|
|
3449
3407
|
let providers = providerAll.allProviders();
|
|
3450
3408
|
React.useEffect(() => {
|
|
3451
|
-
|
|
3452
|
-
}, [configs.theme]);
|
|
3453
|
-
React.useEffect(() => {
|
|
3454
|
-
const wallets = configs.wallets;
|
|
3409
|
+
const wallets = config?.wallets;
|
|
3455
3410
|
clearConnectedWallet();
|
|
3456
|
-
providers = wallets
|
|
3411
|
+
providers = !wallets ? providerAll.allProviders() : providerAll.allProviders().filter(provider => {
|
|
3457
3412
|
const type = provider.config.type;
|
|
3458
3413
|
return wallets.find(w => w === type);
|
|
3459
3414
|
});
|
|
3460
|
-
}, [
|
|
3415
|
+
}, [config?.wallets]);
|
|
3461
3416
|
React.useEffect(() => {
|
|
3462
|
-
changeLanguage(
|
|
3463
|
-
}, [
|
|
3417
|
+
changeLanguage(config?.language || 'en');
|
|
3418
|
+
}, [config?.language]);
|
|
3464
3419
|
return React__default.createElement(walletsCore.Provider, {
|
|
3465
3420
|
allBlockChains: blockchains,
|
|
3466
3421
|
providers: providers,
|
|
@@ -3469,21 +3424,15 @@ const SwapBox = _ref => {
|
|
|
3469
3424
|
id: "pageContainer",
|
|
3470
3425
|
className: activeTheme
|
|
3471
3426
|
}, React__default.createElement(QueueManager, null, React__default.createElement(ui.SwapContainer, {
|
|
3472
|
-
|
|
3473
|
-
width: configs?.width || 'auto',
|
|
3474
|
-
height: configs?.height || 'auto'
|
|
3475
|
-
}
|
|
3427
|
+
fixedHeight: currentPage !== navigationRoutes.home
|
|
3476
3428
|
}, React__default.createElement(AppRouter, {
|
|
3477
|
-
title: configs.title,
|
|
3478
|
-
titleSize: configs.titleSize,
|
|
3479
|
-
titleWeight: configs.titleWeight,
|
|
3480
3429
|
lastConnectedWallet: lastConnectedWalletWithNetwork,
|
|
3481
3430
|
disconnectedWallet: disconnectedWallet,
|
|
3482
3431
|
clearDisconnectedWallet: () => {
|
|
3483
3432
|
setDisconnectedWallet(undefined);
|
|
3484
3433
|
}
|
|
3485
3434
|
}, React__default.createElement(Layout, {
|
|
3486
|
-
|
|
3435
|
+
config: config
|
|
3487
3436
|
}))))));
|
|
3488
3437
|
};
|
|
3489
3438
|
|