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
## 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 editing of symbol and decimal info when adding custom token in new-ui
- new-ui shapeshift form can select all coins (not just BTC)
- Classic ui and new-ui shapeshift forms show when coins are not available on shapeshift
- NewUI shapeshift form can select all coins (not just BTC)
- Add most of Microsoft Edge support.
## 4.1.3 2018-2-28

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

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

@ -34,10 +34,7 @@ AccountImportSubview.prototype.render = function () {
const { type } = state
return (
h('div', {
style: {
},
}, [
h('div', [
h('.section-title.flex-row.flex-center', [
h('i.fa.fa-arrow-left.fa-lg.cursor-pointer', {
onClick: (event) => {
@ -46,6 +43,27 @@ AccountImportSubview.prototype.render = function () {
}),
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', {
style: {
padding: '10px',

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

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

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

@ -13,7 +13,7 @@
"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",
"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:integration": "gulp build:scss && npm run test:flat && npm run test:mascara",
"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 sinon = require('sinon')
const clone = require('clone')
const nock = require('nock')
const MetaMaskController = require('../../app/scripts/metamask-controller')
const blacklistJSON = require('../stub/blacklist')
const firstTimeState = require('../../app/scripts/first-time-state')
const BN = require('ethereumjs-util').BN
const GWEI_BN = new BN('1000000000')
describe('MetaMaskController', function () {
const noop = () => {}
const metamaskController = new MetaMaskController({
showUnconfirmedMessage: 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),
})
let metamaskController
const sandbox = sinon.sandbox.create()
const noop = () => { }
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 () {
// sinon requires cleanup otherwise it will overwrite context
this.sinon.restore()
nock.cleanAll()
sandbox.restore()
})
describe('Metamask Controller', function () {
assert(metamaskController)
beforeEach(function () {
sinon.spy(metamaskController.keyringController, 'createNewVaultAndKeychain')
sinon.spy(metamaskController.keyringController, 'createNewVaultAndRestore')
})
afterEach(function () {
metamaskController.keyringController.createNewVaultAndKeychain.restore()
metamaskController.keyringController.createNewVaultAndRestore.restore()
})
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: []
}
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, '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 () {
it('can only create new vault on keyringController once', async function () {
const selectStub = sinon.stub(metamaskController, 'selectFirstIdentity')
describe('#createNewVaultAndKeychain', function () {
it('can only create new vault on keyringController once', async function () {
const selectStub = sandbox.stub(metamaskController, 'selectFirstIdentity')
const password = 'a-fake-password'
const password = 'a-fake-password'
const first = await metamaskController.createNewVaultAndKeychain(password)
const second = await metamaskController.createNewVaultAndKeychain(password)
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 () {
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)
})
assert(metamaskController.keyringController.createNewVaultAndRestore.calledTwice)
})
})
})

@ -1,25 +1,38 @@
const assert = require('assert')
const nock = require('nock')
const NetworkController = require('../../app/scripts/controllers/network')
const { createTestProviderTools } = require('../stub/provider')
const providerResultStub = {}
const provider = createTestProviderTools({ scaffold: providerResultStub }).provider
describe('# Network Controller', function () {
let networkController
const noop = () => {}
const networkControllerProviderInit = {
getAccounts: () => {},
getAccounts: noop,
}
beforeEach(function () {
nock('https://api.infura.io')
.get('/*/')
.reply(200)
nock('https://rinkeby.infura.io')
.post('/metamask')
.reply(200)
networkController = new NetworkController({
provider: {
type: 'rinkeby',
},
provider,
})
networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor)
networkController.initializeProvider(networkControllerProviderInit, provider)
})
describe('network', function () {
describe('#provider', function () {
it('provider should be updatable without reassignment', function () {
networkController.initializeProvider(networkControllerProviderInit, dummyProviderConstructor)
networkController.initializeProvider(networkControllerProviderInit, provider)
const proxy = networkController._proxy
proxy.setTarget({ test: true, on: () => {} })
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 (
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-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 {
margin-top: 5px;
background-color: $black;
color: $dusty-gray;
background-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 {
display: flex;
flex-flow: column;

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

Loading…
Cancel
Save