diff options
Diffstat (limited to 'app/scripts')
-rw-r--r-- | app/scripts/keyring-controller.js | 1 | ||||
-rw-r--r-- | app/scripts/lib/auto-faucet.js | 16 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 2 |
3 files changed, 14 insertions, 5 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index 72f613641..16df6efa6 100644 --- a/app/scripts/keyring-controller.js +++ b/app/scripts/keyring-controller.js @@ -324,6 +324,7 @@ class KeyringController extends EventEmitter { if (!firstAccount) throw new Error('KeyringController - No account found on keychain.') const hexAccount = normalizeAddress(firstAccount) this.emit('newAccount', hexAccount) + this.emit('newVault', hexAccount) return this.setupAccounts(accounts) }) .then(this.persistAllKeyrings.bind(this)) diff --git a/app/scripts/lib/auto-faucet.js b/app/scripts/lib/auto-faucet.js index 1e86f735e..73b73dfe6 100644 --- a/app/scripts/lib/auto-faucet.js +++ b/app/scripts/lib/auto-faucet.js @@ -4,9 +4,15 @@ const env = process.env.METAMASK_ENV module.exports = function (address) { if (METAMASK_DEBUG || env === 'test') return // Don't faucet in development or test - var http = new XMLHttpRequest() - var data = address - http.open('POST', uri, true) - http.setRequestHeader('Content-type', 'application/rawdata') - http.send(data) + let data = address + let headers = new Headers() + headers.append('Content-type', 'application/rawdata') + fetch(uri, { + method: 'POST', + headers, + body: data, + }) + .catch((err) => { + console.error(err) + }) } diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 040c093df..edb9bbbd9 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -79,6 +79,8 @@ module.exports = class MetamaskController extends EventEmitter { }) this.keyringController.on('newAccount', (address) => { this.preferencesController.setSelectedAddress(address) + }) + this.keyringController.on('newVault', (address) => { autoFaucet(address) }) |