@@ -10,7 +10,6 @@ import suggestedMnemonics from '../../../../../common/config/crypto/valid-words.
1010import { isValidMnemonic } from '../../../../../common/config/crypto/decrypt' ;
1111import ReactToolboxMobxForm from '../../../utils/ReactToolboxMobxForm' ;
1212import { validateMnemonics } from '../../../utils/validations' ;
13- import WalletRecoveryPhraseMnemonic from './WalletRecoveryPhraseMnemonic' ;
1413import DialogCloseButton from '../../widgets/DialogCloseButton' ;
1514import DialogBackButton from '../../widgets/DialogBackButton' ;
1615import Dialog from '../../widgets/Dialog' ;
@@ -68,6 +67,7 @@ const messages = defineMessages({
6867 } ,
6968} ) ;
7069type Props = {
70+ recoveryPhrase : string ;
7171 enteredPhrase : Array < string > ;
7272 isValid : boolean ;
7373 isTermOfflineAccepted : boolean ;
@@ -101,6 +101,13 @@ class WalletRecoveryPhraseEntryDialog extends Component<Props> {
101101 this . props . onUpdateVerificationPhrase ( {
102102 verificationPhrase : enteredWords ,
103103 } ) ;
104+
105+ if ( this . props . recoveryPhrase !== enteredWords . join ( ' ' ) ) {
106+ return this . context . intl . formatMessage (
107+ messages . recoveryPhraseInvalidMnemonics
108+ ) ;
109+ }
110+
104111 return validateMnemonics ( {
105112 requiredWords : WALLET_RECOVERY_PHRASE_WORD_COUNT ,
106113 providedWords : field . value ,
@@ -120,11 +127,20 @@ class WalletRecoveryPhraseEntryDialog extends Component<Props> {
120127 vjf : vjf ( ) ,
121128 } ,
122129 options : {
130+ showErrorsOnChange : false ,
123131 validateOnChange : true ,
124132 } ,
125133 }
126134 ) ;
127135
136+ handleSubmit = ( ) => {
137+ this . form . submit ( {
138+ onSuccess : ( ) => {
139+ this . props . onFinishBackup ( ) ;
140+ } ,
141+ } ) ;
142+ } ;
143+
128144 render ( ) {
129145 const { form } = this ;
130146 const { intl } = this . context ;
@@ -139,7 +155,7 @@ class WalletRecoveryPhraseEntryDialog extends Component<Props> {
139155 canFinishBackup,
140156 onRestartBackup,
141157 onCancelBackup,
142- onFinishBackup ,
158+ recoveryPhrase ,
143159 } = this . props ;
144160 const recoveryPhraseField = form . $ ( 'recoveryPhrase' ) ;
145161 const dialogClasses = classnames ( [
@@ -152,11 +168,17 @@ class WalletRecoveryPhraseEntryDialog extends Component<Props> {
152168 ) : (
153169 < LoadingSpinner />
154170 ) ;
171+ const canSubmit =
172+ ( ! recoveryPhraseField . error &&
173+ recoveryPhraseField . value . length === recoveryPhrase . split ( ' ' ) . length &&
174+ recoveryPhraseField . value . every ( ( word ) => word ) ) ||
175+ canFinishBackup ;
176+
155177 const actions = [
156178 {
157179 label : buttonLabel ,
158- onClick : onFinishBackup ,
159- disabled : ! canFinishBackup ,
180+ onClick : this . handleSubmit ,
181+ disabled : ! canSubmit ,
160182 primary : true ,
161183 } ,
162184 ] ;
0 commit comments