mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
Selector performance improvements (#17410)
* Stop checksumming addresses unnecesarily * Fix lint
This commit is contained in:
parent
64bfe6f307
commit
63cbcc7147
@ -49,7 +49,6 @@ import {
|
||||
|
||||
import { TEMPLATED_CONFIRMATION_MESSAGE_TYPES } from '../pages/confirmation/templates';
|
||||
import { STATIC_MAINNET_TOKEN_LIST } from '../../shared/constants/tokens';
|
||||
import { toChecksumHexAddress } from '../../shared/modules/hexstring-utils';
|
||||
import { DAY } from '../../shared/constants/time';
|
||||
import {
|
||||
getNativeCurrency,
|
||||
@ -394,7 +393,7 @@ export function getEnsResolutionByAddress(state, address) {
|
||||
const entry =
|
||||
getAddressBookEntry(state, address) ||
|
||||
Object.values(state.metamask.identities).find((identity) =>
|
||||
isEqualCaseInsensitive(identity.address, toChecksumHexAddress(address)),
|
||||
isEqualCaseInsensitive(identity.address, address),
|
||||
);
|
||||
|
||||
return entry?.name || '';
|
||||
@ -403,7 +402,7 @@ export function getEnsResolutionByAddress(state, address) {
|
||||
export function getAddressBookEntry(state, address) {
|
||||
const addressBook = getAddressBook(state);
|
||||
const entry = addressBook.find((contact) =>
|
||||
isEqualCaseInsensitive(contact.address, toChecksumHexAddress(address)),
|
||||
isEqualCaseInsensitive(contact.address, address),
|
||||
);
|
||||
return entry;
|
||||
}
|
||||
@ -412,14 +411,14 @@ export function getAddressBookEntryOrAccountName(state, address) {
|
||||
const entry =
|
||||
getAddressBookEntry(state, address) ||
|
||||
Object.values(state.metamask.identities).find((identity) =>
|
||||
isEqualCaseInsensitive(identity.address, toChecksumHexAddress(address)),
|
||||
isEqualCaseInsensitive(identity.address, address),
|
||||
);
|
||||
return entry && entry.name !== '' ? entry.name : address;
|
||||
}
|
||||
|
||||
export function getAccountName(identities, address) {
|
||||
const entry = Object.values(identities).find((identity) =>
|
||||
isEqualCaseInsensitive(identity.address, toChecksumHexAddress(address)),
|
||||
isEqualCaseInsensitive(identity.address, address),
|
||||
);
|
||||
return entry && entry.name !== '' ? entry.name : '';
|
||||
}
|
||||
@ -427,7 +426,7 @@ export function getAccountName(identities, address) {
|
||||
export function getMetadataContractName(state, address) {
|
||||
const tokenList = getTokenList(state);
|
||||
const entry = Object.values(tokenList).find((identity) =>
|
||||
isEqualCaseInsensitive(identity.address, toChecksumHexAddress(address)),
|
||||
isEqualCaseInsensitive(identity.address, address),
|
||||
);
|
||||
return entry && entry.name !== '' ? entry.name : '';
|
||||
}
|
||||
@ -840,9 +839,8 @@ export const getMemoizedMetadataContractName = createDeepEqualSelector(
|
||||
getTokenList,
|
||||
(_tokenList, address) => address,
|
||||
(tokenList, address) => {
|
||||
const checksumHexAddress = toChecksumHexAddress(address);
|
||||
const entry = Object.values(tokenList).find((identity) =>
|
||||
isEqualCaseInsensitive(identity.address, checksumHexAddress),
|
||||
isEqualCaseInsensitive(identity.address, address),
|
||||
);
|
||||
return entry && entry.name !== '' ? entry.name : '';
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user