Handle key suri parsing errors (#1104)

This commit is contained in:
Jaco Greeff 2019-05-08 13:09:39 +02:00 committed by GitHub
parent 666a52bcd8
commit c673d17839
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -85,7 +85,7 @@ function rawValidate (seed: string): boolean {
function addressFromSeed (phrase: string, derivePath: string, pairType: KeypairType): string {
return keyring
.createFromUri(`${phrase}${derivePath}`, {}, pairType)
.createFromUri(`${phrase.trim()}${derivePath}`, {}, pairType)
.address();
}
@ -346,13 +346,17 @@ class Creator extends React.PureComponent<Props, State> {
let address = prevState.address;
const deriveError = deriveValidate(derivePath, pairType);
const isNameValid = !!name;
const isSeedValid = seedType === 'raw'
const isPassValid = keyring.isPassValid(password);
let isSeedValid = seedType === 'raw'
? rawValidate(seed)
: mnemonicValidate(seed);
const isPassValid = keyring.isPassValid(password);
if (!deriveError && isSeedValid && (seed !== prevState.seed || derivePath !== prevState.derivePath || pairType !== prevState.pairType)) {
address = addressFromSeed(seed, derivePath, pairType);
try {
address = addressFromSeed(seed, derivePath, pairType);
} catch (error) {
isSeedValid = false;
}
}
return {