Use contact name instead of address during send flow (#7971)

feature/default_network_editable
ryanml 5 years ago committed by GitHub
parent 1ae0933897
commit 3bbbe13311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      ui/app/components/app/transaction-list-item-details/tests/transaction-list-item-details.component.test.js
  2. 6
      ui/app/components/app/transaction-list-item-details/transaction-list-item-details.component.js
  3. 13
      ui/app/components/app/transaction-list-item-details/transaction-list-item-details.container.js
  4. 2
      ui/app/components/ui/sender-to-recipient/sender-to-recipient.component.js

@ -35,6 +35,8 @@ describe('TransactionListItemDetails Component', () => {
senderAddress="0x2" senderAddress="0x2"
tryReverseResolveAddress={() => {}} tryReverseResolveAddress={() => {}}
transactionGroup={transactionGroup} transactionGroup={transactionGroup}
senderNickname="sender-nickname"
recipientNickname="recipient-nickname"
/>, />,
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } } { context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } }
) )
@ -77,6 +79,8 @@ describe('TransactionListItemDetails Component', () => {
tryReverseResolveAddress={() => {}} tryReverseResolveAddress={() => {}}
transactionGroup={transactionGroup} transactionGroup={transactionGroup}
showSpeedUp showSpeedUp
senderNickname="sender-nickname"
recipientNickname="recipient-nickname"
/>, />,
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } } { context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } }
) )
@ -112,6 +116,8 @@ describe('TransactionListItemDetails Component', () => {
senderAddress="0x2" senderAddress="0x2"
tryReverseResolveAddress={() => {}} tryReverseResolveAddress={() => {}}
transactionGroup={transactionGroup} transactionGroup={transactionGroup}
senderNickname="sender-nickname"
recipientNickname="recipient-nickname"
/>, />,
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } } { context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } }
) )
@ -150,6 +156,8 @@ describe('TransactionListItemDetails Component', () => {
senderAddress="0x2" senderAddress="0x2"
tryReverseResolveAddress={() => {}} tryReverseResolveAddress={() => {}}
transactionGroup={transactionGroup} transactionGroup={transactionGroup}
senderNickname="sender-nickname"
recipientNickname="recipient-nickname"
/>, />,
{ context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } } { context: { t: (str1, str2) => (str2 ? str1 + str2 : str1) } }
) )

@ -35,6 +35,8 @@ export default class TransactionListItemDetails extends PureComponent {
rpcPrefs: PropTypes.object, rpcPrefs: PropTypes.object,
senderAddress: PropTypes.string.isRequired, senderAddress: PropTypes.string.isRequired,
tryReverseResolveAddress: PropTypes.func.isRequired, tryReverseResolveAddress: PropTypes.func.isRequired,
senderNickname: PropTypes.string.isRequired,
recipientNickname: PropTypes.string.isRequired,
} }
state = { state = {
@ -146,6 +148,8 @@ export default class TransactionListItemDetails extends PureComponent {
rpcPrefs: { blockExplorerUrl } = {}, rpcPrefs: { blockExplorerUrl } = {},
senderAddress, senderAddress,
isEarliestNonce, isEarliestNonce,
senderNickname,
recipientNickname,
} = this.props } = this.props
const { primaryTransaction: transaction } = transactionGroup const { primaryTransaction: transaction } = transactionGroup
const { hash } = transaction const { hash } = transaction
@ -212,6 +216,8 @@ export default class TransactionListItemDetails extends PureComponent {
addressOnly addressOnly
recipientEns={recipientEns} recipientEns={recipientEns}
recipientAddress={recipientAddress} recipientAddress={recipientAddress}
recipientNickname={recipientNickname}
senderName={senderNickname}
senderAddress={senderAddress} senderAddress={senderAddress}
onRecipientClick={() => { onRecipientClick={() => {
this.context.metricsEvent({ this.context.metricsEvent({

@ -2,18 +2,29 @@ import { connect } from 'react-redux'
import TransactionListItemDetails from './transaction-list-item-details.component' import TransactionListItemDetails from './transaction-list-item-details.component'
import { checksumAddress } from '../../../helpers/utils/util' import { checksumAddress } from '../../../helpers/utils/util'
import { tryReverseResolveAddress } from '../../../store/actions' import { tryReverseResolveAddress } from '../../../store/actions'
import { getAddressBook } from '../../../selectors/selectors'
const mapStateToProps = (state, ownProps) => { const mapStateToProps = (state, ownProps) => {
const { metamask } = state const { metamask } = state
const { const {
ensResolutionsByAddress, ensResolutionsByAddress,
} = metamask } = metamask
const { recipientAddress } = ownProps const { recipientAddress, senderAddress } = ownProps
const address = checksumAddress(recipientAddress) const address = checksumAddress(recipientAddress)
const recipientEns = ensResolutionsByAddress[address] || '' const recipientEns = ensResolutionsByAddress[address] || ''
const addressBook = getAddressBook(state)
const getNickName = (address) => {
const entry = addressBook.find((contact) => {
return address.toLowerCase() === contact.address.toLowerCase()
})
return entry && entry.name || ''
}
return { return {
recipientEns, recipientEns,
senderNickname: getNickName(senderAddress),
recipientNickname: getNickName(recipientAddress),
} }
} }

@ -78,7 +78,7 @@ export default class SenderToRecipient extends PureComponent {
<div className="sender-to-recipient__name"> <div className="sender-to-recipient__name">
{ {
addressOnly addressOnly
? <span>{`${t('from')}: ${checksummedSenderAddress}`}</span> ? <span>{`${t('from')}: ${senderName || checksummedSenderAddress}`}</span>
: senderName : senderName
} }
</div> </div>

Loading…
Cancel
Save