import React, { Component } from 'react'; import Template from './Template'; import KeystoreInput from './KeystoreInput'; import { fromPrivateKey, IFullWallet, fromV3 } from 'ethereumjs-wallet'; import { makeBlob } from 'utils/blob'; import { isValidPrivKey } from 'libs/validators'; import { stripHexPrefix } from 'libs/values'; import translate from 'translations'; import './KeystoreDetails.scss'; import { N_FACTOR } from 'config/data'; interface State { secretKey: string; password: string; fileName: string; isPasswordVisible: boolean; isPrivateKeyVisible: boolean; wallet: IFullWallet | null | undefined; } const initialState: State = { secretKey: '', password: '', isPasswordVisible: false, isPrivateKeyVisible: false, fileName: '', wallet: null }; const minLength = min => value => value && value.length >= min; const minLength9 = minLength(9); class KeystoreDetails extends Component<{}, State> { public state = initialState; public componentWillUnmount() { this.resetState(); } public render() { const { secretKey, isPasswordVisible, isPrivateKeyVisible, password, wallet, fileName } = this.state; const privateKey = stripHexPrefix(secretKey); const privateKeyValid = isValidPrivKey(privateKey); const content = (
{!wallet ? ( ) : this.runtimeKeystoreCheck() ? ( Download Keystore ) : (

Error generating a valid keystore that matches your private key. In order to protect our users, if our runtime check fails, we prevent you from downloading a potentially corrupted wallet.

)}
); return (