You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
49 lines
1.4 KiB
4 years ago
|
import { connect } from 'react-redux';
|
||
|
import { tryReverseResolveAddress } from '../../../store/actions';
|
||
4 years ago
|
import {
|
||
|
getAddressBook,
|
||
|
getRpcPrefsForCurrentProvider,
|
||
4 years ago
|
} from '../../../selectors';
|
||
4 years ago
|
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
|
||
4 years ago
|
import TransactionListItemDetails from './transaction-list-item-details.component';
|
||
5 years ago
|
|
||
|
const mapStateToProps = (state, ownProps) => {
|
||
4 years ago
|
const { metamask } = state;
|
||
|
const { ensResolutionsByAddress } = metamask;
|
||
|
const { recipientAddress, senderAddress } = ownProps;
|
||
|
let recipientEns;
|
||
5 years ago
|
if (recipientAddress) {
|
||
4 years ago
|
const address = toChecksumHexAddress(recipientAddress);
|
||
4 years ago
|
recipientEns = ensResolutionsByAddress[address] || '';
|
||
5 years ago
|
}
|
||
4 years ago
|
const addressBook = getAddressBook(state);
|
||
5 years ago
|
|
||
|
const getNickName = (address) => {
|
||
|
const entry = addressBook.find((contact) => {
|
||
4 years ago
|
return address.toLowerCase() === contact.address.toLowerCase();
|
||
|
});
|
||
|
return (entry && entry.name) || '';
|
||
|
};
|
||
|
const rpcPrefs = getRpcPrefsForCurrentProvider(state);
|
||
5 years ago
|
|
||
|
return {
|
||
5 years ago
|
rpcPrefs,
|
||
5 years ago
|
recipientEns,
|
||
5 years ago
|
senderNickname: getNickName(senderAddress),
|
||
5 years ago
|
recipientNickname: recipientAddress ? getNickName(recipientAddress) : null,
|
||
4 years ago
|
};
|
||
|
};
|
||
5 years ago
|
|
||
|
const mapDispatchToProps = (dispatch) => {
|
||
|
return {
|
||
|
tryReverseResolveAddress: (address) => {
|
||
4 years ago
|
return dispatch(tryReverseResolveAddress(address));
|
||
5 years ago
|
},
|
||
4 years ago
|
};
|
||
|
};
|
||
5 years ago
|
|
||
4 years ago
|
export default connect(
|
||
|
mapStateToProps,
|
||
|
mapDispatchToProps,
|
||
4 years ago
|
)(TransactionListItemDetails);
|