mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
changing token address to lowercase for dynamic token list (#12071)
This commit is contained in:
parent
05aadb38f2
commit
0c2af43d3a
@ -1354,10 +1354,13 @@ export default class MetamaskController extends EventEmitter {
|
|||||||
checksummedAccountAddress
|
checksummedAccountAddress
|
||||||
].filter((asset) => {
|
].filter((asset) => {
|
||||||
if (asset.isERC721 === undefined) {
|
if (asset.isERC721 === undefined) {
|
||||||
|
// since the token.address from allTokens is checksumaddress
|
||||||
|
// asset.address have to be changed to lowercase when we are using dynamic list
|
||||||
const address = useTokenDetection
|
const address = useTokenDetection
|
||||||
? asset.address
|
? asset.address.toLowerCase()
|
||||||
: toChecksumHexAddress(asset.address);
|
: asset.address;
|
||||||
if (tokenList[address] !== undefined && tokenList[address].erc20) {
|
// the tokenList will be holding only erc20 tokens
|
||||||
|
if (tokenList[address] !== undefined) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else if (asset.isERC721 === false) {
|
} else if (asset.isERC721 === false) {
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
|
|
||||||
|
|
||||||
import Jazzicon from '../jazzicon';
|
import Jazzicon from '../jazzicon';
|
||||||
import BlockieIdenticon from './blockieIdenticon';
|
import BlockieIdenticon from './blockieIdenticon';
|
||||||
|
|
||||||
@ -103,9 +101,9 @@ export default class Identicon extends PureComponent {
|
|||||||
|
|
||||||
if (address) {
|
if (address) {
|
||||||
// token from dynamic api list is fetched when useTokenDetection is true
|
// token from dynamic api list is fetched when useTokenDetection is true
|
||||||
const tokenAddress = useTokenDetection
|
// And since the token.address from allTokens is checksumaddress
|
||||||
? address
|
// tokenAddress have to be changed to lowercase when we are using dynamic list
|
||||||
: toChecksumHexAddress(address);
|
const tokenAddress = useTokenDetection ? address.toLowerCase() : address;
|
||||||
if (tokenAddress && tokenList[tokenAddress]?.iconUrl) {
|
if (tokenAddress && tokenList[tokenAddress]?.iconUrl) {
|
||||||
return this.renderJazzicon();
|
return this.renderJazzicon();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import {
|
import { isValidHexAddress } from '../../../shared/modules/hexstring-utils';
|
||||||
isValidHexAddress,
|
|
||||||
toChecksumHexAddress,
|
|
||||||
} from '../../../shared/modules/hexstring-utils';
|
|
||||||
|
|
||||||
let iconFactory;
|
let iconFactory;
|
||||||
|
|
||||||
@ -26,7 +23,9 @@ IconFactory.prototype.iconForAddress = function (
|
|||||||
// When useTokenDetection flag is true the tokenList contains tokens with non-checksum address from the dynamic token service api,
|
// When useTokenDetection flag is true the tokenList contains tokens with non-checksum address from the dynamic token service api,
|
||||||
// When useTokenDetection flag is false the tokenList contains tokens with checksum addresses from contract-metadata.
|
// When useTokenDetection flag is false the tokenList contains tokens with checksum addresses from contract-metadata.
|
||||||
// So the flag indicates whether the address of tokens currently on the tokenList is checksum or not.
|
// So the flag indicates whether the address of tokens currently on the tokenList is checksum or not.
|
||||||
const addr = useTokenDetection ? address : toChecksumHexAddress(address);
|
// And since the token.address from allTokens is checksumaddress
|
||||||
|
// tokenAddress have to be changed to lowercase when we are using dynamic list
|
||||||
|
const addr = useTokenDetection ? address.toLowerCase() : address;
|
||||||
if (iconExistsFor(addr, tokenList)) {
|
if (iconExistsFor(addr, tokenList)) {
|
||||||
return imageElFor(addr, useTokenDetection, tokenList);
|
return imageElFor(addr, useTokenDetection, tokenList);
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import { getConversionRate } from '../ducks/metamask/metamask';
|
|||||||
|
|
||||||
import { getSwapsTokens } from '../ducks/swaps/swaps';
|
import { getSwapsTokens } from '../ducks/swaps/swaps';
|
||||||
import { isSwapsDefaultTokenSymbol } from '../../shared/modules/swaps.utils';
|
import { isSwapsDefaultTokenSymbol } from '../../shared/modules/swaps.utils';
|
||||||
import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
|
|
||||||
import { useEqualityCheck } from './useEqualityCheck';
|
import { useEqualityCheck } from './useEqualityCheck';
|
||||||
|
|
||||||
const shuffledContractMap = shuffle(
|
const shuffledContractMap = shuffle(
|
||||||
@ -39,9 +38,9 @@ export function getRenderableTokenData(
|
|||||||
) {
|
) {
|
||||||
const { symbol, name, address, iconUrl, string, balance, decimals } = token;
|
const { symbol, name, address, iconUrl, string, balance, decimals } = token;
|
||||||
// token from dynamic api list is fetched when useTokenDetection is true
|
// token from dynamic api list is fetched when useTokenDetection is true
|
||||||
const tokenAddress = useTokenDetection
|
// And since the token.address from allTokens is checksumaddress
|
||||||
? address
|
// token Address have to be changed to lowercase when we are using dynamic list
|
||||||
: toChecksumHexAddress(address);
|
const tokenAddress = useTokenDetection ? address?.toLowerCase() : address;
|
||||||
const formattedFiat =
|
const formattedFiat =
|
||||||
getTokenFiatAmount(
|
getTokenFiatAmount(
|
||||||
isSwapsDefaultTokenSymbol(symbol, chainId)
|
isSwapsDefaultTokenSymbol(symbol, chainId)
|
||||||
|
Loading…
Reference in New Issue
Block a user