Merge branch 'dev' into messageManagerCleanUp

feature/default_network_editable
Frankie 8 years ago
commit ce0c3ed03c
  1. 4
      app/scripts/inpage.js
  2. 28
      app/scripts/keyring-controller.js
  3. 33
      app/scripts/lib/controllers/preferences.js
  4. 10
      app/scripts/lib/inpage-provider.js
  5. 34
      app/scripts/metamask-controller.js
  6. 41
      app/scripts/migrations/006.js
  7. 1
      app/scripts/migrations/index.js
  8. 6
      app/scripts/transaction-manager.js
  9. 2
      development/states.json
  10. 4
      development/states/account-detail-with-shapeshift-tx.json
  11. 4
      development/states/account-detail-with-transaction-history.json
  12. 4
      development/states/account-detail.json
  13. 2
      development/states/account-list-with-imported.json
  14. 2
      development/states/accounts-loose.json
  15. 3
      development/states/accounts.json
  16. 2
      development/states/compilation-bug.json
  17. 3
      development/states/config.json
  18. 3
      development/states/custom-rpc.json
  19. 4
      development/states/empty-account-detail.json
  20. 3
      development/states/help.json
  21. 2
      development/states/import-private-key-warning.json
  22. 2
      development/states/import-private-key.json
  23. 4
      development/states/locked.json
  24. 4
      development/states/lost-accounts.json
  25. 2
      development/states/new-account.json
  26. 2
      development/states/notice.json
  27. 2
      development/states/pending-crash.json
  28. 4
      development/states/pending-signature.json
  29. 2
      development/states/pending-tx-contract.json
  30. 2
      development/states/pending-tx-send-coin.json
  31. 2
      development/states/pending-tx-value.json
  32. 4
      development/states/private-network.json
  33. 2
      development/states/send.json
  34. 4
      development/states/shapeshift.json
  35. 2
      test/integration/mocks/oldVault.json
  36. 4
      test/unit/actions/set_selected_account_test.js
  37. 2
      ui/app/account-detail.js
  38. 4
      ui/app/accounts/account-list-item.js
  39. 11
      ui/app/accounts/index.js
  40. 13
      ui/app/actions.js
  41. 1
      ui/app/components/buy-button-subview.js
  42. 1
      ui/app/components/coinbase-form.js
  43. 2
      ui/app/components/pending-msg-details.js
  44. 2
      ui/app/components/pending-tx-details.js
  45. 1
      ui/app/components/shapeshift-form.js
  46. 8
      ui/app/conf-tx.js
  47. 8
      ui/app/reducers/app.js
  48. 6
      ui/app/reducers/metamask.js
  49. 2
      ui/app/send.js

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

@ -80,8 +80,6 @@ class KeyringController extends EventEmitter {
keyringTypes: this.keyringTypes.map(krt => krt.type),
// memStore
identities: this.identities,
// diskStore
selectedAccount: state.selectedAccount,
// configManager
seedWords: this.configManager.getSeedWords(),
isDisclaimerConfirmed: this.configManager.getConfirmedDisclaimer(),
@ -141,7 +139,7 @@ class KeyringController extends EventEmitter {
const firstAccount = accounts[0]
if (!firstAccount) throw new Error('KeyringController - First Account not found.')
const hexAccount = normalizeAddress(firstAccount)
this.setSelectedAccount(hexAccount)
this.emit('newAccount', hexAccount)
return this.setupAccounts(accounts)
})
.then(this.persistAllKeyrings.bind(this, password))
@ -231,28 +229,6 @@ class KeyringController extends EventEmitter {
.then(this.fullUpdate.bind(this))
}
// Set Selected Account
// @string address
//
// returns Promise( @string address )
//
// Sets the state's `selectedAccount` value
// to the specified address.
setSelectedAccount (account) {
var address = normalizeAddress(account)
this.store.updateState({ selectedAccount: address })
return this.fullUpdate()
}
// Get Selected Account
//
// returns String
//
// Gets the state's `selectedAccount` value
getSelectedAccount () {
return this.store.getState().selectedAccount
}
// Save Account Label
// @string account
// @string label
@ -348,7 +324,6 @@ class KeyringController extends EventEmitter {
const firstAccount = accounts[0]
if (!firstAccount) throw new Error('KeyringController - No account found on keychain.')
const hexAccount = normalizeAddress(firstAccount)
this.setSelectedAccount(hexAccount)
this.emit('newAccount', hexAccount)
return this.setupAccounts(accounts)
})
@ -595,7 +570,6 @@ class KeyringController extends EventEmitter {
this.keyrings = []
this.identities = {}
this.setSelectedAccount()
}
}

