mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-26 12:29:06 +01:00
6e5c2f03bf
* addding the legacy tokenlist, tuning token detection OFF by default, adding new message while importing tokens updating the controller version and calling detectNewToken on network change fixing rebase error Run yarn lavamoat:auto for updating policies updating lavamoat Deleted node modules and run again lavamoat auto fixing rebase issues updating lavamoat policies updating lavamoat after rebasing policies updating custom token warning and blocking detectedtoken link when tpken detection is off for supported networks to update the token in fetchTosync updating the contract map object Revert build-system lavamoat policy changes Move token list selection logic from components to getTokenList selector updating the tokenList Update lavamoat Fix error updating lavamoat lint fix fix unit test fail fix unit test fail lint fix fixing rebase locale error rebase fix Revert build-system policy changes temp addressing review comments * rebase fix
74 lines
2.3 KiB
JavaScript
74 lines
2.3 KiB
JavaScript
import React, { Component } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import classnames from 'classnames';
|
|
import { checkExistingAddresses } from '../../../helpers/utils/util';
|
|
import TokenListPlaceholder from './token-list-placeholder';
|
|
|
|
export default class TokenList extends Component {
|
|
static contextTypes = {
|
|
t: PropTypes.func,
|
|
};
|
|
|
|
static propTypes = {
|
|
tokens: PropTypes.array,
|
|
results: PropTypes.array,
|
|
selectedTokens: PropTypes.object,
|
|
onToggleToken: PropTypes.func,
|
|
};
|
|
|
|
render() {
|
|
const {
|
|
results = [],
|
|
selectedTokens = {},
|
|
onToggleToken,
|
|
tokens = [],
|
|
} = this.props;
|
|
|
|
return results.length === 0 ? (
|
|
<TokenListPlaceholder />
|
|
) : (
|
|
<div className="token-list">
|
|
<div className="token-list__title">
|
|
{this.context.t('searchResults')}
|
|
</div>
|
|
<div className="token-list__tokens-container">
|
|
{Array(6)
|
|
.fill(undefined)
|
|
.map((_, i) => {
|
|
const { symbol, name, address } = results[i] || {};
|
|
const tokenAlreadyAdded = checkExistingAddresses(address, tokens);
|
|
const onClick = () =>
|
|
!tokenAlreadyAdded && onToggleToken(results[i]);
|
|
|
|
return (
|
|
Boolean(results[i]?.iconUrl || symbol || name) && (
|
|
<div
|
|
className={classnames('token-list__token', {
|
|
'token-list__token--selected': selectedTokens[address],
|
|
'token-list__token--disabled': tokenAlreadyAdded,
|
|
})}
|
|
onClick={onClick}
|
|
onKeyPress={(event) => event.key === 'Enter' && onClick()}
|
|
key={i}
|
|
tabIndex="0"
|
|
>
|
|
<div
|
|
className="token-list__token-icon"
|
|
style={{
|
|
backgroundImage:
|
|
results[i]?.iconUrl && `url(${results[i]?.iconUrl})`,
|
|
}}
|
|
/>
|
|
<div className="token-list__token-data">
|
|
<span className="token-list__token-name">{`${name} (${symbol})`}</span>
|
|
</div>
|
|
</div>
|
|
)
|
|
);
|
|
})}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
}
|