@ -3,9 +3,7 @@ const extend = require('xtend')
const Dnode = require ( 'dnode' )
const Dnode = require ( 'dnode' )
const eos = require ( 'end-of-stream' )
const eos = require ( 'end-of-stream' )
const PortStream = require ( './lib/port-stream.js' )
const PortStream = require ( './lib/port-stream.js' )
const createUnlockRequestNotification = require ( './lib/notifications.js' ) . createUnlockRequestNotification
const notification = require ( './lib/notifications.js' )
const createTxNotification = require ( './lib/notifications.js' ) . createTxNotification
const createMsgNotification = require ( './lib/notifications.js' ) . createMsgNotification
const messageManager = require ( './lib/message-manager' )
const messageManager = require ( './lib/message-manager' )
const setupMultiplex = require ( './lib/stream-utils.js' ) . setupMultiplex
const setupMultiplex = require ( './lib/stream-utils.js' ) . setupMultiplex
const MetamaskController = require ( './metamask-controller' )
const MetamaskController = require ( './metamask-controller' )
@ -26,41 +24,15 @@ const controller = new MetamaskController({
const idStore = controller . idStore
const idStore = controller . idStore
function unlockAccountMessage ( ) {
function unlockAccountMessage ( ) {
createUnlockRequestNotification ( {
notification . show ( )
title : 'Account Unlock Request' ,
} )
}
}
function showUnconfirmedMessage ( msgParams , msgId ) {
function showUnconfirmedMessage ( msgParams , msgId ) {
var controllerState = controller . getState ( )
notification . show ( )
createMsgNotification ( {
imageifyIdenticons : false ,
txData : {
msgParams : msgParams ,
time : ( new Date ( ) ) . getTime ( ) ,
} ,
identities : controllerState . identities ,
accounts : controllerState . accounts ,
onConfirm : idStore . approveMessage . bind ( idStore , msgId , noop ) ,
onCancel : idStore . cancelMessage . bind ( idStore , msgId ) ,
} )
}
}
function showUnconfirmedTx ( txParams , txData , onTxDoneCb ) {
function showUnconfirmedTx ( txParams , txData , onTxDoneCb ) {
var controllerState = controller . getState ( )
notification . show ( )
createTxNotification ( {
imageifyIdenticons : false ,
txData : {
txParams : txParams ,
time : ( new Date ( ) ) . getTime ( ) ,
} ,
identities : controllerState . identities ,
accounts : controllerState . accounts ,
onConfirm : idStore . approveTransaction . bind ( idStore , txData . id , noop ) ,
onCancel : idStore . cancelTransaction . bind ( idStore , txData . id ) ,
} )
}
}
//
//
@ -109,7 +81,7 @@ function setupControllerConnection (stream) {
dnode . on ( 'remote' , ( remote ) => {
dnode . on ( 'remote' , ( remote ) => {
// push updates to popup
// push updates to popup
controller . ethStore . on ( 'update' , controller . sendUpdate . bind ( controller ) )
controller . ethStore . on ( 'update' , controller . sendUpdate . bind ( controller ) )
controller . remote = remote
controller . listeners . push ( remote )
idStore . on ( 'update' , controller . sendUpdate . bind ( controller ) )
idStore . on ( 'update' , controller . sendUpdate . bind ( controller ) )
// teardown on disconnect
// teardown on disconnect