2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { withRouter } from 'react-router-dom';
|
|
|
|
import { compose } from 'redux';
|
2020-03-26 17:18:50 +01:00
|
|
|
import {
|
|
|
|
getNetworkIdentifier,
|
2020-05-26 08:11:58 +02:00
|
|
|
getPreferences,
|
2021-03-12 23:23:26 +01:00
|
|
|
isNetworkLoading,
|
2020-05-02 21:41:17 +02:00
|
|
|
submittedPendingTransactionsSelector,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../selectors';
|
2020-03-26 17:18:50 +01:00
|
|
|
import {
|
|
|
|
hideSidebar,
|
|
|
|
lockMetamask,
|
|
|
|
setCurrentCurrency,
|
|
|
|
setLastActiveTime,
|
|
|
|
setMouseUserState,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../store/actions';
|
|
|
|
import { pageChanged } from '../../ducks/history/history';
|
|
|
|
import { prepareToLeaveSwaps } from '../../ducks/swaps/swaps';
|
|
|
|
import Routes from './routes.component';
|
2020-03-26 17:18:50 +01:00
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapStateToProps(state) {
|
2021-02-04 19:15:23 +01:00
|
|
|
const { appState } = state;
|
2020-03-26 17:18:50 +01:00
|
|
|
const {
|
|
|
|
sidebar,
|
|
|
|
alertOpen,
|
|
|
|
alertMessage,
|
|
|
|
isLoading,
|
|
|
|
loadingMessage,
|
2021-02-04 19:15:23 +01:00
|
|
|
} = appState;
|
|
|
|
const { autoLockTimeLimit = 0 } = getPreferences(state);
|
2020-03-26 17:18:50 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
sidebar,
|
|
|
|
alertOpen,
|
|
|
|
alertMessage,
|
|
|
|
textDirection: state.metamask.textDirection,
|
|
|
|
isLoading,
|
|
|
|
loadingMessage,
|
|
|
|
isUnlocked: state.metamask.isUnlocked,
|
|
|
|
submittedPendingTransactions: submittedPendingTransactionsSelector(state),
|
2021-03-12 23:23:26 +01:00
|
|
|
isNetworkLoading: isNetworkLoading(state),
|
2020-03-26 17:18:50 +01:00
|
|
|
provider: state.metamask.provider,
|
|
|
|
frequentRpcListDetail: state.metamask.frequentRpcListDetail || [],
|
|
|
|
currentCurrency: state.metamask.currentCurrency,
|
|
|
|
isMouseUser: state.appState.isMouseUser,
|
|
|
|
providerId: getNetworkIdentifier(state),
|
|
|
|
autoLockTimeLimit,
|
2021-04-30 17:28:07 +02:00
|
|
|
browserEnvironment: state.metamask.browserEnvironment,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-03-26 17:18:50 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
function mapDispatchToProps(dispatch) {
|
2020-03-26 17:18:50 +01:00
|
|
|
return {
|
|
|
|
lockMetaMask: () => dispatch(lockMetamask(false)),
|
|
|
|
hideSidebar: () => dispatch(hideSidebar()),
|
|
|
|
setCurrentCurrencyToUSD: () => dispatch(setCurrentCurrency('usd')),
|
2020-11-03 00:41:28 +01:00
|
|
|
setMouseUserState: (isMouseUser) =>
|
|
|
|
dispatch(setMouseUserState(isMouseUser)),
|
2020-03-26 17:18:50 +01:00
|
|
|
setLastActiveTime: () => dispatch(setLastActiveTime()),
|
2020-06-01 19:54:32 +02:00
|
|
|
pageChanged: (path) => dispatch(pageChanged(path)),
|
2020-10-06 20:28:38 +02:00
|
|
|
prepareToLeaveSwaps: () => dispatch(prepareToLeaveSwaps()),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-03-26 17:18:50 +01:00
|
|
|
}
|
|
|
|
|
2020-11-03 00:41:28 +01:00
|
|
|
export default compose(
|
|
|
|
withRouter,
|
|
|
|
connect(mapStateToProps, mapDispatchToProps),
|
2021-02-04 19:15:23 +01:00
|
|
|
)(Routes);
|