Merge branch 'develop' into handle-import-account-failure-in-ui

feature/default_network_editable
Dan 7 years ago
commit 49f0df3174
  1. 9
      CHANGELOG.md
  2. 2
      app/manifest.json
  3. 85
      app/scripts/controllers/preferences.js
  4. 22
      app/scripts/lib/bug-notifier.js
  5. 2
      app/scripts/lib/setupRaven.js
  6. 25
      app/scripts/metamask-controller.js
  7. 28
      docs/publishing.md
  8. 17
      mascara/src/app/first-time/index.css
  9. 23
      package-lock.json
  10. 32
      test/unit/app/controllers/metamask-controller-test.js
  11. 2
      ui/app/components/index.scss
  12. 2
      ui/app/components/modals/edit-account-name-modal.js
  13. 2
      ui/app/components/modals/hide-token-confirmation-modal.js
  14. 2
      ui/app/components/modals/shapeshift-deposit-tx-modal.js
  15. 2
      ui/app/components/selected-account/index.js
  16. 38
      ui/app/components/selected-account/index.scss
  17. 60
      ui/app/components/selected-account/selected-account.component.js
  18. 13
      ui/app/components/selected-account/selected-account.container.js
  19. 4
      ui/app/components/token-cell.js
  20. 28
      ui/app/components/tx-view.js
  21. 4
      ui/app/css/itcss/components/account-menu.scss
  22. 1
      ui/app/css/itcss/components/hero-balance.scss
  23. 13
      ui/app/css/itcss/components/token-list.scss

@ -2,6 +2,15 @@
## Current Master
- Fixes issue where old nicknames were kept around causing errors.
## 4.7.2 Sun Jun 03 2018
- Fix bug preventing users from logging in. Internally accounts and identities were out of sync.
- Fix support links to point to new support system (Zendesk)
- Fix bug in migration #26 ( moving account nicknames to preferences )
- Clears account nicknames on restore from seedPhrase
## 4.7.1 Fri Jun 01 2018
- Fix bug where errors were not returned to Dapps.

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

