1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Merge pull request #1378 from MetaMask/accounts-when-locked

metamask - selected accounts - dont reveal when locked
This commit is contained in:
Kevin Serrano 2017-05-05 11:55:41 -07:00 committed by GitHub
commit 1c44dd3353

View File

@ -4,7 +4,6 @@ const promiseToCallback = require('promise-to-callback')
const pipe = require('pump') const pipe = require('pump')
const Dnode = require('dnode') const Dnode = require('dnode')
const ObservableStore = require('obs-store') const ObservableStore = require('obs-store')
const storeTransform = require('obs-store/lib/transform')
const EthStore = require('./lib/eth-store') const EthStore = require('./lib/eth-store')
const EthQuery = require('eth-query') const EthQuery = require('eth-query')
const streamIntoProvider = require('web3-stream-provider/handler') const streamIntoProvider = require('web3-stream-provider/handler')
@ -169,8 +168,13 @@ module.exports = class MetamaskController extends EventEmitter {
rpcUrl: this.configManager.getCurrentRpcAddress(), rpcUrl: this.configManager.getCurrentRpcAddress(),
// account mgmt // account mgmt
getAccounts: (cb) => { getAccounts: (cb) => {
const isUnlocked = this.keyringController.memStore.getState().isUnlocked
const result = []
const selectedAddress = this.preferencesController.getSelectedAddress() 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) cb(null, result)
}, },
// tx signing // tx signing
@ -188,19 +192,17 @@ module.exports = class MetamaskController extends EventEmitter {
// get init state // get init state
const publicConfigStore = new ObservableStore() const publicConfigStore = new ObservableStore()
// sync publicConfigStore with transform // memStore -> transform -> publicConfigStore
pipe( this.on('update', (memState) => {
this.store, const publicState = selectPublicState(memState)
storeTransform(selectPublicState.bind(this)), publicConfigStore.putState(publicState)
publicConfigStore })
)
function selectPublicState (state) { function selectPublicState (memState) {
const result = { selectedAddress: undefined } const result = {
try { selectedAddress: memState.isUnlocked ? memState.selectedAddress : undefined,
result.selectedAddress = state.PreferencesController.selectedAddress networkVersion: memState.network,
result.networkVersion = this.getNetworkState() }
} catch (_) {}
return result return result
} }