mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-22 09:23:21 +01:00
rename selectedAccount to selectedAddress
This commit is contained in:
parent
b1de2cdefa
commit
f9b31fe2c3
@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) })
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ function migrateState (state) {
|
||||
// add new state
|
||||
const newState = extend(state, {
|
||||
PreferencesController: {
|
||||
selectedAccount: config.selectedAccount,
|
||||
selectedAddress: config.selectedAccount,
|
||||
},
|
||||
})
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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,
|
||||
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))
|
||||
|
@ -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,
|
||||
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)
|
||||
|
@ -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…
Reference in New Issue
Block a user