2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
2022-08-02 23:56:02 +02:00
|
|
|
import { compose } from 'redux';
|
|
|
|
import { withRouter } from 'react-router-dom';
|
2021-02-04 19:15:23 +01:00
|
|
|
import { tryReverseResolveAddress } from '../../../store/actions';
|
2020-11-03 00:41:28 +01:00
|
|
|
import {
|
|
|
|
getAddressBook,
|
2022-08-02 23:56:02 +02:00
|
|
|
getBlockExplorerLinkText,
|
|
|
|
getIsCustomNetwork,
|
2020-11-03 00:41:28 +01:00
|
|
|
getRpcPrefsForCurrentProvider,
|
2022-06-13 18:18:33 +02:00
|
|
|
getEnsResolutionByAddress,
|
2022-11-08 09:34:21 +01:00
|
|
|
getAccountName,
|
|
|
|
getMetadataContractName,
|
2022-11-10 11:28:34 +01:00
|
|
|
getMetaMaskIdentities,
|
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 { 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);
|
2022-06-13 18:18:33 +02:00
|
|
|
recipientEns = getEnsResolutionByAddress(state, address);
|
2020-05-28 20:00:51 +02:00
|
|
|
}
|
2021-02-04 19:15:23 +01:00
|
|
|
const addressBook = getAddressBook(state);
|
2022-11-10 11:28:34 +01:00
|
|
|
const identities = getMetaMaskIdentities(state);
|
|
|
|
const recipientName = getAccountName(identities, recipientAddress);
|
|
|
|
const recipientMetadataName = getMetadataContractName(
|
|
|
|
state,
|
|
|
|
recipientAddress,
|
|
|
|
);
|
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
|
|
|
|
2022-08-02 23:56:02 +02:00
|
|
|
const isCustomNetwork = getIsCustomNetwork(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,
|
2022-08-02 23:56:02 +02:00
|
|
|
isCustomNetwork,
|
|
|
|
blockExplorerLinkText: getBlockExplorerLinkText(state),
|
2022-11-08 09:34:21 +01:00
|
|
|
recipientName,
|
|
|
|
recipientMetadataName,
|
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
|
|
|
|
2022-08-02 23:56:02 +02:00
|
|
|
export default compose(
|
|
|
|
withRouter,
|
|
|
|
connect(mapStateToProps, mapDispatchToProps),
|
2021-02-04 19:15:23 +01:00
|
|
|
)(TransactionListItemDetails);
|