-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow for 24 length seedphrase on import (#1848)
* Allow for 24 length seedphrase on import, closes #1838 * call toggleHideSeedPhraseInput onScanError * Update broken seed phrase translation keys * Add proper logging for when seed phrase does fail * Validate mnemonic with ethers * Add tests for failedSeedPhraseRequirements
- Loading branch information
1 parent
ba0cf53
commit ebe4745
Showing
7 changed files
with
442 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// eslint-disable-next-line import/prefer-default-export | ||
export const failedSeedPhraseRequirements = seed => { | ||
const wordCount = seed.split(/\s/u).length; | ||
return wordCount % 3 !== 0 || wordCount > 24 || wordCount < 12; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { failedSeedPhraseRequirements } from './validators'; | ||
|
||
const VALID_24 = | ||
'verb middle giant soon wage common wide tool gentle garlic issue nut retreat until album recall expire bronze bundle live accident expect dry cook'; | ||
const VALID_12 = VALID_24.split(' ') | ||
.splice(0, 12) | ||
.join(' '); | ||
|
||
describe('failedSeedPhraseRequirements', () => { | ||
it('Should pass for 12 word mnemonic', () => { | ||
expect(failedSeedPhraseRequirements(VALID_12)).toEqual(false); | ||
}); | ||
it('Should pass for 24 word mnemonic', () => { | ||
expect(failedSeedPhraseRequirements(VALID_24)).toEqual(false); | ||
}); | ||
it('Should fail for 12 + 1 word mnemonic', () => { | ||
const plus_one = VALID_12 + ' lol'; | ||
expect(failedSeedPhraseRequirements(plus_one)).toEqual(true); | ||
}); | ||
it('Should fail for 24 + 1 word mnemonic', () => { | ||
const plus_one = VALID_24 + ' lol'; | ||
expect(failedSeedPhraseRequirements(plus_one)).toEqual(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.