Add isHex check for addresses supplied to icons (#11071)

feature/default_network_editable
Thomas Huang 4 years ago committed by GitHub
parent cacefc72fc
commit e920fe15c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      ui/components/ui/identicon/identicon.component.js
  2. 9
      ui/helpers/utils/icon-factory.js

@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import classnames from 'classnames';
import contractMap from '@metamask/contract-metadata';
import { checksumAddress } from '../../../helpers/utils/util';
import { checksumAddress, isHex } from '../../../helpers/utils/util';
import Jazzicon from '../jazzicon';
import BlockieIdenticon from './blockieIdenticon';
@ -85,11 +85,13 @@ export default class Identicon extends PureComponent {
}
if (address) {
if (isHex(address)) {
const checksummedAddress = checksumAddress(address);
if (contractMap[checksummedAddress]?.logo) {
return this.renderJazzicon();
}
}
return (
<div

@ -1,5 +1,5 @@
import contractMap from '@metamask/contract-metadata';
import { isValidAddress, checksumAddress } from './util';
import { isValidAddress, checksumAddress, isHex } from './util';
let iconFactory;
@ -16,7 +16,12 @@ function IconFactory(jazzicon) {
}
IconFactory.prototype.iconForAddress = function (address, diameter) {
const addr = checksumAddress(address);
let addr = address;
if (isHex(address)) {
addr = checksumAddress(address);
}
if (iconExistsFor(addr)) {
return imageElFor(addr);
}

Loading…
Cancel
Save