From 2bb28e0bbd61cd96ca1f4d983c26e22638d9632c Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Thu, 22 Mar 2018 13:03:59 -0500 Subject: [PATCH] fix(lint): fix linting errors --- app/components/Onboarding/InitWallet.js | 6 +- app/components/Onboarding/Login.js | 8 ++- .../Onboarding/NewAezeedPassword.js | 2 - .../Onboarding/NewWalletPassword.js | 50 ++++++++--------- app/components/Onboarding/NewWalletSeed.js | 28 +++++----- app/components/Onboarding/Onboarding.js | 17 +++--- app/components/Onboarding/ReEnterSeed.js | 55 +++++++++---------- app/components/Onboarding/Signup.js | 6 +- app/containers/Root.js | 4 +- app/lnd/index.js | 2 +- app/lnd/init/index.js | 13 ----- app/lnd/walletUnlockerMethods/index.js | 18 ++---- app/main.dev.js | 7 +-- app/reducers/onboarding.js | 36 ++++++------ 14 files changed, 118 insertions(+), 134 deletions(-) delete mode 100644 app/lnd/init/index.js diff --git a/app/components/Onboarding/InitWallet.js b/app/components/Onboarding/InitWallet.js index ed3b80ce..244b6717 100644 --- a/app/components/Onboarding/InitWallet.js +++ b/app/components/Onboarding/InitWallet.js @@ -15,6 +15,10 @@ const InitWallet = ({ hasSeed, loginProps, signupProps }) => ( ) -InitWallet.propTypes = {} +InitWallet.propTypes = { + hasSeed: PropTypes.bool.isRequired, + loginProps: PropTypes.object.isRequired, + signupProps: PropTypes.object.isRequired +} export default InitWallet diff --git a/app/components/Onboarding/Login.js b/app/components/Onboarding/Login.js index 6f7386b5..5121d59a 100644 --- a/app/components/Onboarding/Login.js +++ b/app/components/Onboarding/Login.js @@ -38,6 +38,12 @@ const Login = ({ ) -Login.propTypes = {} +Login.propTypes = { + password: PropTypes.string.isRequired, + updatePassword: PropTypes.func.isRequired, + unlockingWallet: PropTypes.bool.isRequired, + unlockWallet: PropTypes.func.isRequired, + unlockWalletError: PropTypes.object.isRequired +} export default Login diff --git a/app/components/Onboarding/NewAezeedPassword.js b/app/components/Onboarding/NewAezeedPassword.js index 7c796173..10390738 100644 --- a/app/components/Onboarding/NewAezeedPassword.js +++ b/app/components/Onboarding/NewAezeedPassword.js @@ -1,7 +1,5 @@ import React from 'react' import PropTypes from 'prop-types' -import Isvg from 'react-inlinesvg' -import eye from 'icons/eye.svg' import styles from './NewAezeedPassword.scss' class NewAezeedPassword extends React.Component { diff --git a/app/components/Onboarding/NewWalletPassword.js b/app/components/Onboarding/NewWalletPassword.js index b530b2e9..38bb69b7 100644 --- a/app/components/Onboarding/NewWalletPassword.js +++ b/app/components/Onboarding/NewWalletPassword.js @@ -1,7 +1,5 @@ import React from 'react' import PropTypes from 'prop-types' -import Isvg from 'react-inlinesvg' -import eye from 'icons/eye.svg' import styles from './NewWalletPassword.scss' const NewWalletPassword = ({ @@ -11,32 +9,30 @@ const NewWalletPassword = ({ updateCreateWalletPassword, updateCreateWalletPasswordConfirmation -}) => { - return ( -
-
- updateCreateWalletPassword(event.target.value)} - /> -
+}) => ( +
+
+ updateCreateWalletPassword(event.target.value)} + /> +
-
- updateCreateWalletPasswordConfirmation(event.target.value)} - /> -

Passwords do not match

-
-
- ) -} +
+ updateCreateWalletPasswordConfirmation(event.target.value)} + /> +

Passwords do not match

