Browse Source

refactor: move helper code to lib directory

renovate/lint-staged-8.x
Tom Kirkpatrick 7 years ago
parent
commit
5681b82a3c
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 4
      .eslintignore
  2. 1
      .flowconfig
  3. 2
      app/components/Activity/InvoiceModal.js
  4. 2
      app/components/Activity/TransactionModal.js
  5. 2
      app/components/Contacts/ContactModal.js
  6. 2
      app/components/Contacts/Network.js
  7. 2
      app/components/Form/Pay.js
  8. 2
      app/components/Form/Request.js
  9. 2
      app/components/Onboarding/Syncing.js
  10. 2
      app/components/Value/Value.js
  11. 2
      app/components/Wallet/ReceiveModal.js
  12. 2
      app/components/Wallet/Wallet.js
  13. 12
      app/containers/Root.js
  14. 0
      app/lib/lnd/config.js
  15. 2
      app/lib/lnd/index.js
  16. 12
      app/lib/lnd/lightning.js
  17. 0
      app/lib/lnd/methods/channelController.js
  18. 0
      app/lib/lnd/methods/index.js
  19. 0
      app/lib/lnd/methods/invoicesController.js
  20. 0
      app/lib/lnd/methods/networkController.js
  21. 0
      app/lib/lnd/methods/paymentsController.js
  22. 0
      app/lib/lnd/methods/peersController.js
  23. 0
      app/lib/lnd/methods/walletController.js
  24. 4
      app/lib/lnd/neutrino.js
  25. 0
      app/lib/lnd/push/closechannel.js
  26. 0
      app/lib/lnd/push/openchannel.js
  27. 0
      app/lib/lnd/push/subscribeinvoice.js
  28. 0
      app/lib/lnd/subscribe/channelgraph.js
  29. 0
      app/lib/lnd/subscribe/invoices.js
  30. 0
      app/lib/lnd/subscribe/transactions.js
  31. 2
      app/lib/lnd/util.js
  32. 2
      app/lib/lnd/walletUnlocker.js
  33. 0
      app/lib/lnd/walletUnlockerMethods/index.js
  34. 0
      app/lib/utils/api.js
  35. 0
      app/lib/utils/bech32.js
  36. 0
      app/lib/utils/blockExplorer.js
  37. 0
      app/lib/utils/btc.js
  38. 0
      app/lib/utils/index.js
  39. 0
      app/lib/utils/log.js
  40. 0
      app/lib/utils/notifications.js
  41. 0
      app/lib/utils/usd.js
  42. 10
      app/lib/zap/controller.js
  43. 2
      app/lib/zap/menuBuilder.js
  44. 2
      app/lib/zap/updater.js
  45. 10
      app/main.dev.js
  46. 7
      app/reducers/channels.js
  47. 3
      app/reducers/contactsform.js
  48. 5
      app/reducers/invoice.js
  49. 2
      app/reducers/lnd.js
  50. 2
      app/reducers/network.js
  51. 3
      app/reducers/payform.js
  52. 2
      app/reducers/requestform.js
  53. 2
      app/reducers/ticker.js
  54. 4
      app/reducers/transaction.js
  55. 2
      app/routes/activity/components/components/Invoice/Invoice.js
  56. 2
      app/routes/activity/components/components/Payment/Payment.js
  57. 2
      app/routes/activity/components/components/Transaction/Transaction.js
  58. 2
      app/routes/app/containers/AppContainer.js
  59. 0
      app/utils/.gitkeep
  60. 2
      test/utils/usd.spec.js
  61. 2
      webpack.config.renderer.dev.js

4
.eslintignore

@ -41,9 +41,7 @@ app/main.prod.js
app/main.prod.js.map
app/renderer.prod.js
app/renderer.prod.js.map
app/style.css
app/style.css.map
app/utils/bech32.js
app/lib/utils/bech32.js
dist
dll
main.js

1
.flowconfig

@ -24,5 +24,6 @@ module.name_mapper.extension='styl' -> '<PROJECT_ROOT>/internals/flow/CSSModule.
module.name_mapper.extension='scss' -> '<PROJECT_ROOT>/internals/flow/CSSModule.js.flow'
module.name_mapper.extension='png' -> '<PROJECT_ROOT>/internals/flow/WebpackAsset.js.flow'
module.name_mapper.extension='jpg' -> '<PROJECT_ROOT>/internals/flow/WebpackAsset.js.flow'
module.system.node.resolve_dirname=app
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue

