Merge pull request #4490 from MetaMask/v4.7.3

Version 4.7.3
feature/default_network_editable
Thomas Huang 7 years ago committed by GitHub
commit e1cd3562ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      CHANGELOG.md
  2. 2
      app/manifest.json
  3. 60
      app/scripts/controllers/preferences.js
  4. 22
      app/scripts/lib/bug-notifier.js
  5. 19
      app/scripts/metamask-controller.js
  6. 17
      mascara/src/app/first-time/index.css
  7. 32
      test/unit/app/controllers/metamask-controller-test.js
  8. 2
      ui/app/components/index.scss
  9. 2
      ui/app/components/modals/edit-account-name-modal.js
  10. 2
      ui/app/components/modals/hide-token-confirmation-modal.js
  11. 2
      ui/app/components/modals/shapeshift-deposit-tx-modal.js
  12. 2
      ui/app/components/selected-account/index.js
  13. 38
      ui/app/components/selected-account/index.scss
  14. 60
      ui/app/components/selected-account/selected-account.component.js
  15. 13
      ui/app/components/selected-account/selected-account.container.js
  16. 4
      ui/app/components/token-cell.js
  17. 28
      ui/app/components/tx-view.js
  18. 4
      ui/app/css/itcss/components/account-menu.scss
  19. 1
      ui/app/css/itcss/components/hero-balance.scss
  20. 13
      ui/app/css/itcss/components/token-list.scss

@ -2,6 +2,13 @@
## Current Master ## Current Master
## 4.7.3 Mon Jun 04 2018
- Hide token now uses new modal
- Indicate the current selected account on the popup account view
- Reduce height of notice container in onboarding
- Fixes issue where old nicknames were kept around causing errors
## 4.7.2 Sun Jun 03 2018 ## 4.7.2 Sun Jun 03 2018
- Fix bug preventing users from logging in. Internally accounts and identities were out of sync. - Fix bug preventing users from logging in. Internally accounts and identities were out of sync.

