Skip to content

Commit

Permalink
Make seed phrase import case insensitive
Browse files Browse the repository at this point in the history
The user-specified seed phrase during the first-time-flow import step
required the phrase to be entered in all lowercase. The case does not
add any extra entropy to the seed, so there's no reason to be case
sensitive. Flexibility here will improve the onboarding UX.

This commit makes the entered seed phrase case insensitive.

Fixes #8171
  • Loading branch information
marktoda committed Mar 29, 2020
1 parent 9c18fa3 commit c9d716d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Current Develop Branch
- [#7912](https://github.com/MetaMask/metamask-extension/pull/7912): Disable import button for empty string/file
- [#8246](https://github.com/MetaMask/metamask-extension/pull/8246): Make seed phrase import case-insensitive

## 7.7.0 Thu Nov 28 2019
- [#7004](https://github.com/MetaMask/metamask-extension/pull/7004): Connect distinct accounts per site
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class ImportWithSeedPhrase extends PureComponent {
return ''
}

const words = trimmed.match(/\w+/g)
const words = trimmed.toLowerCase().match(/\w+/g)
if (!words) {
return ''
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ describe('ImportWithSeedPhrase Component', function () {
assert.deepEqual(parseSeedPhrase('foo bar baz'), 'foo bar baz')
})

it('should handle a mixed-case seed phrase', function () {
const root = shallowRender({
onSubmit: sinon.spy(),
})

const { parseSeedPhrase } = root.instance()

assert.deepEqual(parseSeedPhrase('FOO bAr baZ'), 'foo bar baz')
})

it('should handle an upper-case seed phrase', function () {
const root = shallowRender({
onSubmit: sinon.spy(),
})

const { parseSeedPhrase } = root.instance()

assert.deepEqual(parseSeedPhrase('FOO BAR BAZ'), 'foo bar baz')
})

it('should trim extraneous whitespace from the given seed phrase', function () {
const root = shallowRender({
onSubmit: sinon.spy(),
Expand Down

0 comments on commit c9d716d

Please sign in to comment.