@ -1,6 +1,9 @@
const ObservableStore = require('obs-store')
const normalizeAddress = require('eth-sig-util').normalize
const extend = require('xtend')
const notifier = require('../lib/bug-notifier')
const log = require('loglevel')
const { version } = require('../../manifest.json')
class PreferencesController {
@ -28,7 +31,12 @@ class PreferencesController {
featureFlags: {},
currentLocale: opts.initLangCode,
identities: {},
lostIdentities: {},
}, opts.initState)
this.getFirstTimeInfo = opts.getFirstTimeInfo || null
this.notifier = opts.notifier || notifier
this.store = new ObservableStore(initState)
}
// PUBLIC METHODS
@ -63,6 +71,13 @@ class PreferencesController {
this.store.updateState({ currentLocale: key })
}
/**
* Updates identities to only include specified addresses. Removes identities
* not included in addresses array
*
* @param {string[]} addresses An array of hex addresses
*
*/
setAddresses (addresses) {
const oldIdentities = this.store.getState().identities
const identities = addresses.reduce((ids, address, index) => {
@ -73,6 +88,76 @@ class PreferencesController {
this.store.updateState({ identities })
}
/**
* Adds addresses to the identities object without removing identities
*
* @param {string[]} addresses An array of hex addresses
*
*/
addAddresses (addresses) {
const identities = this.store.getState().identities
addresses.forEach((address) => {
// skip if already exists
if (identities[address]) return
// add missing identity
const identityCount = Object.keys(identities).length
identities[address] = { name: `Account ${identityCount + 1}`, address }
})
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
*

@ -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

@ -66,7 +66,7 @@ function simplifyErrorMessages(report) {
function rewriteErrorMessages(report, rewriteFn) {
// rewrite top level message
report.message = rewriteFn(report.message)
if (report.message) report.message = rewriteFn(report.message)
// rewrite each exception message
if (report.exception && report.exception.values) {
report.exception.values.forEach(item => {

@ -85,6 +85,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.preferencesController = new PreferencesController({
initState: initState.PreferencesController,
initLangCode: opts.initLangCode,
getFirstTimeInfo: () => initState.firstTimeInfo,
})
// currency controller
@ -139,6 +140,8 @@ module.exports = class MetamaskController extends EventEmitter {
const address = addresses[0]
this.preferencesController.setSelectedAddress(address)
}
// ensure preferences + identities controller know about all addresses
this.preferencesController.addAddresses(addresses)
this.accountTracker.syncWithAddresses(addresses)
})
@ -354,7 +357,7 @@ module.exports = class MetamaskController extends EventEmitter {
importAccountWithStrategy: nodeify(this.importAccountWithStrategy, this),
// vault management
submitPassword: nodeify(keyringController.submitPassword, keyringController),
submitPassword: nodeify(this.submitPassword, this),
// network management
setProviderType: nodeify(networkController.setProviderType, networkController),
@ -456,7 +459,11 @@ module.exports = class MetamaskController extends EventEmitter {
async createNewVaultAndRestore (password, seed) {
const release = await this.createVaultMutex.acquire()
try {
// clear known identities
this.preferencesController.setAddresses([])
// create new vault
const vault = await this.keyringController.createNewVaultAndRestore(password, seed)
// set new identities
const accounts = await this.keyringController.getAccounts()
this.preferencesController.setAddresses(accounts)
this.selectFirstIdentity()
@ -468,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
* @property {string} name - The account nickname.

@ -2,18 +2,32 @@
When publishing a new version of MetaMask, we follow this procedure:
## Preparation
We try to ensure certain criteria are met before deploying:
- Deploy early in the week, to give time for emergency responses to unforeseen bugs.
- Deploy early in the day, for the same reason.
- Make sure at least one member of the support team is "on duty" to watch for new user issues coming through the support system.
- Roll out incrementally when possible, to a small number of users first, and gradually to more users.
## Incrementing Version & Changelog
Version can be automatically incremented [using our bump script](./bumping-version.md).
npm run version:bump $BUMP_TYPE` where `$BUMP_TYPE` is one of `major`, `minor`, or `patch`.
## Publishing
## Building
1. `npm run dist` to generate the latest build.
2. Publish to chrome store.
- Visit [the chrome developer dashboard](https://chrome.google.com/webstore/developer/dashboard?authuser=2).
3. Publish to firefox addon marketplace.
4. Post on Github releases page.
5. `npm run announce`, post that announcement in our public places.
While we develop on the main `develop` branch, our production version is maintained on the `master` branch.
With each pull request, the @MetaMaskBot will comment with a build of that new pull request, so after bumping the version on `develop`, open a pull request against `master`, and once the pull request is reviewed and merged, you can download those builds for publication.
## Publishing
1. Publish to chrome store.
2. Visit [the chrome developer dashboard](https://chrome.google.com/webstore/developer/dashboard?authuser=2).
3. Publish to [firefox addon marketplace](http://addons.mozilla.org/en-us/firefox/addon/ether-metamask).
4. Publish to [Opera store](https://addons.opera.com/en/extensions/details/metamask/).
5. Post on [Github releases](https://github.com/MetaMask/metamask-extension/releases) page.
6. Run the `npm run announce` script, and post that announcement in our public places.

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

23
package-lock.json generated

@ -309,7 +309,7 @@
},
"@sinonjs/formatio": {
"version": "2.0.0",
"resolved": "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
"resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
"integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==",
"dev": true,
"requires": {
@ -1500,7 +1500,8 @@
},
"dependencies": {
"bignumber.js": {
"version": "git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2"
"version": "git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2",
"from": "git+https://github.com/debris/bignumber.js.git#94d7146671b9719e00a09c29b01a691bc85048c2"
},
"chai": {
"version": "3.5.0",
@ -8013,6 +8014,7 @@
"dependencies": {
"async-eventemitter": {
"version": "github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
"from": "async-eventemitter@github:ahultgren/async-eventemitter#fa06e39e56786ba541c180061dbf2c0a5bbf951c",
"requires": {
"async": "2.6.0"
}
@ -8266,6 +8268,7 @@
"dependencies": {
"ethereumjs-abi": {
"version": "git+https://github.com/ethereumjs/ethereumjs-abi.git#4ea2fdfed09e8f99117d9362d17c6b01b64a2bcf",
"from": "git+https://github.com/ethereumjs/ethereumjs-abi.git",
"requires": {
"bn.js": "4.11.8",
"ethereumjs-util": "5.1.3"
@ -8499,7 +8502,7 @@
"eth-query": "2.1.2",
"ethereumjs-block": "1.7.0",
"ethereumjs-tx": "1.3.3",
"ethereumjs-util": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
"ethereumjs-util": "^5.0.1",
"ethereumjs-vm": "2.3.5",
"through2": "2.0.3",
"treeify": "1.1.0",
@ -8648,7 +8651,7 @@
"async": "2.6.0",
"ethereum-common": "0.2.0",
"ethereumjs-tx": "1.3.3",
"ethereumjs-util": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
"ethereumjs-util": "^5.0.0",
"merkle-patricia-tree": "2.3.0"
}
},
@ -8658,7 +8661,7 @@
"integrity": "sha1-7OBR0+/b53GtKlGNYWMsoqt17Ls=",
"requires": {
"ethereum-common": "0.0.18",
"ethereumjs-util": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9"
"ethereumjs-util": "^5.0.0"
},
"dependencies": {
"ethereum-common": {
@ -8670,6 +8673,7 @@
},
"ethereumjs-util": {
"version": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
"from": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
"requires": {
"bn.js": "4.11.8",
"create-hash": "1.1.3",
@ -9107,7 +9111,7 @@
},
"event-stream": {
"version": "3.3.4",
"resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz",
"resolved": "http://registry.npmjs.org/event-stream/-/event-stream-3.3.4.tgz",
"integrity": "sha1-SrTJoPWlTbkzi0w02Gv86PSzVXE=",
"dev": true,
"requires": {
@ -11823,6 +11827,7 @@
},
"gulp": {
"version": "github:gulpjs/gulp#71c094a51c7972d26f557899ddecab0210ef3776",
"from": "github:gulpjs/gulp#4.0",
"requires": {
"glob-watcher": "4.0.0",
"gulp-cli": "2.0.1",
@ -18205,7 +18210,7 @@
"integrity": "sha512-LKd2OoIT9Re/OG38zXbd5pyHIk2IfcOUczCwkYXl5iJIbufg9nqpweh66VfPwMkUlrEvc7YVvtQdmSrB9V9TkQ==",
"requires": {
"async": "1.5.2",
"ethereumjs-util": "github:ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
"ethereumjs-util": "^5.0.0",
"level-ws": "0.0.0",
"levelup": "1.3.9",
"memdown": "1.4.1",
@ -31227,7 +31232,8 @@
},
"dependencies": {
"bignumber.js": {
"version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934"
"version": "git+https://github.com/frozeman/bignumber.js-nolookahead.git#57692b3ecfc98bbdd6b3a516cb2353652ea49934",
"from": "git+https://github.com/frozeman/bignumber.js-nolookahead.git"
}
}
},
@ -31708,6 +31714,7 @@
},
"websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#7004c39c42ac98875ab61126e5b4a925430f592c",
"from": "websocket@git://github.com/frozeman/WebSocket-Node.git#7004c39c42ac98875ab61126e5b4a925430f592c",
"requires": {
"debug": "2.6.9",
"nan": "2.8.0",

@ -45,7 +45,7 @@ describe('MetaMaskController', function () {
encryptor: {
encrypt: function (password, object) {
this.object = object
return Promise.resolve()
return Promise.resolve('mock-encrypted')
},
decrypt: function () {
return Promise.resolve(this.object)
@ -62,6 +62,36 @@ describe('MetaMaskController', function () {
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 () {
it('gives the 50th percentile lowest accepted gas price from recentBlocksController', async function () {

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

@ -9,7 +9,7 @@ const { getSelectedAccount } = require('../../selectors')
function mapStateToProps (state) {
return {
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) {
return {
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) {
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-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', {
style: {},
}, formattedFiat),

@ -12,7 +12,7 @@ const { checksumAddress: toChecksumAddress } = require('../util')
const BalanceComponent = require('./balance-component')
const TxList = require('./tx-list')
const Identicon = require('./identicon')
const SelectedAccount = require('./selected-account')
module.exports = compose(
withRouter,
@ -103,7 +103,7 @@ TxView.prototype.renderButtons = function () {
}
TxView.prototype.render = function () {
const { selectedAddress, identity, network, isMascara } = this.props
const { isMascara } = this.props
return h('div.tx-view.flex-column', {
style: {},
@ -111,10 +111,12 @@ TxView.prototype.render = function () {
h('div.flex-row.phone-visible', {
style: {
justifyContent: 'space-between',
justifyContent: 'center',
alignItems: 'center',
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(),
}),
h('.identicon-wrapper.select-none', {
style: {
marginLeft: '0.9em',
},
}, [
h(Identicon, {
diameter: 24,
address: selectedAddress,
network,
}),
]),
h('span.account-name', {
style: {},
}, [
identity.name,
]),
h(SelectedAccount),
!isMascara && h('div.open-in-browser', {
onClick: () => global.platform.openExtensionInBrowser(),

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

@ -6,6 +6,7 @@
justify-content: flex-start;
align-items: center;
flex: 0 0 auto;
padding-top: 16px;
}
@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;
&__token-balance {
font-size: 1.5rem;
margin-right: 4px;
white-space: nowrap;
overflow: hidden;
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} {
font-size: 95%;
@ -66,7 +73,9 @@ $wallet-balance-breakpoint-range: "screen and (min-width: #{$break-large}) and (
}
&__balance-wrapper {
flex: 1 1 auto;
flex: 1;
flex-flow: row wrap;
display: flex;
min-width: 0;
}
}

Loading…
Cancel
Save