HenryNguyen5 3bea632a9a EthereumJS-Wallet (Part 2) (#310)
* Progress commit -- ethereumjs-wallet typings

* Add hdkey module + better wallet typing

* Add provider-engine typings

* Add jsdoc descriptions for hdkey constructor methods

* Fix missing return type

* Fix another missing return

* Make provider engine options optional

* Add priv/pubkey members to wallet instance

* Turn into SFC + Use ethereumjs-lib

* Use proper interface naming for V3Wallet

* Switch to ethereumjs-wallet

* Switch to ethereumjs-wallet and refactor using NewTabLink

* Use proper interface naming for V3Wallet

* Use proper interface naming for PublicKeyOnlyWallet

* Fix broken test, re-add scryptsy to make this PR pass

* Fix definition module for thirdparty wallets

* Decrease n-factor to 1024, checksum address of keystore

* Update typedef for react-dom from 15 to 16

* Lock react-dom, set typescript to 2.5.2
2017-11-07 10:42:53 -08:00

102 lines
2.6 KiB
TypeScript

import {
continueToPaper,
generateNewWallet,
resetGenerateWallet,
TContinueToPaper,
TGenerateNewWallet,
TResetGenerateWallet
} from 'actions/generateWallet';
import { IFullWallet } from 'ethereumjs-wallet';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { AppState } from 'reducers';
import DownloadWallet from './components/DownloadWallet';
import EnterPassword from './components/EnterPassword';
import PaperWallet from './components/PaperWallet';
import CryptoWarning from './components/CryptoWarning';
import TabSection from 'containers/TabSection';
interface Props {
// Redux state
activeStep: string; // FIXME union actual steps
password: string;
wallet: IFullWallet | null | undefined;
walletPasswordForm: any;
// Actions
generateNewWallet: TGenerateNewWallet;
continueToPaper: TContinueToPaper;
resetGenerateWallet: TResetGenerateWallet;
}
class GenerateWallet extends Component<Props, {}> {
public componentWillUnmount() {
this.props.resetGenerateWallet();
}
public render() {
const { activeStep, wallet, password } = this.props;
let content;
const AnyEnterPassword = EnterPassword as new () => any;
if (window.crypto) {
switch (activeStep) {
case 'password':
content = (
<AnyEnterPassword
walletPasswordForm={this.props.walletPasswordForm}
generateNewWallet={this.props.generateNewWallet}
/>
);
break;
case 'download':
if (wallet) {
content = (
<DownloadWallet
wallet={wallet}
password={password}
continueToPaper={this.props.continueToPaper}
/>
);
}
break;
case 'paper':
if (wallet) {
content = <PaperWallet wallet={wallet} />;
} else {
content = <h1>Uh oh. Not sure how you got here.</h1>;
}
break;
default:
content = <h1>Uh oh. Not sure how you got here.</h1>;
}
} else {
content = <CryptoWarning />;
}
return (
<TabSection>
<section className="Tab-content">{content}</section>
</TabSection>
);
}
}
function mapStateToProps(state: AppState) {
return {
walletPasswordForm: state.form.walletPasswordForm,
activeStep: state.generateWallet.activeStep,
password: state.generateWallet.password,
wallet: state.generateWallet.wallet
};
}
export default connect(mapStateToProps, {
generateNewWallet,
continueToPaper,
resetGenerateWallet
})(GenerateWallet);