diff options
author | Kevin Serrano <kevgagser@gmail.com> | 2017-05-06 02:55:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-06 02:55:41 +0800 |
commit | 1c44dd3353c51b6135c06188e8cd57690e0d30fc (patch) | |
tree | 72378e5cb682e456fbeb8b36fa6efd1e81eaecc9 | |
parent | f01891fc019b748151365cf7b04cbc26c94f3d06 (diff) | |
parent | fb08c4a1316248485710a277d397fb5d4f395231 (diff) | |
download | tangerine-wallet-browser-1c44dd3353c51b6135c06188e8cd57690e0d30fc.tar tangerine-wallet-browser-1c44dd3353c51b6135c06188e8cd57690e0d30fc.tar.gz tangerine-wallet-browser-1c44dd3353c51b6135c06188e8cd57690e0d30fc.tar.bz2 tangerine-wallet-browser-1c44dd3353c51b6135c06188e8cd57690e0d30fc.tar.lz tangerine-wallet-browser-1c44dd3353c51b6135c06188e8cd57690e0d30fc.tar.xz tangerine-wallet-browser-1c44dd3353c51b6135c06188e8cd57690e0d30fc.tar.zst tangerine-wallet-browser-1c44dd3353c51b6135c06188e8cd57690e0d30fc.zip |
Merge pull request #1378 from MetaMask/accounts-when-locked
metamask - selected accounts - dont reveal when locked
-rw-r--r-- | app/scripts/metamask-controller.js | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 2e4bf07e1..175602ec1 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -4,7 +4,6 @@ const promiseToCallback = require('promise-to-callback') const pipe = require('pump') const Dnode = require('dnode') const ObservableStore = require('obs-store') -const storeTransform = require('obs-store/lib/transform') const EthStore = require('./lib/eth-store') const EthQuery = require('eth-query') const streamIntoProvider = require('web3-stream-provider/handler') @@ -169,8 +168,13 @@ module.exports = class MetamaskController extends EventEmitter { rpcUrl: this.configManager.getCurrentRpcAddress(), // account mgmt getAccounts: (cb) => { + const isUnlocked = this.keyringController.memStore.getState().isUnlocked + const result = [] const selectedAddress = this.preferencesController.getSelectedAddress() - const result = selectedAddress ? [selectedAddress] : [] + // only show address if account is unlocked + if (isUnlocked && selectedAddress) { + result.push(selectedAddress) + } cb(null, result) }, // tx signing @@ -188,19 +192,17 @@ module.exports = class MetamaskController extends EventEmitter { // get init state const publicConfigStore = new ObservableStore() - // sync publicConfigStore with transform - pipe( - this.store, - storeTransform(selectPublicState.bind(this)), - publicConfigStore - ) + // memStore -> transform -> publicConfigStore + this.on('update', (memState) => { + const publicState = selectPublicState(memState) + publicConfigStore.putState(publicState) + }) - function selectPublicState (state) { - const result = { selectedAddress: undefined } - try { - result.selectedAddress = state.PreferencesController.selectedAddress - result.networkVersion = this.getNetworkState() - } catch (_) {} + function selectPublicState (memState) { + const result = { + selectedAddress: memState.isUnlocked ? memState.selectedAddress : undefined, + networkVersion: memState.network, + } return result } |