aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2016-04-15 02:31:15 +0800
committerkumavis <aaron@kumavis.me>2016-04-15 02:31:15 +0800
commit38582f6aae949fdbfd48d28e496fc3f217f9c585 (patch)
tree33f7722e09ae98e8fbc71f321727ad9648f673dd
parent2c47fb14e08fb4385148135892c9b2d429bc76fe (diff)
downloadtangerine-wallet-browser-38582f6aae949fdbfd48d28e496fc3f217f9c585.tar
tangerine-wallet-browser-38582f6aae949fdbfd48d28e496fc3f217f9c585.tar.gz
tangerine-wallet-browser-38582f6aae949fdbfd48d28e496fc3f217f9c585.tar.bz2
tangerine-wallet-browser-38582f6aae949fdbfd48d28e496fc3f217f9c585.tar.lz
tangerine-wallet-browser-38582f6aae949fdbfd48d28e496fc3f217f9c585.tar.xz
tangerine-wallet-browser-38582f6aae949fdbfd48d28e496fc3f217f9c585.tar.zst
tangerine-wallet-browser-38582f6aae949fdbfd48d28e496fc3f217f9c585.zip
web3 - set defaultAccount
-rw-r--r--app/scripts/inpage.js7
1 files changed, 4 insertions, 3 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js
index e15c08671..121246d6a 100644
--- a/app/scripts/inpage.js
+++ b/app/scripts/inpage.js
@@ -32,7 +32,9 @@ remoteProvider.on('error', console.error.bind(console))
//
// handle accounts cache
-var accountsCache = []
+var accountsCache = JSON.parse(localStorage['MetaMask-Accounts'] || '[]')
+web3.eth.defaultAccount = accounts[0]
+
setInterval(populateAccountsCache, 4000)
function populateAccountsCache(){
remoteProvider.sendAsync(createPayload({
@@ -44,6 +46,7 @@ function populateAccountsCache(){
// update localStorage
var accounts = response.result
if (accounts.toString() !== accountsCache.toString()) {
+ web3.eth.defaultAccount = accounts[0]
accountsCache = accounts
localStorage['MetaMask-Accounts'] = JSON.stringify(accounts)
}
@@ -58,13 +61,11 @@ remoteProvider.send = function(payload){
case 'eth_accounts':
// read from localStorage
- accountsCache = JSON.parse(localStorage['MetaMask-Accounts'] || '[]')
result = accountsCache
break
case 'eth_coinbase':
// read from localStorage
- accountsCache = JSON.parse(localStorage['MetaMask-Accounts'] || '[]')
result = accountsCache[0] || '0x0000000000000000000000000000000000000000'
break