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,
|
2022-03-07 19:53:19 +01:00
|
|
|
getTheme,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../selectors';
|
2020-03-26 17:18:50 +01:00
|
|
|
import {
|
|
|
|
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';
|
2022-03-24 16:51:22 +01:00
|
|
|
import { getSendStage } from '../../ducks/send';
|
2021-02-04 19:15:23 +01:00
|
|
|
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;
|
2021-09-09 17:14:07 +02:00
|
|
|
const { alertOpen, alertMessage, isLoading, loadingMessage } = appState;
|
2021-02-04 19:15:23 +01:00
|
|
|
const { autoLockTimeLimit = 0 } = getPreferences(state);
|
2020-03-26 17:18:50 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
alertOpen,
|
|
|
|
alertMessage,
|
|
|
|
textDirection: state.metamask.textDirection,
|
|
|
|
isLoading,
|
|
|
|
loadingMessage,
|
|
|
|
isUnlocked: state.metamask.isUnlocked,
|
2021-03-12 23:23:26 +01:00
|
|
|
isNetworkLoading: isNetworkLoading(state),
|
2020-03-26 17:18:50 +01:00
|
|
|
currentCurrency: state.metamask.currentCurrency,
|
|
|
|
isMouseUser: state.appState.isMouseUser,
|
|
|
|
autoLockTimeLimit,
|
2021-12-01 17:25:09 +01:00
|
|
|
browserEnvironmentOs: state.metamask.browserEnvironment?.os,
|
|
|
|
browserEnvironmentContainter: state.metamask.browserEnvironment?.browser,
|
|
|
|
providerId: getNetworkIdentifier(state),
|
|
|
|
providerType: state.metamask.provider?.type,
|
2022-03-07 19:53:19 +01:00
|
|
|
theme: getTheme(state),
|
2022-03-24 16:51:22 +01:00
|
|
|
sendStage: getSendStage(state),
|
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)),
|
|
|
|
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);
|