Merge pull request #4399 from MetaMask/merge-master

Pull master changes back into develop
feature/default_network_editable
kumavis 7 years ago committed by GitHub
commit ff6976b8a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      CHANGELOG.md
  2. 5
      app/manifest.json
  3. 12
      app/scripts/background.js
  4. 8
      app/scripts/controllers/transactions/index.js
  5. 9
      app/scripts/controllers/transactions/tx-state-manager.js
  6. 24
      app/scripts/lib/cleanErrorStack.js
  7. 15
      app/scripts/metamask-controller.js

@ -2,6 +2,14 @@
## Current Master ## Current Master
## 4.6.1 Mon Apr 30 2018
- Fix bug where sending a transaction resulted in an infinite spinner
- Allow transactions with a 0 gwei gas price
- Handle encoding errors in ERC20 symbol + digits
- Fix ShapeShift forms (new + old ui)
- Fix sourcemaps
## 4.6.0 Thu Apr 26 2018 ## 4.6.0 Thu Apr 26 2018
- Correctly format currency conversion for locally selected preferred currency. - Correctly format currency conversion for locally selected preferred currency.

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

@ -309,6 +309,7 @@ function setupController (initState, initLangCode) {
// connect to other contexts // connect to other contexts
// //
extension.runtime.onConnect.addListener(connectRemote) extension.runtime.onConnect.addListener(connectRemote)
extension.runtime.onConnectExternal.addListener(connectExternal)
const metamaskInternalProcessHash = { const metamaskInternalProcessHash = {
[ENVIRONMENT_TYPE_POPUP]: true, [ENVIRONMENT_TYPE_POPUP]: true,
@ -335,9 +336,9 @@ function setupController (initState, initLangCode) {
function connectRemote (remotePort) { function connectRemote (remotePort) {
const processName = remotePort.name const processName = remotePort.name
const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName] const isMetaMaskInternalProcess = metamaskInternalProcessHash[processName]
const portStream = new PortStream(remotePort)
if (isMetaMaskInternalProcess) { if (isMetaMaskInternalProcess) {
const portStream = new PortStream(remotePort)
// communication with popup // communication with popup
controller.isClientOpen = true controller.isClientOpen = true
controller.setupTrustedCommunication(portStream, 'MetaMask') controller.setupTrustedCommunication(portStream, 'MetaMask')
@ -370,11 +371,16 @@ function setupController (initState, initLangCode) {
}) })
} }
} else { } else {
// communication with page connectExternal(remotePort)
}
}
// communication with page or other extension
function connectExternal(remotePort) {
const originDomain = urlUtil.parse(remotePort.sender.url).hostname const originDomain = urlUtil.parse(remotePort.sender.url).hostname
const portStream = new PortStream(remotePort)
controller.setupUntrustedCommunication(portStream, originDomain) controller.setupUntrustedCommunication(portStream, originDomain)
} }
}
// //
// User Interface setup // User Interface setup

