1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-01 21:57:06 +01:00
metamask-extension/ui/components/app/transaction-list-item-details/transaction-list-item-details.container.js
VSaric 136218893b
Fix contact address pet name (#14613)
* The contact pet name isn't replaced by the recipients address

* Create getEnsResolutionByAddress selector and use it in the codebase

* Modified the getRecipient selector such that it returns an ens resolution as the nickname if a nickname isn't present but a ens resolution is.

* Update ui/ducks/send/send.js

Co-authored-by: Brad Decker <bhdecker84@gmail.com>

* Checked if ens resolution is present in the getRecipient selector

Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2022-06-13 11:18:33 -05:00

48 lines
1.4 KiB
JavaScript

import { connect } from 'react-redux';
import { tryReverseResolveAddress } from '../../../store/actions';
import {
getAddressBook,
getRpcPrefsForCurrentProvider,
getEnsResolutionByAddress,
} from '../../../selectors';
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
import TransactionListItemDetails from './transaction-list-item-details.component';
const mapStateToProps = (state, ownProps) => {
const { recipientAddress, senderAddress } = ownProps;
let recipientEns;
if (recipientAddress) {
const address = toChecksumHexAddress(recipientAddress);
recipientEns = getEnsResolutionByAddress(state, address);
}
const addressBook = getAddressBook(state);
const getNickName = (address) => {
const entry = addressBook.find((contact) => {
return address.toLowerCase() === contact.address.toLowerCase();
});
return (entry && entry.name) || '';
};
const rpcPrefs = getRpcPrefsForCurrentProvider(state);
return {
rpcPrefs,
recipientEns,
senderNickname: getNickName(senderAddress),
recipientNickname: recipientAddress ? getNickName(recipientAddress) : null,
};
};
const mapDispatchToProps = (dispatch) => {
return {
tryReverseResolveAddress: (address) => {
return dispatch(tryReverseResolveAddress(address));
},
};
};
export default connect(
mapStateToProps,
mapDispatchToProps,
)(TransactionListItemDetails);