Merge pull request #869 from MetaMask/dev-cleanup

Dev Cleanup Package
feature/default_network_editable
kumavis 8 years ago committed by GitHub
commit e61d792832
  1. 6
      README.md
  2. 2
      app/scripts/inpage.js
  3. 14
      app/scripts/keyring-controller.js
  4. 8
      app/scripts/lib/idStore.js
  5. 10
      app/scripts/lib/inpage-provider.js
  6. 16
      app/scripts/metamask-controller.js
  7. 2
      development/states.js
  8. 2
      development/states/account-detail-with-shapeshift-tx.json
  9. 2
      development/states/account-detail-with-transaction-history.json
  10. 2
      development/states/account-detail.json
  11. 2
      development/states/accounts.json
  12. 2
      development/states/config.json
  13. 2
      development/states/custom-rpc.json
  14. 2
      development/states/empty-account-detail.json
  15. 2
      development/states/help.json
  16. 2
      development/states/locked.json
  17. 2
      development/states/pending-crash.json
  18. 2
      development/states/pending-signature.json
  19. 2
      development/states/pending-tx-contract.json
  20. 2
      development/states/pending-tx-send-coin.json
  21. 2
      development/states/pending-tx-value.json
  22. 2
      development/states/private-network.json
  23. 2
      development/states/shapeshift.json
  24. 1
      test/unit/actions/set_selected_account_test.js
  25. 2
      test/unit/idStore-migration-test.js
  26. 3
      test/unit/idStore-test.js
  27. 5
      test/unit/keyring-controller-test.js
  28. 2
      ui/app/accounts/account-list-item.js
  29. 8
      ui/app/accounts/index.js
  30. 12
      ui/app/actions.js
  31. 2
      ui/app/components/pending-msg-details.js
  32. 2
      ui/app/components/pending-tx-details.js
  33. 8
      ui/app/conf-tx.js
  34. 2
      ui/app/first-time/init-menu.js
  35. 2
      ui/app/reducers/app.js
  36. 1
      ui/app/reducers/metamask.js
  37. 8
      ui/example.js

