1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-11 20:27:12 +01:00

Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Bruno 2018-06-05 21:37:45 -04:00
commit 4371801083
67 changed files with 841 additions and 317 deletions

View File

@ -2,6 +2,22 @@
## Current Master ## 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.
## 4.7.0 Wed May 30 2018
- Fix Brave support
- Adds error messages when passwords don't match in onboarding flow. - Adds error messages when passwords don't match in onboarding flow.
- Adds modal notification if a retry in the process of being confirmed is dropped. - Adds modal notification if a retry in the process of being confirmed is dropped.
- New unlock screen design. - New unlock screen design.

View File

@ -27,7 +27,9 @@ If you're a web dapp developer, we've got two types of guides for you:
## Building locally ## Building locally
- Install [Node.js](https://nodejs.org/en/) version 6.3.1 or later. - Install [Node.js](https://nodejs.org/en/) version 6.3.1 or later.
- Install local dependencies with `npm install`. - Install dependencies:
- For node versions up to and including 9, install local dependencies with `npm install`.
- For node versions 10 and later, install [Yarn](https://yarnpkg.com/lang/en/docs/install/) and use `yarn install`.
- Install gulp globally with `npm install -g gulp-cli`. - Install gulp globally with `npm install -g gulp-cli`.
- Build the project to the `./dist/` folder with `gulp build`. - Build the project to the `./dist/` folder with `gulp build`.
- Optionally, to rebuild on file changes, run `gulp dev`. - Optionally, to rebuild on file changes, run `gulp dev`.

View File

@ -523,6 +523,9 @@
"networks": { "networks": {
"message": "Networks" "message": "Networks"
}, },
"nevermind": {
"message": "Nevermind"
},
"newAccount": { "newAccount": {
"message": "New Account" "message": "New Account"
}, },
@ -637,9 +640,15 @@
"rejected": { "rejected": {
"message": "Rejected" "message": "Rejected"
}, },
"reset": {
"message": "Reset"
},
"resetAccount": { "resetAccount": {
"message": "Reset Account" "message": "Reset Account"
}, },
"resetAccountDescription": {
"message": "Resetting your account will clear your transaction history."
},
"restoreFromSeed": { "restoreFromSeed": {
"message": "Restore account?" "message": "Restore account?"
}, },
@ -897,7 +906,7 @@
"message": "Welcome to the New UI (Beta)" "message": "Welcome to the New UI (Beta)"
}, },
"uiWelcomeMessage": { "uiWelcomeMessage": {
"message": "You are now using the new Metamask UI. Take a look around, try out new features like sending tokens, and let us know if you have any issues." "message": "You are now using the new Metamask UI."
}, },
"unapproved": { "unapproved": {
"message": "Unapproved" "message": "Unapproved"

View File

@ -1,7 +1,7 @@
{ {
"name": "__MSG_appName__", "name": "__MSG_appName__",
"short_name": "__MSG_appName__", "short_name": "__MSG_appName__",
"version": "4.6.1", "version": "4.7.2",
"manifest_version": 2, "manifest_version": 2,
"author": "https://metamask.io", "author": "https://metamask.io",
"description": "__MSG_appDescription__", "description": "__MSG_appDescription__",
@ -68,6 +68,8 @@
"matches": [ "matches": [
"https://metamask.io/*" "https://metamask.io/*"
], ],
"ids": ["*"] "ids": [
"*"
]
} }
} }

View File

