Merge github.com:MetaMask/metamask-extension into rejectallunapproved

feature/default_network_editable
Kevin Serrano 7 years ago
commit 2e18dd27a4
No known key found for this signature in database
GPG Key ID: BF999DEFC7371BA1
  1. 7
      CHANGELOG.md
  2. 5
      app/manifest.json
  3. 24
      app/scripts/lib/inpage-provider.js
  4. 4
      circle.yml
  5. 19
      test/unit/nonce-tracker-test.js
  6. 29
      ui/app/add-token.js
  7. 11
      ui/app/components/network.js
  8. 2
      ui/app/unlock.js

@ -3,6 +3,13 @@
## Current Master ## Current Master
- Readded loose keyring label back into the account list. - Readded loose keyring label back into the account list.
- Added button to reject all transactions (thanks [davidp94](https://github.com/davidp94)!) - Added button to reject all transactions (thanks [davidp94](https://github.com/davidp94)!)
- Remove cryptonator from chrome permissions.
- Add info on token contract addresses.
- Add validation preventing users from inputting their own addresses as token tracking addresses.
## 3.9.13 2017-9-8
- Changed the way we initialize the inpage provider to fix a bug affecting some developers.
## 3.9.12 2017-9-6 ## 3.9.12 2017-9-6

@ -1,7 +1,7 @@
{ {
"name": "MetaMask", "name": "MetaMask",
"short_name": "Metamask", "short_name": "Metamask",
"version": "3.9.12", "version": "3.9.13",
"manifest_version": 2, "manifest_version": 2,
"author": "https://metamask.io", "author": "https://metamask.io",
"description": "Ethereum Browser Extension", "description": "Ethereum Browser Extension",
@ -57,8 +57,7 @@
"permissions": [ "permissions": [
"storage", "storage",
"clipboardWrite", "clipboardWrite",
"http://localhost:8545/", "http://localhost:8545/"
"https://api.cryptonator.com/"
], ],
"web_accessible_resources": [ "web_accessible_resources": [
"scripts/inpage.js" "scripts/inpage.js"

@ -40,31 +40,37 @@ function MetamaskInpageProvider (connectionStream) {
// start and stop polling to unblock first block lock // start and stop polling to unblock first block lock
self.idMap = {} self.idMap = {}
// handle sendAsync requests via asyncProvider }
self.sendAsync = function (payload, cb) {
// handle sendAsync requests via asyncProvider
// also remap ids inbound and outbound
MetamaskInpageProvider.prototype.sendAsync = function (payload, cb) {
const self = this
// rewrite request ids // rewrite request ids
var request = eachJsonMessage(payload, (_message) => { const request = eachJsonMessage(payload, (_message) => {
const message = Object.assign({}, _message) const message = Object.assign({}, _message)
const newId = createRandomId() const newId = createRandomId()
self.idMap[newId] = message.id self.idMap[newId] = message.id
message.id = newId message.id = newId
return message return message
}) })
// forward to asyncProvider // forward to asyncProvider
asyncProvider.sendAsync(request, function (err, res) { self.asyncProvider.sendAsync(request, (err, _res) => {
if (err) return cb(err) if (err) return cb(err)
// transform messages to original ids // transform messages to original ids
eachJsonMessage(res, (message) => { const res = eachJsonMessage(_res, (message) => {
var oldId = self.idMap[message.id] const oldId = self.idMap[message.id]
delete self.idMap[message.id] delete self.idMap[message.id]
message.id = oldId message.id = oldId
return message return message
}) })
cb(null, res) cb(null, res)
}) })
}
} }
MetamaskInpageProvider.prototype.send = function (payload) { MetamaskInpageProvider.prototype.send = function (payload) {
const self = this const self = this
@ -110,10 +116,6 @@ MetamaskInpageProvider.prototype.send = function (payload) {
} }
} }
MetamaskInpageProvider.prototype.sendAsync = function () {
throw new Error('MetamaskInpageProvider - sendAsync not overwritten')
}
MetamaskInpageProvider.prototype.isConnected = function () { MetamaskInpageProvider.prototype.isConnected = function () {
return true return true
} }

@ -1,10 +1,6 @@
machine: machine:
node: node:
version: 8.1.4 version: 8.1.4
dependencies:
pre:
- "npm i -g testem"
- "npm i -g mocha"
test: test:
override: override:
- "npm run ci" - "npm run ci"

@ -162,6 +162,25 @@ describe('Nonce Tracker', function () {
await nonceLock.releaseLock() await nonceLock.releaseLock()
}) })
}) })
describe('Faq issue 67', function () {
beforeEach(function () {
const txGen = new MockTxGen()
const confirmedTxs = txGen.generate({ status: 'confirmed' }, { count: 64 })
const pendingTxs = txGen.generate({
status: 'submitted',
}, { count: 10 })
// 0x40 is 64 in hex:
nonceTracker = generateNonceTrackerWith(pendingTxs, [], '0x40')
})
it('should return nonce after network nonce', async function () {
this.timeout(15000)
const nonceLock = await nonceTracker.getNonceLock('0x7d3517b0d011698406d6e0aed8453f0be2697926')
assert.equal(nonceLock.nextNonce, '74', `nonce should be 74 got ${nonceLock.nextNonce}`)
await nonceLock.releaseLock()
})
})
}) })
}) })

