mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
the token detction change affected swap performace, this is fixing it (#15607)
This commit is contained in:
parent
b27672bd0e
commit
d09bdbe3df
@ -8,6 +8,7 @@ import {
|
|||||||
getCurrentCurrency,
|
getCurrentCurrency,
|
||||||
getSwapsDefaultToken,
|
getSwapsDefaultToken,
|
||||||
getCurrentChainId,
|
getCurrentChainId,
|
||||||
|
getTokenList,
|
||||||
} from '../selectors';
|
} from '../selectors';
|
||||||
import { getConversionRate } from '../ducks/metamask/metamask';
|
import { getConversionRate } from '../ducks/metamask/metamask';
|
||||||
|
|
||||||
@ -23,7 +24,7 @@ export function getRenderableTokenData(
|
|||||||
conversionRate,
|
conversionRate,
|
||||||
currentCurrency,
|
currentCurrency,
|
||||||
chainId,
|
chainId,
|
||||||
shuffledTokenList,
|
tokenList,
|
||||||
) {
|
) {
|
||||||
const { symbol, name, address, iconUrl, string, balance, decimals } = token;
|
const { symbol, name, address, iconUrl, string, balance, decimals } = token;
|
||||||
let contractExchangeRate;
|
let contractExchangeRate;
|
||||||
@ -54,15 +55,12 @@ export function getRenderableTokenData(
|
|||||||
)
|
)
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
const tokenMetadata = shuffledTokenList.find(
|
const usedIconUrl =
|
||||||
(tokenData) => tokenData.address === address?.toLowerCase(),
|
iconUrl || tokenList[address?.toLowerCase()]?.iconUrl || token?.image;
|
||||||
);
|
|
||||||
|
|
||||||
const usedIconUrl = iconUrl || tokenMetadata?.iconUrl || token?.image;
|
|
||||||
return {
|
return {
|
||||||
...token,
|
...token,
|
||||||
primaryLabel: symbol,
|
primaryLabel: symbol,
|
||||||
secondaryLabel: name || tokenMetadata?.name,
|
secondaryLabel: name || tokenList[address?.toLowerCase()]?.name,
|
||||||
rightPrimaryLabel:
|
rightPrimaryLabel:
|
||||||
string && `${new BigNumber(string).round(6).toString()} ${symbol}`,
|
string && `${new BigNumber(string).round(6).toString()} ${symbol}`,
|
||||||
rightSecondaryLabel: formattedFiat,
|
rightSecondaryLabel: formattedFiat,
|
||||||
@ -70,7 +68,7 @@ export function getRenderableTokenData(
|
|||||||
identiconAddress: usedIconUrl ? null : address,
|
identiconAddress: usedIconUrl ? null : address,
|
||||||
balance,
|
balance,
|
||||||
decimals,
|
decimals,
|
||||||
name: name || tokenMetadata?.name,
|
name: name || tokenList[address?.toLowerCase()]?.name,
|
||||||
rawFiat,
|
rawFiat,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -86,6 +84,7 @@ export function useTokensToSearch({
|
|||||||
const conversionRate = useSelector(getConversionRate);
|
const conversionRate = useSelector(getConversionRate);
|
||||||
const currentCurrency = useSelector(getCurrentCurrency);
|
const currentCurrency = useSelector(getCurrentCurrency);
|
||||||
const defaultSwapsToken = useSelector(getSwapsDefaultToken, shallowEqual);
|
const defaultSwapsToken = useSelector(getSwapsDefaultToken, shallowEqual);
|
||||||
|
const tokenList = useSelector(getTokenList, isEqual);
|
||||||
|
|
||||||
const memoizedTopTokens = useEqualityCheck(topTokens);
|
const memoizedTopTokens = useEqualityCheck(topTokens);
|
||||||
const memoizedUsersToken = useEqualityCheck(usersTokens);
|
const memoizedUsersToken = useEqualityCheck(usersTokens);
|
||||||
@ -96,7 +95,7 @@ export function useTokensToSearch({
|
|||||||
conversionRate,
|
conversionRate,
|
||||||
currentCurrency,
|
currentCurrency,
|
||||||
chainId,
|
chainId,
|
||||||
shuffledTokensList,
|
tokenList,
|
||||||
);
|
);
|
||||||
const memoizedDefaultToken = useEqualityCheck(defaultToken);
|
const memoizedDefaultToken = useEqualityCheck(defaultToken);
|
||||||
|
|
||||||
@ -136,7 +135,7 @@ export function useTokensToSearch({
|
|||||||
conversionRate,
|
conversionRate,
|
||||||
currentCurrency,
|
currentCurrency,
|
||||||
chainId,
|
chainId,
|
||||||
shuffledTokensList,
|
tokenList,
|
||||||
);
|
);
|
||||||
if (tokenBucketPriority === TOKEN_BUCKET_PRIORITY.OWNED) {
|
if (tokenBucketPriority === TOKEN_BUCKET_PRIORITY.OWNED) {
|
||||||
if (
|
if (
|
||||||
@ -192,7 +191,7 @@ export function useTokensToSearch({
|
|||||||
currentCurrency,
|
currentCurrency,
|
||||||
memoizedDefaultToken,
|
memoizedDefaultToken,
|
||||||
chainId,
|
chainId,
|
||||||
shuffledTokensList,
|
tokenList,
|
||||||
tokenBucketPriority,
|
tokenBucketPriority,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@ -66,7 +66,7 @@ import {
|
|||||||
getCurrentCurrency,
|
getCurrentCurrency,
|
||||||
getCurrentChainId,
|
getCurrentChainId,
|
||||||
getRpcPrefsForCurrentProvider,
|
getRpcPrefsForCurrentProvider,
|
||||||
getUseTokenDetection,
|
getTokenList,
|
||||||
isHardwareWallet,
|
isHardwareWallet,
|
||||||
getHardwareWalletType,
|
getHardwareWalletType,
|
||||||
} from '../../../selectors';
|
} from '../../../selectors';
|
||||||
@ -150,7 +150,7 @@ export default function BuildQuote({
|
|||||||
const defaultSwapsToken = useSelector(getSwapsDefaultToken, isEqual);
|
const defaultSwapsToken = useSelector(getSwapsDefaultToken, isEqual);
|
||||||
const chainId = useSelector(getCurrentChainId);
|
const chainId = useSelector(getCurrentChainId);
|
||||||
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider, shallowEqual);
|
const rpcPrefs = useSelector(getRpcPrefsForCurrentProvider, shallowEqual);
|
||||||
const useTokenDetection = useSelector(getUseTokenDetection);
|
const tokenList = useSelector(getTokenList, isEqual);
|
||||||
const quotes = useSelector(getQuotes, isEqual);
|
const quotes = useSelector(getQuotes, isEqual);
|
||||||
const areQuotesPresent = Object.keys(quotes).length > 0;
|
const areQuotesPresent = Object.keys(quotes).length > 0;
|
||||||
|
|
||||||
@ -212,8 +212,7 @@ export default function BuildQuote({
|
|||||||
conversionRate,
|
conversionRate,
|
||||||
currentCurrency,
|
currentCurrency,
|
||||||
chainId,
|
chainId,
|
||||||
shuffledTokensList,
|
tokenList,
|
||||||
useTokenDetection,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const tokensToSearchSwapFrom = useTokensToSearch({
|
const tokensToSearchSwapFrom = useTokensToSearch({
|
||||||
|
Loading…
Reference in New Issue
Block a user