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 PropTypes from 'prop-types'
import Isvg from 'react-inlinesvg'
import { FaCircle, FaQuestionCircle } from 'react-icons/lib/fa'
import x from 'icons/x.svg'
@ -9,25 +8,19 @@ import styles from './AddChannel.scss'
const AddChannel = ({
contactsform,
contactsform: { showErrors },
closeContactsForm,
openSubmitChannelForm,
updateContactFormSearchQuery,
updateManualFormSearchQuery,
updateContactCapacity,
setNode,
openChannel,
updateManualFormErrors,
activeChannelPubkeys,
nonActiveChannelPubkeys,
pendingOpenChannelPubkeys,
filteredNetworkNodes,
loadingChannelPubkeys,
showManualForm,
manualFormIsValid,
openManualForm
}) => {
const renderRightSide = (node) => {
if (loadingChannelPubkeys.includes(node.pub_key)) {
return (
@ -140,7 +133,7 @@ const AddChannel = ({
{
showManualForm &&
<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>
</section>
}
@ -149,7 +142,19 @@ const AddChannel = ({
}
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

2
app/components/Contacts/ChannelForm.js

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

51
app/components/Contacts/ConnectManually.js

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

4
app/components/Contacts/Network.js

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

28
app/components/Contacts/SubmitChannelForm.js

@ -2,15 +2,12 @@ import React from 'react'
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 './SubmitChannelForm.scss'
class SubmitChannelForm extends React.Component {
render() {
const {
submitChannelFormOpen,
closeChannelForm,
closeContactsForm,
@ -21,7 +18,6 @@ class SubmitChannelForm extends React.Component {
toggleCurrencyProps: {
setContactsCurrencyFilters,
setCurrencyFilters,
showCurrencyFilters,
currencyName,
currentCurrencyFilters,
@ -35,9 +31,9 @@ class SubmitChannelForm extends React.Component {
// if not, just show the pubkey (would look ugly with rando parens)
if (node.alias && node.alias.length) {
return `${node.alias} (${node.pub_key})`
} else {
return node.pub_key
}
return node.pub_key
}
const formSubmitted = () => {
@ -55,7 +51,10 @@ class SubmitChannelForm extends React.Component {
<div className={styles.content}>
<header className={styles.header}>
<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>
<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

2
app/main.dev.js

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

4
app/reducers/channels.js

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

24
app/reducers/contactsform.js

@ -16,8 +16,6 @@ const initialState = {
searchQuery: '',
manualSearchQuery: '',
contactCapacity: 0.1,
pubkey: '',
host: '',
node: {},
showErrors: {
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 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 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) {
return {
type: SET_NODE,
@ -179,7 +161,7 @@ export function setContactsCurrencyFilters(showCurrencyFilters) {
const ACTION_HANDLERS = {
[OPEN_CONTACTS_FORM]: state => ({ ...state, isOpen: true }),
[CLOSE_CONTACTS_FORM]: state => ({ ...state, isOpen: false }),
[SET_CHANNEL_FORM_TYPE]: (state, { formType }) => ({ ...state, formType }),
[OPEN_MANUAL_FORM]: state => ({ ...state, manualFormOpen: true }),
@ -193,9 +175,7 @@ const ACTION_HANDLERS = {
[UPDATE_MANUAL_FORM_SEARCH_QUERY]: (state, { searchQuery }) => ({ ...state, searchQuery }),
[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 }),
[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 AddChannel from 'components/Contacts/AddChannel'
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 ActivityModal from 'components/Activity/ActivityModal'
@ -65,12 +61,8 @@ class App extends Component {
networkTabProps,
receiveModalProps,
activityModalProps,
submitChannelFormProps,
connectManuallyProps,
channelFormProps,
contactsform,
children
} = this.props
@ -124,6 +116,7 @@ App.propTypes = {
networkTabProps: PropTypes.object,
activityModalProps: PropTypes.object,
receiveModalProps: PropTypes.object,
channelFormProps: PropTypes.object,
newAddress: 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,
updateContactCapacity: dispatchProps.updateContactCapacity,
closeChannelForm: () => dispatchProps.setChannelFormType(null),
closeContactsForm: dispatchProps.closeContactsForm,
@ -408,7 +408,7 @@ const mergeProps = (stateProps, dispatchProps, ownProps) => {
updateManualFormErrors: dispatchProps.updateManualFormErrors,
setNode: dispatchProps.setNode,
openSubmitChannelForm: () => dispatchProps.setChannelFormType('SUBMIT_CHANNEL_FORM'),
manualFormOpen: stateProps.contactsform.manualFormOpen,
manualSearchQuery: stateProps.contactsform.manualSearchQuery,
manualFormIsValid: stateProps.manualFormIsValid,

Loading…
Cancel
Save