@@ -68,7 +72,6 @@ export default class EditContact extends PureComponent {
className="settings-page__address-book-button"
onClick={async () => {
await removeFromAddressBook(chainId, address)
- history.push(listRoute)
}}
>
{t('deleteAccount')}
@@ -136,7 +139,9 @@ export default class EditContact extends PureComponent {
if (isValidAddress(this.state.newAddress)) {
await removeFromAddressBook(chainId, address)
await addToAddressBook(this.state.newAddress, this.state.newName || name, this.state.newMemo || memo)
- setAccountLabel(this.state.newAddress, this.state.newName || name)
+ if (showingMyAccounts) {
+ setAccountLabel(this.state.newAddress, this.state.newName || name)
+ }
history.push(listRoute)
} else {
this.setState({ error: this.context.t('invalidAddress') })
@@ -144,7 +149,9 @@ export default class EditContact extends PureComponent {
} else {
// update name
await addToAddressBook(address, this.state.newName || name, this.state.newMemo || memo)
- setAccountLabel(address, this.state.newName || name)
+ if (showingMyAccounts) {
+ setAccountLabel(address, this.state.newName || name)
+ }
history.push(listRoute)
}
}}
diff --git a/ui/app/pages/settings/contact-list-tab/edit-contact/edit-contact.container.js b/ui/app/pages/settings/contact-list-tab/edit-contact/edit-contact.container.js
index f649c2300..3766f1ac8 100644
--- a/ui/app/pages/settings/contact-list-tab/edit-contact/edit-contact.container.js
+++ b/ui/app/pages/settings/contact-list-tab/edit-contact/edit-contact.container.js
@@ -19,14 +19,15 @@ const mapStateToProps = (state, ownProps) => {
const pathNameTailIsAddress = pathNameTail.includes('0x')
const address = pathNameTailIsAddress ? pathNameTail.toLowerCase() : ownProps.match.params.id
- const { memo, name } = getAddressBookEntry(state, address) || state.metamask.identities[address]
+ const contact = getAddressBookEntry(state, address) || state.metamask.identities[address]
+ const { memo, name } = contact || {}
const chainId = state.metamask.network
const showingMyAccounts = Boolean(pathname.match(CONTACT_MY_ACCOUNTS_EDIT_ROUTE))
return {
- address,
+ address: contact ? address : null,
chainId,
name,
memo,
diff --git a/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.component.js b/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.component.js
index e251aff6f..9db3f690f 100644
--- a/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.component.js
+++ b/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.component.js
@@ -1,8 +1,9 @@
import React, { PureComponent } from 'react'
import PropTypes from 'prop-types'
+import { Redirect } from 'react-router-dom'
+
import Identicon from '../../../../components/ui/identicon'
import Copy from '../../../../components/ui/icon/copy-icon.component'
-
import Button from '../../../../components/ui/button/button.component'
import copyToClipboard from 'copy-to-clipboard'
@@ -23,11 +24,16 @@ export default class ViewContact extends PureComponent {
checkSummedAddress: PropTypes.string,
memo: PropTypes.string,
editRoute: PropTypes.string,
+ listRoute: PropTypes.string.isRequired,
}
render () {
const { t } = this.context
- const { history, name, address, checkSummedAddress, memo, editRoute } = this.props
+ const { history, name, address, checkSummedAddress, memo, editRoute, listRoute } = this.props
+
+ if (!address) {
+ return
+ }
return (
diff --git a/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.container.js b/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.container.js
index 3390e1a0b..7f7c5d8c1 100644
--- a/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.container.js
+++ b/ui/app/pages/settings/contact-list-tab/view-contact/view-contact.container.js
@@ -6,7 +6,9 @@ import { getAddressBookEntry } from '../../../../selectors'
import { checksumAddress } from '../../../../helpers/utils/util'
import {
CONTACT_EDIT_ROUTE,
+ CONTACT_LIST_ROUTE,
CONTACT_MY_ACCOUNTS_EDIT_ROUTE,
+ CONTACT_MY_ACCOUNTS_ROUTE,
CONTACT_MY_ACCOUNTS_VIEW_ROUTE,
} from '../../../../helpers/constants/routes'
@@ -17,16 +19,18 @@ const mapStateToProps = (state, ownProps) => {
const pathNameTailIsAddress = pathNameTail.includes('0x')
const address = pathNameTailIsAddress ? pathNameTail.toLowerCase() : ownProps.match.params.id
- const { memo, name } = getAddressBookEntry(state, address) || state.metamask.identities[address]
+ const contact = getAddressBookEntry(state, address) || state.metamask.identities[address]
+ const { memo, name } = contact || {}
const showingMyAccounts = Boolean(pathname.match(CONTACT_MY_ACCOUNTS_VIEW_ROUTE))
return {
name,
- address,
+ address: contact ? address : null,
checkSummedAddress: checksumAddress(address),
memo,
editRoute: showingMyAccounts ? CONTACT_MY_ACCOUNTS_EDIT_ROUTE : CONTACT_EDIT_ROUTE,
+ listRoute: showingMyAccounts ? CONTACT_MY_ACCOUNTS_ROUTE : CONTACT_LIST_ROUTE,
}
}