2018-04-27 21:03:00 +02:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import SendEther from './send.component'
|
|
|
|
import { withRouter } from 'react-router-dom'
|
|
|
|
import { compose } from 'recompose'
|
|
|
|
import {
|
|
|
|
getAmountConversionRate,
|
2018-05-22 17:16:53 +02:00
|
|
|
getBlockGasLimit,
|
2018-04-27 21:03:00 +02:00
|
|
|
getConversionRate,
|
|
|
|
getCurrentNetwork,
|
|
|
|
getGasLimit,
|
|
|
|
getGasPrice,
|
|
|
|
getGasTotal,
|
|
|
|
getPrimaryCurrency,
|
2018-05-22 10:10:06 +02:00
|
|
|
getRecentBlocks,
|
2018-04-27 21:03:00 +02:00
|
|
|
getSelectedAddress,
|
|
|
|
getSelectedToken,
|
|
|
|
getSelectedTokenContract,
|
|
|
|
getSelectedTokenToFiatRate,
|
|
|
|
getSendAmount,
|
|
|
|
getSendEditingTransactionId,
|
2018-08-16 09:43:13 +02:00
|
|
|
getSendHexDataFeatureFlagState,
|
2018-04-27 21:03:00 +02:00
|
|
|
getSendFromObject,
|
2018-06-18 18:37:01 +02:00
|
|
|
getSendTo,
|
2018-04-27 21:03:00 +02:00
|
|
|
getTokenBalance,
|
2018-07-25 02:32:20 +02:00
|
|
|
getQrCodeData,
|
2018-04-27 21:03:00 +02:00
|
|
|
} from './send.selectors'
|
|
|
|
import {
|
2018-07-24 04:10:57 +02:00
|
|
|
updateSendTo,
|
2018-04-27 21:03:00 +02:00
|
|
|
updateSendTokenBalance,
|
2018-05-20 02:37:44 +02:00
|
|
|
updateGasData,
|
2018-04-27 21:03:00 +02:00
|
|
|
setGasTotal,
|
2018-08-01 00:30:40 +02:00
|
|
|
showQrScanner,
|
2018-08-04 02:11:46 +02:00
|
|
|
qrCodeDetected,
|
2018-04-27 21:03:00 +02:00
|
|
|
} from '../../actions'
|
|
|
|
import {
|
2018-06-29 19:19:40 +02:00
|
|
|
resetSendState,
|
2018-04-27 21:03:00 +02:00
|
|
|
updateSendErrors,
|
2018-05-14 14:19:09 +02:00
|
|
|
} from '../../ducks/send.duck'
|
2018-04-27 21:03:00 +02:00
|
|
|
import {
|
|
|
|
calcGasTotal,
|
|
|
|
} from './send.utils.js'
|
|
|
|
|
2018-08-01 00:30:40 +02:00
|
|
|
import {
|
|
|
|
SEND_ROUTE,
|
|
|
|
} from '../../routes'
|
|
|
|
|
2018-04-27 21:03:00 +02:00
|
|
|
module.exports = compose(
|
|
|
|
withRouter,
|
|
|
|
connect(mapStateToProps, mapDispatchToProps)
|
|
|
|
)(SendEther)
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
|
|
|
return {
|
|
|
|
amount: getSendAmount(state),
|
|
|
|
amountConversionRate: getAmountConversionRate(state),
|
2018-05-22 17:16:53 +02:00
|
|
|
blockGasLimit: getBlockGasLimit(state),
|
2018-04-27 21:03:00 +02:00
|
|
|
conversionRate: getConversionRate(state),
|
|
|
|
editingTransactionId: getSendEditingTransactionId(state),
|
|
|
|
from: getSendFromObject(state),
|
|
|
|
gasLimit: getGasLimit(state),
|
|
|
|
gasPrice: getGasPrice(state),
|
|
|
|
gasTotal: getGasTotal(state),
|
|
|
|
network: getCurrentNetwork(state),
|
|
|
|
primaryCurrency: getPrimaryCurrency(state),
|
2018-05-22 10:10:06 +02:00
|
|
|
recentBlocks: getRecentBlocks(state),
|
2018-04-27 21:03:00 +02:00
|
|
|
selectedAddress: getSelectedAddress(state),
|
|
|
|
selectedToken: getSelectedToken(state),
|
2018-08-16 09:43:13 +02:00
|
|
|
showHexData: getSendHexDataFeatureFlagState(state),
|
2018-06-18 18:37:01 +02:00
|
|
|
to: getSendTo(state),
|
2018-04-27 21:03:00 +02:00
|
|
|
tokenBalance: getTokenBalance(state),
|
|
|
|
tokenContract: getSelectedTokenContract(state),
|
|
|
|
tokenToFiatRate: getSelectedTokenToFiatRate(state),
|
2018-07-25 02:32:20 +02:00
|
|
|
qrCodeData: getQrCodeData(state),
|
2018-04-27 21:03:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps (dispatch) {
|
|
|
|
return {
|
|
|
|
updateAndSetGasTotal: ({
|
2018-05-22 17:16:53 +02:00
|
|
|
blockGasLimit,
|
2018-04-27 21:03:00 +02:00
|
|
|
editingTransactionId,
|
|
|
|
gasLimit,
|
|
|
|
gasPrice,
|
2018-05-22 10:10:06 +02:00
|
|
|
recentBlocks,
|
2018-04-27 21:03:00 +02:00
|
|
|
selectedAddress,
|
|
|
|
selectedToken,
|
2018-05-23 18:43:25 +02:00
|
|
|
to,
|
|
|
|
value,
|
2018-09-27 15:46:24 +02:00
|
|
|
data,
|
2018-04-27 21:03:00 +02:00
|
|
|
}) => {
|
|
|
|
!editingTransactionId
|
2018-09-27 15:46:24 +02:00
|
|
|
? dispatch(updateGasData({ recentBlocks, selectedAddress, selectedToken, blockGasLimit, to, value, data }))
|
2018-04-27 21:03:00 +02:00
|
|
|
: dispatch(setGasTotal(calcGasTotal(gasLimit, gasPrice)))
|
|
|
|
},
|
|
|
|
updateSendTokenBalance: ({ selectedToken, tokenContract, address }) => {
|
|
|
|
dispatch(updateSendTokenBalance({
|
|
|
|
selectedToken,
|
|
|
|
tokenContract,
|
|
|
|
address,
|
|
|
|
}))
|
|
|
|
},
|
|
|
|
updateSendErrors: newError => dispatch(updateSendErrors(newError)),
|
2018-06-29 19:19:40 +02:00
|
|
|
resetSendState: () => dispatch(resetSendState()),
|
2018-08-01 00:30:40 +02:00
|
|
|
scanQrCode: () => dispatch(showQrScanner(SEND_ROUTE)),
|
2018-08-04 02:11:46 +02:00
|
|
|
qrCodeDetected: (data) => dispatch(qrCodeDetected(data)),
|
2018-07-24 04:10:57 +02:00
|
|
|
updateSendTo: (to, nickname) => dispatch(updateSendTo(to, nickname)),
|
2018-04-27 21:03:00 +02:00
|
|
|
}
|
|
|
|
}
|