1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-11 20:27:12 +01:00
metamask-extension/ui/app/pages/confirm-send-token/confirm-send-token.container.js

64 lines
1.8 KiB
JavaScript
Raw Normal View History

import { connect } from 'react-redux';
import { compose } from 'redux';
import { withRouter } from 'react-router-dom';
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck';
import { updateSend, showSendTokenPage } from '../../store/actions';
import { conversionUtil } from '../../helpers/utils/conversion-util';
2020-11-03 00:41:28 +01:00
import {
getTokenValueParam,
getTokenAddressParam,
} from '../../helpers/utils/token-util';
import { sendTokenTokenAmountAndToAddressSelector } from '../../selectors';
import ConfirmSendToken from './confirm-send-token.component';
2020-02-15 21:34:12 +01:00
const mapStateToProps = (state) => {
const { tokenAmount } = sendTokenTokenAmountAndToAddressSelector(state);
return {
tokenAmount,
};
};
2020-02-15 21:34:12 +01:00
const mapDispatchToProps = (dispatch) => {
return {
editTransaction: ({ txData, tokenData, tokenProps }) => {
const {
id,
2020-11-03 00:41:28 +01:00
txParams: { from, to: tokenAddress, gas: gasLimit, gasPrice } = {},
} = txData;
const to = getTokenValueParam(tokenData);
const tokenAmountInDec = getTokenAddressParam(tokenData);
const tokenAmountInHex = conversionUtil(tokenAmountInDec, {
fromNumericBase: 'dec',
toNumericBase: 'hex',
});
2020-11-03 00:41:28 +01:00
dispatch(
updateSend({
from,
gasLimit,
gasPrice,
gasTotal: null,
to,
amount: tokenAmountInHex,
errors: { to: null, amount: null },
2020-11-05 16:35:58 +01:00
editingTransactionId: id?.toString(),
2020-11-03 00:41:28 +01:00
token: {
...tokenProps,
address: tokenAddress,
},
}),
);
dispatch(clearConfirmTransaction());
dispatch(showSendTokenPage());
},
};
};
export default compose(
withRouter,
connect(mapStateToProps, mapDispatchToProps),
)(ConfirmSendToken);