2020-02-19 19:24:16 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-02-24 23:58:26 +01:00
|
|
|
import { compose } from 'redux'
|
2020-02-19 19:24:16 +01:00
|
|
|
import { withRouter } from 'react-router-dom'
|
|
|
|
|
|
|
|
import {
|
2020-03-06 22:34:56 +01:00
|
|
|
goHome,
|
|
|
|
decryptMsg,
|
|
|
|
cancelDecryptMsg,
|
|
|
|
decryptMsgInline,
|
|
|
|
} from '../../store/actions'
|
|
|
|
import {
|
|
|
|
getTargetAccountWithSendEtherInfo,
|
2020-02-19 19:24:16 +01:00
|
|
|
conversionRateSelector,
|
2020-03-06 22:34:56 +01:00
|
|
|
} from '../../selectors/selectors'
|
2020-02-19 19:24:16 +01:00
|
|
|
import { clearConfirmTransaction } from '../../ducks/confirm-transaction/confirm-transaction.duck'
|
|
|
|
import ConfirmDecryptMessage from './confirm-decrypt-message.component'
|
|
|
|
|
|
|
|
function mapStateToProps (state) {
|
|
|
|
const { confirmTransaction,
|
|
|
|
metamask: { domainMetadata = {} },
|
|
|
|
} = state
|
|
|
|
|
|
|
|
const {
|
|
|
|
txData = {},
|
|
|
|
} = confirmTransaction
|
|
|
|
|
2020-03-06 22:34:56 +01:00
|
|
|
const { msgParams: { from } } = txData
|
|
|
|
|
|
|
|
const fromAccount = getTargetAccountWithSendEtherInfo(state, from)
|
|
|
|
|
2020-02-19 19:24:16 +01:00
|
|
|
return {
|
|
|
|
txData: txData,
|
2020-03-06 22:34:56 +01:00
|
|
|
domainMetadata,
|
|
|
|
fromAccount,
|
2020-02-19 19:24:16 +01:00
|
|
|
requester: null,
|
|
|
|
requesterAddress: null,
|
|
|
|
conversionRate: conversionRateSelector(state),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function mapDispatchToProps (dispatch) {
|
|
|
|
return {
|
|
|
|
goHome: () => dispatch(goHome()),
|
|
|
|
clearConfirmTransaction: () => dispatch(clearConfirmTransaction()),
|
|
|
|
decryptMessage: (msgData, event) => {
|
|
|
|
const params = msgData.msgParams
|
|
|
|
params.metamaskId = msgData.id
|
|
|
|
event.stopPropagation(event)
|
|
|
|
return dispatch(decryptMsg(params))
|
|
|
|
},
|
|
|
|
cancelDecryptMessage: (msgData, event) => {
|
|
|
|
event.stopPropagation(event)
|
|
|
|
return dispatch(cancelDecryptMsg(msgData))
|
|
|
|
},
|
|
|
|
decryptMessageInline: (msgData, event) => {
|
|
|
|
const params = msgData.msgParams
|
|
|
|
params.metamaskId = msgData.id
|
|
|
|
event.stopPropagation(event)
|
|
|
|
return dispatch(decryptMsgInline(params))
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default compose(
|
|
|
|
withRouter,
|
|
|
|
connect(mapStateToProps, mapDispatchToProps)
|
|
|
|
)(ConfirmDecryptMessage)
|