Merge pull request #19 from MyEtherWallet/cleanup-v2

Cleanup round #2
This commit is contained in:
Daniel Ternyak 2017-06-20 18:48:06 -05:00 committed by GitHub
commit 59b0d446f2
10 changed files with 322 additions and 316 deletions

View File

@ -1,21 +1,22 @@
export const GENERATE_WALLET_SHOW_PASSWORD = 'GENERATE_WALLET_SHOW_PASSWORD'; import {
export const GENERATE_WALLET_FILE = 'GENERATE_WALLET_FILE' GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER,
export const GENERATE_WALLET_HAS_DOWNLOADED_FILE = 'GENERATE_WALLET_HAS_DOWNLOADED_FILE' GENERATE_WALLET_FILE,
export const GENERATE_WALLET_CONTINUE_TO_PAPER = 'GENERATE_WALLET_CONTINUE_TO_PAPER' GENERATE_WALLET_DOWNLOAD_FILE,
GENERATE_WALLET_SHOW_PASSWORD
} from 'actions/generateWalletConstants';
export const showPasswordGenerateWallet = () => {
return { type: GENERATE_WALLET_SHOW_PASSWORD };
};
export const SHOW_GENERATE_WALLET_PASSWORD_ACTION = () => Object ({ export const generateFileGenerateWallet = () => {
type: GENERATE_WALLET_SHOW_PASSWORD return { type: GENERATE_WALLET_FILE };
}) };
export const GENERATE_WALLET_FILE_ACTION = () => Object ({ export const downloadFileGenerateWallet = () => {
type: GENERATE_WALLET_FILE return { type: GENERATE_WALLET_DOWNLOAD_FILE };
}) };
export const GENERATE_WALLET_HAS_DOWNLOADED_FILE_ACTION = () => Object ({ export const confirmContinueToPaperGenerateWallet = () => {
type: GENERATE_WALLET_HAS_DOWNLOADED_FILE return { type: GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER };
}) };
export const GENERATE_WALLET_CONTINUE_TO_PAPER_ACTION = () => Object ({
type: GENERATE_WALLET_CONTINUE_TO_PAPER
})

View File

@ -0,0 +1,5 @@
export const GENERATE_WALLET_SHOW_PASSWORD = 'GENERATE_WALLET_SHOW_PASSWORD';
export const GENERATE_WALLET_FILE = 'GENERATE_WALLET_FILE';
export const GENERATE_WALLET_DOWNLOAD_FILE = 'GENERATE_WALLET_DOWNLOAD_FILE';
export const GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER =
'GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER';

View File