@ -0,0 +1,33 @@
const ObservableStore = require('obs-store')
const normalizeAddress = require('../sig-util').normalize
class PreferencesController {
constructor (opts = {}) {
const initState = opts.initState || {}
this.store = new ObservableStore(initState)
}
//
// PUBLIC METHODS
//
setSelectedAddress(_address) {
return new Promise((resolve, reject) => {
const address = normalizeAddress(_address)
this.store.updateState({ selectedAddress: address })
resolve()
})
}
getSelectedAddress(_address) {
return this.store.getState().selectedAddress
}
//
// PRIVATE METHODS
//
}
module.exports = PreferencesController

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

@ -11,6 +11,7 @@ const streamIntoProvider = require('web3-stream-provider/handler')
const MetaMaskProvider = require('web3-provider-engine/zero.js')
const setupMultiplex = require('./lib/stream-utils.js').setupMultiplex
const KeyringController = require('./keyring-controller')
const PreferencesController = require('./lib/controllers/preferences')
const NoticeController = require('./notice-controller')
const MessageManager = require('./lib/message-manager')
const TxManager = require('./transaction-manager')
@ -40,6 +41,11 @@ module.exports = class MetamaskController extends EventEmitter {
})
this.configManager.updateConversionRate()
// preferences controller
this.preferencesController = new PreferencesController({
initState: initState.PreferencesController,
})
// rpc provider
this.provider = this.initializeProvider(opts)
this.provider.on('block', this.logBlock.bind(this))
@ -56,8 +62,9 @@ module.exports = class MetamaskController extends EventEmitter {
configManager: this.configManager,
getNetwork: this.getStateNetwork.bind(this),
})
this.keyringController.on('newAccount', (account) => {
autoFaucet(account)
this.keyringController.on('newAccount', (address) => {
this.preferencesController.setSelectedAddress(address)
autoFaucet(address)
})
// tx mgmt
@ -65,7 +72,7 @@ module.exports = class MetamaskController extends EventEmitter {
txList: this.configManager.getTxList(),
txHistoryLimit: 40,
setTxList: this.configManager.setTxList.bind(this.configManager),
getSelectedAccount: this.keyringController.getSelectedAccount.bind(this.keyringController),
getSelectedAddress: this.preferencesController.getSelectedAddress.bind(this.preferencesController),
getGasMultiplier: this.configManager.getGasMultiplier.bind(this.configManager),
getNetwork: this.getStateNetwork.bind(this),
signTransaction: this.keyringController.signTransaction.bind(this.keyringController),
@ -102,6 +109,9 @@ module.exports = class MetamaskController extends EventEmitter {
this.keyringController.store.subscribe((state) => {
this.store.updateState({ KeyringController: state })
})
this.preferencesController.store.subscribe((state) => {
this.store.updateState({ PreferencesController: state })
})
}
//
@ -117,8 +127,8 @@ module.exports = class MetamaskController extends EventEmitter {
rpcUrl: this.configManager.getCurrentRpcAddress(),
// account mgmt
getAccounts: (cb) => {
let selectedAccount = this.keyringController.getSelectedAccount()
let result = selectedAccount ? [selectedAccount] : []
let selectedAddress = this.preferencesController.getSelectedAddress()
let result = selectedAddress ? [selectedAddress] : []
cb(null, result)
},
// tx signing
@ -141,9 +151,9 @@ module.exports = class MetamaskController extends EventEmitter {
)
function selectPublicState(state) {
const result = { selectedAccount: undefined }
const result = { selectedAddress: undefined }
try {
result.selectedAccount = state.KeyringController.selectedAccount
result.selectedAddress = state.PreferencesController.selectedAddress
} catch (_) {}
return result
}
@ -165,6 +175,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.txManager.getState(),
this.messageManager.getState(),
keyringControllerState,
this.preferencesController.store.getState(),
this.noticeController.getState(),
{
shapeShiftTxList: this.configManager.getShapeShiftTxList(),
@ -180,6 +191,7 @@ module.exports = class MetamaskController extends EventEmitter {
getApi () {
const keyringController = this.keyringController
const preferencesController = this.preferencesController
const txManager = this.txManager
const messageManager = this.messageManager
const noticeController = this.noticeController
@ -211,12 +223,14 @@ module.exports = class MetamaskController extends EventEmitter {
// vault management
submitPassword: this.submitPassword.bind(this),
// PreferencesController
setSelectedAddress: nodeify(preferencesController.setSelectedAddress).bind(preferencesController),
// KeyringController
setLocked: nodeify(keyringController.setLocked).bind(keyringController),
createNewVaultAndKeychain: nodeify(keyringController.createNewVaultAndKeychain).bind(keyringController),
createNewVaultAndRestore: nodeify(keyringController.createNewVaultAndRestore).bind(keyringController),
addNewKeyring: nodeify(keyringController.addNewKeyring).bind(keyringController),
setSelectedAccount: nodeify(keyringController.setSelectedAccount).bind(keyringController),
saveAccountLabel: nodeify(keyringController.saveAccountLabel).bind(keyringController),
exportAccount: nodeify(keyringController.exportAccount).bind(keyringController),
@ -329,7 +343,7 @@ module.exports = class MetamaskController extends EventEmitter {
// ensuring they are only ever available in the background process.
clearSeedWordCache (cb) {
this.configManager.setSeedWords(null)
cb(null, this.keyringController.getSelectedAccount())
cb(null, this.preferencesController.getSelectedAddress())
}
importAccountWithStrategy (strategy, args, cb) {
@ -338,7 +352,7 @@ module.exports = class MetamaskController extends EventEmitter {
return this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ])
})
.then(keyring => keyring.getAccounts())
.then((accounts) => this.keyringController.setSelectedAccount(accounts[0]))
.then((accounts) => this.preferencesController.setSelectedAddress(accounts[0]))
.then(() => { cb(null, this.keyringController.fullUpdate()) })
.catch((reason) => { cb(reason) })
}

@ -0,0 +1,41 @@
const version = 6
/*
This migration moves KeyringController.selectedAddress to PreferencesController.selectedAddress
*/
const extend = require('xtend')
module.exports = {
version,
migrate: function (versionedData) {
versionedData.meta.version = version
try {
const state = versionedData.data
const newState = migrateState(state)
versionedData.data = newState
} catch (err) {
console.warn(`MetaMask Migration #${version}` + err.stack)
}
return Promise.resolve(versionedData)
},
}
function migrateState (state) {
const keyringSubstate = state.KeyringController
// add new state
const newState = extend(state, {
PreferencesController: {
selectedAddress: keyringSubstate.selectedAccount,
},
})
// rm old state
delete newState.KeyringController.selectedAccount
return newState
}

@ -16,4 +16,5 @@ module.exports = [
require('./003'),
require('./004'),
require('./005'),
require('./006'),
]

@ -13,7 +13,7 @@ module.exports = class TransactionManager extends EventEmitter {
this.txList = opts.txList || []
this._setTxList = opts.setTxList
this.txHistoryLimit = opts.txHistoryLimit
this.getSelectedAccount = opts.getSelectedAccount
this.getSelectedAddress = opts.getSelectedAddress
this.provider = opts.provider
this.blockTracker = opts.blockTracker
this.txProviderUtils = new TxProviderUtil(this.provider)
@ -25,11 +25,11 @@ module.exports = class TransactionManager extends EventEmitter {
}
getState () {
var selectedAccount = this.getSelectedAccount()
var selectedAddress = this.getSelectedAddress()
return {
transactions: this.getTxList(),
unapprovedTxs: this.getUnapprovedTxList(),
selectedAccountTxList: this.getFilteredTxList({metamaskNetworkId: this.getNetwork(), from: selectedAccount}),
selectedAddressTxList: this.getFilteredTxList({metamaskNetworkId: this.getNetwork(), from: selectedAddress}),
}
}

File diff suppressed because one or more lines are too long

@ -133,7 +133,7 @@
"address": "0x704107d04affddd9b66ab9de3dd7b095852e9b69"
}
},
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"network": "1",
"seedWords": null,
"isDisclaimerConfirmed": true,
@ -142,7 +142,7 @@
"provider": {
"type": "mainnet"
},
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
},
"appState": {
"menuOpen": false,

@ -99,7 +99,7 @@
"status": "confirmed",
"containsDelegateCall": false
}],
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"network": "2",
"seedWords": null,
"isDisclaimerConfirmed": true,
@ -108,7 +108,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
},
"appState": {
"menuOpen": false,

@ -57,7 +57,7 @@
}
},
"transactions": [],
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"network": "2",
"seedWords": null,
"isDisclaimerConfirmed": true,
@ -66,7 +66,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
},
"appState": {
"menuOpen": false,

@ -37,7 +37,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x9858e7d8b79fc3e6d989636721584498926da38a",
"selectedAddress": "0x9858e7d8b79fc3e6d989636721584498926da38a",
"selectedAccountTxList": [],
"isDisclaimerConfirmed": true,
"unconfMsgs": {},

@ -77,7 +77,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x87658c15aefe7448008a28513a11b6b130ef4cd0",
"selectedAddress": "0x87658c15aefe7448008a28513a11b6b130ef4cd0",
"isDisclaimerConfirmed": true,
"unconfMsgs": {},
"messages": [],

@ -89,7 +89,6 @@
}
},
"transactions": [],
"selectedAccount": "0x0abdd95cafcabec9b3e99dcd09fc4b441037cb80",
"network": "2",
"isDisclaimerConfirmed": true,
"unconfMsgs": {},
@ -98,7 +97,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x0abdd95cafcabec9b3e99dcd09fc4b441037cb80",
"selectedAddress": "0x0abdd95cafcabec9b3e99dcd09fc4b441037cb80",
"seedWords": null
},
"appState": {

@ -95,7 +95,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9",
"selectedAddress": "0xac39b311dceb2a4b2f5d8461c1cdaf756f4f7ae9",
"seedWords": false,
"isDisclaimerConfirmed": true,
"unconfMsgs": {},

@ -57,7 +57,6 @@
}
},
"transactions": [],
"selectedAccount": "0x843963b837841dad3b0f5969ff271108776616df",
"network": "2",
"isDisclaimerConfirmed": true,
"unconfMsgs": {},
@ -65,7 +64,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x843963b837841dad3b0f5969ff271108776616df",
"selectedAddress": "0x843963b837841dad3b0f5969ff271108776616df",
"seedWords": null
},
"appState": {

@ -157,7 +157,6 @@
"estimatedGas": "0x5208"
}
],
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"network": "166",
"seedWords": null,
"isDisclaimerConfirmed": true,
@ -167,7 +166,7 @@
"type": "rpc",
"rpcTarget": "555.203.16.244"
},
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
},
"appState": {
"menuOpen": false,

@ -54,7 +54,7 @@
}
},
"transactions": [],
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"network": "2",
"seedWords": null,
"isDisclaimerConfirmed": true,
@ -63,7 +63,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
},
"appState": {
"menuOpen": false,

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

@ -27,7 +27,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x01208723ba84e15da2e71656544a2963b0c06d40",
"selectedAddress": "0x01208723ba84e15da2e71656544a2963b0c06d40",
"selectedAccountTxList": [],
"seedWords": false,
"isDisclaimerConfirmed": true,

@ -27,7 +27,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x01208723ba84e15da2e71656544a2963b0c06d40",
"selectedAddress": "0x01208723ba84e15da2e71656544a2963b0c06d40",
"selectedAccountTxList": [],
"seedWords": null,
"isDisclaimerConfirmed": true,

@ -11,7 +11,7 @@
"conversionDate": 1473358355,
"accounts": {},
"transactions": [],
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"network": "1473186153102",
"seedWords": null,
"isDisclaimerConfirmed": true,
@ -22,7 +22,7 @@
"type": "rpc",
"rpcTarget": "http://localhost:8545"
},
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
},
"appState": {
"menuOpen": false,

@ -61,7 +61,7 @@
}
},
"transactions": [],
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc",
"network": "2",
"seedWords": null,
"isDisclaimerConfirmed": true,
@ -70,7 +70,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
"selectedAddress": "0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc"
},
"appState": {
"menuOpen": false,

@ -36,7 +36,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0xa6ef573d60594731178b7f85d80da13cc2af52dd",
"selectedAddress": "0xa6ef573d60594731178b7f85d80da13cc2af52dd",
"isConfirmed": true,
"unconfMsgs": {},
"messages": [],

@ -33,7 +33,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x24a1d059462456aa332d6da9117aa7f91a46f2ac",
"selectedAddress": "0x24a1d059462456aa332d6da9117aa7f91a46f2ac",
"seedWords": null,
"isDisclaimerConfirmed": true,
"unconfMsgs": {},

File diff suppressed because one or more lines are too long

@ -351,7 +351,7 @@
"hash": "0xb6e6ff57e7b5f6bd7f2e6dc44c39f4e858a227c9509586634ca547179345a13e"
}
],
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"network": "1471904489432",
"seedWords": null,
"isDisclaimerConfirmed": true,
@ -384,7 +384,7 @@
"type": "rpc",
"rpcTarget": "http://localhost:8545"
},
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
},
"appState": {
"menuOpen": false,

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":[],"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":{}}
{"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"},"selectedAddress":"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"
}
],
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"network": "1479753732793",
"isConfirmed": true,
"isEthConfirmed": true,
@ -64,7 +64,7 @@
"type": "rpc",
"rpcTarget": "http://localhost:8545"
},
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"isDisclaimerConfirmed": true
},
"appState": {

@ -55,7 +55,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
},
"appState": {
"menuOpen": false,

@ -46,7 +46,7 @@
}
},
"transactions": [],
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825",
"network": "1",
"seedWords": null,
"isDisclaimerConfirmed": true,
@ -56,7 +56,7 @@
"provider": {
"type": "mainnet"
},
"selectedAccount": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
"selectedAddress": "0xfdea65c8e26263f6d9a1b5de9555d2931a33b825"
},
"appState": {
"menuOpen": false,

@ -13,7 +13,7 @@
"provider": {
"type": "testnet"
},
"selectedAccount": "0x4dd5d356c5a016a220bcd69e82e5af680a430d00"
"selectedAddress": "0x4dd5d356c5a016a220bcd69e82e5af680a430d00"
},
"showSeedWords": false,
"isEthConfirmed": true

