aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorDan Finlay <somniac@me.com>2016-05-25 06:00:48 +0800
committerDan Finlay <somniac@me.com>2016-05-25 06:00:48 +0800
commitb6a2d388f7bee3c53e64e1551beb843902508ea0 (patch)
tree839b637cb67e61a9377b325140dcd99dccaf7440 /app
parentdfce3d5c9de230b092908c5b76b84b8caf3a92f1 (diff)
parent1d23bf81227b86d66841db75c2efd8e5f64a68fe (diff)
downloadtangerine-wallet-browser-b6a2d388f7bee3c53e64e1551beb843902508ea0.tar
tangerine-wallet-browser-b6a2d388f7bee3c53e64e1551beb843902508ea0.tar.gz
tangerine-wallet-browser-b6a2d388f7bee3c53e64e1551beb843902508ea0.tar.bz2
tangerine-wallet-browser-b6a2d388f7bee3c53e64e1551beb843902508ea0.tar.lz
tangerine-wallet-browser-b6a2d388f7bee3c53e64e1551beb843902508ea0.tar.xz
tangerine-wallet-browser-b6a2d388f7bee3c53e64e1551beb843902508ea0.tar.zst
tangerine-wallet-browser-b6a2d388f7bee3c53e64e1551beb843902508ea0.zip
Merge pull request #207 from MetaMask/i168
signTx+Msg - show Account Unlock Request when locked
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js29
-rw-r--r--app/scripts/lib/notifications.js14
2 files changed, 41 insertions, 2 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 8c6adff04..313dbbc66 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -8,6 +8,7 @@ const handleRequestsFromStream = require('web3-stream-provider/handler')
const ObjectMultiplex = require('./lib/obj-multiplex')
const PortStream = require('./lib/port-stream.js')
const IdentityStore = require('./lib/idStore')
+const createUnlockRequestNotification = require('./lib/notifications.js').createUnlockRequestNotification
const createTxNotification = require('./lib/notifications.js').createTxNotification
const createMsgNotification = require('./lib/notifications.js').createMsgNotification
const configManager = require('./lib/config-manager-singleton')
@@ -65,10 +66,10 @@ var providerOpts = {
cb(null, result)
},
// tx signing
- approveTransaction: addUnconfirmedTx,
+ approveTransaction: approveTransaction,
signTransaction: idStore.signTransaction.bind(idStore),
// msg signing
- approveMessage: addUnconfirmedMsg,
+ approveMessage: approveMessage,
signMessage: idStore.signMessage.bind(idStore),
}
var provider = MetaMaskProvider(providerOpts)
@@ -217,6 +218,30 @@ function updateBadge(state){
// Add unconfirmed Tx + Msg
//
+function approveTransaction(txParams, cb){
+ var state = idStore.getState()
+ if (!state.isUnlocked) {
+ createUnlockRequestNotification({
+ title: 'Account Unlock Request',
+ })
+ var txId = idStore.addUnconfirmedTransaction(txParams, cb)
+ } else {
+ addUnconfirmedTx(txParams, cb)
+ }
+}
+
+function approveMessage(msgParams, cb){
+ var state = idStore.getState()
+ if (!state.isUnlocked) {
+ createUnlockRequestNotification({
+ title: 'Account Unlock Request',
+ })
+ var msgId = idStore.addUnconfirmedMessage(msgParams, cb)
+ } else {
+ addUnconfirmedMsg(msgParams, cb)
+ }
+}
+
function addUnconfirmedTx(txParams, cb){
var txId = idStore.addUnconfirmedTransaction(txParams, cb)
createTxNotification({
diff --git a/app/scripts/lib/notifications.js b/app/scripts/lib/notifications.js
index 2b7cbfe66..0b55417b2 100644
--- a/app/scripts/lib/notifications.js
+++ b/app/scripts/lib/notifications.js
@@ -3,6 +3,7 @@ const uiUtils = require('../../../ui/app/util')
var notificationHandlers = {}
module.exports = {
+ createUnlockRequestNotification: createUnlockRequestNotification,
createTxNotification: createTxNotification,
createMsgNotification: createMsgNotification,
}
@@ -24,6 +25,19 @@ chrome.notifications.onClosed.addListener(function(notificationId){
})
// creation helper
+function createUnlockRequestNotification(opts){
+ var message = 'An Ethereum app has requested a signature. Please unlock your account.'
+
+ var id = createId()
+ chrome.notifications.create(id, {
+ type: 'basic',
+ iconUrl: '/images/icon-128.png',
+ title: opts.title,
+ message: message,
+ })
+
+}
+
function createTxNotification(opts){
var message = [
'to: '+uiUtils.addressSummary(opts.txParams.to),