1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-24 02:58:09 +01:00
metamask-extension/ui/components/app/modals/cancel-transaction/cancel-transaction.container.js

54 lines
1.6 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { compose } from 'redux';
import withModalProps from '../../../../helpers/higher-order-components/with-modal-props';
import { showModal, createCancelTransaction } from '../../../../store/actions';
import CancelTransaction from './cancel-transaction.component';
const mapStateToProps = (state, ownProps) => {
const { metamask } = state;
2022-07-31 20:26:40 +02:00
const { transactionId, originalGasPrice, newGasFee, customGasSettings } =
ownProps;
const { currentNetworkTxList } = metamask;
2020-11-03 00:41:28 +01:00
const transaction = currentNetworkTxList.find(
({ id }) => id === transactionId,
);
const transactionStatus = transaction ? transaction.status : '';
return {
transactionId,
transactionStatus,
originalGasPrice,
customGasSettings,
newGasFee,
};
};
2020-02-15 21:34:12 +01:00
const mapDispatchToProps = (dispatch) => {
return {
createCancelTransaction: (txId, customGasSettings) => {
return dispatch(createCancelTransaction(txId, customGasSettings));
2018-12-09 21:48:06 +01:00
},
2020-11-03 00:41:28 +01:00
showTransactionConfirmedModal: () =>
dispatch(showModal({ name: 'TRANSACTION_CONFIRMED' })),
};
};
const mergeProps = (stateProps, dispatchProps, ownProps) => {
const { transactionId, customGasSettings, ...restStateProps } = stateProps;
// eslint-disable-next-line no-shadow
const { createCancelTransaction, ...restDispatchProps } = dispatchProps;
return {
...restStateProps,
...restDispatchProps,
...ownProps,
2020-11-03 00:41:28 +01:00
createCancelTransaction: () =>
createCancelTransaction(transactionId, customGasSettings),
};
};
export default compose(
withModalProps,
connect(mapStateToProps, mapDispatchToProps, mergeProps),
)(CancelTransaction);