@ -31,7 +31,7 @@ describe('SHOW_ACCOUNT_DETAIL', function() {
it('updates metamask state', function() {
var initialState = {
metamask: {
selectedAccount: 'foo'
selectedAddress: 'foo'
}
}
freeze(initialState)
@ -43,6 +43,6 @@ describe('SHOW_ACCOUNT_DETAIL', function() {
freeze(action)
var resultingState = reducers(initialState, action)
assert.equal(resultingState.metamask.selectedAccount, action.value)
assert.equal(resultingState.metamask.selectedAddress, action.value)
})
})

@ -24,7 +24,7 @@ function mapStateToProps (state) {
metamask: state.metamask,
identities: state.metamask.identities,
accounts: state.metamask.accounts,
address: state.metamask.selectedAccount,
address: state.metamask.selectedAddress,
accountDetail: state.appState.accountDetail,
network: state.metamask.network,
unapprovedMsgs: valuesFor(state.metamask.unapprovedMsgs),

@ -15,10 +15,10 @@ function AccountListItem () {
}
AccountListItem.prototype.render = function () {
const { identity, selectedAccount, accounts, onShowDetail } = this.props
const { identity, selectedAddress, accounts, onShowDetail } = this.props
const checksumAddress = identity && identity.address && ethUtil.toChecksumAddress(identity.address)
const isSelected = selectedAccount === identity.address
const isSelected = selectedAddress === identity.address
const account = accounts[identity.address]
const selectedClass = isSelected ? '.selected' : ''

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

@ -90,7 +90,6 @@ var actions = {
TRANSACTION_ERROR: 'TRANSACTION_ERROR',
NEXT_TX: 'NEXT_TX',
PREVIOUS_TX: 'PREV_TX',
setSelectedAccount: setSelectedAccount,
signMsg: signMsg,
cancelMsg: cancelMsg,
sendTx: sendTx,
@ -287,7 +286,7 @@ function importNewAccount (strategy, args) {
dispatch(actions.updateMetamaskState(newState))
dispatch({
type: actions.SHOW_ACCOUNT_DETAIL,
value: newState.selectedAccount,
value: newState.selectedAddress,
})
})
}
@ -309,10 +308,6 @@ function showInfoPage () {
}
}
function setSelectedAccount (address) {
return callBackgroundThenUpdate(background.setSelectedAccount, address)
}
function setCurrentFiat (fiat) {
return (dispatch) => {
dispatch(this.showLoadingIndication())
@ -508,16 +503,14 @@ function lockMetamask () {
function showAccountDetail (address) {
return (dispatch) => {
dispatch(actions.showLoadingIndication())
background.setSelectedAccount(address, (err, newState) => {
background.setSelectedAddress(address, (err) => {
dispatch(actions.hideLoadingIndication())
if (err) {
return dispatch(actions.displayWarning(err.message))
}
dispatch(actions.updateMetamaskState(newState))
dispatch({
type: actions.SHOW_ACCOUNT_DETAIL,
value: newState.selectedAccount,
value: address,
})
})
}

@ -13,7 +13,6 @@ module.exports = connect(mapStateToProps)(BuyButtonSubview)
function mapStateToProps (state) {
return {
selectedAccount: state.selectedAccount,
warning: state.appState.warning,
buyView: state.appState.buyView,
network: state.metamask.network,

@ -9,7 +9,6 @@ module.exports = connect(mapStateToProps)(CoinbaseForm)
function mapStateToProps (state) {
return {
selectedAccount: state.selectedAccount,
warning: state.appState.warning,
}
}

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

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

@ -10,7 +10,6 @@ module.exports = connect(mapStateToProps)(ShapeshiftForm)
function mapStateToProps (state) {
return {
selectedAccount: state.selectedAccount,
warning: state.appState.warning,
isSubLoading: state.appState.isSubLoading,
qrRequested: state.appState.qrRequested,

@ -19,7 +19,7 @@ function mapStateToProps (state) {
return {
identities: state.metamask.identities,
accounts: state.metamask.accounts,
selectedAccount: state.metamask.selectedAccount,
selectedAddress: state.metamask.selectedAddress,
unapprovedTxs: state.metamask.unapprovedTxs,
unapprovedMsgs: state.metamask.unapprovedMsgs,
index: state.appState.currentView.context,
@ -99,12 +99,12 @@ ConfirmTxScreen.prototype.render = function () {
// Properties
txData: txData,
key: txData.id,
selectedAccount: state.selectedAccount,
selectedAddress: state.selectedAddress,
accounts: state.accounts,
identities: state.identities,
insufficientBalance: this.checkBalanceAgainstTx(txData),
// Actions
buyEth: this.buyEth.bind(this, txParams.from || state.selectedAccount),
buyEth: this.buyEth.bind(this, txParams.from || state.selectedAddress),
sendTransaction: this.sendTransaction.bind(this, txData),
cancelTransaction: this.cancelTransaction.bind(this, txData),
signMessage: this.signMessage.bind(this, txData),
@ -131,7 +131,7 @@ function currentTxView (opts) {
ConfirmTxScreen.prototype.checkBalanceAgainstTx = function (txData) {
if (!txData.txParams) return false
var state = this.props
var address = txData.txParams.from || state.selectedAccount
var address = txData.txParams.from || state.selectedAddress
var account = state.accounts[address]
var balance = account ? account.balance : '0x0'
var maxCost = new BN(txData.maxCost, 16)

@ -7,10 +7,10 @@ module.exports = reduceApp
function reduceApp (state, action) {
// clone and defaults
const selectedAccount = state.metamask.selectedAccount
const selectedAddress = state.metamask.selectedAddress
const pendingTxs = hasPendingTxs(state)
let name = 'accounts'
if (selectedAccount) {
if (selectedAddress) {
name = 'accountDetail'
}
if (pendingTxs) {
@ -20,7 +20,7 @@ function reduceApp (state, action) {
var defaultView = {
name,
detailView: null,
context: selectedAccount,
context: selectedAddress,
}
// confirm seed words
@ -331,7 +331,7 @@ function reduceApp (state, action) {
warning: null,
currentView: {
name: 'accountDetail',
context: state.metamask.selectedAccount,
context: state.metamask.selectedAddress,
},
accountDetail: {
subview: 'transactions',

@ -50,7 +50,7 @@ function reduceMetamask (state, action) {
return extend(metamaskState, {
isUnlocked: true,
isInitialized: true,
selectedAccount: action.value,
selectedAddress: action.value,
})
case actions.LOCK_METAMASK:
@ -101,7 +101,7 @@ function reduceMetamask (state, action) {
newState = extend(metamaskState, {
isUnlocked: true,
isInitialized: true,
selectedAccount: action.value,
selectedAddress: action.value,
})
delete newState.seedWords
return newState
@ -110,7 +110,7 @@ function reduceMetamask (state, action) {
newState = extend(metamaskState, {
isUnlocked: true,
isInitialized: true,
selectedAccount: action.value,
selectedAddress: action.value,
})
delete newState.seedWords
return newState

@ -16,7 +16,7 @@ module.exports = connect(mapStateToProps)(SendTransactionScreen)
function mapStateToProps (state) {
var result = {
address: state.metamask.selectedAccount,
address: state.metamask.selectedAddress,
accounts: state.metamask.accounts,
identities: state.metamask.identities,
warning: state.appState.warning,

Loading…
Cancel
Save