Default Privacy Mode to ON, allow force sharing address (#6904)
parent
4d88e1cf86
commit
e9a63d5d5b
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 1.0 KiB |
@ -0,0 +1,33 @@ |
||||
const version = 34 |
||||
const clone = require('clone') |
||||
|
||||
/** |
||||
* The purpose of this migration is to enable the {@code privacyMode} feature flag and set the user as being migrated |
||||
* if it was {@code false}. |
||||
*/ |
||||
module.exports = { |
||||
version, |
||||
migrate: async function (originalVersionedData) { |
||||
const versionedData = clone(originalVersionedData) |
||||
versionedData.meta.version = version |
||||
const state = versionedData.data |
||||
versionedData.data = transformState(state) |
||||
return versionedData |
||||
}, |
||||
} |
||||
|
||||
function transformState (state) { |
||||
const { PreferencesController } = state |
||||
|
||||
if (PreferencesController) { |
||||
const featureFlags = PreferencesController.featureFlags || {} |
||||
|
||||
if (!featureFlags.privacyMode && typeof PreferencesController.migratedPrivacyMode === 'undefined') { |
||||
// Mark the state has being migrated and enable Privacy Mode
|
||||
PreferencesController.migratedPrivacyMode = true |
||||
featureFlags.privacyMode = true |
||||
} |
||||
} |
||||
|
||||
return state |
||||
} |
@ -1,77 +0,0 @@ |
||||
const {EventEmitter} = require('events') |
||||
const async = require('async') |
||||
const Dnode = require('dnode') |
||||
const Eth = require('ethjs') |
||||
const EthQuery = require('eth-query') |
||||
const launchMetamaskUi = require('../../ui') |
||||
const StreamProvider = require('web3-stream-provider') |
||||
const {setupMultiplex} = require('./lib/stream-utils.js') |
||||
|
||||
module.exports = initializePopup |
||||
|
||||
/** |
||||
* Asynchronously initializes the MetaMask popup UI |
||||
* |
||||
* @param {{ container: Element, connectionStream: * }} config Popup configuration object |
||||
* @param {Function} cb Called when initialization is complete |
||||
*/ |
||||
function initializePopup ({ container, connectionStream }, cb) { |
||||
// setup app
|
||||
async.waterfall([ |
||||
(cb) => connectToAccountManager(connectionStream, cb), |
||||
(backgroundConnection, cb) => launchMetamaskUi({ container, backgroundConnection }, cb), |
||||
], cb) |
||||
} |
||||
|
||||
/** |
||||
* Establishes streamed connections to background scripts and a Web3 provider |
||||
* |
||||
* @param {PortDuplexStream} connectionStream PortStream instance establishing a background connection |
||||
* @param {Function} cb Called when controller connection is established |
||||
*/ |
||||
function connectToAccountManager (connectionStream, cb) { |
||||
// setup communication with background
|
||||
// setup multiplexing
|
||||
const mx = setupMultiplex(connectionStream) |
||||
// connect features
|
||||
setupControllerConnection(mx.createStream('controller'), cb) |
||||
setupWeb3Connection(mx.createStream('provider')) |
||||
} |
||||
|
||||
/** |
||||
* Establishes a streamed connection to a Web3 provider |
||||
* |
||||
* @param {PortDuplexStream} connectionStream PortStream instance establishing a background connection |
||||
*/ |
||||
function setupWeb3Connection (connectionStream) { |
||||
const providerStream = new StreamProvider() |
||||
providerStream.pipe(connectionStream).pipe(providerStream) |
||||
connectionStream.on('error', console.error.bind(console)) |
||||
providerStream.on('error', console.error.bind(console)) |
||||
global.ethereumProvider = providerStream |
||||
global.ethQuery = new EthQuery(providerStream) |
||||
global.eth = new Eth(providerStream) |
||||
} |
||||
|
||||
/** |
||||
* Establishes a streamed connection to the background account manager |
||||
* |
||||
* @param {PortDuplexStream} connectionStream PortStream instance establishing a background connection |
||||
* @param {Function} cb Called when the remote account manager connection is established |
||||
*/ |
||||
function setupControllerConnection (connectionStream, cb) { |
||||
// this is a really sneaky way of adding EventEmitter api
|
||||
// to a bi-directional dnode instance
|
||||
const eventEmitter = new EventEmitter() |
||||
const backgroundDnode = Dnode({ |
||||
sendUpdate: function (state) { |
||||
eventEmitter.emit('update', state) |
||||
}, |
||||
}) |
||||
connectionStream.pipe(backgroundDnode).pipe(connectionStream) |
||||
backgroundDnode.once('remote', function (backgroundConnection) { |
||||
// setup push events
|
||||
backgroundConnection.on = eventEmitter.on.bind(eventEmitter) |
||||
cb(null, backgroundConnection) |
||||
}) |
||||
} |
@ -0,0 +1,110 @@ |
||||
import React, { PureComponent } from 'react' |
||||
import {Tooltip as ReactTippy} from 'react-tippy' |
||||
import PropTypes from 'prop-types' |
||||
import Button from '../../ui/button' |
||||
|
||||
export default class HomeNotification extends PureComponent { |
||||
static contextTypes = { |
||||
metricsEvent: PropTypes.func, |
||||
} |
||||
|
||||
static defaultProps = { |
||||
onAccept: null, |
||||
ignoreText: null, |
||||
onIgnore: null, |
||||
infoText: null, |
||||
} |
||||
|
||||
static propTypes = { |
||||
acceptText: PropTypes.string.isRequired, |
||||
onAccept: PropTypes.func, |
||||
ignoreText: PropTypes.string, |
||||
onIgnore: PropTypes.func, |
||||
descriptionText: PropTypes.string.isRequired, |
||||
infoText: PropTypes.string, |
||||
} |
||||
|
||||
handleAccept = () => { |
||||
this.props.onAccept() |
||||
} |
||||
|
||||
handleIgnore = () => { |
||||
this.props.onIgnore() |
||||
} |
||||
|
||||
render () { |
||||
const { descriptionText, acceptText, onAccept, ignoreText, onIgnore, infoText } = this.props |
||||
|
||||
return ( |
||||
<div className="home-notification"> |
||||
<div className="home-notification__header"> |
||||
<div className="home-notification__header-container"> |
||||
<img |
||||
className="home-notification__icon" |
||||
alt="" |
||||
src="images/icons/connect.svg" |
||||
/> |
||||
<div className="home-notification__text"> |
||||
{ descriptionText } |
||||
</div> |
||||
</div> |
||||
{ |
||||
infoText ? ( |
||||
<ReactTippy |
||||
style={{ |
||||
display: 'flex', |
||||
}} |
||||
html={( |
||||
<p className="home-notification-tooltip__content"> |
||||
{infoText} |
||||
</p> |
||||
)} |
||||
offset={-36} |
||||
distance={36} |
||||
animation="none" |
||||
position="top" |
||||
arrow |
||||
theme="info" |
||||
> |
||||
<img |
||||
alt="" |
||||
src="images/icons/info.svg" |
||||
/> |
||||
</ReactTippy> |
||||
) : ( |
||||
null |
||||
) |
||||
} |
||||
</div> |
||||
<div className="home-notification__buttons"> |
||||
{ |
||||
(onAccept && acceptText) ? ( |
||||
<Button |
||||
type="primary" |
||||
className="home-notification__accept-button" |
||||
onClick={this.handleAccept} |
||||
> |
||||
{ acceptText } |
||||
</Button> |
||||
) : ( |
||||
null |
||||
) |
||||
} |
||||
{ |
||||
(onIgnore && ignoreText) ? ( |
||||
<Button |
||||
type="secondary" |
||||
className="home-notification__ignore-button" |
||||
onClick={this.handleIgnore} |
||||
> |
||||
{ ignoreText } |
||||
</Button> |
||||
) : ( |
||||
null |
||||
) |
||||
} |
||||
</div> |
||||
</div> |
||||
) |
||||
} |
||||
} |
@ -0,0 +1 @@ |
||||
export { default } from './home-notification.component' |
@ -0,0 +1,106 @@ |
||||
.tippy-tooltip.info-theme { |
||||
background: rgba(36, 41, 46, 0.9); |
||||
color: $white; |
||||
border-radius: 8px; |
||||
} |
||||
|
||||
.home-notification { |
||||
background: rgba(36, 41, 46, 0.9); |
||||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12); |
||||
border-radius: 8px; |
||||
height: 116px; |
||||
padding: 16px; |
||||
margin: 8px; |
||||
|
||||
display: flex; |
||||
flex-flow: column; |
||||
justify-content: space-between; |
||||
|
||||
&__header-container { |
||||
display: flex; |
||||
} |
||||
|
||||
&__header { |
||||
display: flex; |
||||
align-items: center; |
||||
justify-content: space-between; |
||||
} |
||||
|
||||
&__text { |
||||
font-family: Roboto, 'sans-serif'; |
||||
font-style: normal; |
||||
font-weight: normal; |
||||
font-size: 12px; |
||||
color: $white; |
||||
margin-left: 10px; |
||||
margin-right: 8px; |
||||
} |
||||
|
||||
.fa-info-circle { |
||||
color: #6A737D; |
||||
} |
||||
|
||||
&__ignore-button { |
||||
border: 2px solid #6A737D; |
||||
box-sizing: border-box; |
||||
border-radius: 6px; |
||||
color: $white; |
||||
background-color: inherit; |
||||
height: 34px; |
||||
width: 155px; |
||||
padding: 0; |
||||
|
||||
&:hover { |
||||
border-color: #6A737D; |
||||
background-color: #6A737D; |
||||
} |
||||
|
||||
&:active { |
||||
background-color: #141618; |
||||
} |
||||
} |
||||
|
||||
&__accept-button { |
||||
border: 2px solid #6A737D; |
||||
box-sizing: border-box; |
||||
border-radius: 6px; |
||||
color: $white; |
||||
background-color: inherit; |
||||
height: 34px; |
||||
width: 155px; |
||||
padding: 0; |
||||
|
||||
&:hover { |
||||
border-color: #6A737D; |
||||
background-color: #6A737D; |
||||
} |
||||
|
||||
&:active { |
||||
background-color: #141618; |
||||
} |
||||
} |
||||
|
||||
&__buttons { |
||||
display: flex; |
||||
width: 100%; |
||||
justify-content: space-between; |
||||
flex-direction: row-reverse; |
||||
} |
||||
} |
||||
|
||||
.home-notification-tooltip { |
||||
&__tooltip-container { |
||||
display: flex; |
||||
} |
||||
|
||||
&__content { |
||||
font-family: Roboto, 'sans-serif'; |
||||
font-style: normal; |
||||
font-weight: normal; |
||||
font-size: 12px; |
||||
color: $white; |
||||
text-align: left; |
||||
display: inline-block; |
||||
width: 200px; |
||||
} |
||||
} |
Loading…
Reference in new issue