@ -18,6 +18,12 @@ If you're a web dapp developer, we've got two types of guides for you:
Uncompressed builds can be found in `/dist`, compressed builds can be found in `/builds` once they're built. Uncompressed builds can be found in `/dist`, compressed builds can be found in `/builds` once they're built.
## Installing Local Builds on Chrome
To install your locally built extension on Chrome, [follow this guide](http://stackoverflow.com/a/24577660/272576).
The built extension is stored in `./dist/chrome/`.
## Architecture ## Architecture
[![Architecture Diagram](./docs/architecture.png)][1] [![Architecture Diagram](./docs/architecture.png)][1]

@ -50,7 +50,7 @@ endOfStream(pingStream, triggerReload)
// set web3 defaultAcount // set web3 defaultAcount
inpageProvider.publicConfigStore.subscribe(function (state) { inpageProvider.publicConfigStore.subscribe(function (state) {
web3.eth.defaultAccount = state.selectedAddress web3.eth.defaultAccount = state.selectedAccount
}) })
// //

@ -9,7 +9,6 @@ const EventEmitter = require('events').EventEmitter
const normalize = require('./lib/sig-util').normalize const normalize = require('./lib/sig-util').normalize
const encryptor = require('./lib/encryptor') const encryptor = require('./lib/encryptor')
const messageManager = require('./lib/message-manager') const messageManager = require('./lib/message-manager')
const autoFaucet = require('./lib/auto-faucet')
const IdStoreMigrator = require('./lib/idStore-migrator') const IdStoreMigrator = require('./lib/idStore-migrator')
const BN = ethUtil.BN const BN = ethUtil.BN
@ -61,7 +60,6 @@ module.exports = class KeyringController extends EventEmitter {
transactions: this.configManager.getTxList(), transactions: this.configManager.getTxList(),
unconfMsgs: messageManager.unconfirmedMsgs(), unconfMsgs: messageManager.unconfirmedMsgs(),
messages: messageManager.getMsgList(), messages: messageManager.getMsgList(),
selectedAddress: address,
selectedAccount: address, selectedAccount: address,
shapeShiftTxList: this.configManager.getShapeShiftTxList(), shapeShiftTxList: this.configManager.getShapeShiftTxList(),
currentFiat: this.configManager.getCurrentFiat(), currentFiat: this.configManager.getCurrentFiat(),
@ -76,8 +74,8 @@ module.exports = class KeyringController extends EventEmitter {
this.ethStore = ethStore this.ethStore = ethStore
} }
createNewVaultAndKeychain (password, entropy, cb) { createNewVaultAndKeychain (password, cb) {
this.createNewVault(password, entropy, (err) => { this.createNewVault(password, (err) => {
if (err) return cb(err) if (err) return cb(err)
this.createFirstKeyTree(password, cb) this.createFirstKeyTree(password, cb)
}) })
@ -94,7 +92,7 @@ module.exports = class KeyringController extends EventEmitter {
this.clearKeyrings() this.clearKeyrings()
this.createNewVault(password, '', (err) => { this.createNewVault(password, (err) => {
if (err) return cb(err) if (err) return cb(err)
this.addNewKeyring('HD Key Tree', { this.addNewKeyring('HD Key Tree', {
mnemonic: seed, mnemonic: seed,
@ -135,7 +133,7 @@ module.exports = class KeyringController extends EventEmitter {
}) })
} }
createNewVault (password, entropy, cb) { createNewVault (password, cb) {
const configManager = this.configManager const configManager = this.configManager
const salt = this.encryptor.generateSalt() const salt = this.encryptor.generateSalt()
configManager.setSalt(salt) configManager.setSalt(salt)
@ -161,7 +159,7 @@ module.exports = class KeyringController extends EventEmitter {
this.configManager.setSelectedAccount(firstAccount) this.configManager.setSelectedAccount(firstAccount)
this.placeSeedWords() this.placeSeedWords()
autoFaucet(hexAccount) this.emit('newAccount', hexAccount)
this.setupAccounts(accounts) this.setupAccounts(accounts)
this.persistAllKeyrings() this.persistAllKeyrings()
.then(() => { .then(() => {
@ -329,7 +327,7 @@ module.exports = class KeyringController extends EventEmitter {
}, []) }, [])
} }
setSelectedAddress (address, cb) { setSelectedAccount (address, cb) {
var addr = normalize(address) var addr = normalize(address)
this.configManager.setSelectedAccount(addr) this.configManager.setSelectedAccount(addr)
cb(null, addr) cb(null, addr)

@ -44,7 +44,7 @@ function IdentityStore (opts = {}) {
// public // public
// //
IdentityStore.prototype.createNewVault = function (password, entropy, cb) { IdentityStore.prototype.createNewVault = function (password, cb) {
delete this._keyStore delete this._keyStore
var serializedKeystore = this.configManager.getWallet() var serializedKeystore = this.configManager.getWallet()
@ -53,7 +53,7 @@ IdentityStore.prototype.createNewVault = function (password, entropy, cb) {
} }
this.purgeCache() this.purgeCache()
this._createVault(password, null, entropy, (err) => { this._createVault(password, null, (err) => {
if (err) return cb(err) if (err) return cb(err)
this._autoFaucet() this._autoFaucet()
@ -77,7 +77,7 @@ IdentityStore.prototype.recoverSeed = function (cb) {
IdentityStore.prototype.recoverFromSeed = function (password, seed, cb) { IdentityStore.prototype.recoverFromSeed = function (password, seed, cb) {
this.purgeCache() this.purgeCache()
this._createVault(password, seed, null, (err) => { this._createVault(password, seed, (err) => {
if (err) return cb(err) if (err) return cb(err)
this._loadIdentities() 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 = { const opts = {
password, password,
hdPathString: this.hdPathString, hdPathString: this.hdPathString,

@ -66,20 +66,20 @@ function MetamaskInpageProvider (connectionStream) {
MetamaskInpageProvider.prototype.send = function (payload) { MetamaskInpageProvider.prototype.send = function (payload) {
const self = this const self = this
let selectedAddress let selectedAccount
let result = null let result = null
switch (payload.method) { switch (payload.method) {
case 'eth_accounts': case 'eth_accounts':
// read from localStorage // read from localStorage
selectedAddress = self.publicConfigStore.get('selectedAddress') selectedAccount = self.publicConfigStore.get('selectedAddress')
result = selectedAddress ? [selectedAddress] : [] result = selectedAccount ? [selectedAccount] : []
break break
case 'eth_coinbase': case 'eth_coinbase':
// read from localStorage // read from localStorage
selectedAddress = self.publicConfigStore.get('selectedAddress') selectedAccount = self.publicConfigStore.get('selectedAddress')
result = selectedAddress || '0x0000000000000000000000000000000000000000' result = selectedAccount || '0x0000000000000000000000000000000000000000'
break break
// throw not-supported Error // throw not-supported Error

@ -7,6 +7,8 @@ const HostStore = require('./lib/remote-store.js').HostStore
const Web3 = require('web3') const Web3 = require('web3')
const ConfigManager = require('./lib/config-manager') const ConfigManager = require('./lib/config-manager')
const extension = require('./lib/extension') const extension = require('./lib/extension')
const autoFaucet = require('./lib/auto-faucet')
module.exports = class MetamaskController { module.exports = class MetamaskController {
@ -67,7 +69,7 @@ module.exports = class MetamaskController {
addNewKeyring: keyringController.addNewKeyring.bind(keyringController), addNewKeyring: keyringController.addNewKeyring.bind(keyringController),
addNewAccount: keyringController.addNewAccount.bind(keyringController), addNewAccount: keyringController.addNewAccount.bind(keyringController),
submitPassword: keyringController.submitPassword.bind(keyringController), submitPassword: keyringController.submitPassword.bind(keyringController),
setSelectedAddress: keyringController.setSelectedAddress.bind(keyringController), setSelectedAccount: keyringController.setSelectedAccount.bind(keyringController),
approveTransaction: keyringController.approveTransaction.bind(keyringController), approveTransaction: keyringController.approveTransaction.bind(keyringController),
cancelTransaction: keyringController.cancelTransaction.bind(keyringController), cancelTransaction: keyringController.cancelTransaction.bind(keyringController),
signMessage: keyringController.signMessage.bind(keyringController), signMessage: keyringController.signMessage.bind(keyringController),
@ -125,8 +127,8 @@ module.exports = class MetamaskController {
rpcUrl: this.configManager.getCurrentRpcAddress(), rpcUrl: this.configManager.getCurrentRpcAddress(),
// account mgmt // account mgmt
getAccounts: (cb) => { getAccounts: (cb) => {
var selectedAddress = this.configManager.getSelectedAccount() var selectedAccount = this.configManager.getSelectedAccount()
var result = selectedAddress ? [selectedAddress] : [] var result = selectedAccount ? [selectedAccount] : []
cb(null, result) cb(null, result)
}, },
// tx signing // tx signing
@ -174,17 +176,21 @@ module.exports = class MetamaskController {
this.sendUpdate() this.sendUpdate()
}) })
this.keyringController.on('newAccount', (account) => {
autoFaucet(account)
})
// keyringController substate // keyringController substate
function keyringControllerToPublic (state) { function keyringControllerToPublic (state) {
return { return {
selectedAddress: state.selectedAddress, selectedAccount: state.selectedAccount,
} }
} }
// config substate // config substate
function configToPublic (state) { function configToPublic (state) {
return { return {
provider: state.provider, provider: state.provider,
selectedAddress: state.selectedAccount, selectedAccount: state.selectedAccount,
} }
} }
// dump obj into store // dump obj into store

File diff suppressed because one or more lines are too long

@ -133,7 +133,7 @@
"address": "0x704107d04affddd9b66ab9de3dd7b095852e9b69" "address": "0x704107d04affddd9b66ab9de3dd7b095852e9b69"
} }
}, },
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", "selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"network": "1", "network": "1",
"seedWords": null, "seedWords": null,
"isDisclaimerConfirmed": true, "isDisclaimerConfirmed": true,

@ -99,7 +99,7 @@
"status": "confirmed", "status": "confirmed",
"containsDelegateCall": false "containsDelegateCall": false
}], }],
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", "selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"network": "2", "network": "2",
"seedWords": null, "seedWords": null,
"isDisclaimerConfirmed": true, "isDisclaimerConfirmed": true,

@ -57,7 +57,7 @@
} }
}, },
"transactions": [], "transactions": [],
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", "selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"network": "2", "network": "2",
"seedWords": null, "seedWords": null,
"isDisclaimerConfirmed": true, "isDisclaimerConfirmed": true,

@ -89,7 +89,7 @@
} }
}, },
"transactions": [], "transactions": [],
"selectedAddress": "0x0abdd95cafcabec9b3e99dcd09fc4b441037cb80", "selectedAccount": "0x0abdd95cafcabec9b3e99dcd09fc4b441037cb80",
"network": "2", "network": "2",
"isDisclaimerConfirmed": true, "isDisclaimerConfirmed": true,
"unconfMsgs": {}, "unconfMsgs": {},

@ -57,7 +57,7 @@
} }
}, },
"transactions": [], "transactions": [],
"selectedAddress": "0x843963b837841dad3b0f5969ff271108776616df", "selectedAccount": "0x843963b837841dad3b0f5969ff271108776616df",
"network": "2", "network": "2",
"isDisclaimerConfirmed": true, "isDisclaimerConfirmed": true,
"unconfMsgs": {}, "unconfMsgs": {},

@ -157,7 +157,7 @@
"estimatedGas": "0x5208" "estimatedGas": "0x5208"
} }
], ],
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825", "selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"network": "166", "network": "166",
"seedWords": null, "seedWords": null,
"isDisclaimerConfirmed": true, "isDisclaimerConfirmed": true,

@ -54,7 +54,7 @@
} }
}, },
"transactions": [], "transactions": [],
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", "selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"network": "2", "network": "2",
"seedWords": null, "seedWords": null,
"isDisclaimerConfirmed": true, "isDisclaimerConfirmed": true,

@ -62,7 +62,7 @@
"type": "testnet" "type": "testnet"
}, },
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", "selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc", "selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"seedWords": null "seedWords": null
}, },
"appState": { "appState": {

@ -11,7 +11,7 @@
"conversionDate": 1473358355, "conversionDate": 1473358355,
"accounts": {}, "accounts": {},
"transactions": [], "transactions": [],
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825", "selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"network": "1473186153102", "network": "1473186153102",
"seedWords": null, "seedWords": null,
"isDisclaimerConfirmed": true, "isDisclaimerConfirmed": true,

File diff suppressed because one or more lines are too long

@ -351,7 +351,7 @@
"hash": "0xb6e6ff57e7b5f6bd7f2e6dc44c39f4e858a227c9509586634ca547179345a13e" "hash": "0xb6e6ff57e7b5f6bd7f2e6dc44c39f4e858a227c9509586634ca547179345a13e"
} }
], ],
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825", "selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"network": "1471904489432", "network": "1471904489432",
"seedWords": null, "seedWords": null,
"isDisclaimerConfirmed": true, "isDisclaimerConfirmed": true,