@ -2,6 +2,7 @@ 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')
class PreferencesController { class PreferencesController {
/** /**
@ -28,7 +29,11 @@ class PreferencesController {
featureFlags: {}, featureFlags: {},
currentLocale: opts.initLangCode, currentLocale: opts.initLangCode,
identities: {}, identities: {},
lostIdentities: {},
}, opts.initState) }, opts.initState)
this.diagnostics = opts.diagnostics
this.store = new ObservableStore(initState) this.store = new ObservableStore(initState)
} }
// PUBLIC METHODS // PUBLIC METHODS
@ -63,6 +68,13 @@ class PreferencesController {
this.store.updateState({ currentLocale: key }) 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) { setAddresses (addresses) {
const oldIdentities = this.store.getState().identities const oldIdentities = this.store.getState().identities
const identities = addresses.reduce((ids, address, index) => { const identities = addresses.reduce((ids, address, index) => {
@ -73,6 +85,68 @@ class PreferencesController {
this.store.updateState({ identities }) 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:
if (this.diagnostics) this.diagnostics.reportOrphans(newlyLost)
// store lost accounts
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
* *

View File

@ -0,0 +1,17 @@
const MessageManager = require('./lib/message-manager')
const PersonalMessageManager = require('./lib/personal-message-manager')
const TypedMessageManager = require('./lib/typed-message-manager')
class UserActionController {
constructor (opts = {}) {
this.messageManager = new MessageManager()
this.personalMessageManager = new PersonalMessageManager()
this.typedMessageManager = new TypedMessageManager()
}
}
module.exports = UserActionController

View File

@ -59,6 +59,7 @@ function createErrorMiddleware ({ override = true } = {}) {
if (!error) { return done() } if (!error) { return done() }
sanitizeRPCError(error) sanitizeRPCError(error)
log.error(`MetaMask - RPC Error: ${error.message}`, error) log.error(`MetaMask - RPC Error: ${error.message}`, error)
done()
}) })
} }
} }

View File

@ -0,0 +1,71 @@
class DiagnosticsReporter {
constructor ({ firstTimeInfo, version }) {
this.firstTimeInfo = firstTimeInfo
this.version = version
}
async reportOrphans(orphans) {
try {
return await this.submit({
accounts: Object.keys(orphans),
metadata: {
type: 'orphans',
},
})
} catch (err) {
console.error('DiagnosticsReporter - "reportOrphans" encountered an error:')
console.error(err)
}
}
async reportMultipleKeyrings(rawKeyrings) {
try {
const keyrings = await Promise.all(rawKeyrings.map(async (keyring, index) => {
return {
index,
type: keyring.type,
accounts: await keyring.getAccounts(),
}
}))
return await this.submit({
accounts: [],
metadata: {
type: 'keyrings',
keyrings,
},
})
} catch (err) {
console.error('DiagnosticsReporter - "reportMultipleKeyrings" encountered an error:')
console.error(err)
}
}
async submit (message) {
try {
// add metadata
message.metadata.version = this.version
message.metadata.firstTimeInfo = this.firstTimeInfo
return await postData(message)
} catch (err) {
console.error('DiagnosticsReporter - "submit" encountered an error:')
throw err
}
}
}
function postData(data) {
const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts'
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
})
}
module.exports = DiagnosticsReporter

View File

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

View File

@ -46,6 +46,7 @@ const GWEI_BN = new BN('1000000000')
const percentile = require('percentile') const percentile = require('percentile')
const seedPhraseVerifier = require('./lib/seed-phrase-verifier') const seedPhraseVerifier = require('./lib/seed-phrase-verifier')
const cleanErrorStack = require('./lib/cleanErrorStack') const cleanErrorStack = require('./lib/cleanErrorStack')
const DiagnosticsReporter = require('./lib/diagnostics-reporter')
const log = require('loglevel') const log = require('loglevel')
module.exports = class MetamaskController extends EventEmitter { module.exports = class MetamaskController extends EventEmitter {
@ -64,6 +65,12 @@ module.exports = class MetamaskController extends EventEmitter {
const initState = opts.initState || {} const initState = opts.initState || {}
this.recordFirstTimeInfo(initState) this.recordFirstTimeInfo(initState)
// metamask diagnostics reporter
this.diagnostics = opts.diagnostics || new DiagnosticsReporter({
firstTimeInfo: initState.firstTimeInfo,
version,
})
// platform-specific api // platform-specific api
this.platform = opts.platform this.platform = opts.platform
@ -85,6 +92,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,
diagnostics: this.diagnostics,
}) })
// currency controller // currency controller
@ -139,6 +147,8 @@ module.exports = class MetamaskController extends EventEmitter {
const address = addresses[0] const address = addresses[0]
this.preferencesController.setSelectedAddress(address) this.preferencesController.setSelectedAddress(address)
} }
// ensure preferences + identities controller know about all addresses
this.preferencesController.addAddresses(addresses)
this.accountTracker.syncWithAddresses(addresses) this.accountTracker.syncWithAddresses(addresses)
}) })
@ -354,7 +364,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),
@ -456,7 +466,11 @@ module.exports = class MetamaskController extends EventEmitter {
async createNewVaultAndRestore (password, seed) { async createNewVaultAndRestore (password, seed) {
const release = await this.createVaultMutex.acquire() const release = await this.createVaultMutex.acquire()
try { try {
// clear known identities
this.preferencesController.setAddresses([])
// create new vault
const vault = await this.keyringController.createNewVaultAndRestore(password, seed) const vault = await this.keyringController.createNewVaultAndRestore(password, seed)
// set new identities
const accounts = await this.keyringController.getAccounts() const accounts = await this.keyringController.getAccounts()
this.preferencesController.setAddresses(accounts) this.preferencesController.setAddresses(accounts)
this.selectFirstIdentity() this.selectFirstIdentity()
@ -468,6 +482,28 @@ 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()
// verify keyrings
const nonSimpleKeyrings = this.keyringController.keyrings.filter(keyring => keyring.type !== 'Simple Key Pair')
if (nonSimpleKeyrings.length > 1 && this.diagnostics) {
await this.diagnostics.reportMultipleKeyrings(nonSimpleKeyrings)
}
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.

View File

@ -27,7 +27,7 @@ module.exports = {
function transformState (state) { function transformState (state) {
if (!state.KeyringController || !state.PreferencesController) { if (!state.KeyringController || !state.PreferencesController) {
return return state
} }
if (!state.KeyringController.walletNicknames) { if (!state.KeyringController.walletNicknames) {

View File

@ -2,18 +2,32 @@
When publishing a new version of MetaMask, we follow this procedure: 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 ## Incrementing Version & Changelog
Version can be automatically incremented [using our bump script](./bumping-version.md). 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`. npm run version:bump $BUMP_TYPE` where `$BUMP_TYPE` is one of `major`, `minor`, or `patch`.
## Building
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 ## Publishing
1. `npm run dist` to generate the latest build. 1. Publish to chrome store.
2. Publish to chrome store. 2. Visit [the chrome developer dashboard](https://chrome.google.com/webstore/developer/dashboard?authuser=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).
3. Publish to firefox addon marketplace. 4. Publish to [Opera store](https://addons.opera.com/en/extensions/details/metamask/).
4. Post on Github releases page. 5. Post on [Github releases](https://github.com/MetaMask/metamask-extension/releases) page.
5. `npm run announce`, post that announcement in our public places. 6. Run the `npm run announce` script, and post that announcement in our public places.

View File

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

30
package-lock.json generated
View File

@ -8174,16 +8174,16 @@
"integrity": "sha512-NNlVB/TBc8p9CblwECjPlUR+7MNQKiBa7tEFxIzZ9MjjNCEYPWDXTm0vJZzuDtVmFxYwIA53UD0QEn0QNxWNEQ==", "integrity": "sha512-NNlVB/TBc8p9CblwECjPlUR+7MNQKiBa7tEFxIzZ9MjjNCEYPWDXTm0vJZzuDtVmFxYwIA53UD0QEn0QNxWNEQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"bip39": "^2.4.0", "bip39": "2.4.0",
"bluebird": "^3.5.0", "bluebird": "3.5.1",
"browser-passworder": "^2.0.3", "browser-passworder": "2.0.3",
"eth-hd-keyring": "^1.2.2", "eth-hd-keyring": "1.2.2",
"eth-sig-util": "^1.4.0", "eth-sig-util": "1.4.2",
"eth-simple-keyring": "^1.2.2", "eth-simple-keyring": "1.2.2",
"ethereumjs-util": "^5.1.2", "ethereumjs-util": "5.2.0",
"loglevel": "^1.5.0", "loglevel": "1.6.0",
"obs-store": "^2.4.1", "obs-store": "2.4.1",
"promise-filter": "^1.1.0" "promise-filter": "1.1.0"
}, },
"dependencies": { "dependencies": {
"babelify": { "babelify": {
@ -8296,11 +8296,11 @@
"integrity": "sha512-uQVBYshHUOaXVoat1BpLA/QNMCr4hgdFBgwIB7rRmQ+m3vQQAseUsOM+biPDYzq6end+6LjcccElLpQaIZe6dg==", "integrity": "sha512-uQVBYshHUOaXVoat1BpLA/QNMCr4hgdFBgwIB7rRmQ+m3vQQAseUsOM+biPDYzq6end+6LjcccElLpQaIZe6dg==",
"dev": true, "dev": true,
"requires": { "requires": {
"eth-sig-util": "^1.4.2", "eth-sig-util": "1.4.2",
"ethereumjs-util": "^5.1.1", "ethereumjs-util": "5.2.0",
"ethereumjs-wallet": "^0.6.0", "ethereumjs-wallet": "0.6.0",
"events": "^1.1.1", "events": "1.1.1",
"xtend": "^4.0.1" "xtend": "4.0.1"
}, },
"dependencies": { "dependencies": {
"ethereumjs-util": { "ethereumjs-util": {

View File

@ -43,7 +43,7 @@ async function runAddTokenFlowTest (assert, done) {
assert.equal(addTokenTitle[0].textContent, 'Add Tokens', 'add token title is correct') assert.equal(addTokenTitle[0].textContent, 'Add Tokens', 'add token title is correct')
// Cancel Add Token // Cancel Add Token
const cancelAddTokenButton = await queryAsync($, 'button.btn-secondary--lg.page-container__footer-button') const cancelAddTokenButton = await queryAsync($, 'button.btn-default.btn--large.page-container__footer-button')
assert.ok(cancelAddTokenButton[0], 'cancel add token button present') assert.ok(cancelAddTokenButton[0], 'cancel add token button present')
cancelAddTokenButton.click() cancelAddTokenButton.click()
@ -75,15 +75,15 @@ async function runAddTokenFlowTest (assert, done) {
tokenWrapper[0].click() tokenWrapper[0].click()
// Click Next button // Click Next button
let nextButton = await queryAsync($, 'button.btn-primary--lg') let nextButton = await queryAsync($, 'button.btn-primary.btn--large')
assert.equal(nextButton[0].textContent, 'Next', 'next button rendered') assert.equal(nextButton[0].textContent, 'Next', 'next button rendered')
nextButton[0].click() nextButton[0].click()
// Confirm Add token // Confirm Add token
const confirmAddToken = await queryAsync($, '.confirm-add-token') const confirmAddToken = await queryAsync($, '.confirm-add-token')
assert.ok(confirmAddToken[0], 'confirm add token rendered') assert.ok(confirmAddToken[0], 'confirm add token rendered')
assert.ok($('button.btn-primary--lg')[0], 'confirm add token button found') assert.ok($('button.btn-primary.btn--large')[0], 'confirm add token button found')
$('button.btn-primary--lg')[0].click() $('button.btn-primary.btn--large')[0].click()
// Verify added token image // Verify added token image
let heroBalance = await queryAsync($, '.hero-balance') let heroBalance = await queryAsync($, '.hero-balance')
@ -120,7 +120,7 @@ async function runAddTokenFlowTest (assert, done) {
const errorMessage = await queryAsync($, '#custom-symbol-helper-text') const errorMessage = await queryAsync($, '#custom-symbol-helper-text')
assert.ok(errorMessage[0], 'error rendered') assert.ok(errorMessage[0], 'error rendered')
$('button.btn-secondary--lg')[0].click() $('button.btn-default.btn--large')[0].click()
// await timeout(100000) // await timeout(100000)

View File

@ -38,7 +38,7 @@ async function runConfirmSigRequestsTest(assert, done) {
let confirmSigRowValue = await queryAsync($, '.request-signature__row-value') let confirmSigRowValue = await queryAsync($, '.request-signature__row-value')
assert.equal(confirmSigRowValue[0].textContent, '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0') assert.equal(confirmSigRowValue[0].textContent, '0x879a053d4800c6354e76c7985a865d2922c82fb5b3f4577b2fe08b998954f2e0')
let confirmSigSignButton = await queryAsync($, 'button.btn-primary--lg') let confirmSigSignButton = await queryAsync($, 'button.btn-primary.btn--large')
confirmSigSignButton[0].click() confirmSigSignButton[0].click()
confirmSigHeadline = await queryAsync($, '.request-signature__headline') confirmSigHeadline = await queryAsync($, '.request-signature__headline')
@ -47,7 +47,7 @@ async function runConfirmSigRequestsTest(assert, done) {
confirmSigRowValue = await queryAsync($, '.request-signature__row-value') confirmSigRowValue = await queryAsync($, '.request-signature__row-value')
assert.ok(confirmSigRowValue[0].textContent.match(/^\#\sTerms\sof\sUse/)) assert.ok(confirmSigRowValue[0].textContent.match(/^\#\sTerms\sof\sUse/))
confirmSigSignButton = await queryAsync($, 'button.btn-primary--lg') confirmSigSignButton = await queryAsync($, 'button.btn-primary.btn--large')
confirmSigSignButton[0].click() confirmSigSignButton[0].click()
confirmSigHeadline = await queryAsync($, '.request-signature__headline') confirmSigHeadline = await queryAsync($, '.request-signature__headline')
@ -57,7 +57,7 @@ async function runConfirmSigRequestsTest(assert, done) {
assert.equal(confirmSigRowValue[0].textContent, 'Hi, Alice!') assert.equal(confirmSigRowValue[0].textContent, 'Hi, Alice!')
assert.equal(confirmSigRowValue[1].textContent, '1337') assert.equal(confirmSigRowValue[1].textContent, '1337')
confirmSigSignButton = await queryAsync($, 'button.btn-primary--lg') confirmSigSignButton = await queryAsync($, 'button.btn-primary.btn--large')
confirmSigSignButton[0].click() confirmSigSignButton[0].click()
const txView = await queryAsync($, '.tx-view') const txView = await queryAsync($, '.tx-view')

View File

@ -129,7 +129,7 @@ async function runSendFlowTest(assert, done) {
await customizeGas(assert, 0, 21000, '0', '$0.00 USD') await customizeGas(assert, 0, 21000, '0', '$0.00 USD')
await customizeGas(assert, 500, 60000, '0.003', '$3.60 USD') await customizeGas(assert, 500, 60000, '0.003', '$3.60 USD')
const sendButton = await queryAsync($, 'button.btn-primary--lg.page-container__footer-button') const sendButton = await queryAsync($, 'button.btn-primary.btn--large.page-container__footer-button')
assert.equal(sendButton[0].textContent, 'Next', 'next button rendered') assert.equal(sendButton[0].textContent, 'Next', 'next button rendered')
sendButton[0].click() sendButton[0].click()
await timeout() await timeout()
@ -169,13 +169,13 @@ async function runSendFlowTest(assert, done) {
sendAmountFieldInputInEdit.val('1.0') sendAmountFieldInputInEdit.val('1.0')
reactTriggerChange(sendAmountFieldInputInEdit[0]) reactTriggerChange(sendAmountFieldInputInEdit[0])
const sendButtonInEdit = await queryAsync($, '.btn-primary--lg.page-container__footer-button') const sendButtonInEdit = await queryAsync($, '.btn-primary.btn--large.page-container__footer-button')
assert.equal(sendButtonInEdit[0].textContent, 'Next', 'next button in edit rendered') assert.equal(sendButtonInEdit[0].textContent, 'Next', 'next button in edit rendered')
selectState.val('send new ui') selectState.val('send new ui')
reactTriggerChange(selectState[0]) reactTriggerChange(selectState[0])
const cancelButtonInEdit = await queryAsync($, '.btn-secondary--lg.page-container__footer-button') const cancelButtonInEdit = await queryAsync($, '.btn-default.btn--large.page-container__footer-button')
cancelButtonInEdit[0].click() cancelButtonInEdit[0].click()
// sendButtonInEdit[0].click() // sendButtonInEdit[0].click()

View File

@ -163,7 +163,7 @@ async function captureAllScreens() {
await delay(300) await delay(300)
await captureLanguageScreenShots('metamask account detail export private key screen - password entered') await captureLanguageScreenShots('metamask account detail export private key screen - password entered')
await driver.findElement(By.css('.btn-primary--lg.export-private-key__button')).click() await driver.findElement(By.css('.btn-primary.btn--large.export-private-key__button')).click()
await delay(300) await delay(300)
await captureLanguageScreenShots('metamask account detail export private key screen - reveal key') await captureLanguageScreenShots('metamask account detail export private key screen - reveal key')

View File

@ -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,31 @@ 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])
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 () {

View File

@ -503,17 +503,23 @@ function requestRevealSeedWords (password) {
} }
function resetAccount () { function resetAccount () {
return (dispatch) => { return dispatch => {
background.resetAccount((err, account) => { dispatch(actions.showLoadingIndication())
dispatch(actions.hideLoadingIndication())
if (err) {
dispatch(actions.displayWarning(err.message))
}
log.info('Transaction history reset for ' + account) return new Promise((resolve, reject) => {
dispatch(actions.showAccountsPage()) background.resetAccount((err, account) => {
}) dispatch(actions.hideLoadingIndication())
} if (err) {
dispatch(actions.displayWarning(err.message))
return reject(err)
}
log.info('Transaction history reset for ' + account)
dispatch(actions.showAccountsPage())
resolve(account)
})
})
}
} }
function addNewKeyring (type, opts) { function addNewKeyring (type, opts) {

View File

@ -2,20 +2,15 @@ import React, { Component } from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import classnames from 'classnames' import classnames from 'classnames'
const SECONDARY = 'secondary' const CLASSNAME_DEFAULT = 'btn-default'
const CLASSNAME_PRIMARY = 'btn-primary' const CLASSNAME_PRIMARY = 'btn-primary'
const CLASSNAME_PRIMARY_LARGE = 'btn-primary--lg'
const CLASSNAME_SECONDARY = 'btn-secondary' const CLASSNAME_SECONDARY = 'btn-secondary'
const CLASSNAME_SECONDARY_LARGE = 'btn-secondary--lg' const CLASSNAME_LARGE = 'btn--large'
const getClassName = (type, large = false) => { const typeHash = {
let output = type === SECONDARY ? CLASSNAME_SECONDARY : CLASSNAME_PRIMARY default: CLASSNAME_DEFAULT,
primary: CLASSNAME_PRIMARY,
if (large) { secondary: CLASSNAME_SECONDARY,
output += ` ${type === SECONDARY ? CLASSNAME_SECONDARY_LARGE : CLASSNAME_PRIMARY_LARGE}`
}
return output
} }
class Button extends Component { class Button extends Component {
@ -24,7 +19,11 @@ class Button extends Component {
return ( return (
<button <button
className={classnames(getClassName(type, large), className)} className={classnames(
typeHash[type],
large && CLASSNAME_LARGE,
className
)}
{ ...buttonProps } { ...buttonProps }
> >
{ this.props.children } { this.props.children }

View File

@ -13,13 +13,21 @@ storiesOf('Button', module)
{text('text', 'Click me')} {text('text', 'Click me')}
</Button> </Button>
) )
.add('secondary', () => ( .add('secondary', () =>
<Button <Button
onClick={action('clicked')} onClick={action('clicked')}
type="secondary" type="secondary"
> >
{text('text', 'Click me')} {text('text', 'Click me')}
</Button> </Button>
)
.add('default', () => (
<Button
onClick={action('clicked')}
type="default"
>
{text('text', 'Click me')}
</Button>
)) ))
.add('large primary', () => ( .add('large primary', () => (
<Button <Button
@ -39,3 +47,12 @@ storiesOf('Button', module)
{text('text', 'Click me')} {text('text', 'Click me')}
</Button> </Button>
)) ))
.add('large default', () => (
<Button
onClick={action('clicked')}
type="default"
large
>
{text('text', 'Click me')}
</Button>
))

View File

@ -308,7 +308,7 @@ CustomizeGasModal.prototype.render = function () {
}, [this.context.t('revert')]), }, [this.context.t('revert')]),
h('div.send-v2__customize-gas__buttons', [ h('div.send-v2__customize-gas__buttons', [
h('button.btn-secondary.send-v2__customize-gas__cancel', { h('button.btn-default.send-v2__customize-gas__cancel', {
onClick: this.props.hideModal, onClick: this.props.hideModal,
style: { style: {
marginRight: '10px', marginRight: '10px',

View File

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

View File

@ -0,0 +1,54 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import Button from '../../button'
class ConfirmResetAccount extends Component {
static propTypes = {
hideModal: PropTypes.func.isRequired,
resetAccount: PropTypes.func.isRequired,
}
static contextTypes = {
t: PropTypes.func,
}
handleReset () {
this.props.resetAccount()
.then(() => this.props.hideModal())
}
render () {
const { t } = this.context
return (
<div className="modal-container">
<div className="modal-container__content">
<div className="modal-container__title">
{ `${t('resetAccount')}?` }
</div>
<div className="modal-container__description">
{ t('resetAccountDescription') }
</div>
</div>
<div className="modal-container__footer">
<Button
type="default"
className="modal-container__footer-button"
onClick={() => this.props.hideModal()}
>
{ t('nevermind') }
</Button>
<Button
type="secondary"
className="modal-container__footer-button"
onClick={() => this.handleReset()}
>
{ t('reset') }
</Button>
</div>
</div>
)
}
}
export default ConfirmResetAccount

View File

@ -0,0 +1,13 @@
import { connect } from 'react-redux'
import ConfirmResetAccount from './confirm-reset-account.component'
const { hideModal, resetAccount } = require('../../../actions')
const mapDispatchToProps = dispatch => {
return {
hideModal: () => dispatch(hideModal()),
resetAccount: () => dispatch(resetAccount()),
}
}
export default connect(null, mapDispatchToProps)(ConfirmResetAccount)

View File

@ -0,0 +1,2 @@
import ConfirmResetAccount from './confirm-reset-account.container'
module.exports = ConfirmResetAccount

View File

@ -109,7 +109,7 @@ DepositEtherModal.prototype.renderRow = function ({
]), ]),
!hideButton && h('div.deposit-ether-modal__buy-row__button', [ !hideButton && h('div.deposit-ether-modal__buy-row__button', [
h('button.btn-primary--lg.deposit-ether-modal__deposit-button', { h('button.btn-primary.btn--large.deposit-ether-modal__deposit-button', {
onClick: onButtonClick, onClick: onButtonClick,
}, [buttonLabel]), }, [buttonLabel]),
]), ]),

View File

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

View File

@ -87,14 +87,14 @@ ExportPrivateKeyModal.prototype.renderButton = function (className, onClick, lab
ExportPrivateKeyModal.prototype.renderButtons = function (privateKey, password, address, hideModal) { ExportPrivateKeyModal.prototype.renderButtons = function (privateKey, password, address, hideModal) {
return h('div.export-private-key-buttons', {}, [ return h('div.export-private-key-buttons', {}, [
!privateKey && this.renderButton( !privateKey && this.renderButton(
'btn-secondary--lg export-private-key__button export-private-key__button--cancel', 'btn-default btn--large export-private-key__button export-private-key__button--cancel',
() => hideModal(), () => hideModal(),
'Cancel' 'Cancel'
), ),
(privateKey (privateKey
? this.renderButton('btn-primary--lg export-private-key__button', () => hideModal(), this.context.t('done')) ? this.renderButton('btn-primary btn--large export-private-key__button', () => hideModal(), this.context.t('done'))
: this.renderButton('btn-primary--lg export-private-key__button', () => this.exportAccountAndGetPrivateKey(this.state.password, address), this.context.t('confirm')) : this.renderButton('btn-primary btn--large export-private-key__button', () => this.exportAccountAndGetPrivateKey(this.state.password, address), this.context.t('confirm'))
), ),
]) ])

View File

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

View File

@ -1 +1,52 @@
@import './transaction-confirmed/index'; .modal-container {
width: 100%;
height: 100%;
background-color: #fff;
display: flex;
flex-flow: column;
border-radius: 8px;
&__title {
font-size: 1.5rem;
font-weight: 500;
padding: 16px 0;
text-align: center;
}
&__description {
text-align: center;
font-size: .875rem;
}
&__content {
overflow-y: auto;
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
padding: 32px;
@media screen and (max-width: 575px) {
justify-content: center;
padding: 28px 20px;
}
}
&__footer {
display: flex;
flex-flow: row;
justify-content: center;
border-top: 1px solid #d2d8dd;
padding: 16px;
flex: 0 0 auto;
&-button {
min-width: 0;
margin-right: 16px;
&:last-of-type {
margin-right: 0;
}
}
}
}

View File

@ -19,8 +19,30 @@ const ShapeshiftDepositTxModal = require('./shapeshift-deposit-tx-modal.js')
const HideTokenConfirmationModal = require('./hide-token-confirmation-modal') const HideTokenConfirmationModal = require('./hide-token-confirmation-modal')
const CustomizeGasModal = require('../customize-gas-modal') const CustomizeGasModal = require('../customize-gas-modal')
const NotifcationModal = require('./notification-modal') const NotifcationModal = require('./notification-modal')
const ConfirmResetAccount = require('./notification-modals/confirm-reset-account') const ConfirmResetAccount = require('./confirm-reset-account')
const TransactionConfirmed = require('./transaction-confirmed') const TransactionConfirmed = require('./transaction-confirmed')
const WelcomeBeta = require('./welcome-beta')
const Notification = require('./notification')
const modalContainerBaseStyle = {
transform: 'translate3d(-50%, 0, 0px)',
border: '1px solid #CCCFD1',
borderRadius: '8px',
backgroundColor: '#FFFFFF',
boxShadow: '0 2px 22px 0 rgba(0,0,0,0.2)',
}
const modalContainerLaptopStyle = {
...modalContainerBaseStyle,
width: '344px',
top: '15%',
}
const modalContainerMobileStyle = {
...modalContainerBaseStyle,
width: '309px',
top: '12.5%',
}
const accountModalStyle = { const accountModalStyle = {
mobileModalStyle: { mobileModalStyle: {
@ -174,18 +196,18 @@ const MODALS = {
BETA_UI_NOTIFICATION_MODAL: { BETA_UI_NOTIFICATION_MODAL: {
contents: [ contents: [
h(NotifcationModal, { h(Notification, [
header: 'uiWelcome', h(WelcomeBeta),
message: 'uiWelcomeMessage', ]),
}),
], ],
mobileModalStyle: { mobileModalStyle: {
width: '95%', ...modalContainerMobileStyle,
top: getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP ? '52vh' : '36.5vh',
}, },
laptopModalStyle: { laptopModalStyle: {
width: '449px', ...modalContainerLaptopStyle,
top: 'calc(33% + 45px)', },
contentStyle: {
borderRadius: '8px',
}, },
}, },
@ -209,12 +231,13 @@ const MODALS = {
CONFIRM_RESET_ACCOUNT: { CONFIRM_RESET_ACCOUNT: {
contents: h(ConfirmResetAccount), contents: h(ConfirmResetAccount),
mobileModalStyle: { mobileModalStyle: {
width: '95%', ...modalContainerMobileStyle,
top: getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP ? '52vh' : '36.5vh',
}, },
laptopModalStyle: { laptopModalStyle: {
width: '473px', ...modalContainerLaptopStyle,
top: 'calc(33% + 45px)', },
contentStyle: {
borderRadius: '8px',
}, },
}, },
@ -269,31 +292,18 @@ const MODALS = {
TRANSACTION_CONFIRMED: { TRANSACTION_CONFIRMED: {
disableBackdropClick: true, disableBackdropClick: true,
contents: [ contents: [
h(TransactionConfirmed, {}, []), h(Notification, [
h(TransactionConfirmed),
]),
], ],
mobileModalStyle: { mobileModalStyle: {
width: '100%', ...modalContainerMobileStyle,
height: '100%',
transform: 'none',
left: '0',
right: '0',
margin: '0 auto',
boxShadow: '0 0 7px 0 rgba(0,0,0,0.08)',
top: '0',
display: 'flex',
}, },
laptopModalStyle: { laptopModalStyle: {
width: '344px', ...modalContainerLaptopStyle,
transform: 'translate3d(-50%, 0, 0px)',
top: '15%',
border: '1px solid #CCCFD1',
borderRadius: '8px',
backgroundColor: '#FFFFFF',
boxShadow: '0 2px 22px 0 rgba(0,0,0,0.2)',
}, },
contentStyle: { contentStyle: {
borderRadius: '8px', borderRadius: '8px',
height: '100%',
}, },
}, },

View File

@ -1,46 +0,0 @@
const { Component } = require('react')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')
const connect = require('react-redux').connect
const actions = require('../../../actions')
const NotifcationModal = require('../notification-modal')
class ConfirmResetAccount extends Component {
render () {
const { resetAccount } = this.props
return h(NotifcationModal, {
header: 'Are you sure you want to reset account?',
message: h('div', [
h('span', `Resetting is for developer use only. This button wipes the current account's transaction history,
which is used to calculate the current account nonce. `),
h('a.notification-modal__link', {
href: 'http://metamask.helpscoutdocs.com/article/36-resetting-an-account',
target: '_blank',
onClick (event) { global.platform.openWindow({ url: event.target.href }) },
}, 'Read more.'),
]),
showCancelButton: true,
showConfirmButton: true,
onConfirm: resetAccount,
})
}
}
ConfirmResetAccount.propTypes = {
resetAccount: PropTypes.func,
}
const mapDispatchToProps = dispatch => {
return {
resetAccount: () => {
dispatch(actions.resetAccount())
},
}
}
module.exports = connect(null, mapDispatchToProps)(ConfirmResetAccount)

View File

@ -0,0 +1,2 @@
import Notification from './notification.container'
module.exports = Notification

View File

@ -0,0 +1,30 @@
import React from 'react'
import PropTypes from 'prop-types'
import Button from '../../button'
const Notification = (props, context) => {
return (
<div className="modal-container">
{ props.children }
<div className="modal-container__footer">
<Button
type="primary"
onClick={() => props.onHide()}
>
{ context.t('ok') }
</Button>
</div>
</div>
)
}
Notification.propTypes = {
onHide: PropTypes.func.isRequired,
children: PropTypes.element,
}
Notification.contextTypes = {
t: PropTypes.func,
}
export default Notification

View File

@ -0,0 +1,38 @@
import { connect } from 'react-redux'
import Notification from './notification.component'
const { hideModal } = require('../../../actions')
const mapStateToProps = state => {
const { appState: { modal: { modalState: { props } } } } = state
const { onHide } = props
return {
onHide,
}
}
const mapDispatchToProps = dispatch => {
return {
hideModal: () => dispatch(hideModal()),
}
}
const mergeProps = (stateProps, dispatchProps, ownProps) => {
const { onHide, ...otherStateProps } = stateProps
const { hideModal, ...otherDispatchProps } = dispatchProps
return {
...otherStateProps,
...otherDispatchProps,
...ownProps,
onHide: () => {
hideModal()
if (onHide && typeof onHide === 'function') {
onHide()
}
},
}
}
export default connect(mapStateToProps, mapDispatchToProps, mergeProps)(Notification)

View File

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

View File

@ -1,2 +1,2 @@
import TransactionConfirmed from './transaction-confirmed.container' import TransactionConfirmed from './transaction-confirmed.component'
module.exports = TransactionConfirmed module.exports = TransactionConfirmed

View File

@ -1,21 +0,0 @@
.transaction-confirmed {
display: flex;
flex-direction: column;
align-items: center;
padding: 32px;
&__title {
font-size: 2rem;
padding: 16px 0;
}
&__description {
text-align: center;
font-size: .875rem;
line-height: 1.5rem;
}
@media screen and (max-width: 575px) {
justify-content: center;
}
}

View File

@ -1,42 +1,20 @@
import React, { Component } from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import Button from '../../button'
class TransactionConfirmed extends Component { const TransactionConfirmed = (props, context) => {
render () { const { t } = context
const { t } = this.context
return ( return (
<div className="page-container page-container--full-width page-container--full-height"> <div className="modal-container__content">
<div className="page-container__content transaction-confirmed"> <img src="images/check-icon.svg" />
<img src="images/check-icon.svg" /> <div className="modal-container__title">
<div className="transaction-confirmed__title"> { `${t('confirmed')}!` }
{ `${t('confirmed')}!` }
</div>
<div className="transaction-confirmed__description">
{ t('initialTransactionConfirmed') }
</div>
</div>
<div className="page-container__footer">
<Button
type="primary"
className="page-container__footer-button"
onClick={() => {
this.props.hideModal()
this.props.onHide()
}}
>
{ t('ok') }
</Button>
</div>
</div> </div>
) <div className="modal-container__description">
} { t('initialTransactionConfirmed') }
} </div>
</div>
TransactionConfirmed.propTypes = { )
hideModal: PropTypes.func.isRequired,
onHide: PropTypes.func.isRequired,
} }
TransactionConfirmed.contextTypes = { TransactionConfirmed.contextTypes = {

View File

@ -1,20 +0,0 @@
import { connect } from 'react-redux'
import TransactionConfirmed from './transaction-confirmed.component'
const { hideModal } = require('../../../actions')
const mapStateToProps = state => {
const { appState: { modal: { modalState: { props } } } } = state
const { onHide } = props
return {
onHide,
}
}
const mapDispatchToProps = dispatch => {
return {
hideModal: () => dispatch(hideModal()),
}
}
export default connect(mapStateToProps, mapDispatchToProps)(TransactionConfirmed)

View File

@ -0,0 +1,2 @@
import WelcomeBeta from './welcome-beta.component'
module.exports = WelcomeBeta

View File

@ -0,0 +1,23 @@
import React from 'react'
import PropTypes from 'prop-types'
const TransactionConfirmed = (props, context) => {
const { t } = context
return (
<div className="modal-container__content">
<div className="modal-container__title">
{ `${t('uiWelcome')}` }
</div>
<div className="modal-container__description">
{ t('uiWelcomeMessage') }
</div>
</div>
)
}
TransactionConfirmed.contextTypes = {
t: PropTypes.func,
}
export default TransactionConfirmed

View File

@ -323,7 +323,7 @@ class AddToken extends Component {
</div> </div>
<div className="page-container__footer"> <div className="page-container__footer">
<Button <Button
type="secondary" type="default"
large large
className="page-container__footer-button" className="page-container__footer-button"
onClick={() => { onClick={() => {

View File

@ -15,7 +15,7 @@ export default class TokenListPlaceholder extends Component {
</div> </div>
<a <a
className="token-list-placeholder__link" className="token-list-placeholder__link"
href="http://metamask.helpscoutdocs.com/article/16-managing-erc20-tokens" href="https://consensys.zendesk.com/hc/en-us/articles/360004135092"
target="_blank" target="_blank"
rel="noopener noreferrer" rel="noopener noreferrer"
> >

View File

@ -87,7 +87,7 @@ export default class ConfirmAddToken extends Component {
</div> </div>
<div className="page-container__footer"> <div className="page-container__footer">
<Button <Button
type="secondary" type="default"
large large
className="page-container__footer-button" className="page-container__footer-button"
onClick={() => history.push(ADD_TOKEN_ROUTE)} onClick={() => history.push(ADD_TOKEN_ROUTE)}

View File

@ -46,7 +46,7 @@ AccountImportSubview.prototype.render = function () {
}, },
onClick: () => { onClick: () => {
global.platform.openWindow({ global.platform.openWindow({
url: 'https://metamask.helpscoutdocs.com/article/17-what-are-loose-accounts', url: 'https://consensys.zendesk.com/hc/en-us/articles/360004180111-What-are-imported-accounts-New-UI',
}) })
}, },
}, this.context.t('here')), }, this.context.t('here')),

View File

@ -51,7 +51,7 @@ class JsonImportSubview extends Component {
h('div.new-account-create-form__buttons', {}, [ h('div.new-account-create-form__buttons', {}, [
h('button.btn-secondary.new-account-create-form__button', { h('button.btn-default.new-account-create-form__button', {
onClick: () => this.props.history.push(DEFAULT_ROUTE), onClick: () => this.props.history.push(DEFAULT_ROUTE),
}, [ }, [
this.context.t('cancel'), this.context.t('cancel'),

View File

@ -59,13 +59,13 @@ PrivateKeyImportView.prototype.render = function () {
h('div.new-account-import-form__buttons', {}, [ h('div.new-account-import-form__buttons', {}, [
h('button.btn-secondary--lg.new-account-create-form__button', { h('button.btn-default.btn--large.new-account-create-form__button', {
onClick: () => this.props.history.push(DEFAULT_ROUTE), onClick: () => this.props.history.push(DEFAULT_ROUTE),
}, [ }, [
this.context.t('cancel'), this.context.t('cancel'),
]), ]),
h('button.btn-primary--lg.new-account-create-form__button', { h('button.btn-primary.btn--large.new-account-create-form__button', {
onClick: () => this.createNewKeychain(), onClick: () => this.createNewKeychain(),
}, [ }, [
this.context.t('import'), this.context.t('import'),

View File

@ -38,13 +38,13 @@ class NewAccountCreateForm extends Component {
h('div.new-account-create-form__buttons', {}, [ h('div.new-account-create-form__buttons', {}, [
h('button.btn-secondary--lg.new-account-create-form__button', { h('button.btn-default.btn--large.new-account-create-form__button', {
onClick: () => history.push(DEFAULT_ROUTE), onClick: () => history.push(DEFAULT_ROUTE),
}, [ }, [
this.context.t('cancel'), this.context.t('cancel'),
]), ]),
h('button.btn-primary--lg.new-account-create-form__button', { h('button.btn-primary.btn--large.new-account-create-form__button', {
onClick: () => { onClick: () => {
createAccount(newAccountName || defaultAccountName) createAccount(newAccountName || defaultAccountName)
.then(() => history.push(DEFAULT_ROUTE)) .then(() => history.push(DEFAULT_ROUTE))

View File

@ -106,10 +106,10 @@ class RevealSeedPage extends Component {
renderPasswordPromptFooter () { renderPasswordPromptFooter () {
return ( return (
h('.page-container__footer', [ h('.page-container__footer', [
h('button.btn-secondary--lg.page-container__footer-button', { h('button.btn-default.btn--large.page-container__footer-button', {
onClick: () => this.props.history.push(DEFAULT_ROUTE), onClick: () => this.props.history.push(DEFAULT_ROUTE),
}, this.context.t('cancel')), }, this.context.t('cancel')),
h('button.btn-primary--lg.page-container__footer-button', { h('button.btn-primary.btn--large.page-container__footer-button', {
onClick: event => this.handleSubmit(event), onClick: event => this.handleSubmit(event),
disabled: this.state.password === '', disabled: this.state.password === '',
}, this.context.t('next')), }, this.context.t('next')),
@ -120,7 +120,7 @@ class RevealSeedPage extends Component {
renderRevealSeedFooter () { renderRevealSeedFooter () {
return ( return (
h('.page-container__footer', [ h('.page-container__footer', [
h('button.btn-secondary--lg.page-container__footer-button', { h('button.btn-default.btn--large.page-container__footer-button', {
onClick: () => this.props.history.push(DEFAULT_ROUTE), onClick: () => this.props.history.push(DEFAULT_ROUTE),
}, this.context.t('close')), }, this.context.t('close')),
]) ])

View File

@ -217,7 +217,7 @@ class Settings extends Component {
]), ]),
h('div.settings__content-item', [ h('div.settings__content-item', [
h('div.settings__content-item-col', [ h('div.settings__content-item-col', [
h('button.btn-primary--lg.settings__button', { h('button.btn-primary.btn--large.settings__button', {
onClick (event) { onClick (event) {
window.logStateString((err, result) => { window.logStateString((err, result) => {
if (err) { if (err) {
@ -242,7 +242,7 @@ class Settings extends Component {
h('div.settings__content-item', this.context.t('revealSeedWords')), h('div.settings__content-item', this.context.t('revealSeedWords')),
h('div.settings__content-item', [ h('div.settings__content-item', [
h('div.settings__content-item-col', [ h('div.settings__content-item-col', [
h('button.btn-primary--lg.settings__button--red', { h('button.btn-primary.btn--large.settings__button--red', {
onClick: event => { onClick: event => {
event.preventDefault() event.preventDefault()
history.push(REVEAL_SEED_ROUTE) history.push(REVEAL_SEED_ROUTE)
@ -262,7 +262,7 @@ class Settings extends Component {
h('div.settings__content-item', this.context.t('useOldUI')), h('div.settings__content-item', this.context.t('useOldUI')),
h('div.settings__content-item', [ h('div.settings__content-item', [
h('div.settings__content-item-col', [ h('div.settings__content-item-col', [
h('button.btn-primary--lg.settings__button--orange', { h('button.btn-primary.btn--large.settings__button--orange', {
onClick (event) { onClick (event) {
event.preventDefault() event.preventDefault()
setFeatureFlagToBeta() setFeatureFlagToBeta()
@ -281,7 +281,7 @@ class Settings extends Component {
h('div.settings__content-item', this.context.t('resetAccount')), h('div.settings__content-item', this.context.t('resetAccount')),
h('div.settings__content-item', [ h('div.settings__content-item', [
h('div.settings__content-item-col', [ h('div.settings__content-item-col', [
h('button.btn-primary--lg.settings__button--orange', { h('button.btn-primary.btn--large.settings__button--orange', {
onClick (event) { onClick (event) {
event.preventDefault() event.preventDefault()
showResetAccountConfirmationModal() showResetAccountConfirmationModal()

View File

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

View File

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

View File

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

View File

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

View File

@ -242,7 +242,7 @@ ShapeshiftForm.prototype.render = function () {
]), ]),
!depositAddress && h('button.btn-primary--lg.shapeshift-form__shapeshift-buy-btn', { !depositAddress && h('button.btn-primary.btn--large.shapeshift-form__shapeshift-buy-btn', {
className: btnClass, className: btnClass,
disabled: !token, disabled: !token,
onClick: () => this.onBuyWithShapeShift(), onClick: () => this.onBuyWithShapeShift(),

View File

@ -235,12 +235,12 @@ SignatureRequest.prototype.renderFooter = function () {
} }
return h('div.request-signature__footer', [ return h('div.request-signature__footer', [
h('button.btn-secondary--lg.request-signature__footer__cancel-button', { h('button.btn-default.btn--large.request-signature__footer__cancel-button', {
onClick: event => { onClick: event => {
cancel(event).then(() => this.props.history.push(DEFAULT_ROUTE)) cancel(event).then(() => this.props.history.push(DEFAULT_ROUTE))
}, },
}, this.context.t('cancel')), }, this.context.t('cancel')),
h('button.btn-primary--lg', { h('button.btn-primary.btn--large', {
onClick: event => { onClick: event => {
sign(event).then(() => this.props.history.push(DEFAULT_ROUTE)) sign(event).then(() => this.props.history.push(DEFAULT_ROUTE))
}, },

View File

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

View File

@ -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(),

View File

@ -36,7 +36,6 @@ function mapStateToProps (state) {
tokens: state.metamask.tokens, tokens: state.metamask.tokens,
keyrings: state.metamask.keyrings, keyrings: state.metamask.keyrings,
selectedAddress: selectors.getSelectedAddress(state), selectedAddress: selectors.getSelectedAddress(state),
selectedIdentity: selectors.getSelectedIdentity(state),
selectedAccount: selectors.getSelectedAccount(state), selectedAccount: selectors.getSelectedAccount(state),
selectedTokenAddress: state.metamask.selectedTokenAddress, selectedTokenAddress: state.metamask.selectedTokenAddress,
} }
@ -99,21 +98,24 @@ WalletView.prototype.render = function () {
const { const {
responsiveDisplayClassname, responsiveDisplayClassname,
selectedAddress, selectedAddress,
selectedIdentity,
keyrings, keyrings,
showAccountDetailModal, showAccountDetailModal,
sidebarOpen, sidebarOpen,
hideSidebar, hideSidebar,
history, history,
identities,
} = this.props } = this.props
// temporary logs + fake extra wallets // temporary logs + fake extra wallets
// console.log('walletview, selectedAccount:', selectedAccount) // console.log('walletview, selectedAccount:', selectedAccount)
const checksummedAddress = checksumAddress(selectedAddress) const checksummedAddress = checksumAddress(selectedAddress)
if (!selectedAddress) {
throw new Error('selectedAddress should not be ' + String(selectedAddress))
}
const keyring = keyrings.find((kr) => { const keyring = keyrings.find((kr) => {
return kr.accounts.includes(selectedAddress) || return kr.accounts.includes(selectedAddress)
kr.accounts.includes(selectedIdentity.address)
}) })
const type = keyring.type const type = keyring.type
@ -145,7 +147,7 @@ WalletView.prototype.render = function () {
h('span.account-name', { h('span.account-name', {
style: {}, style: {},
}, [ }, [
selectedIdentity.name, identities[selectedAddress].name,
]), ]),
h('button.btn-clear.wallet-view__details-button.allcaps', this.context.t('details')), h('button.btn-clear.wallet-view__details-button.allcaps', this.context.t('details')),

View File

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

View File

@ -2,10 +2,10 @@
Buttons Buttons
*/ */
.btn-default,
.btn-primary, .btn-primary,
.btn-primary--lg, .btn-secondary {
.btn-secondary, height: 44px;
.btn-secondary--lg {
background: $white; background: $white;
display: flex; display: flex;
justify-content: center; justify-content: center;
@ -20,10 +20,16 @@
width: 100%; width: 100%;
text-transform: uppercase; text-transform: uppercase;
outline: none; outline: none;
&--disabled,
&[disabled] {
cursor: auto;
opacity: .5;
pointer-events: none;
}
} }
.btn-primary, .btn-primary {
.btn-primary--lg {
color: $curious-blue; color: $curious-blue;
border: 2px solid $spindle; border: 2px solid $spindle;
@ -35,17 +41,23 @@
&:hover { &:hover {
border-color: $curious-blue; border-color: $curious-blue;
} }
}
&--disabled, .btn-secondary {
&[disabled] { color: $monzo;
cursor: auto; border: 2px solid lighten($monzo, 40%);
opacity: .5;
pointer-events: none; &:active {
background: lighten($monzo, 55%);
border-color: $monzo;
}
&:hover {
border-color: $monzo;
} }
} }
.btn-secondary, .btn-default {
.btn-secondary--lg {
color: $scorpion; color: $scorpion;
border: 2px solid $dusty-gray; border: 2px solid $dusty-gray;
@ -57,20 +69,9 @@
&:hover { &:hover {
border-color: $scorpion; border-color: $scorpion;
} }
&--disabled,
&[disabled] {
cursor: auto;
opacity: .5;
pointer-events: none;
}
} }
.btn-primary, .btn-secondary { .btn--large {
height: 44px;
}
.btn-primary--lg, .btn-secondary--lg {
height: 54px; height: 54px;
} }

View File

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

View File

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

View File

@ -499,7 +499,7 @@ SendTransactionScreen.prototype.renderFooter = function () {
return h('div.page-container__footer', [ return h('div.page-container__footer', [
h(Button, { h(Button, {
type: 'secondary', type: 'default',
large: true, large: true,
className: 'page-container__footer-button', className: 'page-container__footer-button',
onClick: () => { onClick: () => {