Adding Token Detection Toggle to Security & Privacy (#11851)

feature/default_network_editable
Niranjana Binoy 3 years ago committed by GitHub
parent 490d3b8d40
commit 18c35ad91e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      app/_locales/en/messages.json
  2. 29
      ui/pages/settings/security-tab/security-tab.component.js
  3. 4
      ui/pages/settings/security-tab/security-tab.container.js

@ -2696,6 +2696,12 @@
"usePhishingDetectionDescription": { "usePhishingDetectionDescription": {
"message": "Display a warning for phishing domains targeting Ethereum users" "message": "Display a warning for phishing domains targeting Ethereum users"
}, },
"useTokenDetection": {
"message": "Use Token Detection"
},
"useTokenDetectionDescription": {
"message": "We use third-party APIs to detect and display new tokens sent to your wallet. Turn this off if you don’t want MetaMask to pull data from those those services."
},
"usedByClients": { "usedByClients": {
"message": "Used by a variety of different clients" "message": "Used by a variety of different clients"
}, },

@ -19,6 +19,8 @@ export default class SecurityTab extends PureComponent {
setShowIncomingTransactionsFeatureFlag: PropTypes.func.isRequired, setShowIncomingTransactionsFeatureFlag: PropTypes.func.isRequired,
setUsePhishDetect: PropTypes.func.isRequired, setUsePhishDetect: PropTypes.func.isRequired,
usePhishDetect: PropTypes.bool.isRequired, usePhishDetect: PropTypes.bool.isRequired,
useTokenDetection: PropTypes.bool.isRequired,
setUseTokenDetection: PropTypes.func.isRequired,
}; };
renderSeedWords() { renderSeedWords() {
@ -141,6 +143,32 @@ export default class SecurityTab extends PureComponent {
); );
} }
renderTokenDetectionToggle() {
const { t } = this.context;
const { useTokenDetection, setUseTokenDetection } = this.props;
return (
<div className="settings-page__content-row">
<div className="settings-page__content-item">
<span>{t('useTokenDetection')}</span>
<div className="settings-page__content-description">
{t('useTokenDetectionDescription')}
</div>
</div>
<div className="settings-page__content-item">
<div className="settings-page__content-item-col">
<ToggleButton
value={useTokenDetection}
onToggle={(value) => setUseTokenDetection(!value)}
offLabel={t('off')}
onLabel={t('on')}
/>
</div>
</div>
</div>
);
}
render() { render() {
const { warning } = this.props; const { warning } = this.props;
@ -151,6 +179,7 @@ export default class SecurityTab extends PureComponent {
{this.renderIncomingTransactionsOptIn()} {this.renderIncomingTransactionsOptIn()}
{this.renderPhishingDetectionToggle()} {this.renderPhishingDetectionToggle()}
{this.renderMetaMetricsOptIn()} {this.renderMetaMetricsOptIn()}
{this.renderTokenDetectionToggle()}
</div> </div>
); );
} }

@ -5,6 +5,7 @@ import {
setFeatureFlag, setFeatureFlag,
setParticipateInMetaMetrics, setParticipateInMetaMetrics,
setUsePhishDetect, setUsePhishDetect,
setUseTokenDetection,
} from '../../../store/actions'; } from '../../../store/actions';
import SecurityTab from './security-tab.component'; import SecurityTab from './security-tab.component';
@ -17,6 +18,7 @@ const mapStateToProps = (state) => {
featureFlags: { showIncomingTransactions } = {}, featureFlags: { showIncomingTransactions } = {},
participateInMetaMetrics, participateInMetaMetrics,
usePhishDetect, usePhishDetect,
useTokenDetection,
} = metamask; } = metamask;
return { return {
@ -24,6 +26,7 @@ const mapStateToProps = (state) => {
showIncomingTransactions, showIncomingTransactions,
participateInMetaMetrics, participateInMetaMetrics,
usePhishDetect, usePhishDetect,
useTokenDetection,
}; };
}; };
@ -34,6 +37,7 @@ const mapDispatchToProps = (dispatch) => {
setShowIncomingTransactionsFeatureFlag: (shouldShow) => setShowIncomingTransactionsFeatureFlag: (shouldShow) =>
dispatch(setFeatureFlag('showIncomingTransactions', shouldShow)), dispatch(setFeatureFlag('showIncomingTransactions', shouldShow)),
setUsePhishDetect: (val) => dispatch(setUsePhishDetect(val)), setUsePhishDetect: (val) => dispatch(setUsePhishDetect(val)),
setUseTokenDetection: (val) => dispatch(setUseTokenDetection(val)),
}; };
}; };

Loading…
Cancel
Save