1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 16:18:07 +01:00
metamask-extension/ui/components/app/transaction-activity-log/transaction-activity-log.container.js

60 lines
1.5 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { findLastIndex } from 'lodash';
import {
conversionRateSelector,
getRpcPrefsForCurrentProvider,
} from '../../../selectors';
import { getNativeCurrency } from '../../../ducks/metamask/metamask';
import TransactionActivityLog from './transaction-activity-log.component';
import { combineTransactionHistories } from './transaction-activity-log.util';
2018-12-09 21:48:06 +01:00
import {
TRANSACTION_RESUBMITTED_EVENT,
TRANSACTION_CANCEL_ATTEMPTED_EVENT,
} from './transaction-activity-log.constants';
2018-12-09 21:48:06 +01:00
2022-07-31 20:26:40 +02:00
const matchesEventKey =
(matchEventKey) =>
({ eventKey }) =>
eventKey === matchEventKey;
2020-02-15 21:34:12 +01:00
const mapStateToProps = (state) => {
return {
conversionRate: conversionRateSelector(state),
nativeCurrency: getNativeCurrency(state),
rpcPrefs: getRpcPrefsForCurrentProvider(state),
};
};
2018-12-09 21:48:06 +01:00
const mergeProps = (stateProps, dispatchProps, ownProps) => {
const {
2020-11-03 00:41:28 +01:00
transactionGroup: { transactions = [], primaryTransaction } = {},
2018-12-09 21:48:06 +01:00
...restOwnProps
} = ownProps;
2018-12-09 21:48:06 +01:00
const activities = combineTransactionHistories(transactions);
2020-11-03 00:41:28 +01:00
const inlineRetryIndex = findLastIndex(
activities,
matchesEventKey(TRANSACTION_RESUBMITTED_EVENT),
);
2020-11-03 00:41:28 +01:00
const inlineCancelIndex = findLastIndex(
activities,
matchesEventKey(TRANSACTION_CANCEL_ATTEMPTED_EVENT),
);
2018-12-09 21:48:06 +01:00
return {
...stateProps,
...dispatchProps,
...restOwnProps,
activities,
inlineRetryIndex,
inlineCancelIndex,
primaryTransaction,
};
};
2018-12-09 21:48:06 +01:00
2020-11-03 00:41:28 +01:00
export default connect(
mapStateToProps,
null,
mergeProps,
)(TransactionActivityLog);