mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-01 21:57:06 +01:00
00bad7b8a8
* Added code fencing in transaction list * Fixed import * Fixed tests * Fixed indentation * Fixed code fences * Removed custody icon in favor of svg * Fix prettier * lint * Fixed prettier issue * adds check before set state with variable _mounted * lint * check for address in selectedIdentity * review fix * lint * updates test * lint * clean up * prettier * adds missing locale * Added tests and improved code * Fixed code --------- Co-authored-by: Antonio Regadas <antonio.regadas@consensys.net>
96 lines
3.0 KiB
JavaScript
96 lines
3.0 KiB
JavaScript
import { connect } from 'react-redux';
|
|
import { compose } from 'redux';
|
|
import { withRouter } from 'react-router-dom';
|
|
import { tryReverseResolveAddress } from '../../../store/actions';
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
import { mmiActionsFactory } from '../../../store/institutional/institution-background';
|
|
///: END:ONLY_INCLUDE_IN
|
|
import {
|
|
getAddressBook,
|
|
getBlockExplorerLinkText,
|
|
getIsCustomNetwork,
|
|
getRpcPrefsForCurrentProvider,
|
|
getEnsResolutionByAddress,
|
|
getAccountName,
|
|
getMetadataContractName,
|
|
getMetaMaskIdentities,
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
getSelectedIdentity,
|
|
getKnownMethodData,
|
|
///: END:ONLY_INCLUDE_IN
|
|
} from '../../../selectors';
|
|
import { toChecksumHexAddress } from '../../../../shared/modules/hexstring-utils';
|
|
import TransactionListItemDetails from './transaction-list-item-details.component';
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
const { recipientAddress, senderAddress } = ownProps;
|
|
let recipientEns;
|
|
if (recipientAddress) {
|
|
const address = toChecksumHexAddress(recipientAddress);
|
|
recipientEns = getEnsResolutionByAddress(state, address);
|
|
}
|
|
const addressBook = getAddressBook(state);
|
|
const identities = getMetaMaskIdentities(state);
|
|
const recipientName = getAccountName(identities, recipientAddress);
|
|
const recipientMetadataName = getMetadataContractName(
|
|
state,
|
|
recipientAddress,
|
|
);
|
|
|
|
const getNickName = (address) => {
|
|
const entry = addressBook.find((contact) => {
|
|
return address.toLowerCase() === contact.address.toLowerCase();
|
|
});
|
|
return (entry && entry.name) || '';
|
|
};
|
|
const rpcPrefs = getRpcPrefsForCurrentProvider(state);
|
|
|
|
const isCustomNetwork = getIsCustomNetwork(state);
|
|
|
|
///: 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
|
|
|
|
return {
|
|
rpcPrefs,
|
|
recipientEns,
|
|
senderNickname: getNickName(senderAddress),
|
|
recipientNickname: recipientAddress ? getNickName(recipientAddress) : null,
|
|
isCustomNetwork,
|
|
blockExplorerLinkText: getBlockExplorerLinkText(state),
|
|
recipientName,
|
|
recipientMetadataName,
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
methodData,
|
|
transactionNote,
|
|
selectedIdentity: getSelectedIdentity(state),
|
|
///: END:ONLY_INCLUDE_IN
|
|
};
|
|
};
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
const mmiActions = mmiActionsFactory();
|
|
///: END:ONLY_INCLUDE_IN
|
|
return {
|
|
tryReverseResolveAddress: (address) => {
|
|
return dispatch(tryReverseResolveAddress(address));
|
|
},
|
|
///: BEGIN:ONLY_INCLUDE_IN(build-mmi)
|
|
getCustodianTransactionDeepLink: (address, txId) => {
|
|
return dispatch(
|
|
mmiActions.getCustodianTransactionDeepLink(address, txId),
|
|
);
|
|
},
|
|
///: END:ONLY_INCLUDE_IN
|
|
};
|
|
};
|
|
|
|
export default compose(
|
|
withRouter,
|
|
connect(mapStateToProps, mapDispatchToProps),
|
|
)(TransactionListItemDetails);
|