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/pages/settings/experimental-tab/experimental-tab.component.js

200 lines
6.0 KiB

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import ToggleButton from '../../../components/ui/toggle-button';
export default class ExperimentalTab extends PureComponent {
static contextTypes = {
t: PropTypes.func,
metricsEvent: PropTypes.func,
};
static propTypes = {
useTokenDetection: PropTypes.bool,
setUseTokenDetection: PropTypes.func,
useCollectibleDetection: PropTypes.bool,
setUseCollectibleDetection: PropTypes.func,
setOpenSeaEnabled: PropTypes.func,
openSeaEnabled: PropTypes.bool,
eip1559V2Enabled: PropTypes.bool,
setEIP1559V2Enabled: PropTypes.func,
};
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) => {
this.context.metricsEvent({
eventOpts: {
category: 'Settings',
action: 'Token Detection',
name: 'Token Detection',
},
});
setUseTokenDetection(!value);
}}
offLabel={t('off')}
onLabel={t('on')}
/>
</div>
</div>
</div>
);
}
renderCollectibleDetectionToggle() {
if (!process.env.COLLECTIBLES_V1) {
return null;
}
const { t } = this.context;
const {
useCollectibleDetection,
setUseCollectibleDetection,
openSeaEnabled,
} = this.props;
return (
<div className="settings-page__content-row">
<div className="settings-page__content-item">
<span>{t('useCollectibleDetection')}</span>
<div className="settings-page__content-description">
{t('useCollectibleDetectionDescription')}
</div>
</div>
<div className="settings-page__content-item">
<div className="settings-page__content-item-col">
<ToggleButton
disabled={!openSeaEnabled}
value={useCollectibleDetection}
onToggle={(value) => {
this.context.metricsEvent({
eventOpts: {
category: 'Settings',
action: 'Collectible Detection',
name: 'Collectible Detection',
},
});
setUseCollectibleDetection(!value);
}}
offLabel={t('off')}
onLabel={t('on')}
/>
</div>
</div>
</div>
);
}
renderOpenSeaEnabledToggle() {
if (!process.env.COLLECTIBLES_V1) {
return null;
}
const { t } = this.context;
const { openSeaEnabled, setOpenSeaEnabled } = this.props;
return (
<div className="settings-page__content-row">
<div className="settings-page__content-item">
<span>{t('enableOpenSeaAPI')}</span>
<div className="settings-page__content-description">
{t('enableOpenSeaAPIDescription')}
</div>
</div>
<div className="settings-page__content-item">
<div className="settings-page__content-item-col">
<ToggleButton
value={openSeaEnabled}
onToggle={(value) => {
this.context.metricsEvent({
eventOpts: {
category: 'Settings',
action: 'Enabled/Disable OpenSea',
name: 'Enabled/Disable OpenSea',
},
});
setOpenSeaEnabled(!value);
}}
offLabel={t('off')}
onLabel={t('on')}
/>
</div>
</div>
</div>
);
}
renderEIP1559V2EnabledToggle() {
const EIP_1559_V2_ENABLED =
// This is a string in unit tests but is a boolean in the browser
process.env.EIP_1559_V2 === true || process.env.EIP_1559_V2 === 'true';
if (!EIP_1559_V2_ENABLED) {
return null;
}
const { t } = this.context;
const { eip1559V2Enabled, setEIP1559V2Enabled } = this.props;
return (
<div className="settings-page__content-row">
<div className="settings-page__content-item">
<span>{t('enableEIP1559V2')}</span>
<div className="settings-page__content-description">
{t('enableEIP1559V2Description', [
<a
key="eip_page_link"
href="https://metamask.io/1559.html"
rel="noopener noreferrer"
target="_blank"
>
{t('learnMoreUpperCase')}
</a>,
])}
</div>
</div>
<div className="settings-page__content-item">
<div className="settings-page__content-item-col">
<ToggleButton
value={eip1559V2Enabled}
onToggle={(value) => {
this.context.metricsEvent({
eventOpts: {
category: 'Settings',
action: 'Enabled/Disable OpenSea',
name: 'Enabled/Disable OpenSea',
},
});
setEIP1559V2Enabled(!value);
}}
offLabel={t('off')}
onLabel={t('on')}
/>
</div>
</div>
</div>
);
}
render() {
return (
<div className="settings-page__body">
{this.renderTokenDetectionToggle()}
{this.renderOpenSeaEnabledToggle()}
{this.renderCollectibleDetectionToggle()}
{this.renderEIP1559V2EnabledToggle()}
</div>
);
}
}