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.
64 lines
1.8 KiB
64 lines
1.8 KiB
4 years ago
|
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';
|
||
4 years ago
|
import {
|
||
|
getTokenValueParam,
|
||
|
getTokenAddressParam,
|
||
4 years ago
|
} from '../../helpers/utils/token-util';
|
||
|
import { sendTokenTokenAmountAndToAddressSelector } from '../../selectors';
|
||
|
import ConfirmSendToken from './confirm-send-token.component';
|
||
7 years ago
|
|
||
5 years ago
|
const mapStateToProps = (state) => {
|
||
4 years ago
|
const { tokenAmount } = sendTokenTokenAmountAndToAddressSelector(state);
|
||
7 years ago
|
|
||
|
return {
|
||
6 years ago
|
tokenAmount,
|
||
4 years ago
|
};
|
||
|
};
|
||
7 years ago
|
|
||
5 years ago
|
const mapDispatchToProps = (dispatch) => {
|
||
7 years ago
|
return {
|
||
|
editTransaction: ({ txData, tokenData, tokenProps }) => {
|
||
5 years ago
|
const {
|
||
|
id,
|
||
4 years ago
|
txParams: { from, to: tokenAddress, gas: gasLimit, gasPrice } = {},
|
||
4 years ago
|
} = txData;
|
||
5 years ago
|
|
||
4 years ago
|
const to = getTokenValueParam(tokenData);
|
||
|
const tokenAmountInDec = getTokenAddressParam(tokenData);
|
||
5 years ago
|
|
||
7 years ago
|
const tokenAmountInHex = conversionUtil(tokenAmountInDec, {
|
||
|
fromNumericBase: 'dec',
|
||
|
toNumericBase: 'hex',
|
||
4 years ago
|
});
|
||
5 years ago
|
|
||
4 years ago
|
dispatch(
|
||
|
updateSend({
|
||
|
from,
|
||
|
gasLimit,
|
||
|
gasPrice,
|
||
|
gasTotal: null,
|
||
|
to,
|
||
|
amount: tokenAmountInHex,
|
||
|
errors: { to: null, amount: null },
|
||
4 years ago
|
editingTransactionId: id?.toString(),
|
||
4 years ago
|
token: {
|
||
|
...tokenProps,
|
||
|
address: tokenAddress,
|
||
|
},
|
||
|
}),
|
||
4 years ago
|
);
|
||
|
dispatch(clearConfirmTransaction());
|
||
|
dispatch(showSendTokenPage());
|
||
7 years ago
|
},
|
||
4 years ago
|
};
|
||
|
};
|
||
7 years ago
|
|
||
|
export default compose(
|
||
|
withRouter,
|
||
4 years ago
|
connect(mapStateToProps, mapDispatchToProps),
|
||
4 years ago
|
)(ConfirmSendToken);
|