import { IV3Wallet } from 'ethereumjs-wallet'; import React, { Component } from 'react'; import { generateKeystore } from 'libs/web-workers'; import { WalletType } from '../../GenerateWallet'; import Template from '../Template'; import DownloadWallet from './DownloadWallet'; import EnterPassword from './EnterPassword'; import PaperWallet from './PaperWallet'; import FinalSteps from '../FinalSteps'; export enum Steps { Password = 'password', Download = 'download', Paper = 'paper', Final = 'final' } interface State { activeStep: Steps; password: string; keystore: IV3Wallet | null | undefined; filename: string; privateKey: string; isGenerating: boolean; } export default class GenerateKeystore extends Component<{}, State> { public state: State = { activeStep: Steps.Password, password: '', keystore: null, filename: '', privateKey: '', isGenerating: false }; public render() { const { activeStep, keystore, privateKey, filename, isGenerating } = this.state; let content; switch (activeStep) { case Steps.Password: content = ( ); break; case Steps.Download: if (keystore) { content = ( ); } break; case Steps.Paper: if (keystore) { content = ( ); } break; case Steps.Final: content = ( ); break; default: content =

Uh oh. Not sure how you got here.

; } return content; } private generateWalletAndContinue = (password: string) => { this.setState({ isGenerating: true }); generateKeystore(password).then(res => { this.setState({ password, activeStep: Steps.Download, keystore: res.keystore, filename: res.filename, privateKey: res.privateKey, isGenerating: false }); }); }; private continueToPaper = () => { this.setState({ activeStep: Steps.Paper }); }; private continueToFinal = () => { this.setState({ activeStep: Steps.Final }); }; }