aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-03-03 08:58:47 +0800
committerkumavis <aaron@kumavis.me>2016-03-03 15:08:28 +0800
commit92987b44079fe143cba3972e8267ce048267b54e (patch)
tree6f79f35c13779ea38a9b36726695b78896e2ab77 /app
parentffdf9135d2f845d29e4bc4cf4140da798cf190be (diff)
downloadtangerine-wallet-browser-92987b44079fe143cba3972e8267ce048267b54e.tar
tangerine-wallet-browser-92987b44079fe143cba3972e8267ce048267b54e.tar.gz
tangerine-wallet-browser-92987b44079fe143cba3972e8267ce048267b54e.tar.bz2
tangerine-wallet-browser-92987b44079fe143cba3972e8267ce048267b54e.tar.lz
tangerine-wallet-browser-92987b44079fe143cba3972e8267ce048267b54e.tar.xz
tangerine-wallet-browser-92987b44079fe143cba3972e8267ce048267b54e.tar.zst
tangerine-wallet-browser-92987b44079fe143cba3972e8267ce048267b54e.zip
background - use provider-engine zero client
Diffstat (limited to 'app')
-rw-r--r--app/scripts/background.js10
-rw-r--r--app/scripts/lib/metamask-provider.js61
2 files changed, 8 insertions, 63 deletions
diff --git a/app/scripts/background.js b/app/scripts/background.js
index 8572d53a3..17238f227 100644
--- a/app/scripts/background.js
+++ b/app/scripts/background.js
@@ -3,7 +3,7 @@ const eos = require('end-of-stream')
const extend = require('xtend')
const EthStore = require('eth-store')
const PortStream = require('./lib/port-stream.js')
-const MetaMaskProvider = require('./lib/metamask-provider')
+const MetaMaskProvider = require('web3-provider-engine/zero.js')
const IdentityStore = require('./lib/idStore')
console.log('ready to roll')
@@ -40,9 +40,15 @@ var zeroClient = MetaMaskProvider({
var result = selectedAddress ? [selectedAddress] : []
cb(null, result)
},
- approveTx: idStore.addUnconfirmedTransaction.bind(idStore),
+ approveTransaction: idStore.addUnconfirmedTransaction.bind(idStore),
signTransaction: idStore.signTransaction.bind(idStore),
})
+
+// log new blocks
+zeroClient.on('block', function(block){
+ console.log('BLOCK CHANGED:', '#'+block.number.toString('hex'), '0x'+block.hash.toString('hex'))
+})
+
var ethStore = new EthStore(zeroClient)
idStore.setStore(ethStore)
diff --git a/app/scripts/lib/metamask-provider.js b/app/scripts/lib/metamask-provider.js
deleted file mode 100644
index 589ea0fad..000000000
--- a/app/scripts/lib/metamask-provider.js
+++ /dev/null
@@ -1,61 +0,0 @@
-const ProviderEngine = require('web3-provider-engine')
-const NonceTrackerSubprovider = require('web3-provider-engine/subproviders/nonce-tracker.js')
-const CacheSubprovider = require('web3-provider-engine/subproviders/cache.js')
-const FixtureSubprovider = require('web3-provider-engine/subproviders/fixture.js')
-const FilterSubprovider = require('web3-provider-engine/subproviders/filters.js')
-const VmSubprovider = require('web3-provider-engine/subproviders/vm.js')
-const HookedWalletSubprovider = require('web3-provider-engine/subproviders/hooked-wallet.js')
-const RpcSubprovider = require('web3-provider-engine/subproviders/rpc.js')
-
-module.exports = metamaskProvider
-
-function metamaskProvider(opts){
-
- var engine = new ProviderEngine()
-
- // nonce tracker
- engine.addProvider(new NonceTrackerSubprovider())
-
- // cache layer
- engine.addProvider(new CacheSubprovider())
-
- // static results
- engine.addProvider(new FixtureSubprovider({
- web3_clientVersion: 'MetaMask-ProviderEngine/v0.0.0/javascript',
- net_listening: true,
- eth_hashrate: '0x0',
- eth_mining: false,
- eth_syncing: true,
- }))
-
- // filters
- engine.addProvider(new FilterSubprovider())
-
- // vm
- engine.addProvider(new VmSubprovider())
-
- // id mgmt
- engine.addProvider(new HookedWalletSubprovider({
- getAccounts: opts.getAccounts,
- approveTx: opts.approveTx,
- signTransaction: opts.signTransaction,
- }))
-
- // data source
- engine.addProvider(new RpcSubprovider({
- rpcUrl: opts.rpcUrl,
- }))
-
- // log new blocks
- engine.on('block', function(block){
- // console.log('================================')
- console.log('BLOCK CHANGED:', '#'+block.number.toString('hex'), '0x'+block.hash.toString('hex'))
- // console.log('================================')
- })
-
- // start polling for blocks
- engine.start()
-
- return engine
-
-} \ No newline at end of file