Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow restoring from metamask #63

Merged
merged 2 commits into from Sep 4, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

allow restoring from metamask

  • Loading branch information
diracdeltas committed Aug 29, 2019
commit 8b9935c2d85e38a4ca066cc77ba8e002afae2fbb
@@ -22,5 +22,8 @@
},
"trezorCreateSubText": {
"message": "Connect your Trezor hardware wallet to interact with dApps and make transfers to other connected wallets."
},
"metamaskImportSubText": {
"message": "Note: If importing from a Metamask wallet, enter 12 words instead of 24."
}
}
@@ -2,8 +2,13 @@ import React from 'react'
import PasswordWarning from '../password-warning'
import ImportWithSeedPhrase from '../../../../../../../ui/app/pages/first-time-flow/create-password/import-with-seed-phrase/import-with-seed-phrase.component'
import { validateMnemonic } from 'bip39'
import PropTypes from 'prop-types'

module.exports = class BraveImportWithSeedPhrase extends ImportWithSeedPhrase {
static contextTypes = {
This conversation was marked as resolved by ryanml

This comment has been minimized.

Copy link
@ryanml

ryanml Sep 2, 2019

Member

Adding metricsEvent: PropTypes.func, to this struct will fix the error mentioned in this PR. Since this one takes precedence in the override it won't be available for the non-extended functions

t: PropTypes.func,
}

componentDidMount () {
this.setState({ termsChecked: true })
}
@@ -13,7 +18,8 @@ module.exports = class BraveImportWithSeedPhrase extends ImportWithSeedPhrase {

if (seedPhrase) {
const parsedSeedPhrase = this.parseSeedPhrase(seedPhrase)
if (parsedSeedPhrase.split(' ').length !== 24) {
if (parsedSeedPhrase.split(' ').length !== 24 &&
parsedSeedPhrase.split(' ').length !== 12) {
seedPhraseError = this.context.t('seedPhraseReq')
} else if (!validateMnemonic(parsedSeedPhrase)) {
seedPhraseError = this.context.t('invalidSeedPhrase')
@@ -24,9 +30,11 @@ module.exports = class BraveImportWithSeedPhrase extends ImportWithSeedPhrase {
}

render () {
const { t } = this.context
return (
<div>
{super.render()}
<div>{t('metamaskImportSubText')}</div>
<PasswordWarning />
</div>
)
@@ -10,8 +10,11 @@ class BraveRestoreVaultPage extends RestoreVaultPage {
handleSeedPhraseChange (seedPhrase) {
let seedPhraseError = null

if (seedPhrase && this.parseSeedPhrase(seedPhrase).split(' ').length !== 24) {
seedPhraseError = this.context.t('seedPhraseReq')
if (seedPhrase) {
const words = this.parseSeedPhrase(seedPhrase).split(' ')
if (words.length !== 24 && words.length !== 12) {
seedPhraseError = this.context.t('seedPhraseReq')
}
}

this.setState({ seedPhrase, seedPhraseError })
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.