Merge branch 'master' into i18n

feature/default_network_editable
Dan Finlay 7 years ago committed by GitHub
commit abe8bc19a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      CHANGELOG.md
  2. 4
      app/manifest.json
  3. 13
      development/run-version-bump.js
  4. 26
      old-ui/app/accounts/import/index.js
  5. 2
      old-ui/app/components/account-dropdowns.js
  6. 2
      old-ui/app/css/lib.css
  7. 2
      old-ui/app/unlock.js
  8. 2
      package.json
  9. 1374
      test/stub/blacklist.json
  10. 176
      test/unit/metamask-controller-test.js
  11. 42
      test/unit/network-contoller-test.js
  12. 15
      ui/app/accounts/import/index.js
  13. 16
      ui/app/components/dropdowns/components/account-dropdowns.js
  14. 5
      ui/app/css/itcss/components/account-menu.scss
  15. 10
      ui/app/css/itcss/components/new-account.scss
  16. 2
      ui/app/unlock.js

@ -2,10 +2,15 @@
## Current Master ## Current Master
## 4.2.0 Tue Mar 06 2018
- Replace "Loose" wording to "Imported".
- Replace "Unlock" wording with "Log In".
- Add Imported Account disclaimer.
- Allow adding custom tokens to classic ui when balance is 0 - Allow adding custom tokens to classic ui when balance is 0
- Allow editing of symbol and decimal info when adding custom token in new-ui - Allow editing of symbol and decimal info when adding custom token in new-ui
- new-ui shapeshift form can select all coins (not just BTC) - NewUI shapeshift form can select all coins (not just BTC)
- Classic ui and new-ui shapeshift forms show when coins are not available on shapeshift - Add most of Microsoft Edge support.
## 4.1.3 2018-2-28 ## 4.1.3 2018-2-28

@ -1,7 +1,7 @@
{ {
"name": "__MSG_appName__", "name": "__MSG_appName__",
"short_name": "__MSG_appName__", "short_name": "__MSG_appName__",
"version": "4.1.3", "version": "4.2.0",
"manifest_version": 2, "manifest_version": 2,
"author": "https://metamask.io", "author": "https://metamask.io",
"description": "__MSG_appDescription__", "description": "__MSG_appDescription__",
@ -59,7 +59,7 @@
"clipboardWrite", "clipboardWrite",
"http://localhost:8545/", "http://localhost:8545/",
"https://*.infura.io/" "https://*.infura.io/"
], ],
"web_accessible_resources": [ "web_accessible_resources": [
"scripts/inpage.js" "scripts/inpage.js"
], ],

