@rango-dev/widget-embedded 0.1.15 → 0.1.16-next.1
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/QueueManager.d.ts.map +1 -1
- package/dist/components/RoutesOverview.d.ts.map +1 -1
- package/dist/components/TokenPreview.d.ts.map +1 -1
- package/dist/pages/Home.d.ts.map +1 -1
- package/dist/store/wallets.d.ts +6 -15
- package/dist/store/wallets.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/wallets.d.ts +7 -0
- package/dist/types/wallets.d.ts.map +1 -0
- package/dist/utils/routing.d.ts +2 -3
- package/dist/utils/routing.d.ts.map +1 -1
- package/dist/utils/swap.d.ts +8 -9
- package/dist/utils/swap.d.ts.map +1 -1
- package/dist/utils/wallets.d.ts +11 -12
- package/dist/utils/wallets.d.ts.map +1 -1
- package/dist/widget-embedded.cjs.development.js +67 -73
- package/dist/widget-embedded.cjs.development.js.map +1 -1
- package/dist/widget-embedded.cjs.production.min.js +67 -73
- package/dist/widget-embedded.cjs.production.min.js.map +1 -1
- package/dist/widget-embedded.esm.js +67 -73
- package/dist/widget-embedded.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/QueueManager.tsx +4 -5
- package/src/components/Layout.tsx +5 -5
- package/src/components/RoutesOverview.tsx +1 -4
- package/src/components/TokenInfo.tsx +5 -5
- package/src/components/TokenPreview.tsx +8 -3
- package/src/hooks/useConfirmSwap.ts +2 -2
- package/src/pages/ConfirmSwapPage.tsx +2 -2
- package/src/pages/Home.tsx +5 -3
- package/src/store/bestRoute.ts +7 -7
- package/src/store/wallets.ts +32 -46
- package/src/types/index.ts +1 -0
- package/src/types/wallets.ts +7 -0
- package/src/utils/routing.ts +2 -3
- package/src/utils/swap.ts +12 -11
- package/src/utils/wallets.ts +59 -52
|
@@ -394,27 +394,27 @@ function getRequiredChains(route) {
|
|
|
394
394
|
});
|
|
395
395
|
return wallets;
|
|
396
396
|
}
|
|
397
|
-
function getSelectableWallets(
|
|
398
|
-
const
|
|
399
|
-
address:
|
|
400
|
-
walletType:
|
|
401
|
-
chain:
|
|
402
|
-
image: getWalletInfo(
|
|
403
|
-
name: getWalletInfo(
|
|
404
|
-
selected: !!selectedWallets.find(
|
|
397
|
+
function getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo) {
|
|
398
|
+
const selectableWallets = connectedWallets.map(connectedWallet => ({
|
|
399
|
+
address: connectedWallet.address,
|
|
400
|
+
walletType: connectedWallet.walletType,
|
|
401
|
+
chain: connectedWallet.chain,
|
|
402
|
+
image: getWalletInfo(connectedWallet.walletType).img,
|
|
403
|
+
name: getWalletInfo(connectedWallet.walletType).name,
|
|
404
|
+
selected: !!selectedWallets.find(selectedWallet => selectedWallet.chain === connectedWallet.chain && selectedWallet.walletType === connectedWallet.walletType)
|
|
405
405
|
}));
|
|
406
|
-
return
|
|
406
|
+
return selectableWallets;
|
|
407
407
|
}
|
|
408
|
-
function getBalanceFromWallet(
|
|
409
|
-
if (
|
|
410
|
-
const
|
|
411
|
-
if (
|
|
412
|
-
return
|
|
408
|
+
function getBalanceFromWallet(connectedWallets, chain, symbol, address) {
|
|
409
|
+
if (connectedWallets.length === 0) return null;
|
|
410
|
+
const selectedChainWallets = connectedWallets.filter(wallet => wallet.chain === chain);
|
|
411
|
+
if (selectedChainWallets.length === 0) return null;
|
|
412
|
+
return selectedChainWallets.map(wallet => wallet.balances?.find(balance => address !== null && balance.address === address || address === null && balance.address === address && balance.symbol === symbol) || null).filter(balance => balance !== null).sort((a, b) => parseFloat(b?.amount || '0') - parseFloat(a?.amount || '1')).find(() => true) || null;
|
|
413
413
|
}
|
|
414
|
-
function
|
|
415
|
-
return account.address ===
|
|
414
|
+
function isAccountAndWalletMatched(account, connectedWallet) {
|
|
415
|
+
return account.address === connectedWallet.address && account.chain === connectedWallet.chain && account.walletType === connectedWallet.walletType;
|
|
416
416
|
}
|
|
417
|
-
function makeBalanceFor(
|
|
417
|
+
function makeBalanceFor(wallet, retrivedBalance, tokens) {
|
|
418
418
|
const {
|
|
419
419
|
address,
|
|
420
420
|
blockChain: chain,
|
|
@@ -427,7 +427,7 @@ function makeBalanceFor(account, retrivedBalance, tokens) {
|
|
|
427
427
|
loading: false,
|
|
428
428
|
error: false,
|
|
429
429
|
explorerUrl,
|
|
430
|
-
walletType:
|
|
430
|
+
walletType: wallet.walletType,
|
|
431
431
|
balances: balances?.map(tokenBalance => ({
|
|
432
432
|
chain,
|
|
433
433
|
symbol: tokenBalance.asset.symbol,
|
|
@@ -441,16 +441,16 @@ function makeBalanceFor(account, retrivedBalance, tokens) {
|
|
|
441
441
|
})) || []
|
|
442
442
|
};
|
|
443
443
|
}
|
|
444
|
-
function
|
|
444
|
+
function resetConnectedWalletState(connectedWallet) {
|
|
445
445
|
return {
|
|
446
|
-
...
|
|
446
|
+
...connectedWallet,
|
|
447
447
|
loading: false,
|
|
448
448
|
error: true
|
|
449
449
|
};
|
|
450
450
|
}
|
|
451
|
-
const calculateWalletUsdValue =
|
|
451
|
+
const calculateWalletUsdValue = connectedWallet => {
|
|
452
452
|
const uniqueAccountAddresses = new Set();
|
|
453
|
-
const uniqueBalane =
|
|
453
|
+
const uniqueBalane = connectedWallet?.reduce((acc, current) => {
|
|
454
454
|
return acc.findIndex(i => i.address === current.address && i.chain === current.chain) === -1 ? [...acc, current] : acc;
|
|
455
455
|
}, []);
|
|
456
456
|
const modifiedWalletBlockchains = uniqueBalane?.map(chain => {
|
|
@@ -496,15 +496,15 @@ const getKeplrCompatibleConnectedWallets = selectableWallets => {
|
|
|
496
496
|
const connectedWalletTypes = new Set(selectableWallets.map(a => a.walletType.toString()));
|
|
497
497
|
return KEPLR_COMPATIBLE_WALLETS.filter(compatibleWallet => connectedWalletTypes.has(compatibleWallet));
|
|
498
498
|
};
|
|
499
|
-
function getTokensWithBalance(tokens,
|
|
499
|
+
function getTokensWithBalance(tokens, connectedWallets) {
|
|
500
500
|
return tokens.map(_ref2 => {
|
|
501
501
|
let {
|
|
502
502
|
balance,
|
|
503
503
|
...otherProps
|
|
504
504
|
} = _ref2;
|
|
505
|
-
const tokenAmount = numberToString(new BigNumber(getBalanceFromWallet(
|
|
505
|
+
const tokenAmount = numberToString(new BigNumber(getBalanceFromWallet(connectedWallets, otherProps.blockchain, otherProps.symbol, otherProps.address)?.amount || ZERO));
|
|
506
506
|
let tokenUsdValue = '';
|
|
507
|
-
if (otherProps.usdPrice) tokenUsdValue = numberToString(new BigNumber(getBalanceFromWallet(
|
|
507
|
+
if (otherProps.usdPrice) tokenUsdValue = numberToString(new BigNumber(getBalanceFromWallet(connectedWallets, otherProps.blockchain, otherProps.symbol, otherProps.address)?.amount || ZERO).multipliedBy(otherProps.usdPrice));
|
|
508
508
|
return {
|
|
509
509
|
...otherProps,
|
|
510
510
|
...(tokenAmount !== '0' && {
|
|
@@ -516,11 +516,11 @@ function getTokensWithBalance(tokens, balances) {
|
|
|
516
516
|
};
|
|
517
517
|
});
|
|
518
518
|
}
|
|
519
|
-
function getSortedTokens(chain, tokens,
|
|
519
|
+
function getSortedTokens(chain, tokens, connectedWallets, otherChainTokens) {
|
|
520
520
|
const fromChainEqueulsToToChain = chain?.name === otherChainTokens[0]?.name;
|
|
521
521
|
if (fromChainEqueulsToToChain) return otherChainTokens;
|
|
522
522
|
const filteredTokens = tokens.filter(token => token.blockchain === chain?.name);
|
|
523
|
-
return sortTokens(getTokensWithBalance(filteredTokens,
|
|
523
|
+
return sortTokens(getTokensWithBalance(filteredTokens, connectedWallets));
|
|
524
524
|
}
|
|
525
525
|
function tokensAreEqual(tokenA, tokenB) {
|
|
526
526
|
return tokenA?.blockchain === tokenB?.blockchain && tokenA?.symbol === tokenB?.symbol && tokenA?.address === tokenB?.address;
|
|
@@ -601,12 +601,12 @@ function LimitErrorMessage(bestRoute) {
|
|
|
601
601
|
recommendation
|
|
602
602
|
};
|
|
603
603
|
}
|
|
604
|
-
function getSwapButtonState(loadingMetaStatus,
|
|
604
|
+
function getSwapButtonState(loadingMetaStatus, connectedWallets, loading, bestRoute, hasLimitError, highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputAmount) {
|
|
605
605
|
if (loadingMetaStatus !== 'success') return {
|
|
606
606
|
title: 'Connect Wallet',
|
|
607
607
|
disabled: true
|
|
608
608
|
};
|
|
609
|
-
if (
|
|
609
|
+
if (connectedWallets.length == 0) return {
|
|
610
610
|
title: 'Connect Wallet',
|
|
611
611
|
disabled: false
|
|
612
612
|
};
|
|
@@ -818,14 +818,12 @@ function shouldRetrySwap(pendingSwap) {
|
|
|
818
818
|
}
|
|
819
819
|
|
|
820
820
|
const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/subscribeWithSelector((set, get) => ({
|
|
821
|
-
|
|
822
|
-
balances: [],
|
|
821
|
+
connectedWallets: [],
|
|
823
822
|
selectedWallets: [],
|
|
824
823
|
connectWallet: accounts => {
|
|
825
824
|
const getOneOfWalletsDetails = get().getOneOfWalletsDetails;
|
|
826
825
|
set(state => ({
|
|
827
|
-
|
|
828
|
-
balances: state.balances.concat(accounts.map(account => ({
|
|
826
|
+
connectedWallets: state.connectedWallets.concat(accounts.map(account => ({
|
|
829
827
|
balances: [],
|
|
830
828
|
address: account.address,
|
|
831
829
|
chain: account.chain,
|
|
@@ -839,14 +837,13 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
839
837
|
},
|
|
840
838
|
disconnectWallet: walletType => {
|
|
841
839
|
set(state => ({
|
|
842
|
-
|
|
843
|
-
balances: state.balances.filter(balance => balance.walletType !== walletType),
|
|
840
|
+
connectedWallets: state.connectedWallets.filter(balance => balance.walletType !== walletType),
|
|
844
841
|
selectedWallets: state.selectedWallets.filter(wallet => wallet.walletType != walletType)
|
|
845
842
|
}));
|
|
846
843
|
},
|
|
847
844
|
initSelectedWallets: () => set(state => {
|
|
848
845
|
const requiredChains = getRequiredChains(useBestRouteStore.getState().bestRoute);
|
|
849
|
-
const connectedWallets = state.
|
|
846
|
+
const connectedWallets = state.connectedWallets;
|
|
850
847
|
const selectedWallets = [];
|
|
851
848
|
requiredChains.forEach(chain => {
|
|
852
849
|
const anyWalletSelected = !!state.selectedWallets.find(wallet => wallet.chain === chain);
|
|
@@ -871,14 +868,13 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
871
868
|
})
|
|
872
869
|
})),
|
|
873
870
|
clearConnectedWallet: () => set(() => ({
|
|
874
|
-
|
|
875
|
-
balances: [],
|
|
871
|
+
connectedWallets: [],
|
|
876
872
|
selectedWallets: []
|
|
877
873
|
})),
|
|
878
874
|
getOneOfWalletsDetails: async account => {
|
|
879
875
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
880
876
|
set(state => ({
|
|
881
|
-
|
|
877
|
+
connectedWallets: state.connectedWallets.map(balance => {
|
|
882
878
|
return balance.address === account.address && balance.chain === account.chain ? {
|
|
883
879
|
...balance,
|
|
884
880
|
loading: true
|
|
@@ -893,28 +889,28 @@ const useWalletsStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#
|
|
|
893
889
|
const retrivedBalance = response.wallets[0];
|
|
894
890
|
if (retrivedBalance) {
|
|
895
891
|
set(state => ({
|
|
896
|
-
|
|
897
|
-
return
|
|
892
|
+
connectedWallets: state.connectedWallets.map(connectedWallet => {
|
|
893
|
+
return isAccountAndWalletMatched(account, connectedWallet) ? makeBalanceFor(account, retrivedBalance, tokens) : connectedWallet;
|
|
898
894
|
})
|
|
899
895
|
}));
|
|
900
896
|
} else throw new Error('Wallet not found');
|
|
901
897
|
} catch (error) {
|
|
902
898
|
set(state => ({
|
|
903
|
-
|
|
904
|
-
return
|
|
899
|
+
connectedWallets: state.connectedWallets.map(balance => {
|
|
900
|
+
return isAccountAndWalletMatched(account, balance) ? resetConnectedWalletState(balance) : balance;
|
|
905
901
|
})
|
|
906
902
|
}));
|
|
907
903
|
}
|
|
908
904
|
}
|
|
909
905
|
}))));
|
|
910
|
-
useWalletsStore.subscribe(state => state.
|
|
906
|
+
useWalletsStore.subscribe(state => state.connectedWallets, connectedWallets => {
|
|
911
907
|
useBestRouteStore.setState(_ref => {
|
|
912
908
|
let {
|
|
913
909
|
sourceTokens,
|
|
914
910
|
destinationTokens
|
|
915
911
|
} = _ref;
|
|
916
|
-
const sourceTokensWithBalance = getTokensWithBalance(sourceTokens,
|
|
917
|
-
const destinationTokensWithBalance = getTokensWithBalance(destinationTokens,
|
|
912
|
+
const sourceTokensWithBalance = getTokensWithBalance(sourceTokens, connectedWallets);
|
|
913
|
+
const destinationTokensWithBalance = getTokensWithBalance(destinationTokens, connectedWallets);
|
|
918
914
|
return {
|
|
919
915
|
sourceTokens: sortTokens(sourceTokensWithBalance),
|
|
920
916
|
destinationTokens: sortTokens(destinationTokensWithBalance)
|
|
@@ -923,7 +919,7 @@ useWalletsStore.subscribe(state => state.balances, balances => {
|
|
|
923
919
|
}, {
|
|
924
920
|
equalityFn: shallow
|
|
925
921
|
});
|
|
926
|
-
const fetchingBalanceSelector = state => !!state.
|
|
922
|
+
const fetchingBalanceSelector = state => !!state.connectedWallets.find(wallet => wallet.loading);
|
|
927
923
|
|
|
928
924
|
const getUsdValue = (token, amount) => new BigNumber(amount || ZERO).multipliedBy(token?.usdPrice || 0);
|
|
929
925
|
const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /*#__PURE__*/subscribeWithSelector(set => ({
|
|
@@ -967,8 +963,8 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
967
963
|
set(state => {
|
|
968
964
|
if (state.fromChain?.name === chain?.name) return {};
|
|
969
965
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
970
|
-
const
|
|
971
|
-
const sortedTokens = getSortedTokens(chain, tokens,
|
|
966
|
+
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
967
|
+
const sortedTokens = getSortedTokens(chain, tokens, connectedWallets, state.destinationTokens);
|
|
972
968
|
const fromToken = getDefaultToken(sortedTokens, state.toToken);
|
|
973
969
|
return {
|
|
974
970
|
fromChain: chain,
|
|
@@ -992,8 +988,8 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
992
988
|
set(state => {
|
|
993
989
|
if (state.toChain?.name === chain?.name) return {};
|
|
994
990
|
const tokens = useMetaStore.getState().meta.tokens;
|
|
995
|
-
const
|
|
996
|
-
const sortedTokens = getSortedTokens(chain, tokens,
|
|
991
|
+
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
992
|
+
const sortedTokens = getSortedTokens(chain, tokens, connectedWallets, state.destinationTokens);
|
|
997
993
|
return {
|
|
998
994
|
toChain: chain,
|
|
999
995
|
destinationTokens: sortedTokens,
|
|
@@ -1025,7 +1021,7 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
1025
1021
|
tokens,
|
|
1026
1022
|
blockchains
|
|
1027
1023
|
} = useMetaStore.getState().meta;
|
|
1028
|
-
const
|
|
1024
|
+
const connectedWallets = useWalletsStore.getState().connectedWallets;
|
|
1029
1025
|
const failedIndex = pendingSwap.status === 'failed' ? pendingSwap.steps.findIndex(s => s.status === 'failed') : null;
|
|
1030
1026
|
if (failedIndex === null || failedIndex < 0) return;
|
|
1031
1027
|
const firstStep = pendingSwap.steps[0];
|
|
@@ -1042,8 +1038,8 @@ const useBestRouteStore = /*#__PURE__*/createSelectors( /*#__PURE__*/create()( /
|
|
|
1042
1038
|
symbol: lastStep.toSymbol,
|
|
1043
1039
|
address: lastStep.toSymbolAddress
|
|
1044
1040
|
}));
|
|
1045
|
-
const sortedSourceTokens = getSortedTokens(fromChain, tokens,
|
|
1046
|
-
const sortedDestinationTokens = getSortedTokens(toChain, tokens,
|
|
1041
|
+
const sortedSourceTokens = getSortedTokens(fromChain, tokens, connectedWallets, []);
|
|
1042
|
+
const sortedDestinationTokens = getSortedTokens(toChain, tokens, connectedWallets, []);
|
|
1047
1043
|
const inputAmount = pendingSwap.inputAmount;
|
|
1048
1044
|
set({
|
|
1049
1045
|
fromChain,
|
|
@@ -1550,7 +1546,7 @@ function useConfirmSwap() {
|
|
|
1550
1546
|
const setBestRoute = useBestRouteStore.use.setBestRoute();
|
|
1551
1547
|
const inputUsdValue = useBestRouteStore.use.inputUsdValue();
|
|
1552
1548
|
const affiliateRef = useSettingsStore.use.affiliateRef();
|
|
1553
|
-
const
|
|
1549
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
1554
1550
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
1555
1551
|
const meta = useMetaStore.use.meta();
|
|
1556
1552
|
const customSlippage = useSettingsStore.use.customSlippage();
|
|
@@ -1589,7 +1585,7 @@ function useConfirmSwap() {
|
|
|
1589
1585
|
}
|
|
1590
1586
|
abortControllerRef.current = new AbortController();
|
|
1591
1587
|
setLoading(true);
|
|
1592
|
-
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount,
|
|
1588
|
+
const requestBody = createBestRouteRequestBody(fromToken, toToken, inputAmount, connectedWallets, selectedWallets, disabledLiquiditySources, userSlippage, affiliateRef, initialRoute);
|
|
1593
1589
|
try {
|
|
1594
1590
|
const confiremedRoute = await httpService().getBestRoute(requestBody, {
|
|
1595
1591
|
signal: abortControllerRef.current?.signal
|
|
@@ -1833,7 +1829,7 @@ function ConfirmSwapPage() {
|
|
|
1833
1829
|
tokens
|
|
1834
1830
|
} = useMetaStore.use.meta();
|
|
1835
1831
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
1836
|
-
const
|
|
1832
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
1837
1833
|
const selectedWallets = useWalletsStore.use.selectedWallets();
|
|
1838
1834
|
const initSelectedWallets = useWalletsStore.use.initSelectedWallets();
|
|
1839
1835
|
const setSelectedWallet = useWalletsStore.use.setSelectedWallet();
|
|
@@ -1866,7 +1862,7 @@ function ConfirmSwapPage() {
|
|
|
1866
1862
|
useEffect(() => {
|
|
1867
1863
|
initSelectedWallets();
|
|
1868
1864
|
}, []);
|
|
1869
|
-
const selectableWallets = getSelectableWallets(
|
|
1865
|
+
const selectableWallets = getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo);
|
|
1870
1866
|
const handleConnectChain = wallet => {
|
|
1871
1867
|
const network = wallet;
|
|
1872
1868
|
getKeplrCompatibleConnectedWallets(selectableWallets).forEach(compatibleWallet => connect?.(compatibleWallet, network));
|
|
@@ -2111,14 +2107,14 @@ function TokenInfo(props) {
|
|
|
2111
2107
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2112
2108
|
const bestRoute = useBestRouteStore.use.bestRoute();
|
|
2113
2109
|
const inputAmount = useBestRouteStore.use.inputAmount();
|
|
2114
|
-
const
|
|
2110
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
2115
2111
|
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
2116
2112
|
const navigate = useNavigate();
|
|
2117
2113
|
const {
|
|
2118
2114
|
t
|
|
2119
2115
|
} = useTranslation();
|
|
2120
|
-
const tokenBalance = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(
|
|
2121
|
-
const tokenBalanceReal = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(
|
|
2116
|
+
const tokenBalance = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(connectedWallets, fromChain?.name, fromToken?.symbol, fromToken?.address)?.amount || '0', 8) : '0';
|
|
2117
|
+
const tokenBalanceReal = !!fromChain && !!fromToken ? numberToString(getBalanceFromWallet(connectedWallets, fromChain?.name, fromToken?.symbol, fromToken?.address)?.amount || '0', getBalanceFromWallet(connectedWallets, fromChain?.name, fromToken?.symbol, fromToken?.address)?.decimal) : '0';
|
|
2122
2118
|
const ItemSuffix = React.createElement("div", {
|
|
2123
2119
|
style: {
|
|
2124
2120
|
display: 'flex',
|
|
@@ -2393,7 +2389,7 @@ function Home() {
|
|
|
2393
2389
|
const fetchingBestRoute = useBestRouteStore.use.loading();
|
|
2394
2390
|
const bestRouteError = useBestRouteStore.use.error();
|
|
2395
2391
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2396
|
-
const
|
|
2392
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
2397
2393
|
const setCurrentPage = useUiStore.use.setCurrentPage();
|
|
2398
2394
|
const switchFromAndTo = useBestRouteStore.use.switchFromAndTo();
|
|
2399
2395
|
const errorMessage = loadingMetaStatus === 'failed' ? errorMessages.genericServerError : bestRouteError;
|
|
@@ -2407,7 +2403,7 @@ function Home() {
|
|
|
2407
2403
|
swap
|
|
2408
2404
|
} = LimitErrorMessage(bestRoute);
|
|
2409
2405
|
const priceImpactCanNotBeComputed = !canComputePriceImpact(bestRoute, inputAmount, inputUsdValue, outputUsdValue);
|
|
2410
|
-
const swapButtonState = getSwapButtonState(loadingMetaStatus,
|
|
2406
|
+
const swapButtonState = getSwapButtonState(loadingMetaStatus, connectedWallets, fetchingBestRoute, bestRoute, hasLimitError(bestRoute), highValueLoss, priceImpactCanNotBeComputed, needsToWarnEthOnPath, inputAmount);
|
|
2411
2407
|
const totalFeeInUsd = getTotalFeeInUsd(bestRoute, tokens);
|
|
2412
2408
|
const highFee = hasHighFee(totalFeeInUsd);
|
|
2413
2409
|
useEffect(() => {
|
|
@@ -2966,14 +2962,13 @@ function Layout(_ref) {
|
|
|
2966
2962
|
} = _ref;
|
|
2967
2963
|
const navigate = useNavigate();
|
|
2968
2964
|
const {
|
|
2969
|
-
|
|
2970
|
-
accounts,
|
|
2965
|
+
connectedWallets,
|
|
2971
2966
|
selectedWallets
|
|
2972
2967
|
} = useWalletsStore();
|
|
2973
2968
|
const {
|
|
2974
2969
|
getWalletInfo
|
|
2975
2970
|
} = useWallets();
|
|
2976
|
-
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(
|
|
2971
|
+
const connectedWalletsImages = removeDuplicateFrom(getSelectableWallets(connectedWallets, selectedWallets, getWalletInfo).map(w => w.image));
|
|
2977
2972
|
const {
|
|
2978
2973
|
blockchains,
|
|
2979
2974
|
tokens
|
|
@@ -2984,7 +2979,7 @@ function Layout(_ref) {
|
|
|
2984
2979
|
const setToToken = useBestRouteStore.use.setToToken();
|
|
2985
2980
|
const setInputAmount = useBestRouteStore.use.setInputAmount();
|
|
2986
2981
|
const setAffiliateRef = useSettingsStore.use.setAffiliateRef();
|
|
2987
|
-
const totalBalance = calculateWalletUsdValue(
|
|
2982
|
+
const totalBalance = calculateWalletUsdValue(connectedWallets);
|
|
2988
2983
|
const connectWalletsButtonDisabled = useUiStore.use.connectWalletsButtonDisabled();
|
|
2989
2984
|
const loadingMetaStatus = useMetaStore.use.loadingStatus();
|
|
2990
2985
|
const fetchingBalance = useWalletsStore(fetchingBalanceSelector);
|
|
@@ -3030,7 +3025,7 @@ function Layout(_ref) {
|
|
|
3030
3025
|
className: "balance"
|
|
3031
3026
|
}, React.createElement(Typography, {
|
|
3032
3027
|
variant: "body2"
|
|
3033
|
-
}, !
|
|
3028
|
+
}, !connectedWallets?.length ? t('Connect Wallet') : `$${totalBalance || 0}`), fetchingBalance && React.createElement(Spinner, null)))), React.createElement(AppRoutes, {
|
|
3034
3029
|
config: config
|
|
3035
3030
|
}));
|
|
3036
3031
|
}
|
|
@@ -3266,13 +3261,12 @@ function QueueManager(props) {
|
|
|
3266
3261
|
});
|
|
3267
3262
|
}, []);
|
|
3268
3263
|
const getOneOfWalletsDetails = useWalletsStore.use.getOneOfWalletsDetails();
|
|
3269
|
-
const accounts = useWalletsStore.use.accounts();
|
|
3270
3264
|
const {
|
|
3271
3265
|
blockchains
|
|
3272
3266
|
} = useMetaStore.use.meta();
|
|
3273
|
-
const
|
|
3267
|
+
const connectedWallets = useWalletsStore.use.connectedWallets();
|
|
3274
3268
|
const wallets = {
|
|
3275
|
-
blockchains:
|
|
3269
|
+
blockchains: connectedWallets.map(wallet => ({
|
|
3276
3270
|
accounts: [wallet],
|
|
3277
3271
|
name: wallet.chain
|
|
3278
3272
|
}))
|
|
@@ -3298,8 +3292,8 @@ function QueueManager(props) {
|
|
|
3298
3292
|
const outputAmount = data.step?.outputAmount || '';
|
|
3299
3293
|
const step = data.step || lastStep;
|
|
3300
3294
|
if (data.eventType === 'task_completed' || data.eventType === 'step_completed_with_output' && lastStep?.id !== data.step?.id || !!outputAmount) {
|
|
3301
|
-
const fromAccount =
|
|
3302
|
-
const toAccount = step?.fromBlockchain !== step?.toBlockchain &&
|
|
3295
|
+
const fromAccount = connectedWallets.find(account => account.chain === step?.fromBlockchain);
|
|
3296
|
+
const toAccount = step?.fromBlockchain !== step?.toBlockchain && connectedWallets.find(wallet => wallet.chain === step?.toBlockchain);
|
|
3303
3297
|
fromAccount && getOneOfWalletsDetails(fromAccount);
|
|
3304
3298
|
toAccount && getOneOfWalletsDetails(toAccount);
|
|
3305
3299
|
}
|