import React, { Component } from 'react' import PropTypes from 'prop-types' import { connect } from 'react-redux' import classnames from 'classnames' import { withRouter } from 'react-router-dom' import { compose } from 'recompose' import Identicon from '../../../../ui/app/components/identicon' import Breadcrumbs from './breadcrumbs' import LoadingScreen from './loading-screen' import { DEFAULT_ROUTE, INITIALIZE_CONFIRM_SEED_ROUTE } from '../../../../ui/app/routes' import { confirmSeedWords } from '../../../../ui/app/actions' const LockIcon = props => ( ) class BackupPhraseScreen extends Component { static propTypes = { isLoading: PropTypes.bool.isRequired, address: PropTypes.string.isRequired, seedWords: PropTypes.string, history: PropTypes.object, isRevealingSeedWords: PropTypes.bool, clearSeedWords: PropTypes.func, }; static defaultProps = { seedWords: '', } constructor (props) { super(props) this.state = { isShowingSecret: false, } } componentWillMount () { this.checkSeedWords() } componentDidUpdate () { this.checkSeedWords() } checkSeedWords () { const { seedWords, history } = this.props if (!seedWords) { history.push(DEFAULT_ROUTE) } } renderSecretWordsContainer () { const { isShowingSecret } = this.state return (
{this.props.seedWords}
{!isShowingSecret && (
this.setState({ isShowingSecret: true })} >
Click here to reveal secret words
)}
) } renderSubmitButton () { const { isRevealingSeedWords, clearSeedWords, history } = this.props const { isShowingSecret } = this.state return isRevealingSeedWords ? : } renderSecretScreen () { const { isRevealingSeedWords } = this.props return (
Secret Backup Phrase
Your secret backup phrase makes it easy to back up and restore your account.
WARNING: Never disclose your backup phrase. Anyone with this phrase can take your Ether forever.
{this.renderSecretWordsContainer()}
Tips:
Store this phrase in a password manager like 1password.
Write this phrase on a piece of paper and store in a secure location. If you want even more security, write it down on multiple pieces of paper and store each in 2 - 3 different locations.
Memorize this phrase.
{ this.renderSubmitButton() } { !isRevealingSeedWords && }
) } render () { return this.props.isLoading ? : (
{this.renderSecretScreen()}
) } } const mapStateToProps = ({ metamask, appState }) => { const { selectedAddress, seedWords, isRevealingSeedWords } = metamask const { isLoading } = appState return { seedWords, isRevealingSeedWords, isLoading, address: selectedAddress, } } const mapDispatchToProps = dispatch => { return { clearSeedWords: () => dispatch(confirmSeedWords()), } } export default compose( withRouter, connect(mapStateToProps, mapDispatchToProps), )(BackupPhraseScreen)