mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
get identities from getState() instead of passing from caller, only set new account label if label set.
This commit is contained in:
parent
a1d72a59fe
commit
13f22ff6b0
@ -349,9 +349,10 @@ function navigateToNewAccountScreen () {
|
||||
}
|
||||
}
|
||||
|
||||
function addNewAccount (oldIdentities) {
|
||||
function addNewAccount () {
|
||||
log.debug(`background.addNewAccount`)
|
||||
return (dispatch) => {
|
||||
return (dispatch, getState) => {
|
||||
const oldIdentities = getState().metamask.identities
|
||||
dispatch(actions.showLoadingIndication())
|
||||
return new Promise((resolve, reject) => {
|
||||
background.addNewAccount((err, { identities: newIdentities}) => {
|
||||
|
@ -8,7 +8,6 @@ function mapStateToProps (state) {
|
||||
return {
|
||||
network: state.metamask.network,
|
||||
address: state.metamask.selectedAddress,
|
||||
identities: state.metamask.identities,
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,10 +19,12 @@ function mapDispatchToProps (dispatch) {
|
||||
hideModal: () => {
|
||||
dispatch(actions.hideModal())
|
||||
},
|
||||
createAccount: (identities, newAccountName) => {
|
||||
dispatch(actions.addNewAccount(identities))
|
||||
createAccount: (newAccountName) => {
|
||||
dispatch(actions.addNewAccount())
|
||||
.then((newAccountAddress) => {
|
||||
dispatch(actions.saveAccountLabel(newAccountAddress, newAccountName))
|
||||
if (newAccountName) {
|
||||
dispatch(actions.saveAccountLabel(newAccountAddress, newAccountName))
|
||||
}
|
||||
dispatch(actions.hideModal())
|
||||
})
|
||||
},
|
||||
@ -42,7 +43,6 @@ function NewAccountModal () {
|
||||
module.exports = connect(mapStateToProps, mapDispatchToProps)(NewAccountModal)
|
||||
|
||||
NewAccountModal.prototype.render = function () {
|
||||
const { identities } = this.props
|
||||
const { newAccountName } = this.state
|
||||
|
||||
return h('div', {}, [
|
||||
@ -77,7 +77,7 @@ NewAccountModal.prototype.render = function () {
|
||||
|
||||
h('div.new-account-modal-content.button', {}, [
|
||||
h('button.btn-clear', {
|
||||
onClick: () => this.props.createAccount(identities, newAccountName)
|
||||
onClick: () => this.props.createAccount(newAccountName)
|
||||
}, [
|
||||
'SAVE',
|
||||
]),
|
||||
|
Loading…
Reference in New Issue
Block a user