1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-12 20:57:12 +01:00
metamask-extension/ui/components/app/transaction-list-item-details/transaction-list-item-details.container.js

49 lines
1.4 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { tryReverseResolveAddress } from '../../../store/actions';
2020-11-03 00:41:28 +01:00
import {
getAddressBook,
getRpcPrefsForCurrentProvider,
} from '../../../selectors';
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
import TransactionListItemDetails from './transaction-list-item-details.component';
const mapStateToProps = (state, ownProps) => {
const { metamask } = state;
const { ensResolutionsByAddress } = metamask;
const { recipientAddress, senderAddress } = ownProps;
let recipientEns;
if (recipientAddress) {
2021-05-17 23:19:39 +02:00
const address = toChecksumHexAddress(recipientAddress);
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) || '';
};
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));
},
};
};
2020-11-03 00:41:28 +01:00
export default connect(
mapStateToProps,
mapDispatchToProps,
)(TransactionListItemDetails);