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.js21
1 files changed, 6 insertions, 15 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 14293ab05..772c1de89 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -6,7 +6,7 @@ const combineStreams = require('pumpify')
const extend = require('xtend')
const EthStore = require('eth-store')
const PortStream = require('./lib/port-stream.js')
-const MetaMaskProvider = require('./lib/zero.js')
+const MetaMaskProvider = require('web3-provider-engine/zero.js')
const IdentityStore = require('./lib/idStore')
const createTxNotification = require('./lib/tx-notification.js')
const configManager = require('./lib/config-manager-singleton')
@@ -36,9 +36,8 @@ function handleEthRpcRequestStream(stream){
// state and network
//
-var providerConfig = configManager.getProvider()
var idStore = new IdentityStore()
-var providerOpts = {
+var zeroClient = MetaMaskProvider({
rpcUrl: configManager.getCurrentRpcAddress(),
getAccounts: function(cb){
var selectedAddress = idStore.getSelectedAddress()
@@ -47,16 +46,14 @@ var providerOpts = {
},
approveTransaction: addUnconfirmedTx,
signTransaction: idStore.signTransaction.bind(idStore),
- etherscan: providerConfig.type === 'etherscan',
-}
-var provider = MetaMaskProvider(providerOpts)
+})
// log new blocks
-provider.on('block', function(block){
+zeroClient.on('block', function(block){
console.log('BLOCK CHANGED:', '#'+block.number.toString('hex'), '0x'+block.hash.toString('hex'))
})
-var ethStore = new EthStore(provider)
+var ethStore = new EthStore(zeroClient)
idStore.setStore(ethStore)
function getState(){
@@ -71,7 +68,7 @@ function getState(){
// handle rpc requests
function onRpcRequest(remoteStream, payload){
// console.log('MetaMaskPlugin - incoming payload:', payload)
- provider.sendAsync(payload, function onPayloadHandled(err, response){
+ zeroClient.sendAsync(payload, function onPayloadHandled(err, response){
// provider engine errors are included in response objects
if (!payload.isMetamaskInternal) console.log('MetaMaskPlugin - RPC complete:', payload, '->', response)
try {
@@ -114,7 +111,6 @@ function linkDnode(stream){
var connection = Dnode({
getState: function(cb){ cb(null, getState()) },
setRpcTarget: setRpcTarget,
- useEtherscanProvider: useEtherscanProvider,
// forward directly to idStore
createNewVault: idStore.createNewVault.bind(idStore),
recoverFromSeed: idStore.recoverFromSeed.bind(idStore),
@@ -183,11 +179,6 @@ function setRpcTarget(rpcTarget){
chrome.runtime.reload()
}
-function useEtherscanProvider() {
- configManager.useEtherscanProvider()
- chrome.runtime.reload()
-}
-
// util
function jsonParseStream(){