File diff suppressed because one or more lines are too long

@ -1 +1 @@
{"metamask":{"isInitialized":true,"isUnlocked":true,"currentDomain":"example.com","rpcTarget":"https://rawtestrpc.metamask.io/","identities":{"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825":{"name":"Wallet 1","address":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","mayBeFauceting":false},"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb":{"name":"Wallet 2","address":"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb","mayBeFauceting":false},"0x2f8d4a878cfa04a6e60d46362f5644deab66572d":{"name":"Wallet 3","address":"0x2f8d4a878cfa04a6e60d46362f5644deab66572d","mayBeFauceting":false}},"unconfTxs":{"1467868023090690":{"id":1467868023090690,"txParams":{"data":"0xa9059cbb0000000000000000000000008deb4d106090c3eb8f1950f727e87c4f884fb06f0000000000000000000000000000000000000000000000000000000000000064","from":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","value":"0x16345785d8a0000","to":"0xbeb0ed3034c4155f3d16a64a5c5e7c8d4ea9e9c9","origin":"MetaMask","metamaskId":1467868023090690,"metamaskNetworkId":"2"},"time":1467868023090,"status":"unconfirmed","containsDelegateCall":false}},"accounts":{"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825":{"code":"0x","balance":"0x38326dc32cf80800","nonce":"0x10000c","address":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"},"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb":{"code":"0x","balance":"0x15e578bd8e9c8000","nonce":"0x100000","address":"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb"},"0x2f8d4a878cfa04a6e60d46362f5644deab66572d":{"code":"0x","nonce":"0x100000","balance":"0x2386f26fc10000","address":"0x2f8d4a878cfa04a6e60d46362f5644deab66572d"}},"transactions":[],"selectedAddress":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","network":"2","seedWords":null,"isDisclaimerConfirmed":true,"unconfMsgs":{},"messages":[],"provider":{"type":"testnet"},"selectedAccount":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"},"appState":{"menuOpen":false,"currentView":{"name":"confTx","context":0},"accountDetail":{"subview":"transactions"},"currentDomain":"extensions","transForward":true,"isLoading":false,"warning":null},"identities":{}} {"metamask":{"isInitialized":true,"isUnlocked":true,"currentDomain":"example.com","rpcTarget":"https://rawtestrpc.metamask.io/","identities":{"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825":{"name":"Wallet 1","address":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","mayBeFauceting":false},"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb":{"name":"Wallet 2","address":"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb","mayBeFauceting":false},"0x2f8d4a878cfa04a6e60d46362f5644deab66572d":{"name":"Wallet 3","address":"0x2f8d4a878cfa04a6e60d46362f5644deab66572d","mayBeFauceting":false}},"unconfTxs":{"1467868023090690":{"id":1467868023090690,"txParams":{"data":"0xa9059cbb0000000000000000000000008deb4d106090c3eb8f1950f727e87c4f884fb06f0000000000000000000000000000000000000000000000000000000000000064","from":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","value":"0x16345785d8a0000","to":"0xbeb0ed3034c4155f3d16a64a5c5e7c8d4ea9e9c9","origin":"MetaMask","metamaskId":1467868023090690,"metamaskNetworkId":"2"},"time":1467868023090,"status":"unconfirmed","containsDelegateCall":false}},"accounts":{"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825":{"code":"0x","balance":"0x38326dc32cf80800","nonce":"0x10000c","address":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"},"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb":{"code":"0x","balance":"0x15e578bd8e9c8000","nonce":"0x100000","address":"0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb"},"0x2f8d4a878cfa04a6e60d46362f5644deab66572d":{"code":"0x","nonce":"0x100000","balance":"0x2386f26fc10000","address":"0x2f8d4a878cfa04a6e60d46362f5644deab66572d"}},"transactions":[],"selectedAccount":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825","network":"2","seedWords":null,"isDisclaimerConfirmed":true,"unconfMsgs":{},"messages":[],"provider":{"type":"testnet"},"selectedAccount":"0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"},"appState":{"menuOpen":false,"currentView":{"name":"confTx","context":0},"accountDetail":{"subview":"transactions"},"currentDomain":"extensions","transForward":true,"isLoading":false,"warning":null},"identities":{}}

File diff suppressed because one or more lines are too long

@ -52,7 +52,7 @@
"hash": "0xad609a6931f54a575ad71222ffc27cd6746017106d5b89f4ad300b37b273f8ac" "hash": "0xad609a6931f54a575ad71222ffc27cd6746017106d5b89f4ad300b37b273f8ac"
} }
], ],
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825", "selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"network": "1479753732793", "network": "1479753732793",
"isConfirmed": true, "isConfirmed": true,
"isEthConfirmed": true, "isEthConfirmed": true,

