Browse Source

fix(lint): fix linting errors

renovate/lint-staged-8.x
Jack Mallers 7 years ago
parent
commit
704e803f40
  1. 1
      app/lnd/methods/index.js
  2. 50
      app/reducers/activity.js
  3. 4
      app/reducers/payment.js
  4. 3
      app/reducers/transaction.js
  5. 63
      app/routes/activity/components/Activity.js
  6. 8
      app/routes/activity/components/components/Invoice/Invoice.js
  7. 2
      app/routes/activity/components/components/Invoice/index.js
  8. 3
      app/routes/activity/components/components/Modal/Invoice/Invoice.js
  9. 2
      app/routes/activity/components/components/Modal/Invoice/index.js
  10. 10
      app/routes/activity/components/components/Modal/Modal.js
  11. 7
      app/routes/activity/components/components/Modal/Payment/Payment.js
  12. 2
      app/routes/activity/components/components/Modal/Payment/index.js
  13. 7
      app/routes/activity/components/components/Modal/Transaction/Transaction.js
  14. 2
      app/routes/activity/components/components/Modal/Transaction/index.js
  15. 2
      app/routes/activity/components/components/Modal/index.js
  16. 8
      app/routes/activity/components/components/Payment/Payment.js
  17. 6
      app/routes/activity/components/components/Transaction/Transaction.js
  18. 3
      app/routes/app/components/App.js
  19. 2
      app/routes/app/components/components/Form/Form.js

1
app/lnd/methods/index.js