+
+
+) NewWalletPassword.propTypes = { createWalletPassword: PropTypes.string.isRequired, diff --git a/app/components/Onboarding/NewWalletSeed.js b/app/components/Onboarding/NewWalletSeed.js index b04207f7..a2cdc55b 100644 --- a/app/components/Onboarding/NewWalletSeed.js +++ b/app/components/Onboarding/NewWalletSeed.js @@ -5,21 +5,19 @@ import styles from './NewWalletSeed.scss' const NewWalletSeed = ({ seed }) => (
+ { + seed.map((word, index) => ( +
  • +
    + +
    +
    + {word} +
    +
  • + )) + } +
    ) diff --git a/app/components/Onboarding/Onboarding.js b/app/components/Onboarding/Onboarding.js index 273d2781..5f37a8a3 100644 --- a/app/components/Onboarding/Onboarding.js +++ b/app/components/Onboarding/Onboarding.js @@ -6,7 +6,6 @@ import LoadingBolt from 'components/LoadingBolt' import FormContainer from './FormContainer' import Alias from './Alias' import Autopilot from './Autopilot' -import InitWallet from './InitWallet' import Login from './Login' import Signup from './Signup' import NewWalletSeed from './NewWalletSeed' @@ -81,7 +80,7 @@ const Onboarding = ({ next={() => { // dont allow the user to move on if the confirmation password doesnt match the original password if (newWalletPasswordProps.showCreateWalletPasswordConfirmationError) { return } - + changeStep(5) }} > @@ -94,7 +93,7 @@ const Onboarding = ({ title={'Alright, let\'s get set up'} description='Would you like to create a new wallet or import an existing one?' // eslint-disable-line back={() => changeStep(4)} - next={() => initWalletProps.signupProps.signupForm.create ? changeStep(6) : console.log('import')} + next={() => (initWalletProps.signupProps.signupForm.create ? changeStep(6) : console.log('import'))} > @@ -143,9 +142,7 @@ const Onboarding = ({ } if (startingLnd) { return } - if (fetchingSeed) { - console.log('got em!') - return } + if (fetchingSeed) { return } return (
    @@ -158,8 +155,14 @@ Onboarding.propTypes = { onboarding: PropTypes.object.isRequired, aliasProps: PropTypes.object.isRequired, autopilotProps: PropTypes.object.isRequired, + initWalletProps: PropTypes.object.isRequired, + newWalletSeedProps: PropTypes.object.isRequired, + newWalletPasswordProps: PropTypes.object.isRequired, + newAezeedPasswordProps: PropTypes.object.isRequired, + reEnterSeedProps: PropTypes.object.isRequired, changeStep: PropTypes.func.isRequired, - startLnd: PropTypes.func.isRequired + startLnd: PropTypes.func.isRequired, + submitNewWallet: PropTypes.func.isRequired } export default Onboarding diff --git a/app/components/Onboarding/ReEnterSeed.js b/app/components/Onboarding/ReEnterSeed.js index 2e8270b1..5bb38b27 100644 --- a/app/components/Onboarding/ReEnterSeed.js +++ b/app/components/Onboarding/ReEnterSeed.js @@ -2,35 +2,32 @@ import React from 'react' import PropTypes from 'prop-types' import styles from './ReEnterSeed.scss' -const ReEnterSeed = ({ seed, seedInput, updateSeedInput }) => { - return ( -
    -
      - { - seed.map((word, index) => { - return ( -
    • -
      - -
      -
      - updateSeedInput({ word: event.target.value, index })} - className={`${styles.word} ${seedInput[index] && word === seedInput[index].word ? styles.valid : styles.invalid}`} - /> -
      -
    • - ) - }) - } -
    -
    - ) -} +const ReEnterSeed = ({ seed, seedInput, updateSeedInput }) => ( +
    +
      + { + seed.map((word, index) => ( +
    • +
      + +
      +
      + updateSeedInput({ word: event.target.value, index })} + className={`${styles.word} ${seedInput[index] && word === seedInput[index].word ? styles.valid : styles.invalid}`} + /> +
      +
    • + )) + } +
    +
    +) + ReEnterSeed.propTypes = { seed: PropTypes.array.isRequired, diff --git a/app/components/Onboarding/Signup.js b/app/components/Onboarding/Signup.js index 3e28e6fd..251d1719 100644 --- a/app/components/Onboarding/Signup.js +++ b/app/components/Onboarding/Signup.js @@ -34,6 +34,10 @@ const Signup = ({ signupForm, setSignupCreate, setSignupImport }) => (
    ) -Signup.propTypes = {} +Signup.propTypes = { + signupForm: PropTypes.object.isRequired, + setSignupCreate: PropTypes.func.isRequired, + setSignupImport: PropTypes.func.isRequired +} export default Signup diff --git a/app/containers/Root.js b/app/containers/Root.js index d0d9f40d..6f1bc2b4 100644 --- a/app/containers/Root.js +++ b/app/containers/Root.js @@ -74,14 +74,14 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => { const initWalletProps = { hasSeed: stateProps.onboarding.hasSeed, - + loginProps: { password: stateProps.onboarding.password, passwordIsValid: stateProps.passwordIsValid, hasSeed: stateProps.onboarding.hasSeed, unlockingWallet: stateProps.onboarding.unlockingWallet, unlockWalletError: stateProps.onboarding.unlockWalletError, - + updatePassword: dispatchProps.updatePassword, createWallet: dispatchProps.createWallet, unlockWallet: dispatchProps.unlockWallet diff --git a/app/lnd/index.js b/app/lnd/index.js index 4db8a714..aa5733e4 100644 --- a/app/lnd/index.js +++ b/app/lnd/index.js @@ -31,4 +31,4 @@ const initWalletUnlocker = (callback) => { export default { initLnd, initWalletUnlocker -} \ No newline at end of file +} diff --git a/app/lnd/init/index.js b/app/lnd/init/index.js deleted file mode 100644 index 74b0a81b..00000000 --- a/app/lnd/init/index.js +++ /dev/null @@ -1,13 +0,0 @@ -/* eslint no-console: 0 */ // --> OFF -import * as walletController from '../methods/walletController' - -export default function (walletUnlocker, meta, event, msg, data) { - console.log('msg yo wtf: ', msg) - switch (msg) { - case 'genSeed': - walletController.genSeed(walletUnlocker, meta) - .then(data => { console.log('data: ', data) }) - .catch(error => { console.log('error: ', error) }) - default: - } -} diff --git a/app/lnd/walletUnlockerMethods/index.js b/app/lnd/walletUnlockerMethods/index.js index 07a782a1..19adeb81 100644 --- a/app/lnd/walletUnlockerMethods/index.js +++ b/app/lnd/walletUnlockerMethods/index.js @@ -6,24 +6,18 @@ export default function (walletUnlocker, event, msg, data) { switch (msg) { case 'genSeed': walletController.genSeed(walletUnlocker) - .then(data => { - console.log('data yo: ', data) - event.sender.send('receiveSeed', data) - }) - .catch(error => { - console.log('genSeed error: ', error) - event.sender.send('receiveSeedError', error) - }) + .then(genSeedData => event.sender.send('receiveSeed', genSeedData)) + .catch(error => event.sender.send('receiveSeedError', error)) break case 'unlockWallet': walletController.unlockWallet(walletUnlocker, data) - .then(data => event.sender.send('walletUnlocked')) - .catch(error => event.sender.send('unlockWalletError')) + .then(() => event.sender.send('walletUnlocked')) + .catch(() => event.sender.send('unlockWalletError')) break case 'initWallet': walletController.initWallet(walletUnlocker, data) - .then(data => event.sender.send('successfullyCreatedWallet')) - .catch(error => console.log('initWallet error: ', error)) + .then(() => event.sender.send('successfullyCreatedWallet')) + .catch(error => console.log('initWallet error: ', error)) break default: } diff --git a/app/main.dev.js b/app/main.dev.js index 06d3ebc7..e3b54bba 100644 --- a/app/main.dev.js +++ b/app/main.dev.js @@ -17,7 +17,7 @@ import { spawn } from 'child_process' import { lookup } from 'ps-node' import os from 'os' import MenuBuilder from './menu' -import { initLnd, initWalletUnlocker } from './lnd' +import lnd from './lnd' const plat = os.platform() const homedir = os.homedir() @@ -111,7 +111,7 @@ const sendGrpcConnected = () => { // Create and subscribe the grpc object const startGrpc = () => { - initLnd((lndSubscribe, lndMethods) => { + lnd.initLnd((lndSubscribe, lndMethods) => { // Subscribe to bi-directional streams lndSubscribe(mainWindow) @@ -126,7 +126,7 @@ const startGrpc = () => { // Create and subscribe the grpc object const startWalletUnlocker = () => { - initWalletUnlocker((walletUnlockerMethods) => { + lnd.initWalletUnlocker((walletUnlockerMethods) => { // Listen for all gRPC restful methods ipcMain.on('walletUnlocker', (event, { msg, data }) => { walletUnlockerMethods(event, msg, data) @@ -196,7 +196,6 @@ const startLnd = (alias, autopilot) => { if (mainWindow) { mainWindow.webContents.send('walletUnlockerStarted') } - } }, 1000) } diff --git a/app/reducers/onboarding.js b/app/reducers/onboarding.js index 36921f67..675d7369 100644 --- a/app/reducers/onboarding.js +++ b/app/reducers/onboarding.js @@ -105,7 +105,7 @@ export function changeStep(step) { } export function startLnd(alias, autopilot) { - // once the user submits the data needed to start LND we will alert the app that it should start LND + // once the user submits the data needed to start LND we will alert the app that it should start LND ipcRenderer.send('startLnd', { alias, autopilot }) return { @@ -114,7 +114,7 @@ export function startLnd(alias, autopilot) { } export const submitNewWallet = (wallet_password, cipher_seed_mnemonic, aezeed_passphrase) => (dispatch) => { - // once the user submits the data needed to start LND we will alert the app that it should start LND + // once the user submits the data needed to start LND we will alert the app that it should start LND ipcRenderer.send('walletUnlocker', { msg: 'initWallet', data: { wallet_password, cipher_seed_mnemonic, aezeed_passphrase } }) dispatch({ type: CREATING_NEW_WALLET }) } @@ -134,7 +134,7 @@ export const createWallet = () => (dispatch) => { dispatch({ type: CHANGE_STEP, step: 4 }) } -export const successfullyCreatedWallet = (event) => (dispatch) => dispatch({ type: ONBOARDING_FINISHED }) +export const successfullyCreatedWallet = () => dispatch => dispatch({ type: ONBOARDING_FINISHED }) // Listener for when LND creates and sends us a generated seed export const receiveSeed = (event, { cipher_seed_mnemonic }) => (dispatch) => { @@ -144,14 +144,14 @@ export const receiveSeed = (event, { cipher_seed_mnemonic }) => (dispatch) => { } // Listener for when LND throws an error on seed creation -export const receiveSeedError = (event, error) => (dispatch) => { +export const receiveSeedError = () => (dispatch) => { dispatch({ type: SET_HAS_SEED, hasSeed: true }) // there is already a seed, send user to the login component dispatch({ type: CHANGE_STEP, step: 3 }) } // Unlock an existing wallet with a wallet password -export const unlockWallet = (wallet_password) => (dispatch) => { +export const unlockWallet = wallet_password => (dispatch) => { ipcRenderer.send('walletUnlocker', { msg: 'unlockWallet', data: { wallet_password } }) dispatch({ type: UNLOCKING_WALLET }) } @@ -174,23 +174,21 @@ const ACTION_HANDLERS = { [UPDATE_CREATE_WALLET_PASSWORD]: (state, { createWalletPassword }) => ({ ...state, createWalletPassword }), [UPDATE_CREATE_WALLET_PASSWORD_CONFIRMATION]: (state, { createWalletPasswordConfirmation }) => ({ ...state, createWalletPasswordConfirmation }), [UPDATE_AEZEED_PASSWORD]: (state, { aezeedPassword }) => ({ ...state, aezeedPassword }), - [UPDATE_SEED_INPUT]: (state, { inputSeedObj }) => { - return { - ...state, - seedInput: Object.assign([], state.seedInput, { [inputSeedObj['index']]: inputSeedObj }) - } - }, - + [UPDATE_SEED_INPUT]: (state, { inputSeedObj }) => ({ + ...state, + seedInput: Object.assign([], state.seedInput, { [inputSeedObj.index]: inputSeedObj }) + }), + [SET_AUTOPILOT]: (state, { autopilot }) => ({ ...state, autopilot }), - + [SET_HAS_SEED]: (state, { hasSeed }) => ({ ...state, hasSeed }), [SET_SEED]: (state, { seed }) => ({ ...state, seed, fetchingSeed: false }), - + [CHANGE_STEP]: (state, { step }) => ({ ...state, step }), - + [ONBOARDING_STARTED]: state => ({ ...state, onboarded: false }), [ONBOARDING_FINISHED]: state => ({ ...state, onboarded: true }), - + [STARTING_LND]: state => ({ ...state, startingLnd: true }), [LND_STARTED]: state => ({ ...state, startingLnd: false }), @@ -199,7 +197,7 @@ const ACTION_HANDLERS = { [UNLOCKING_WALLET]: state => ({ ...state, unlockingWallet: true }), [WALLET_UNLOCKED]: state => ({ ...state, unlockingWallet: false, unlockWalletError: { isError: false, message: '' } }), [SET_UNLOCK_WALLET_ERROR]: state => ({ ...state, unlockingWallet: false, unlockWalletError: { isError: true, message: 'Incorrect password' } }), - + [SET_SIGNUP_CREATE]: state => ({ ...state, signupForm: { create: true, import: false } }), [SET_SIGNUP_IMPORT]: state => ({ ...state, signupForm: { create: false, import: true } }) } @@ -241,11 +239,11 @@ const initialState = { alias: '', password: '', startingLnd: false, - + fetchingSeed: false, hasSeed: false, seed: [], - + // wallet password. password used to encrypt the wallet and is required to unlock the daemon after set createWalletPassword: '', createWalletPasswordConfirmation: '',