@ -1,7 +1,7 @@
{ {
"name": "__MSG_appName__", "name": "__MSG_appName__",
"short_name": "__MSG_appName__", "short_name": "__MSG_appName__",
"version": "4.7.2", "version": "4.7.3",
"manifest_version": 2, "manifest_version": 2,
"author": "https://metamask.io", "author": "https://metamask.io",
"description": "__MSG_appDescription__", "description": "__MSG_appDescription__",

@ -1,6 +1,9 @@
const ObservableStore = require('obs-store') const ObservableStore = require('obs-store')
const normalizeAddress = require('eth-sig-util').normalize const normalizeAddress = require('eth-sig-util').normalize
const extend = require('xtend') const extend = require('xtend')
const notifier = require('../lib/bug-notifier')
const log = require('loglevel')
const { version } = require('../../manifest.json')
class PreferencesController { class PreferencesController {
@ -28,7 +31,12 @@ class PreferencesController {
featureFlags: {}, featureFlags: {},
currentLocale: opts.initLangCode, currentLocale: opts.initLangCode,
identities: {}, identities: {},
lostIdentities: {},
}, opts.initState) }, opts.initState)
this.getFirstTimeInfo = opts.getFirstTimeInfo || null
this.notifier = opts.notifier || notifier
this.store = new ObservableStore(initState) this.store = new ObservableStore(initState)
} }
// PUBLIC METHODS // PUBLIC METHODS
@ -98,6 +106,58 @@ class PreferencesController {
this.store.updateState({ identities }) this.store.updateState({ identities })
} }
/*
* Synchronizes identity entries with known accounts.
* Removes any unknown identities, and returns the resulting selected address.
*
* @param {Array<string>} addresses known to the vault.
* @returns {Promise<string>} selectedAddress the selected address.
*/
syncAddresses (addresses) {
let { identities, lostIdentities } = this.store.getState()
let newlyLost = {}
Object.keys(identities).forEach((identity) => {
if (!addresses.includes(identity)) {
newlyLost[identity] = identities[identity]
delete identities[identity]
}
})
// Identities are no longer present.
if (Object.keys(newlyLost).length > 0) {
// Notify our servers:
const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts'
const firstTimeInfo = this.getFirstTimeInfo ? this.getFirstTimeInfo() : {}
this.notifier.notify(uri, {
accounts: Object.keys(newlyLost),
metadata: {
version,
firstTimeInfo,
},
})
.catch(log.error)
for (let key in newlyLost) {
lostIdentities[key] = newlyLost[key]
}
}
this.store.updateState({ identities, lostIdentities })
this.addAddresses(addresses)
// If the selected account is no longer valid,
// select an arbitrary other account:
let selected = this.getSelectedAddress()
if (!addresses.includes(selected)) {
selected = addresses[0]
this.setSelectedAddress(selected)
}
return selected
}
/** /**
* Setter for the `selectedAddress` property * Setter for the `selectedAddress` property
* *

@ -0,0 +1,22 @@
class BugNotifier {
notify (uri, message) {
return postData(uri, message)
}
}
function postData(uri, data) {
return fetch(uri, {
body: JSON.stringify(data), // must match 'Content-Type' header
credentials: 'same-origin', // include, same-origin, *omit
headers: {
'content-type': 'application/json',
},
method: 'POST', // *GET, POST, PUT, DELETE, etc.
mode: 'cors', // no-cors, cors, *same-origin
})
}
const notifier = new BugNotifier()
module.exports = notifier

@ -85,6 +85,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.preferencesController = new PreferencesController({ this.preferencesController = new PreferencesController({
initState: initState.PreferencesController, initState: initState.PreferencesController,
initLangCode: opts.initLangCode, initLangCode: opts.initLangCode,
getFirstTimeInfo: () => initState.firstTimeInfo,
}) })
// currency controller // currency controller
@ -356,7 +357,7 @@ module.exports = class MetamaskController extends EventEmitter {
importAccountWithStrategy: nodeify(this.importAccountWithStrategy, this), importAccountWithStrategy: nodeify(this.importAccountWithStrategy, this),
// vault management // vault management
submitPassword: nodeify(keyringController.submitPassword, keyringController), submitPassword: nodeify(this.submitPassword, this),
// network management // network management
setProviderType: nodeify(networkController.setProviderType, networkController), setProviderType: nodeify(networkController.setProviderType, networkController),
@ -474,6 +475,22 @@ module.exports = class MetamaskController extends EventEmitter {
} }
} }
/*
* Submits the user's password and attempts to unlock the vault.
* Also synchronizes the preferencesController, to ensure its schema
* is up to date with known accounts once the vault is decrypted.
*
* @param {string} password - The user's password
* @returns {Promise<object>} - The keyringController update.
*/
async submitPassword (password) {
await this.keyringController.submitPassword(password)
const accounts = await this.keyringController.getAccounts()
await this.preferencesController.syncAddresses(accounts)
return this.keyringController.fullUpdate()
}
/** /**
* @type Identity * @type Identity
* @property {string} name - The account nickname. * @property {string} name - The account nickname.

@ -123,10 +123,6 @@
width: calc(100vw - 80px); width: calc(100vw - 80px);
} }
.unique-image {
width: auto;
}
.create-password__title, .create-password__title,
.unique-image__title, .unique-image__title,
.tou__title, .tou__title,
@ -148,7 +144,7 @@
height: 100%; height: 100%;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: space-evenly; justify-content: flex-start;
margin-top: 12px; margin-top: 12px;
} }
@ -181,7 +177,6 @@
margin: 0 !important; margin: 0 !important;
padding: 16px 20px !important; padding: 16px 20px !important;
height: 30vh !important; height: 30vh !important;
width: calc(100% - 48px) !important;
} }
.backup-phrase__content-wrapper { .backup-phrase__content-wrapper {
@ -280,6 +275,12 @@
width: 335px; width: 335px;
} }
@media only screen and (max-width: 575px) {
.unique-image__body-text {
width: initial;
}
}
.unique-image__body-text + .unique-image__body-text +
.unique-image__body-text, .unique-image__body-text,
.backup-phrase__body-text + .backup-phrase__body-text +
@ -294,7 +295,7 @@
border-radius: 8px; border-radius: 8px;
background-color: #FFFFFF; background-color: #FFFFFF;
margin: 0 142px 0 0; margin: 0 142px 0 0;
height: 334px; height: 200px;
overflow-y: auto; overflow-y: auto;
color: #757575; color: #757575;
font-family: Roboto; font-family: Roboto;
@ -679,7 +680,7 @@ button.backup-phrase__confirm-seed-option:hover {
} }
.first-time-flow__input { .first-time-flow__input {
width: 350px; max-width: 350px;
} }
.first-time-flow__button { .first-time-flow__button {

@ -45,7 +45,7 @@ describe('MetaMaskController', function () {
encryptor: { encryptor: {
encrypt: function (password, object) { encrypt: function (password, object) {
this.object = object this.object = object
return Promise.resolve() return Promise.resolve('mock-encrypted')
}, },
decrypt: function () { decrypt: function () {
return Promise.resolve(this.object) return Promise.resolve(this.object)
@ -62,6 +62,36 @@ describe('MetaMaskController', function () {
sandbox.restore() sandbox.restore()
}) })
describe('submitPassword', function () {
const password = 'password'
beforeEach(async function () {
await metamaskController.createNewVaultAndKeychain(password)
})
it('removes any identities that do not correspond to known accounts.', async function () {
const fakeAddress = '0xbad0'
metamaskController.preferencesController.addAddresses([fakeAddress])
metamaskController.preferencesController.notifier = {
notify: async () => {
return true
},
}
await metamaskController.submitPassword(password)
const identities = Object.keys(metamaskController.preferencesController.store.getState().identities)
const addresses = await metamaskController.keyringController.getAccounts()
identities.forEach((identity) => {
assert.ok(addresses.includes(identity), `addresses should include all IDs: ${identity}`)
})
addresses.forEach((address) => {
assert.ok(identities.includes(address), `identities should include all Addresses: ${address}`)
})
})
})
describe('#getGasPrice', function () { describe('#getGasPrice', function () {
it('gives the 50th percentile lowest accepted gas price from recentBlocksController', async function () { it('gives the 50th percentile lowest accepted gas price from recentBlocksController', async function () {

@ -1,5 +1,7 @@
@import './export-text-container/index'; @import './export-text-container/index';
@import './selected-account/index';
@import './info-box/index'; @import './info-box/index';
@import './pages/index'; @import './pages/index';

@ -9,7 +9,7 @@ const { getSelectedAccount } = require('../../selectors')
function mapStateToProps (state) { function mapStateToProps (state) {
return { return {
selectedAccount: getSelectedAccount(state), selectedAccount: getSelectedAccount(state),
identity: state.appState.modal.modalState.identity, identity: state.appState.modal.modalState.props.identity,
} }
} }

@ -9,7 +9,7 @@ const Identicon = require('../identicon')
function mapStateToProps (state) { function mapStateToProps (state) {
return { return {
network: state.metamask.network, network: state.metamask.network,
token: state.appState.modal.modalState.token, token: state.appState.modal.modalState.props.token,
} }
} }

@ -8,7 +8,7 @@ const AccountModalContainer = require('./account-modal-container')
function mapStateToProps (state) { function mapStateToProps (state) {
return { return {
Qr: state.appState.modal.modalState.Qr, Qr: state.appState.modal.modalState.props.Qr,
} }
} }

@ -0,0 +1,2 @@
import SelectedAccount from './selected-account.container'
module.exports = SelectedAccount

@ -0,0 +1,38 @@
.selected-account {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
flex: 1;
&__name {
max-width: 200px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
text-align: center;
}
&__address {
font-size: .75rem;
color: $silver-chalice;
}
&__clickable {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 5px 15px;
border-radius: 10px;
cursor: pointer;
&:hover {
background-color: #e8e6e8;
}
&:active {
background-color: #d9d7da;
}
}
}

@ -0,0 +1,60 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import copyToClipboard from 'copy-to-clipboard'
const Tooltip = require('../tooltip-v2.js')
const addressStripper = (address = '') => {
if (address.length < 4) {
return address
}
return `${address.slice(0, 4)}...${address.slice(-4)}`
}
class SelectedAccount extends Component {
state = {
copied: false,
}
static contextTypes = {
t: PropTypes.func,
}
static propTypes = {
selectedAddress: PropTypes.string,
selectedIdentity: PropTypes.object,
}
render () {
const { t } = this.context
const { selectedAddress, selectedIdentity } = this.props
return (
<div className="selected-account">
<Tooltip
position="bottom"
title={this.state.copied ? t('copiedExclamation') : t('copyToClipboard')}
>
<div
className="selected-account__clickable"
onClick={() => {
this.setState({ copied: true })
setTimeout(() => this.setState({ copied: false }), 3000)
copyToClipboard(selectedAddress)
}}
>
<div className="selected-account__name">
{ selectedIdentity.name }
</div>
<div className="selected-account__address">
{ addressStripper(selectedAddress) }
</div>
</div>
</Tooltip>
</div>
)
}
}
export default SelectedAccount

@ -0,0 +1,13 @@
import { connect } from 'react-redux'
import SelectedAccount from './selected-account.component'
const selectors = require('../../selectors')
const mapStateToProps = state => {
return {
selectedAddress: selectors.getSelectedAddress(state),
selectedIdentity: selectors.getSelectedIdentity(state),
}
}
export default connect(mapStateToProps)(SelectedAccount)

@ -101,8 +101,8 @@ TokenCell.prototype.render = function () {
h('div.token-list-item__balance-ellipsis', null, [ h('div.token-list-item__balance-ellipsis', null, [
h('div.token-list-item__balance-wrapper', null, [ h('div.token-list-item__balance-wrapper', null, [
h('h3.token-list-item__token-balance', `${string || 0} ${symbol}`), h('div.token-list-item__token-balance', `${string || 0}`),
h('div.token-list-item__token-symbol', symbol),
showFiat && h('div.token-list-item__fiat-amount', { showFiat && h('div.token-list-item__fiat-amount', {
style: {}, style: {},
}, formattedFiat), }, formattedFiat),

@ -12,7 +12,7 @@ const { checksumAddress: toChecksumAddress } = require('../util')
const BalanceComponent = require('./balance-component') const BalanceComponent = require('./balance-component')
const TxList = require('./tx-list') const TxList = require('./tx-list')
const Identicon = require('./identicon') const SelectedAccount = require('./selected-account')
module.exports = compose( module.exports = compose(
withRouter, withRouter,
@ -103,7 +103,7 @@ TxView.prototype.renderButtons = function () {
} }
TxView.prototype.render = function () { TxView.prototype.render = function () {
const { selectedAddress, identity, network, isMascara } = this.props const { isMascara } = this.props
return h('div.tx-view.flex-column', { return h('div.tx-view.flex-column', {
style: {}, style: {},
@ -111,10 +111,12 @@ TxView.prototype.render = function () {
h('div.flex-row.phone-visible', { h('div.flex-row.phone-visible', {
style: { style: {
justifyContent: 'space-between', justifyContent: 'center',
alignItems: 'center', alignItems: 'center',
flex: '0 0 auto', flex: '0 0 auto',
margin: '10px', marginBottom: '16px',
padding: '5px',
borderBottom: '1px solid #e5e5e5',
}, },
}, [ }, [
@ -127,23 +129,7 @@ TxView.prototype.render = function () {
onClick: () => this.props.sidebarOpen ? this.props.hideSidebar() : this.props.showSidebar(), onClick: () => this.props.sidebarOpen ? this.props.hideSidebar() : this.props.showSidebar(),
}), }),
h('.identicon-wrapper.select-none', { h(SelectedAccount),
style: {
marginLeft: '0.9em',
},
}, [
h(Identicon, {
diameter: 24,
address: selectedAddress,
network,
}),
]),
h('span.account-name', {
style: {},
}, [
identity.name,
]),
!isMascara && h('div.open-in-browser', { !isMascara && h('div.open-in-browser', {
onClick: () => global.platform.openExtensionInBrowser(), onClick: () => global.platform.openExtensionInBrowser(),

@ -116,6 +116,10 @@
&__name { &__name {
color: $white; color: $white;
font-size: 18px; font-size: 18px;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
max-width: 200px;
} }
&__balance { &__balance {

@ -6,6 +6,7 @@
justify-content: flex-start; justify-content: flex-start;
align-items: center; align-items: center;
flex: 0 0 auto; flex: 0 0 auto;
padding-top: 16px;
} }
@media screen and (min-width: $break-large) { @media screen and (min-width: $break-large) {

@ -14,10 +14,17 @@ $wallet-balance-breakpoint-range: "screen and (min-width: #{$break-large}) and (
min-width: 0; min-width: 0;
&__token-balance { &__token-balance {
font-size: 1.5rem; margin-right: 4px;
white-space: nowrap; white-space: nowrap;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
min-width: 0;
max-width: 100%;
}
&__token-balance, &__token-symbol {
font-size: 1.5rem;
flex: 0 0 auto;
@media #{$wallet-balance-breakpoint-range} { @media #{$wallet-balance-breakpoint-range} {
font-size: 95%; font-size: 95%;
@ -66,7 +73,9 @@ $wallet-balance-breakpoint-range: "screen and (min-width: #{$break-large}) and (
} }
&__balance-wrapper { &__balance-wrapper {
flex: 1 1 auto; flex: 1;
flex-flow: row wrap;
display: flex;
min-width: 0; min-width: 0;
} }
} }

Loading…
Cancel
Save