diff options
author | kumavis <kumavis@users.noreply.github.com> | 2016-11-23 04:23:55 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-23 04:23:55 +0800 |
commit | e61d792832381a66e7393d32e1bc2c359834f919 (patch) | |
tree | 8ecd86cae8bb50fe928ce591529ec02a8fba557d /app | |
parent | 1a8d95f5627aac6e122f7a1c905d2d23f5a0758d (diff) | |
parent | 8261cf232d5d7225f83747460cb7dbed52d5f8b8 (diff) | |
download | tangerine-wallet-browser-e61d792832381a66e7393d32e1bc2c359834f919.tar tangerine-wallet-browser-e61d792832381a66e7393d32e1bc2c359834f919.tar.gz tangerine-wallet-browser-e61d792832381a66e7393d32e1bc2c359834f919.tar.bz2 tangerine-wallet-browser-e61d792832381a66e7393d32e1bc2c359834f919.tar.lz tangerine-wallet-browser-e61d792832381a66e7393d32e1bc2c359834f919.tar.xz tangerine-wallet-browser-e61d792832381a66e7393d32e1bc2c359834f919.tar.zst tangerine-wallet-browser-e61d792832381a66e7393d32e1bc2c359834f919.zip |
Merge pull request #869 from MetaMask/dev-cleanup
Dev Cleanup Package
Diffstat (limited to 'app')
-rw-r--r-- | app/scripts/inpage.js | 2 | ||||
-rw-r--r-- | app/scripts/keyring-controller.js | 14 | ||||
-rw-r--r-- | app/scripts/lib/idStore.js | 8 | ||||
-rw-r--r-- | app/scripts/lib/inpage-provider.js | 10 | ||||
-rw-r--r-- | app/scripts/metamask-controller.js | 16 |
5 files changed, 27 insertions, 23 deletions
diff --git a/app/scripts/inpage.js b/app/scripts/inpage.js index 9d6fc96de..68c6165c8 100644 --- a/app/scripts/inpage.js +++ b/app/scripts/inpage.js @@ -50,7 +50,7 @@ endOfStream(pingStream, triggerReload) // set web3 defaultAcount inpageProvider.publicConfigStore.subscribe(function (state) { - web3.eth.defaultAccount = state.selectedAddress + web3.eth.defaultAccount = state.selectedAccount }) // diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js index fdef9d7b3..989103993 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 @@ -61,7 +60,6 @@ module.exports = class KeyringController extends EventEmitter { transactions: this.configManager.getTxList(), unconfMsgs: messageManager.unconfirmedMsgs(), messages: messageManager.getMsgList(), - selectedAddress: address, selectedAccount: address, shapeShiftTxList: this.configManager.getShapeShiftTxList(), currentFiat: this.configManager.getCurrentFiat(), @@ -76,8 +74,8 @@ module.exports = class KeyringController extends EventEmitter { this.ethStore = ethStore } - createNewVaultAndKeychain (password, entropy, cb) { - this.createNewVault(password, entropy, (err) => { + createNewVaultAndKeychain (password, cb) { + this.createNewVault(password, (err) => { if (err) return cb(err) this.createFirstKeyTree(password, cb) }) @@ -94,7 +92,7 @@ module.exports = class KeyringController extends EventEmitter { this.clearKeyrings() - this.createNewVault(password, '', (err) => { + this.createNewVault(password, (err) => { if (err) return cb(err) this.addNewKeyring('HD Key Tree', { mnemonic: seed, @@ -135,7 +133,7 @@ module.exports = class KeyringController extends EventEmitter { }) } - createNewVault (password, entropy, cb) { + createNewVault (password, cb) { const configManager = this.configManager const salt = this.encryptor.generateSalt() configManager.setSalt(salt) @@ -161,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(() => { @@ -329,7 +327,7 @@ module.exports = class KeyringController extends EventEmitter { }, []) } - setSelectedAddress (address, cb) { + setSelectedAccount (address, cb) { var addr = normalize(address) this.configManager.setSelectedAccount(addr) cb(null, addr) diff --git a/app/scripts/lib/idStore.js b/app/scripts/lib/idStore.js index b73652af5..e5861c0ca 100644 --- a/app/scripts/lib/idStore.js +++ b/app/scripts/lib/idStore.js @@ -44,7 +44,7 @@ function IdentityStore (opts = {}) { // public // -IdentityStore.prototype.createNewVault = function (password, entropy, cb) { +IdentityStore.prototype.createNewVault = function (password, cb) { delete this._keyStore var serializedKeystore = this.configManager.getWallet() @@ -53,7 +53,7 @@ IdentityStore.prototype.createNewVault = function (password, entropy, cb) { } this.purgeCache() - this._createVault(password, null, entropy, (err) => { + this._createVault(password, null, (err) => { if (err) return cb(err) this._autoFaucet() @@ -77,7 +77,7 @@ IdentityStore.prototype.recoverSeed = function (cb) { IdentityStore.prototype.recoverFromSeed = function (password, seed, cb) { this.purgeCache() - this._createVault(password, seed, null, (err) => { + this._createVault(password, seed, (err) => { if (err) return cb(err) this._loadIdentities() @@ -497,7 +497,7 @@ IdentityStore.prototype.tryPassword = function (password, cb) { }) } -IdentityStore.prototype._createVault = function (password, seedPhrase, entropy, cb) { +IdentityStore.prototype._createVault = function (password, seedPhrase, cb) { const opts = { password, hdPathString: this.hdPathString, diff --git a/app/scripts/lib/inpage-provider.js b/app/scripts/lib/inpage-provider.js index 034812b6a..7179ae978 100644 --- a/app/scripts/lib/inpage-provider.js +++ b/app/scripts/lib/inpage-provider.js @@ -66,20 +66,20 @@ function MetamaskInpageProvider (connectionStream) { MetamaskInpageProvider.prototype.send = function (payload) { const self = this - let selectedAddress + let selectedAccount let result = null switch (payload.method) { case 'eth_accounts': // read from localStorage - selectedAddress = self.publicConfigStore.get('selectedAddress') - result = selectedAddress ? [selectedAddress] : [] + selectedAccount = self.publicConfigStore.get('selectedAddress') + result = selectedAccount ? [selectedAccount] : [] break case 'eth_coinbase': // read from localStorage - selectedAddress = self.publicConfigStore.get('selectedAddress') - result = selectedAddress || '0x0000000000000000000000000000000000000000' + selectedAccount = self.publicConfigStore.get('selectedAddress') + result = selectedAccount || '0x0000000000000000000000000000000000000000' break // throw not-supported Error diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 168a1cf59..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 |