aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/inpage.js
diff options
context:
space:
mode:
authorbitpshr <mail@bitpshr.net>2018-10-30 05:28:59 +0800
committerDan Finlay <542863+danfinlay@users.noreply.github.com>2018-11-06 07:07:09 +0800
commitd7618bd5c6cffe02d8737fe6925a31484a1fc0b0 (patch)
treecc99f09a1a3b56f59ddb78a079542248293076db /app/scripts/inpage.js
parentba40fcbcb43c5adcb3a961afd4050cdb2025b7a6 (diff)
downloadtangerine-wallet-browser-d7618bd5c6cffe02d8737fe6925a31484a1fc0b0.tar
tangerine-wallet-browser-d7618bd5c6cffe02d8737fe6925a31484a1fc0b0.tar.gz
tangerine-wallet-browser-d7618bd5c6cffe02d8737fe6925a31484a1fc0b0.tar.bz2
tangerine-wallet-browser-d7618bd5c6cffe02d8737fe6925a31484a1fc0b0.tar.lz
tangerine-wallet-browser-d7618bd5c6cffe02d8737fe6925a31484a1fc0b0.tar.xz
tangerine-wallet-browser-d7618bd5c6cffe02d8737fe6925a31484a1fc0b0.tar.zst
tangerine-wallet-browser-d7618bd5c6cffe02d8737fe6925a31484a1fc0b0.zip
Code bath
Diffstat (limited to 'app/scripts/inpage.js')
-rw-r--r--app/scripts/inpage.js16
1 files changed, 10 insertions, 6 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index 49a18c5e9..a5e0118d4 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -6,14 +6,18 @@ const LocalMessageDuplexStream = require('post-message-stream')
const setupDappAutoReload = require('./lib/auto-reload.js')
const MetamaskInpageProvider = require('metamask-inpage-provider')
+let isEnabled = false
+let warned = false
+
restoreContextAfterImports()
log.setDefaultLevel(process.env.METAMASK_DEBUG ? 'debug' : 'warn')
console.warn('ATTENTION: In an effort to improve user privacy, MetaMask ' +
-'stopped exposing user accounts to dapps by default beginning November 2nd, 2018. ' +
-'Dapps should call provider.enable() in order to view and use accounts. Please see ' +
-'https://bit.ly/2QQHXvF for complete information and up-to-date example code.')
+'stopped exposing user accounts to dapps if "privacy mode" is enabled on ' +
+'November 2nd, 2018. Dapps should now call provider.enable() in order to view and use ' +
+'accounts. Please see https://bit.ly/2QQHXvF for complete information and up-to-date ' +
+'example code.')
//
// setup plugin communication
@@ -30,9 +34,8 @@ var inpageProvider = new MetamaskInpageProvider(metamaskStream)
// set a high max listener count to avoid unnecesary warnings
inpageProvider.setMaxListeners(100)
-var isEnabled = false
-var warned = false
+// set up a listener for when MetaMask is locked
window.addEventListener('metamasksetlocked', () => {
isEnabled = false
})
@@ -44,6 +47,7 @@ inpageProvider.enable = function () {
if (typeof detail.error !== 'undefined') {
reject(detail.error)
} else {
+ // wait for the publicConfig store to populate with an account
const publicConfig = new Promise((resolve) => {
const { selectedAddress } = inpageProvider.publicConfigStore.getState()
if (selectedAddress) {
@@ -55,6 +59,7 @@ inpageProvider.enable = function () {
}
})
+ // wait for the background to update with an accoount
const ethAccounts = new Promise((resolveAccounts, rejectAccounts) => {
inpageProvider.sendAsync({ method: 'eth_accounts', params: [] }, (error, response) => {
if (error) {
@@ -143,7 +148,6 @@ const proxiedInpageProvider = new Proxy(inpageProvider, {
window.ethereum = proxiedInpageProvider
-
//
// setup web3
//