2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { tryReverseResolveAddress } from '../../../store/actions';
|
2020-11-03 00:41:28 +01:00
|
|
|
import {
|
|
|
|
getAddressBook,
|
|
|
|
getRpcPrefsForCurrentProvider,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../selectors';
|
2021-05-17 23:19:39 +02:00
|
|
|
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
|
2021-02-04 19:15:23 +01:00
|
|
|
import TransactionListItemDetails from './transaction-list-item-details.component';
|
2019-11-01 18:54:00 +01:00
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { metamask } = state;
|
|
|
|
const { ensResolutionsByAddress } = metamask;
|
|
|
|
const { recipientAddress, senderAddress } = ownProps;
|
|
|
|
let recipientEns;
|
2020-05-28 20:00:51 +02:00
|
|
|
if (recipientAddress) {
|
2021-05-17 23:19:39 +02:00
|
|
|
const address = toChecksumHexAddress(recipientAddress);
|
2021-02-04 19:15:23 +01:00
|
|
|
recipientEns = ensResolutionsByAddress[address] || '';
|
2020-05-28 20:00:51 +02:00
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
const addressBook = getAddressBook(state);
|
2020-02-11 16:40:15 +01:00
|
|
|
|
|
|
|
const getNickName = (address) => {
|
|
|
|
const entry = addressBook.find((contact) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
return address.toLowerCase() === contact.address.toLowerCase();
|
|
|
|
});
|
|
|
|
return (entry && entry.name) || '';
|
|
|
|
};
|
|
|
|
const rpcPrefs = getRpcPrefsForCurrentProvider(state);
|
2019-11-01 18:54:00 +01:00
|
|
|
|
|
|
|
return {
|
2020-05-26 22:49:11 +02:00
|
|
|
rpcPrefs,
|
2019-11-01 18:54:00 +01:00
|
|
|
recipientEns,
|
2020-02-11 16:40:15 +01:00
|
|
|
senderNickname: getNickName(senderAddress),
|
2020-05-28 20:00:51 +02:00
|
|
|
recipientNickname: recipientAddress ? getNickName(recipientAddress) : null,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2019-11-01 18:54:00 +01:00
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
return {
|
|
|
|
tryReverseResolveAddress: (address) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
return dispatch(tryReverseResolveAddress(address));
|
2019-11-01 18:54:00 +01:00
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2019-11-01 18:54:00 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps,
|
2021-02-04 19:15:23 +01:00
|
|
|
)(TransactionListItemDetails);
|