@ -6,35 +6,35 @@ import {
SWAP_UPDATE_BITY_RATES SWAP_UPDATE_BITY_RATES
} from './swapConstants'; } from './swapConstants';
export const SWAP_ORIGIN_KIND_TO = value => { export const originKindSwap = value => {
return { return {
type: SWAP_ORIGIN_KIND, type: SWAP_ORIGIN_KIND,
value value
}; };
}; };
export const SWAP_DESTINATION_KIND_TO = value => { export const destinationKindSwap = value => {
return { return {
type: SWAP_DESTINATION_KIND, type: SWAP_DESTINATION_KIND,
value value
}; };
}; };
export const SWAP_ORIGIN_AMOUNT_TO = value => { export const originAmountSwap = value => {
return { return {
type: SWAP_ORIGIN_AMOUNT, type: SWAP_ORIGIN_AMOUNT,
value value
}; };
}; };
export const SWAP_DESTINATION_AMOUNT_TO = value => { export const destinationAmountSwap = value => {
return { return {
type: SWAP_DESTINATION_AMOUNT, type: SWAP_DESTINATION_AMOUNT,
value value
}; };
}; };
export const SWAP_UPDATE_BITY_RATES_TO = value => { export const updateBityRatesSwap = value => {
return { return {
type: SWAP_UPDATE_BITY_RATES, type: SWAP_UPDATE_BITY_RATES,
value value

View File

@ -1,141 +1,159 @@
import React, {Component} from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import {Field, reduxForm} from 'redux-form'; import { Field, reduxForm } from 'redux-form';
import GenerateWalletPasswordInputComponent from './GenerateWalletPasswordInputComponent'; import GenerateWalletPasswordInputComponent from './GenerateWalletPasswordInputComponent';
import LedgerTrezorWarning from './LedgerTrezorWarning'; import LedgerTrezorWarning from './LedgerTrezorWarning';
import translate from 'translations'; import translate from 'translations';
// VALIDATORS // VALIDATORS
const minLength = min => value => { const minLength = min => value => {
return value && value.length < min ? `Must be ${min} characters or more` : undefined return value && value.length < min
? `Must be ${min} characters or more`
: undefined;
}; };
const minLength9 = minLength(9); const minLength9 = minLength(9);
const required = value => value ? undefined : 'Required'; const required = value => (value ? undefined : 'Required');
class GenerateWalletPasswordComponent extends Component { class GenerateWalletPasswordComponent extends Component {
constructor(props) { constructor(props) {
super(props) super(props);
} }
static propTypes = { static propTypes = {
title: PropTypes.string, // state
body: PropTypes.string, title: PropTypes.string,
userId: PropTypes.number, body: PropTypes.string,
id: PropTypes.number, userId: PropTypes.number,
generateWalletPassword: PropTypes.object, id: PropTypes.number,
showPassword: PropTypes.bool, generateWalletPassword: PropTypes.object,
showGenerateWalletPasswordAction: PropTypes.func, showPassword: PropTypes.bool,
generateWalletFileAction: PropTypes.func, generateWalletFile: PropTypes.bool,
generateWalletHasDownloadedFileAction: PropTypes.func, hasDownloadedWalletFile: PropTypes.bool,
generateWalletFile: PropTypes.bool, canProceedToPaper: PropTypes.bool,
hasDownloadedWalletFile: PropTypes.bool, // actions
generateWalletContinueToPaperAction: PropTypes.func, showPasswordGenerateWallet: PropTypes.func,
canProceedToPaper: PropTypes.bool generateFileGenerateWallet: PropTypes.func,
}; downloadFileGenerateWallet: PropTypes.func,
confirmContinueToPaperGenerateWallet: PropTypes.func
};
continueToPaper() {}
continueToPaper() { downloaded() {
} let nextState = this.state;
nextState.hasDownloadedWalletFile = true;
this.setState(nextState);
}
downloaded() { render() {
let nextState = this.state; const {
nextState.hasDownloadedWalletFile = true; generateWalletPassword,
this.setState(nextState) showPassword,
} generateWalletFile,
hasDownloadedWalletFile,
showPasswordGenerateWallet,
generateFileGenerateWallet,
downloadFileGenerateWallet,
confirmContinueToPaperGenerateWallet
} = this.props;
return (
render() { <section className="container" style={{ minHeight: '50%' }}>
const { <div className="tab-content">
// handleSubmit, <main className="tab-pane active text-center" role="main">
// pristine, <br />
// reset, {!generateWalletFile &&
// submitting, <div>
generateWalletPassword, <section className="row">
showPassword, <h1 aria-live="polite">{translate('NAV_GenerateWallet')}</h1>
showGenerateWalletPasswordAction, <div className="col-sm-8 col-sm-offset-2">
generateWalletFileAction, <h4>{translate('HELP_1_Desc_3')}</h4>
generateWalletFile, <Field
hasDownloadedWalletFile, validate={[required, minLength9]}
generateWalletHasDownloadedFileAction, component={GenerateWalletPasswordInputComponent}
generateWalletContinueToPaperAction showPassword={showPassword}
// canProceedToPaper showPasswordGenerateWallet={showPasswordGenerateWallet}
name="password"
} = this.props; type="text"
/>
return ( <br />
<section className="container" style={{minHeight: '50%'}}> <button
<div className="tab-content"> onClick={() => generateFileGenerateWallet()}
<main className="tab-pane active text-center" role="main"> disabled={
<br/> generateWalletPassword
{ ? generateWalletPassword.syncErrors
!generateWalletFile && ( : true
<div> }
<section className="row"> className="btn btn-primary btn-block"
<h1 aria-live="polite">{translate('NAV_GenerateWallet')}</h1> >
<div className="col-sm-8 col-sm-offset-2"> {translate('NAV_GenerateWallet')}
<h4>{translate('HELP_1_Desc_3')}</h4> </button>
<Field </div>
validate={[required, minLength9]} </section>
component={GenerateWalletPasswordInputComponent} <LedgerTrezorWarning />
showPassword={showPassword} </div>}
showGenerateWalletPasswordAction={showGenerateWalletPasswordAction} {generateWalletFile &&
name="password" <section role="main" className="row">
type="text"/> <h1>{translate('GEN_Label_2')}</h1>
<br/> <br />
<button onClick={() => generateWalletFileAction()} <div className="col-sm-8 col-sm-offset-2">
disabled={generateWalletPassword ? generateWalletPassword.syncErrors : true} <div aria-hidden="true" className="account-help-icon">
className="btn btn-primary btn-block"> <img
{translate('NAV_GenerateWallet')} src="https://myetherwallet.com/images/icon-help.svg"
</button> className="help-icon"
</div> />
</section> <p className="account-help-text">
<LedgerTrezorWarning/> {translate('x_KeystoreDesc')}
</div> </p>
) <h4>{translate('x_Keystore2')}</h4>
} </div>
{ <a
generateWalletFile && ( role="button"
<section role="main" className="row"> className="btn btn-primary btn-block"
<h1>{translate('GEN_Label_2')}</h1> href="blob:https://myetherwallet.com/2455ae32-916f-4224-a806-414bbe680168"
<br/> download="UTC--2017-04-26T23-07-03.538Z--c5b7fff4e1669e38e8d6bc8fffe7e562b2b70f43"
<div className="col-sm-8 col-sm-offset-2"> aria-label="Download Keystore File (UTC / JSON · Recommended · Encrypted)"
<div aria-hidden="true" className="account-help-icon"><img aria-describedby="x_KeystoreDesc"
src="https://myetherwallet.com/images/icon-help.svg" className="help-icon"/> onClick={() => downloadFileGenerateWallet()}
<p className="account-help-text">{translate('x_KeystoreDesc')}</p> >
<h4>{translate('x_Keystore2')}</h4> {translate('x_Download')}
</div> </a>
<a role="button" className="btn btn-primary btn-block" <p className="sr-only" id="x_KeystoreDesc">
href="blob:https://myetherwallet.com/2455ae32-916f-4224-a806-414bbe680168" {translate('x_KeystoreDesc')}
download="UTC--2017-04-26T23-07-03.538Z--c5b7fff4e1669e38e8d6bc8fffe7e562b2b70f43" </p>
aria-label="Download Keystore File (UTC / JSON · Recommended · Encrypted)" <br /><br /><br /><br />
aria-describedby="x_KeystoreDesc"
onClick={() => generateWalletHasDownloadedFileAction()}>{translate('x_Download')}</a>
<p className="sr-only" id="x_KeystoreDesc">{translate('x_KeystoreDesc')}</p>
<br/><br/><br/><br/>
</div>
<div className="col-xs-12 alert alert-danger">
<span>
MyEtherWallet.com is not a web wallet &amp; does not store or transmit this secret information at any time. <br/>
<strong>If you do not save your wallet file and password, we cannot recover them.</strong><br/>
Save your wallet file now &amp; back it up in a second location (not on your computer).
<br/><br/>
<a role="button"
className={`btn btn-info ${hasDownloadedWalletFile ? '' : 'disabled'}`}
onClick={() => generateWalletContinueToPaperAction()}> I understand. Continue. </a>
</span>
</div>
</section>
)
}
</main>
</div> </div>
</section> <div className="col-xs-12 alert alert-danger">
) <span>
} MyEtherWallet.com is not a web wallet &amp; does not store
or transmit this secret information at any time. <br />
<strong>
If you do not save your wallet file and password, we
cannot recover them.
</strong>
<br />
Save your wallet file now &amp; back it up in a second
location (not on your computer).
<br /><br />
<a
role="button"
className={`btn btn-info ${hasDownloadedWalletFile
? ''
: 'disabled'}`}
onClick={() => confirmContinueToPaperGenerateWallet()}
>
{' '}I understand. Continue.{' '}
</a>
</span>
</div>
</section>}
</main>
</div>
</section>
);
}
} }
export default reduxForm({ export default reduxForm({
form: 'generateWalletPassword' // a unique name for this form form: 'generateWalletPassword' // a unique name for this form
})(GenerateWalletPasswordComponent); })(GenerateWalletPasswordComponent);

View File

@ -1,40 +1,44 @@
import React, {Component} from 'react'; import React, { Component } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
export default class GenerateWalletPasswordInputComponent extends Component { export default class GenerateWalletPasswordInputComponent extends Component {
constructor(props) { constructor(props) {
super(props) super(props);
} }
static propTypes = { static propTypes = {
showGenerateWalletPasswordAction: PropTypes.func, showPasswordGenerateWallet: PropTypes.func,
showPassword: PropTypes.bool, showPassword: PropTypes.bool,
input: PropTypes.object, input: PropTypes.object,
meta: PropTypes.object meta: PropTypes.object
}; };
render() {
return (
<div>
<div>
<div className="input-group" style={{width: '100%'}}>
<input {...this.props.input}
name="password"
className={this.props.meta.error ? 'form-control is-invalid' : 'form-control'}
type={this.props.showPassword ? 'text' : 'password'}
placeholder="Do NOT forget to save this!"
aria-label="Enter a strong password (at least 9 characters)"/>
<span
onClick={() => this.props.showGenerateWalletPasswordAction()}
aria-label="make password visible"
role="button"
className="input-group-addon eye"/>
</div>
</div>
</div>
)
}
render() {
return (
<div>
<div>
<div className="input-group" style={{ width: '100%' }}>
<input
{...this.props.input}
name="password"
className={
this.props.meta.error
? 'form-control is-invalid'
: 'form-control'
}
type={this.props.showPassword ? 'text' : 'password'}
placeholder="Do NOT forget to save this!"
aria-label="Enter a strong password (at least 9 characters)"
/>
<span
onClick={() => this.props.showPasswordGenerateWallet()}
aria-label="make password visible"
role="button"
className="input-group-addon eye"
/>
</div>
</div>
</div>
);
}
} }

View File

@ -1,21 +1,23 @@
import React from 'react'; import React from 'react';
const LedgerTrezorWarning = () => ( const LedgerTrezorWarning = () =>
<section className="row"> <section className="row">
<br/> <br />
<br/> <br />
<br/> <br />
<br/> <br />
<br/> <br />
<br/> <br />
<p className="strong">Ledger &amp; TREZOR users: Do not generate a new <p className="strong">
walletyour Ledger &amp; TREZOR users: Do not generate a new
hardware device <em> is </em> your wallet.<br/> walletyour
<a>You hardware device <em> is </em> your wallet.<br />
can connect to your device, see your addresses, or send ETH or Tokens <a>
here.</a> You
</p> can connect to your device, see your addresses, or send ETH or Tokens
</section> here.
); </a>
</p>
</section>;
export default LedgerTrezorWarning; export default LedgerTrezorWarning;

View File

@ -1,63 +1,41 @@
import GenerateWalletPasswordComponent from './components/GenerateWalletPasswordComponent'; import GenerateWalletPasswordComponent from './components/GenerateWalletPasswordComponent';
import React, {Component} from 'react'; import React, { Component } from 'react';
import {connect} from 'react-redux'; import { connect } from 'react-redux';
import { import * as generateWalletActions from 'actions/generateWallet';
GENERATE_WALLET_FILE_ACTION,
GENERATE_WALLET_HAS_DOWNLOADED_FILE_ACTION,
SHOW_GENERATE_WALLET_PASSWORD_ACTION,
GENERATE_WALLET_CONTINUE_TO_PAPER_ACTION
} from 'actions/generateWallet';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
class GenerateWallet extends Component { class GenerateWallet extends Component {
constructor(props) { constructor(props) {
super(props) super(props);
} }
static propTypes = { static propTypes = {
generateWalletPassword: PropTypes.object, // state
showPassword: PropTypes.bool, generateWalletPassword: PropTypes.object,
hasDownloadedWalletFile: PropTypes.bool, showPassword: PropTypes.bool,
showGenerateWalletPasswordAction: PropTypes.func, hasDownloadedWalletFile: PropTypes.bool,
generateWalletFileAction: PropTypes.func, generateWalletFile: PropTypes.bool,
generateWalletHasDownloadedFileAction: PropTypes.func, canProceedToPaper: PropTypes.bool,
generateWalletFile: PropTypes.bool, // actions
generateWalletContinueToPaperAction: PropTypes.func, showPasswordGenerateWallet: PropTypes.func,
canProceedToPaper: PropTypes.bool generateFileGenerateWallet: PropTypes.func,
} downloadFileGenerateWallet: PropTypes.func,
confirmContinueToPaperGenerateWallet: PropTypes.func
};
render() { render() {
return ( return <GenerateWalletPasswordComponent {...this.props} />;
<GenerateWalletPasswordComponent {...this.props}/> }
)
}
} }
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {
generateWalletPassword: state.form.generateWalletPassword, generateWalletPassword: state.form.generateWalletPassword,
generateWalletFile: state.generateWallet.generateWalletFile, generateWalletFile: state.generateWallet.generateWalletFile,
showPassword: state.generateWallet.showPassword, showPassword: state.generateWallet.showPassword,
hasDownloadedWalletFile: state.generateWallet.hasDownloadedWalletFile, hasDownloadedWalletFile: state.generateWallet.hasDownloadedWalletFile,
canProceedToPaper: state.generateWallet.canProceedToPaper canProceedToPaper: state.generateWallet.canProceedToPaper
} };
} }
function mapDispatchToProps(dispatch) { export default connect(mapStateToProps, generateWalletActions)(GenerateWallet);
return {
showGenerateWalletPasswordAction: () => {
dispatch(SHOW_GENERATE_WALLET_PASSWORD_ACTION())
},
generateWalletFileAction: () => {
dispatch(GENERATE_WALLET_FILE_ACTION())
},
generateWalletHasDownloadedFileAction: () => {
dispatch(GENERATE_WALLET_HAS_DOWNLOADED_FILE_ACTION())
},
generateWalletContinueToPaperAction: () => {
dispatch(GENERATE_WALLET_CONTINUE_TO_PAPER_ACTION())
}
}
}
export default connect(mapStateToProps, mapDispatchToProps)(GenerateWallet)