@ -7,12 +7,13 @@ const changelogPath = path.join(__dirname, '..', 'CHANGELOG.md')
const manifestPath = path.join(__dirname, '..', 'app', 'manifest.json') const manifestPath = path.join(__dirname, '..', 'app', 'manifest.json')
const manifest = require('../app/manifest.json') const manifest = require('../app/manifest.json')
const versionBump = require('./version-bump') const versionBump = require('./version-bump')
const bumpType = normalizeType(process.argv[2]) const bumpType = normalizeType(process.argv[2])
start().catch(console.error)
async function start() {
readFile(changelogPath) const changeBuffer = await readFile(changelogPath)
.then(async (changeBuffer) => {
const changelog = changeBuffer.toString() const changelog = changeBuffer.toString()
const newData = await versionBump(bumpType, changelog, manifest) const newData = await versionBump(bumpType, changelog, manifest)
@ -22,10 +23,8 @@ readFile(changelogPath)
await writeFile(changelogPath, newData.changelog) await writeFile(changelogPath, newData.changelog)
await writeFile(manifestPath, manifestString) await writeFile(manifestPath, manifestString)
return newData.version console.log(`Bumped ${bumpType} to version ${newData.version}`)
}) }
.then((version) => console.log(`Bumped ${bumpType} to version ${version}`))
.catch(console.error)
function normalizeType (userInput) { function normalizeType (userInput) {

@ -34,10 +34,7 @@ AccountImportSubview.prototype.render = function () {
const { type } = state const { type } = state
return ( return (
h('div', { h('div', [
style: {
},
}, [
h('.section-title.flex-row.flex-center', [ h('.section-title.flex-row.flex-center', [
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', { h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
onClick: (event) => { onClick: (event) => {
@ -46,6 +43,27 @@ AccountImportSubview.prototype.render = function () {
}), }),
h('h2.page-subtitle', 'Import Accounts'), h('h2.page-subtitle', 'Import Accounts'),
]), ]),
h('.error', {
style: {
display: 'inline-block',
alignItems: 'center',
padding: '5px 15px 0px 15px',
},
}, [
h('span', 'Imported accounts will not be associated with your originally created MetaMask account seedphrase. Learn more about imported accounts '),
h('span', {
style: {
color: 'rgba(247, 134, 28, 1)',
cursor: 'pointer',
textDecoration: 'underline',
},
onClick: () => {
global.platform.openWindow({
url: 'https://metamask.helpscoutdocs.com/article/17-what-are-loose-accounts',
})
},
}, 'here.'),
]),
h('div', { h('div', {
style: { style: {
padding: '10px', padding: '10px',

@ -79,7 +79,7 @@ class AccountDropdowns extends Component {
try { // Sometimes keyrings aren't loaded yet: try { // Sometimes keyrings aren't loaded yet:
const type = keyring.type const type = keyring.type
const isLoose = type !== 'HD Key Tree' const isLoose = type !== 'HD Key Tree'
return isLoose ? h('.keyring-label', 'LOOSE') : null return isLoose ? h('.keyring-label', 'IMPORTED') : null
} catch (e) { return } } catch (e) { return }
} }

@ -217,7 +217,7 @@ hr.horizontal-line {
background: rgba(255,0,0,0.8); background: rgba(255,0,0,0.8);
color: white; color: white;
bottom: 0px; bottom: 0px;
left: -8px; left: -18px;
border-radius: 10px; border-radius: 10px;
height: 20px; height: 20px;
min-width: 20px; min-width: 20px;

@ -69,7 +69,7 @@ UnlockScreen.prototype.render = function () {
style: { style: {
margin: 10, margin: 10,
}, },
}, 'Unlock'), }, 'Log In'),
]), ]),
h('.flex-row.flex-center.flex-grow', [ h('.flex-row.flex-center.flex-grow', [

@ -13,7 +13,7 @@
"dist": "npm run dist:clear && npm install && gulp dist", "dist": "npm run dist:clear && npm install && gulp dist",
"dist:clear": "rm -rf node_modules/eth-contract-metadata && rm -rf node_modules/eth-phishing-detect", "dist:clear": "rm -rf node_modules/eth-contract-metadata && rm -rf node_modules/eth-phishing-detect",
"test": "npm run lint && npm run test:coverage && npm run test:integration", "test": "npm run lint && npm run test:coverage && npm run test:integration",
"test:unit": "METAMASK_ENV=test mocha --exit --compilers js:babel-core/register --require test/helper.js --recursive \"test/unit/**/*.js\"", "test:unit": "METAMASK_ENV=test mocha --exit --require babel-core/register --require test/helper.js --recursive \"test/unit/**/*.js\"",
"test:single": "METAMASK_ENV=test mocha --require test/helper.js", "test:single": "METAMASK_ENV=test mocha --require test/helper.js",
"test:integration": "gulp build:scss && npm run test:flat && npm run test:mascara", "test:integration": "gulp build:scss && npm run test:flat && npm run test:mascara",
"test:coverage": "nyc npm run test:unit && npm run test:coveralls-upload", "test:coverage": "nyc npm run test:unit && npm run test:coveralls-upload",

File diff suppressed because it is too large Load Diff

@ -1,129 +1,103 @@
const assert = require('assert') const assert = require('assert')
const sinon = require('sinon') const sinon = require('sinon')
const clone = require('clone') const clone = require('clone')
const nock = require('nock')
const MetaMaskController = require('../../app/scripts/metamask-controller') const MetaMaskController = require('../../app/scripts/metamask-controller')
const blacklistJSON = require('../stub/blacklist')
const firstTimeState = require('../../app/scripts/first-time-state') const firstTimeState = require('../../app/scripts/first-time-state')
const BN = require('ethereumjs-util').BN
const GWEI_BN = new BN('1000000000')
describe('MetaMaskController', function () { describe('MetaMaskController', function () {
const noop = () => {} let metamaskController
const metamaskController = new MetaMaskController({ const sandbox = sinon.sandbox.create()
showUnconfirmedMessage: noop, const noop = () => { }
unlockAccountMessage: noop,
showUnapprovedTx: noop,
platform: {},
encryptor: {
encrypt: function(password, object) {
this.object = object
return Promise.resolve()
},
decrypt: function () {
return Promise.resolve(this.object)
}
},
// initial state
initState: clone(firstTimeState),
})
beforeEach(function () { beforeEach(function () {
// sinon allows stubbing methods that are easily verified
this.sinon = sinon.sandbox.create() nock('https://api.infura.io')
.persist()
.get('/v2/blacklist')
.reply(200, blacklistJSON)
nock('https://api.infura.io')
.persist()
.get(/.*/)
.reply(200)
metamaskController = new MetaMaskController({
showUnapprovedTx: noop,
encryptor: {
encrypt: function (password, object) {
this.object = object
return Promise.resolve()
},
decrypt: function () {
return Promise.resolve(this.object)
},
},
initState: clone(firstTimeState),
})
sandbox.spy(metamaskController.keyringController, 'createNewVaultAndKeychain')
sandbox.spy(metamaskController.keyringController, 'createNewVaultAndRestore')
}) })
afterEach(function () { afterEach(function () {
// sinon requires cleanup otherwise it will overwrite context nock.cleanAll()
this.sinon.restore() sandbox.restore()
}) })
describe('Metamask Controller', function () { describe('#getGasPrice', function () {
assert(metamaskController) it('gives the 50th percentile lowest accepted gas price from recentBlocksController', async function () {
const realRecentBlocksController = metamaskController.recentBlocksController
beforeEach(function () { metamaskController.recentBlocksController = {
sinon.spy(metamaskController.keyringController, 'createNewVaultAndKeychain') store: {
sinon.spy(metamaskController.keyringController, 'createNewVaultAndRestore') getState: () => {
}) return {
recentBlocks: [
afterEach(function () { { gasPrices: [ '0x3b9aca00', '0x174876e800'] },
metamaskController.keyringController.createNewVaultAndKeychain.restore() { gasPrices: [ '0x3b9aca00', '0x174876e800'] },
metamaskController.keyringController.createNewVaultAndRestore.restore() { gasPrices: [ '0x174876e800', '0x174876e800' ]},
}) { gasPrices: [ '0x174876e800', '0x174876e800' ]},
],
describe('#getGasPrice', function () {
it('gives the 50th percentile lowest accepted gas price from recentBlocksController', async function () {
const realRecentBlocksController = metamaskController.recentBlocksController
metamaskController.recentBlocksController = {
store: {
getState: () => {
return {
recentBlocks: [
{ gasPrices: [ '0x3b9aca00', '0x174876e800'] },
{ gasPrices: [ '0x3b9aca00', '0x174876e800'] },
{ gasPrices: [ '0x174876e800', '0x174876e800' ]},
{ gasPrices: [ '0x174876e800', '0x174876e800' ]},
]
}
}
}
}
const gasPrice = metamaskController.getGasPrice()
assert.equal(gasPrice, '0x3b9aca00', 'accurately estimates 50th percentile accepted gas price')
metamaskController.recentBlocksController = realRecentBlocksController
})
it('gives the 1 gwei price if no blocks have been seen.', async function () {
const realRecentBlocksController = metamaskController.recentBlocksController
metamaskController.recentBlocksController = {
store: {
getState: () => {
return {
recentBlocks: []
}
} }
} },
} },
}
const gasPrice = metamaskController.getGasPrice()
assert.equal(gasPrice, '0x' + GWEI_BN.toString(16), 'defaults to 1 gwei')
metamaskController.recentBlocksController = realRecentBlocksController const gasPrice = metamaskController.getGasPrice()
}) assert.equal(gasPrice, '0x3b9aca00', 'accurately estimates 50th percentile accepted gas price')
metamaskController.recentBlocksController = realRecentBlocksController
}) })
})
describe('#createNewVaultAndKeychain', function () { describe('#createNewVaultAndKeychain', function () {
it('can only create new vault on keyringController once', async function () { it('can only create new vault on keyringController once', async function () {
const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity') const selectStub = sandbox.stub(metamaskController, 'selectFirstIdentity')
const password = 'a-fake-password' const password = 'a-fake-password'
const first = await metamaskController.createNewVaultAndKeychain(password) await metamaskController.createNewVaultAndKeychain(password)
const second = await metamaskController.createNewVaultAndKeychain(password) await metamaskController.createNewVaultAndKeychain(password)
assert(metamaskController.keyringController.createNewVaultAndKeychain.calledOnce) assert(metamaskController.keyringController.createNewVaultAndKeychain.calledOnce)
selectStub.reset() selectStub.reset()
})
}) })
})
describe('#createNewVaultAndRestore', function () {
it('should be able to call newVaultAndRestore despite a mistake.', async function () {
const password = 'what-what-what'
const wrongSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadiu'
const rightSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
await metamaskController.createNewVaultAndRestore(password, wrongSeed)
.catch((e) => {
return
})
await metamaskController.createNewVaultAndRestore(password, rightSeed)
describe('#createNewVaultAndRestore', function () { assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice)
it('should be able to call newVaultAndRestore despite a mistake.', async function () {
// const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity')
const password = 'what-what-what'
const wrongSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadiu'
const rightSeed = 'debris dizzy just program just float decrease vacant alarm reduce speak stadium'
const first = await metamaskController.createNewVaultAndRestore(password, wrongSeed)
.catch((e) => {
return
})
const second = await metamaskController.createNewVaultAndRestore(password, rightSeed)
assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice)
})
}) })
}) })
}) })

@ -1,25 +1,38 @@
const assert = require('assert') const assert = require('assert')
const nock = require('nock')
const NetworkController = require('../../app/scripts/controllers/network') const NetworkController = require('../../app/scripts/controllers/network')
const { createTestProviderTools } = require('../stub/provider')
const providerResultStub = {}
const provider = createTestProviderTools({ scaffold: providerResultStub }).provider
describe('# Network Controller', function () { describe('# Network Controller', function () {
let networkController let networkController
const noop = () => {}
const networkControllerProviderInit = { const networkControllerProviderInit = {
getAccounts: () => {}, getAccounts: noop,
} }
beforeEach(function () { beforeEach(function () {
nock('https://api.infura.io')
.get('/*/')
.reply(200)
nock('https://rinkeby.infura.io')
.post('/metamask')
.reply(200)
networkController = new NetworkController({ networkController = new NetworkController({
provider: { provider,
type: 'rinkeby',
},
}) })
networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor) networkController.initializeProvider(networkControllerProviderInit, provider)
}) })
describe('network', function () { describe('network', function () {
describe('#provider', function () { describe('#provider', function () {
it('provider should be updatable without reassignment', function () { it('provider should be updatable without reassignment', function () {
networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor) networkController.initializeProvider(networkControllerProviderInit, provider)
const proxy = networkController._proxy const proxy = networkController._proxy
proxy.setTarget({ test: true, on: () => {} }) proxy.setTarget({ test: true, on: () => {} })
assert.ok(proxy.test) assert.ok(proxy.test)
@ -65,20 +78,3 @@ describe('# Network Controller', function () {
}) })
}) })
}) })
function dummyProviderConstructor() {
return {
// provider
sendAsync: noop,
// block tracker
_blockTracker: {},
start: noop,
stop: noop,
on: noop,
addListener: noop,
once: noop,
removeAllListeners: noop,
}
}
function noop() {}

@ -36,6 +36,21 @@ AccountImportSubview.prototype.render = function () {
return ( return (
h('div.new-account-import-form', [ h('div.new-account-import-form', [
h('.new-account-import-disclaimer', [
h('span', 'Imported accounts will not be associated with your originally created MetaMask account seedphrase. Learn more about imported accounts '),
h('span', {
style: {
cursor: 'pointer',
textDecoration: 'underline',
},
onClick: () => {
global.platform.openWindow({
url: 'https://metamask.helpscoutdocs.com/article/17-what-are-loose-accounts',
})
},
}, 'here'),
]),
h('div.new-account-import-form__select-section', [ h('div.new-account-import-form__select-section', [
h('div.new-account-import-form__select-label', 'Select Type'), h('div.new-account-import-form__select-label', 'Select Type'),

@ -135,22 +135,6 @@ class AccountDropdowns extends Component {
]), ]),
]), ]),
// =======
// },
// ),
// this.indicateIfLoose(keyring),
// h('span', {
// style: {
// marginLeft: '20px',
// fontSize: '24px',
// maxWidth: '145px',
// whiteSpace: 'nowrap',
// overflow: 'hidden',
// textOverflow: 'ellipsis',
// },
// }, identity.name || ''),
// h('span', { style: { marginLeft: '20px', fontSize: '24px' } }, isSelected ? h('.check', '✓') : null),
// >>>>>>> master:ui/app/components/account-dropdowns.js
] ]
) )
}) })

@ -66,8 +66,9 @@
.keyring-label { .keyring-label {
margin-top: 5px; margin-top: 5px;
background-color: $black; background-color: $dusty-gray;
color: $dusty-gray; color: $black;
font-weight: normal;
} }
} }

@ -54,6 +54,16 @@
} }
.new-account-import-disclaimer {
width: 120%;
background-color: #F4F9FC;
display: inline-block;
align-items: center;
padding: 20px 30px 20px;
font-size: 12px;
line-height: 1.5;
}
.new-account-import-form { .new-account-import-form {
display: flex; display: flex;
flex-flow: column; flex-flow: column;

@ -72,7 +72,7 @@ UnlockScreen.prototype.render = function () {
style: { style: {
margin: 10, margin: 10,
}, },
}, 'Unlock'), }, 'Log In'),
]), ]),
h('.flex-row.flex-center.flex-grow', [ h('.flex-row.flex-center.flex-grow', [

Loading…
Cancel
Save