aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Finlay <somniac@me.com>2016-07-21 05:54:07 +0800
committerGitHub <noreply@github.com>2016-07-21 05:54:07 +0800
commitcdd7e40545af8e62fc586f8da120e8d05ca90653 (patch)
tree410279980ea926c3bd15a06c1cd6ddc7c4ab40e9
parent5567ea8dc5f387d971b51bd4cf46abd6e7979688 (diff)
downloadtangerine-wallet-browser-cdd7e40545af8e62fc586f8da120e8d05ca90653.tar
tangerine-wallet-browser-cdd7e40545af8e62fc586f8da120e8d05ca90653.tar.gz
tangerine-wallet-browser-cdd7e40545af8e62fc586f8da120e8d05ca90653.tar.bz2
tangerine-wallet-browser-cdd7e40545af8e62fc586f8da120e8d05ca90653.tar.lz
tangerine-wallet-browser-cdd7e40545af8e62fc586f8da120e8d05ca90653.tar.xz
tangerine-wallet-browser-cdd7e40545af8e62fc586f8da120e8d05ca90653.tar.zst
tangerine-wallet-browser-cdd7e40545af8e62fc586f8da120e8d05ca90653.zip
Make injected web3 fail hard on sync methods (#471)
Make injected web3 fail hard on sync methods
-rw-r--r--CHANGELOG.md2
-rw-r--r--app/scripts/lib/inpage-provider.js10
2 files changed, 11 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c06da79e5..d1939570c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,8 @@
## Current Master
+- MetaMask now throws descriptive errors when apps try to use synchronous web3 methods.
+
## 2.6.2 2016-07-20
- Fixed bug that would prevent the plugin from reopening on the first try after receiving a new transaction while locked.
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) {