@rango-dev/widget-embedded 0.1.11-next.0 → 0.1.11-next.11
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 +3 -7
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +144 -195
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +144 -195
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +144 -195
- 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 +9 -13
- 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 +3 -10
- 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 +5 -4
- package/src/store/meta.ts +6 -4
- package/src/store/settings.ts +7 -0
- package/src/store/wallets.ts +2 -2
- package/src/types/config.ts +28 -29
- package/src/utils/configs.ts +24 -0
- package/src/utils/swap.ts +17 -99
|
@@ -430,7 +430,7 @@ function LimitErrorMessage(bestRoute) {
|
|
|
430
430
|
recommendation
|
|
431
431
|
};
|
|
432
432
|
}
|
|
433
|
-
function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, hasLimitError, highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath,
|
|
433
|
+
function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, hasLimitError, highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputAmount) {
|
|
434
434
|
if (loadingMetaStatus !== 'success') return {
|
|
435
435
|
title: 'Connect Wallet',
|
|
436
436
|
disabled: true
|
|
@@ -442,7 +442,7 @@ function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, has
|
|
|
442
442
|
if (loading) return {
|
|
443
443
|
title: 'Finding Best Route...',
|
|
444
444
|
disabled: true
|
|
445
|
-
};else if (
|
|
445
|
+
};else if (!inputAmount || inputAmount === '0') return {
|
|
446
446
|
title: 'Enter an amount',
|
|
447
447
|
disabled: true
|
|
448
448
|
};else if (!bestRoute || !bestRoute.result) return {
|
|
@@ -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,
|
|
514
|
+
function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, affiliateRef, initialRoute) {
|
|
589
515
|
const selectedWalletsMap = selectedWallets.reduce((selectedWalletsMap, selectedWallet) => (selectedWalletsMap[selectedWallet.chain] = selectedWallet.address, selectedWalletsMap), {});
|
|
590
516
|
const connectedWallets = [];
|
|
591
517
|
wallets.forEach(wallet => {
|
|
@@ -595,9 +521,11 @@ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, se
|
|
|
595
521
|
addresses: [wallet.address]
|
|
596
522
|
});
|
|
597
523
|
});
|
|
598
|
-
const
|
|
524
|
+
const checkPrerequisites = !!initialRoute;
|
|
525
|
+
const filteredBlockchains = removeDuplicateFrom((initialRoute?.result?.swaps || []).reduce((blockchains, swap) => (blockchains.push(swap.from.blockchain, swap.to.blockchain), blockchains), []));
|
|
599
526
|
const requestBody = {
|
|
600
527
|
amount: inputAmount.toString(),
|
|
528
|
+
affiliateRef,
|
|
601
529
|
checkPrerequisites,
|
|
602
530
|
from: {
|
|
603
531
|
address: fromToken.address,
|
|
@@ -784,7 +712,20 @@ const createSelectors = _store => {
|
|
|
784
712
|
return store;
|
|
785
713
|
};
|
|
786
714
|
|
|
787
|
-
const
|
|
715
|
+
const RANGO_PUBLIC_API_KEY = 'c6381a79-2817-4602-83bf-6a641a409e32';
|
|
716
|
+
let configs = {
|
|
717
|
+
API_KEY: RANGO_PUBLIC_API_KEY
|
|
718
|
+
};
|
|
719
|
+
function getConfig(name) {
|
|
720
|
+
return configs[name];
|
|
721
|
+
}
|
|
722
|
+
|
|
723
|
+
let rango = undefined;
|
|
724
|
+
const httpService = () => {
|
|
725
|
+
if (rango) return rango;
|
|
726
|
+
rango = new rangoSdk.RangoClient(getConfig('API_KEY'));
|
|
727
|
+
return rango;
|
|
728
|
+
};
|
|
788
729
|
|
|
789
730
|
const SLIPPAGES = [0.5, 1, 3, 5, 8, 13, 20];
|
|
790
731
|
const DEFAULT_SLIPPAGE = 1;
|
|
@@ -802,7 +743,7 @@ const useMetaStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.create()
|
|
|
802
743
|
loadingStatus: 'loading',
|
|
803
744
|
fetchMeta: async () => {
|
|
804
745
|
try {
|
|
805
|
-
const response = await httpService.getAllMetadata();
|
|
746
|
+
const response = await httpService().getAllMetadata();
|
|
806
747
|
const chainThatHasTokenInMetaResponse = removeDuplicateFrom(response.tokens.map(t => t.blockchain));
|
|
807
748
|
const enabledChains = response.blockchains.filter(chain => chain.enabled && chainThatHasTokenInMetaResponse.includes(chain.name));
|
|
808
749
|
response.blockchains = enabledChains.sort((a, b) => a.sort - b.sort);
|
|
@@ -822,6 +763,7 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.crea
|
|
|
822
763
|
slippage: DEFAULT_SLIPPAGE,
|
|
823
764
|
customSlippage: null,
|
|
824
765
|
infiniteApprove: false,
|
|
766
|
+
affiliateRef: null,
|
|
825
767
|
disabledLiquiditySources: [],
|
|
826
768
|
theme: 'auto',
|
|
827
769
|
setSlippage: slippage => set(() => ({
|
|
@@ -830,6 +772,9 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.crea
|
|
|
830
772
|
setCustomSlippage: customSlippage => set(() => ({
|
|
831
773
|
customSlippage: customSlippage
|
|
832
774
|
})),
|
|
775
|
+
setAffiliateRef: affiliateRef => set(() => ({
|
|
776
|
+
affiliateRef
|
|
777
|
+
})),
|
|
833
778
|
toggleAllLiquiditySources: () => set(state => {
|
|
834
779
|
const {
|
|
835
780
|
swappers
|
|
@@ -880,7 +825,7 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.creat
|
|
|
880
825
|
}));
|
|
881
826
|
accounts.forEach(async account => {
|
|
882
827
|
try {
|
|
883
|
-
const response = await httpService.getWalletsDetails([{
|
|
828
|
+
const response = await httpService().getWalletsDetails([{
|
|
884
829
|
address: account.address,
|
|
885
830
|
blockchain: account.chain
|
|
886
831
|
}]);
|
|
@@ -924,7 +869,7 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.creat
|
|
|
924
869
|
}
|
|
925
870
|
});
|
|
926
871
|
return {
|
|
927
|
-
selectedWallets: selectedWallets
|
|
872
|
+
selectedWallets: state.selectedWallets.concat(selectedWallets)
|
|
928
873
|
};
|
|
929
874
|
}),
|
|
930
875
|
setSelectedWallet: wallet => set(state => ({
|
|
@@ -1108,20 +1053,21 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1108
1053
|
const {
|
|
1109
1054
|
slippage,
|
|
1110
1055
|
customSlippage,
|
|
1111
|
-
disabledLiquiditySources
|
|
1056
|
+
disabledLiquiditySources,
|
|
1057
|
+
affiliateRef
|
|
1112
1058
|
} = settingsStore.getState();
|
|
1113
1059
|
if (!fromToken || !toToken || !inputAmount || inputAmount === '0') return;
|
|
1114
1060
|
abortController?.abort();
|
|
1115
1061
|
abortController = new AbortController();
|
|
1116
1062
|
const userSlippage = !!customSlippage ? customSlippage : slippage;
|
|
1117
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage,
|
|
1063
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, affiliateRef);
|
|
1118
1064
|
if (!bestRouteStore.getState().loading) bestRouteStore.setState({
|
|
1119
1065
|
loading: true,
|
|
1120
1066
|
bestRoute: null,
|
|
1121
1067
|
outputAmount: null,
|
|
1122
1068
|
outputUsdValue: new BigNumber__default(0)
|
|
1123
1069
|
});
|
|
1124
|
-
httpService.getBestRoute(requestBody, {
|
|
1070
|
+
httpService().getBestRoute(requestBody, {
|
|
1125
1071
|
signal: abortController.signal
|
|
1126
1072
|
}).then(res => {
|
|
1127
1073
|
const {
|
|
@@ -1148,7 +1094,9 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1148
1094
|
inputAmount,
|
|
1149
1095
|
inputUsdValue
|
|
1150
1096
|
} = useBestRouteStore.getState();
|
|
1151
|
-
if (!inputAmount || inputAmount === '0' || inputUsdValue.eq(0)) return
|
|
1097
|
+
if (!inputAmount || inputAmount === '0' || inputUsdValue.eq(0)) return bestRouteStore.setState({
|
|
1098
|
+
loading: false
|
|
1099
|
+
});
|
|
1152
1100
|
if (tokensAreEqual(fromToken, toToken)) return bestRouteStore.setState({
|
|
1153
1101
|
loading: false,
|
|
1154
1102
|
bestRoute: null,
|
|
@@ -1420,10 +1368,6 @@ const Container = /*#__PURE__*/ui.styled('div', {
|
|
|
1420
1368
|
}
|
|
1421
1369
|
}
|
|
1422
1370
|
});
|
|
1423
|
-
const StyledImage = /*#__PURE__*/ui.styled('img', {
|
|
1424
|
-
width: '$24',
|
|
1425
|
-
maxHeight: '$24'
|
|
1426
|
-
});
|
|
1427
1371
|
const Options = /*#__PURE__*/ui.styled('div', {
|
|
1428
1372
|
display: 'flex',
|
|
1429
1373
|
justifyContent: 'flex-end',
|
|
@@ -1465,6 +1409,7 @@ function TokenInfo(props) {
|
|
|
1465
1409
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
1466
1410
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
1467
1411
|
const balances = useWalletsStore.use.balances();
|
|
1412
|
+
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
1468
1413
|
const navigate = reactRouterDom.useNavigate();
|
|
1469
1414
|
const {
|
|
1470
1415
|
t
|
|
@@ -1520,8 +1465,9 @@ function TokenInfo(props) {
|
|
|
1520
1465
|
variant: "outlined",
|
|
1521
1466
|
disabled: loadingStatus === 'failed',
|
|
1522
1467
|
loading: loadingStatus === 'loading',
|
|
1523
|
-
prefix: loadingStatus === 'success' && chain ? React__default.createElement(
|
|
1524
|
-
src: chain.logo
|
|
1468
|
+
prefix: loadingStatus === 'success' && chain ? React__default.createElement(ui.Image, {
|
|
1469
|
+
src: chain.logo,
|
|
1470
|
+
size: 24
|
|
1525
1471
|
}) : React__default.createElement(ImagePlaceholder, null),
|
|
1526
1472
|
suffix: ItemSuffix,
|
|
1527
1473
|
align: "start",
|
|
@@ -1536,8 +1482,9 @@ function TokenInfo(props) {
|
|
|
1536
1482
|
variant: "outlined",
|
|
1537
1483
|
disabled: loadingStatus === 'failed' || type === 'From' && !fromChain || type === 'To' && !toChain,
|
|
1538
1484
|
loading: loadingStatus === 'loading',
|
|
1539
|
-
prefix: loadingStatus === 'success' && token ? React__default.createElement(
|
|
1540
|
-
src: token.image
|
|
1485
|
+
prefix: loadingStatus === 'success' && token ? React__default.createElement(ui.Image, {
|
|
1486
|
+
src: token.image,
|
|
1487
|
+
size: 24
|
|
1541
1488
|
}) : React__default.createElement(ImagePlaceholder, null),
|
|
1542
1489
|
suffix: ItemSuffix,
|
|
1543
1490
|
size: "large",
|
|
@@ -1571,7 +1518,7 @@ function TokenInfo(props) {
|
|
|
1571
1518
|
} : undefined
|
|
1572
1519
|
}) : React__default.createElement(OutputContainer, null, React__default.createElement(ui.Typography, {
|
|
1573
1520
|
variant: "h4"
|
|
1574
|
-
},
|
|
1521
|
+
}, fetchingBestRoute && '?', !!bestRoute?.result && `≈ ${numberToString(props.outputAmount)}`, (!inputAmount || inputAmount === '0') && '0'))))));
|
|
1575
1522
|
}
|
|
1576
1523
|
|
|
1577
1524
|
const Container$1 = /*#__PURE__*/theme.styled('div', {
|
|
@@ -1682,7 +1629,8 @@ function HeaderButtons(props) {
|
|
|
1682
1629
|
onClick: onClickRefresh,
|
|
1683
1630
|
disabled: !onClickRefresh
|
|
1684
1631
|
}, React__default.createElement(ui.RetryIcon, {
|
|
1685
|
-
size: 24
|
|
1632
|
+
size: 24,
|
|
1633
|
+
disabled: !onClickRefresh
|
|
1686
1634
|
}))), React__default.createElement(ui.Tooltip, {
|
|
1687
1635
|
content: "Transactions History"
|
|
1688
1636
|
}, React__default.createElement(ui.Button, {
|
|
@@ -1722,10 +1670,7 @@ const Alerts = /*#__PURE__*/ui.styled('div', {
|
|
|
1722
1670
|
width: '100%',
|
|
1723
1671
|
paddingTop: '$16'
|
|
1724
1672
|
});
|
|
1725
|
-
function Home(
|
|
1726
|
-
const {
|
|
1727
|
-
title = 'SWAP'
|
|
1728
|
-
} = props;
|
|
1673
|
+
function Home() {
|
|
1729
1674
|
const isRouterInContext = reactRouterDom.useInRouterContext();
|
|
1730
1675
|
const navigate = reactRouterDom.useNavigate();
|
|
1731
1676
|
const [count, setCount] = React.useState(0);
|
|
@@ -1757,8 +1702,7 @@ function Home(props) {
|
|
|
1757
1702
|
swap
|
|
1758
1703
|
} = LimitErrorMessage(bestRoute);
|
|
1759
1704
|
const priceImpactCanNotBeComputed = !canComputePriceImpact(bestRoute, inputAmount, inputUsdValue, outputUsdValue);
|
|
1760
|
-
const
|
|
1761
|
-
const swapButtonState = getSwapButtonState(loadingMetaStatus, accounts, fetchingBestRoute, bestRoute, hasLimitError(bestRoute), highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputIsZero);
|
|
1705
|
+
const swapButtonState = getSwapButtonState(loadingMetaStatus, accounts, fetchingBestRoute, bestRoute, hasLimitError(bestRoute), highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputAmount);
|
|
1762
1706
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
1763
1707
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
1764
1708
|
React.useEffect(() => {
|
|
@@ -1766,7 +1710,7 @@ function Home(props) {
|
|
|
1766
1710
|
return setCurrentPage.bind(null, '');
|
|
1767
1711
|
}, []);
|
|
1768
1712
|
return React__default.createElement(Container$2, null, React__default.createElement(ui.Header, {
|
|
1769
|
-
title:
|
|
1713
|
+
title: "SWAP",
|
|
1770
1714
|
suffix: React__default.createElement(HeaderButtons, {
|
|
1771
1715
|
onClickRefresh: !!bestRoute ? fetchBestRoute : undefined
|
|
1772
1716
|
})
|
|
@@ -1827,8 +1771,7 @@ function Home(props) {
|
|
|
1827
1771
|
|
|
1828
1772
|
const Route = _ref => {
|
|
1829
1773
|
let {
|
|
1830
|
-
children
|
|
1831
|
-
...props
|
|
1774
|
+
children
|
|
1832
1775
|
} = _ref;
|
|
1833
1776
|
const location = reactRouter.useLocation();
|
|
1834
1777
|
const navigate = reactRouter.useNavigate();
|
|
@@ -1839,7 +1782,7 @@ const Route = _ref => {
|
|
|
1839
1782
|
});
|
|
1840
1783
|
ref.current = false;
|
|
1841
1784
|
}, []);
|
|
1842
|
-
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React__default.createElement(Home,
|
|
1785
|
+
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React__default.createElement(Home, null);
|
|
1843
1786
|
return React__default.createElement(React__default.Fragment, null, " ", children);
|
|
1844
1787
|
};
|
|
1845
1788
|
function AppRouter(_ref2) {
|
|
@@ -1933,10 +1876,6 @@ const Container$3 = /*#__PURE__*/ui.styled('div', {
|
|
|
1933
1876
|
}
|
|
1934
1877
|
}
|
|
1935
1878
|
});
|
|
1936
|
-
const StyledImage$1 = /*#__PURE__*/ui.styled('img', {
|
|
1937
|
-
width: '$24',
|
|
1938
|
-
maxHeight: '$24'
|
|
1939
|
-
});
|
|
1940
1879
|
const ImagePlaceholder$1 = /*#__PURE__*/ui.styled('span', {
|
|
1941
1880
|
width: '24px',
|
|
1942
1881
|
height: '24px',
|
|
@@ -1992,8 +1931,9 @@ function TokenPreview(props) {
|
|
|
1992
1931
|
className: "selectors",
|
|
1993
1932
|
variant: "outlined",
|
|
1994
1933
|
loading: loadingStatus === 'loading',
|
|
1995
|
-
prefix: loadingStatus === 'success' && chain ? React__default.createElement(
|
|
1996
|
-
src: chain.logo
|
|
1934
|
+
prefix: loadingStatus === 'success' && chain ? React__default.createElement(ui.Image, {
|
|
1935
|
+
src: chain.logo,
|
|
1936
|
+
size: 24
|
|
1997
1937
|
}) : React__default.createElement(ImagePlaceholder$1, null),
|
|
1998
1938
|
suffix: ItemSuffix,
|
|
1999
1939
|
align: "start",
|
|
@@ -2004,8 +1944,9 @@ function TokenPreview(props) {
|
|
|
2004
1944
|
className: "selectors",
|
|
2005
1945
|
variant: "outlined",
|
|
2006
1946
|
loading: loadingStatus === 'loading',
|
|
2007
|
-
prefix: loadingStatus === 'success' && token ? React__default.createElement(
|
|
2008
|
-
src: token.image
|
|
1947
|
+
prefix: loadingStatus === 'success' && token ? React__default.createElement(ui.Image, {
|
|
1948
|
+
src: token.image,
|
|
1949
|
+
size: 24
|
|
2009
1950
|
}) : React__default.createElement(ImagePlaceholder$1, null),
|
|
2010
1951
|
suffix: ItemSuffix,
|
|
2011
1952
|
size: "large",
|
|
@@ -2083,6 +2024,7 @@ function useConfirmSwap() {
|
|
|
2083
2024
|
const initialRoute = useBestRouteStore.use.bestRoute();
|
|
2084
2025
|
const setBestRoute = useBestRouteStore.use.setBestRoute();
|
|
2085
2026
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
2027
|
+
const affiliateRef = useSettingsStore.use.affiliateRef();
|
|
2086
2028
|
const accounts = useWalletsStore.use.accounts();
|
|
2087
2029
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
2088
2030
|
const meta = useMetaStore.use.meta();
|
|
@@ -2115,17 +2057,16 @@ function useConfirmSwap() {
|
|
|
2115
2057
|
if (warnings.length > 0) setWarnings([]);
|
|
2116
2058
|
proceedAnywayRef.current = false;
|
|
2117
2059
|
if (confiremedRouteRef.current) {
|
|
2118
|
-
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2119
|
-
//@ts-ignore
|
|
2060
|
+
const newSwap = queueManagerRangoPreset.calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2120
2061
|
return newSwap;
|
|
2121
2062
|
}
|
|
2122
2063
|
return;
|
|
2123
2064
|
}
|
|
2124
2065
|
abortControllerRef.current = new AbortController();
|
|
2125
2066
|
setLoading(true);
|
|
2126
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage,
|
|
2067
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, affiliateRef, initialRoute);
|
|
2127
2068
|
try {
|
|
2128
|
-
const confiremedRoute = await httpService.getBestRoute(requestBody, {
|
|
2069
|
+
const confiremedRoute = await httpService().getBestRoute(requestBody, {
|
|
2129
2070
|
signal: abortControllerRef.current?.signal
|
|
2130
2071
|
});
|
|
2131
2072
|
abortControllerRef.current = null;
|
|
@@ -2178,8 +2119,7 @@ function useConfirmSwap() {
|
|
|
2178
2119
|
slippage: userSlippage.toString(),
|
|
2179
2120
|
disabledSwappersGroups: disabledLiquiditySources
|
|
2180
2121
|
};
|
|
2181
|
-
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2182
|
-
//@ts-ignore
|
|
2122
|
+
const newSwap = queueManagerRangoPreset.calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2183
2123
|
return newSwap;
|
|
2184
2124
|
} else if (!proceedAnywayRef.current) {
|
|
2185
2125
|
proceedAnywayRef.current = true;
|
|
@@ -2367,6 +2307,7 @@ function ConfirmSwapPage() {
|
|
|
2367
2307
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
2368
2308
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
2369
2309
|
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
2310
|
+
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2370
2311
|
const bestRouteloadingStatus = getBestRouteStatus(fetchingBestRoute, !!fetchingBestRouteError);
|
|
2371
2312
|
const {
|
|
2372
2313
|
manager
|
|
@@ -2413,6 +2354,7 @@ function ConfirmSwapPage() {
|
|
|
2413
2354
|
navigate(navigationRoutes.swaps + `/${swap.requestId}`, {
|
|
2414
2355
|
replace: true
|
|
2415
2356
|
});
|
|
2357
|
+
setInputAmount('');
|
|
2416
2358
|
}
|
|
2417
2359
|
});
|
|
2418
2360
|
},
|
|
@@ -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
|
|