View File

@ -44,10 +44,10 @@ export default class WantToSwapMy extends Component {
destinationKind: PropTypes.string, destinationKind: PropTypes.string,
destinationKindOptions: PropTypes.array, destinationKindOptions: PropTypes.array,
originKindOptions: PropTypes.array, originKindOptions: PropTypes.array,
SWAP_ORIGIN_KIND_TO: PropTypes.func, originKindSwap: PropTypes.func,
SWAP_DESTINATION_KIND_TO: PropTypes.func, destinationKindSwap: PropTypes.func,
SWAP_ORIGIN_AMOUNT_TO: PropTypes.func, originAmountSwap: PropTypes.func,
SWAP_DESTINATION_AMOUNT_TO: PropTypes.func destinationAmountSwap: PropTypes.func
}; };
onClickStartSwap() {} onClickStartSwap() {}
@ -60,38 +60,38 @@ export default class WantToSwapMy extends Component {
this.props.destinationKind this.props.destinationKind
); );
let bityRate = this.props.bityRates[pairName]; let bityRate = this.props.bityRates[pairName];
this.props.SWAP_ORIGIN_AMOUNT_TO(originAmountAsNumber); this.props.originAmountSwap(originAmountAsNumber);
this.props.SWAP_DESTINATION_AMOUNT_TO(originAmountAsNumber * bityRate); this.props.destinationAmountSwap(originAmountAsNumber * bityRate);
} else { } else {
this.props.SWAP_ORIGIN_AMOUNT_TO(''); this.props.originAmountSwap('');
this.props.SWAP_DESTINATION_AMOUNT_TO(''); this.props.destinationAmountSwap('');
} }
}; };
onChangeDestinationAmount(amount) { onChangeDestinationAmount(amount) {
let destinationAmountAsNumber = parseFloat(amount); let destinationAmountAsNumber = parseFloat(amount);
if (destinationAmountAsNumber) { if (destinationAmountAsNumber) {
this.props.SWAP_DESTINATION_AMOUNT_TO(destinationAmountAsNumber); this.props.destinationAmountSwap(destinationAmountAsNumber);
let pairName = combineAndUpper( let pairName = combineAndUpper(
this.props.destinationKind, this.props.destinationKind,
this.props.originKind this.props.originKind
); );
let bityRate = this.props.bityRates[pairName]; let bityRate = this.props.bityRates[pairName];
this.props.SWAP_ORIGIN_AMOUNT_TO(destinationAmountAsNumber * bityRate); this.props.originAmountSwap(destinationAmountAsNumber * bityRate);
} else { } else {
this.props.SWAP_ORIGIN_AMOUNT_TO(''); this.props.originAmountSwap('');
this.props.SWAP_DESTINATION_AMOUNT_TO(''); this.props.destinationAmountSwap('');
} }
} }
async onChangeDestinationKind(event) { async onChangeDestinationKind(event) {
let newDestinationKind = event.target.value; let newDestinationKind = event.target.value;
this.props.SWAP_DESTINATION_KIND_TO(newDestinationKind); this.props.destinationKindSwap(newDestinationKind);
} }
async onChangeOriginKind(event) { async onChangeOriginKind(event) {
let newOriginKind = event.target.value; let newOriginKind = event.target.value;
this.props.SWAP_ORIGIN_KIND_TO(newOriginKind); this.props.originKindSwap(newOriginKind);
} }
render() { render() {

View File

@ -21,11 +21,11 @@ class Swap extends Component {
destinationKind: PropTypes.string, destinationKind: PropTypes.string,
destinationKindOptions: PropTypes.array, destinationKindOptions: PropTypes.array,
originKindOptions: PropTypes.array, originKindOptions: PropTypes.array,
SWAP_ORIGIN_KIND_TO: PropTypes.func, originKindSwap: PropTypes.func,
SWAP_DESTINATION_KIND_TO: PropTypes.func, destinationKindSwap: PropTypes.func,
SWAP_ORIGIN_AMOUNT_TO: PropTypes.func, originAmountSwap: PropTypes.func,
SWAP_DESTINATION_AMOUNT_TO: PropTypes.func, destinationAmountSwap: PropTypes.func,
SWAP_UPDATE_BITY_RATES_TO: PropTypes.func updateBityRatesSwap: PropTypes.func
}; };
componentDidMount() { componentDidMount() {
@ -38,7 +38,7 @@ class Swap extends Component {
!bityRates.BTCREP !bityRates.BTCREP
) { ) {
this.bity.getAllRates().then(data => { this.bity.getAllRates().then(data => {
this.props.SWAP_UPDATE_BITY_RATES_TO(data); this.props.updateBityRatesSwap(data);
}); });
} }
} }
@ -52,10 +52,10 @@ class Swap extends Component {
destinationKind, destinationKind,
destinationKindOptions, destinationKindOptions,
originKindOptions, originKindOptions,
SWAP_ORIGIN_KIND_TO, originKindSwap,
SWAP_DESTINATION_KIND_TO, destinationKindSwap,
SWAP_ORIGIN_AMOUNT_TO, originAmountSwap,
SWAP_DESTINATION_AMOUNT_TO destinationAmountSwap
} = this.props; } = this.props;
let wantToSwapMyProps = { let wantToSwapMyProps = {
@ -66,10 +66,10 @@ class Swap extends Component {
destinationKind, destinationKind,
destinationKindOptions, destinationKindOptions,
originKindOptions, originKindOptions,
SWAP_ORIGIN_KIND_TO, originKindSwap,
SWAP_DESTINATION_KIND_TO, destinationKindSwap,
SWAP_ORIGIN_AMOUNT_TO, originAmountSwap,
SWAP_DESTINATION_AMOUNT_TO destinationAmountSwap
}; };
return ( return (

View File

@ -1,50 +1,48 @@
import { import {
GENERATE_WALLET_SHOW_PASSWORD, GENERATE_WALLET_SHOW_PASSWORD,
GENERATE_WALLET_FILE, GENERATE_WALLET_FILE,
GENERATE_WALLET_HAS_DOWNLOADED_FILE, GENERATE_WALLET_DOWNLOAD_FILE,
GENERATE_WALLET_CONTINUE_TO_PAPER GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER
} from 'actions/generateWalletConstants';
} from 'actions/generateWallet';
const initialState = { const initialState = {
showPassword: false, showPassword: false,
generateWalletFile: false, generateWalletFile: false,
hasDownloadedWalletFile: false, hasDownloadedWalletFile: false,
canProceedToPaper: false canProceedToPaper: false
} };
export function generateWallet(state = initialState, action) { export function generateWallet(state = initialState, action) {
switch (action.type) { switch (action.type) {
case GENERATE_WALLET_SHOW_PASSWORD: { case GENERATE_WALLET_SHOW_PASSWORD: {
return { return {
...state, ...state,
showPassword: !state.showPassword showPassword: !state.showPassword
} };
}
case GENERATE_WALLET_FILE: {
return {
...state,
generateWalletFile: true
}
}
case GENERATE_WALLET_HAS_DOWNLOADED_FILE: {
return {
...state,
hasDownloadedWalletFile: true
}
}
case GENERATE_WALLET_CONTINUE_TO_PAPER: {
return {
...state,
canProceedToPaper: true
}
}
default:
return state
} }
case GENERATE_WALLET_FILE: {
return {
...state,
generateWalletFile: true
};
}
case GENERATE_WALLET_DOWNLOAD_FILE: {
return {
...state,
hasDownloadedWalletFile: true
};
}
case GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER: {
return {
...state,
canProceedToPaper: true
};
}
default:
return state;
}
} }