From cdd7e40545af8e62fc586f8da120e8d05ca90653 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Wed, 20 Jul 2016 14:54:07 -0700 Subject: Make injected web3 fail hard on sync methods (#471) Make injected web3 fail hard on sync methods --- app/scripts/lib/inpage-provider.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js index 3b6ec154f..e387be895 100644 --- a/app/scripts/lib/inpage-provider.js +++ b/app/scripts/lib/inpage-provider.js @@ -107,7 +107,15 @@ function createSyncProvider (providerConfig) { syncProviderUrl = MetamaskConfig.network.default } } - return new HttpProvider(syncProviderUrl) + + 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) { -- cgit v1.2.3