@ -54,6 +54,7 @@ export default function (lnd, event, msg, data) {
walletController.getTransactions(lnd)
.then(transactionsData => event.sender.send('receiveTransactions', transactionsData))
.catch(error => console.log('transactions error: ', error))
break
case 'payments':
// Data looks like { payments: [] }
paymentsController.listPayments(lnd)

50
app/reducers/activity.js

@ -7,11 +7,11 @@ const initialState = {
filterPulldown: false,
filter: { key: 'ALL_ACTIVITY', name: 'Activity' },
filters: [
{ key: 'ALL_ACTIVITY', name: 'All Activity'},
{ key: 'LN_ACTIVITY', name: 'LN Activity'},
{ key: 'PAYMENT_ACTIVITY', name: 'LN Payments'},
{ key: 'INVOICE_ACTIVITY', name: 'LN Invoices'},
{ key: 'TRANSACTION_ACTIVITY', name: 'On-chain Activity'}
{ key: 'ALL_ACTIVITY', name: 'All Activity' },
{ key: 'LN_ACTIVITY', name: 'LN Activity' },
{ key: 'PAYMENT_ACTIVITY', name: 'LN Payments' },
{ key: 'INVOICE_ACTIVITY', name: 'LN Invoices' },
{ key: 'TRANSACTION_ACTIVITY', name: 'On-chain Activity' }
],
modal: {
modalType: null,
@ -64,9 +64,9 @@ export function toggleFilterPulldown() {
// ------------------------------------
const ACTION_HANDLERS = {
[SHOW_ACTIVITY_MODAL]: (state, { modalType, modalProps }) => ({ ...state, modal: { modalType, modalProps } }),
[HIDE_ACTIVITY_MODAL]: (state) => ({ ...state, modal: { modalType: null, modalProps: {} } }),
[HIDE_ACTIVITY_MODAL]: state => ({ ...state, modal: { modalType: null, modalProps: {} } }),
[CHANGE_FILTER]: (state, { filter }) => ({ ...state, filter, filterPulldown: false }),
[TOGGLE_PULLDOWN]: (state) => ({ ...state, filterPulldown: !state.filterPulldown })
[TOGGLE_PULLDOWN]: state => ({ ...state, filterPulldown: !state.filterPulldown })
}
// ------------------------------------
@ -83,27 +83,18 @@ const allActivity = createSelector(
paymentsSelector,
invoicesSelector,
transactionsSelector,
(payments, invoices, transactions) => {
return [...payments, ...invoices, ...transactions].sort((a, b) => {
let aTimestamp = a.hasOwnProperty('time_stamp') ? a.time_stamp : a.creation_date
let bTimestamp = b.hasOwnProperty('time_stamp') ? b.time_stamp : b.creation_date
(payments, invoices, transactions) => [...payments, ...invoices, ...transactions].sort((a, b) => {
const aTimestamp = Object.prototype.hasOwnProperty.call(a, 'time_stamp') ? a.time_stamp : a.creation_date
const bTimestamp = Object.prototype.hasOwnProperty.call(b, 'time_stamp') ? b.time_stamp : b.creation_date
return bTimestamp - aTimestamp
})
}
return bTimestamp - aTimestamp
})
)
const lnActivity = createSelector(
paymentsSelector,
invoicesSelector,
(payments, invoices) => {
return [...payments, ...invoices].sort((a, b) => {
let aTimestamp = a.hasOwnProperty('time_stamp') ? a.time_stamp : a.creation_date
let bTimestamp = b.hasOwnProperty('time_stamp') ? b.time_stamp : b.creation_date
return bTimestamp - aTimestamp
})
}
(payments, invoices) => [...payments, ...invoices].sort((a, b) => b.creation_date - a.creation_date)
)
const paymentActivity = createSelector(
@ -121,6 +112,14 @@ const transactionActivity = createSelector(
transactions => transactions
)
const FILTERS = {
ALL_ACTIVITY: allActivity,
LN_ACTIVITY: lnActivity,
PAYMENT_ACTIVITY: paymentActivity,
INVOICE_ACTIVITY: invoiceActivity,
TRANSACTION_ACTIVITY: transactionActivity
}
activitySelectors.currentActivity = createSelector(
filterSelector,
filter => FILTERS[filter.key]
@ -132,13 +131,6 @@ activitySelectors.nonActiveFilters = createSelector(
(filters, filter) => filters.filter(f => f.key !== filter.key)
)
const FILTERS = {
ALL_ACTIVITY: allActivity,
LN_ACTIVITY: lnActivity,
PAYMENT_ACTIVITY: paymentActivity,
INVOICE_ACTIVITY: invoiceActivity,
TRANSACTION_ACTIVITY: transactionActivity
}
export { activitySelectors }

4
app/reducers/payment.js

@ -1,8 +1,6 @@
import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron'
import { btc, usd } from '../utils'
import { setForm, resetForm } from './form'
import { showModal } from './modal'
// ------------------------------------
// Constants
@ -68,7 +66,7 @@ export const payInvoice = paymentRequest => (dispatch) => {
// Receive IPC event for successful payment
// TODO: Add payment to state, not a total re-fetch
export const paymentSuccessful = () => dispatch => {
export const paymentSuccessful = () => (dispatch) => {
// Close the form modal once the payment was succesful
dispatch(setForm({ modalOpen: false }))

3
app/reducers/transaction.js

@ -1,4 +1,3 @@
import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron'
import { btc, usd } from '../utils'
import { setForm, resetForm } from './form'
@ -62,7 +61,7 @@ export const transactionSuccessful = (event, { amount, addr, txid }) => (dispatc
}
export const transactionError = () => (dispatch) => {
dispatch({ type: PAYMENT_FAILED })
dispatch({ type: TRANSACTION_FAILED })
}

63
app/routes/activity/components/Activity.js

@ -1,7 +1,7 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { MdSearch } from 'react-icons/lib/md'
import { FaChain, FaBolt, FaAngleDown } from 'react-icons/lib/fa'
import { FaAngleDown } from 'react-icons/lib/fa'
import Invoice from './components/Invoice'
import Payment from './components/Payment'
@ -14,10 +14,6 @@ import styles from './Activity.scss'
class Activity extends Component {
constructor(props, context) {
super(props, context)
this.state = {
pulldown: false
}
this.renderActivity = this.renderActivity.bind(this)
}
@ -32,29 +28,23 @@ class Activity extends Component {
renderActivity(activity) {
const { ticker, currentTicker, showActivityModal } = this.props
if (activity.hasOwnProperty('block_hash')) {
if (Object.prototype.hasOwnProperty.call(activity, 'block_hash')) {
// activity is an on-chain tx
return <Transaction transaction={activity} ticker={ticker} currentTicker={currentTicker} showActivityModal={showActivityModal} />
} else if (activity.hasOwnProperty('payment_request')) {
} else if (Object.prototype.hasOwnProperty.call(activity, 'payment_request')) {
// activity is an LN invoice
return <Invoice invoice={activity} ticker={ticker} currentTicker={currentTicker} showActivityModal={showActivityModal} />
} else {
// activity is an LN payment
return <Payment payment={activity} ticker={ticker} currentTicker={currentTicker} showActivityModal={showActivityModal} />
}
// activity is an LN payment
return <Payment payment={activity} ticker={ticker} currentTicker={currentTicker} showActivityModal={showActivityModal} />
}
render() {
const {
ticker,
searchInvoices,
invoices,
invoice: { invoicesSearchText, invoice, invoiceLoading },
payment: { payment, payments, paymentLoading },
setPayment,
setInvoice,
paymentModalOpen,
invoiceModalOpen,
invoice: { invoicesSearchText, invoiceLoading },
payment: { paymentLoading },
currentTicker,
activity: { modal, filter, filterPulldown },
hideActivityModal,
@ -64,8 +54,6 @@ class Activity extends Component {
nonActiveFilters
} = this.props
const { pulldown } = this.state
if (invoiceLoading || paymentLoading) { return <div>Loading...</div> }
return (
@ -77,7 +65,7 @@ class Activity extends Component {
ticker={ticker}
currentTicker={currentTicker}
/>
<div className={styles.search}>
<label className={`${styles.label} ${styles.input}`} htmlFor='invoiceSearch'>
<MdSearch />
@ -100,10 +88,10 @@ class Activity extends Component {
</h2>
<ul className={`${styles.filters} ${filterPulldown ? styles.active : ''}`}>
{
nonActiveFilters.map(filter =>
<li key={filter.key} onClick={() => changeFilter(filter)}>
{filter.name}
</li>
nonActiveFilters.map(f =>
(<li key={f.key} onClick={() => changeFilter(f)}>
{f.name}
</li>)
)
}
</ul>
@ -111,13 +99,11 @@ class Activity extends Component {
</header>
<ul className={`${styles.activityContainer} ${filterPulldown ? styles.pulldown : ''}`}>
{
currentActivity.map((activity, index) => {
return (
<li className={styles.activity} key={index}>
{this.renderActivity(activity)}
</li>
)
})
currentActivity.map((activity, index) => (
<li className={styles.activity} key={index}>
{this.renderActivity(activity)}
</li>
))
}
</ul>
</div>
@ -129,16 +115,19 @@ class Activity extends Component {
Activity.propTypes = {
fetchPayments: PropTypes.func.isRequired,
fetchInvoices: PropTypes.func.isRequired,
fetchTransactions: PropTypes.func.isRequired,
ticker: PropTypes.object.isRequired,
searchInvoices: PropTypes.func.isRequired,
invoices: PropTypes.array.isRequired,
invoice: PropTypes.object.isRequired,
payment: PropTypes.object.isRequired,
setPayment: PropTypes.func.isRequired,
setInvoice: PropTypes.func.isRequired,
paymentModalOpen: PropTypes.bool.isRequired,
invoiceModalOpen: PropTypes.bool.isRequired,
currentTicker: PropTypes.object.isRequired
currentTicker: PropTypes.object.isRequired,
showActivityModal: PropTypes.func.isRequired,
hideActivityModal: PropTypes.func.isRequired,
changeFilter: PropTypes.func.isRequired,
toggleFilterPulldown: PropTypes.func.isRequired,
activity: PropTypes.object.isRequired,
currentActivity: PropTypes.array.isRequired,
nonActiveFilters: PropTypes.array.isRequired
}
export default Activity

8
app/routes/activity/components/components/Invoice/Invoice.js

@ -4,7 +4,6 @@ import Moment from 'react-moment'
import 'moment-timezone'
import { FaBolt, FaClockO } from 'react-icons/lib/fa'
import { btc } from '../../../../../utils'
import CurrencyIcon from '../../../../../components/CurrencyIcon'
import styles from '../Activity.scss'
const Invoice = ({ invoice, ticker, currentTicker, showActivityModal }) => (
@ -45,7 +44,7 @@ const Invoice = ({ invoice, ticker, currentTicker, showActivityModal }) => (
</div>
<div className={`${styles.amount} ${invoice.settled ? styles.positive : styles.negative}`}>
<span className='hint--top' data-hint='Invoice amount'>
+
+
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(invoice.value, currentTicker.price_usd)
@ -66,7 +65,10 @@ const Invoice = ({ invoice, ticker, currentTicker, showActivityModal }) => (
)
Invoice.propTypes = {
invoice: PropTypes.object.isRequired,
ticker: PropTypes.object.isRequired,
currentTicker: PropTypes.object.isRequired,
showActivityModal: PropTypes.func.isRequired
}
export default Invoice

2
app/routes/activity/components/components/Invoice/index.js

@ -1,3 +1,3 @@
import Invoice from './Invoice'
export default Invoice
export default Invoice

3
app/routes/activity/components/components/Modal/Invoice/Invoice.js

@ -53,6 +53,9 @@ const Invoice = ({ invoice, ticker, currentTicker }) => (
)
Invoice.propTypes = {
invoice: PropTypes.object.isRequired,
ticker: PropTypes.object.isRequired,
currentTicker: PropTypes.object.isRequired
}
export default Invoice

2
app/routes/activity/components/components/Modal/Invoice/index.js

@ -1,3 +1,3 @@
import Invoice from './Invoice'
export default Invoice
export default Invoice

10
app/routes/activity/components/components/Modal/Modal.js

@ -11,7 +11,7 @@ const Modal = ({ modalType, modalProps, hideActivityModal, ticker, currentTicker
TRANSACTION: Transaction,
PAYMENT: Payment,
INVOICE: Invoice
}
const customStyles = {
overlay: {
@ -26,7 +26,7 @@ const Modal = ({ modalType, modalProps, hideActivityModal, ticker, currentTicker
margin: '50px auto'
}
}
if (!modalType) { return null }
const SpecificModal = MODAL_COMPONENTS[modalType]
@ -47,7 +47,11 @@ const Modal = ({ modalType, modalProps, hideActivityModal, ticker, currentTicker
}
Modal.propTypes = {
modalType: PropTypes.string
modalType: PropTypes.string,
modalProps: PropTypes.object.isRequired,
hideActivityModal: PropTypes.func.isRequired,
ticker: PropTypes.object.isRequired,
currentTicker: PropTypes.object.isRequired
}
export default Modal

7
app/routes/activity/components/components/Modal/Payment/Payment.js

@ -4,10 +4,6 @@ import PropTypes from 'prop-types'
import Moment from 'react-moment'
import 'moment-timezone'
import QRCode from 'qrcode.react'
import { MdCheck } from 'react-icons/lib/md'
import CurrencyIcon from '../../../../../../components/CurrencyIcon'
import { btc } from '../../../../../../utils'
@ -40,6 +36,9 @@ const Payment = ({ payment, ticker, currentTicker }) => (
)
Payment.propTypes = {
payment: PropTypes.object.isRequired,
ticker: PropTypes.object.isRequired,
currentTicker: PropTypes.object.isRequired
}
export default Payment

2
app/routes/activity/components/components/Modal/Payment/index.js

@ -1,3 +1,3 @@
import Payment from './Payment'
export default Payment
export default Payment

7
app/routes/activity/components/components/Modal/Transaction/Transaction.js

@ -4,10 +4,6 @@ import PropTypes from 'prop-types'
import Moment from 'react-moment'
import 'moment-timezone'
import QRCode from 'qrcode.react'
import { MdCheck } from 'react-icons/lib/md'
import CurrencyIcon from '../../../../../../components/CurrencyIcon'
import { btc } from '../../../../../../utils'
@ -50,6 +46,9 @@ const Transaction = ({ transaction, ticker, currentTicker }) => (
)
Transaction.propTypes = {
transaction: PropTypes.object.isRequired,
ticker: PropTypes.object.isRequired,
currentTicker: PropTypes.object.isRequired
}
export default Transaction

2
app/routes/activity/components/components/Modal/Transaction/index.js

@ -1,3 +1,3 @@
import Transaction from './Transaction'
export default Transaction
export default Transaction

2
app/routes/activity/components/components/Modal/index.js

@ -1,3 +1,3 @@
import Modal from './Modal'
export default Modal
export default Modal

8
app/routes/activity/components/components/Payment/Payment.js

@ -4,7 +4,6 @@ import Moment from 'react-moment'
import 'moment-timezone'
import { FaBolt } from 'react-icons/lib/fa'
import { btc } from '../../../../../utils'
import CurrencyIcon from '../../../../../components/CurrencyIcon'
import styles from '../Activity.scss'
const Payment = ({ payment, ticker, currentTicker, showActivityModal }) => (
@ -35,7 +34,7 @@ const Payment = ({ payment, ticker, currentTicker, showActivityModal }) => (
</div>
<div className={styles.amount}>
<span className='hint--top' data-hint='Payment amount'>
-
-
{
ticker.currency === 'usd' ?
btc.satoshisToUsd(payment.value, currentTicker.price_usd)
@ -56,7 +55,10 @@ const Payment = ({ payment, ticker, currentTicker, showActivityModal }) => (
)
Payment.propTypes = {
payment: PropTypes.object.isRequired,
ticker: PropTypes.object.isRequired,
currentTicker: PropTypes.object.isRequired,
showActivityModal: PropTypes.func.isRequired
}
export default Payment

6
app/routes/activity/components/components/Transaction/Transaction.js

@ -4,7 +4,6 @@ import Moment from 'react-moment'
import 'moment-timezone'
import { FaChain } from 'react-icons/lib/fa'
import { btc } from '../../../../../utils'
import CurrencyIcon from '../../../../../components/CurrencyIcon'
import styles from '../Activity.scss'
const Transaction = ({ transaction, ticker, currentTicker, showActivityModal }) => (
@ -56,7 +55,10 @@ const Transaction = ({ transaction, ticker, currentTicker, showActivityModal })
)
Transaction.propTypes = {
transaction: PropTypes.object.isRequired,
ticker: PropTypes.object.isRequired,
currentTicker: PropTypes.object.isRequired,
showActivityModal: PropTypes.func.isRequired
}
export default Transaction

3
app/routes/app/components/App.js

@ -27,7 +27,6 @@ class App extends Component {
setMessage,
setPubkey,
setPaymentRequest,
payment,
transaction: { sendingTransaction },
peers,
setCurrency,
@ -61,7 +60,6 @@ class App extends Component {
setMessage={setMessage}
setPubkey={setPubkey}
setPaymentRequest={setPaymentRequest}
payment={payment}
peers={peers}
ticker={ticker}
form={form}
@ -104,7 +102,6 @@ App.propTypes = {
setMessage: PropTypes.func.isRequired,
setPubkey: PropTypes.func.isRequired,
setPaymentRequest: PropTypes.func.isRequired,
payment: PropTypes.object.isRequired,
transaction: PropTypes.object.isRequired,
peers: PropTypes.array,
setCurrency: PropTypes.func.isRequired,

2
app/routes/app/components/components/Form/Form.js

@ -7,7 +7,6 @@ import styles from './Form.scss'
const Form = ({
form: { formType, amount, onchainAmount, message, payment_request },
payment: { sendingPayment },
setAmount,
setOnchainAmount,
setMessage,
@ -72,7 +71,6 @@ const Form = ({
)
Form.propTypes = {
payment: PropTypes.object.isRequired,
form: PropTypes.object.isRequired,
ticker: PropTypes.object.isRequired,
setAmount: PropTypes.func.isRequired,

Loading…
Cancel
Save