diff --git a/common/actions/generateWallet.js b/common/actions/generateWallet.js index dbfb50e5..a4a7273c 100644 --- a/common/actions/generateWallet.js +++ b/common/actions/generateWallet.js @@ -1,21 +1,22 @@ -export const GENERATE_WALLET_SHOW_PASSWORD = 'GENERATE_WALLET_SHOW_PASSWORD'; -export const GENERATE_WALLET_FILE = 'GENERATE_WALLET_FILE' -export const GENERATE_WALLET_HAS_DOWNLOADED_FILE = 'GENERATE_WALLET_HAS_DOWNLOADED_FILE' -export const GENERATE_WALLET_CONTINUE_TO_PAPER = 'GENERATE_WALLET_CONTINUE_TO_PAPER' +import { + GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER, + GENERATE_WALLET_FILE, + 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 ({ - type: GENERATE_WALLET_SHOW_PASSWORD -}) +export const generateFileGenerateWallet = () => { + return { type: GENERATE_WALLET_FILE }; +}; -export const GENERATE_WALLET_FILE_ACTION = () => Object ({ - type: GENERATE_WALLET_FILE -}) +export const downloadFileGenerateWallet = () => { + return { type: GENERATE_WALLET_DOWNLOAD_FILE }; +}; -export const GENERATE_WALLET_HAS_DOWNLOADED_FILE_ACTION = () => Object ({ - type: GENERATE_WALLET_HAS_DOWNLOADED_FILE -}) - -export const GENERATE_WALLET_CONTINUE_TO_PAPER_ACTION = () => Object ({ - type: GENERATE_WALLET_CONTINUE_TO_PAPER -}) +export const confirmContinueToPaperGenerateWallet = () => { + return { type: GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER }; +}; diff --git a/common/actions/generateWalletConstants.js b/common/actions/generateWalletConstants.js new file mode 100644 index 00000000..07d200db --- /dev/null +++ b/common/actions/generateWalletConstants.js @@ -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'; diff --git a/common/actions/swap.js b/common/actions/swap.js index 334d6a7e..15f2a4d0 100644 --- a/common/actions/swap.js +++ b/common/actions/swap.js @@ -6,35 +6,35 @@ import { SWAP_UPDATE_BITY_RATES } from './swapConstants'; -export const SWAP_ORIGIN_KIND_TO = value => { +export const originKindSwap = value => { return { type: SWAP_ORIGIN_KIND, value }; }; -export const SWAP_DESTINATION_KIND_TO = value => { +export const destinationKindSwap = value => { return { type: SWAP_DESTINATION_KIND, value }; }; -export const SWAP_ORIGIN_AMOUNT_TO = value => { +export const originAmountSwap = value => { return { type: SWAP_ORIGIN_AMOUNT, value }; }; -export const SWAP_DESTINATION_AMOUNT_TO = value => { +export const destinationAmountSwap = value => { return { type: SWAP_DESTINATION_AMOUNT, value }; }; -export const SWAP_UPDATE_BITY_RATES_TO = value => { +export const updateBityRatesSwap = value => { return { type: SWAP_UPDATE_BITY_RATES, value diff --git a/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordComponent.jsx b/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordComponent.jsx index 58c7eebc..db577887 100644 --- a/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordComponent.jsx +++ b/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordComponent.jsx @@ -1,141 +1,159 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; -import {Field, reduxForm} from 'redux-form'; +import { Field, reduxForm } from 'redux-form'; import GenerateWalletPasswordInputComponent from './GenerateWalletPasswordInputComponent'; import LedgerTrezorWarning from './LedgerTrezorWarning'; import translate from 'translations'; - // VALIDATORS 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 required = value => value ? undefined : 'Required'; - +const required = value => (value ? undefined : 'Required'); class GenerateWalletPasswordComponent extends Component { - constructor(props) { - super(props) - } + constructor(props) { + super(props); + } - static propTypes = { - title: PropTypes.string, - body: PropTypes.string, - userId: PropTypes.number, - id: PropTypes.number, - generateWalletPassword: PropTypes.object, - showPassword: PropTypes.bool, - showGenerateWalletPasswordAction: PropTypes.func, - generateWalletFileAction: PropTypes.func, - generateWalletHasDownloadedFileAction: PropTypes.func, - generateWalletFile: PropTypes.bool, - hasDownloadedWalletFile: PropTypes.bool, - generateWalletContinueToPaperAction: PropTypes.func, - canProceedToPaper: PropTypes.bool - }; + static propTypes = { + // state + title: PropTypes.string, + body: PropTypes.string, + userId: PropTypes.number, + id: PropTypes.number, + generateWalletPassword: PropTypes.object, + showPassword: PropTypes.bool, + generateWalletFile: PropTypes.bool, + hasDownloadedWalletFile: PropTypes.bool, + canProceedToPaper: PropTypes.bool, + // actions + showPasswordGenerateWallet: PropTypes.func, + generateFileGenerateWallet: PropTypes.func, + downloadFileGenerateWallet: PropTypes.func, + confirmContinueToPaperGenerateWallet: PropTypes.func + }; + continueToPaper() {} - continueToPaper() { - } + downloaded() { + let nextState = this.state; + nextState.hasDownloadedWalletFile = true; + this.setState(nextState); + } - downloaded() { - let nextState = this.state; - nextState.hasDownloadedWalletFile = true; - this.setState(nextState) - } + render() { + const { + generateWalletPassword, + showPassword, + generateWalletFile, + hasDownloadedWalletFile, + showPasswordGenerateWallet, + generateFileGenerateWallet, + downloadFileGenerateWallet, + confirmContinueToPaperGenerateWallet + } = this.props; - - render() { - const { - // handleSubmit, - // pristine, - // reset, - // submitting, - generateWalletPassword, - showPassword, - showGenerateWalletPasswordAction, - generateWalletFileAction, - generateWalletFile, - hasDownloadedWalletFile, - generateWalletHasDownloadedFileAction, - generateWalletContinueToPaperAction - // canProceedToPaper - - } = this.props; - - return ( -
-
-
-
- { - !generateWalletFile && ( -
-
-

{translate('NAV_GenerateWallet')}

-
-

{translate('HELP_1_Desc_3')}

- -
- -
-
- -
- ) - } - { - generateWalletFile && ( -
-

{translate('GEN_Label_2')}

-
-
- - generateWalletHasDownloadedFileAction()}>{translate('x_Download')} -

{translate('x_KeystoreDesc')}

-



-
-
- - MyEtherWallet.com is not a web wallet & does not store or transmit this secret information at any time.
- If you do not save your wallet file and password, we cannot recover them.
- Save your wallet file now & back it up in a second location (not on your computer). -

- generateWalletContinueToPaperAction()}> I understand. Continue. -
-
-
- ) - } -
+ return ( +
+
+
+
+ {!generateWalletFile && +
+
+

{translate('NAV_GenerateWallet')}

+
+

{translate('HELP_1_Desc_3')}

+ +
+ +
+
+ +
} + {generateWalletFile && +
+

{translate('GEN_Label_2')}

+
+
+ + downloadFileGenerateWallet()} + > + {translate('x_Download')} + +

+ {translate('x_KeystoreDesc')} +

+



-
- ) - } +
+ + MyEtherWallet.com is not a web wallet & does not store + or transmit this secret information at any time.
+ + If you do not save your wallet file and password, we + cannot recover them. + +
+ Save your wallet file now & back it up in a second + location (not on your computer). +

