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';
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
import { mmiActionsFactory } from '../../../store/institutional/institution-background';
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
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,
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
getSelectedIdentity,
|
|
|
|
getKnownMethodData,
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
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);
|
|
|
|
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
const data = ownProps.transactionGroup?.primaryTransaction?.txParams?.data;
|
|
|
|
const methodData = getKnownMethodData(state, data) || {};
|
|
|
|
const transactionNote =
|
|
|
|
ownProps.transactionGroup?.primaryTransaction?.metadata?.note;
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
|
|
|
|
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,
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
methodData,
|
|
|
|
transactionNote,
|
|
|
|
selectedIdentity: getSelectedIdentity(state),
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2019-11-01 18:54:00 +01:00
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
const mmiActions = mmiActionsFactory();
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
2019-11-01 18:54:00 +01:00
|
|
|
return {
|
|
|
|
tryReverseResolveAddress: (address) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
return dispatch(tryReverseResolveAddress(address));
|
2019-11-01 18:54:00 +01:00
|
|
|
},
|
2023-05-24 13:40:58 +02:00
|
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
|
|
getCustodianTransactionDeepLink: (address, txId) => {
|
|
|
|
return dispatch(
|
|
|
|
mmiActions.getCustodianTransactionDeepLink(address, txId),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
///: END:ONLY_INCLUDE_IN
|
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);
|