@ -46,7 +46,7 @@
} }
}, },
"transactions": [], "transactions": [],
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825", "selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"network": "1", "network": "1",
"seedWords": null, "seedWords": null,
"isDisclaimerConfirmed": true, "isDisclaimerConfirmed": true,

@ -44,6 +44,5 @@ describe('SHOW_ACCOUNT_DETAIL', function() {
var resultingState = reducers(initialState, action) var resultingState = reducers(initialState, action)
assert.equal(resultingState.metamask.selectedAccount, action.value) assert.equal(resultingState.metamask.selectedAccount, action.value)
assert.equal(resultingState.metamask.selectedAddress, action.value)
}) })
}) })

@ -52,7 +52,7 @@ describe('IdentityStore to KeyringController migration', function() {
}, },
}) })
idStore._createVault(password, mockVault.seed, null, (err) => { idStore._createVault(password, mockVault.seed, (err) => {
assert.ifError(err, 'createNewVault threw error') assert.ifError(err, 'createNewVault threw error')
originalKeystore = idStore._idmgmt.keyStore originalKeystore = idStore._idmgmt.keyStore

@ -11,7 +11,6 @@ describe('IdentityStore', function() {
describe('#createNewVault', function () { describe('#createNewVault', function () {
let idStore let idStore
let password = 'password123' let password = 'password123'
let entropy = 'entripppppyy duuude'
let seedWords let seedWords
let accounts = [] let accounts = []
let originalKeystore let originalKeystore
@ -26,7 +25,7 @@ describe('IdentityStore', function() {
}, },
}) })
idStore.createNewVault(password, entropy, (err, seeds) => { idStore.createNewVault(password, (err, seeds) => {
assert.ifError(err, 'createNewVault threw error') assert.ifError(err, 'createNewVault threw error')
seedWords = seeds seedWords = seeds
originalKeystore = idStore._idmgmt.keyStore originalKeystore = idStore._idmgmt.keyStore

@ -12,7 +12,6 @@ describe('KeyringController', function() {
let keyringController, state let keyringController, state
let password = 'password123' let password = 'password123'
let entropy = 'entripppppyy duuude'
let seedWords = 'puzzle seed penalty soldier say clay field arctic metal hen cage runway' let seedWords = 'puzzle seed penalty soldier say clay field arctic metal hen cage runway'
let addresses = ['eF35cA8EbB9669A35c31b5F6f249A9941a812AC1'.toLowerCase()] let addresses = ['eF35cA8EbB9669A35c31b5F6f249A9941a812AC1'.toLowerCase()]
let accounts = [] let accounts = []
@ -33,7 +32,7 @@ describe('KeyringController', function() {
// Browser crypto is tested in the integration test suite. // Browser crypto is tested in the integration test suite.
keyringController.encryptor = mockEncryptor keyringController.encryptor = mockEncryptor
keyringController.createNewVaultAndKeychain(password, null, function (err, newState) { keyringController.createNewVaultAndKeychain(password, function (err, newState) {
assert.ifError(err) assert.ifError(err)
state = newState state = newState
done() done()
@ -51,7 +50,7 @@ describe('KeyringController', function() {
it('should set a vault on the configManager', function(done) { it('should set a vault on the configManager', function(done) {
keyringController.configManager.setVault(null) keyringController.configManager.setVault(null)
assert(!keyringController.configManager.getVault(), 'no previous vault') assert(!keyringController.configManager.getVault(), 'no previous vault')
keyringController.createNewVaultAndKeychain(password, null, (err, state) => { keyringController.createNewVaultAndKeychain(password, (err, state) => {
assert.ifError(err) assert.ifError(err)
const vault = keyringController.configManager.getVault() const vault = keyringController.configManager.getVault()
assert(vault, 'vault created') assert(vault, 'vault created')

@ -16,7 +16,7 @@ function AccountListItem () {
AccountListItem.prototype.render = function () { AccountListItem.prototype.render = function () {
const identity = this.props.identity const identity = this.props.identity
var isSelected = this.props.selectedAddress === identity.address var isSelected = this.props.selectedAccount === identity.address
var account = this.props.accounts[identity.address] var account = this.props.accounts[identity.address]
const selectedClass = isSelected ? '.selected' : '' const selectedClass = isSelected ? '.selected' : ''

@ -19,7 +19,7 @@ function mapStateToProps (state) {
accounts: state.metamask.accounts, accounts: state.metamask.accounts,
identities: state.metamask.identities, identities: state.metamask.identities,
unconfTxs: state.metamask.unconfTxs, unconfTxs: state.metamask.unconfTxs,
selectedAddress: state.metamask.selectedAddress, selectedAccount: state.metamask.selectedAccount,
scrollToBottom: state.appState.scrollToBottom, scrollToBottom: state.appState.scrollToBottom,
pending, pending,
} }
@ -72,7 +72,7 @@ AccountsScreen.prototype.render = function () {
return h(AccountListItem, { return h(AccountListItem, {
key: `acct-panel-${identity.address}`, key: `acct-panel-${identity.address}`,
identity, identity,
selectedAddress: this.props.selectedAddress, selectedAccount: this.props.selectedAccount,
accounts: this.props.accounts, accounts: this.props.accounts,
onShowDetail: this.onShowDetail.bind(this), onShowDetail: this.onShowDetail.bind(this),
pending, pending,
@ -133,8 +133,8 @@ AccountsScreen.prototype.navigateToConfTx = function () {
AccountsScreen.prototype.onSelect = function (address, event) { AccountsScreen.prototype.onSelect = function (address, event) {
event.stopPropagation() event.stopPropagation()
// if already selected, deselect // if already selected, deselect
if (this.props.selectedAddress === address) address = null if (this.props.selectedAccount === address) address = null
this.props.dispatch(actions.setSelectedAddress(address)) this.props.dispatch(actions.setSelectedAccount(address))
} }
AccountsScreen.prototype.onShowDetail = function (address, event) { AccountsScreen.prototype.onShowDetail = function (address, event) {

@ -71,7 +71,7 @@ var actions = {
TRANSACTION_ERROR: 'TRANSACTION_ERROR', TRANSACTION_ERROR: 'TRANSACTION_ERROR',
NEXT_TX: 'NEXT_TX', NEXT_TX: 'NEXT_TX',
PREVIOUS_TX: 'PREV_TX', PREVIOUS_TX: 'PREV_TX',
setSelectedAddress: setSelectedAddress, setSelectedAccount: setSelectedAccount,
signMsg: signMsg, signMsg: signMsg,
cancelMsg: cancelMsg, cancelMsg: cancelMsg,
sendTx: sendTx, sendTx: sendTx,
@ -201,9 +201,9 @@ function createNewVaultAndRestore (password, seed) {
} }
} }
function createNewVaultAndKeychain (password, entropy) { function createNewVaultAndKeychain (password) {
return (dispatch) => { return (dispatch) => {
background.createNewVaultAndKeychain(password, entropy, (err) => { background.createNewVaultAndKeychain(password, (err) => {
if (err) { if (err) {
return dispatch(actions.showWarning(err.message)) return dispatch(actions.showWarning(err.message))
} }
@ -259,9 +259,9 @@ function showInfoPage () {
} }
} }
function setSelectedAddress (address) { function setSelectedAccount (address) {
return (dispatch) => { return (dispatch) => {
background.setSelectedAddress(address) background.setSelectedAccount(address)
} }
} }
@ -455,7 +455,7 @@ function lockMetamask () {
function showAccountDetail (address) { function showAccountDetail (address) {
return (dispatch) => { return (dispatch) => {
dispatch(actions.showLoadingIndication()) dispatch(actions.showLoadingIndication())
background.setSelectedAddress(address, (err, address) => { background.setSelectedAccount(address, (err, address) => {
dispatch(actions.hideLoadingIndication()) dispatch(actions.hideLoadingIndication())
if (err) { if (err) {
return dispatch(actions.displayWarning(err.message)) return dispatch(actions.displayWarning(err.message))

@ -16,7 +16,7 @@ PendingMsgDetails.prototype.render = function () {
var msgData = state.txData var msgData = state.txData
var msgParams = msgData.msgParams || {} var msgParams = msgData.msgParams || {}
var address = msgParams.from || state.selectedAddress var address = msgParams.from || state.selectedAccount
var identity = state.identities[address] || { address: address } var identity = state.identities[address] || { address: address }
var account = state.accounts[address] || { address: address } var account = state.accounts[address] || { address: address }

@ -24,7 +24,7 @@ PTXP.render = function () {
var txData = props.txData var txData = props.txData
var txParams = txData.txParams || {} var txParams = txData.txParams || {}
var address = txParams.from || props.selectedAddress var address = txParams.from || props.selectedAccount
var identity = props.identities[address] || { address: address } var identity = props.identities[address] || { address: address }
var account = props.accounts[address] var account = props.accounts[address]
var balance = account ? account.balance : '0x0' var balance = account ? account.balance : '0x0'

@ -18,7 +18,7 @@ function mapStateToProps (state) {
return { return {
identities: state.metamask.identities, identities: state.metamask.identities,
accounts: state.metamask.accounts, accounts: state.metamask.accounts,
selectedAddress: state.metamask.selectedAddress, selectedAccount: state.metamask.selectedAccount,
unconfTxs: state.metamask.unconfTxs, unconfTxs: state.metamask.unconfTxs,
unconfMsgs: state.metamask.unconfMsgs, unconfMsgs: state.metamask.unconfMsgs,
index: state.appState.currentView.context, index: state.appState.currentView.context,
@ -90,12 +90,12 @@ ConfirmTxScreen.prototype.render = function () {
// Properties // Properties
txData: txData, txData: txData,
key: txData.id, key: txData.id,
selectedAddress: state.selectedAddress, selectedAccount: state.selectedAccount,
accounts: state.accounts, accounts: state.accounts,
identities: state.identities, identities: state.identities,
insufficientBalance: this.checkBalnceAgainstTx(txData), insufficientBalance: this.checkBalnceAgainstTx(txData),
// Actions // Actions
buyEth: this.buyEth.bind(this, txParams.from || state.selectedAddress), buyEth: this.buyEth.bind(this, txParams.from || state.selectedAccount),
sendTransaction: this.sendTransaction.bind(this, txData), sendTransaction: this.sendTransaction.bind(this, txData),
cancelTransaction: this.cancelTransaction.bind(this, txData), cancelTransaction: this.cancelTransaction.bind(this, txData),
signMessage: this.signMessage.bind(this, txData), signMessage: this.signMessage.bind(this, txData),
@ -120,7 +120,7 @@ ConfirmTxScreen.prototype.checkBalnceAgainstTx = function (txData) {
var state = this.props var state = this.props
var txParams = txData.txParams || {} var txParams = txData.txParams || {}
var address = txParams.from || state.selectedAddress var address = txParams.from || state.selectedAccount
var account = state.accounts[address] var account = state.accounts[address]
var balance = account ? account.balance : '0x0' var balance = account ? account.balance : '0x0'

@ -165,7 +165,7 @@ InitializeMenuScreen.prototype.createNewVaultAndKeychain = function () {
return return
} }
this.props.dispatch(actions.createNewVaultAndKeychain(password, ''/* entropy*/)) this.props.dispatch(actions.createNewVaultAndKeychain(password))
} }
InitializeMenuScreen.prototype.inputChanged = function (event) { InitializeMenuScreen.prototype.inputChanged = function (event) {

@ -285,7 +285,7 @@ function reduceApp (state, action) {
warning: null, warning: null,
currentView: { currentView: {
name: 'accountDetail', name: 'accountDetail',
context: state.metamask.selectedAddress, context: state.metamask.selectedAccount,
}, },
accountDetail: { accountDetail: {
subview: 'transactions', subview: 'transactions',

@ -98,7 +98,6 @@ function reduceMetamask (state, action) {
isUnlocked: true, isUnlocked: true,
isInitialized: true, isInitialized: true,
selectedAccount: action.value, selectedAccount: action.value,
selectedAddress: action.value,
}) })
delete newState.seedWords delete newState.seedWords
return newState return newState

@ -53,14 +53,14 @@ function addUnconfTx (txParams) {
} }
var isUnlocked = false var isUnlocked = false
var selectedAddress = null var selectedAccount = null
function getState () { function getState () {
return { return {
isUnlocked: isUnlocked, isUnlocked: isUnlocked,
identities: isUnlocked ? identities : {}, identities: isUnlocked ? identities : {},
unconfTxs: isUnlocked ? unconfTxs : {}, unconfTxs: isUnlocked ? unconfTxs : {},
selectedAddress: selectedAddress, selectedAccount: selectedAccount,
} }
} }
@ -85,8 +85,8 @@ accountManager.submitPassword = function (password, cb) {
} }
} }
accountManager.setSelectedAddress = function (address, cb) { accountManager.setSelectedAccount = function (address, cb) {
selectedAddress = address selectedAccount = address
cb(null, getState()) cb(null, getState())
this._didUpdate() this._didUpdate()
} }

Loading…
Cancel
Save