aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-05-05 08:50:59 +0800
committerkumavis <aaron@kumavis.me>2017-05-05 08:50:59 +0800
commit10ba760ed32be6e23186bd9f9a025e28bd757042 (patch)
treee118728072ab766e38765cee4e338603fd3f1c86 /app/scripts
parenta72f50509010a12bf4fb879f2c638a38d2a210d2 (diff)
downloadtangerine-wallet-browser-10ba760ed32be6e23186bd9f9a025e28bd757042.tar
tangerine-wallet-browser-10ba760ed32be6e23186bd9f9a025e28bd757042.tar.gz
tangerine-wallet-browser-10ba760ed32be6e23186bd9f9a025e28bd757042.tar.bz2
tangerine-wallet-browser-10ba760ed32be6e23186bd9f9a025e28bd757042.tar.lz
tangerine-wallet-browser-10ba760ed32be6e23186bd9f9a025e28bd757042.tar.xz
tangerine-wallet-browser-10ba760ed32be6e23186bd9f9a025e28bd757042.tar.zst
tangerine-wallet-browser-10ba760ed32be6e23186bd9f9a025e28bd757042.zip
metamask - selected accounts - dont reveal when locked
Diffstat (limited to 'app/scripts')
-rw-r--r--app/scripts/metamask-controller.js32
1 files changed, 17 insertions, 15 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 2e4bf07e1..497b661d4 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
@@ -186,21 +190,19 @@ module.exports = class MetamaskController extends EventEmitter {
initPublicConfigStore () {
// get init state
- const publicConfigStore = new ObservableStore()
+ const publicConfigStore = new ObservableStore(this.store.getState())
- // 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
}