aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-04-15 12:11:35 +0800
committerkumavis <aaron@kumavis.me>2016-04-15 12:11:35 +0800
commit1e989fb8a48e61a8dfb9cb3d1f82f46925b1239b (patch)
treedc742fbec95c9de25a9f23cecd9c39a603491d43 /app
parent2f8a5d1c3a1f472aecfaac959f07c7f013512d39 (diff)
downloadtangerine-wallet-browser-1e989fb8a48e61a8dfb9cb3d1f82f46925b1239b.tar
tangerine-wallet-browser-1e989fb8a48e61a8dfb9cb3d1f82f46925b1239b.tar.gz
tangerine-wallet-browser-1e989fb8a48e61a8dfb9cb3d1f82f46925b1239b.tar.bz2
tangerine-wallet-browser-1e989fb8a48e61a8dfb9cb3d1f82f46925b1239b.tar.lz
tangerine-wallet-browser-1e989fb8a48e61a8dfb9cb3d1f82f46925b1239b.tar.xz
tangerine-wallet-browser-1e989fb8a48e61a8dfb9cb3d1f82f46925b1239b.tar.zst
tangerine-wallet-browser-1e989fb8a48e61a8dfb9cb3d1f82f46925b1239b.zip
inpage - defaultAccount - fix bug
Diffstat (limited to 'app')
-rw-r--r--app/scripts/inpage.js25
1 files changed, 13 insertions, 12 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index 121246d6a..01f35d0fe 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -26,6 +26,17 @@ remoteProvider.pipe(pluginStream).pipe(remoteProvider)
pluginStream.on('error', console.error.bind(console))
remoteProvider.on('error', console.error.bind(console))
+//
+// global web3
+//
+
+var web3 = new Web3(remoteProvider)
+window.web3 = web3
+web3.setProvider = function(){
+ console.log('MetaMask - overrode web3.setProvider')
+}
+console.log('MetaMask - injected web3')
+
//
// handle synchronous requests
@@ -33,7 +44,7 @@ remoteProvider.on('error', console.error.bind(console))
// handle accounts cache
var accountsCache = JSON.parse(localStorage['MetaMask-Accounts'] || '[]')
-web3.eth.defaultAccount = accounts[0]
+web3.eth.defaultAccount = accountsCache[0]
setInterval(populateAccountsCache, 4000)
function populateAccountsCache(){
@@ -46,8 +57,8 @@ function populateAccountsCache(){
// update localStorage
var accounts = response.result
if (accounts.toString() !== accountsCache.toString()) {
- web3.eth.defaultAccount = accounts[0]
accountsCache = accounts
+ web3.eth.defaultAccount = accountsCache[0]
localStorage['MetaMask-Accounts'] = JSON.stringify(accounts)
}
})
@@ -83,13 +94,3 @@ remoteProvider.send = function(payload){
}
}
-//
-// global web3
-//
-
-var web3 = new Web3(remoteProvider)
-window.web3 = web3
-web3.setProvider = function(){
- console.log('MetaMask - overrode web3.setProvider')
-}
-console.log('MetaMask - injected web3')