@ -3,6 +3,8 @@ const Component = require('react').Component
const h = require('react-hyperscript') const h = require('react-hyperscript')
const connect = require('react-redux').connect const connect = require('react-redux').connect
const actions = require('./actions') const actions = require('./actions')
const Tooltip = require('./components/tooltip.js')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
const abi = require('human-standard-token-abi') const abi = require('human-standard-token-abi')
@ -15,6 +17,7 @@ module.exports = connect(mapStateToProps)(AddTokenScreen)
function mapStateToProps (state) { function mapStateToProps (state) {
return { return {
identities: state.metamask.identities,
} }
} }
@ -64,15 +67,25 @@ AddTokenScreen.prototype.render = function () {
}, [ }, [
h('div', [ h('div', [
h('span', { h(Tooltip, {
position: 'top',
title: 'The contract of the actual token contract. Click for more info.',
}, [
h('a', {
style: { fontWeight: 'bold', paddingRight: '10px'}, style: { fontWeight: 'bold', paddingRight: '10px'},
}, 'Token Address'), href: 'https://consensyssupport.happyfox.com/staff/kb/article/24-what-is-a-token-contract-address',
target: '_blank',
}, [
h('span', 'Token Contract Address '),
h('i.fa.fa-question-circle'),
]),
]),
]), ]),
h('section.flex-row.flex-center', [ h('section.flex-row.flex-center', [
h('input#token-address', { h('input#token-address', {
name: 'address', name: 'address',
placeholder: 'Token Address', placeholder: 'Token Contract Address',
onChange: this.tokenAddressDidChange.bind(this), onChange: this.tokenAddressDidChange.bind(this),
style: { style: {
width: 'inherit', width: 'inherit',
@ -171,7 +184,9 @@ AddTokenScreen.prototype.tokenAddressDidChange = function (event) {
AddTokenScreen.prototype.validateInputs = function () { AddTokenScreen.prototype.validateInputs = function () {
let msg = '' let msg = ''
const state = this.state const state = this.state
const identitiesList = Object.keys(this.props.identities)
const { address, symbol, decimals } = state const { address, symbol, decimals } = state
const standardAddress = ethUtil.addHexPrefix(address).toLowerCase()
const validAddress = ethUtil.isValidAddress(address) const validAddress = ethUtil.isValidAddress(address)
if (!validAddress) { if (!validAddress) {
@ -189,7 +204,12 @@ AddTokenScreen.prototype.validateInputs = function () {
msg += 'Symbol must be between 0 and 10 characters.' msg += 'Symbol must be between 0 and 10 characters.'
} }
const isValid = validAddress && validDecimals const ownAddress = identitiesList.includes(standardAddress)
if (ownAddress) {
msg = 'Personal address detected. Input the token contract address.'
}
const isValid = validAddress && validDecimals && !ownAddress
if (!isValid) { if (!isValid) {
this.setState({ this.setState({
@ -216,4 +236,3 @@ AddTokenScreen.prototype.attemptToAutoFillTokenParams = async function (address)
this.setState({ symbol: symbol[0], decimals: decimals[0].toString() }) this.setState({ symbol: symbol[0], decimals: decimals[0].toString() })
} }
} }

@ -22,7 +22,7 @@ Network.prototype.render = function () {
let iconName, hoverText let iconName, hoverText
if (networkNumber === 'loading') { if (networkNumber === 'loading') {
return h('span', { return h('span.pointer', {
style: { style: {
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
@ -37,7 +37,7 @@ Network.prototype.render = function () {
}, },
src: 'images/loading.svg', src: 'images/loading.svg',
}), }),
h('i.fa.fa-sort-desc'), h('i.fa.fa-caret-down'),
]) ])
} else if (providerName === 'mainnet') { } else if (providerName === 'mainnet') {
hoverText = 'Main Ethereum Network' hoverText = 'Main Ethereum Network'
@ -73,7 +73,8 @@ Network.prototype.render = function () {
style: { style: {
color: '#039396', color: '#039396',
}}, }},
'Ethereum Main Net'), 'Main Network'),
h('i.fa.fa-caret-down.fa-lg'),
]) ])
case 'ropsten-test-network': case 'ropsten-test-network':
return h('.network-indicator', [ return h('.network-indicator', [
@ -83,6 +84,7 @@ Network.prototype.render = function () {
color: '#ff6666', color: '#ff6666',
}}, }},
'Ropsten Test Net'), 'Ropsten Test Net'),
h('i.fa.fa-caret-down.fa-lg'),
]) ])
case 'kovan-test-network': case 'kovan-test-network':
return h('.network-indicator', [ return h('.network-indicator', [
@ -92,6 +94,7 @@ Network.prototype.render = function () {
color: '#690496', color: '#690496',
}}, }},
'Kovan Test Net'), 'Kovan Test Net'),
h('i.fa.fa-caret-down.fa-lg'),
]) ])
case 'rinkeby-test-network': case 'rinkeby-test-network':
return h('.network-indicator', [ return h('.network-indicator', [
@ -101,6 +104,7 @@ Network.prototype.render = function () {
color: '#e7a218', color: '#e7a218',
}}, }},
'Rinkeby Test Net'), 'Rinkeby Test Net'),
h('i.fa.fa-caret-down.fa-lg'),
]) ])
default: default:
return h('.network-indicator', [ return h('.network-indicator', [
@ -116,6 +120,7 @@ Network.prototype.render = function () {
color: '#AEAEAE', color: '#AEAEAE',
}}, }},
'Private Network'), 'Private Network'),
h('i.fa.fa-caret-down.fa-lg'),
]) ])
} }
})(), })(),

@ -80,7 +80,7 @@ UnlockScreen.prototype.render = function () {
color: 'rgb(247, 134, 28)', color: 'rgb(247, 134, 28)',
textDecoration: 'underline', textDecoration: 'underline',
}, },
}, 'I forgot my password.'), }, 'Restore from seed phrase'),
]), ]),
]) ])
) )

Loading…
Cancel
Save