@rango-dev/widget-embedded 0.1.10 → 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/components/PercentageChange.d.ts +9 -0
- package/dist/components/PercentageChange.d.ts.map +1 -0
- package/dist/components/TokenInfo.d.ts.map +1 -1
- package/dist/components/TokenPreview.d.ts +2 -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/store/bestRoute.d.ts +1 -0
- 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/types/routing.d.ts +14 -1
- package/dist/types/routing.d.ts.map +1 -1
- package/dist/utils/routing.d.ts +2 -2
- package/dist/utils/routing.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 +181 -193
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +181 -193
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +181 -193
- 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/components/PercentageChange.tsx +33 -0
- package/src/components/TokenInfo.tsx +20 -4
- package/src/components/TokenPreview.tsx +16 -8
- 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 +14 -7
- package/src/pages/Home.tsx +10 -22
- 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 +38 -8
- package/src/store/settings.ts +7 -0
- package/src/types/config.ts +27 -29
- package/src/types/routing.ts +17 -1
- package/src/utils/routing.ts +29 -23
- package/src/utils/swap.ts +5 -97
|
@@ -445,7 +445,7 @@ function getSwapButtonState(loadingMetaStatus, accounts, loading, bestRoute, has
|
|
|
445
445
|
};else if (inputIsZero) return {
|
|
446
446
|
title: 'Enter an amount',
|
|
447
447
|
disabled: true
|
|
448
|
-
};else if (!bestRoute) return {
|
|
448
|
+
};else if (!bestRoute || !bestRoute.result) return {
|
|
449
449
|
title: 'Swap',
|
|
450
450
|
disabled: true
|
|
451
451
|
};else if (hasLimitError) 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, checkPrerequisites) {
|
|
514
|
+
function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, selectedWallets, disabledLiquiditySources, slippage, checkPrerequisites, affiliateRef) {
|
|
589
515
|
const selectedWalletsMap = selectedWallets.reduce((selectedWalletsMap, selectedWallet) => (selectedWalletsMap[selectedWallet.chain] = selectedWallet.address, selectedWalletsMap), {});
|
|
590
516
|
const connectedWallets = [];
|
|
591
517
|
wallets.forEach(wallet => {
|
|
@@ -598,6 +524,7 @@ function createBestRouteRequestBody(fromToken, toToken, inputAmount, wallets, se
|
|
|
598
524
|
const filteredBlockchains = selectedWallets.map(wallet => wallet.chain);
|
|
599
525
|
const requestBody = {
|
|
600
526
|
amount: inputAmount.toString(),
|
|
527
|
+
affiliateRef,
|
|
601
528
|
checkPrerequisites,
|
|
602
529
|
from: {
|
|
603
530
|
address: fromToken.address,
|
|
@@ -753,8 +680,21 @@ function getRequiredBalanceOfWallet(selectedWallet, fee) {
|
|
|
753
680
|
if (!relatedFeeStatus) return null;
|
|
754
681
|
return relatedFeeStatus.requiredAssets;
|
|
755
682
|
}
|
|
756
|
-
function isRouteParametersChanged(
|
|
757
|
-
|
|
683
|
+
function isRouteParametersChanged(params) {
|
|
684
|
+
if (params.store === 'bestRoute') {
|
|
685
|
+
const {
|
|
686
|
+
prevState,
|
|
687
|
+
currentState
|
|
688
|
+
} = params;
|
|
689
|
+
return !!currentState.fromToken && !!currentState.toToken && (prevState.fromChain?.name !== currentState.fromChain?.name || prevState.toChain?.name !== currentState.toChain?.name || prevState.fromToken?.symbol !== currentState.fromToken?.symbol || prevState.toToken?.symbol !== currentState.toToken?.symbol || prevState.fromToken?.blockchain !== prevState.fromToken?.blockchain || prevState.toToken?.blockchain !== currentState.toToken?.blockchain || prevState.fromToken?.address !== currentState.fromToken?.address || prevState.toToken?.address !== currentState.toToken?.address || prevState.inputAmount !== currentState.inputAmount);
|
|
690
|
+
} else if (params.store === 'settings') {
|
|
691
|
+
const {
|
|
692
|
+
prevState,
|
|
693
|
+
currentState
|
|
694
|
+
} = params;
|
|
695
|
+
return prevState.slippage !== currentState.slippage || prevState.customSlippage !== currentState.customSlippage || prevState.disabledLiquiditySources?.length !== currentState.disabledLiquiditySources?.length || prevState.infiniteApprove || currentState.infiniteApprove;
|
|
696
|
+
}
|
|
697
|
+
return false;
|
|
758
698
|
}
|
|
759
699
|
//todo: refactor bestRoute store and add loadingStatus
|
|
760
700
|
const getBestRouteStatus = (loading, error) => {
|
|
@@ -809,6 +749,7 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.crea
|
|
|
809
749
|
slippage: DEFAULT_SLIPPAGE,
|
|
810
750
|
customSlippage: null,
|
|
811
751
|
infiniteApprove: false,
|
|
752
|
+
affiliateRef: null,
|
|
812
753
|
disabledLiquiditySources: [],
|
|
813
754
|
theme: 'auto',
|
|
814
755
|
setSlippage: slippage => set(() => ({
|
|
@@ -817,6 +758,9 @@ const useSettingsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.crea
|
|
|
817
758
|
setCustomSlippage: customSlippage => set(() => ({
|
|
818
759
|
customSlippage: customSlippage
|
|
819
760
|
})),
|
|
761
|
+
setAffiliateRef: affiliateRef => set(() => ({
|
|
762
|
+
affiliateRef
|
|
763
|
+
})),
|
|
820
764
|
toggleAllLiquiditySources: () => set(state => {
|
|
821
765
|
const {
|
|
822
766
|
swappers
|
|
@@ -1020,7 +964,6 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.cre
|
|
|
1020
964
|
toToken: token
|
|
1021
965
|
})),
|
|
1022
966
|
setInputAmount: amount => {
|
|
1023
|
-
console.log(amount, typeof amount);
|
|
1024
967
|
set(state => ({
|
|
1025
968
|
inputAmount: amount,
|
|
1026
969
|
...(!amount && {
|
|
@@ -1073,7 +1016,17 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/zustand.cre
|
|
|
1073
1016
|
sourceTokens: sortedSourceTokens,
|
|
1074
1017
|
destinationTokens: sortedDestinationTokens
|
|
1075
1018
|
});
|
|
1076
|
-
}
|
|
1019
|
+
},
|
|
1020
|
+
switchFromAndTo: () => set(state => ({
|
|
1021
|
+
fromChain: state.toChain,
|
|
1022
|
+
fromToken: state.toToken,
|
|
1023
|
+
toChain: state.fromChain,
|
|
1024
|
+
toToken: state.fromToken,
|
|
1025
|
+
sourceTokens: state.destinationTokens,
|
|
1026
|
+
destinationTokens: state.sourceTokens,
|
|
1027
|
+
inputAmount: state.outputAmount?.toString() || '',
|
|
1028
|
+
inputUsdValue: getUsdValue(state.toToken, state.outputAmount?.toString() || '')
|
|
1029
|
+
}))
|
|
1077
1030
|
}))));
|
|
1078
1031
|
const bestRoute = (bestRouteStore, settingsStore) => {
|
|
1079
1032
|
let abortController = null;
|
|
@@ -1086,13 +1039,14 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1086
1039
|
const {
|
|
1087
1040
|
slippage,
|
|
1088
1041
|
customSlippage,
|
|
1089
|
-
disabledLiquiditySources
|
|
1042
|
+
disabledLiquiditySources,
|
|
1043
|
+
affiliateRef
|
|
1090
1044
|
} = settingsStore.getState();
|
|
1091
1045
|
if (!fromToken || !toToken || !inputAmount || inputAmount === '0') return;
|
|
1092
1046
|
abortController?.abort();
|
|
1093
1047
|
abortController = new AbortController();
|
|
1094
1048
|
const userSlippage = !!customSlippage ? customSlippage : slippage;
|
|
1095
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false);
|
|
1049
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, [], [], disabledLiquiditySources, userSlippage, false, affiliateRef);
|
|
1096
1050
|
if (!bestRouteStore.getState().loading) bestRouteStore.setState({
|
|
1097
1051
|
loading: true,
|
|
1098
1052
|
bestRoute: null,
|
|
@@ -1126,7 +1080,7 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1126
1080
|
inputAmount,
|
|
1127
1081
|
inputUsdValue
|
|
1128
1082
|
} = useBestRouteStore.getState();
|
|
1129
|
-
if (!inputAmount || inputAmount === '0') return;
|
|
1083
|
+
if (!inputAmount || inputAmount === '0' || inputUsdValue.eq(0)) return;
|
|
1130
1084
|
if (tokensAreEqual(fromToken, toToken)) return bestRouteStore.setState({
|
|
1131
1085
|
loading: false,
|
|
1132
1086
|
bestRoute: null,
|
|
@@ -1148,17 +1102,26 @@ const bestRoute = (bestRouteStore, settingsStore) => {
|
|
|
1148
1102
|
toToken: state.toToken,
|
|
1149
1103
|
inputAmount: state.inputAmount
|
|
1150
1104
|
}), bestRouteParamsListener, {
|
|
1151
|
-
equalityFn: (prevState,
|
|
1152
|
-
if (isRouteParametersChanged(
|
|
1105
|
+
equalityFn: (prevState, currentState) => {
|
|
1106
|
+
if (isRouteParametersChanged({
|
|
1107
|
+
store: 'bestRoute',
|
|
1108
|
+
prevState,
|
|
1109
|
+
currentState
|
|
1110
|
+
})) return false;else return true;
|
|
1153
1111
|
}
|
|
1154
1112
|
});
|
|
1155
1113
|
useSettingsStore.subscribe(state => ({
|
|
1156
1114
|
slippage: state.slippage,
|
|
1157
1115
|
customSlippage: state.customSlippage,
|
|
1158
|
-
disabledLiquiditySources: state.disabledLiquiditySources
|
|
1116
|
+
disabledLiquiditySources: state.disabledLiquiditySources,
|
|
1117
|
+
infiniteApprove: state.infiniteApprove
|
|
1159
1118
|
}), bestRouteParamsListener, {
|
|
1160
|
-
equalityFn: (prevState,
|
|
1161
|
-
if (isRouteParametersChanged(
|
|
1119
|
+
equalityFn: (prevState, currentState) => {
|
|
1120
|
+
if (isRouteParametersChanged({
|
|
1121
|
+
store: 'settings',
|
|
1122
|
+
prevState,
|
|
1123
|
+
currentState
|
|
1124
|
+
})) return false;else return true;
|
|
1162
1125
|
}
|
|
1163
1126
|
});
|
|
1164
1127
|
return {
|
|
@@ -1323,6 +1286,20 @@ function UpdateUrl() {
|
|
|
1323
1286
|
return null;
|
|
1324
1287
|
}
|
|
1325
1288
|
|
|
1289
|
+
function PercentageChange(props) {
|
|
1290
|
+
const {
|
|
1291
|
+
inputUsdValue,
|
|
1292
|
+
outputUsdValue
|
|
1293
|
+
} = props;
|
|
1294
|
+
if (!inputUsdValue || !outputUsdValue || !outputUsdValue.gt(0)) return null;
|
|
1295
|
+
const percentageChange = getPercentageChange(inputUsdValue.toNumber(), outputUsdValue.toNumber());
|
|
1296
|
+
const showPercentageChange = percentageChange?.lt(0);
|
|
1297
|
+
return React__default.createElement(React__default.Fragment, null, showPercentageChange && React__default.createElement(ui.Typography, {
|
|
1298
|
+
variant: "caption",
|
|
1299
|
+
color: "$error500"
|
|
1300
|
+
}, `(${numberToString(percentageChange, 0, 2)}%)`));
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1326
1303
|
const Box = /*#__PURE__*/ui.styled('div', {
|
|
1327
1304
|
display: 'flex',
|
|
1328
1305
|
flexDirection: 'column',
|
|
@@ -1366,6 +1343,13 @@ const Container = /*#__PURE__*/ui.styled('div', {
|
|
|
1366
1343
|
'.amount': {
|
|
1367
1344
|
width: '30%'
|
|
1368
1345
|
}
|
|
1346
|
+
},
|
|
1347
|
+
'.output-usd': {
|
|
1348
|
+
display: 'flex',
|
|
1349
|
+
div: {
|
|
1350
|
+
display: 'flex',
|
|
1351
|
+
paddingLeft: '$8'
|
|
1352
|
+
}
|
|
1369
1353
|
}
|
|
1370
1354
|
});
|
|
1371
1355
|
const StyledImage = /*#__PURE__*/ui.styled('img', {
|
|
@@ -1450,10 +1434,15 @@ function TokenInfo(props) {
|
|
|
1450
1434
|
type: "primary",
|
|
1451
1435
|
variant: "ghost",
|
|
1452
1436
|
size: "compact"
|
|
1453
|
-
}, t('Max')))) : React__default.createElement(
|
|
1437
|
+
}, t('Max')))) : React__default.createElement("div", {
|
|
1438
|
+
className: "output-usd"
|
|
1439
|
+
}, React__default.createElement(PercentageChange, {
|
|
1440
|
+
inputUsdValue: inputUsdValue,
|
|
1441
|
+
outputUsdValue: props.outputUsdValue
|
|
1442
|
+
}), React__default.createElement("div", null, React__default.createElement(ui.Typography, {
|
|
1454
1443
|
variant: "caption",
|
|
1455
1444
|
color: "neutrals600"
|
|
1456
|
-
}, `$${numberToString(props.outputUsdValue)}`)), React__default.createElement("div", {
|
|
1445
|
+
}, `$${numberToString(props.outputUsdValue)}`)))), React__default.createElement("div", {
|
|
1457
1446
|
className: "form"
|
|
1458
1447
|
}, React__default.createElement(ui.Button, {
|
|
1459
1448
|
className: "selectors",
|
|
@@ -1665,10 +1654,7 @@ const Alerts = /*#__PURE__*/ui.styled('div', {
|
|
|
1665
1654
|
width: '100%',
|
|
1666
1655
|
paddingTop: '$16'
|
|
1667
1656
|
});
|
|
1668
|
-
function Home(
|
|
1669
|
-
const {
|
|
1670
|
-
title = 'SWAP'
|
|
1671
|
-
} = props;
|
|
1657
|
+
function Home() {
|
|
1672
1658
|
const isRouterInContext = reactRouterDom.useInRouterContext();
|
|
1673
1659
|
const navigate = reactRouterDom.useNavigate();
|
|
1674
1660
|
const [count, setCount] = React.useState(0);
|
|
@@ -1676,10 +1662,6 @@ function Home(props) {
|
|
|
1676
1662
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
1677
1663
|
const toChain = useBestRouteStore.use.toChain();
|
|
1678
1664
|
const toToken = useBestRouteStore.use.toToken();
|
|
1679
|
-
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
1680
|
-
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
1681
|
-
const setToChain = useBestRouteStore.use.setToChain();
|
|
1682
|
-
const setToToken = useBestRouteStore.use.setToToken();
|
|
1683
1665
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
1684
1666
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1685
1667
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
@@ -1692,14 +1674,7 @@ function Home(props) {
|
|
|
1692
1674
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
1693
1675
|
const accounts = useWalletsStore.use.accounts();
|
|
1694
1676
|
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
1695
|
-
const
|
|
1696
|
-
setFromChain(toChain);
|
|
1697
|
-
setFromToken(toToken);
|
|
1698
|
-
setToChain(fromChain);
|
|
1699
|
-
setToToken(fromToken);
|
|
1700
|
-
setInputAmount(outputAmount?.toString() || '');
|
|
1701
|
-
setCount(prev => prev + 1);
|
|
1702
|
-
};
|
|
1677
|
+
const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
|
|
1703
1678
|
const errorMessage = loadingMetaStatus === 'failed' ? errorMessages.genericServerError : bestRouteError;
|
|
1704
1679
|
const needsToWarnEthOnPath = false;
|
|
1705
1680
|
const showBestRoute = inputAmount && (!!bestRoute || fetchingBestRoute || bestRouteError);
|
|
@@ -1720,7 +1695,7 @@ function Home(props) {
|
|
|
1720
1695
|
return setCurrentPage.bind(null, '');
|
|
1721
1696
|
}, []);
|
|
1722
1697
|
return React__default.createElement(Container$2, null, React__default.createElement(ui.Header, {
|
|
1723
|
-
title:
|
|
1698
|
+
title: "SWAP",
|
|
1724
1699
|
suffix: React__default.createElement(HeaderButtons, {
|
|
1725
1700
|
onClickRefresh: !!bestRoute ? fetchBestRoute : undefined
|
|
1726
1701
|
})
|
|
@@ -1732,7 +1707,10 @@ function Home(props) {
|
|
|
1732
1707
|
inputAmount: inputAmount
|
|
1733
1708
|
}), React__default.createElement(SwitchButtonContainer, null, React__default.createElement(ui.Button, {
|
|
1734
1709
|
variant: "ghost",
|
|
1735
|
-
onClick:
|
|
1710
|
+
onClick: () => {
|
|
1711
|
+
switchFromAndTo();
|
|
1712
|
+
setCount(prev => prev + 1);
|
|
1713
|
+
}
|
|
1736
1714
|
}, React__default.createElement(ui.VerticalSwapIcon, {
|
|
1737
1715
|
size: 32
|
|
1738
1716
|
}), isRouterInContext && React__default.createElement(SwithFromAndTo, {
|
|
@@ -1778,8 +1756,7 @@ function Home(props) {
|
|
|
1778
1756
|
|
|
1779
1757
|
const Route = _ref => {
|
|
1780
1758
|
let {
|
|
1781
|
-
children
|
|
1782
|
-
...props
|
|
1759
|
+
children
|
|
1783
1760
|
} = _ref;
|
|
1784
1761
|
const location = reactRouter.useLocation();
|
|
1785
1762
|
const navigate = reactRouter.useNavigate();
|
|
@@ -1790,7 +1767,7 @@ const Route = _ref => {
|
|
|
1790
1767
|
});
|
|
1791
1768
|
ref.current = false;
|
|
1792
1769
|
}, []);
|
|
1793
|
-
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React__default.createElement(Home,
|
|
1770
|
+
if (location.pathname === navigationRoutes.confirmSwap && ref.current) return React__default.createElement(Home, null);
|
|
1794
1771
|
return React__default.createElement(React__default.Fragment, null, " ", children);
|
|
1795
1772
|
};
|
|
1796
1773
|
function AppRouter(_ref2) {
|
|
@@ -1862,7 +1839,10 @@ const Container$3 = /*#__PURE__*/ui.styled('div', {
|
|
|
1862
1839
|
display: 'flex',
|
|
1863
1840
|
justifyContent: 'space-between',
|
|
1864
1841
|
alignItems: 'center',
|
|
1865
|
-
minHeight: '32px'
|
|
1842
|
+
minHeight: '32px',
|
|
1843
|
+
'.usd-value': {
|
|
1844
|
+
paddingLeft: '$8'
|
|
1845
|
+
}
|
|
1866
1846
|
},
|
|
1867
1847
|
'.form': {
|
|
1868
1848
|
display: 'flex',
|
|
@@ -1907,7 +1887,8 @@ function TokenPreview(props) {
|
|
|
1907
1887
|
const {
|
|
1908
1888
|
chain,
|
|
1909
1889
|
token,
|
|
1910
|
-
loadingStatus
|
|
1890
|
+
loadingStatus,
|
|
1891
|
+
percentageChange
|
|
1911
1892
|
} = props;
|
|
1912
1893
|
const {
|
|
1913
1894
|
t
|
|
@@ -1929,10 +1910,11 @@ function TokenPreview(props) {
|
|
|
1929
1910
|
}, React__default.createElement(ui.Typography, {
|
|
1930
1911
|
variant: "body2",
|
|
1931
1912
|
color: "neutrals800"
|
|
1932
|
-
}, props.label), props.usdValue && React__default.createElement(ui.Typography, {
|
|
1913
|
+
}, props.label), React__default.createElement("div", null, percentageChange, props.usdValue && React__default.createElement(ui.Typography, {
|
|
1933
1914
|
variant: "caption",
|
|
1934
|
-
color: "neutrals600"
|
|
1935
|
-
|
|
1915
|
+
color: "neutrals600",
|
|
1916
|
+
className: "usd-value"
|
|
1917
|
+
}, `$${numberToString(props.usdValue)}`))), React__default.createElement("div", {
|
|
1936
1918
|
className: "form"
|
|
1937
1919
|
}, React__default.createElement(ui.Button, {
|
|
1938
1920
|
className: "selectors",
|
|
@@ -2029,6 +2011,7 @@ function useConfirmSwap() {
|
|
|
2029
2011
|
const initialRoute = useBestRouteStore.use.bestRoute();
|
|
2030
2012
|
const setBestRoute = useBestRouteStore.use.setBestRoute();
|
|
2031
2013
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
2014
|
+
const affiliateRef = useSettingsStore.use.affiliateRef();
|
|
2032
2015
|
const accounts = useWalletsStore.use.accounts();
|
|
2033
2016
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
2034
2017
|
const meta = useMetaStore.use.meta();
|
|
@@ -2061,15 +2044,14 @@ function useConfirmSwap() {
|
|
|
2061
2044
|
if (warnings.length > 0) setWarnings([]);
|
|
2062
2045
|
proceedAnywayRef.current = false;
|
|
2063
2046
|
if (confiremedRouteRef.current) {
|
|
2064
|
-
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2065
|
-
//@ts-ignore
|
|
2047
|
+
const newSwap = queueManagerRangoPreset.calculatePendingSwap(inputAmount.toString(), confiremedRouteRef.current, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2066
2048
|
return newSwap;
|
|
2067
2049
|
}
|
|
2068
2050
|
return;
|
|
2069
2051
|
}
|
|
2070
2052
|
abortControllerRef.current = new AbortController();
|
|
2071
2053
|
setLoading(true);
|
|
2072
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true);
|
|
2054
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, accounts, selectedWallets, disabledLiquiditySources, userSlippage, true, affiliateRef);
|
|
2073
2055
|
try {
|
|
2074
2056
|
const confiremedRoute = await httpService.getBestRoute(requestBody, {
|
|
2075
2057
|
signal: abortControllerRef.current?.signal
|
|
@@ -2124,8 +2106,7 @@ function useConfirmSwap() {
|
|
|
2124
2106
|
slippage: userSlippage.toString(),
|
|
2125
2107
|
disabledSwappersGroups: disabledLiquiditySources
|
|
2126
2108
|
};
|
|
2127
|
-
const newSwap = calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2128
|
-
//@ts-ignore
|
|
2109
|
+
const newSwap = queueManagerRangoPreset.calculatePendingSwap(inputAmount.toString(), confiremedRoute, getWalletsForNewSwap(selectedWallets), swapSettings, false, meta);
|
|
2129
2110
|
return newSwap;
|
|
2130
2111
|
} else if (!proceedAnywayRef.current) {
|
|
2131
2112
|
proceedAnywayRef.current = true;
|
|
@@ -2311,6 +2292,8 @@ function ConfirmSwapPage() {
|
|
|
2311
2292
|
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
2312
2293
|
const slippage = useSettingsStore.use.slippage();
|
|
2313
2294
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
2295
|
+
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
2296
|
+
const outputUsdValue = useBestRouteStore.use.outputUsdValue();
|
|
2314
2297
|
const bestRouteloadingStatus = getBestRouteStatus(fetchingBestRoute, !!fetchingBestRouteError);
|
|
2315
2298
|
const {
|
|
2316
2299
|
manager
|
|
@@ -2341,7 +2324,10 @@ function ConfirmSwapPage() {
|
|
|
2341
2324
|
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
2342
2325
|
};
|
|
2343
2326
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
2344
|
-
return React__default.createElement(ui.ConfirmSwap
|
|
2327
|
+
return React__default.createElement(ui.ConfirmSwap
|
|
2328
|
+
// @ts-ignore
|
|
2329
|
+
, {
|
|
2330
|
+
// @ts-ignore
|
|
2345
2331
|
requiredWallets: getRequiredChains(bestRoute),
|
|
2346
2332
|
selectableWallets: selectableWallets,
|
|
2347
2333
|
onBack: navigateBackFrom.bind(null, navigationRoutes.confirmSwap),
|
|
@@ -2350,7 +2336,9 @@ function ConfirmSwapPage() {
|
|
|
2350
2336
|
if (swap) {
|
|
2351
2337
|
manager?.create('swap', {
|
|
2352
2338
|
swapDetails: swap
|
|
2353
|
-
},
|
|
2339
|
+
},
|
|
2340
|
+
// @ts-ignore
|
|
2341
|
+
{
|
|
2354
2342
|
id: swap.requestId
|
|
2355
2343
|
});
|
|
2356
2344
|
setSelectedSwap(swap.requestId);
|
|
@@ -2373,7 +2361,7 @@ function ConfirmSwapPage() {
|
|
|
2373
2361
|
symbol: firstStep?.from.symbol || '',
|
|
2374
2362
|
image: firstStep?.from.logo || ''
|
|
2375
2363
|
},
|
|
2376
|
-
usdValue:
|
|
2364
|
+
usdValue: inputUsdValue,
|
|
2377
2365
|
amount: fromAmount,
|
|
2378
2366
|
label: i18n.t('From'),
|
|
2379
2367
|
loadingStatus: bestRouteloadingStatus
|
|
@@ -2389,10 +2377,14 @@ function ConfirmSwapPage() {
|
|
|
2389
2377
|
symbol: lastStep?.to.symbol || '',
|
|
2390
2378
|
image: lastStep?.to.logo || ''
|
|
2391
2379
|
},
|
|
2392
|
-
usdValue:
|
|
2380
|
+
usdValue: outputUsdValue,
|
|
2393
2381
|
amount: toAmount,
|
|
2394
2382
|
label: i18n.t('To'),
|
|
2395
|
-
loadingStatus: bestRouteloadingStatus
|
|
2383
|
+
loadingStatus: bestRouteloadingStatus,
|
|
2384
|
+
percentageChange: React__default.createElement(PercentageChange, {
|
|
2385
|
+
inputUsdValue: inputUsdValue,
|
|
2386
|
+
outputUsdValue: outputUsdValue
|
|
2387
|
+
})
|
|
2396
2388
|
})),
|
|
2397
2389
|
previewRoutes: React__default.createElement(RoutesOverview, {
|
|
2398
2390
|
routes: bestRoute,
|
|
@@ -2504,7 +2496,7 @@ function LiquiditySourcePage(_ref) {
|
|
|
2504
2496
|
});
|
|
2505
2497
|
return React__default.createElement(ui.LiquiditySourcesSelector, {
|
|
2506
2498
|
toggleAll: toggleAllLiquiditySources,
|
|
2507
|
-
list: supportedSwappers
|
|
2499
|
+
list: supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups,
|
|
2508
2500
|
onChange: liquiditySource => toggleLiquiditySource(liquiditySource.title),
|
|
2509
2501
|
onBack: navigateBackFrom.bind(null, navigationRoutes.liquiditySources),
|
|
2510
2502
|
loadingStatus: loadingMetaStatus
|
|
@@ -2516,7 +2508,7 @@ function SelectChainPage(props) {
|
|
|
2516
2508
|
type,
|
|
2517
2509
|
supportedChains
|
|
2518
2510
|
} = props;
|
|
2519
|
-
const blockchains = supportedChains
|
|
2511
|
+
const blockchains = supportedChains ? useMetaStore.use.meta().blockchains.filter(chain => supportedChains.includes(chain.name)) : useMetaStore.use.meta().blockchains;
|
|
2520
2512
|
const loadingStatus = useMetaStore.use.loadingStatus();
|
|
2521
2513
|
const fromChain = useBestRouteStore.use.fromChain();
|
|
2522
2514
|
const toChain = useBestRouteStore.use.toChain();
|
|
@@ -2548,8 +2540,8 @@ function SelectTokenPage(props) {
|
|
|
2548
2540
|
} = props;
|
|
2549
2541
|
const sourceTokens = useBestRouteStore.use.sourceTokens();
|
|
2550
2542
|
const destinationTokens = useBestRouteStore.use.destinationTokens();
|
|
2551
|
-
const supportedSourceTokens = supportedTokens
|
|
2552
|
-
const supportedDestinationTokens = supportedTokens
|
|
2543
|
+
const supportedSourceTokens = supportedTokens ? sourceTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : sourceTokens;
|
|
2544
|
+
const supportedDestinationTokens = supportedTokens ? destinationTokens.filter(token => supportedTokens.some(supportedToken => tokensAreEqual(supportedToken, token))) : destinationTokens;
|
|
2553
2545
|
const fromToken = useBestRouteStore.use.fromToken();
|
|
2554
2546
|
const toToken = useBestRouteStore.use.toToken();
|
|
2555
2547
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
@@ -2602,8 +2594,8 @@ function SettingsPage(_ref) {
|
|
|
2602
2594
|
}
|
|
2603
2595
|
}
|
|
2604
2596
|
});
|
|
2605
|
-
supportedSwappers
|
|
2606
|
-
const supportedUniqueSwappersGroups = supportedSwappers
|
|
2597
|
+
supportedSwappers && uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0);
|
|
2598
|
+
const supportedUniqueSwappersGroups = supportedSwappers ? uniqueSwappersGroups.filter(item => supportedSwappers.filter(s => s === item.title).length > 0) : uniqueSwappersGroups;
|
|
2607
2599
|
return React__default.createElement(ui.Settings, {
|
|
2608
2600
|
slippages: SLIPPAGES,
|
|
2609
2601
|
selectedSlippage: slippage,
|
|
@@ -2656,7 +2648,7 @@ function WalletsPage(_ref) {
|
|
|
2656
2648
|
getWalletInfo,
|
|
2657
2649
|
connect
|
|
2658
2650
|
} = walletsCore.useWallets();
|
|
2659
|
-
const wallets = getlistWallet(state, getWalletInfo, supportedWallets
|
|
2651
|
+
const wallets = getlistWallet(state, getWalletInfo, supportedWallets || Object.values(walletsShared.WalletType));
|
|
2660
2652
|
const walletsRef = React.useRef();
|
|
2661
2653
|
let sortedWallets = walletsShared.detectMobileScreens() ? wallets.filter(wallet => wallet.showOnMobile) : wallets;
|
|
2662
2654
|
sortedWallets = sortWalletsBasedOnState(sortedWallets);
|
|
@@ -2865,7 +2857,7 @@ function SwapDetailsPage() {
|
|
|
2865
2857
|
}), React__default.createElement(TokenPreview, {
|
|
2866
2858
|
chain: {
|
|
2867
2859
|
displayName: lastStep?.toBlockchain || '',
|
|
2868
|
-
|
|
2860
|
+
//@ts-ignore
|
|
2869
2861
|
logo: lastStep?.toBlockchainLogo || ''
|
|
2870
2862
|
},
|
|
2871
2863
|
token: {
|
|
@@ -2877,7 +2869,6 @@ function SwapDetailsPage() {
|
|
|
2877
2869
|
loadingStatus: 'success'
|
|
2878
2870
|
})),
|
|
2879
2871
|
//todo: move PendingSwap type to rango-types
|
|
2880
|
-
//@ts-ignore
|
|
2881
2872
|
pendingSwap: swap,
|
|
2882
2873
|
onCopy: handleCopy,
|
|
2883
2874
|
isCopied: isCopied,
|
|
@@ -2907,48 +2898,44 @@ function SwapDetailsPage() {
|
|
|
2907
2898
|
const getAbsolutePath = path => path.replace('/', '');
|
|
2908
2899
|
function AppRoutes(props) {
|
|
2909
2900
|
const {
|
|
2910
|
-
|
|
2901
|
+
config
|
|
2911
2902
|
} = props;
|
|
2912
2903
|
return reactRouterDom.useRoutes([{
|
|
2913
2904
|
path: getAbsolutePath(navigationRoutes.home),
|
|
2914
|
-
element: React__default.createElement(Home,
|
|
2915
|
-
title: configs?.title,
|
|
2916
|
-
titleSize: configs?.titleSize,
|
|
2917
|
-
titleWeight: configs?.titleWeight
|
|
2918
|
-
})
|
|
2905
|
+
element: React__default.createElement(Home, null)
|
|
2919
2906
|
}, {
|
|
2920
2907
|
path: getAbsolutePath(navigationRoutes.fromChain),
|
|
2921
2908
|
element: React__default.createElement(SelectChainPage, {
|
|
2922
2909
|
type: "from",
|
|
2923
|
-
supportedChains:
|
|
2910
|
+
supportedChains: config?.from?.blockchains
|
|
2924
2911
|
})
|
|
2925
2912
|
}, {
|
|
2926
2913
|
path: getAbsolutePath(navigationRoutes.toChain),
|
|
2927
2914
|
element: React__default.createElement(SelectChainPage, {
|
|
2928
2915
|
type: "to",
|
|
2929
|
-
supportedChains:
|
|
2916
|
+
supportedChains: config?.to?.blockchains
|
|
2930
2917
|
})
|
|
2931
2918
|
}, {
|
|
2932
2919
|
path: getAbsolutePath(navigationRoutes.fromToken),
|
|
2933
2920
|
element: React__default.createElement(SelectTokenPage, {
|
|
2934
2921
|
type: "from",
|
|
2935
|
-
supportedTokens:
|
|
2922
|
+
supportedTokens: config?.from?.tokens
|
|
2936
2923
|
})
|
|
2937
2924
|
}, {
|
|
2938
2925
|
path: getAbsolutePath(navigationRoutes.toToken),
|
|
2939
2926
|
element: React__default.createElement(SelectTokenPage, {
|
|
2940
2927
|
type: "to",
|
|
2941
|
-
supportedTokens:
|
|
2928
|
+
supportedTokens: config?.to?.tokens
|
|
2942
2929
|
})
|
|
2943
2930
|
}, {
|
|
2944
2931
|
path: getAbsolutePath(navigationRoutes.settings),
|
|
2945
2932
|
element: React__default.createElement(SettingsPage, {
|
|
2946
|
-
supportedSwappers:
|
|
2933
|
+
supportedSwappers: config?.liquiditySources
|
|
2947
2934
|
})
|
|
2948
2935
|
}, {
|
|
2949
2936
|
path: getAbsolutePath(navigationRoutes.liquiditySources),
|
|
2950
2937
|
element: React__default.createElement(LiquiditySourcePage, {
|
|
2951
|
-
supportedSwappers:
|
|
2938
|
+
supportedSwappers: config?.liquiditySources
|
|
2952
2939
|
})
|
|
2953
2940
|
}, {
|
|
2954
2941
|
path: getAbsolutePath(navigationRoutes.swaps),
|
|
@@ -2959,8 +2946,8 @@ function AppRoutes(props) {
|
|
|
2959
2946
|
}, {
|
|
2960
2947
|
path: getAbsolutePath(navigationRoutes.wallets),
|
|
2961
2948
|
element: React__default.createElement(WalletsPage, {
|
|
2962
|
-
supportedWallets:
|
|
2963
|
-
multiWallets: typeof
|
|
2949
|
+
supportedWallets: config?.wallets,
|
|
2950
|
+
multiWallets: typeof config?.multiWallets === 'undefined' ? true : config.multiWallets
|
|
2964
2951
|
})
|
|
2965
2952
|
}, {
|
|
2966
2953
|
path: getAbsolutePath(navigationRoutes.confirmSwap),
|
|
@@ -2985,7 +2972,7 @@ const WalletImage = /*#__PURE__*/ui.styled('img', {
|
|
|
2985
2972
|
});
|
|
2986
2973
|
function Layout(_ref) {
|
|
2987
2974
|
let {
|
|
2988
|
-
|
|
2975
|
+
config
|
|
2989
2976
|
} = _ref;
|
|
2990
2977
|
const navigate = reactRouterDom.useNavigate();
|
|
2991
2978
|
const {
|
|
@@ -2997,11 +2984,16 @@ function Layout(_ref) {
|
|
|
2997
2984
|
getWalletInfo
|
|
2998
2985
|
} = walletsCore.useWallets();
|
|
2999
2986
|
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(accounts, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2987
|
+
const {
|
|
2988
|
+
blockchains,
|
|
2989
|
+
tokens
|
|
2990
|
+
} = useMetaStore.use.meta();
|
|
3000
2991
|
const setFromChain = useBestRouteStore.use.setFromChain();
|
|
3001
2992
|
const setFromToken = useBestRouteStore.use.setFromToken();
|
|
3002
2993
|
const setToChain = useBestRouteStore.use.setToChain();
|
|
3003
2994
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
3004
2995
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2996
|
+
const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
|
|
3005
2997
|
const totalBalance = calculateWalletUsdValue(balances);
|
|
3006
2998
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
3007
2999
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
@@ -3010,22 +3002,23 @@ function Layout(_ref) {
|
|
|
3010
3002
|
t
|
|
3011
3003
|
} = reactI18next.useTranslation();
|
|
3012
3004
|
React.useEffect(() => {
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
|
|
3005
|
+
const chain = blockchains.find(chain => chain.name === config?.to?.blockchain);
|
|
3006
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.to?.token || null));
|
|
3007
|
+
setToChain(chain || null);
|
|
3008
|
+
setToToken(token || null);
|
|
3009
|
+
}, [config?.to?.token, config?.to?.blockchain]);
|
|
3016
3010
|
React.useEffect(() => {
|
|
3017
|
-
setInputAmount(
|
|
3018
|
-
}, [
|
|
3011
|
+
setInputAmount(config?.amount?.toString() || '');
|
|
3012
|
+
}, [config?.amount]);
|
|
3019
3013
|
React.useEffect(() => {
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3014
|
+
const chain = blockchains.find(chain => chain.name === config?.from?.blockchain);
|
|
3015
|
+
const token = tokens.find(t => tokensAreEqual(t, config?.from?.token || null));
|
|
3016
|
+
setFromChain(chain || null);
|
|
3017
|
+
setFromToken(token || null);
|
|
3018
|
+
}, [config?.from?.token, config?.from?.blockchain]);
|
|
3023
3019
|
React.useEffect(() => {
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
setFromToken(null);
|
|
3027
|
-
setToToken(null);
|
|
3028
|
-
}, [configs?.fromChains, configs?.toChains, configs?.fromTokens, configs?.toTokens]);
|
|
3020
|
+
setAffiliateRef(config?.affiliateRef || null);
|
|
3021
|
+
}, [config?.affiliateRef]);
|
|
3029
3022
|
return React__default.createElement(React__default.Fragment, null, React__default.createElement(Header, null, React__default.createElement(ui.Button, {
|
|
3030
3023
|
size: "small",
|
|
3031
3024
|
suffix: React__default.createElement(ui.AddWalletIcon, {
|
|
@@ -3046,7 +3039,7 @@ function Layout(_ref) {
|
|
|
3046
3039
|
}, React__default.createElement(ui.Typography, {
|
|
3047
3040
|
variant: "body2"
|
|
3048
3041
|
}, !accounts?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React__default.createElement(ui.Spinner, null)))), React__default.createElement(AppRoutes, {
|
|
3049
|
-
|
|
3042
|
+
config: config
|
|
3050
3043
|
}));
|
|
3051
3044
|
}
|
|
3052
3045
|
|
|
@@ -3089,17 +3082,20 @@ function usePrevious(value) {
|
|
|
3089
3082
|
|
|
3090
3083
|
function useTheme(_ref) {
|
|
3091
3084
|
let {
|
|
3092
|
-
|
|
3093
|
-
background = '#fff',
|
|
3094
|
-
foreground = '#000',
|
|
3095
|
-
error = '#FF0000',
|
|
3096
|
-
warning = '#F5A623',
|
|
3097
|
-
success = '#0070F3',
|
|
3085
|
+
colors: themeColors,
|
|
3098
3086
|
fontFamily = 'Robot',
|
|
3099
|
-
borderRadius = 8
|
|
3087
|
+
borderRadius = 8,
|
|
3088
|
+
mode = 'auto'
|
|
3100
3089
|
} = _ref;
|
|
3101
3090
|
const theme = useSettingsStore.use.theme();
|
|
3102
3091
|
const fetchMeta = useMetaStore.use.fetchMeta();
|
|
3092
|
+
const setTheme = useSettingsStore.use.setTheme();
|
|
3093
|
+
const primary = themeColors?.primary || '#5FA425',
|
|
3094
|
+
background = themeColors?.background || '#fff',
|
|
3095
|
+
foreground = themeColors?.foreground || '#000',
|
|
3096
|
+
error = themeColors?.error || '#FF0000',
|
|
3097
|
+
warning = themeColors?.warning || '#F5A623',
|
|
3098
|
+
success = themeColors?.success || '#0070F3';
|
|
3103
3099
|
const colors = {
|
|
3104
3100
|
neutrals200: '#FAFAFA',
|
|
3105
3101
|
neutrals300: '#f2f2f2',
|
|
@@ -3177,6 +3173,9 @@ function useTheme(_ref) {
|
|
|
3177
3173
|
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', switchTheme);
|
|
3178
3174
|
};
|
|
3179
3175
|
}, []);
|
|
3176
|
+
React.useEffect(() => {
|
|
3177
|
+
if (mode !== 'auto') setTheme(mode);
|
|
3178
|
+
}, [mode]);
|
|
3180
3179
|
const prevFont = usePrevious(fontFamily);
|
|
3181
3180
|
React.useLayoutEffect(() => {
|
|
3182
3181
|
const {
|
|
@@ -3341,29 +3340,27 @@ function QueueManager(props) {
|
|
|
3341
3340
|
|
|
3342
3341
|
const SwapBox = _ref => {
|
|
3343
3342
|
let {
|
|
3344
|
-
|
|
3343
|
+
config
|
|
3345
3344
|
} = _ref;
|
|
3346
3345
|
globalStyles();
|
|
3347
|
-
globalFont(
|
|
3346
|
+
globalFont(config?.theme?.fontFamily || 'Roboto');
|
|
3348
3347
|
const {
|
|
3349
3348
|
activeTheme
|
|
3350
3349
|
} = useTheme({
|
|
3351
|
-
...
|
|
3352
|
-
borderRadius: configs?.borderRadius,
|
|
3353
|
-
fontFamily: configs?.fontFamily
|
|
3350
|
+
...config?.theme
|
|
3354
3351
|
});
|
|
3355
3352
|
const {
|
|
3356
3353
|
blockchains
|
|
3357
3354
|
} = useMetaStore.use.meta();
|
|
3358
3355
|
const disconnectWallet = useWalletsStore.use.disconnectWallet();
|
|
3359
3356
|
const connectWallet = useWalletsStore.use.connectWallet();
|
|
3360
|
-
const setTheme = useSettingsStore.use.setTheme();
|
|
3361
3357
|
const {
|
|
3362
3358
|
changeLanguage
|
|
3363
3359
|
} = useSelectLanguage();
|
|
3364
3360
|
const clearConnectedWallet = useWalletsStore.use.clearConnectedWallet();
|
|
3365
3361
|
const [lastConnectedWalletWithNetwork, setLastConnectedWalletWithNetwork] = React.useState('');
|
|
3366
3362
|
const [disconnectedWallet, setDisconnectedWallet] = React.useState();
|
|
3363
|
+
const currentPage = useUiStore.use.currentPage();
|
|
3367
3364
|
const evmBasedChainNames = blockchains.filter(rangoSdk.isEvmBlockchain).map(chain => chain.name);
|
|
3368
3365
|
const onUpdateState = (type, event, value, state, supportedChains) => {
|
|
3369
3366
|
if (event === walletsCore.Events.ACCOUNTS) {
|
|
@@ -3388,19 +3385,16 @@ const SwapBox = _ref => {
|
|
|
3388
3385
|
};
|
|
3389
3386
|
let providers = providerAll.allProviders();
|
|
3390
3387
|
React.useEffect(() => {
|
|
3391
|
-
|
|
3392
|
-
}, [configs.theme]);
|
|
3393
|
-
React.useEffect(() => {
|
|
3394
|
-
const wallets = configs.wallets;
|
|
3388
|
+
const wallets = config?.wallets;
|
|
3395
3389
|
clearConnectedWallet();
|
|
3396
|
-
providers = wallets
|
|
3390
|
+
providers = !wallets ? providerAll.allProviders() : providerAll.allProviders().filter(provider => {
|
|
3397
3391
|
const type = provider.config.type;
|
|
3398
3392
|
return wallets.find(w => w === type);
|
|
3399
3393
|
});
|
|
3400
|
-
}, [
|
|
3394
|
+
}, [config?.wallets]);
|
|
3401
3395
|
React.useEffect(() => {
|
|
3402
|
-
changeLanguage(
|
|
3403
|
-
}, [
|
|
3396
|
+
changeLanguage(config?.language || 'en');
|
|
3397
|
+
}, [config?.language]);
|
|
3404
3398
|
return React__default.createElement(walletsCore.Provider, {
|
|
3405
3399
|
allBlockChains: blockchains,
|
|
3406
3400
|
providers: providers,
|
|
@@ -3409,21 +3403,15 @@ const SwapBox = _ref => {
|
|
|
3409
3403
|
id: "pageContainer",
|
|
3410
3404
|
className: activeTheme
|
|
3411
3405
|
}, React__default.createElement(QueueManager, null, React__default.createElement(ui.SwapContainer, {
|
|
3412
|
-
|
|
3413
|
-
width: configs?.width || 'auto',
|
|
3414
|
-
height: configs?.height || 'auto'
|
|
3415
|
-
}
|
|
3406
|
+
fixedHeight: currentPage !== navigationRoutes.home
|
|
3416
3407
|
}, React__default.createElement(AppRouter, {
|
|
3417
|
-
title: configs.title,
|
|
3418
|
-
titleSize: configs.titleSize,
|
|
3419
|
-
titleWeight: configs.titleWeight,
|
|
3420
3408
|
lastConnectedWallet: lastConnectedWalletWithNetwork,
|
|
3421
3409
|
disconnectedWallet: disconnectedWallet,
|
|
3422
3410
|
clearDisconnectedWallet: () => {
|
|
3423
3411
|
setDisconnectedWallet(undefined);
|
|
3424
3412
|
}
|
|
3425
3413
|
}, React__default.createElement(Layout, {
|
|
3426
|
-
|
|
3414
|
+
config: config
|
|
3427
3415
|
}))))));
|
|
3428
3416
|
};
|
|
3429
3417
|
|