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 {
|
2022-09-14 17:35:59 +02:00
|
|
|
getAllAccountsOnNetworkAreEmpty,
|
2022-08-23 17:04:07 +02:00
|
|
|
getIsNetworkUsed,
|
2020-03-26 17:18:50 +01:00
|
|
|
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,
|
2022-09-14 17:35:59 +02:00
|
|
|
getIsTestnet,
|
2022-09-19 17:39:28 +02:00
|
|
|
getCurrentChainId,
|
2022-09-19 19:40:30 +02:00
|
|
|
getShouldShowSeedPhraseReminder,
|
2022-10-27 12:25:30 +02:00
|
|
|
isCurrentProviderCustom,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../selectors';
|
2020-03-26 17:18:50 +01:00
|
|
|
import {
|
|
|
|
lockMetamask,
|
|
|
|
setCurrentCurrency,
|
|
|
|
setLastActiveTime,
|
|
|
|
setMouseUserState,
|
2023-03-22 11:00:08 +01:00
|
|
|
toggleAccountMenu,
|
2023-04-13 18:54:03 +02:00
|
|
|
toggleNetworkMenu,
|
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';
|
2023-05-02 14:36:24 +02:00
|
|
|
import { getProviderConfig } from '../../ducks/metamask/metamask';
|
2023-06-22 18:29:24 +02:00
|
|
|
import { DEFAULT_AUTO_LOCK_TIME_LIMIT } from '../../../shared/constants/preferences';
|
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;
|
2023-06-22 18:29:24 +02:00
|
|
|
const { autoLockTimeLimit = DEFAULT_AUTO_LOCK_TIME_LIMIT } =
|
|
|
|
getPreferences(state);
|
2022-12-08 17:42:23 +01:00
|
|
|
const { completedOnboarding } = state.metamask;
|
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),
|
2023-05-02 14:36:24 +02:00
|
|
|
providerType: getProviderConfig(state).type,
|
2022-03-07 19:53:19 +01:00
|
|
|
theme: getTheme(state),
|
2022-03-24 16:51:22 +01:00
|
|
|
sendStage: getSendStage(state),
|
2022-08-23 17:04:07 +02:00
|
|
|
isNetworkUsed: getIsNetworkUsed(state),
|
2022-09-14 17:35:59 +02:00
|
|
|
allAccountsOnNetworkAreEmpty: getAllAccountsOnNetworkAreEmpty(state),
|
2022-09-19 17:39:28 +02:00
|
|
|
isTestNet: getIsTestnet(state),
|
|
|
|
currentChainId: getCurrentChainId(state),
|
2022-09-19 19:40:30 +02:00
|
|
|
shouldShowSeedPhraseReminder: getShouldShowSeedPhraseReminder(state),
|
2022-10-11 17:05:03 +02:00
|
|
|
forgottenPassword: state.metamask.forgottenPassword,
|
2022-10-27 12:25:30 +02:00
|
|
|
isCurrentProviderCustom: isCurrentProviderCustom(state),
|
2022-12-08 17:42:23 +01:00
|
|
|
completedOnboarding,
|
2023-03-22 11:00:08 +01:00
|
|
|
isAccountMenuOpen: state.metamask.isAccountMenuOpen,
|
2023-04-13 18:54:03 +02:00
|
|
|
isNetworkMenuOpen: state.metamask.isNetworkMenuOpen,
|
2023-05-03 19:09:13 +02:00
|
|
|
accountDetailsAddress: state.appState.accountDetailsAddress,
|
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()),
|
2023-03-22 11:00:08 +01:00
|
|
|
toggleAccountMenu: () => dispatch(toggleAccountMenu()),
|
2023-04-13 18:54:03 +02:00
|
|
|
toggleNetworkMenu: () => dispatch(toggleNetworkMenu()),
|
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);
|