aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/inpage.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-04-16 03:12:04 +0800
committerkumavis <aaron@kumavis.me>2016-04-16 03:12:04 +0800
commitd840e81a101351bd661668cf0b1f9e5b73683890 (patch)
tree7c24e6afc902774d14f5594727173ed87d73ce17 /app/scripts/inpage.js
parent907e39e5abc301fa54e144c5c151b79c3affb788 (diff)
downloadtangerine-wallet-browser-d840e81a101351bd661668cf0b1f9e5b73683890.tar
tangerine-wallet-browser-d840e81a101351bd661668cf0b1f9e5b73683890.tar.gz
tangerine-wallet-browser-d840e81a101351bd661668cf0b1f9e5b73683890.tar.bz2
tangerine-wallet-browser-d840e81a101351bd661668cf0b1f9e5b73683890.tar.lz
tangerine-wallet-browser-d840e81a101351bd661668cf0b1f9e5b73683890.tar.xz
tangerine-wallet-browser-d840e81a101351bd661668cf0b1f9e5b73683890.tar.zst
tangerine-wallet-browser-d840e81a101351bd661668cf0b1f9e5b73683890.zip
wiring - trusted-untrusted features + remote-store
Diffstat (limited to 'app/scripts/inpage.js')
-rw-r--r--app/scripts/inpage.js30
1 files changed, 20 insertions, 10 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index 01f35d0fe..b59cf1b0c 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -1,13 +1,13 @@
-const XHR = window.XMLHttpRequest
-
-// bring in web3 but rename on window
-const Web3 = require('web3')
-delete window.Web3
-window.MetamaskWeb3 = Web3
-
const createPayload = require('web3-provider-engine/util/create-payload')
const StreamProvider = require('./lib/stream-provider.js')
const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
+const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
+const RemoteStore = require('./lib/remote-store.js').RemoteStore
+const Web3 = require('web3')
+
+// rename on window
+delete window.Web3
+window.MetamaskWeb3 = Web3
const RPC_URL = 'https://testrpc.metamask.io/'
@@ -16,16 +16,26 @@ const RPC_URL = 'https://testrpc.metamask.io/'
// setup plugin communication
//
+// setup background connection
var pluginStream = new LocalMessageDuplexStream({
name: 'inpage',
target: 'contentscript',
})
+var mx = setupMultiplex(pluginStream)
+// connect features
var remoteProvider = new StreamProvider()
-remoteProvider.pipe(pluginStream).pipe(remoteProvider)
-
-pluginStream.on('error', console.error.bind(console))
+remoteProvider.pipe(mx.createStream('provider')).pipe(remoteProvider)
remoteProvider.on('error', console.error.bind(console))
+var publicConfigStore = new RemoteStore()
+var storeStream = publicConfigStore.createStream()
+storeStream.pipe(mx.createStream('publicConfig')).pipe(storeStream)
+
+publicConfigStore.subscribe(function(state){
+ console.log('store updated:', state)
+})
+
+
//
// global web3
//