aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorKevin Serrano <kevgagser@gmail.com>2017-03-08 02:37:31 +0800
committerKevin Serrano <kevgagser@gmail.com>2017-03-08 02:37:31 +0800
commit08ca7dac5a15e104084c6da3eb6015136b316809 (patch)
tree3e0b1a61f3be3aa1e01824512b4df0a793dc6a17 /app
parent01f2ec4823e83d986e7ecfd268f6b293f38a13e8 (diff)
parent2acf991b67bc42fb904ff77af6ff6a7ca3a683fd (diff)
downloadtangerine-wallet-browser-08ca7dac5a15e104084c6da3eb6015136b316809.tar
tangerine-wallet-browser-08ca7dac5a15e104084c6da3eb6015136b316809.tar.gz
tangerine-wallet-browser-08ca7dac5a15e104084c6da3eb6015136b316809.tar.bz2
tangerine-wallet-browser-08ca7dac5a15e104084c6da3eb6015136b316809.tar.lz
tangerine-wallet-browser-08ca7dac5a15e104084c6da3eb6015136b316809.tar.xz
tangerine-wallet-browser-08ca7dac5a15e104084c6da3eb6015136b316809.tar.zst
tangerine-wallet-browser-08ca7dac5a15e104084c6da3eb6015136b316809.zip
Merge branch 'master' into i1144-moarrpc
Diffstat (limited to 'app')
-rw-r--r--app/scripts/lib/personal-message-manager.js22
-rw-r--r--app/scripts/metamask-controller.js8
-rw-r--r--app/scripts/transaction-manager.js2
3 files changed, 19 insertions, 13 deletions
diff --git a/app/scripts/lib/personal-message-manager.js b/app/scripts/lib/personal-message-manager.js
index 3b8510767..bbc978446 100644
--- a/app/scripts/lib/personal-message-manager.js
+++ b/app/scripts/lib/personal-message-manager.js
@@ -2,6 +2,7 @@ const EventEmitter = require('events')
const ObservableStore = require('obs-store')
const ethUtil = require('ethereumjs-util')
const createId = require('./random-id')
+const hexRe = /^[0-9A-Fa-f]+$/g
module.exports = class PersonalMessageManager extends EventEmitter{
@@ -24,7 +25,8 @@ module.exports = class PersonalMessageManager extends EventEmitter{
}
addUnapprovedMessage (msgParams) {
- msgParams.data = normalizeMsgData(msgParams.data)
+ log.debug(`PersonalMessageManager addUnapprovedMessage: ${JSON.stringify(msgParams)}`)
+ msgParams.data = this.normalizeMsgData(msgParams.data)
// create txData obj with parameters and meta data
var time = (new Date()).getTime()
var msgId = createId()
@@ -106,14 +108,18 @@ module.exports = class PersonalMessageManager extends EventEmitter{
this.emit('updateBadge')
}
-}
+ normalizeMsgData(data) {
+ try {
+ const stripped = ethUtil.stripHexPrefix(data)
+ if (stripped.match(hexRe)) {
+ return ethUtil.addHexPrefix(stripped)
+ }
+ } catch (e) {
+ log.debug(`Message was not hex encoded, interpreting as utf8.`)
+ }
-function normalizeMsgData(data) {
- if (data.slice(0, 2) === '0x') {
- // data is already hex
- return data
- } else {
- // data is unicode, convert to hex
return ethUtil.bufferToHex(new Buffer(data, 'utf8'))
}
+
}
+
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index ab55ed697..f6dbf899d 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -415,14 +415,14 @@ module.exports = class MetamaskController extends EventEmitter {
self.sendUpdate()
self.opts.showUnapprovedTx(txMeta)
// listen for tx completion (success, fail)
- self.txManager.once(`${txMeta.id}:finished`, (status) => {
- switch (status) {
+ self.txManager.once(`${txMeta.id}:finished`, (completedTx) => {
+ switch (completedTx.status) {
case 'submitted':
- return cb(null, txMeta.hash)
+ return cb(null, completedTx.hash)
case 'rejected':
return cb(new Error('MetaMask Tx Signature: User denied transaction signature.'))
default:
- return cb(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(txMeta.txParams)}`))
+ return cb(new Error(`MetaMask Tx Signature: Unknown problem: ${JSON.stringify(completedTx.txParams)}`))
}
})
})
diff --git a/app/scripts/transaction-manager.js b/app/scripts/transaction-manager.js
index 07c90af7e..c6cfdf11d 100644
--- a/app/scripts/transaction-manager.js
+++ b/app/scripts/transaction-manager.js
@@ -353,7 +353,7 @@ module.exports = class TransactionManager extends EventEmitter {
txMeta.status = status
this.emit(`${txMeta.id}:${status}`, txId)
if (status === 'submitted' || status === 'rejected') {
- this.emit(`${txMeta.id}:finished`, status)
+ this.emit(`${txMeta.id}:finished`, txMeta)
}
this.updateTx(txMeta)
this.emit('updateBadge')