2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
2019-07-31 21:56:44 +02:00
|
|
|
import {
|
2020-03-06 22:34:56 +01:00
|
|
|
accountsWithSendEtherInfoSelector,
|
2019-08-14 01:13:05 +02:00
|
|
|
getAddressBookEntry,
|
2021-04-28 20:02:01 +02:00
|
|
|
getIsEthGasPriceFetched,
|
|
|
|
getNoGasPriceFetched,
|
2021-09-30 13:57:59 +02:00
|
|
|
checkNetworkOrAccountNotSupports1559,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../../selectors';
|
2021-06-23 23:35:25 +02:00
|
|
|
import { getIsAssetSendable, getSendTo } from '../../../ducks/send';
|
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
import * as actions from '../../../store/actions';
|
|
|
|
import SendContent from './send-content.component';
|
2019-07-31 21:56:44 +02:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapStateToProps(state) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const ownedAccounts = accountsWithSendEtherInfoSelector(state);
|
|
|
|
const to = getSendTo(state);
|
2019-07-31 21:56:44 +02:00
|
|
|
return {
|
2021-06-23 23:35:25 +02:00
|
|
|
isAssetSendable: getIsAssetSendable(state),
|
2020-11-03 00:41:28 +01:00
|
|
|
isOwnedAccount: Boolean(
|
|
|
|
ownedAccounts.find(
|
|
|
|
({ address }) => address.toLowerCase() === to.toLowerCase(),
|
|
|
|
),
|
|
|
|
),
|
2019-08-14 01:13:05 +02:00
|
|
|
contact: getAddressBookEntry(state, to),
|
2021-04-28 20:02:01 +02:00
|
|
|
isEthGasPrice: getIsEthGasPriceFetched(state),
|
|
|
|
noGasPrice: getNoGasPriceFetched(state),
|
2021-06-23 23:35:25 +02:00
|
|
|
to,
|
2021-09-30 13:57:59 +02:00
|
|
|
networkOrAccountNotSupports1559: checkNetworkOrAccountNotSupports1559(
|
|
|
|
state,
|
|
|
|
),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-07-31 21:56:44 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapDispatchToProps(dispatch) {
|
2019-07-31 21:56:44 +02:00
|
|
|
return {
|
2020-11-03 00:41:28 +01:00
|
|
|
showAddToAddressBookModal: (recipient) =>
|
|
|
|
dispatch(
|
|
|
|
actions.showModal({
|
|
|
|
name: 'ADD_TO_ADDRESSBOOK',
|
|
|
|
recipient,
|
|
|
|
}),
|
|
|
|
),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-07-31 21:56:44 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mergeProps(stateProps, dispatchProps, ownProps) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { to, ...restStateProps } = stateProps;
|
2019-07-31 21:56:44 +02:00
|
|
|
return {
|
|
|
|
...ownProps,
|
2019-12-08 04:10:47 +01:00
|
|
|
...restStateProps,
|
2020-11-03 00:41:28 +01:00
|
|
|
showAddToAddressBookModal: () =>
|
|
|
|
dispatchProps.showAddToAddressBookModal(to),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2019-07-31 21:56:44 +02:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export default connect(
|
|
|
|
mapStateToProps,
|
|
|
|
mapDispatchToProps,
|
|
|
|
mergeProps,
|
2021-02-04 19:15:23 +01:00
|
|
|
)(SendContent);
|