+ confirmContinueToPaperGenerateWallet()} + > + {' '}I understand. Continue.{' '} + +
+
+
} + +
+
+ ); + } } export default reduxForm({ - form: 'generateWalletPassword' // a unique name for this form + form: 'generateWalletPassword' // a unique name for this form })(GenerateWalletPasswordComponent); diff --git a/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordInputComponent.jsx b/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordInputComponent.jsx index 2e23001e..e3b48d13 100644 --- a/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordInputComponent.jsx +++ b/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordInputComponent.jsx @@ -1,40 +1,44 @@ -import React, {Component} from 'react'; +import React, { Component } from 'react'; import PropTypes from 'prop-types'; - export default class GenerateWalletPasswordInputComponent extends Component { - constructor(props) { - super(props) - } + constructor(props) { + super(props); + } - static propTypes = { - showGenerateWalletPasswordAction: PropTypes.func, - showPassword: PropTypes.bool, - input: PropTypes.object, - meta: PropTypes.object - }; - - - render() { - return ( -
-
-
- - this.props.showGenerateWalletPasswordAction()} - aria-label="make password visible" - role="button" - className="input-group-addon eye"/> -
-
-
- ) - } + static propTypes = { + showPasswordGenerateWallet: PropTypes.func, + showPassword: PropTypes.bool, + input: PropTypes.object, + meta: PropTypes.object + }; + render() { + return ( +
+
+
+ + this.props.showPasswordGenerateWallet()} + aria-label="make password visible" + role="button" + className="input-group-addon eye" + /> +
+
+
+ ); + } } diff --git a/common/containers/Tabs/GenerateWallet/components/LedgerTrezorWarning.jsx b/common/containers/Tabs/GenerateWallet/components/LedgerTrezorWarning.jsx index 9b714987..a3414bcd 100644 --- a/common/containers/Tabs/GenerateWallet/components/LedgerTrezorWarning.jsx +++ b/common/containers/Tabs/GenerateWallet/components/LedgerTrezorWarning.jsx @@ -1,21 +1,23 @@ import React from 'react'; -const LedgerTrezorWarning = () => ( -
-
-
-
-
-
-
-

Ledger & TREZOR users: Do not generate a new - wallet—your - hardware device is your wallet.
- You - can connect to your device, see your addresses, or send ETH or Tokens - here. -

-
-); +const LedgerTrezorWarning = () => +
+
+
+
+
+
+
+

