From c46ed8f6ed27dafbd3d48aa350e847bbf6a7675a Mon Sep 17 00:00:00 2001 From: Daniel Ternyak Date: Mon, 19 Jun 2017 22:15:38 -0500 Subject: [PATCH 1/7] clean up Generate Wallet actions to not use boilerplate --- common/actions/generateWallet.js | 35 ++++---- common/actions/generateWalletConstants.js | 6 ++ .../GenerateWalletPasswordComponent.jsx | 33 ++++---- .../GenerateWalletPasswordInputComponent.jsx | 4 +- .../containers/Tabs/GenerateWallet/index.js | 82 +++++++----------- common/reducers/generateWallet.js | 84 +++++++++---------- 6 files changed, 112 insertions(+), 132 deletions(-) create mode 100644 common/actions/generateWalletConstants.js diff --git a/common/actions/generateWallet.js b/common/actions/generateWallet.js index dbfb50e5..8c6984c1 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_CONTINUE_TO_PAPER, + GENERATE_WALLET_FILE, + GENERATE_WALLET_HAS_DOWNLOADED_FILE, + GENERATE_WALLET_SHOW_PASSWORD +} from 'actions/generateWalletConstants'; +export const SHOW_GENERATE_WALLET_PASSWORD_ACTION = () => { + return { type: GENERATE_WALLET_SHOW_PASSWORD }; +}; -export const SHOW_GENERATE_WALLET_PASSWORD_ACTION = () => Object ({ - type: GENERATE_WALLET_SHOW_PASSWORD -}) +export const GENERATE_WALLET_FILE_ACTION = () => { + return { type: GENERATE_WALLET_FILE }; +}; -export const GENERATE_WALLET_FILE_ACTION = () => Object ({ - type: GENERATE_WALLET_FILE -}) +export const GENERATE_WALLET_HAS_DOWNLOADED_FILE_ACTION = () => { + return { type: GENERATE_WALLET_HAS_DOWNLOADED_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 GENERATE_WALLET_CONTINUE_TO_PAPER_ACTION = () => { + return { type: GENERATE_WALLET_CONTINUE_TO_PAPER }; +}; diff --git a/common/actions/generateWalletConstants.js b/common/actions/generateWalletConstants.js new file mode 100644 index 00000000..e94843b0 --- /dev/null +++ b/common/actions/generateWalletConstants.js @@ -0,0 +1,6 @@ +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'; diff --git a/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordComponent.jsx b/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordComponent.jsx index 58c7eebc..ba6ac056 100644 --- a/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordComponent.jsx +++ b/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordComponent.jsx @@ -20,19 +20,21 @@ class GenerateWalletPasswordComponent extends Component { } static propTypes = { + // state 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 + canProceedToPaper: PropTypes.bool, + // actions + SHOW_GENERATE_WALLET_PASSWORD_ACTION: PropTypes.func, + GENERATE_WALLET_FILE_ACTION: PropTypes.func, + GENERATE_WALLET_HAS_DOWNLOADED_FILE_ACTION: PropTypes.func, + GENERATE_WALLET_CONTINUE_TO_PAPER_ACTION: PropTypes.func }; @@ -48,19 +50,14 @@ class GenerateWalletPasswordComponent extends Component { render() { const { - // handleSubmit, - // pristine, - // reset, - // submitting, generateWalletPassword, showPassword, - showGenerateWalletPasswordAction, - generateWalletFileAction, generateWalletFile, hasDownloadedWalletFile, - generateWalletHasDownloadedFileAction, - generateWalletContinueToPaperAction - // canProceedToPaper + SHOW_GENERATE_WALLET_PASSWORD_ACTION, + GENERATE_WALLET_FILE_ACTION, + GENERATE_WALLET_HAS_DOWNLOADED_FILE_ACTION, + GENERATE_WALLET_CONTINUE_TO_PAPER_ACTION } = this.props; @@ -80,11 +77,11 @@ class GenerateWalletPasswordComponent extends Component { validate={[required, minLength9]} component={GenerateWalletPasswordInputComponent} showPassword={showPassword} - showGenerateWalletPasswordAction={showGenerateWalletPasswordAction} + SHOW_GENERATE_WALLET_PASSWORD_ACTION={SHOW_GENERATE_WALLET_PASSWORD_ACTION} name="password" type="text"/>
- - - - - - ) - } - { - generateWalletFile && ( -
-

{translate('GEN_Label_2')}

-
-
- - generateWalletDownloadFile()}>{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). -

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

{translate('NAV_GenerateWallet')}

+
+

{translate('HELP_1_Desc_3')}

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

{translate('GEN_Label_2')}

+
+
+ + generateWalletDownloadFile()} + > + {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). +

