@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
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { WalletState, Typography, InfoCircleIcon, AngleDownIcon, Spacer, Button, TextField, styled, Tooltip, RetryIcon, HistoryIcon, SettingsIcon, Header as Header$1, VerticalSwapIcon, BestRoute, Alert, ChevronRightIcon, GasIcon, ConfirmSwap, History, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Spinner, LoadingFailedAlert, Wallet, SwapHistory, AddWalletIcon, globalCss, createTheme, SwapContainer } from '@rango-dev/ui';
|
|
2
|
-
import React, { useRef, useEffect, useState, useLayoutEffect } from 'react';
|
|
1
|
+
import { WalletState, Typography, InfoCircleIcon, AngleDownIcon, Spacer, Button, Image, TextField, styled, Tooltip, RetryIcon, HistoryIcon, SettingsIcon, Header as Header$1, VerticalSwapIcon, BestRoute, Alert, ChevronRightIcon, GasIcon, ConfirmSwap, History, LiquiditySourcesSelector, BlockchainSelector, TokenSelector, Settings, SecondaryPage, Spinner, LoadingFailedAlert, Wallet, SwapHistory, AddWalletIcon, globalCss, createTheme, SwapContainer } from '@rango-dev/ui';
|
|
2
|
+
import React, { useRef, useEffect, useState, useLayoutEffect, useMemo } from 'react';
|
|
3
3
|
import { useInRouterContext as useInRouterContext$1, MemoryRouter, useLocation as useLocation$1, useNavigate as useNavigate$1 } from 'react-router';
|
|
4
|
-
import { PendingSwapNetworkStatus, useQueueManager, getCurrentStep, getCurrentBlockchainOfOrNull, getRelatedWalletOrNull, cancelSwap,
|
|
4
|
+
import { PendingSwapNetworkStatus, useQueueManager, calculatePendingSwap, getCurrentStep, getCurrentBlockchainOfOrNull, getRelatedWalletOrNull, cancelSwap, makeQueueDefinition, checkWaitingForNetworkChange } from '@rango-dev/queue-manager-rango-preset';
|
|
5
5
|
import { isCosmosBlockchain, isEvmBlockchain } from 'rango-types';
|
|
6
6
|
import { useSearchParams, useLocation, createSearchParams, useNavigate, useInRouterContext, useRoutes } from 'react-router-dom';
|
|
7
7
|
import { create } from 'zustand';
|
|
@@ -461,80 +461,6 @@ function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, has
|
|
|
461
461
|
function canComputePriceImpact(bestRoute, inputAmount, inputUsdValue, outputUsdValue) {
|
|
462
462
|
return !((inputUsdValue.lte(ZERO) || outputUsdValue.lte(ZERO)) && !!bestRoute?.result && !!inputAmount && inputAmount !== '0' && parseFloat(inputAmount || '0') !== 0 && !!bestRoute.result);
|
|
463
463
|
}
|
|
464
|
-
function calculatePendingSwap(inputAmount, bestRoute, wallets, settings, validateBalanceOrFee, meta) {
|
|
465
|
-
const simulationResult = bestRoute.result;
|
|
466
|
-
if (!simulationResult) throw Error('Simulation result should not be null');
|
|
467
|
-
return {
|
|
468
|
-
creationTime: new Date().getTime().toString(),
|
|
469
|
-
finishTime: null,
|
|
470
|
-
requestId: bestRoute.requestId || '',
|
|
471
|
-
inputAmount: inputAmount,
|
|
472
|
-
//@ts-ignore
|
|
473
|
-
wallets,
|
|
474
|
-
status: 'running',
|
|
475
|
-
isPaused: false,
|
|
476
|
-
extraMessage: null,
|
|
477
|
-
extraMessageSeverity: null,
|
|
478
|
-
extraMessageDetail: null,
|
|
479
|
-
extraMessageErrorCode: null,
|
|
480
|
-
networkStatusExtraMessage: null,
|
|
481
|
-
networkStatusExtraMessageDetail: null,
|
|
482
|
-
lastNotificationTime: null,
|
|
483
|
-
//@ts-ignore
|
|
484
|
-
settings: settings,
|
|
485
|
-
simulationResult: simulationResult,
|
|
486
|
-
validateBalanceOrFee,
|
|
487
|
-
//@ts-ignore
|
|
488
|
-
steps: bestRoute.result?.swaps?.map((swap, index) => {
|
|
489
|
-
const swapper = meta.swappers.find(swapper => swapper.id === swap.swapperId);
|
|
490
|
-
const swapperType = swapper?.types[0];
|
|
491
|
-
const fromBlockchain = meta.blockchains.find(blockchain => blockchain.name === swap.from.blockchain);
|
|
492
|
-
const toBlockchain = meta.blockchains.find(blockchain => blockchain.name === swap.to.blockchain);
|
|
493
|
-
return {
|
|
494
|
-
id: index + 1,
|
|
495
|
-
fromBlockchain: swap.from.blockchain,
|
|
496
|
-
fromSymbol: swap.from.symbol,
|
|
497
|
-
fromSymbolAddress: swap.from.address,
|
|
498
|
-
fromDecimals: swap.from.decimals,
|
|
499
|
-
fromAmountPrecision: swap.fromAmountPrecision,
|
|
500
|
-
fromAmountMinValue: swap.fromAmountMinValue,
|
|
501
|
-
fromAmountMaxValue: swap.fromAmountMaxValue,
|
|
502
|
-
toBlockchain: swap.to.blockchain,
|
|
503
|
-
fromLogo: swap.from.logo,
|
|
504
|
-
toSymbol: swap.to.symbol,
|
|
505
|
-
toSymbolAddress: swap.to.address,
|
|
506
|
-
toDecimals: swap.to.decimals,
|
|
507
|
-
toLogo: swap.to.logo,
|
|
508
|
-
startTransactionTime: new Date().getTime(),
|
|
509
|
-
swapperId: swap.swapperId,
|
|
510
|
-
feeInUsd: numberToString(getUsdFeeOfStep(swap, meta.tokens), null, 2),
|
|
511
|
-
expectedOutputAmountHumanReadable: swap.toAmount,
|
|
512
|
-
outputAmount: '',
|
|
513
|
-
status: 'created',
|
|
514
|
-
networkStatus: null,
|
|
515
|
-
executedTransactionId: null,
|
|
516
|
-
externalTransactionId: null,
|
|
517
|
-
explorerUrl: null,
|
|
518
|
-
trackingCode: null,
|
|
519
|
-
cosmosTransaction: null,
|
|
520
|
-
solanaTransaction: null,
|
|
521
|
-
starknetTransaction: null,
|
|
522
|
-
starknetApprovalTransaction: null,
|
|
523
|
-
tronTransaction: null,
|
|
524
|
-
tronApprovalTransaction: null,
|
|
525
|
-
evmTransaction: null,
|
|
526
|
-
evmApprovalTransaction: null,
|
|
527
|
-
transferTransaction: null,
|
|
528
|
-
diagnosisUrl: null,
|
|
529
|
-
internalSteps: null,
|
|
530
|
-
fromBlockchainLogo: fromBlockchain?.logo || '',
|
|
531
|
-
toBlockchainLogo: toBlockchain?.logo || '',
|
|
532
|
-
swapperLogo: swapper?.logo || '',
|
|
533
|
-
swapperType: swapperType || ''
|
|
534
|
-
};
|
|
535
|
-
}) || []
|
|
536
|
-
};
|
|
537
|
-
}
|
|
538
464
|
function requiredWallets(route) {
|
|
539
465
|
const wallets = [];
|
|
540
466
|
route?.result?.swaps.forEach(swap => {
|
|
@@ -576,7 +502,7 @@ function hasProperSlippage(userSlippage, minRequiredSlippage) {
|
|
|
576
502
|
if (!minRequiredSlippage) return true;
|
|
577
503
|
return parseFloat(userSlippage) >= parseFloat(minRequiredSlippage);
|
|
578
504
|
}
|
|
579
|
-
function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites) {
|
|
505
|
+
function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites, affiliateRef) {
|
|
580
506
|
const selectedWalletsMap = selectedWallets.reduce((selectedWalletsMap, selectedWallet) => (selectedWalletsMap[selectedWallet.chain] = selectedWallet.address, selectedWalletsMap), {});
|
|
581
507
|
const connectedWallets = [];
|
|
582
508
|
wallets.forEach(wallet => {
|
|
@@ -589,6 +515,7 @@ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, se
|
|
|
589
515
|
const filteredBlockchains = selectedWallets.map(wallet => wallet.chain);
|
|
590
516
|
const requestBody = {
|
|
591
517
|
amount: inputAmount.toString(),
|
|
518
|
+
affiliateRef,
|
|
592
519
|
checkPrerequisites,
|
|
593
520
|
from: {
|
|
594
521
|
address: fromToken.address,
|
|
@@ -775,7 +702,20 @@ const createSelectors = _store => {
|
|
|
775
702
|
return store;
|
|
776
703
|
};
|
|
777
704
|
|
|
778
|
-
const
|
|
705
|
+
const RANGO_PUBLIC_API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32';
|
|
706
|
+
let configs = {
|
|
707
|
+
API_KEY: RANGO_PUBLIC_API_KEY
|
|
708
|
+
};
|
|
709
|
+
function getConfig(name) {
|
|
710
|
+
return configs[name];
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
let rango = undefined;
|
|
714
|
+
const httpService = () => {
|
|
715
|
+
if (rango) return rango;
|
|
716
|
+
rango = new RangoClient(getConfig('API_KEY'));
|
|
717
|
+
return rango;
|
|
718
|
+
};
|
|
779
719
|
|
|
780
720
|
const SLIPPAGES = [0.5, 1, 3, 5, 8, 13, 20];
|
|
781
721
|
const DEFAULT_SLIPPAGE = 1;
|
|
@@ -793,7 +733,7 @@ const useMetaStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()(set =>
|
|
|
793
733
|
loadingStatus: 'loading',
|
|
794
734
|
fetchMeta: async () => {
|
|
795
735
|
try {
|
|
796
|
-
const response = await httpService.getAllMetadata();
|
|
736
|
+
const response = await httpService().getAllMetadata();
|
|
797
737
|
const chainThatHasTokenInMetaResponse = removeDuplicateFrom(response.tokens.map(t => t.blockchain));
|
|
798
738
|
const enabledChains = response.blockchains.filter(chain => chain.enabled && chainThatHasTokenInMetaResponse.includes(chain.name));
|
|
799
739
|
response.blockchains = enabledChains.sort((a, b) => a.sort - b.sort);
|
|
@@ -813,6 +753,7 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*
|
|
|
813
753
|
slippage: DEFAULT_SLIPPAGE,
|
|
814
754
|
customSlippage: null,
|
|
815
755
|
infiniteApprove: false,
|
|
756
|
+
affiliateRef: null,
|
|
816
757
|
disabledLiquiditySources: [],
|
|
817
758
|
theme: 'auto',
|
|
818
759
|
setSlippage: slippage => set(() => ({
|
|
@@ -821,6 +762,9 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*
|
|
|
821
762
|
setCustomSlippage: customSlippage => set(() => ({
|
|
822
763
|
customSlippage: customSlippage
|
|
823
764
|
})),
|
|
765
|
+
setAffiliateRef: affiliateRef => set(() => ({
|
|
766
|
+
affiliateRef
|
|
767
|
+
})),
|
|
824
768
|
toggleAllLiquiditySources: () => set(state => {
|
|
825
769
|
const {
|
|
826
770
|
swappers
|
|
@@ -871,7 +815,7 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
871
815
|
}));
|
|
872
816
|
accounts.forEach(async account => {
|
|
873
817
|
try {
|
|
874
|
-
const response = await httpService.getWalletsDetails([{
|
|
818
|
+
const response = await httpService().getWalletsDetails([{
|
|
875
819
|
address: account.address,
|
|
876
820
|
blockchain: account.chain
|
|
877
821
|
}]);
|
|
@@ -1099,20 +1043,21 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1099
1043
|
const {
|
|
1100
1044
|
slippage,
|
|
1101
1045
|
customSlippage,
|
|
1102
|
-
disabledLiquiditySources
|
|
1046
|
+
disabledLiquiditySources,
|
|
1047
|
+
affiliateRef
|
|
1103
1048
|
} = settingsStore.getState();
|
|
1104
1049
|
if (!fromToken || !toToken || !inputAmount || inputAmount === '0') return;
|
|
1105
1050
|
abortController?.abort();
|
|
1106
1051
|
abortController = new AbortController();
|
|
1107
1052
|
const userSlippage = !!customSlippage ? customSlippage : slippage;
|
|
1108
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false);
|
|
1053
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false, affiliateRef);
|
|
1109
1054
|
if (!bestRouteStore.getState().loading) bestRouteStore.setState({
|
|
1110
1055
|
loading: true,
|
|
1111
1056
|
bestRoute: null,
|
|
1112
1057
|
outputAmount: null,
|
|
1113
1058
|
outputUsdValue: new BigNumber(0)
|
|
1114
1059
|
});
|
|
1115
|
-
httpService.getBestRoute(requestBody, {
|
|
1060
|
+
httpService().getBestRoute(requestBody, {
|
|
1116
1061
|
signal: abortController.signal
|
|
1117
1062
|
}).then(res => {
|
|
1118
1063
|
const {
|
|
@@ -1411,10 +1356,6 @@ const Container = /*#__PURE__*/styled('div', {
|
|
|
1411
1356
|
}
|
|
1412
1357
|
}
|
|
1413
1358
|
});
|
|
1414
|
-
const StyledImage = /*#__PURE__*/styled('img', {
|
|
1415
|
-
width: '$24',
|
|
1416
|
-
maxHeight: '$24'
|
|
1417
|
-
});
|
|
1418
1359
|
const Options = /*#__PURE__*/styled('div', {
|
|
1419
1360
|
display: 'flex',
|
|
1420
1361
|
justifyContent: 'flex-end',
|
|
@@ -1511,8 +1452,9 @@ function TokenInfo(props) {
|
|
|
1511
1452
|
variant: "outlined",
|
|
1512
1453
|
disabled: loadingStatus === 'failed',
|
|
1513
1454
|
loading: loadingStatus === 'loading',
|
|
1514
|
-
prefix: loadingStatus === 'success' && chain ? React.createElement(
|
|
1515
|
-
src: chain.logo
|
|
1455
|
+
prefix: loadingStatus === 'success' && chain ? React.createElement(Image, {
|
|
1456
|
+
src: chain.logo,
|
|
1457
|
+
size: 24
|
|
1516
1458
|
}) : React.createElement(ImagePlaceholder, null),
|
|
1517
1459
|
suffix: ItemSuffix,
|
|
1518
1460
|
align: "start",
|
|
@@ -1527,8 +1469,9 @@ function TokenInfo(props) {
|
|
|
1527
1469
|
variant: "outlined",
|
|
1528
1470
|
disabled: loadingStatus === 'failed' || type === 'From' && !fromChain || type === 'To' && !toChain,
|
|
1529
1471
|
loading: loadingStatus === 'loading',
|
|
1530
|
-
prefix: loadingStatus === 'success' && token ? React.createElement(
|
|
1531
|
-
src: token.image
|
|
1472
|
+
prefix: loadingStatus === 'success' && token ? React.createElement(Image, {
|
|
1473
|
+
src: token.image,
|
|
1474
|
+
size: 24
|
|
1532
1475
|
}) : React.createElement(ImagePlaceholder, null),
|
|
1533
1476
|
suffix: ItemSuffix,
|
|
1534
1477
|
size: "large",
|
|
@@ -1673,7 +1616,8 @@ function HeaderButtons(props) {
|
|
|
1673
1616
|
onClick: onClickRefresh,
|
|
1674
1617
|
disabled: !onClickRefresh
|
|
1675
1618
|
}, React.createElement(RetryIcon, {
|
|
1676
|
-
size: 24
|
|
1619
|
+
size: 24,
|
|
1620
|
+
disabled: !onClickRefresh
|
|
1677
1621
|
}))), React.createElement(Tooltip, {
|
|
1678
1622
|
content: "Transactions History"
|
|
1679
1623
|
}, React.createElement(Button, {
|
|
@@ -1713,10 +1657,7 @@ const Alerts = /*#__PURE__*/styled('div', {
|
|
|
1713
1657
|
width: '100%',
|
|
1714
1658
|
paddingTop: '$16'
|
|
1715
1659
|
});
|
|
1716
|
-
function Home(
|
|
1717
|
-
const {
|
|
1718
|
-
title = 'SWAP'
|
|
1719
|
-
} = props;
|
|
1660
|
+
function Home() {
|
|
1720
1661
|
const isRouterInContext = useInRouterContext();
|
|
1721
1662
|
const navigate = useNavigate();
|
|
1722
1663
|
const [count, setCount] = useState(0);
|
|
@@ -1757,7 +1698,7 @@ function Home(props) {
|
|
|
1757
1698
|
return setCurrentPage.bind(null, '');
|
|
1758
1699
|
}, []);
|
|
1759
1700
|
return React.createElement(Container$2, null, React.createElement(Header$1, {
|
|
1760
|
-
title:
|
|
1701
|
+
title: "SWAP",
|
|
1761
1702
|
suffix: React.createElement(HeaderButtons, {
|
|
1762
1703
|
onClickRefresh: !!bestRoute ? fetchBestRoute : undefined
|
|
1763
1704
|
})
|
|
@@ -1818,8 +1759,7 @@ function Home(props) {
|
|
|
1818
1759
|
|
|
1819
1760
|
const Route = _ref => {
|
|
1820
1761
|
let {
|
|
1821
|
-
children
|
|
1822
|
-
...props
|
|
1762
|
+
children
|
|
1823
1763
|
} = _ref;
|
|
1824
1764
|
const location = useLocation$1();
|
|
1825
1765
|
const navigate = useNavigate$1();
|
|
@@ -1830,7 +1770,7 @@ const Route = _ref => {
|
|
|
1830
1770
|
});
|
|
1831
1771
|
ref.current = false;
|
|
1832
1772
|
}, []);
|
|
1833
|
-
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React.createElement(Home,
|
|
1773
|
+
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React.createElement(Home, null);
|
|
1834
1774
|
return React.createElement(React.Fragment, null, " ", children);
|
|
1835
1775
|
};
|
|
1836
1776
|
function AppRouter(_ref2) {
|
|
@@ -1924,10 +1864,6 @@ const Container$3 = /*#__PURE__*/styled('div', {
|
|
|
1924
1864
|
}
|
|
1925
1865
|
}
|
|
1926
1866
|
});
|
|
1927
|
-
const StyledImage$1 = /*#__PURE__*/styled('img', {
|
|
1928
|
-
width: '$24',
|
|
1929
|
-
maxHeight: '$24'
|
|
1930
|
-
});
|
|
1931
1867
|
const ImagePlaceholder$1 = /*#__PURE__*/styled('span', {
|
|
1932
1868
|
width: '24px',
|
|
1933
1869
|
height: '24px',
|
|
@@ -1983,8 +1919,9 @@ function TokenPreview(props) {
|
|
|
1983
1919
|
className: "selectors",
|
|
1984
1920
|
variant: "outlined",
|
|
1985
1921
|
loading: loadingStatus === 'loading',
|
|
1986
|
-
prefix: loadingStatus === 'success' && chain ? React.createElement(
|
|
1987
|
-
src: chain.logo
|
|
1922
|
+
prefix: loadingStatus === 'success' && chain ? React.createElement(Image, {
|
|
1923
|
+
src: chain.logo,
|
|
1924
|
+
size: 24
|
|
1988
1925
|
}) : React.createElement(ImagePlaceholder$1, null),
|
|
1989
1926
|
suffix: ItemSuffix,
|
|
1990
1927
|
align: "start",
|
|
@@ -1995,8 +1932,9 @@ function TokenPreview(props) {
|
|
|
1995
1932
|
className: "selectors",
|
|
1996
1933
|
variant: "outlined",
|
|
1997
1934
|
loading: loadingStatus === 'loading',
|
|
1998
|
-
prefix: loadingStatus === 'success' && token ? React.createElement(
|
|
1999
|
-
src: token.image
|
|
1935
|
+
prefix: loadingStatus === 'success' && token ? React.createElement(Image, {
|
|
1936
|
+
src: token.image,
|
|
1937
|
+
size: 24
|
|
2000
1938
|
}) : React.createElement(ImagePlaceholder$1, null),
|
|
2001
1939
|
suffix: ItemSuffix,
|
|
2002
1940
|
size: "large",
|
|
@@ -2074,6 +2012,7 @@ function useConfirmSwap() {
|
|
|
2074
2012
|
const initialRoute = useBestRouteStore.use.bestRoute();
|
|
2075
2013
|
const setBestRoute = useBestRouteStore.use.setBestRoute();
|
|
2076
2014
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
2015
|
+
const affiliateRef = useSettingsStore.use.affiliateRef();
|
|
2077
2016
|
const accounts = useWalletsStore.use.accounts();
|
|
2078
2017
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
2079
2018
|
const meta = useMetaStore.use.meta();
|
|
@@ -2107,16 +2046,15 @@ function useConfirmSwap() {
|
|
|
2107
2046
|
proceedAnywayRef.current = false;
|
|
2108
2047
|
if (confiremedRouteRef.current) {
|
|
2109
2048
|
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2110
|
-
//@ts-ignore
|
|
2111
2049
|
return newSwap;
|
|
2112
2050
|
}
|
|
2113
2051
|
return;
|
|
2114
2052
|
}
|
|
2115
2053
|
abortControllerRef.current = new AbortController();
|
|
2116
2054
|
setLoading(true);
|
|
2117
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true);
|
|
2055
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true, affiliateRef);
|
|
2118
2056
|
try {
|
|
2119
|
-
const confiremedRoute = await httpService.getBestRoute(requestBody, {
|
|
2057
|
+
const confiremedRoute = await httpService().getBestRoute(requestBody, {
|
|
2120
2058
|
signal: abortControllerRef.current?.signal
|
|
2121
2059
|
});
|
|
2122
2060
|
abortControllerRef.current = null;
|
|
@@ -2170,7 +2108,6 @@ function useConfirmSwap() {
|
|
|
2170
2108
|
disabledSwappersGroups: disabledLiquiditySources
|
|
2171
2109
|
};
|
|
2172
2110
|
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2173
|
-
//@ts-ignore
|
|
2174
2111
|
return newSwap;
|
|
2175
2112
|
} else if (!proceedAnywayRef.current) {
|
|
2176
2113
|
proceedAnywayRef.current = true;
|
|
@@ -2388,7 +2325,10 @@ function ConfirmSwapPage() {
|
|
|
2388
2325
|
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
2389
2326
|
};
|
|
2390
2327
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
2391
|
-
return React.createElement(ConfirmSwap
|
|
2328
|
+
return React.createElement(ConfirmSwap
|
|
2329
|
+
// @ts-ignore
|
|
2330
|
+
, {
|
|
2331
|
+
// @ts-ignore
|
|
2392
2332
|
requiredWallets: getRequiredChains(bestRoute),
|
|
2393
2333
|
selectableWallets: selectableWallets,
|
|
2394
2334
|
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
@@ -2397,7 +2337,9 @@ function ConfirmSwapPage() {
|
|
|
2397
2337
|
if (swap) {
|
|
2398
2338
|
manager?.create('swap', {
|
|
2399
2339
|
swapDetails: swap
|
|
2400
|
-
},
|
|
2340
|
+
},
|
|
2341
|
+
// @ts-ignore
|
|
2342
|
+
{
|
|
2401
2343
|
id: swap.requestId
|
|
2402
2344
|
});
|
|
2403
2345
|
setSelectedSwap(swap.requestId);
|
|
@@ -2555,7 +2497,7 @@ function LiquiditySourcePage(_ref) {
|
|
|
2555
2497
|
});
|
|
2556
2498
|
return React.createElement(LiquiditySourcesSelector, {
|
|
2557
2499
|
toggleAll: toggleAllLiquiditySources,
|
|
2558
|
-
list: supportedSwappers
|
|
2500
|
+
list: supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups,
|
|
2559
2501
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
2560
2502
|
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources),
|
|
2561
2503
|
loadingStatus: loadingMetaStatus
|
|
@@ -2567,7 +2509,7 @@ function SelectChainPage(props) {
|
|
|
2567
2509
|
type,
|
|
2568
2510
|
supportedChains
|
|
2569
2511
|
} = props;
|
|
2570
|
-
const blockchains = supportedChains
|
|
2512
|
+
const blockchains = supportedChains ? useMetaStore.use.meta().blockchains.filter(chain => supportedChains.includes(chain.name)) : useMetaStore.use.meta().blockchains;
|
|
2571
2513
|
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
2572
2514
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
2573
2515
|
const toChain = useBestRouteStore.use.toChain();
|
|
@@ -2599,8 +2541,8 @@ function SelectTokenPage(props) {
|
|
|
2599
2541
|
} = props;
|
|
2600
2542
|
const sourceTokens = useBestRouteStore.use.sourceTokens();
|
|
2601
2543
|
const destinationTokens = useBestRouteStore.use.destinationTokens();
|
|
2602
|
-
const supportedSourceTokens = supportedTokens
|
|
2603
|
-
const supportedDestinationTokens = supportedTokens
|
|
2544
|
+
const supportedSourceTokens = supportedTokens ? sourceTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : sourceTokens;
|
|
2545
|
+
const supportedDestinationTokens = supportedTokens ? destinationTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : destinationTokens;
|
|
2604
2546
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
2605
2547
|
const toToken = useBestRouteStore.use.toToken();
|
|
2606
2548
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
@@ -2653,8 +2595,8 @@ function SettingsPage(_ref) {
|
|
|
2653
2595
|
}
|
|
2654
2596
|
}
|
|
2655
2597
|
});
|
|
2656
|
-
supportedSwappers
|
|
2657
|
-
const supportedUniqueSwappersGroups = supportedSwappers
|
|
2598
|
+
supportedSwappers && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0);
|
|
2599
|
+
const supportedUniqueSwappersGroups = supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups;
|
|
2658
2600
|
return React.createElement(Settings, {
|
|
2659
2601
|
slippages: SLIPPAGES,
|
|
2660
2602
|
selectedSlippage: slippage,
|
|
@@ -2707,7 +2649,7 @@ function WalletsPage(_ref) {
|
|
|
2707
2649
|
getWalletInfo,
|
|
2708
2650
|
connect
|
|
2709
2651
|
} = useWallets();
|
|
2710
|
-
const wallets = getlistWallet(state, getWalletInfo, supportedWallets
|
|
2652
|
+
const wallets = getlistWallet(state, getWalletInfo, supportedWallets || Object.values(WalletType));
|
|
2711
2653
|
const walletsRef = useRef();
|
|
2712
2654
|
let sortedWallets = detectMobileScreens() ? wallets.filter(wallet => wallet.showOnMobile) : wallets;
|
|
2713
2655
|
sortedWallets = sortWalletsBasedOnState(sortedWallets);
|
|
@@ -2916,7 +2858,7 @@ function SwapDetailsPage() {
|
|
|
2916
2858
|
}), React.createElement(TokenPreview, {
|
|
2917
2859
|
chain: {
|
|
2918
2860
|
displayName: lastStep?.toBlockchain || '',
|
|
2919
|
-
|
|
2861
|
+
//@ts-ignore
|
|
2920
2862
|
logo: lastStep?.toBlockchainLogo || ''
|
|
2921
2863
|
},
|
|
2922
2864
|
token: {
|
|
@@ -2928,7 +2870,6 @@ function SwapDetailsPage() {
|
|
|
2928
2870
|
loadingStatus: 'success'
|
|
2929
2871
|
})),
|
|
2930
2872
|
//todo: move PendingSwap type to rango-types
|
|
2931
|
-
//@ts-ignore
|
|
2932
2873
|
pendingSwap: swap,
|
|
2933
2874
|
onCopy: handleCopy,
|
|
2934
2875
|
isCopied: isCopied,
|
|
@@ -2958,48 +2899,44 @@ function SwapDetailsPage() {
|
|
|
2958
2899
|
const getAbsolutePath = path => path.replace('/', '');
|
|
2959
2900
|
function AppRoutes(props) {
|
|
2960
2901
|
const {
|
|
2961
|
-
|
|
2902
|
+
config
|
|
2962
2903
|
} = props;
|
|
2963
2904
|
return useRoutes([{
|
|
2964
2905
|
path: getAbsolutePath(navigationRoutes.home),
|
|
2965
|
-
element: React.createElement(Home,
|
|
2966
|
-
title: configs?.title,
|
|
2967
|
-
titleSize: configs?.titleSize,
|
|
2968
|
-
titleWeight: configs?.titleWeight
|
|
2969
|
-
})
|
|
2906
|
+
element: React.createElement(Home, null)
|
|
2970
2907
|
}, {
|
|
2971
2908
|
path: getAbsolutePath(navigationRoutes.fromChain),
|
|
2972
2909
|
element: React.createElement(SelectChainPage, {
|
|
2973
2910
|
type: "from",
|
|
2974
|
-
supportedChains:
|
|
2911
|
+
supportedChains: config?.from?.blockchains
|
|
2975
2912
|
})
|
|
2976
2913
|
}, {
|
|
2977
2914
|
path: getAbsolutePath(navigationRoutes.toChain),
|
|
2978
2915
|
element: React.createElement(SelectChainPage, {
|
|
2979
2916
|
type: "to",
|
|
2980
|
-
supportedChains:
|
|
2917
|
+
supportedChains: config?.to?.blockchains
|
|
2981
2918
|
})
|
|
2982
2919
|
}, {
|
|
2983
2920
|
path: getAbsolutePath(navigationRoutes.fromToken),
|
|
2984
2921
|
element: React.createElement(SelectTokenPage, {
|
|
2985
2922
|
type: "from",
|
|
2986
|
-
supportedTokens:
|
|
2923
|
+
supportedTokens: config?.from?.tokens
|
|
2987
2924
|
})
|
|
2988
2925
|
}, {
|
|
2989
2926
|
path: getAbsolutePath(navigationRoutes.toToken),
|
|
2990
2927
|
element: React.createElement(SelectTokenPage, {
|
|
2991
2928
|
type: "to",
|
|
2992
|
-
supportedTokens:
|
|
2929
|
+
supportedTokens: config?.to?.tokens
|
|
2993
2930
|
})
|
|
2994
2931
|
}, {
|
|
2995
2932
|
path: getAbsolutePath(navigationRoutes.settings),
|
|
2996
2933
|
element: React.createElement(SettingsPage, {
|
|
2997
|
-
supportedSwappers:
|
|
2934
|
+
supportedSwappers: config?.liquiditySources
|
|
2998
2935
|
})
|
|
2999
2936
|
}, {
|
|
3000
2937
|
path: getAbsolutePath(navigationRoutes.liquiditySources),
|
|
3001
2938
|
element: React.createElement(LiquiditySourcePage, {
|
|
3002
|
-
supportedSwappers:
|
|
2939
|
+
supportedSwappers: config?.liquiditySources
|
|
3003
2940
|
})
|
|
3004
2941
|
}, {
|
|
3005
2942
|
path: getAbsolutePath(navigationRoutes.swaps),
|
|
@@ -3010,8 +2947,8 @@ function AppRoutes(props) {
|
|
|
3010
2947
|
}, {
|
|
3011
2948
|
path: getAbsolutePath(navigationRoutes.wallets),
|
|
3012
2949
|
element: React.createElement(WalletsPage, {
|
|
3013
|
-
supportedWallets:
|
|
3014
|
-
multiWallets: typeof
|
|
2950
|
+
supportedWallets: config?.wallets,
|
|
2951
|
+
multiWallets: typeof config?.multiWallets === 'undefined' ? true : config.multiWallets
|
|
3015
2952
|
})
|
|
3016
2953
|
}, {
|
|
3017
2954
|
path: getAbsolutePath(navigationRoutes.confirmSwap),
|
|
@@ -3027,16 +2964,14 @@ const Header = /*#__PURE__*/styled('div', {
|
|
|
3027
2964
|
display: 'flex'
|
|
3028
2965
|
}
|
|
3029
2966
|
});
|
|
3030
|
-
const
|
|
3031
|
-
width: '$24',
|
|
3032
|
-
height: '$24',
|
|
2967
|
+
const WalletImageContainer = /*#__PURE__*/styled('div', {
|
|
3033
2968
|
marginLeft: -15,
|
|
3034
2969
|
marginRight: '$6',
|
|
3035
2970
|
borderRadius: '99999px'
|
|
3036
2971
|
});
|
|
3037
2972
|
function Layout(_ref) {
|
|
3038
2973
|
let {
|
|
3039
|
-
|
|
2974
|
+
config
|
|
3040
2975
|
} = _ref;
|
|
3041
2976
|
const navigate = useNavigate();
|
|
3042
2977
|
const {
|
|
@@ -3048,11 +2983,16 @@ function Layout(_ref) {
|
|
|
3048
2983
|
getWalletInfo
|
|
3049
2984
|
} = useWallets();
|
|
3050
2985
|
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(accounts, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2986
|
+
const {
|
|
2987
|
+
blockchains,
|
|
2988
|
+
tokens
|
|
2989
|
+
} = useMetaStore.use.meta();
|
|
3051
2990
|
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
3052
2991
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
3053
2992
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
3054
2993
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
3055
2994
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2995
|
+
const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
|
|
3056
2996
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
3057
2997
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
3058
2998
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
@@ -3061,22 +3001,23 @@ function Layout(_ref) {
|
|
|
3061
3001
|
t
|
|
3062
3002
|
} = useTranslation();
|
|
3063
3003
|
useEffect(() => {
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3004
|
+
const chain = blockchains.find(chain => chain.name === config?.to?.blockchain);
|
|
3005
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.to?.token || null));
|
|
3006
|
+
setToChain(chain || null);
|
|
3007
|
+
setToToken(token || null);
|
|
3008
|
+
}, [config?.to?.token, config?.to?.blockchain]);
|
|
3067
3009
|
useEffect(() => {
|
|
3068
|
-
setInputAmount(
|
|
3069
|
-
}, [
|
|
3010
|
+
setInputAmount(config?.amount?.toString() || '');
|
|
3011
|
+
}, [config?.amount]);
|
|
3070
3012
|
useEffect(() => {
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3013
|
+
const chain = blockchains.find(chain => chain.name === config?.from?.blockchain);
|
|
3014
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.from?.token || null));
|
|
3015
|
+
setFromChain(chain || null);
|
|
3016
|
+
setFromToken(token || null);
|
|
3017
|
+
}, [config?.from?.token, config?.from?.blockchain]);
|
|
3074
3018
|
useEffect(() => {
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
setFromToken(null);
|
|
3078
|
-
setToToken(null);
|
|
3079
|
-
}, [configs?.fromChains, configs?.toChains, configs?.fromTokens, configs?.toTokens]);
|
|
3019
|
+
setAffiliateRef(config?.affiliateRef || null);
|
|
3020
|
+
}, [config?.affiliateRef]);
|
|
3080
3021
|
return React.createElement(React.Fragment, null, React.createElement(Header, null, React.createElement(Button, {
|
|
3081
3022
|
size: "small",
|
|
3082
3023
|
suffix: React.createElement(AddWalletIcon, {
|
|
@@ -3089,15 +3030,17 @@ function Layout(_ref) {
|
|
|
3089
3030
|
onClick: () => {
|
|
3090
3031
|
if (!connectWalletsButtonDisabled) navigate(navigationRoutes.wallets);
|
|
3091
3032
|
}
|
|
3092
|
-
}, connectedWalletsImages?.length ? connectedWalletsImages.map((walletImage, index) => React.createElement(
|
|
3093
|
-
key: index
|
|
3094
|
-
|
|
3095
|
-
|
|
3033
|
+
}, connectedWalletsImages?.length ? connectedWalletsImages.map((walletImage, index) => React.createElement(WalletImageContainer, {
|
|
3034
|
+
key: index
|
|
3035
|
+
}, React.createElement(Image, {
|
|
3036
|
+
src: walletImage,
|
|
3037
|
+
size: 24
|
|
3038
|
+
}))) : React.createElement(React.Fragment, null), React.createElement("div", {
|
|
3096
3039
|
className: "balance"
|
|
3097
3040
|
}, React.createElement(Typography, {
|
|
3098
3041
|
variant: "body2"
|
|
3099
3042
|
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React.createElement(Spinner, null)))), React.createElement(AppRoutes, {
|
|
3100
|
-
|
|
3043
|
+
config: config
|
|
3101
3044
|
}));
|
|
3102
3045
|
}
|
|
3103
3046
|
|
|
@@ -3140,17 +3083,20 @@ function usePrevious(value) {
|
|
|
3140
3083
|
|
|
3141
3084
|
function useTheme(_ref) {
|
|
3142
3085
|
let {
|
|
3143
|
-
|
|
3144
|
-
background = '#fff',
|
|
3145
|
-
foreground = '#000',
|
|
3146
|
-
error = '#FF0000',
|
|
3147
|
-
warning = '#F5A623',
|
|
3148
|
-
success = '#0070F3',
|
|
3086
|
+
colors: themeColors,
|
|
3149
3087
|
fontFamily = 'Robot',
|
|
3150
|
-
borderRadius = 8
|
|
3088
|
+
borderRadius = 8,
|
|
3089
|
+
mode = 'auto'
|
|
3151
3090
|
} = _ref;
|
|
3152
3091
|
const theme = useSettingsStore.use.theme();
|
|
3153
3092
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
3093
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
3094
|
+
const primary = themeColors?.primary || '#5FA425',
|
|
3095
|
+
background = themeColors?.background || '#fff',
|
|
3096
|
+
foreground = themeColors?.foreground || '#000',
|
|
3097
|
+
error = themeColors?.error || '#FF0000',
|
|
3098
|
+
warning = themeColors?.warning || '#F5A623',
|
|
3099
|
+
success = themeColors?.success || '#0070F3';
|
|
3154
3100
|
const colors = {
|
|
3155
3101
|
neutrals200: '#FAFAFA',
|
|
3156
3102
|
neutrals300: '#f2f2f2',
|
|
@@ -3192,6 +3138,9 @@ function useTheme(_ref) {
|
|
|
3192
3138
|
colors,
|
|
3193
3139
|
radii: {
|
|
3194
3140
|
5: `${borderRadius}px`
|
|
3141
|
+
},
|
|
3142
|
+
shadows: {
|
|
3143
|
+
s: '0px 3px 5px 3px #f0f2f5, 0px 6px 10px 3px #f0f2f5, 0px 1px 18px 3px #f0f2f5'
|
|
3195
3144
|
}
|
|
3196
3145
|
});
|
|
3197
3146
|
const customeDarkTheme = createTheme({
|
|
@@ -3210,6 +3159,9 @@ function useTheme(_ref) {
|
|
|
3210
3159
|
},
|
|
3211
3160
|
radii: {
|
|
3212
3161
|
5: `${borderRadius}px`
|
|
3162
|
+
},
|
|
3163
|
+
shadows: {
|
|
3164
|
+
s: '0px 3px 5px 3px #222, 0px 6px 10px 3px #222, 0px 1px 18px 3px #222'
|
|
3213
3165
|
}
|
|
3214
3166
|
});
|
|
3215
3167
|
const [OSTheme, setOSTheme] = useState(customeLightTheme);
|
|
@@ -3228,6 +3180,9 @@ function useTheme(_ref) {
|
|
|
3228
3180
|
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', switchTheme);
|
|
3229
3181
|
};
|
|
3230
3182
|
}, []);
|
|
3183
|
+
useEffect(() => {
|
|
3184
|
+
if (mode !== 'auto') setTheme(mode);
|
|
3185
|
+
}, [mode]);
|
|
3231
3186
|
const prevFont = usePrevious(fontFamily);
|
|
3232
3187
|
useLayoutEffect(() => {
|
|
3233
3188
|
const {
|
|
@@ -3332,6 +3287,11 @@ function QueueManager(props) {
|
|
|
3332
3287
|
canSwitchNetworkTo,
|
|
3333
3288
|
getWalletInfo
|
|
3334
3289
|
} = useWallets();
|
|
3290
|
+
const swapQueueDef = useMemo(() => {
|
|
3291
|
+
return makeQueueDefinition({
|
|
3292
|
+
API_KEY: getConfig('API_KEY')
|
|
3293
|
+
});
|
|
3294
|
+
}, []);
|
|
3335
3295
|
const {
|
|
3336
3296
|
blockchains
|
|
3337
3297
|
} = useMetaStore.use.meta();
|
|
@@ -3392,29 +3352,27 @@ function QueueManager(props) {
|
|
|
3392
3352
|
|
|
3393
3353
|
const SwapBox = _ref => {
|
|
3394
3354
|
let {
|
|
3395
|
-
|
|
3355
|
+
config
|
|
3396
3356
|
} = _ref;
|
|
3397
3357
|
globalStyles();
|
|
3398
|
-
globalFont(
|
|
3358
|
+
globalFont(config?.theme?.fontFamily || 'Roboto');
|
|
3399
3359
|
const {
|
|
3400
3360
|
activeTheme
|
|
3401
3361
|
} = useTheme({
|
|
3402
|
-
...
|
|
3403
|
-
borderRadius: configs?.borderRadius,
|
|
3404
|
-
fontFamily: configs?.fontFamily
|
|
3362
|
+
...config?.theme
|
|
3405
3363
|
});
|
|
3406
3364
|
const {
|
|
3407
3365
|
blockchains
|
|
3408
3366
|
} = useMetaStore.use.meta();
|
|
3409
3367
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
3410
3368
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
3411
|
-
const setTheme = useSettingsStore.use.setTheme();
|
|
3412
3369
|
const {
|
|
3413
3370
|
changeLanguage
|
|
3414
3371
|
} = useSelectLanguage();
|
|
3415
3372
|
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
3416
3373
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] = useState('');
|
|
3417
3374
|
const [disconnectedWallet, setDisconnectedWallet] = useState();
|
|
3375
|
+
const currentPage = useUiStore.use.currentPage();
|
|
3418
3376
|
const evmBasedChainNames = blockchains.filter(isEvmBlockchain$1).map(chain => chain.name);
|
|
3419
3377
|
const onUpdateState = (type, event, value, state, supportedChains) => {
|
|
3420
3378
|
if (event === Events.ACCOUNTS) {
|
|
@@ -3439,19 +3397,16 @@ const SwapBox = _ref => {
|
|
|
3439
3397
|
};
|
|
3440
3398
|
let providers = allProviders();
|
|
3441
3399
|
useEffect(() => {
|
|
3442
|
-
|
|
3443
|
-
}, [configs.theme]);
|
|
3444
|
-
useEffect(() => {
|
|
3445
|
-
const wallets = configs.wallets;
|
|
3400
|
+
const wallets = config?.wallets;
|
|
3446
3401
|
clearConnectedWallet();
|
|
3447
|
-
providers = wallets
|
|
3402
|
+
providers = !wallets ? allProviders() : allProviders().filter(provider => {
|
|
3448
3403
|
const type = provider.config.type;
|
|
3449
3404
|
return wallets.find(w => w === type);
|
|
3450
3405
|
});
|
|
3451
|
-
}, [
|
|
3406
|
+
}, [config?.wallets]);
|
|
3452
3407
|
useEffect(() => {
|
|
3453
|
-
changeLanguage(
|
|
3454
|
-
}, [
|
|
3408
|
+
changeLanguage(config?.language || 'en');
|
|
3409
|
+
}, [config?.language]);
|
|
3455
3410
|
return React.createElement(Provider$1, {
|
|
3456
3411
|
allBlockChains: blockchains,
|
|
3457
3412
|
providers: providers,
|
|
@@ -3460,21 +3415,15 @@ const SwapBox = _ref => {
|
|
|
3460
3415
|
id: "pageContainer",
|
|
3461
3416
|
className: activeTheme
|
|
3462
3417
|
}, React.createElement(QueueManager, null, React.createElement(SwapContainer, {
|
|
3463
|
-
|
|
3464
|
-
width: configs?.width || 'auto',
|
|
3465
|
-
height: configs?.height || 'auto'
|
|
3466
|
-
}
|
|
3418
|
+
fixedHeight: currentPage !== navigationRoutes.home
|
|
3467
3419
|
}, React.createElement(AppRouter, {
|
|
3468
|
-
title: configs.title,
|
|
3469
|
-
titleSize: configs.titleSize,
|
|
3470
|
-
titleWeight: configs.titleWeight,
|
|
3471
3420
|
lastConnectedWallet: lastConnectedWalletWithNetwork,
|
|
3472
3421
|
disconnectedWallet: disconnectedWallet,
|
|
3473
3422
|
clearDisconnectedWallet: () => {
|
|
3474
3423
|
setDisconnectedWallet(undefined);
|
|
3475
3424
|
}
|
|
3476
3425
|
}, React.createElement(Layout, {
|
|
3477
|
-
|
|
3426
|
+
config: config
|
|
3478
3427
|
}))))));
|
|
3479
3428
|
};
|
|
3480
3429
|
|