1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Complete onboarding upon importing/verifying seed (#8873)

Fixes #8679
This commit is contained in:
ryanml 2020-07-27 14:03:26 -07:00 committed by GitHub
parent 57715a8da1
commit d9f07a796d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 16 deletions

View File

@ -19,6 +19,7 @@ export default class ImportWithSeedPhrase extends PureComponent {
onSubmit: PropTypes.func.isRequired, onSubmit: PropTypes.func.isRequired,
setSeedPhraseBackedUp: PropTypes.func, setSeedPhraseBackedUp: PropTypes.func,
initializeThreeBox: PropTypes.func, initializeThreeBox: PropTypes.func,
completeOnboarding: PropTypes.func,
} }
state = { state = {
@ -119,7 +120,7 @@ export default class ImportWithSeedPhrase extends PureComponent {
} }
const { password, seedPhrase } = this.state const { password, seedPhrase } = this.state
const { history, onSubmit, setSeedPhraseBackedUp, initializeThreeBox } = this.props const { history, onSubmit, setSeedPhraseBackedUp, initializeThreeBox, completeOnboarding } = this.props
try { try {
await onSubmit(password, this.parseSeedPhrase(seedPhrase)) await onSubmit(password, this.parseSeedPhrase(seedPhrase))
@ -131,7 +132,8 @@ export default class ImportWithSeedPhrase extends PureComponent {
}, },
}) })
setSeedPhraseBackedUp(true).then(() => { setSeedPhraseBackedUp(true).then(async () => {
await completeOnboarding()
initializeThreeBox() initializeThreeBox()
history.push(INITIALIZE_END_OF_FLOW_ROUTE) history.push(INITIALIZE_END_OF_FLOW_ROUTE)
}) })

View File

@ -3,12 +3,14 @@ import ImportWithSeedPhrase from './import-with-seed-phrase.component'
import { import {
setSeedPhraseBackedUp, setSeedPhraseBackedUp,
initializeThreeBox, initializeThreeBox,
setCompletedOnboarding,
} from '../../../../store/actions' } from '../../../../store/actions'
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => {
return { return {
setSeedPhraseBackedUp: (seedPhraseBackupState) => dispatch(setSeedPhraseBackedUp(seedPhraseBackupState)), setSeedPhraseBackedUp: (seedPhraseBackupState) => dispatch(setSeedPhraseBackedUp(seedPhraseBackupState)),
initializeThreeBox: () => dispatch(initializeThreeBox()), initializeThreeBox: () => dispatch(initializeThreeBox()),
completeOnboarding: () => dispatch(setCompletedOnboarding()),
} }
} }

View File

