@@ -4,7 +4,7 @@ import { observer } from 'mobx-react';
44import classnames from 'classnames' ;
55import { Autocomplete } from 'react-polymorph/lib/components/Autocomplete' ;
66import { Input } from 'react-polymorph/lib/components/Input' ;
7- import { defineMessages , intlShape , FormattedHTMLMessage } from 'react-intl' ;
7+ import { defineMessages , FormattedHTMLMessage , intlShape } from 'react-intl' ;
88import vjf from 'mobx-react-form/lib/validators/VJF' ;
99import SVGInline from 'react-svg-inline' ;
1010import { PopOver } from 'react-polymorph/lib/components/PopOver' ;
@@ -16,10 +16,9 @@ import ReactToolboxMobxForm, {
1616import DialogCloseButton from '../widgets/DialogCloseButton' ;
1717import Dialog from '../widgets/Dialog' ;
1818import {
19- isValidWalletName ,
20- isValidSpendingPassword ,
2119 isValidRepeatPassword ,
22- errorOrIncompleteMarker ,
20+ isValidSpendingPassword ,
21+ isValidWalletName ,
2322 validateMnemonics ,
2423} from '../../utils/validations' ;
2524import globalMessages from '../../i18n/global-messages' ;
@@ -28,8 +27,8 @@ import { FORM_VALIDATION_DEBOUNCE_WAIT } from '../../config/timingConfig';
2827import styles from './WalletRestoreDialog.scss' ;
2928import { submitOnEnter } from '../../utils/form' ;
3029import {
31- WALLET_RESTORE_TYPES ,
3230 RECOVERY_PHRASE_WORD_COUNT_OPTIONS ,
31+ WALLET_RESTORE_TYPES ,
3332} from '../../config/walletsConfig' ;
3433import {
3534 LEGACY_WALLET_RECOVERY_PHRASE_WORD_COUNT ,
@@ -38,6 +37,7 @@ import {
3837} from '../../config/cryptoConfig' ;
3938import infoIconInline from '../../assets/images/info-icon.inline.svg' ;
4039import LoadingSpinner from '../widgets/LoadingSpinner' ;
40+ import { MnemonicInput } from './mnemonic-input' ;
4141
4242const messages = defineMessages ( {
4343 title : {
@@ -87,23 +87,11 @@ const messages = defineMessages({
8787 description :
8888 'Label for the recovery phrase input on the wallet restore dialog.' ,
8989 } ,
90- recoveryPhraseInputHint : {
91- id : 'wallet.restore.dialog.recovery.phrase.input.hint' ,
92- defaultMessage : '!!!Enter recovery phrase' ,
93- description :
94- 'Hint "Enter recovery phrase" for the recovery phrase input on the wallet restore dialog.' ,
95- } ,
9690 newLabel : {
9791 id : 'wallet.restore.dialog.recovery.phrase.newLabel' ,
9892 defaultMessage : '!!!New' ,
9993 description : 'Label "new" on the wallet restore dialog.' ,
10094 } ,
101- recoveryPhraseNoResults : {
102- id : 'wallet.restore.dialog.recovery.phrase.input.noResults' ,
103- defaultMessage : '!!!No results' ,
104- description :
105- '"No results" message for the recovery phrase input search results.' ,
106- } ,
10795 importButtonLabel : {
10896 id : 'wallet.restore.dialog.restore.wallet.button.label' ,
10997 defaultMessage : '!!!Restore wallet' ,
@@ -167,19 +155,6 @@ const messages = defineMessages({
167155 description :
168156 'Label for the shielded recovery phrase input on the wallet restore dialog.' ,
169157 } ,
170- shieldedRecoveryPhraseInputHint : {
171- id : 'wallet.restore.dialog.shielded.recovery.phrase.input.hint' ,
172- defaultMessage :
173- '!!!Enter your {numberOfWords}-word paper wallet recovery phrase' ,
174- description :
175- 'Hint "Enter your 27-word paper wallet recovery phrase." for the recovery phrase input on the wallet restore dialog.' ,
176- } ,
177- shieldedRecoveryPhraseInputPlaceholder : {
178- id : 'wallet.restore.dialog.shielded.recovery.phrase.input.placeholder' ,
179- defaultMessage : '!!!Enter word #{wordNumber}' ,
180- description :
181- 'Placeholder "Enter word #" for the recovery phrase input on the wallet restore dialog.' ,
182- } ,
183158 restorePaperWalletButtonLabel : {
184159 id : 'wallet.restore.dialog.paper.wallet.button.label' ,
185160 defaultMessage : '!!!Restore paper wallet' ,
@@ -326,6 +301,7 @@ class WalletRestoreDialog extends Component<Props, State> {
326301 } ,
327302 options : {
328303 validateOnChange : true ,
304+ showErrorsOnChange : false ,
329305 validationDebounceWait : FORM_VALIDATION_DEBOUNCE_WAIT ,
330306 } ,
331307 }
@@ -364,8 +340,6 @@ class WalletRestoreDialog extends Component<Props, State> {
364340 recoveryPhraseField . debouncedValidation . cancel ( ) ;
365341 recoveryPhraseField . reset ( ) ;
366342 recoveryPhraseField . showErrors ( false ) ;
367- // Autocomplete has to be reset manually
368- this . recoveryPhraseAutocomplete . clear ( ) ;
369343 } ;
370344
371345 render ( ) {
@@ -406,6 +380,8 @@ class WalletRestoreDialog extends Component<Props, State> {
406380 'yoroiTab' ,
407381 this . isYoroi ( ) ? styles . activeButton : '' ,
408382 ] ) ;
383+ const { reset, ...mnemonicInputProps } = recoveryPhraseField . bind ( ) ;
384+
409385 return (
410386 < Dialog
411387 className = { dialogClasses }
@@ -554,44 +530,18 @@ class WalletRestoreDialog extends Component<Props, State> {
554530 ] }
555531 />
556532 ) }
557-
558- < Autocomplete
559- { ...recoveryPhraseField . bind ( ) }
560- ref = { ( autocomplete ) => {
561- this . recoveryPhraseAutocomplete = autocomplete ;
562- } }
533+ < MnemonicInput
534+ { ...mnemonicInputProps }
563535 label = {
564- ! this . isCertificate ( )
565- ? intl . formatMessage ( messages . recoveryPhraseInputLabel )
566- : intl . formatMessage ( messages . shieldedRecoveryPhraseInputLabel )
567- }
568- placeholder = {
569- ! this . isCertificate ( )
570- ? intl . formatMessage ( messages . recoveryPhraseInputHint )
571- : intl . formatMessage (
572- messages . shieldedRecoveryPhraseInputPlaceholder ,
573- {
574- wordNumber : recoveryPhraseField . value . length + 1 ,
575- }
576- )
536+ this . isCertificate ( )
537+ ? intl . formatMessage ( messages . shieldedRecoveryPhraseInputLabel )
538+ : intl . formatMessage ( messages . recoveryPhraseInputLabel )
577539 }
578- options = { suggestedMnemonics }
579- requiredSelections = { [ RECOVERY_PHRASE_WORD_COUNT_OPTIONS [ walletType ] ] }
580- requiredSelectionsInfo = { ( required , actual ) =>
581- intl . formatMessage ( globalMessages . knownMnemonicWordCount , {
582- actual,
583- required,
584- } )
585- }
586- maxSelections = { RECOVERY_PHRASE_WORD_COUNT_OPTIONS [ walletType ] }
587- error = { errorOrIncompleteMarker ( recoveryPhraseField . error ) }
588- maxVisibleOptions = { 5 }
589- noResultsMessage = { intl . formatMessage (
590- messages . recoveryPhraseNoResults
591- ) }
592- optionHeight = { 50 }
540+ availableWords = { suggestedMnemonics }
541+ wordCount = { RECOVERY_PHRASE_WORD_COUNT_OPTIONS [ walletType ] }
542+ error = { recoveryPhraseField . error }
543+ reset = { form . resetting }
593544 />
594-
595545 < div className = { styles . spendingPasswordWrapper } >
596546 < div className = { styles . passwordSectionLabel } >
597547 { intl . formatMessage ( messages . passwordSectionLabel ) }
0 commit comments