+ Ledger & TREZOR users: Do not generate a new + wallet—your + hardware device is your wallet.
+ + You + can connect to your device, see your addresses, or send ETH or Tokens + here. + +

+
; export default LedgerTrezorWarning; diff --git a/common/containers/Tabs/GenerateWallet/index.js b/common/containers/Tabs/GenerateWallet/index.js index aa77f776..38e5502b 100644 --- a/common/containers/Tabs/GenerateWallet/index.js +++ b/common/containers/Tabs/GenerateWallet/index.js @@ -1,63 +1,41 @@ import GenerateWalletPasswordComponent from './components/GenerateWalletPasswordComponent'; -import React, {Component} from 'react'; -import {connect} from 'react-redux'; -import { - 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 React, { Component } from 'react'; +import { connect } from 'react-redux'; +import * as generateWalletActions from 'actions/generateWallet'; import PropTypes from 'prop-types'; class GenerateWallet extends Component { - constructor(props) { - super(props) - } + constructor(props) { + super(props); + } - static propTypes = { - generateWalletPassword: PropTypes.object, - showPassword: PropTypes.bool, - hasDownloadedWalletFile: PropTypes.bool, - showGenerateWalletPasswordAction: PropTypes.func, - generateWalletFileAction: PropTypes.func, - generateWalletHasDownloadedFileAction: PropTypes.func, - generateWalletFile: PropTypes.bool, - generateWalletContinueToPaperAction: PropTypes.func, - canProceedToPaper: PropTypes.bool - } + static propTypes = { + // state + generateWalletPassword: PropTypes.object, + showPassword: PropTypes.bool, + hasDownloadedWalletFile: PropTypes.bool, + generateWalletFile: PropTypes.bool, + canProceedToPaper: PropTypes.bool, + // actions + showPasswordGenerateWallet: PropTypes.func, + generateFileGenerateWallet: PropTypes.func, + downloadFileGenerateWallet: PropTypes.func, + confirmContinueToPaperGenerateWallet: PropTypes.func + }; - render() { - return ( - - ) - } + render() { + return ; + } } function mapStateToProps(state) { - return { - generateWalletPassword: state.form.generateWalletPassword, - generateWalletFile: state.generateWallet.generateWalletFile, - showPassword: state.generateWallet.showPassword, - hasDownloadedWalletFile: state.generateWallet.hasDownloadedWalletFile, - canProceedToPaper: state.generateWallet.canProceedToPaper - } + return { + generateWalletPassword: state.form.generateWalletPassword, + generateWalletFile: state.generateWallet.generateWalletFile, + showPassword: state.generateWallet.showPassword, + hasDownloadedWalletFile: state.generateWallet.hasDownloadedWalletFile, + canProceedToPaper: state.generateWallet.canProceedToPaper + }; } -function mapDispatchToProps(dispatch) { - 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) +export default connect(mapStateToProps, generateWalletActions)(GenerateWallet); diff --git a/common/containers/Tabs/Swap/components/wantToSwapMy.js b/common/containers/Tabs/Swap/components/wantToSwapMy.js index a8efd912..f82da9f0 100644 --- a/common/containers/Tabs/Swap/components/wantToSwapMy.js +++ b/common/containers/Tabs/Swap/components/wantToSwapMy.js @@ -44,10 +44,10 @@ export default class WantToSwapMy extends Component { destinationKind: PropTypes.string, destinationKindOptions: PropTypes.array, originKindOptions: PropTypes.array, - SWAP_ORIGIN_KIND_TO: PropTypes.func, - SWAP_DESTINATION_KIND_TO: PropTypes.func, - SWAP_ORIGIN_AMOUNT_TO: PropTypes.func, - SWAP_DESTINATION_AMOUNT_TO: PropTypes.func + originKindSwap: PropTypes.func, + destinationKindSwap: PropTypes.func, + originAmountSwap: PropTypes.func, + destinationAmountSwap: PropTypes.func }; onClickStartSwap() {} @@ -60,38 +60,38 @@ export default class WantToSwapMy extends Component { this.props.destinationKind ); let bityRate = this.props.bityRates[pairName]; - this.props.SWAP_ORIGIN_AMOUNT_TO(originAmountAsNumber); - this.props.SWAP_DESTINATION_AMOUNT_TO(originAmountAsNumber * bityRate); + this.props.originAmountSwap(originAmountAsNumber); + this.props.destinationAmountSwap(originAmountAsNumber * bityRate); } else { - this.props.SWAP_ORIGIN_AMOUNT_TO(''); - this.props.SWAP_DESTINATION_AMOUNT_TO(''); + this.props.originAmountSwap(''); + this.props.destinationAmountSwap(''); } }; onChangeDestinationAmount(amount) { let destinationAmountAsNumber = parseFloat(amount); if (destinationAmountAsNumber) { - this.props.SWAP_DESTINATION_AMOUNT_TO(destinationAmountAsNumber); + this.props.destinationAmountSwap(destinationAmountAsNumber); let pairName = combineAndUpper( this.props.destinationKind, this.props.originKind ); let bityRate = this.props.bityRates[pairName]; - this.props.SWAP_ORIGIN_AMOUNT_TO(destinationAmountAsNumber * bityRate); + this.props.originAmountSwap(destinationAmountAsNumber * bityRate); } else { - this.props.SWAP_ORIGIN_AMOUNT_TO(''); - this.props.SWAP_DESTINATION_AMOUNT_TO(''); + this.props.originAmountSwap(''); + this.props.destinationAmountSwap(''); } } async onChangeDestinationKind(event) { let newDestinationKind = event.target.value; - this.props.SWAP_DESTINATION_KIND_TO(newDestinationKind); + this.props.destinationKindSwap(newDestinationKind); } async onChangeOriginKind(event) { let newOriginKind = event.target.value; - this.props.SWAP_ORIGIN_KIND_TO(newOriginKind); + this.props.originKindSwap(newOriginKind); } render() { diff --git a/common/containers/Tabs/Swap/index.js b/common/containers/Tabs/Swap/index.js index e428371b..62dc6158 100644 --- a/common/containers/Tabs/Swap/index.js +++ b/common/containers/Tabs/Swap/index.js @@ -21,11 +21,11 @@ class Swap extends Component { destinationKind: PropTypes.string, destinationKindOptions: PropTypes.array, originKindOptions: PropTypes.array, - SWAP_ORIGIN_KIND_TO: PropTypes.func, - SWAP_DESTINATION_KIND_TO: PropTypes.func, - SWAP_ORIGIN_AMOUNT_TO: PropTypes.func, - SWAP_DESTINATION_AMOUNT_TO: PropTypes.func, - SWAP_UPDATE_BITY_RATES_TO: PropTypes.func + originKindSwap: PropTypes.func, + destinationKindSwap: PropTypes.func, + originAmountSwap: PropTypes.func, + destinationAmountSwap: PropTypes.func, + updateBityRatesSwap: PropTypes.func }; componentDidMount() { @@ -38,7 +38,7 @@ class Swap extends Component { !bityRates.BTCREP ) { 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, destinationKindOptions, originKindOptions, - SWAP_ORIGIN_KIND_TO, - SWAP_DESTINATION_KIND_TO, - SWAP_ORIGIN_AMOUNT_TO, - SWAP_DESTINATION_AMOUNT_TO + originKindSwap, + destinationKindSwap, + originAmountSwap, + destinationAmountSwap } = this.props; let wantToSwapMyProps = { @@ -66,10 +66,10 @@ class Swap extends Component { destinationKind, destinationKindOptions, originKindOptions, - SWAP_ORIGIN_KIND_TO, - SWAP_DESTINATION_KIND_TO, - SWAP_ORIGIN_AMOUNT_TO, - SWAP_DESTINATION_AMOUNT_TO + originKindSwap, + destinationKindSwap, + originAmountSwap, + destinationAmountSwap }; return ( diff --git a/common/reducers/generateWallet.js b/common/reducers/generateWallet.js index a1d9c492..33df5af4 100644 --- a/common/reducers/generateWallet.js +++ b/common/reducers/generateWallet.js @@ -1,50 +1,48 @@ import { - GENERATE_WALLET_SHOW_PASSWORD, - GENERATE_WALLET_FILE, - GENERATE_WALLET_HAS_DOWNLOADED_FILE, - GENERATE_WALLET_CONTINUE_TO_PAPER - -} from 'actions/generateWallet'; - + GENERATE_WALLET_SHOW_PASSWORD, + GENERATE_WALLET_FILE, + GENERATE_WALLET_DOWNLOAD_FILE, + GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER +} from 'actions/generateWalletConstants'; const initialState = { - showPassword: false, - generateWalletFile: false, - hasDownloadedWalletFile: false, - canProceedToPaper: false -} + showPassword: false, + generateWalletFile: false, + hasDownloadedWalletFile: false, + canProceedToPaper: false +}; export function generateWallet(state = initialState, action) { - switch (action.type) { - case GENERATE_WALLET_SHOW_PASSWORD: { - return { - ...state, - 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 + switch (action.type) { + case GENERATE_WALLET_SHOW_PASSWORD: { + return { + ...state, + showPassword: !state.showPassword + }; } + + 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; + } }