@ -14,7 +14,6 @@ export default class EndOfFlowScreen extends PureComponent {
static propTypes = { static propTypes = {
history: PropTypes.object, history: PropTypes.object,
completeOnboarding: PropTypes.func,
completionMetaMetricsName: PropTypes.string, completionMetaMetricsName: PropTypes.string,
onboardingInitiator: PropTypes.exact({ onboardingInitiator: PropTypes.exact({
location: PropTypes.string, location: PropTypes.string,
@ -23,9 +22,8 @@ export default class EndOfFlowScreen extends PureComponent {
} }
onComplete = async () => { onComplete = async () => {
const { history, completeOnboarding, completionMetaMetricsName, onboardingInitiator } = this.props const { history, completionMetaMetricsName, onboardingInitiator } = this.props
await completeOnboarding()
this.context.metricsEvent({ this.context.metricsEvent({
eventOpts: { eventOpts: {
category: 'Onboarding', category: 'Onboarding',

View File

@ -1,6 +1,5 @@
import { connect } from 'react-redux' import { connect } from 'react-redux'
import EndOfFlow from './end-of-flow.component' import EndOfFlow from './end-of-flow.component'
import { setCompletedOnboarding } from '../../../store/actions'
import { getOnboardingInitiator } from '../../../selectors' import { getOnboardingInitiator } from '../../../selectors'
const firstTimeFlowTypeNameMap = { const firstTimeFlowTypeNameMap = {
@ -17,10 +16,4 @@ const mapStateToProps = (state) => {
} }
} }
const mapDispatchToProps = (dispatch) => { export default connect(mapStateToProps)(EndOfFlow)
return {
completeOnboarding: () => dispatch(setCompletedOnboarding()),
}
}
export default connect(mapStateToProps, mapDispatchToProps)(EndOfFlow)

View File

@ -12,7 +12,6 @@ describe('End of Flow Screen', function () {
history: { history: {
push: sinon.spy(), push: sinon.spy(),
}, },
completeOnboarding: sinon.spy(),
} }
beforeEach(function () { beforeEach(function () {
@ -30,7 +29,6 @@ describe('End of Flow Screen', function () {
endOfFlowButton.simulate('click') endOfFlowButton.simulate('click')
setImmediate(() => { setImmediate(() => {
assert(props.completeOnboarding.calledOnce)
assert(props.history.push.calledOnceWithExactly(DEFAULT_ROUTE)) assert(props.history.push.calledOnceWithExactly(DEFAULT_ROUTE))
done() done()
}) })

View File

@ -26,6 +26,7 @@ export default class ConfirmSeedPhrase extends PureComponent {
seedPhrase: PropTypes.string, seedPhrase: PropTypes.string,
initializeThreeBox: PropTypes.func, initializeThreeBox: PropTypes.func,
setSeedPhraseBackedUp: PropTypes.func, setSeedPhraseBackedUp: PropTypes.func,
completeOnboarding: PropTypes.func,
} }
state = { state = {
@ -66,6 +67,10 @@ export default class ConfirmSeedPhrase extends PureComponent {
exportAsFile('', this.props.seedPhrase, 'text/plain') exportAsFile('', this.props.seedPhrase, 'text/plain')
} }
setOnboardingCompleted = async () => {
await this.props.completeOnboarding()
}
handleSubmit = async () => { handleSubmit = async () => {
const { const {
history, history,
@ -86,8 +91,9 @@ export default class ConfirmSeedPhrase extends PureComponent {
}, },
}) })
setSeedPhraseBackedUp(true).then(() => { setSeedPhraseBackedUp(true).then(async () => {
initializeThreeBox() initializeThreeBox()
this.setOnboardingCompleted()
history.push(INITIALIZE_END_OF_FLOW_ROUTE) history.push(INITIALIZE_END_OF_FLOW_ROUTE)
}) })
} catch (error) { } catch (error) {

View File

@ -3,12 +3,14 @@ import ConfirmSeedPhrase from './confirm-seed-phrase.component'
import { import {
setSeedPhraseBackedUp, setSeedPhraseBackedUp,
initializeThreeBox, initializeThreeBox,
setCompletedOnboarding,
} from '../../../../store/actions' } from '../../../../store/actions'
const mapDispatchToProps = (dispatch) => { const mapDispatchToProps = (dispatch) => {
return { return {
setSeedPhraseBackedUp: (seedPhraseBackupState) => dispatch(setSeedPhraseBackedUp(seedPhraseBackupState)), setSeedPhraseBackedUp: (seedPhraseBackupState) => dispatch(setSeedPhraseBackedUp(seedPhraseBackupState)),
initializeThreeBox: () => dispatch(initializeThreeBox()), initializeThreeBox: () => dispatch(initializeThreeBox()),
completeOnboarding: () => dispatch(setCompletedOnboarding()),
} }
} }

View File

@ -142,6 +142,7 @@ describe('ConfirmSeedPhrase Component', function () {
history: { push: pushSpy }, history: { push: pushSpy },
setSeedPhraseBackedUp: () => Promise.resolve(), setSeedPhraseBackedUp: () => Promise.resolve(),
initializeThreeBox: initialize3BoxSpy, initializeThreeBox: initialize3BoxSpy,
completeOnboarding: sinon.spy(),
}, },
{ {
metricsEvent: metricsEventSpy, metricsEvent: metricsEventSpy,