Browse Source

fix(lint + grpc): fix lint errors and a bug where gRPC connection starts too early

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
7cff397a4c
  1. 23
      app/components/Contacts/AddChannel.js
  2. 2
      app/components/Contacts/ChannelForm.js
  3. 51
      app/components/Contacts/ConnectManually.js
  4. 4
      app/components/Contacts/Network.js
  5. 28
      app/components/Contacts/SubmitChannelForm.js
  6. 2
      app/main.dev.js
  7. 4
      app/reducers/channels.js
  8. 24
      app/reducers/contactsform.js
  9. 9
      app/routes/app/components/App.js
  10. 4
      app/routes/app/containers/AppContainer.js

23
app/components/Contacts/AddChannel.js

@ -1,7 +1,6 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import Isvg from 'react-inlinesvg' import Isvg from 'react-inlinesvg'
import { FaCircle, FaQuestionCircle } from 'react-icons/lib/fa'
import x from 'icons/x.svg' import x from 'icons/x.svg'
@ -9,25 +8,19 @@ import styles from './AddChannel.scss'
const AddChannel = ({ const AddChannel = ({
contactsform, contactsform,
contactsform: { showErrors },
closeContactsForm, closeContactsForm,
openSubmitChannelForm, openSubmitChannelForm,
updateContactFormSearchQuery, updateContactFormSearchQuery,
updateManualFormSearchQuery, updateManualFormSearchQuery,
updateContactCapacity,
setNode, setNode,
openChannel,
updateManualFormErrors,
activeChannelPubkeys, activeChannelPubkeys,
nonActiveChannelPubkeys, nonActiveChannelPubkeys,
pendingOpenChannelPubkeys, pendingOpenChannelPubkeys,
filteredNetworkNodes, filteredNetworkNodes,
loadingChannelPubkeys, loadingChannelPubkeys,
showManualForm, showManualForm,
manualFormIsValid,
openManualForm openManualForm
}) => { }) => {
const renderRightSide = (node) => { const renderRightSide = (node) => {
if (loadingChannelPubkeys.includes(node.pub_key)) { if (loadingChannelPubkeys.includes(node.pub_key)) {
return ( return (
@ -140,7 +133,7 @@ const AddChannel = ({
{ {
showManualForm && showManualForm &&
<section className={styles.manualForm}> <section className={styles.manualForm}>
<p>Hm, looks like we can't see that node from here, wanna try to manually connect?</p> <p>Hm, looks like we can&apos;t see that node from here, wanna try to manually connect?</p>
<div className={styles.manualConnectButton} onClick={openManualForm}>Connect Manually</div> <div className={styles.manualConnectButton} onClick={openManualForm}>Connect Manually</div>
</section> </section>
} }
@ -149,7 +142,19 @@ const AddChannel = ({
} }
AddChannel.propTypes = { AddChannel.propTypes = {
contactsform: PropTypes.object.isRequired,
closeContactsForm: PropTypes.func.isRequired,
openSubmitChannelForm: PropTypes.func.isRequired,
updateContactFormSearchQuery: PropTypes.func.isRequired,
updateManualFormSearchQuery: PropTypes.func.isRequired,
setNode: PropTypes.func.isRequired,
activeChannelPubkeys: PropTypes.array.isRequired,
nonActiveChannelPubkeys: PropTypes.array.isRequired,
pendingOpenChannelPubkeys: PropTypes.array.isRequired,
filteredNetworkNodes: PropTypes.array.isRequired,
loadingChannelPubkeys: PropTypes.array.isRequired,
showManualForm: PropTypes.bool.isRequired,
openManualForm: PropTypes.func.isRequired
} }
export default AddChannel export default AddChannel

2
app/components/Contacts/ChannelForm.js

@ -15,11 +15,9 @@ const FORM_TYPES = {
} }
const ChannelForm = ({ formType, formProps, closeForm }) => { const ChannelForm = ({ formType, formProps, closeForm }) => {
console.log('formType: ', formType)
if (!formType) { return null } if (!formType) { return null }
const FormComponent = FORM_TYPES[formType] const FormComponent = FORM_TYPES[formType]
console.log('FormComponent: ', FormComponent)
return ( return (
<div className={styles.container}> <div className={styles.container}>
<div className={styles.closeContainer}> <div className={styles.closeContainer}>

51
app/components/Contacts/ConnectManually.js

@ -1,16 +1,10 @@
import React from 'react' import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { FaAngleDown } from 'react-icons/lib/fa'
import Isvg from 'react-inlinesvg'
import x from 'icons/x.svg'
import styles from './ConnectManually.scss' import styles from './ConnectManually.scss'
class ConnectManually extends React.Component { class ConnectManually extends React.Component {
render() { render() {
const { const {
manualFormOpen,
manualSearchQuery, manualSearchQuery,
manualFormIsValid, manualFormIsValid,
@ -27,35 +21,35 @@ class ConnectManually extends React.Component {
const formSubmitted = () => { const formSubmitted = () => {
if (!manualFormIsValid.isValid) { if (!manualFormIsValid.isValid) {
updateManualFormErrors(manualFormIsValid.errors) updateManualFormErrors(manualFormIsValid.errors)
return return
} }
// clear any existing errors // clear any existing errors
updateManualFormErrors({ manualInput: null }) updateManualFormErrors({ manualInput: null })
const [pub_key, addr] = manualSearchQuery && manualSearchQuery.split('@') const [pub_key, addr] = manualSearchQuery && manualSearchQuery.split('@')
// the SubmitChannel component is expecting a node object that looks like the following // the SubmitChannel component is expecting a node object that looks like the following
// { // {
// pub_key: 'some_string', // pub_key: 'some_string',
// addresses: [ // addresses: [
// { // {
// addr: 'some_host_address' // addr: 'some_host_address'
// } // }
// ] // ]
// } // }
// knowing this we will set the node object with the known format and plug in the pubkey + host accordingly // knowing this we will set the node object with the known format and plug in the pubkey + host accordingly
setNode({ pub_key, addresses: [{ addr }] }) setNode({ pub_key, addresses: [{ addr }] })
// now we close the ConnectManually form and open the SubmitChannel form by chaning the channelFormType // now we close the ConnectManually form and open the SubmitChannel form by chaning the channelFormType
openSubmitChannelForm() openSubmitChannelForm()
} }
return ( return (
<div className={styles.content}> <div className={styles.content}>
<header className={styles.header}> <header className={styles.header}>
<h1>Connect Manually</h1> <h1>Connect Manually</h1>
<p>Please enter the peer's pubkey@host</p> <p>Please enter the peer&apos;s pubkey@host</p>
</header> </header>
<section className={styles.peer}> <section className={styles.peer}>
@ -89,7 +83,6 @@ class ConnectManually extends React.Component {
} }
ConnectManually.propTypes = { ConnectManually.propTypes = {
manualFormOpen: PropTypes.bool.isRequired,
manualSearchQuery: PropTypes.string.isRequired, manualSearchQuery: PropTypes.string.isRequired,
manualFormIsValid: PropTypes.object.isRequired, manualFormIsValid: PropTypes.object.isRequired,
@ -100,7 +93,7 @@ ConnectManually.propTypes = {
setNode: PropTypes.func.isRequired, setNode: PropTypes.func.isRequired,
showErrors: PropTypes.bool.isRequired showErrors: PropTypes.object.isRequired
} }
export default ConnectManually export default ConnectManually

4
app/components/Contacts/Network.js

@ -24,7 +24,7 @@ class Network extends Component {
searchQuery, searchQuery,
filterPulldown, filterPulldown,
filter, filter,
loadingChannelPubkeys, loadingChannelPubkeys
// closingChannelIds // closingChannelIds
}, },
currentChannels, currentChannels,
@ -144,7 +144,7 @@ class Network extends Component {
<ul className={filterPulldown && styles.fade}> <ul className={filterPulldown && styles.fade}>
{ {
loadingChannelPubkeys.map(loadingPubkey => { loadingChannelPubkeys.map((loadingPubkey) => {
// TODO(jimmymow): refactor this out. same logic is in displayNodeName above // TODO(jimmymow): refactor this out. same logic is in displayNodeName above
const node = find(nodes, n => loadingPubkey === n.pub_key) const node = find(nodes, n => loadingPubkey === n.pub_key)
const nodeDisplay = () => { const nodeDisplay = () => {

28
app/components/Contacts/SubmitChannelForm.js

@ -2,15 +2,12 @@ import React from 'react'
import PropTypes from 'prop-types' import PropTypes from 'prop-types'
import { FaAngleDown } from 'react-icons/lib/fa' import { FaAngleDown } from 'react-icons/lib/fa'
import Isvg from 'react-inlinesvg'
import x from 'icons/x.svg'
import styles from './SubmitChannelForm.scss' import styles from './SubmitChannelForm.scss'
class SubmitChannelForm extends React.Component { class SubmitChannelForm extends React.Component {
render() { render() {
const { const {
submitChannelFormOpen,
closeChannelForm, closeChannelForm,
closeContactsForm, closeContactsForm,
@ -21,7 +18,6 @@ class SubmitChannelForm extends React.Component {
toggleCurrencyProps: { toggleCurrencyProps: {
setContactsCurrencyFilters, setContactsCurrencyFilters,
setCurrencyFilters,
showCurrencyFilters, showCurrencyFilters,
currencyName, currencyName,
currentCurrencyFilters, currentCurrencyFilters,
@ -35,9 +31,9 @@ class SubmitChannelForm extends React.Component {
// if not, just show the pubkey (would look ugly with rando parens) // if not, just show the pubkey (would look ugly with rando parens)
if (node.alias && node.alias.length) { if (node.alias && node.alias.length) {
return `${node.alias} (${node.pub_key})` return `${node.alias} (${node.pub_key})`
} else {
return node.pub_key
} }
return node.pub_key
} }
const formSubmitted = () => { const formSubmitted = () => {
@ -55,7 +51,10 @@ class SubmitChannelForm extends React.Component {
<div className={styles.content}> <div className={styles.content}>
<header className={styles.header}> <header className={styles.header}>
<h1>Add Funds to Network</h1> <h1>Add Funds to Network</h1>
<p>Adding a connection will help you send and receive money on the Lightning Network. You aren't spening any money, rather moving the money you plan to use onto the network.</p> <p>
Adding a connection will help you send and receive money on the Lightning Network.
You aren&apos;t spening any money, rather moving the money you plan to use onto the network.
</p>
</header> </header>
<section className={styles.title}> <section className={styles.title}>
@ -104,6 +103,19 @@ class SubmitChannelForm extends React.Component {
} }
} }
SubmitChannelForm.propTypes = {} SubmitChannelForm.propTypes = {
closeChannelForm: PropTypes.func.isRequired,
closeContactsForm: PropTypes.func.isRequired,
node: PropTypes.object.isRequired,
contactCapacity: PropTypes.PropTypes.oneOfType([
PropTypes.number,
PropTypes.string
]),
updateContactCapacity: PropTypes.func.isRequired,
openChannel: PropTypes.func.isRequired,
toggleCurrencyProps: PropTypes.object.isRequired
}
export default SubmitChannelForm export default SubmitChannelForm

2
app/main.dev.js

@ -200,7 +200,7 @@ const startLnd = (alias, autopilot) => {
}, 1000) }, 1000)
} }
if (line.includes('LightningWallet opened')) { if (line.includes('gRPC proxy started') && !line.includes('password')) {
console.log('WALLET OPENED, STARTING LIGHTNING GRPC CONNECTION') console.log('WALLET OPENED, STARTING LIGHTNING GRPC CONNECTION')
sendLndSyncing() sendLndSyncing()
startGrpc() startGrpc()

4
app/reducers/channels.js

@ -166,8 +166,6 @@ export const openChannel = ({
// Receive IPC event for openChannel // Receive IPC event for openChannel
export const channelSuccessful = () => (dispatch) => { export const channelSuccessful = () => (dispatch) => {
dispatch(fetchChannels()) dispatch(fetchChannels())
dispatch(closeChannelForm())
dispatch(resetChannelForm())
} }
// Receive IPC event for updated channel // Receive IPC event for updated channel
@ -198,8 +196,6 @@ export const closeChannel = ({ channel_point, chan_id, force }) => (dispatch) =>
dispatch(closingChannel()) dispatch(closingChannel())
dispatch(addClosingChanId(chan_id)) dispatch(addClosingChanId(chan_id))
console.log('force: ', force)
const [funding_txid, output_index] = channel_point.split(':') const [funding_txid, output_index] = channel_point.split(':')
ipcRenderer.send( ipcRenderer.send(
'lnd', 'lnd',

24
app/reducers/contactsform.js

@ -16,8 +16,6 @@ const initialState = {
searchQuery: '', searchQuery: '',
manualSearchQuery: '', manualSearchQuery: '',
contactCapacity: 0.1, contactCapacity: 0.1,
pubkey: '',
host: '',
node: {}, node: {},
showErrors: { showErrors: {
manualInput: false manualInput: false
@ -45,8 +43,6 @@ export const CLOSE_MANUAL_FORM = 'CLOSE_MANUAL_FORM'
export const OPEN_SUBMIT_CHANNEL_FORM = 'OPEN_SUBMIT_CHANNEL_FORM' export const OPEN_SUBMIT_CHANNEL_FORM = 'OPEN_SUBMIT_CHANNEL_FORM'
export const CLOSE_SUBMIT_CHANNEL_FORM = 'CLOSE_SUBMIT_CHANNEL_FORM' export const CLOSE_SUBMIT_CHANNEL_FORM = 'CLOSE_SUBMIT_CHANNEL_FORM'
export const SET_PUBKEY = 'SET_PUBKEY'
export const SET_HOST = 'SET_HOST'
export const SET_NODE = 'SET_NODE' export const SET_NODE = 'SET_NODE'
export const UPDATE_CONTACT_FORM_SEARCH_QUERY = 'UPDATE_CONTACT_FORM_SEARCH_QUERY' export const UPDATE_CONTACT_FORM_SEARCH_QUERY = 'UPDATE_CONTACT_FORM_SEARCH_QUERY'
@ -138,20 +134,6 @@ export function updateContactCapacity(contactCapacity) {
} }
} }
export function setPubkey(pubkey) {
return {
type: SET_PUBKEY,
pubkey
}
}
export function setHost(host) {
return {
type: SET_HOST,
host
}
}
export function setNode(node) { export function setNode(node) {
return { return {
type: SET_NODE, type: SET_NODE,
@ -179,7 +161,7 @@ export function setContactsCurrencyFilters(showCurrencyFilters) {
const ACTION_HANDLERS = { const ACTION_HANDLERS = {
[OPEN_CONTACTS_FORM]: state => ({ ...state, isOpen: true }), [OPEN_CONTACTS_FORM]: state => ({ ...state, isOpen: true }),
[CLOSE_CONTACTS_FORM]: state => ({ ...state, isOpen: false }), [CLOSE_CONTACTS_FORM]: state => ({ ...state, isOpen: false }),
[SET_CHANNEL_FORM_TYPE]: (state, { formType }) => ({ ...state, formType }), [SET_CHANNEL_FORM_TYPE]: (state, { formType }) => ({ ...state, formType }),
[OPEN_MANUAL_FORM]: state => ({ ...state, manualFormOpen: true }), [OPEN_MANUAL_FORM]: state => ({ ...state, manualFormOpen: true }),
@ -193,9 +175,7 @@ const ACTION_HANDLERS = {
[UPDATE_MANUAL_FORM_SEARCH_QUERY]: (state, { searchQuery }) => ({ ...state, searchQuery }), [UPDATE_MANUAL_FORM_SEARCH_QUERY]: (state, { searchQuery }) => ({ ...state, searchQuery }),
[UPDATE_CONTACT_CAPACITY]: (state, { contactCapacity }) => ({ ...state, contactCapacity }), [UPDATE_CONTACT_CAPACITY]: (state, { contactCapacity }) => ({ ...state, contactCapacity }),
[SET_PUBKEY]: (state, { pubkey }) => ({ ...state, pubkey }),
[SET_HOST]: (state, { host }) => ({ ...state, host }),
[SET_NODE]: (state, { node }) => ({ ...state, node }), [SET_NODE]: (state, { node }) => ({ ...state, node }),
[UPDATE_MANUAL_FORM_ERRORS]: (state, { errorsObject }) => ({ ...state, showErrors: Object.assign(state.showErrors, errorsObject) }), [UPDATE_MANUAL_FORM_ERRORS]: (state, { errorsObject }) => ({ ...state, showErrors: Object.assign(state.showErrors, errorsObject) }),

9
app/routes/app/components/App.js

@ -11,10 +11,6 @@ import ModalRoot from 'components/ModalRoot'
import Network from 'components/Contacts/Network' import Network from 'components/Contacts/Network'
import AddChannel from 'components/Contacts/AddChannel' import AddChannel from 'components/Contacts/AddChannel'
import ContactModal from 'components/Contacts/ContactModal' import ContactModal from 'components/Contacts/ContactModal'
import ContactsForm from 'components/Contacts/ContactsForm'
import SubmitChannelForm from 'components/Contacts/SubmitChannelForm'
import ConnectManually from 'components/Contacts/ConnectManually'
import ReceiveModal from 'components/Wallet/ReceiveModal' import ReceiveModal from 'components/Wallet/ReceiveModal'
import ActivityModal from 'components/Activity/ActivityModal' import ActivityModal from 'components/Activity/ActivityModal'
@ -65,12 +61,8 @@ class App extends Component {
networkTabProps, networkTabProps,
receiveModalProps, receiveModalProps,
activityModalProps, activityModalProps,
submitChannelFormProps,
connectManuallyProps,
channelFormProps, channelFormProps,
contactsform,
children children
} = this.props } = this.props
@ -124,6 +116,7 @@ App.propTypes = {
networkTabProps: PropTypes.object, networkTabProps: PropTypes.object,
activityModalProps: PropTypes.object, activityModalProps: PropTypes.object,
receiveModalProps: PropTypes.object, receiveModalProps: PropTypes.object,
channelFormProps: PropTypes.object,
newAddress: PropTypes.func.isRequired, newAddress: PropTypes.func.isRequired,
fetchInfo: PropTypes.func.isRequired, fetchInfo: PropTypes.func.isRequired,

4
app/routes/app/containers/AppContainer.js

@ -380,7 +380,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
contactCapacity: stateProps.contactsform.contactCapacity, contactCapacity: stateProps.contactsform.contactCapacity,
updateContactCapacity: dispatchProps.updateContactCapacity, updateContactCapacity: dispatchProps.updateContactCapacity,
closeChannelForm: () => dispatchProps.setChannelFormType(null), closeChannelForm: () => dispatchProps.setChannelFormType(null),
closeContactsForm: dispatchProps.closeContactsForm, closeContactsForm: dispatchProps.closeContactsForm,
@ -408,7 +408,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
updateManualFormErrors: dispatchProps.updateManualFormErrors, updateManualFormErrors: dispatchProps.updateManualFormErrors,
setNode: dispatchProps.setNode, setNode: dispatchProps.setNode,
openSubmitChannelForm: () => dispatchProps.setChannelFormType('SUBMIT_CHANNEL_FORM'), openSubmitChannelForm: () => dispatchProps.setChannelFormType('SUBMIT_CHANNEL_FORM'),
manualFormOpen: stateProps.contactsform.manualFormOpen, manualFormOpen: stateProps.contactsform.manualFormOpen,
manualSearchQuery: stateProps.contactsform.manualSearchQuery, manualSearchQuery: stateProps.contactsform.manualSearchQuery,
manualFormIsValid: stateProps.manualFormIsValid, manualFormIsValid: stateProps.manualFormIsValid,

Loading…
Cancel
Save