aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/background.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-04-29 05:16:24 +0800
committerkumavis <aaron@kumavis.me>2016-04-29 05:16:24 +0800
commit82983e5effb236474c7eba2ac2ba62ea3fe58f5f (patch)
tree5173113d4b2cc928d87e8673677bed4a40afbb9e /app/scripts/background.js
parent6cc7c08b75bed6ad95698b96cb788366a8334ecd (diff)
downloadtangerine-wallet-browser-82983e5effb236474c7eba2ac2ba62ea3fe58f5f.tar
tangerine-wallet-browser-82983e5effb236474c7eba2ac2ba62ea3fe58f5f.tar.gz
tangerine-wallet-browser-82983e5effb236474c7eba2ac2ba62ea3fe58f5f.tar.bz2
tangerine-wallet-browser-82983e5effb236474c7eba2ac2ba62ea3fe58f5f.tar.lz
tangerine-wallet-browser-82983e5effb236474c7eba2ac2ba62ea3fe58f5f.tar.xz
tangerine-wallet-browser-82983e5effb236474c7eba2ac2ba62ea3fe58f5f.tar.zst
tangerine-wallet-browser-82983e5effb236474c7eba2ac2ba62ea3fe58f5f.zip
idmgmt - eth_sign support + notifications
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
//