A Metamask fork with Infura removed and default networks editable
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
ciphermask/ui/components/app/asset-list/detetcted-tokens-link/detected-tokens-link.js

57 lines
1.6 KiB

import React, { useContext } from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import Box from '../../../ui/box/box';
import Button from '../../../ui/button';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { getDetectedTokensInCurrentNetwork } from '../../../../selectors';
import { MetaMetricsContext } from '../../../../contexts/metametrics';
import {
EVENT,
EVENT_NAMES,
} from '../../../../../shared/constants/metametrics';
const DetectedTokensLink = ({ className = '', setShowDetectedTokens }) => {
const t = useI18nContext();
const trackEvent = useContext(MetaMetricsContext);
const detectedTokens = useSelector(getDetectedTokensInCurrentNetwork);
const detectedTokensDetails = detectedTokens.map(
({ address, symbol }) => `${symbol} - ${address}`,
);
const onClick = () => {
setShowDetectedTokens(true);
trackEvent({
event: EVENT_NAMES.TOKEN_IMPORT_CLICKED,
category: EVENT.CATEGORIES.WALLET,
properties: {
source: EVENT.SOURCE.TOKEN.DETECTED,
tokens: detectedTokensDetails,
},
});
};
return (
<Box
className={classNames('detected-tokens-link', className)}
marginTop={1}
>
<Button
type="link"
className="detected-tokens-link__link"
onClick={onClick}
>
{t('numberOfNewTokensDetected', [detectedTokens.length])}
</Button>
</Box>
);
};
DetectedTokensLink.propTypes = {
setShowDetectedTokens: PropTypes.func.isRequired,
className: PropTypes.string,
};
export default DetectedTokensLink;