aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/metamask-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/scripts/metamask-controller.js')
-rw-r--r--app/scripts/metamask-controller.js18
1 files changed, 12 insertions, 6 deletions
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 951918460..701046e76 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 {
@@ -67,7 +69,7 @@ module.exports = class MetamaskController {
addNewKeyring: keyringController.addNewKeyring.bind(keyringController),
addNewAccount: keyringController.addNewAccount.bind(keyringController),
submitPassword: keyringController.submitPassword.bind(keyringController),
- setSelectedAddress: keyringController.setSelectedAddress.bind(keyringController),
+ setSelectedAccount: keyringController.setSelectedAccount.bind(keyringController),
approveTransaction: keyringController.approveTransaction.bind(keyringController),
cancelTransaction: keyringController.cancelTransaction.bind(keyringController),
signMessage: keyringController.signMessage.bind(keyringController),
@@ -125,8 +127,8 @@ module.exports = class MetamaskController {
rpcUrl: this.configManager.getCurrentRpcAddress(),
// account mgmt
getAccounts: (cb) => {
- var selectedAddress = this.configManager.getSelectedAccount()
- var result = selectedAddress ? [selectedAddress] : []
+ var selectedAccount = this.configManager.getSelectedAccount()
+ var result = selectedAccount ? [selectedAccount] : []
cb(null, result)
},
// tx signing
@@ -174,17 +176,21 @@ module.exports = class MetamaskController {
this.sendUpdate()
})
+ this.keyringController.on('newAccount', (account) => {
+ autoFaucet(account)
+ })
+
// keyringController substate
function keyringControllerToPublic (state) {
return {
- selectedAddress: state.selectedAddress,
+ selectedAccount: state.selectedAccount,
}
}
// config substate
function configToPublic (state) {
return {
provider: state.provider,
- selectedAddress: state.selectedAccount,
+ selectedAccount: state.selectedAccount,
}
}
// dump obj into store
@@ -341,7 +347,7 @@ module.exports = class MetamaskController {
var network = this.state.network
var url = `https://buy.coinbase.com/?code=9ec56d01-7e81-5017-930c-513daa27bb6a&amount=${amount}&address=${address}&crypto_currency=ETH`
- if (network === '2') {
+ if (network === '3') {
url = 'https://faucet.metamask.io/'
}