@ -8,6 +8,7 @@ const TxGasUtil = require('./tx-gas-utils')
const PendingTransactionTracker = require('./pending-tx-tracker') const PendingTransactionTracker = require('./pending-tx-tracker')
const NonceTracker = require('./nonce-tracker') const NonceTracker = require('./nonce-tracker')
const txUtils = require('./lib/util') const txUtils = require('./lib/util')
const cleanErrorStack = require('../../lib/cleanErrorStack')
const log = require('loglevel') const log = require('loglevel')
/** /**
@ -118,6 +119,7 @@ class TransactionController extends EventEmitter {
@param txParams {object} - txParams for the transaction @param txParams {object} - txParams for the transaction
@param opts {object} - with the key origin to put the origin on the txMeta @param opts {object} - with the key origin to put the origin on the txMeta
*/ */
async newUnapprovedTransaction (txParams, opts = {}) { async newUnapprovedTransaction (txParams, opts = {}) {
log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`) log.debug(`MetaMaskController newUnapprovedTransaction ${JSON.stringify(txParams)}`)
const initialTxMeta = await this.addUnapprovedTransaction(txParams) const initialTxMeta = await this.addUnapprovedTransaction(txParams)
@ -130,11 +132,11 @@ class TransactionController extends EventEmitter {
case 'submitted': case 'submitted':
return resolve(finishedTxMeta.hash) return resolve(finishedTxMeta.hash)
case 'rejected': case 'rejected':
return reject(new Error('MetaMask Tx Signature: User denied transaction signature.')) return reject(cleanErrorStack(new Error('MetaMask Tx Signature: User denied transaction signature.')))
case 'failed': case 'failed':
return reject(new Error(finishedTxMeta.err.message)) return reject(cleanErrorStack(new Error(finishedTxMeta.err.message)))
default: default:
return reject(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`)) return reject(cleanErrorStack(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(finishedTxMeta.txParams)}`)))
} }
}) })
}) })

@ -2,6 +2,7 @@ const extend = require('xtend')
const EventEmitter = require('events') const EventEmitter = require('events')
const ObservableStore = require('obs-store') const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util') const ethUtil = require('ethereumjs-util')
const log = require('loglevel')
const txStateHistoryHelper = require('./lib/tx-state-history-helper') const txStateHistoryHelper = require('./lib/tx-state-history-helper')
const createId = require('../../lib/random-id') const createId = require('../../lib/random-id')
const { getFinalStates } = require('./lib/util') const { getFinalStates } = require('./lib/util')
@ -398,13 +399,19 @@ class TransactionStateManager extends EventEmitter {
_setTxStatus (txId, status) { _setTxStatus (txId, status) {
const txMeta = this.getTx(txId) const txMeta = this.getTx(txId)
txMeta.status = status txMeta.status = status
setTimeout(() => {
try {
this.updateTx(txMeta, `txStateManager: setting status to ${status}`)
this.emit(`${txMeta.id}:${status}`, txId) this.emit(`${txMeta.id}:${status}`, txId)
this.emit(`tx:status-update`, txId, status) this.emit(`tx:status-update`, txId, status)
if (['submitted', 'rejected', 'failed'].includes(status)) { if (['submitted', 'rejected', 'failed'].includes(status)) {
this.emit(`${txMeta.id}:finished`, txMeta) this.emit(`${txMeta.id}:finished`, txMeta)
} }
this.updateTx(txMeta, `txStateManager: setting status to ${status}`)
this.emit('update:badge') this.emit('update:badge')
} catch (error) {
log.error(error)
}
})
} }
/** /**

@ -0,0 +1,24 @@
/**
* Returns error without stack trace for better UI display
* @param {Error} err - error
* @returns {Error} Error with clean stack trace.
*/
function cleanErrorStack(err){
var name = err.name
name = (name === undefined) ? 'Error' : String(name)
var msg = err.message
msg = (msg === undefined) ? '' : String(msg)
if (name === '') {
err.stack = err.message
} else if (msg === '') {
err.stack = err.name
} else {
err.stack = err.name + ': ' + err.message
}
return err
}
module.exports = cleanErrorStack

@ -45,6 +45,7 @@ const BN = require('ethereumjs-util').BN
const GWEI_BN = new BN('1000000000') 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 log = require('loglevel') const log = require('loglevel')
module.exports = class MetamaskController extends EventEmitter { module.exports = class MetamaskController extends EventEmitter {
@ -642,9 +643,9 @@ module.exports = class MetamaskController extends EventEmitter {
case 'signed': case 'signed':
return cb(null, data.rawSig) return cb(null, data.rawSig)
case 'rejected': case 'rejected':
return cb(new Error('MetaMask Message Signature: User denied message signature.')) return cb(cleanErrorStack(new Error('MetaMask Message Signature: User denied message signature.')))
default: default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)) return cb(cleanErrorStack(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)))
} }
}) })
} }
@ -702,7 +703,7 @@ module.exports = class MetamaskController extends EventEmitter {
*/ */
newUnsignedPersonalMessage (msgParams, cb) { newUnsignedPersonalMessage (msgParams, cb) {
if (!msgParams.from) { if (!msgParams.from) {
return cb(new Error('MetaMask Message Signature: from field is required.')) return cb(cleanErrorStack(new Error('MetaMask Message Signature: from field is required.')))
} }
const msgId = this.personalMessageManager.addUnapprovedMessage(msgParams) const msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
@ -713,9 +714,9 @@ module.exports = class MetamaskController extends EventEmitter {
case 'signed': case 'signed':
return cb(null, data.rawSig) return cb(null, data.rawSig)
case 'rejected': case 'rejected':
return cb(new Error('MetaMask Message Signature: User denied message signature.')) return cb(cleanErrorStack(new Error('MetaMask Message Signature: User denied message signature.')))
default: default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)) return cb(cleanErrorStack(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)))
} }
}) })
} }
@ -781,9 +782,9 @@ module.exports = class MetamaskController extends EventEmitter {
case 'signed': case 'signed':
return cb(null, data.rawSig) return cb(null, data.rawSig)
case 'rejected': case 'rejected':
return cb(new Error('MetaMask Message Signature: User denied message signature.')) return cb(cleanErrorStack(new Error('MetaMask Message Signature: User denied message signature.')))
default: default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)) return cb(cleanErrorStack(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`)))
} }
}) })
} }

Loading…
Cancel
Save