2021-02-04 19:15:23 +01:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
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,
|
2021-02-04 19:15:23 +01:00
|
|
|
} from '../../store/actions';
|
|
|
|
import { INITIALIZE_BACKUP_SEED_PHRASE_ROUTE } from '../../helpers/constants/routes';
|
|
|
|
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,
|
|
|
|
},
|
2021-02-04 19:15:23 +01:00
|
|
|
} = state;
|
2020-11-03 00:41:28 +01:00
|
|
|
const showingSeedPhraseBackupAfterOnboarding = Boolean(
|
|
|
|
ownProps.location.pathname.match(INITIALIZE_BACKUP_SEED_PHRASE_ROUTE),
|
2021-02-04 19:15:23 +01:00
|
|
|
);
|
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,
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
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) => {
|
2021-02-04 19:15:23 +01:00
|
|
|
return dispatch(createNewVaultAndRestore(password, seedPhrase));
|
2019-01-23 16:25:34 +01:00
|
|
|
},
|
2020-02-15 21:34:12 +01:00
|
|
|
unlockAccount: (password) => dispatch(unlockAndGetSeedPhrase(password)),
|
2019-08-02 05:57:26 +02:00
|
|
|
verifySeedPhrase: () => verifySeedPhrase(),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
|
|
|
};
|
2019-01-23 16:25:34 +01:00
|
|
|
|
2021-02-04 19:15:23 +01:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(FirstTimeFlow);
|