2
app/components/Activity/InvoiceModal.js

@ -5,7 +5,7 @@ import Moment from 'react-moment'
import QRCode from 'qrcode.react'
import copy from 'copy-to-clipboard'
import { showNotification } from 'notifications'
import { showNotification } from 'lib/utils/notifications'
import FaAngleDown from 'react-icons/lib/fa/angle-down'

2
app/components/Activity/TransactionModal.js

@ -9,7 +9,7 @@ import Isvg from 'react-inlinesvg'
import paperPlane from 'icons/paper_plane.svg'
import hand from 'icons/hand.svg'
import link from 'icons/link.svg'
import { blockExplorer } from 'utils'
import { blockExplorer } from 'lib/utils'
import Value from 'components/Value'

2
app/components/Contacts/ContactModal.js

@ -4,7 +4,7 @@ import ReactModal from 'react-modal'
import FaCircle from 'react-icons/lib/fa/circle'
import MdClose from 'react-icons/lib/md/close'
import { btc } from 'utils'
import { btc } from 'lib/utils'
import styles from './ContactModal.scss'

2
app/components/Contacts/Network.js

@ -5,7 +5,7 @@ import FaExternalLink from 'react-icons/lib/fa/external-link'
import FaCircle from 'react-icons/lib/fa/circle'
import FaRepeat from 'react-icons/lib/fa/repeat'
import FaAngleDown from 'react-icons/lib/fa/angle-down'
import { btc, blockExplorer } from 'utils'
import { btc, blockExplorer } from 'lib/utils'
import plus from 'icons/plus.svg'
import search from 'icons/search.svg'

2
app/components/Form/Pay.js

@ -6,7 +6,7 @@ import paperPlane from 'icons/paper_plane.svg'
import link from 'icons/link.svg'
import FaAngleDown from 'react-icons/lib/fa/angle-down'
import { btc } from 'utils'
import { btc } from 'lib/utils'
import styles from './Pay.scss'

2
app/components/Form/Request.js

