2019-01-23 16:25:34 +01:00
|
|
|
import { connect } from 'react-redux'
|
2020-05-04 17:22:34 +02:00
|
|
|
import { getFirstTimeFlowTypeRoute } from '../../selectors'
|
2019-01-23 16:25:34 +01:00
|
|
|
import {
|
|
|
|
createNewVaultAndGetSeedPhrase,
|
|
|
|
createNewVaultAndRestore,
|
|
|
|
unlockAndGetSeedPhrase,
|
2019-08-02 05:57:26 +02:00
|
|
|
verifySeedPhrase,
|
2019-03-22 00:03:30 +01:00
|
|
|
} from '../../store/actions'
|
2020-11-03 00:41:28 +01:00
|
|
|
import { INITIALIZE_BACKUP_SEED_PHRASE_ROUTE } from '../../helpers/constants/routes'
|
2020-08-18 21:18:25 +02:00
|
|
|
import FirstTimeFlow from './first-time-flow.component'
|
2019-01-23 16:25:34 +01:00
|
|
|
|
2019-08-06 05:24:19 +02:00
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2020-11-03 00:41:28 +01:00
|
|
|
const {
|
|
|
|
metamask: {
|
|
|
|
completedOnboarding,
|
|
|
|
isInitialized,
|
|
|
|
isUnlocked,
|
|
|
|
seedPhraseBackedUp,
|
|
|
|
},
|
|
|
|
} = state
|
|
|
|
const showingSeedPhraseBackupAfterOnboarding = Boolean(
|
|
|
|
ownProps.location.pathname.match(INITIALIZE_BACKUP_SEED_PHRASE_ROUTE),
|
|
|
|
)
|
2019-01-23 16:25:34 +01:00
|
|
|
|
|
|
|
return {
|
|
|
|
completedOnboarding,
|
|
|
|
isInitialized,
|
|
|
|
isUnlocked,
|
2019-03-05 16:45:01 +01:00
|
|
|
nextRoute: getFirstTimeFlowTypeRoute(state),
|
2019-08-02 05:57:26 +02:00
|
|
|
showingSeedPhraseBackupAfterOnboarding,
|
|
|
|
seedPhraseBackedUp,
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
const mapDispatchToProps = (dispatch) => {
|
2019-01-23 16:25:34 +01:00
|
|
|
return {
|
2020-11-03 00:41:28 +01:00
|
|
|
createNewAccount: (password) =>
|
|
|
|
dispatch(createNewVaultAndGetSeedPhrase(password)),
|
2019-01-23 16:25:34 +01:00
|
|
|
createNewAccountFromSeed: (password, seedPhrase) => {
|
|
|
|
return dispatch(createNewVaultAndRestore(password, seedPhrase))
|
|
|
|
},
|
2020-02-15 21:34:12 +01:00
|
|
|
unlockAccount: (password) => dispatch(unlockAndGetSeedPhrase(password)),
|
2019-08-02 05:57:26 +02:00
|
|
|
verifySeedPhrase: () => verifySeedPhrase(),
|
2019-01-23 16:25:34 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(FirstTimeFlow)
|