aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/background.js')
-rw-r--r--app/scripts/background.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 83d0f575a..3c46f4693 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -7,7 +7,8 @@ const EthStore = require('eth-store')
const PortStream = require('./lib/port-stream.js')
const MetaMaskProvider = require('web3-provider-engine/zero.js')
const IdentityStore = require('./lib/idStore')
-const createTxNotification = require('./lib/tx-notification.js')
+const createTxNotification = require('./lib/notifications.js').createTxNotification
+const createMsgNotification = require('./lib/notifications.js').createMsgNotification
const configManager = require('./lib/config-manager-singleton')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
const HostStore = require('./lib/remote-store.js').HostStore
@@ -55,13 +56,18 @@ var idStore = new IdentityStore()
var providerOpts = {
rpcUrl: configManager.getCurrentRpcAddress(),
+ // account mgmt
getAccounts: function(cb){
var selectedAddress = idStore.getSelectedAddress()
var result = selectedAddress ? [selectedAddress] : []
cb(null, result)
},
+ // tx signing
approveTransaction: addUnconfirmedTx,
signTransaction: idStore.signTransaction.bind(idStore),
+ // msg signing
+ approveMessage: addUnconfirmedMsg,
+ signMessage: idStore.signMessage.bind(idStore),
}
var provider = MetaMaskProvider(providerOpts)
var web3 = new Web3(provider)
@@ -209,7 +215,7 @@ function updateBadge(state){
}
//
-// Add unconfirmed Tx
+// Add unconfirmed Tx + Msg
//
function addUnconfirmedTx(txParams, cb){
@@ -222,6 +228,16 @@ function addUnconfirmedTx(txParams, cb){
})
}
+function addUnconfirmedMsg(msgParams, cb){
+ var msgId = idStore.addUnconfirmedMessage(msgParams, cb)
+ createMsgNotification({
+ title: 'New Unsigned Message',
+ msgParams: msgParams,
+ confirm: idStore.approveMessage.bind(idStore, msgId, noop),
+ cancel: idStore.cancelMessage.bind(idStore, msgId),
+ })
+}
+
//
// config
//