aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <dan@danfinlay.com>2017-02-24 08:00:43 +0800
committerDan Finlay <dan@danfinlay.com>2017-02-24 08:02:58 +0800
commit961a83769bd46334f5ecf72d00a32730d19866c3 (patch)
tree5d7397ec9e83c90e7c56ab9a1b9c62d9aa052ffe
parent1d1d296a1eec2fc66927dd80bf0f1bbd1a6841cf (diff)
downloadtangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar
tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar.gz
tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar.bz2
tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar.lz
tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar.xz
tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.tar.zst
tangerine-wallet-browser-961a83769bd46334f5ecf72d00a32730d19866c3.zip
Fix cancel msg signing behavior.
-rw-r--r--app/scripts/metamask-controller.js31
-rw-r--r--ui/app/actions.js8
-rw-r--r--ui/app/components/pending-personal-msg.js2
-rw-r--r--ui/app/conf-tx.js8
-rw-r--r--ui/app/reducers/app.js15
5 files changed, 45 insertions, 19 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index c301e2035..eace72c24 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -139,6 +139,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.ethStore.subscribe(this.sendUpdate.bind(this))
this.txManager.memStore.subscribe(this.sendUpdate.bind(this))
this.messageManager.memStore.subscribe(this.sendUpdate.bind(this))
+ this.personalMessageManager.memStore.subscribe(this.sendUpdate.bind(this))
this.keyringController.memStore.subscribe(this.sendUpdate.bind(this))
this.preferencesController.store.subscribe(this.sendUpdate.bind(this))
this.currencyController.store.subscribe(this.sendUpdate.bind(this))
@@ -239,8 +240,6 @@ module.exports = class MetamaskController extends EventEmitter {
const keyringController = this.keyringController
const preferencesController = this.preferencesController
const txManager = this.txManager
- const messageManager = this.messageManager
- const personalMessageManager = this.personalMessageManager
const noticeController = this.noticeController
return {
@@ -283,11 +282,11 @@ module.exports = class MetamaskController extends EventEmitter {
// messageManager
signMessage: nodeify(this.signMessage).bind(this),
- cancelMessage: messageManager.rejectMsg.bind(messageManager),
+ cancelMessage: this.cancelMessage.bind(this),
// personalMessageManager
signPersonalMessage: nodeify(this.signPersonalMessage).bind(this),
- cancelPersonalMessage: personalMessageManager.rejectMsg.bind(personalMessageManager),
+ cancelPersonalMessage: this.cancelPersonalMessage.bind(this),
// notices
checkNotices: noticeController.updateNoticesList.bind(noticeController),
@@ -437,7 +436,7 @@ module.exports = class MetamaskController extends EventEmitter {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
- return cb(new Error('MetaMask Message Signature: User denied transaction signature.'))
+ return cb(new Error('MetaMask Message Signature: User denied message signature.'))
default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
@@ -445,6 +444,10 @@ module.exports = class MetamaskController extends EventEmitter {
}
newUnsignedPersonalMessage (msgParams, cb) {
+ if (!msgParams.from) {
+ return cb(new Error('MetaMask Message Signature: from field is required.'))
+ }
+
let msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
this.sendUpdate()
this.opts.showUnconfirmedMessage()
@@ -453,7 +456,7 @@ module.exports = class MetamaskController extends EventEmitter {
case 'signed':
return cb(null, data.rawSig)
case 'rejected':
- return cb(new Error('MetaMask Message Signature: User denied transaction signature.'))
+ return cb(new Error('MetaMask Message Signature: User denied message signature.'))
default:
return cb(new Error(`MetaMask Message Signature: Unknown problem: ${JSON.stringify(msgParams)}`))
}
@@ -479,6 +482,14 @@ module.exports = class MetamaskController extends EventEmitter {
})
}
+ cancelMessage(msgId, cb) {
+ const messageManager = this.messageManager
+ messageManager.rejectMsg(msgId)
+ if (cb && typeof cb === 'function') {
+ cb(null, this.getState())
+ }
+ }
+
// Prefixed Style Message Signing Methods:
approvePersonalMessage (msgParams, cb) {
let msgId = this.personalMessageManager.addUnapprovedMessage(msgParams)
@@ -514,6 +525,14 @@ module.exports = class MetamaskController extends EventEmitter {
})
}
+ cancelPersonalMessage(msgId, cb) {
+ const messageManager = this.personalMessageManager
+ messageManager.rejectMsg(msgId)
+ if (cb && typeof cb === 'function') {
+ cb(null, this.getState())
+ }
+ }
+
recoverPersonalMessage (msgParams) {
const keyringController = this.keyringController
return keyringController.recoverPersonalMessage(msgParams)
diff --git a/ui/app/actions.js b/ui/app/actions.js
index 12ee0367a..89a4fadfa 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -418,7 +418,7 @@ function sendTx (txData) {
function completedTx (id) {
return {
type: actions.COMPLETED_TX,
- id,
+ value: id,
}
}
@@ -436,9 +436,9 @@ function cancelMsg (msgData) {
}
function cancelPersonalMsg (msgData) {
- log.debug(`background.cancelMessage`)
- background.cancelPersonalMessage(msgData.id)
- return actions.completedTx(msgData.id)
+ const id = msgData.id
+ background.cancelPersonalMessage(id)
+ return actions.completedTx(id)
}
function cancelTx (txData) {
diff --git a/ui/app/components/pending-personal-msg.js b/ui/app/components/pending-personal-msg.js
index d48dd5ecc..4542adb28 100644
--- a/ui/app/components/pending-personal-msg.js
+++ b/ui/app/components/pending-personal-msg.js
@@ -34,7 +34,7 @@ PendingMsg.prototype.render = function () {
// sign + cancel
h('.flex-row.flex-space-around', [
h('button', {
- onClick: state.cancelMessage,
+ onClick: state.cancelPersonalMessage,
}, 'Cancel'),
h('button', {
onClick: state.signPersonalMessage,
diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js
index a2e5ee94c..2df6c5384 100644
--- a/ui/app/conf-tx.js
+++ b/ui/app/conf-tx.js
@@ -111,6 +111,7 @@ ConfirmTxScreen.prototype.render = function () {
signMessage: this.signMessage.bind(this, txData),
signPersonalMessage: this.signPersonalMessage.bind(this, txData),
cancelMessage: this.cancelMessage.bind(this, txData),
+ cancelPersonalMessage: this.cancelPersonalMessage.bind(this, txData),
}),
]),
@@ -170,7 +171,6 @@ ConfirmTxScreen.prototype.cancelTransaction = function (txData, event) {
ConfirmTxScreen.prototype.signMessage = function (msgData, event) {
log.info('conf-tx.js: signing message')
var params = msgData.msgParams
- var type = msgData.type
params.metamaskId = msgData.id
event.stopPropagation()
this.props.dispatch(actions.signMsg(params))
@@ -190,6 +190,12 @@ ConfirmTxScreen.prototype.cancelMessage = function (msgData, event) {
this.props.dispatch(actions.cancelMsg(msgData))
}
+ConfirmTxScreen.prototype.cancelPersonalMessage = function (msgData, event) {
+ log.info('canceling personal message')
+ event.stopPropagation()
+ this.props.dispatch(actions.cancelPersonalMsg(msgData))
+}
+
ConfirmTxScreen.prototype.goHome = function (event) {
event.stopPropagation()
this.props.dispatch(actions.goHome())
diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js
index 6d92764f1..136326301 100644
--- a/ui/app/reducers/app.js
+++ b/ui/app/reducers/app.js
@@ -9,12 +9,13 @@ function reduceApp (state, action) {
log.debug('App Reducer got ' + action.type)
// clone and defaults
const selectedAddress = state.metamask.selectedAddress
- const pendingTxs = hasPendingTxs(state)
+ let pendingTxs = hasPendingTxs(state)
let name = 'accounts'
if (selectedAddress) {
name = 'accountDetail'
}
if (pendingTxs) {
+ log.debug('pending txs detected, defaulting to conf-tx view.')
name = 'confTx'
}
@@ -310,15 +311,16 @@ function reduceApp (state, action) {
})
case actions.COMPLETED_TX:
- log.debug('reducing COMPLETED_TX')
+ log.debug('reducing COMPLETED_TX for tx ' + action.value)
var { unapprovedTxs, unapprovedMsgs,
unapprovedPersonalMsgs, network } = state.metamask
var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network)
- .filter(tx => tx !== tx.id)
- log.debug(`actions - COMPLETED_TX with ${unconfTxList.length} txs`)
+ .filter(tx => tx.id !== action.value )
- if (unconfTxList && unconfTxList.length > 0) {
+ pendingTxs = unconfTxList.length > 0
+
+ if (pendingTxs) {
log.debug('reducer detected txs - rendering confTx view')
return extend(appState, {
transForward: false,
@@ -583,8 +585,7 @@ function hasPendingTxs (state) {
var unconfTxList = txHelper(unapprovedTxs, unapprovedMsgs, unapprovedPersonalMsgs, network)
var has = unconfTxList.length > 0
- log.debug('checking if state has pending txs, concluded ' + has)
- return unconfTxList.length > 0
+ return has
}
function indexForPending (state, txId) {