+ generateWalletConfirmContinueToPaper()} + > + {' '}I understand. Continue.{' '} + +
+
+
} + + + + ); + } } export default reduxForm({ - form: 'generateWalletPassword' // a unique name for this form + form: 'generateWalletPassword' // a unique name for this form })(GenerateWalletPasswordComponent); From ff81133b5e128045628877324d5de9143086cba6 Mon Sep 17 00:00:00 2001 From: Daniel Ternyak Date: Tue, 20 Jun 2017 01:14:23 -0500 Subject: [PATCH 5/7] reformat --- .../GenerateWalletPasswordInputComponent.jsx | 72 ++++++++++--------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordInputComponent.jsx b/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordInputComponent.jsx index d68bcd1f..6989f017 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 = { - generateWalletShowPassword: PropTypes.func, - showPassword: PropTypes.bool, - input: PropTypes.object, - meta: PropTypes.object - }; - - - render() { - return ( -
-
-
- - this.props.generateWalletShowPassword()} - aria-label="make password visible" - role="button" - className="input-group-addon eye"/> -
-
-
- ) - } + static propTypes = { + generateWalletShowPassword: PropTypes.func, + showPassword: PropTypes.bool, + input: PropTypes.object, + meta: PropTypes.object + }; + render() { + return ( +
+
+
+ + this.props.generateWalletShowPassword()} + aria-label="make password visible" + role="button" + className="input-group-addon eye" + /> +
+
+
+ ); + } } From ba6d46e91d7d909dd905403e27ebe5a64a69ea22 Mon Sep 17 00:00:00 2001 From: Daniel Ternyak Date: Tue, 20 Jun 2017 01:14:35 -0500 Subject: [PATCH 6/7] reformat --- .../components/LedgerTrezorWarning.jsx | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) 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; From 1a4fac1dec3a10e2407c09495063c591fc542333 Mon Sep 17 00:00:00 2001 From: Daniel Ternyak Date: Tue, 20 Jun 2017 01:28:22 -0500 Subject: [PATCH 7/7] accidently swapped verb and namespace order for action creators originally; fixed --- common/actions/generateWallet.js | 8 +++--- common/actions/swap.js | 10 +++---- .../GenerateWalletPasswordComponent.jsx | 24 ++++++++-------- .../GenerateWalletPasswordInputComponent.jsx | 4 +-- .../containers/Tabs/GenerateWallet/index.js | 8 +++--- .../Tabs/Swap/components/wantToSwapMy.js | 28 +++++++++---------- common/containers/Tabs/Swap/index.js | 28 +++++++++---------- 7 files changed, 55 insertions(+), 55 deletions(-) diff --git a/common/actions/generateWallet.js b/common/actions/generateWallet.js index 677ab9b4..a4a7273c 100644 --- a/common/actions/generateWallet.js +++ b/common/actions/generateWallet.js @@ -5,18 +5,18 @@ import { GENERATE_WALLET_SHOW_PASSWORD } from 'actions/generateWalletConstants'; -export const generateWalletShowPassword = () => { +export const showPasswordGenerateWallet = () => { return { type: GENERATE_WALLET_SHOW_PASSWORD }; }; -export const generateWalletGenerateFile = () => { +export const generateFileGenerateWallet = () => { return { type: GENERATE_WALLET_FILE }; }; -export const generateWalletDownloadFile = () => { +export const downloadFileGenerateWallet = () => { return { type: GENERATE_WALLET_DOWNLOAD_FILE }; }; -export const generateWalletConfirmContinueToPaper = () => { +export const confirmContinueToPaperGenerateWallet = () => { return { type: GENERATE_WALLET_CONFIRM_CONTINUE_TO_PAPER }; }; diff --git a/common/actions/swap.js b/common/actions/swap.js index 7ffbeead..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 swapOriginKind = value => { +export const originKindSwap = value => { return { type: SWAP_ORIGIN_KIND, value }; }; -export const swapDestinationKind = value => { +export const destinationKindSwap = value => { return { type: SWAP_DESTINATION_KIND, value }; }; -export const swapOriginAmount = value => { +export const originAmountSwap = value => { return { type: SWAP_ORIGIN_AMOUNT, value }; }; -export const swapDestinationAmount = value => { +export const destinationAmountSwap = value => { return { type: SWAP_DESTINATION_AMOUNT, value }; }; -export const swapUpdateBityRates = 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 66e3466d..db577887 100644 --- a/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordComponent.jsx +++ b/common/containers/Tabs/GenerateWallet/components/GenerateWalletPasswordComponent.jsx @@ -31,10 +31,10 @@ class GenerateWalletPasswordComponent extends Component { hasDownloadedWalletFile: PropTypes.bool, canProceedToPaper: PropTypes.bool, // actions - generateWalletShowPassword: PropTypes.func, - generateWalletGenerateFile: PropTypes.func, - generateWalletDownloadFile: PropTypes.func, - generateWalletConfirmContinueToPaper: PropTypes.func + showPasswordGenerateWallet: PropTypes.func, + generateFileGenerateWallet: PropTypes.func, + downloadFileGenerateWallet: PropTypes.func, + confirmContinueToPaperGenerateWallet: PropTypes.func }; continueToPaper() {} @@ -51,10 +51,10 @@ class GenerateWalletPasswordComponent extends Component { showPassword, generateWalletFile, hasDownloadedWalletFile, - generateWalletShowPassword, - generateWalletGenerateFile, - generateWalletDownloadFile, - generateWalletConfirmContinueToPaper + showPasswordGenerateWallet, + generateFileGenerateWallet, + downloadFileGenerateWallet, + confirmContinueToPaperGenerateWallet } = this.props; return ( @@ -72,13 +72,13 @@ class GenerateWalletPasswordComponent extends Component { validate={[required, minLength9]} component={GenerateWalletPasswordInputComponent} showPassword={showPassword} - generateWalletShowPassword={generateWalletShowPassword} + showPasswordGenerateWallet={showPasswordGenerateWallet} name="password" type="text" />