2018-07-24 20:40:05 +02:00
|
|
|
import Home from './home.component'
|
|
|
|
import { compose } from 'recompose'
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { withRouter } from 'react-router-dom'
|
2019-03-22 00:03:30 +01:00
|
|
|
import { unconfirmedTransactionsCountSelector } from '../../selectors/confirm-transaction'
|
2019-11-18 22:46:28 +01:00
|
|
|
import { getCurrentEthBalance, getDaiV1Token } from '../../selectors/selectors'
|
2019-08-01 15:24:33 +02:00
|
|
|
import {
|
|
|
|
unsetMigratedPrivacyMode,
|
2019-09-16 19:11:01 +02:00
|
|
|
restoreFromThreeBox,
|
|
|
|
turnThreeBoxSyncingOn,
|
|
|
|
getThreeBoxLastUpdated,
|
2019-09-26 09:24:52 +02:00
|
|
|
setShowRestorePromptToFalse,
|
2019-08-01 15:24:33 +02:00
|
|
|
} from '../../store/actions'
|
2019-09-16 19:11:01 +02:00
|
|
|
import { setThreeBoxLastUpdated } from '../../ducks/app/app'
|
2019-08-01 15:24:33 +02:00
|
|
|
import { getEnvironmentType } from '../../../../app/scripts/lib/util'
|
|
|
|
import { ENVIRONMENT_TYPE_POPUP } from '../../../../app/scripts/lib/enums'
|
2019-07-12 17:41:39 +02:00
|
|
|
|
2018-07-24 20:40:05 +02:00
|
|
|
const mapStateToProps = state => {
|
2019-08-15 23:07:18 +02:00
|
|
|
const { metamask, appState } = state
|
2018-07-24 20:40:05 +02:00
|
|
|
const {
|
2018-08-28 20:20:30 +02:00
|
|
|
suggestedTokens,
|
2018-09-27 20:19:09 +02:00
|
|
|
providerRequests,
|
2019-08-01 15:24:33 +02:00
|
|
|
migratedPrivacyMode,
|
2019-08-02 05:57:26 +02:00
|
|
|
seedPhraseBackedUp,
|
2019-08-02 20:43:15 +02:00
|
|
|
tokens,
|
2019-09-16 19:11:01 +02:00
|
|
|
threeBoxSynced,
|
2019-09-26 09:24:52 +02:00
|
|
|
showRestorePrompt,
|
2019-09-16 19:11:01 +02:00
|
|
|
selectedAddress,
|
2018-07-24 20:40:05 +02:00
|
|
|
} = metamask
|
2019-08-02 05:57:26 +02:00
|
|
|
const accountBalance = getCurrentEthBalance(state)
|
2019-09-16 19:11:01 +02:00
|
|
|
const { forgottenPassword, threeBoxLastUpdated } = appState
|
2018-07-24 20:40:05 +02:00
|
|
|
|
2019-08-01 15:24:33 +02:00
|
|
|
const isPopup = getEnvironmentType(window.location.href) === ENVIRONMENT_TYPE_POPUP
|
|
|
|
|
2018-07-24 20:40:05 +02:00
|
|
|
return {
|
|
|
|
forgottenPassword,
|
2018-08-28 20:20:30 +02:00
|
|
|
suggestedTokens,
|
2018-07-31 07:03:20 +02:00
|
|
|
unconfirmedTransactionsCount: unconfirmedTransactionsCountSelector(state),
|
2018-09-27 20:19:09 +02:00
|
|
|
providerRequests,
|
2019-08-01 15:24:33 +02:00
|
|
|
showPrivacyModeNotification: migratedPrivacyMode,
|
2019-08-02 20:43:15 +02:00
|
|
|
shouldShowSeedPhraseReminder: !seedPhraseBackedUp && (parseInt(accountBalance, 16) > 0 || tokens.length > 0),
|
2019-08-02 22:31:26 +02:00
|
|
|
isPopup,
|
2019-09-16 19:11:01 +02:00
|
|
|
threeBoxSynced,
|
2019-09-26 09:24:52 +02:00
|
|
|
showRestorePrompt,
|
2019-09-16 19:11:01 +02:00
|
|
|
selectedAddress,
|
|
|
|
threeBoxLastUpdated,
|
2019-11-18 22:46:28 +01:00
|
|
|
hasDaiV1Token: Boolean(getDaiV1Token(state)),
|
2018-07-24 20:40:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-01 15:24:33 +02:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
unsetMigratedPrivacyMode: () => dispatch(unsetMigratedPrivacyMode()),
|
2019-09-16 19:11:01 +02:00
|
|
|
turnThreeBoxSyncingOn: () => dispatch(turnThreeBoxSyncingOn()),
|
|
|
|
setupThreeBox: () => {
|
|
|
|
dispatch(getThreeBoxLastUpdated())
|
|
|
|
.then(lastUpdated => {
|
|
|
|
if (lastUpdated) {
|
|
|
|
dispatch(setThreeBoxLastUpdated(lastUpdated))
|
|
|
|
} else {
|
2019-09-26 09:24:52 +02:00
|
|
|
dispatch(setShowRestorePromptToFalse())
|
2019-09-16 19:11:01 +02:00
|
|
|
dispatch(turnThreeBoxSyncingOn())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
restoreFromThreeBox: (address) => dispatch(restoreFromThreeBox(address)),
|
2019-09-26 09:24:52 +02:00
|
|
|
setShowRestorePromptToFalse: () => dispatch(setShowRestorePromptToFalse()),
|
2019-08-01 15:24:33 +02:00
|
|
|
})
|
|
|
|
|
2018-07-24 20:40:05 +02:00
|
|
|
export default compose(
|
|
|
|
withRouter,
|
2019-08-01 15:24:33 +02:00
|
|
|
connect(mapStateToProps, mapDispatchToProps)
|
2018-07-24 20:40:05 +02:00
|
|
|
)(Home)
|