aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/inpage.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2015-12-19 14:05:16 +0800
committerkumavis <aaron@kumavis.me>2015-12-19 14:05:16 +0800
commit72a747165dda417aa7968e44b404eb90707202a2 (patch)
tree0fd4c52727815665b8851ca80b2b8d9dc462b19a /app/scripts/inpage.js
parentcc935a1ebaa73d855056d143ef548ca982a5f8e8 (diff)
downloadtangerine-wallet-browser-72a747165dda417aa7968e44b404eb90707202a2.tar
tangerine-wallet-browser-72a747165dda417aa7968e44b404eb90707202a2.tar.gz
tangerine-wallet-browser-72a747165dda417aa7968e44b404eb90707202a2.tar.bz2
tangerine-wallet-browser-72a747165dda417aa7968e44b404eb90707202a2.tar.lz
tangerine-wallet-browser-72a747165dda417aa7968e44b404eb90707202a2.tar.xz
tangerine-wallet-browser-72a747165dda417aa7968e44b404eb90707202a2.tar.zst
tangerine-wallet-browser-72a747165dda417aa7968e44b404eb90707202a2.zip
migrate to ProviderEngine zero-client
Diffstat (limited to 'app/scripts/inpage.js')
-rw-r--r--app/scripts/inpage.js69
1 files changed, 14 insertions, 55 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index 5149bd37e..d45dde593 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -1,59 +1,18 @@
-const web3 = require('web3')
-const BlockAppsWeb3Provider = require('blockapps-web3')
-const Transaction = require('ethereumjs-tx')
-require('object.entries').shim()
+const Web3 = require('web3')
+const StreamProvider = require('./lib/stream-provider.js')
+const LocalMessageDuplexStream = require('./lib/local-message-stream.js')
-// const rpcUrl = 'https://rpc.metamask.io'
-// var provider = new MetamaskProvider(forwardPayload, rpcUrl)
-var provider = new BlockAppsWeb3Provider({
- host: 'http://hacknet.blockapps.net',
- // host: 'http://api.blockapps.net',
- transaction_signer: {
- // Can be any object that implements the following methods:
- hasAddress: function(address, callback) {
- console.log('metamask provider - asked for address ownership', address)
- callback(null, true)
- },
- signTransaction: function(txParams, callback) {
- txParams.gasLimit = txParams.gas
- var tx = new Transaction(txParams)
- tx.sign(new Buffer('0d0ba14043088cd629a978b49c8691deca5926f0271432bc0064e4745bac0a9f', 'hex'))
- callback(null, '0x'+tx.serialize().toString('hex'))
- },
- },
- coinbase: '0x00000000000',
- accounts: ['0x985095ef977ba75fb2bb79cd5c4b84c81392dff6'],
- // host: function(){ debugger },
-});
-
-const documentOrigin = window.location.origin
-const allowedMessageTarget = 'metamask'
-const allowedMessageType = 'addUnsignedTx'
-
-web3.setProvider(provider)
-// disable setProvider
-web3.setProvider = function(){}
-
-// injecting web3
-console.log('Metamask injected web3')
-
-
-// log all the stuff!
-// provider.verbosity = 1
-
-// web3.currentProvider.vm.onStep = function(data, cb){
-// console.log(data)
-// cb()
-// }
+// setup plugin communication
+var pluginStream = new LocalMessageDuplexStream({
+ name: 'inpage',
+ target: 'contentscript',
+})
+var remoteProvider = new StreamProvider()
+remoteProvider.pipe(pluginStream).pipe(remoteProvider)
+// create web3
+var web3 = new Web3(remoteProvider)
window.web3 = web3
-
-
-function forwardPayload(payload){
- window.postMessage({
- to: allowedMessageTarget,
- type: allowedMessageType,
- payload: payload,
- }, documentOrigin)
-} \ No newline at end of file
+web3.setProvider = function(){}
+console.log('Metamask injected web3') \ No newline at end of file