From 638bbe04283ec885997db8be6482343b7283bf7b Mon Sep 17 00:00:00 2001 From: Jacky Chan Date: Wed, 30 Aug 2017 02:05:45 -0700 Subject: [PATCH] Shuffle tokens --- .../app/first-time/backup-phrase-screen.js | 58 ++++++++++++------- mascara/src/app/first-time/index.js | 2 +- package.json | 3 + ui/app/app.js | 6 +- 4 files changed, 44 insertions(+), 25 deletions(-) diff --git a/mascara/src/app/first-time/backup-phrase-screen.js b/mascara/src/app/first-time/backup-phrase-screen.js index c3a52d94e..52ec79307 100644 --- a/mascara/src/app/first-time/backup-phrase-screen.js +++ b/mascara/src/app/first-time/backup-phrase-screen.js @@ -1,6 +1,8 @@ import React, {Component, PropTypes} from 'react' import {connect} from 'react-redux'; import classnames from 'classnames' +import shuffle from 'lodash.shuffle' +import {compose, onlyUpdateForPropTypes} from 'recompose' import Identicon from '../../../../ui/app/components/identicon' import {confirmSeedWords} from '../../../../ui/app/actions' import Breadcrumbs from './breadcrumbs' @@ -41,6 +43,7 @@ class BackupPhraseScreen extends Component { address: PropTypes.string.isRequired, seedWords: PropTypes.string.isRequired, next: PropTypes.func.isRequired, + confirmSeedWords: PropTypes.func.isRequired, }; static defaultProps = { @@ -52,14 +55,19 @@ class BackupPhraseScreen extends Component { CONFIRM: 'confirm' }; - state = { - isShowingSecret: false, - page: BackupPhraseScreen.PAGE.SECRET, - selectedSeeds: [] + constructor(props) { + super(props) + this.state = { + isShowingSecret: false, + page: BackupPhraseScreen.PAGE.SECRET, + selectedSeeds: [], + shuffledSeeds: shuffle(props.seedWords.split(' ')), + } } renderSecretWordsContainer() { - const { isShowingSecret } = this.state; + const { isShowingSecret } = this.state + return (
@@ -125,8 +134,8 @@ class BackupPhraseScreen extends Component { renderConfirmationScreen() { const { seedWords, confirmSeedWords, next } = this.props; - const { selectedSeeds } = this.state; - const isValid = seedWords === selectedSeeds.join(' ') + const { selectedSeeds, shuffledSeeds } = this.state; + const isValid = seedWords === selectedSeeds.map(([_, seed]) => seed).join(' ') return (
@@ -136,7 +145,7 @@ class BackupPhraseScreen extends Component { Please select each phrase in order to make sure it is correct.
- {selectedSeeds.map((word, i) => ( + {selectedSeeds.map(([_, word], i) => (