From 1cbab788ec21ba096d4375015c6cd3cd481de5b2 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Mon, 21 Nov 2016 16:46:26 -0800 Subject: [PATCH] Change fauceting to become a response of an emit. --- app/scripts/keyring-controller.js | 3 +-- app/scripts/metamask-controller.js | 6 ++++++ ui/app/actions.js | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index b29150267..31d144ca9 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -9,7 +9,6 @@ const EventEmitter = require('events').EventEmitter const normalize = require('./lib/sig-util').normalize const encryptor = require('./lib/encryptor') const messageManager = require('./lib/message-manager') -const autoFaucet = require('./lib/auto-faucet') const IdStoreMigrator = require('./lib/idStore-migrator') const BN = ethUtil.BN @@ -160,7 +159,7 @@ module.exports = class KeyringController extends EventEmitter { this.configManager.setSelectedAccount(firstAccount) this.placeSeedWords() - autoFaucet(hexAccount) + this.emit('newAccount', hexAccount) this.setupAccounts(accounts) this.persistAllKeyrings() .then(() => { diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index d230b3483..8ff7ab5b2 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -7,6 +7,8 @@ const HostStore = require('./lib/remote-store.js').HostStore const Web3 = require('web3') const ConfigManager = require('./lib/config-manager') const extension = require('./lib/extension') +const autoFaucet = require('./lib/auto-faucet') + module.exports = class MetamaskController { @@ -174,6 +176,10 @@ module.exports = class MetamaskController { this.sendUpdate() }) + this.keyringController.on('newAccount', (account) => { + autoFaucet(account) + }) + // keyringController substate function keyringControllerToPublic (state) { return { diff --git a/ui/app/actions.js b/ui/app/actions.js index b4bf2fdde..b61f9f464 100644 --- a/ui/app/actions.js +++ b/ui/app/actions.js @@ -261,7 +261,7 @@ function showInfoPage () { function setselectedAccount (address) { return (dispatch) => { - background.setselectedAccount(address) + background.setSelectedAccount(address) } } @@ -455,7 +455,7 @@ function lockMetamask () { function showAccountDetail (address) { return (dispatch) => { dispatch(actions.showLoadingIndication()) - background.setselectedAccount(address, (err, address) => { + background.setSelectedAccount(address, (err, address) => { dispatch(actions.hideLoadingIndication()) if (err) { return dispatch(actions.displayWarning(err.message))