mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Keep imported tokens in the Assets list (#16167)
* Don't add a token if it's already added * Pass tokens directly * Add toLowerCase
This commit is contained in:
parent
7eb93ff74b
commit
c09e685bce
@ -83,7 +83,7 @@ import {
|
||||
IN_PROGRESS_TRANSACTION_STATUSES,
|
||||
SMART_TRANSACTION_STATUSES,
|
||||
} from '../../../shared/constants/transaction';
|
||||
import { getGasFeeEstimates } from '../metamask/metamask';
|
||||
import { getGasFeeEstimates, getTokens } from '../metamask/metamask';
|
||||
import { ORIGIN_METAMASK } from '../../../shared/constants/app';
|
||||
import {
|
||||
calcGasTotal,
|
||||
@ -606,6 +606,15 @@ export const fetchSwapsLivenessAndFeatureFlags = () => {
|
||||
};
|
||||
};
|
||||
|
||||
const isTokenAlreadyAdded = (tokenAddress, tokens) => {
|
||||
if (!Array.isArray(tokens)) {
|
||||
return false;
|
||||
}
|
||||
return tokens.find(
|
||||
(token) => token.address.toLowerCase() === tokenAddress.toLowerCase(),
|
||||
);
|
||||
};
|
||||
|
||||
export const fetchQuotesAndSetQuoteState = (
|
||||
history,
|
||||
inputValue,
|
||||
@ -674,7 +683,8 @@ export const fetchQuotesAndSetQuoteState = (
|
||||
if (
|
||||
toTokenAddress &&
|
||||
toTokenSymbol !== swapsDefaultToken.symbol &&
|
||||
contractExchangeRates[toTokenAddress] === undefined
|
||||
contractExchangeRates[toTokenAddress] === undefined &&
|
||||
!isTokenAlreadyAdded(toTokenAddress, getTokens(state))
|
||||
) {
|
||||
destinationTokenAddedForSwap = true;
|
||||
await dispatch(
|
||||
|
Loading…
Reference in New Issue
Block a user