aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/lib/inpage-provider.js
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-08-12 04:23:49 +0800
committerkumavis <aaron@kumavis.me>2016-08-12 04:23:49 +0800
commit3417c421c8c5a73d363a724613145807bdbee354 (patch)
treeacc5887987dc4f101d8029599bd641d7d7b9702f /app/scripts/lib/inpage-provider.js
parentc48b60d7a6f14d2d2348be8d9a63965ca1267433 (diff)
downloadtangerine-wallet-browser-3417c421c8c5a73d363a724613145807bdbee354.tar
tangerine-wallet-browser-3417c421c8c5a73d363a724613145807bdbee354.tar.gz
tangerine-wallet-browser-3417c421c8c5a73d363a724613145807bdbee354.tar.bz2
tangerine-wallet-browser-3417c421c8c5a73d363a724613145807bdbee354.tar.lz
tangerine-wallet-browser-3417c421c8c5a73d363a724613145807bdbee354.tar.xz
tangerine-wallet-browser-3417c421c8c5a73d363a724613145807bdbee354.tar.zst
tangerine-wallet-browser-3417c421c8c5a73d363a724613145807bdbee354.zip
inpage-provider - remove createSyncProvider, just fail
Diffstat (limited to 'app/scripts/lib/inpage-provider.js')
-rw-r--r--app/scripts/lib/inpage-provider.js43
1 files changed, 3 insertions, 40 deletions
diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js
index e387be895..5e8b240bc 100644
--- a/app/scripts/lib/inpage-provider.js
+++ b/app/scripts/lib/inpage-provider.js
@@ -1,9 +1,7 @@
-const HttpProvider = require('web3/lib/web3/httpprovider')
const Streams = require('mississippi')
const ObjectMultiplex = require('./obj-multiplex')
const StreamProvider = require('web3-stream-provider')
const RemoteStore = require('./remote-store.js').RemoteStore
-const MetamaskConfig = require('../config.js')
module.exports = MetamaskInpageProvider
@@ -27,13 +25,6 @@ function MetamaskInpageProvider (connectionStream) {
})
self.publicConfigStore = publicConfigStore
- // connect to sync provider
- self.syncProvider = createSyncProvider(publicConfigStore.get('provider'))
- // subscribe to publicConfig to update the syncProvider on change
- publicConfigStore.subscribe(function (state) {
- self.syncProvider = createSyncProvider(state.provider)
- })
-
// connect to async provider
var asyncProvider = new StreamProvider()
Streams.pipe(asyncProvider, multiStream.createStream('provider'), asyncProvider, function (err) {
@@ -65,9 +56,10 @@ MetamaskInpageProvider.prototype.send = function (payload) {
result = selectedAddress || '0x0000000000000000000000000000000000000000'
break
- // fallback to normal rpc
+ // throw not-supported Error
default:
- return self.syncProvider.send(payload)
+ var message = 'The MetaMask Web3 object does not support synchronous methods. See https://github.com/MetaMask/faq#all-async---think-of-metamask-as-a-light-client for details.'
+ throw new Error(message)
}
@@ -89,35 +81,6 @@ MetamaskInpageProvider.prototype.isConnected = function () {
// util
-function createSyncProvider (providerConfig) {
- providerConfig = providerConfig || {}
- let syncProviderUrl
-
- if (providerConfig.rpcTarget) {
- syncProviderUrl = providerConfig.rpcTarget
- } else {
- switch (providerConfig.type) {
- case 'testnet':
- syncProviderUrl = MetamaskConfig.network.testnet
- break
- case 'mainnet':
- syncProviderUrl = MetamaskConfig.network.mainnet
- break
- default:
- syncProviderUrl = MetamaskConfig.network.default
- }
- }
-
- const provider = new HttpProvider(syncProviderUrl)
- // Stubbing out the send method to throw on sync methods:
- provider.send = function() {
- var message = 'The MetaMask Web3 object does not support synchronous methods. See https://github.com/MetaMask/faq#all-async---think-of-metamask-as-a-light-client for details.'
- throw new Error(message)
- }
-
- return provider
-}
-
function remoteStoreWithLocalStorageCache (storageKey) {
// read local cache
var initState = JSON.parse(localStorage[storageKey] || '{}')