@rango-dev/widget-embedded 0.1.11-next.0 → 0.1.11-next.4
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/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/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/store/bestRoute.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 +26 -29
- package/dist/types/config.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +2 -6
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +87 -159
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +87 -159
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +86 -158
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +6 -4
- package/readme.md +1 -1
- package/src/App.tsx +21 -13
- package/src/components/AppRouter.tsx +7 -16
- package/src/components/AppRoutes.tsx +13 -32
- package/src/components/Layout.tsx +32 -23
- package/src/hooks/useConfirmSwap.ts +5 -4
- package/src/hooks/useTheme.ts +15 -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/store/bestRoute.ts +3 -2
- package/src/store/settings.ts +7 -0
- package/src/types/config.ts +27 -29
- package/src/utils/swap.ts +3 -96
|
@@ -1,7 +1,7 @@
|
|
|
1
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
2
|
import React, { useRef, useEffect, useState, useLayoutEffect } 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, swapQueueDef, checkWaitingForNetworkChange } from '@rango-dev/queue-manager-rango-preset';
|
|
4
|
+
import { PendingSwapNetworkStatus, useQueueManager, calculatePendingSwap, getCurrentStep, getCurrentBlockchainOfOrNull, getRelatedWalletOrNull, cancelSwap, swapQueueDef, 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,
|
|
@@ -813,6 +740,7 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*
|
|
|
813
740
|
slippage: DEFAULT_SLIPPAGE,
|
|
814
741
|
customSlippage: null,
|
|
815
742
|
infiniteApprove: false,
|
|
743
|
+
affiliateRef: null,
|
|
816
744
|
disabledLiquiditySources: [],
|
|
817
745
|
theme: 'auto',
|
|
818
746
|
setSlippage: slippage => set(() => ({
|
|
@@ -821,6 +749,9 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*
|
|
|
821
749
|
setCustomSlippage: customSlippage => set(() => ({
|
|
822
750
|
customSlippage: customSlippage
|
|
823
751
|
})),
|
|
752
|
+
setAffiliateRef: affiliateRef => set(() => ({
|
|
753
|
+
affiliateRef
|
|
754
|
+
})),
|
|
824
755
|
toggleAllLiquiditySources: () => set(state => {
|
|
825
756
|
const {
|
|
826
757
|
swappers
|
|
@@ -1099,13 +1030,14 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1099
1030
|
const {
|
|
1100
1031
|
slippage,
|
|
1101
1032
|
customSlippage,
|
|
1102
|
-
disabledLiquiditySources
|
|
1033
|
+
disabledLiquiditySources,
|
|
1034
|
+
affiliateRef
|
|
1103
1035
|
} = settingsStore.getState();
|
|
1104
1036
|
if (!fromToken || !toToken || !inputAmount || inputAmount === '0') return;
|
|
1105
1037
|
abortController?.abort();
|
|
1106
1038
|
abortController = new AbortController();
|
|
1107
1039
|
const userSlippage = !!customSlippage ? customSlippage : slippage;
|
|
1108
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false);
|
|
1040
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false, affiliateRef);
|
|
1109
1041
|
if (!bestRouteStore.getState().loading) bestRouteStore.setState({
|
|
1110
1042
|
loading: true,
|
|
1111
1043
|
bestRoute: null,
|
|
@@ -1713,10 +1645,7 @@ const Alerts = /*#__PURE__*/styled('div', {
|
|
|
1713
1645
|
width: '100%',
|
|
1714
1646
|
paddingTop: '$16'
|
|
1715
1647
|
});
|
|
1716
|
-
function Home(
|
|
1717
|
-
const {
|
|
1718
|
-
title = 'SWAP'
|
|
1719
|
-
} = props;
|
|
1648
|
+
function Home() {
|
|
1720
1649
|
const isRouterInContext = useInRouterContext();
|
|
1721
1650
|
const navigate = useNavigate();
|
|
1722
1651
|
const [count, setCount] = useState(0);
|
|
@@ -1757,7 +1686,7 @@ function Home(props) {
|
|
|
1757
1686
|
return setCurrentPage.bind(null, '');
|
|
1758
1687
|
}, []);
|
|
1759
1688
|
return React.createElement(Container$2, null, React.createElement(Header$1, {
|
|
1760
|
-
title:
|
|
1689
|
+
title: "SWAP",
|
|
1761
1690
|
suffix: React.createElement(HeaderButtons, {
|
|
1762
1691
|
onClickRefresh: !!bestRoute ? fetchBestRoute : undefined
|
|
1763
1692
|
})
|
|
@@ -1818,8 +1747,7 @@ function Home(props) {
|
|
|
1818
1747
|
|
|
1819
1748
|
const Route = _ref => {
|
|
1820
1749
|
let {
|
|
1821
|
-
children
|
|
1822
|
-
...props
|
|
1750
|
+
children
|
|
1823
1751
|
} = _ref;
|
|
1824
1752
|
const location = useLocation$1();
|
|
1825
1753
|
const navigate = useNavigate$1();
|
|
@@ -1830,7 +1758,7 @@ const Route = _ref => {
|
|
|
1830
1758
|
});
|
|
1831
1759
|
ref.current = false;
|
|
1832
1760
|
}, []);
|
|
1833
|
-
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React.createElement(Home,
|
|
1761
|
+
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React.createElement(Home, null);
|
|
1834
1762
|
return React.createElement(React.Fragment, null, " ", children);
|
|
1835
1763
|
};
|
|
1836
1764
|
function AppRouter(_ref2) {
|
|
@@ -2074,6 +2002,7 @@ function useConfirmSwap() {
|
|
|
2074
2002
|
const initialRoute = useBestRouteStore.use.bestRoute();
|
|
2075
2003
|
const setBestRoute = useBestRouteStore.use.setBestRoute();
|
|
2076
2004
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
2005
|
+
const affiliateRef = useSettingsStore.use.affiliateRef();
|
|
2077
2006
|
const accounts = useWalletsStore.use.accounts();
|
|
2078
2007
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
2079
2008
|
const meta = useMetaStore.use.meta();
|
|
@@ -2107,14 +2036,13 @@ function useConfirmSwap() {
|
|
|
2107
2036
|
proceedAnywayRef.current = false;
|
|
2108
2037
|
if (confiremedRouteRef.current) {
|
|
2109
2038
|
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2110
|
-
//@ts-ignore
|
|
2111
2039
|
return newSwap;
|
|
2112
2040
|
}
|
|
2113
2041
|
return;
|
|
2114
2042
|
}
|
|
2115
2043
|
abortControllerRef.current = new AbortController();
|
|
2116
2044
|
setLoading(true);
|
|
2117
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true);
|
|
2045
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true, affiliateRef);
|
|
2118
2046
|
try {
|
|
2119
2047
|
const confiremedRoute = await httpService.getBestRoute(requestBody, {
|
|
2120
2048
|
signal: abortControllerRef.current?.signal
|
|
@@ -2170,7 +2098,6 @@ function useConfirmSwap() {
|
|
|
2170
2098
|
disabledSwappersGroups: disabledLiquiditySources
|
|
2171
2099
|
};
|
|
2172
2100
|
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2173
|
-
//@ts-ignore
|
|
2174
2101
|
return newSwap;
|
|
2175
2102
|
} else if (!proceedAnywayRef.current) {
|
|
2176
2103
|
proceedAnywayRef.current = true;
|
|
@@ -2388,7 +2315,10 @@ function ConfirmSwapPage() {
|
|
|
2388
2315
|
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
2389
2316
|
};
|
|
2390
2317
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
2391
|
-
return React.createElement(ConfirmSwap
|
|
2318
|
+
return React.createElement(ConfirmSwap
|
|
2319
|
+
// @ts-ignore
|
|
2320
|
+
, {
|
|
2321
|
+
// @ts-ignore
|
|
2392
2322
|
requiredWallets: getRequiredChains(bestRoute),
|
|
2393
2323
|
selectableWallets: selectableWallets,
|
|
2394
2324
|
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
@@ -2397,7 +2327,9 @@ function ConfirmSwapPage() {
|
|
|
2397
2327
|
if (swap) {
|
|
2398
2328
|
manager?.create('swap', {
|
|
2399
2329
|
swapDetails: swap
|
|
2400
|
-
},
|
|
2330
|
+
},
|
|
2331
|
+
// @ts-ignore
|
|
2332
|
+
{
|
|
2401
2333
|
id: swap.requestId
|
|
2402
2334
|
});
|
|
2403
2335
|
setSelectedSwap(swap.requestId);
|
|
@@ -2555,7 +2487,7 @@ function LiquiditySourcePage(_ref) {
|
|
|
2555
2487
|
});
|
|
2556
2488
|
return React.createElement(LiquiditySourcesSelector, {
|
|
2557
2489
|
toggleAll: toggleAllLiquiditySources,
|
|
2558
|
-
list: supportedSwappers
|
|
2490
|
+
list: supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups,
|
|
2559
2491
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
2560
2492
|
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources),
|
|
2561
2493
|
loadingStatus: loadingMetaStatus
|
|
@@ -2567,7 +2499,7 @@ function SelectChainPage(props) {
|
|
|
2567
2499
|
type,
|
|
2568
2500
|
supportedChains
|
|
2569
2501
|
} = props;
|
|
2570
|
-
const blockchains = supportedChains
|
|
2502
|
+
const blockchains = supportedChains ? useMetaStore.use.meta().blockchains.filter(chain => supportedChains.includes(chain.name)) : useMetaStore.use.meta().blockchains;
|
|
2571
2503
|
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
2572
2504
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
2573
2505
|
const toChain = useBestRouteStore.use.toChain();
|
|
@@ -2599,8 +2531,8 @@ function SelectTokenPage(props) {
|
|
|
2599
2531
|
} = props;
|
|
2600
2532
|
const sourceTokens = useBestRouteStore.use.sourceTokens();
|
|
2601
2533
|
const destinationTokens = useBestRouteStore.use.destinationTokens();
|
|
2602
|
-
const supportedSourceTokens = supportedTokens
|
|
2603
|
-
const supportedDestinationTokens = supportedTokens
|
|
2534
|
+
const supportedSourceTokens = supportedTokens ? sourceTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : sourceTokens;
|
|
2535
|
+
const supportedDestinationTokens = supportedTokens ? destinationTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : destinationTokens;
|
|
2604
2536
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
2605
2537
|
const toToken = useBestRouteStore.use.toToken();
|
|
2606
2538
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
@@ -2653,8 +2585,8 @@ function SettingsPage(_ref) {
|
|
|
2653
2585
|
}
|
|
2654
2586
|
}
|
|
2655
2587
|
});
|
|
2656
|
-
supportedSwappers
|
|
2657
|
-
const supportedUniqueSwappersGroups = supportedSwappers
|
|
2588
|
+
supportedSwappers && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0);
|
|
2589
|
+
const supportedUniqueSwappersGroups = supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups;
|
|
2658
2590
|
return React.createElement(Settings, {
|
|
2659
2591
|
slippages: SLIPPAGES,
|
|
2660
2592
|
selectedSlippage: slippage,
|
|
@@ -2707,7 +2639,7 @@ function WalletsPage(_ref) {
|
|
|
2707
2639
|
getWalletInfo,
|
|
2708
2640
|
connect
|
|
2709
2641
|
} = useWallets();
|
|
2710
|
-
const wallets = getlistWallet(state, getWalletInfo, supportedWallets
|
|
2642
|
+
const wallets = getlistWallet(state, getWalletInfo, supportedWallets || Object.values(WalletType));
|
|
2711
2643
|
const walletsRef = useRef();
|
|
2712
2644
|
let sortedWallets = detectMobileScreens() ? wallets.filter(wallet => wallet.showOnMobile) : wallets;
|
|
2713
2645
|
sortedWallets = sortWalletsBasedOnState(sortedWallets);
|
|
@@ -2916,7 +2848,7 @@ function SwapDetailsPage() {
|
|
|
2916
2848
|
}), React.createElement(TokenPreview, {
|
|
2917
2849
|
chain: {
|
|
2918
2850
|
displayName: lastStep?.toBlockchain || '',
|
|
2919
|
-
|
|
2851
|
+
//@ts-ignore
|
|
2920
2852
|
logo: lastStep?.toBlockchainLogo || ''
|
|
2921
2853
|
},
|
|
2922
2854
|
token: {
|
|
@@ -2928,7 +2860,6 @@ function SwapDetailsPage() {
|
|
|
2928
2860
|
loadingStatus: 'success'
|
|
2929
2861
|
})),
|
|
2930
2862
|
//todo: move PendingSwap type to rango-types
|
|
2931
|
-
//@ts-ignore
|
|
2932
2863
|
pendingSwap: swap,
|
|
2933
2864
|
onCopy: handleCopy,
|
|
2934
2865
|
isCopied: isCopied,
|
|
@@ -2958,48 +2889,44 @@ function SwapDetailsPage() {
|
|
|
2958
2889
|
const getAbsolutePath = path => path.replace('/', '');
|
|
2959
2890
|
function AppRoutes(props) {
|
|
2960
2891
|
const {
|
|
2961
|
-
|
|
2892
|
+
config
|
|
2962
2893
|
} = props;
|
|
2963
2894
|
return useRoutes([{
|
|
2964
2895
|
path: getAbsolutePath(navigationRoutes.home),
|
|
2965
|
-
element: React.createElement(Home,
|
|
2966
|
-
title: configs?.title,
|
|
2967
|
-
titleSize: configs?.titleSize,
|
|
2968
|
-
titleWeight: configs?.titleWeight
|
|
2969
|
-
})
|
|
2896
|
+
element: React.createElement(Home, null)
|
|
2970
2897
|
}, {
|
|
2971
2898
|
path: getAbsolutePath(navigationRoutes.fromChain),
|
|
2972
2899
|
element: React.createElement(SelectChainPage, {
|
|
2973
2900
|
type: "from",
|
|
2974
|
-
supportedChains:
|
|
2901
|
+
supportedChains: config?.from?.blockchains
|
|
2975
2902
|
})
|
|
2976
2903
|
}, {
|
|
2977
2904
|
path: getAbsolutePath(navigationRoutes.toChain),
|
|
2978
2905
|
element: React.createElement(SelectChainPage, {
|
|
2979
2906
|
type: "to",
|
|
2980
|
-
supportedChains:
|
|
2907
|
+
supportedChains: config?.to?.blockchains
|
|
2981
2908
|
})
|
|
2982
2909
|
}, {
|
|
2983
2910
|
path: getAbsolutePath(navigationRoutes.fromToken),
|
|
2984
2911
|
element: React.createElement(SelectTokenPage, {
|
|
2985
2912
|
type: "from",
|
|
2986
|
-
supportedTokens:
|
|
2913
|
+
supportedTokens: config?.from?.tokens
|
|
2987
2914
|
})
|
|
2988
2915
|
}, {
|
|
2989
2916
|
path: getAbsolutePath(navigationRoutes.toToken),
|
|
2990
2917
|
element: React.createElement(SelectTokenPage, {
|
|
2991
2918
|
type: "to",
|
|
2992
|
-
supportedTokens:
|
|
2919
|
+
supportedTokens: config?.to?.tokens
|
|
2993
2920
|
})
|
|
2994
2921
|
}, {
|
|
2995
2922
|
path: getAbsolutePath(navigationRoutes.settings),
|
|
2996
2923
|
element: React.createElement(SettingsPage, {
|
|
2997
|
-
supportedSwappers:
|
|
2924
|
+
supportedSwappers: config?.liquiditySources
|
|
2998
2925
|
})
|
|
2999
2926
|
}, {
|
|
3000
2927
|
path: getAbsolutePath(navigationRoutes.liquiditySources),
|
|
3001
2928
|
element: React.createElement(LiquiditySourcePage, {
|
|
3002
|
-
supportedSwappers:
|
|
2929
|
+
supportedSwappers: config?.liquiditySources
|
|
3003
2930
|
})
|
|
3004
2931
|
}, {
|
|
3005
2932
|
path: getAbsolutePath(navigationRoutes.swaps),
|
|
@@ -3010,8 +2937,8 @@ function AppRoutes(props) {
|
|
|
3010
2937
|
}, {
|
|
3011
2938
|
path: getAbsolutePath(navigationRoutes.wallets),
|
|
3012
2939
|
element: React.createElement(WalletsPage, {
|
|
3013
|
-
supportedWallets:
|
|
3014
|
-
multiWallets: typeof
|
|
2940
|
+
supportedWallets: config?.wallets,
|
|
2941
|
+
multiWallets: typeof config?.multiWallets === 'undefined' ? true : config.multiWallets
|
|
3015
2942
|
})
|
|
3016
2943
|
}, {
|
|
3017
2944
|
path: getAbsolutePath(navigationRoutes.confirmSwap),
|
|
@@ -3036,7 +2963,7 @@ const WalletImage = /*#__PURE__*/styled('img', {
|
|
|
3036
2963
|
});
|
|
3037
2964
|
function Layout(_ref) {
|
|
3038
2965
|
let {
|
|
3039
|
-
|
|
2966
|
+
config
|
|
3040
2967
|
} = _ref;
|
|
3041
2968
|
const navigate = useNavigate();
|
|
3042
2969
|
const {
|
|
@@ -3048,11 +2975,16 @@ function Layout(_ref) {
|
|
|
3048
2975
|
getWalletInfo
|
|
3049
2976
|
} = useWallets();
|
|
3050
2977
|
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(accounts, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2978
|
+
const {
|
|
2979
|
+
blockchains,
|
|
2980
|
+
tokens
|
|
2981
|
+
} = useMetaStore.use.meta();
|
|
3051
2982
|
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
3052
2983
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
3053
2984
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
3054
2985
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
3055
2986
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2987
|
+
const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
|
|
3056
2988
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
3057
2989
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
3058
2990
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
@@ -3061,22 +2993,23 @@ function Layout(_ref) {
|
|
|
3061
2993
|
t
|
|
3062
2994
|
} = useTranslation();
|
|
3063
2995
|
useEffect(() => {
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
2996
|
+
const chain = blockchains.find(chain => chain.name === config?.to?.blockchain);
|
|
2997
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.to?.token || null));
|
|
2998
|
+
setToChain(chain || null);
|
|
2999
|
+
setToToken(token || null);
|
|
3000
|
+
}, [config?.to?.token, config?.to?.blockchain]);
|
|
3067
3001
|
useEffect(() => {
|
|
3068
|
-
setInputAmount(
|
|
3069
|
-
}, [
|
|
3002
|
+
setInputAmount(config?.amount?.toString() || '');
|
|
3003
|
+
}, [config?.amount]);
|
|
3070
3004
|
useEffect(() => {
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3005
|
+
const chain = blockchains.find(chain => chain.name === config?.from?.blockchain);
|
|
3006
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.from?.token || null));
|
|
3007
|
+
setFromChain(chain || null);
|
|
3008
|
+
setFromToken(token || null);
|
|
3009
|
+
}, [config?.from?.token, config?.from?.blockchain]);
|
|
3074
3010
|
useEffect(() => {
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
setFromToken(null);
|
|
3078
|
-
setToToken(null);
|
|
3079
|
-
}, [configs?.fromChains, configs?.toChains, configs?.fromTokens, configs?.toTokens]);
|
|
3011
|
+
setAffiliateRef(config?.affiliateRef || null);
|
|
3012
|
+
}, [config?.affiliateRef]);
|
|
3080
3013
|
return React.createElement(React.Fragment, null, React.createElement(Header, null, React.createElement(Button, {
|
|
3081
3014
|
size: "small",
|
|
3082
3015
|
suffix: React.createElement(AddWalletIcon, {
|
|
@@ -3097,7 +3030,7 @@ function Layout(_ref) {
|
|
|
3097
3030
|
}, React.createElement(Typography, {
|
|
3098
3031
|
variant: "body2"
|
|
3099
3032
|
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React.createElement(Spinner, null)))), React.createElement(AppRoutes, {
|
|
3100
|
-
|
|
3033
|
+
config: config
|
|
3101
3034
|
}));
|
|
3102
3035
|
}
|
|
3103
3036
|
|
|
@@ -3140,17 +3073,20 @@ function usePrevious(value) {
|
|
|
3140
3073
|
|
|
3141
3074
|
function useTheme(_ref) {
|
|
3142
3075
|
let {
|
|
3143
|
-
|
|
3144
|
-
background = '#fff',
|
|
3145
|
-
foreground = '#000',
|
|
3146
|
-
error = '#FF0000',
|
|
3147
|
-
warning = '#F5A623',
|
|
3148
|
-
success = '#0070F3',
|
|
3076
|
+
colors: themeColors,
|
|
3149
3077
|
fontFamily = 'Robot',
|
|
3150
|
-
borderRadius = 8
|
|
3078
|
+
borderRadius = 8,
|
|
3079
|
+
mode = 'auto'
|
|
3151
3080
|
} = _ref;
|
|
3152
3081
|
const theme = useSettingsStore.use.theme();
|
|
3153
3082
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
3083
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
3084
|
+
const primary = themeColors?.primary || '#5FA425',
|
|
3085
|
+
background = themeColors?.background || '#fff',
|
|
3086
|
+
foreground = themeColors?.foreground || '#000',
|
|
3087
|
+
error = themeColors?.error || '#FF0000',
|
|
3088
|
+
warning = themeColors?.warning || '#F5A623',
|
|
3089
|
+
success = themeColors?.success || '#0070F3';
|
|
3154
3090
|
const colors = {
|
|
3155
3091
|
neutrals200: '#FAFAFA',
|
|
3156
3092
|
neutrals300: '#f2f2f2',
|
|
@@ -3228,6 +3164,9 @@ function useTheme(_ref) {
|
|
|
3228
3164
|
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', switchTheme);
|
|
3229
3165
|
};
|
|
3230
3166
|
}, []);
|
|
3167
|
+
useEffect(() => {
|
|
3168
|
+
if (mode !== 'auto') setTheme(mode);
|
|
3169
|
+
}, [mode]);
|
|
3231
3170
|
const prevFont = usePrevious(fontFamily);
|
|
3232
3171
|
useLayoutEffect(() => {
|
|
3233
3172
|
const {
|
|
@@ -3392,29 +3331,27 @@ function QueueManager(props) {
|
|
|
3392
3331
|
|
|
3393
3332
|
const SwapBox = _ref => {
|
|
3394
3333
|
let {
|
|
3395
|
-
|
|
3334
|
+
config
|
|
3396
3335
|
} = _ref;
|
|
3397
3336
|
globalStyles();
|
|
3398
|
-
globalFont(
|
|
3337
|
+
globalFont(config?.theme?.fontFamily || 'Roboto');
|
|
3399
3338
|
const {
|
|
3400
3339
|
activeTheme
|
|
3401
3340
|
} = useTheme({
|
|
3402
|
-
...
|
|
3403
|
-
borderRadius: configs?.borderRadius,
|
|
3404
|
-
fontFamily: configs?.fontFamily
|
|
3341
|
+
...config?.theme
|
|
3405
3342
|
});
|
|
3406
3343
|
const {
|
|
3407
3344
|
blockchains
|
|
3408
3345
|
} = useMetaStore.use.meta();
|
|
3409
3346
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
3410
3347
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
3411
|
-
const setTheme = useSettingsStore.use.setTheme();
|
|
3412
3348
|
const {
|
|
3413
3349
|
changeLanguage
|
|
3414
3350
|
} = useSelectLanguage();
|
|
3415
3351
|
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
3416
3352
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] = useState('');
|
|
3417
3353
|
const [disconnectedWallet, setDisconnectedWallet] = useState();
|
|
3354
|
+
const currentPage = useUiStore.use.currentPage();
|
|
3418
3355
|
const evmBasedChainNames = blockchains.filter(isEvmBlockchain$1).map(chain => chain.name);
|
|
3419
3356
|
const onUpdateState = (type, event, value, state, supportedChains) => {
|
|
3420
3357
|
if (event === Events.ACCOUNTS) {
|
|
@@ -3439,19 +3376,16 @@ const SwapBox = _ref => {
|
|
|
3439
3376
|
};
|
|
3440
3377
|
let providers = allProviders();
|
|
3441
3378
|
useEffect(() => {
|
|
3442
|
-
|
|
3443
|
-
}, [configs.theme]);
|
|
3444
|
-
useEffect(() => {
|
|
3445
|
-
const wallets = configs.wallets;
|
|
3379
|
+
const wallets = config?.wallets;
|
|
3446
3380
|
clearConnectedWallet();
|
|
3447
|
-
providers = wallets
|
|
3381
|
+
providers = !wallets ? allProviders() : allProviders().filter(provider => {
|
|
3448
3382
|
const type = provider.config.type;
|
|
3449
3383
|
return wallets.find(w => w === type);
|
|
3450
3384
|
});
|
|
3451
|
-
}, [
|
|
3385
|
+
}, [config?.wallets]);
|
|
3452
3386
|
useEffect(() => {
|
|
3453
|
-
changeLanguage(
|
|
3454
|
-
}, [
|
|
3387
|
+
changeLanguage(config?.language || 'en');
|
|
3388
|
+
}, [config?.language]);
|
|
3455
3389
|
return React.createElement(Provider$1, {
|
|
3456
3390
|
allBlockChains: blockchains,
|
|
3457
3391
|
providers: providers,
|
|
@@ -3460,21 +3394,15 @@ const SwapBox = _ref => {
|
|
|
3460
3394
|
id: "pageContainer",
|
|
3461
3395
|
className: activeTheme
|
|
3462
3396
|
}, React.createElement(QueueManager, null, React.createElement(SwapContainer, {
|
|
3463
|
-
|
|
3464
|
-
width: configs?.width || 'auto',
|
|
3465
|
-
height: configs?.height || 'auto'
|
|
3466
|
-
}
|
|
3397
|
+
fixedHeight: currentPage !== navigationRoutes.home
|
|
3467
3398
|
}, React.createElement(AppRouter, {
|
|
3468
|
-
title: configs.title,
|
|
3469
|
-
titleSize: configs.titleSize,
|
|
3470
|
-
titleWeight: configs.titleWeight,
|
|
3471
3399
|
lastConnectedWallet: lastConnectedWalletWithNetwork,
|
|
3472
3400
|
disconnectedWallet: disconnectedWallet,
|
|
3473
3401
|
clearDisconnectedWallet: () => {
|
|
3474
3402
|
setDisconnectedWallet(undefined);
|
|
3475
3403
|
}
|
|
3476
3404
|
}, React.createElement(Layout, {
|
|
3477
|
-
|
|
3405
|
+
config: config
|
|
3478
3406
|
}))))));
|
|
3479
3407
|
};
|
|
3480
3408
|
|