aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-31 07:08:31 +0800
committerkumavis <aaron@kumavis.me>2017-01-31 07:08:31 +0800
commitf9b31fe2c3a43339a4519761e4c8b2f3813e85e0 (patch)
tree123f368b533b374a89cb5e5da593d3babb5002e2
parentb1de2cdefa2341eeab8d0269a1b14b349fdd5d16 (diff)
downloadtangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar.gz
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar.bz2
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar.lz
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar.xz
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.tar.zst
tangerine-wallet-browser-f9b31fe2c3a43339a4519761e4c8b2f3813e85e0.zip
rename selectedAccount to selectedAddress
-rw-r--r--app/scripts/keyring-controller.js4
-rw-r--r--app/scripts/lib/controllers/preferences.js7
-rw-r--r--app/scripts/metamask-controller.js10
-rw-r--r--app/scripts/migrations/006.js2
-rw-r--r--ui/app/account-detail.js2
-rw-r--r--ui/app/accounts/account-list-item.js4
-rw-r--r--ui/app/accounts/index.js11
-rw-r--r--ui/app/actions.js13
-rw-r--r--ui/app/components/buy-button-subview.js1
-rw-r--r--ui/app/components/coinbase-form.js1
-rw-r--r--ui/app/components/pending-msg-details.js2
-rw-r--r--ui/app/components/pending-tx-details.js2
-rw-r--r--ui/app/components/shapeshift-form.js1
-rw-r--r--ui/app/conf-tx.js8
-rw-r--r--ui/app/reducers/app.js8
-rw-r--r--ui/app/reducers/metamask.js6
-rw-r--r--ui/app/send.js2
17 files changed, 35 insertions, 49 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 3e329cb3f..f7a4e4010 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -150,7 +150,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))
@@ -391,7 +391,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)
})
@@ -638,7 +637,6 @@ class KeyringController extends EventEmitter {
this.keyrings = []
this.identities = {}
- this.setSelectedAccount()
}
}
diff --git a/app/scripts/lib/controllers/preferences.js b/app/scripts/lib/controllers/preferences.js
index e338f5b5e..dc9464c4e 100644
--- a/app/scripts/lib/controllers/preferences.js
+++ b/app/scripts/lib/controllers/preferences.js
@@ -13,8 +13,11 @@ class PreferencesController {
//
setSelectedAddress(_address) {
- const address = normalizeAddress(_address)
- this.store.updateState({ selectedAddress: address })
+ return new Promise((resolve, reject) => {
+ const address = normalizeAddress(_address)
+ this.store.updateState({ selectedAddress: address })
+ resolve()
+ })
}
getSelectedAddress(_address) {
diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js
index 64deae426..e081188ce 100644
--- a/app/scripts/metamask-controller.js
+++ b/app/scripts/metamask-controller.js
@@ -62,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
@@ -176,6 +177,7 @@ module.exports = class MetamaskController extends EventEmitter {
this.configManager.getConfig(),
this.txManager.getState(),
keyringControllerState,
+ this.preferencesController.store.getState(),
this.noticeController.getState(),
{
shapeShiftTxList: this.configManager.getShapeShiftTxList(),
@@ -223,7 +225,7 @@ module.exports = class MetamaskController extends EventEmitter {
submitPassword: this.submitPassword.bind(this),
// PreferencesController
- setSelectedAccount: nodeify(preferencesController.setSelectedAccount).bind(preferencesController),
+ setSelectedAddress: nodeify(preferencesController.setSelectedAddress).bind(preferencesController),
// KeyringController
setLocked: nodeify(keyringController.setLocked).bind(keyringController),
@@ -351,7 +353,7 @@ module.exports = class MetamaskController extends EventEmitter {
return this.keyringController.addNewKeyring('Simple Key Pair', [ privateKey ])
})
.then(keyring => keyring.getAccounts())
- .then((accounts) => this.preferencesController.setSelectedAccount(accounts[0]))
+ .then((accounts) => this.preferencesController.setSelectedAddress(accounts[0]))
.then(() => { cb(null, this.keyringController.fullUpdate()) })
.catch((reason) => { cb(reason) })
}
diff --git a/app/scripts/migrations/006.js b/app/scripts/migrations/006.js
index b2fcbae15..677e89bf7 100644
--- a/app/scripts/migrations/006.js
+++ b/app/scripts/migrations/006.js
@@ -30,7 +30,7 @@ function migrateState (state) {
// add new state
const newState = extend(state, {
PreferencesController: {
- selectedAccount: config.selectedAccount,
+ selectedAddress: config.selectedAccount,
},
})
diff --git a/ui/app/account-detail.js b/ui/app/account-detail.js
index 0bcfbcaab..aa418a1ba 100644
--- a/ui/app/account-detail.js
+++ b/ui/app/account-detail.js
@@ -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,
unconfMsgs: valuesFor(state.metamask.unconfMsgs),
diff --git a/ui/app/accounts/account-list-item.js b/ui/app/accounts/account-list-item.js
index 74ecef07f..2a3c13d05 100644
--- a/ui/app/accounts/account-list-item.js
+++ b/ui/app/accounts/account-list-item.js
@@ -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' : ''
diff --git a/ui/app/accounts/index.js b/ui/app/accounts/index.js
index e6f376735..7c35a83dd 100644
--- a/ui/app/accounts/index.js
+++ b/ui/app/accounts/index.js
@@ -19,7 +19,7 @@ function mapStateToProps (state) {
accounts: state.metamask.accounts,
identities: state.metamask.identities,
unconfTxs: state.metamask.unconfTxs,
- 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))
diff --git a/ui/app/actions.js b/ui/app/actions.js
index a0fed265f..fa1e0deb5 100644
--- a/ui/app/actions.js
+++ b/ui/app/actions.js
@@ -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,
})
})
}
diff --git a/ui/app/components/buy-button-subview.js b/ui/app/components/buy-button-subview.js
index afda5bf59..3074bd7cd 100644
--- a/ui/app/components/buy-button-subview.js
+++ b/ui/app/components/buy-button-subview.js
@@ -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,
diff --git a/ui/app/components/coinbase-form.js b/ui/app/components/coinbase-form.js
index 430a3eead..40f5719bb 100644
--- a/ui/app/components/coinbase-form.js
+++ b/ui/app/components/coinbase-form.js
@@ -9,7 +9,6 @@ module.exports = connect(mapStateToProps)(CoinbaseForm)
function mapStateToProps (state) {
return {
- selectedAccount: state.selectedAccount,
warning: state.appState.warning,
}
}
diff --git a/ui/app/components/pending-msg-details.js b/ui/app/components/pending-msg-details.js
index 404cb8ae2..16308d121 100644
--- a/ui/app/components/pending-msg-details.js
+++ b/ui/app/components/pending-msg-details.js
@@ -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 }
diff --git a/ui/app/components/pending-tx-details.js b/ui/app/components/pending-tx-details.js
index 286931f6f..e8615404e 100644
--- a/ui/app/components/pending-tx-details.js
+++ b/ui/app/components/pending-tx-details.js
@@ -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'
diff --git a/ui/app/components/shapeshift-form.js b/ui/app/components/shapeshift-form.js
index 383d5b623..8c9686035 100644
--- a/ui/app/components/shapeshift-form.js
+++ b/ui/app/components/shapeshift-form.js
@@ -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,
diff --git a/ui/app/conf-tx.js b/ui/app/conf-tx.js
index 1bd69f7d9..ca6c28ac9 100644
--- a/ui/app/conf-tx.js
+++ b/ui/app/conf-tx.js
@@ -19,7 +19,7 @@ function mapStateToProps (state) {
return {
identities: state.metamask.identities,
accounts: state.metamask.accounts,
- selectedAccount: state.metamask.selectedAccount,
+ selectedAddress: state.metamask.selectedAddress,
unconfTxs: state.metamask.unconfTxs,
unconfMsgs: state.metamask.unconfMsgs,
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)
diff --git a/ui/app/reducers/app.js b/ui/app/reducers/app.js
index 6a2c93f78..4fe9352a7 100644
--- a/ui/app/reducers/app.js
+++ b/ui/app/reducers/app.js
@@ -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',
diff --git a/ui/app/reducers/metamask.js b/ui/app/reducers/metamask.js
index 8679ab062..dec247c82 100644
--- a/ui/app/reducers/metamask.js
+++ b/ui/app/reducers/metamask.js
@@ -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
diff --git a/ui/app/send.js b/ui/app/send.js
index b8af19028..d16270b41 100644
--- a/ui/app/send.js
+++ b/ui/app/send.js
@@ -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,