You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.8 KiB
67 lines
1.8 KiB
4 years ago
|
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';
|
||
6 years ago
|
|
||
|
const mapStateToProps = (state, ownProps) => {
|
||
4 years ago
|
const { metamask } = state;
|
||
4 years ago
|
const {
|
||
|
transactionId,
|
||
|
originalGasPrice,
|
||
|
newGasFee,
|
||
|
defaultNewGasPrice,
|
||
|
gasLimit,
|
||
|
} = ownProps;
|
||
4 years ago
|
const { currentNetworkTxList } = metamask;
|
||
4 years ago
|
const transaction = currentNetworkTxList.find(
|
||
|
({ id }) => id === transactionId,
|
||
4 years ago
|
);
|
||
|
const transactionStatus = transaction ? transaction.status : '';
|
||
6 years ago
|
|
||
|
return {
|
||
|
transactionId,
|
||
|
transactionStatus,
|
||
|
originalGasPrice,
|
||
6 years ago
|
defaultNewGasPrice,
|
||
6 years ago
|
newGasFee,
|
||
4 years ago
|
gasLimit,
|
||
4 years ago
|
};
|
||
|
};
|
||
6 years ago
|
|
||
5 years ago
|
const mapDispatchToProps = (dispatch) => {
|
||
6 years ago
|
return {
|
||
4 years ago
|
createCancelTransaction: (txId, customGasPrice, customGasLimit) => {
|
||
|
return dispatch(
|
||
|
createCancelTransaction(txId, customGasPrice, customGasLimit),
|
||
|
);
|
||
6 years ago
|
},
|
||
4 years ago
|
showTransactionConfirmedModal: () =>
|
||
|
dispatch(showModal({ name: 'TRANSACTION_CONFIRMED' })),
|
||
4 years ago
|
};
|
||
|
};
|
||
6 years ago
|
|
||
|
const mergeProps = (stateProps, dispatchProps, ownProps) => {
|
||
4 years ago
|
const {
|
||
|
transactionId,
|
||
|
defaultNewGasPrice,
|
||
|
gasLimit,
|
||
|
...restStateProps
|
||
|
} = stateProps;
|
||
4 years ago
|
// eslint-disable-next-line no-shadow
|
||
4 years ago
|
const { createCancelTransaction, ...restDispatchProps } = dispatchProps;
|
||
6 years ago
|
|
||
|
return {
|
||
|
...restStateProps,
|
||
|
...restDispatchProps,
|
||
|
...ownProps,
|
||
4 years ago
|
createCancelTransaction: () =>
|
||
4 years ago
|
createCancelTransaction(transactionId, defaultNewGasPrice, gasLimit),
|
||
4 years ago
|
};
|
||
|
};
|
||
6 years ago
|
|
||
|
export default compose(
|
||
|
withModalProps,
|
||
|
connect(mapStateToProps, mapDispatchToProps, mergeProps),
|
||
4 years ago
|
)(CancelTransaction);
|