@ -5,7 +5,7 @@ import Isvg from 'react-inlinesvg'
import hand from 'icons/hand.svg'
import FaAngleDown from 'react-icons/lib/fa/angle-down'
import { btc } from 'utils'
import { btc } from 'lib/utils'
import styles from './Request.scss'
const Request = ({

2
app/components/Onboarding/Syncing.js

@ -5,7 +5,7 @@ import copy from 'copy-to-clipboard'
import Isvg from 'react-inlinesvg'
import zapLogo from 'icons/zap_logo.svg'
import copyIcon from 'icons/copy.svg'
import { showNotification } from 'notifications'
import { showNotification } from 'lib/utils/notifications'
import styles from './Syncing.scss'
class Syncing extends Component {

2
app/components/Value/Value.js

@ -1,6 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
import { btc } from 'utils'
import { btc } from 'lib/utils'
const Value = ({ value, currency, currentTicker }) => {
if (currency === 'sats') {

2
app/components/Wallet/ReceiveModal.js

@ -6,7 +6,7 @@ import copyIcon from 'icons/copy.svg'
import Isvg from 'react-inlinesvg'
import x from 'icons/x.svg'
import { showNotification } from 'notifications'
import { showNotification } from 'lib/utils/notifications'
import styles from './ReceiveModal.scss'

2
app/components/Wallet/Wallet.js

@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
import FaAngleDown from 'react-icons/lib/fa/angle-down'
import Isvg from 'react-inlinesvg'
import { btc, blockExplorer } from 'utils'
import { btc, blockExplorer } from 'lib/utils'
import Value from 'components/Value'
import AnimatedCheckmark from 'components/AnimatedCheckmark'

12
app/containers/Root.js

@ -4,9 +4,6 @@ import { Provider, connect } from 'react-redux'
import { ConnectedRouter } from 'react-router-redux'
import PropTypes from 'prop-types'
import LoadingBolt from '../components/LoadingBolt'
import Onboarding from '../components/Onboarding'
import Syncing from '../components/Onboarding/Syncing'
import {
setConnectionType,
setConnectionString,
@ -29,9 +26,12 @@ import {
updateReEnterSeedInput,
updateRecoverSeedInput,
setReEnterSeedIndexes
} from '../reducers/onboarding'
import { lndSelectors } from '../reducers/lnd'
import { walletAddress } from '../reducers/address'
} from 'reducers/onboarding'
import { lndSelectors } from 'reducers/lnd'
import { walletAddress } from 'reducers/address'
import LoadingBolt from 'components/LoadingBolt'
import Onboarding from 'components/Onboarding'
import Syncing from 'components/Onboarding/Syncing'
import Routes from '../routes'
const mapDispatchToProps = {

0
app/lnd/config/index.js → app/lib/lnd/config.js

2
app/lnd/index.js → app/lib/lnd/index.js

@ -1,5 +1,5 @@
import config from './config'
import walletUnlocker from './lib/walletUnlocker'
import walletUnlocker from './walletUnlocker'
import walletUnlockerMethods from './walletUnlockerMethods'
// use mainLog because lndLog is reserved for the lnd binary itself
import { mainLog } from '../utils/log'

12
app/lnd/lib/lightning.js → app/lib/lnd/lightning.js

@ -1,12 +1,12 @@
import grpc from 'grpc'
import { loadSync } from '@grpc/proto-loader'
import config from '../config'
import config from './config'
import { getDeadline, validateHost, createSslCreds, createMacaroonCreds } from './util'
import methods from '../methods'
import { mainLog } from '../../utils/log'
import subscribeToTransactions from '../subscribe/transactions'
import subscribeToInvoices from '../subscribe/invoices'
import subscribeToChannelGraph from '../subscribe/channelgraph'
import methods from './methods'
import { mainLog } from '../utils/log'
import subscribeToTransactions from './subscribe/transactions'
import subscribeToInvoices from './subscribe/invoices'
import subscribeToChannelGraph from './subscribe/channelgraph'
/**
* Creates an LND grpc client lightning service.

0
app/lnd/methods/channelController.js → app/lib/lnd/methods/channelController.js

0
app/lnd/methods/index.js → app/lib/lnd/methods/index.js

0
app/lnd/methods/invoicesController.js → app/lib/lnd/methods/invoicesController.js

0
app/lnd/methods/networkController.js → app/lib/lnd/methods/networkController.js

0
app/lnd/methods/paymentsController.js → app/lib/lnd/methods/paymentsController.js

0
app/lnd/methods/peersController.js → app/lib/lnd/methods/peersController.js

0
app/lnd/methods/walletController.js → app/lib/lnd/methods/walletController.js

4
app/lnd/lib/neutrino.js → app/lib/lnd/neutrino.js

@ -1,8 +1,8 @@
import split2 from 'split2'
import { spawn } from 'child_process'
import EventEmitter from 'events'
import config from '../config'
import { mainLog, lndLog, lndLogGetLevel } from '../../utils/log'
import config from './config'
import { mainLog, lndLog, lndLogGetLevel } from '../utils/log'
import { fetchBlockHeight } from './util'
// Sync statuses

0
app/lnd/push/closechannel.js → app/lib/lnd/push/closechannel.js

0
app/lnd/push/openchannel.js → app/lib/lnd/push/openchannel.js

0
app/lnd/push/subscribeinvoice.js → app/lib/lnd/push/subscribeinvoice.js

0
app/lnd/subscribe/channelgraph.js → app/lib/lnd/subscribe/channelgraph.js

0
app/lnd/subscribe/invoices.js → app/lib/lnd/subscribe/invoices.js

0
app/lnd/subscribe/transactions.js → app/lib/lnd/subscribe/transactions.js

2
app/lnd/lib/util.js → app/lib/lnd/util.js

@ -8,7 +8,7 @@ import grpc from 'grpc'
import isIP from 'validator/lib/isIP'
import isPort from 'validator/lib/isPort'
import get from 'lodash.get'
import { mainLog } from '../../utils/log'
import { mainLog } from '../utils/log'
const fsReadFile = promisify(fs.readFile)
const dnsLookup = promisify(dns.lookup)

2
app/lnd/lib/walletUnlocker.js → app/lib/lnd/walletUnlocker.js

@ -1,7 +1,7 @@
import fs from 'fs'
import grpc from 'grpc'
import { loadSync } from '@grpc/proto-loader'
import config from '../config'
import config from './config'
const walletUnlocker = (rpcpath, host) => {
const lndConfig = config.lnd()

0
app/lnd/walletUnlockerMethods/index.js → app/lib/lnd/walletUnlockerMethods/index.js

0
app/api/index.js → app/lib/utils/api.js

0
app/utils/bech32.js → app/lib/utils/bech32.js

0
app/utils/blockExplorer.js → app/lib/utils/blockExplorer.js

0
app/utils/btc.js → app/lib/utils/btc.js

0
app/utils/index.js → app/lib/utils/index.js

0
app/utils/log.js → app/lib/utils/log.js

0
app/notifications/index.js → app/lib/utils/notifications.js

0
app/utils/usd.js → app/lib/utils/usd.js

10
app/zap.js → app/lib/zap/controller.js

@ -1,11 +1,11 @@
import { app, ipcMain, dialog } from 'electron'
import Store from 'electron-store'
import StateMachine from 'javascript-state-machine'
import lnd from './lnd'
import Neutrino from './lnd/lib/neutrino'
import Lightning from './lnd/lib/lightning'
import { mainLog } from './utils/log'
import { isLndRunning } from './lnd/lib/util'
import lnd from '../lnd'
import Neutrino from '../lnd/neutrino'
import Lightning from '../lnd/lightning'
import { mainLog } from '../utils/log'
import { isLndRunning } from '../lnd/util'
const grpcSslCipherSuites = connectionType =>
(connectionType === 'btcpayserver'

2
app/menu.js → app/lib/zap/menuBuilder.js

@ -1,7 +1,7 @@
// @flow
import { app, Menu, shell, BrowserWindow } from 'electron'
export default class MenuBuilder {
export default class ZapMenuBuilder {
mainWindow: BrowserWindow
constructor(mainWindow: BrowserWindow) {

2
app/updater.js → app/lib/zap/updater.js

@ -1,6 +1,6 @@
import { dialog } from 'electron'
import { autoUpdater } from 'electron-updater'
import { updaterLog } from './utils/log'
import { updaterLog } from '../utils/log'
autoUpdater.logger = updaterLog

10
app/main.dev.js

@ -7,10 +7,10 @@
* `./app/main.prod.js` using webpack. This gives us some performance wins.
*/
import { app, BrowserWindow, session } from 'electron'
import { mainLog } from './utils/log'
import MenuBuilder from './menu'
import ZapController from './zap'
import ZapUpdater from './updater'
import { mainLog } from './lib/utils/log'
import ZapMenuBuilder from './lib/zap/menuBuilder'
import ZapController from './lib/zap/controller'
import ZapUpdater from './lib/zap/updater'
// Set up a couple of timers to track the app startup progress.
mainLog.time('Time until app is ready')
@ -41,7 +41,7 @@ app.on('ready', () => {
zap.init()
// Initialise the application menus.
const menuBuilder = new MenuBuilder(mainWindow)
const menuBuilder = new ZapMenuBuilder(mainWindow)
menuBuilder.buildMenu()
/**

7
app/reducers/channels.js

@ -1,9 +1,10 @@
import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron'
import { showNotification } from '../notifications'
import { btc } from '../utils'
import { requestSuggestedNodes } from '../api'
import { btc } from 'lib/utils'
import { showNotification } from 'lib/utils/notifications'
import { requestSuggestedNodes } from 'lib/utils/api'
import { setError } from './error'
// ------------------------------------
// Constants
// ------------------------------------

3
app/reducers/contactsform.js

@ -1,7 +1,6 @@
import { createSelector } from 'reselect'
import { btc } from 'lib/utils'
import { tickerSelectors } from './ticker'
import { btc } from '../utils'
// Initial State
const initialState = {

5
app/reducers/invoice.js

@ -2,6 +2,9 @@ import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron'
import { push } from 'react-router-redux'
import { showNotification } from 'lib/utils/notifications'
import { btc } from 'lib/utils'
import { showActivityModal } from './activity'
import { fetchBalance } from './balance'
import { setFormType } from './form'
@ -9,8 +12,6 @@ import { setPayInvoice } from './payform'
import { resetRequestForm } from './requestform'
import { setError } from './error'
import { showNotification } from '../notifications'
import { btc } from '../utils'
// ------------------------------------
// Constants
// ------------------------------------

2
app/reducers/lnd.js

@ -1,9 +1,9 @@
import Store from 'electron-store'
import { createSelector } from 'reselect'
import { showNotification } from 'lib/utils/notifications'
import { fetchTicker } from './ticker'
import { fetchBalance } from './balance'
import { fetchInfo, setHasSynced } from './info'
import { showNotification } from '../notifications'
// ------------------------------------
// Constants
// ------------------------------------

2
app/reducers/network.js

@ -1,6 +1,6 @@
import { createSelector } from 'reselect'
import { ipcRenderer } from 'electron'
import { bech32 } from '../utils'
import { bech32 } from 'lib/utils'
// ------------------------------------
// Constants

3
app/reducers/payform.js

@ -1,10 +1,9 @@
import { createSelector } from 'reselect'
import bitcoin from 'bitcoinjs-lib'
import { btc, bech32 } from 'lib/utils'
import { setFormType } from './form'
import { tickerSelectors } from './ticker'
import { infoSelectors } from './info'
import { btc, bech32 } from '../utils'
// Initial State
const initialState = {

2
app/reducers/requestform.js

@ -1,5 +1,5 @@
import { createSelector } from 'reselect'
import { btc } from '../utils'
import { btc } from 'lib/utils'
import { tickerSelectors } from './ticker'
// Initial State

2
app/reducers/ticker.js

@ -1,5 +1,5 @@
import { createSelector } from 'reselect'
import { requestTickers } from '../api'
import { requestTickers } from 'lib/utils/api'
import { infoSelectors } from './info'
// ------------------------------------

4
app/reducers/transaction.js

@ -1,6 +1,6 @@
import { ipcRenderer } from 'electron'
import { showNotification } from '../notifications'
import { btc } from '../utils'
import { showNotification } from 'lib/utils/notifications'
import { btc } from 'lib/utils'
import { newAddress } from './address'
import { fetchBalance } from './balance'
import { setFormType } from './form'

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

@ -1,7 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import Moment from 'react-moment'
import { btc } from 'utils'
import { btc } from 'lib/utils'
import Isvg from 'react-inlinesvg'
import Value from 'components/Value'

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

@ -3,8 +3,8 @@ import PropTypes from 'prop-types'
import Moment from 'react-moment'
import Isvg from 'react-inlinesvg'
import zap from 'icons/zap.svg'
import { btc } from 'utils'
import { btc } from 'lib/utils'
import Value from 'components/Value'
import styles from '../Activity.scss'

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

@ -3,8 +3,8 @@ import PropTypes from 'prop-types'
import Moment from 'react-moment'
import Isvg from 'react-inlinesvg'
import link from 'icons/link.svg'
import { btc } from 'utils'
import { btc } from 'lib/utils'
import Value from 'components/Value'
import styles from '../Activity.scss'

2
app/routes/app/containers/AppContainer.js

@ -1,7 +1,7 @@
import { withRouter } from 'react-router'
import { connect } from 'react-redux'
import { btc } from 'utils'
import { btc } from 'lib/utils'
import { fetchTicker, setCurrency, tickerSelectors } from 'reducers/ticker'

0
app/utils/.gitkeep

2
test/utils/usd.spec.js

@ -1,4 +1,4 @@
import { formatUsd, usdToBtc } from '../../app/utils/usd'
import { formatUsd, usdToBtc } from 'lib/utils/usd'
describe('usd', () => {
describe('formatUsd', () => {

2
webpack.config.renderer.dev.js

@ -20,7 +20,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin'
import AddAssetHtmlPlugin from 'add-asset-html-webpack-plugin'
import CspHtmlWebpackPlugin from 'csp-html-webpack-plugin'
import baseConfig from './webpack.config.base'
import { mainLog } from './app/utils/log'
import { mainLog } from './app/lib/utils/log'
const port = process.env.PORT || 1212
const publicPath = `http://localhost:${port}/dist`

Loading…
Cancel
Save