Browse Source

Merge pull request #160 from Empact/enhance/lints

Minimize disabling of lints
renovate/lint-staged-8.x
JimmyMow 7 years ago
committed by GitHub
parent
commit
6d0585298d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .eslintignore
  2. 2
      app/components/Form/PayForm.js
  3. 8
      app/components/LndSyncing/LndSyncing.js
  4. 4
      app/lnd/methods/paymentsController.js
  5. 2
      app/lnd/subscribe/invoices.js
  6. 4
      app/lnd/subscribe/transactions.js
  7. 292
      app/main.dev.js
  8. 94
      app/menu.js
  9. 29
      app/reducers/channels.js
  10. 4
      app/reducers/lnd.js
  11. 2
      app/reducers/transaction.js
  12. 3
      app/utils/bech32.js
  13. 6
      internals/scripts/CheckNodeEnv.js
  14. 61
      test/e2e/e2e.spec.js
  15. 23
      webpack.config.renderer.dev.js

1
.eslintignore

@ -43,6 +43,7 @@ app/renderer.prod.js
app/renderer.prod.js.map
app/style.css
app/style.css.map
app/utils/bech32.js
dist
dll
main.js

2
app/components/Form/PayForm.js

@ -55,7 +55,7 @@ class PayForm extends Component {
<input
type='number'
min='0'
ref={input => this.amountInput = input} // eslint-disable-line
ref={(input) => { this.amountInput = input }}
size=''
style={
isLn ?

8
app/components/LndSyncing/LndSyncing.js

@ -9,19 +9,19 @@ class LndSyncing extends Component {
facts: [
{
title: 'The Lightning Network',
description: 'The Lightning Network is a second layer solution built on top of the Bitcoin block chain that attempts to increase Bitcoin\'s scalability and privacy' // eslint-disable-line
description: 'The Lightning Network is a second layer solution built on top of the Bitcoin block chain that attempts to increase Bitcoin\'s scalability and privacy' // eslint-disable-line max-len
},
{
title: 'Payment Channel',
description: 'A payment channel is a class of techniques designed to allow users to make multiple Bitcoin transactions without commiting all of the transactions to the Bitcoin block chain. You can think of payment channels like tubes of money' // eslint-disable-line
description: 'A payment channel is a class of techniques designed to allow users to make multiple Bitcoin transactions without commiting all of the transactions to the Bitcoin block chain. You can think of payment channels like tubes of money' // eslint-disable-line max-len
},
{
title: 'HTLC',
description: 'Hashed TimeLock Contracts is a class of payments that use hashlocks and timelocks to require the receiver of a payment either acknowledge receiving the payment before a deadline or forfeit the ability to claim the payment. HTLCs are useful within the Lightning Network for routing payments across two or more payment channels' // eslint-disable-line
description: 'Hashed TimeLock Contracts is a class of payments that use hashlocks and timelocks to require the receiver of a payment either acknowledge receiving the payment before a deadline or forfeit the ability to claim the payment. HTLCs are useful within the Lightning Network for routing payments across two or more payment channels' // eslint-disable-line max-len
},
{
title: 'Onion Routing',
description: 'Onion routing is a technique for anonymous communication over a computer network. In an onion network, messages are encapsulated in layers of encryption, analogous to layers of an onion.' // eslint-disable-line
description: 'Onion routing is a technique for anonymous communication over a computer network. In an onion network, messages are encapsulated in layers of encryption, analogous to layers of an onion.' // eslint-disable-line max-len
}
],
currentFact: 0

4
app/lnd/methods/paymentsController.js

@ -8,11 +8,11 @@ export function sendPaymentSync(lnd, meta, { paymentRequest }) {
return new Promise((resolve, reject) => {
lnd.sendPaymentSync({ payment_request: paymentRequest }, meta, (error, data) => {
if (error) {
reject({ error }) // eslint-disable-line
reject({ error })
return
}
if (!data || !data.payment_route) { reject({ error: data.payment_error }) } // eslint-disable-line
if (!data || !data.payment_route) { reject({ error: data.payment_error }) }
resolve(data)
})

2
app/lnd/subscribe/invoices.js

@ -1,5 +1,3 @@
/* eslint-disable */
export default function subscribeToInvoices(mainWindow, lnd, meta) {
const call = lnd.subscribeInvoices({}, meta)

4
app/lnd/subscribe/transactions.js

@ -1,8 +1,6 @@
/* eslint-disable */
export default function subscribeToTransactions(mainWindow, lnd, meta) {
const call = lnd.subscribeTransactions({}, meta)
call.on('data', transaction => {
call.on('data', (transaction) => {
console.log('TRANSACTION: ', transaction)
mainWindow.send('newTransaction', { transaction })
})

292
app/main.dev.js

@ -1,4 +1,3 @@
/* eslint-disable */
/* eslint global-require: 1, flowtype-errors/show-errors: 0 */
/**
@ -30,34 +29,155 @@ let startedSync = false
let sentGrpcDisconnect = false
let certPath
let certInterval
if (process.env.NODE_ENV === 'production') {
const sourceMapSupport = require('source-map-support');
sourceMapSupport.install();
const sourceMapSupport = require('source-map-support')
sourceMapSupport.install()
}
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') {
require('electron-debug')();
const path = require('path');
const p = path.join(__dirname, '..', 'app', 'node_modules');
require('module').globalPaths.push(p);
require('electron-debug')()
const p = path.join(__dirname, '..', 'app', 'node_modules')
require('module').globalPaths.push(p)
}
const installExtensions = async () => {
const installer = require('electron-devtools-installer');
const forceDownload = !!process.env.UPGRADE_EXTENSIONS;
const installer = require('electron-devtools-installer')
const forceDownload = !!process.env.UPGRADE_EXTENSIONS
const extensions = [
'REACT_DEVELOPER_TOOLS',
'REDUX_DEVTOOLS'
];
]
return Promise
.all(extensions.map(name => installer.default(installer[name], forceDownload)))
.catch(console.log);
};
.catch(console.log)
}
// Send the front end event letting them know the gRPC connection has started
const sendGrpcDisconnected = () => {
const sendGrpcDisonnectedInterval = setInterval(() => {
if (didFinishLoad) {
clearInterval(sendGrpcDisonnectedInterval)
if (mainWindow) {
sentGrpcDisconnect = true
mainWindow.webContents.send('grpcDisconnected')
}
}
}, 1000)
}
// Send the front end event letting them know LND is synced to the blockchain
const sendLndSyncing = () => {
const sendLndSyncingInterval = setInterval(() => {
if (didFinishLoad) {
clearInterval(sendLndSyncingInterval)
if (mainWindow) {
console.log('SENDING SYNCING')
startedSync = true
mainWindow.webContents.send('lndSyncing')
}
}
}, 1000)
}
// Send the front end event letting them know the gRPC connection has started
const sendGrpcConnected = () => {
const sendGrpcConnectedInterval = setInterval(() => {
if (didFinishLoad && sentGrpcDisconnect) {
clearInterval(sendGrpcConnectedInterval)
if (mainWindow) {
mainWindow.webContents.send('grpcConnected')
}
}
}, 1000)
}
// Create and subscribe the grpc object
const startGrpc = () => {
lnd((lndSubscribe, lndMethods) => {
// Subscribe to bi-directional streams
lndSubscribe(mainWindow)
// Listen for all gRPC restful methods
ipcMain.on('lnd', (event, { msg, data }) => {
lndMethods(event, msg, data)
})
sendGrpcConnected()
})
}
// Send the front end event letting them know LND is synced to the blockchain
const sendLndSynced = () => {
const sendLndSyncedInterval = setInterval(() => {
if (didFinishLoad && startedSync) {
clearInterval(sendLndSyncedInterval)
if (mainWindow) {
console.log('SENDING SYNCED')
mainWindow.webContents.send('lndSynced')
}
}
}, 1000)
}
// Starts the LND node
const startLnd = () => {
const lndPath = path.join(__dirname, '..', 'resources', 'bin', plat, plat === 'win32' ? 'lnd.exe' : 'lnd')
const neutrino = spawn(lndPath,
[
'--bitcoin.active',
'--bitcoin.testnet',
'--neutrino.active',
'--neutrino.connect=btcd0.lightning.computer:18333',
'--autopilot.active',
'--debuglevel=debug',
'--noencryptwallet'
]
)
.on('error', error => console.log(`lnd error: ${error}`))
.on('close', code => console.log(`lnd shutting down ${code}`))
// Listen for when neutrino prints out data
neutrino.stdout.on('data', (data) => {
// Data stored in variable line, log line to the console
const line = data.toString('utf8')
if (process.env.NODE_ENV === 'development') { console.log(line) }
// If the gRPC proxy has started we can start ours
if (line.includes('gRPC proxy started')) {
const certInterval = setInterval(() => {
if (fs.existsSync(certPath)) {
clearInterval(certInterval)
console.log('CERT EXISTS, STARTING GRPC')
startGrpc()
}
}, 1000)
}
// Pass current clock height progress to front end for loading state UX
if (mainWindow && (line.includes('Caught up to height') || line.includes('Catching up block hashes to height'))) {
// const blockHeight = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim()
mainWindow.webContents.send('lndStdout', line)
}
// When LND is all caught up to the blockchain
if (line.includes('Chain backend is fully synced')) {
// Log that LND is caught up to the current block height
console.log('NEUTRINO IS SYNCED')
// Let the front end know we have stopped syncing LND
sendLndSynced()
}
})
}
/**
* Add event listeners...
@ -74,10 +194,10 @@ app.on('window-all-closed', () => {
app.on('ready', async () => {
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') {
await installExtensions();
await installExtensions()
}
let icon = path.join(__dirname, '..', 'resources', 'icon.icns')
const icon = path.join(__dirname, '..', 'resources', 'icon.icns')
console.log('icon: ', icon)
mainWindow = new BrowserWindow({
show: false,
@ -86,7 +206,7 @@ app.on('ready', async () => {
height: 1100,
minHeight: 700,
minWidth: 1100,
icon: icon
icon
})
mainWindow.loadURL(`file://${__dirname}/app.html`)
@ -106,17 +226,17 @@ app.on('ready', async () => {
})
mainWindow.on('closed', () => {
mainWindow = null;
mainWindow = null
})
const menuBuilder = new MenuBuilder(mainWindow);
const menuBuilder = new MenuBuilder(mainWindow)
menuBuilder.buildMenu()
sendGrpcDisconnected()
// Check to see if and LND process is running
lookup({ command: 'lnd' }, (err, results) => {
// There was an error checking for the LND process
if (err) { throw new Error( err ) }
if (err) { throw new Error(err) }
// No LND process was found
if (!results.length) {
@ -125,7 +245,7 @@ app.on('ready', async () => {
switch (os.platform()) {
case 'darwin':
certPath = path.join(homedir, 'Library/Application\ Support/Lnd/tls.cert')
certPath = path.join(homedir, 'Library/Application Support/Lnd/tls.cert')
break
case 'linux':
certPath = path.join(homedir, '.lnd/tls.cert')
@ -145,11 +265,11 @@ app.on('ready', async () => {
startGrpc()
}
})
});
})
app.setAsDefaultProtocolClient('lightning')
app.on('open-url', function (event, url) {
app.on('open-url', (event, url) => {
event.preventDefault()
if (!mainWindow) {
@ -161,128 +281,4 @@ app.on('open-url', function (event, url) {
mainWindow.show()
})
// Starts the LND node
export const startLnd = () => {
const lndPath = path.join(__dirname, '..', 'resources', 'bin', plat, plat === 'win32' ? 'lnd.exe' : 'lnd')
const neutrino = spawn(lndPath,
[
'--bitcoin.active',
'--bitcoin.testnet',
'--neutrino.active',
'--neutrino.connect=btcd0.lightning.computer:18333',
'--autopilot.active',
'--debuglevel=debug',
'--noencryptwallet'
]
)
.on('error', error => console.log(`lnd error: ${error}`))
.on('close', code => console.log(`lnd shutting down ${code}`))
// Listen for when neutrino prints out data
neutrino.stdout.on('data', data => {
// Data stored in variable line, log line to the console
let line = data.toString('utf8')
if (process.env.NODE_ENV === 'development') { console.log(line) }
// If the gRPC proxy has started we can start ours
if (line.includes('gRPC proxy started')) {
let certInterval = setInterval(() => {
if (fs.existsSync(certPath)) {
clearInterval(certInterval)
console.log('CERT EXISTS, STARTING GRPC')
startGrpc()
}
}, 1000)
}
// Pass current clock height progress to front end for loading state UX
if (mainWindow && (line.includes('Caught up to height') || line.includes('Catching up block hashes to height'))) {
// const blockHeight = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim()
const blockHeight = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim()
mainWindow.webContents.send('lndStdout', line)
}
// When LND is all caught up to the blockchain
if (line.includes('Chain backend is fully synced')) {
// Log that LND is caught up to the current block height
console.log('NEUTRINO IS SYNCED')
// Let the front end know we have stopped syncing LND
sendLndSynced()
}
})
}
// Create and subscribe the grpc object
const startGrpc = () => {
lnd((lndSubscribe, lndMethods) => {
// Subscribe to bi-directional streams
lndSubscribe(mainWindow)
// Listen for all gRPC restful methods
ipcMain.on('lnd', (event, { msg, data }) => {
lndMethods(event, msg, data)
})
sendGrpcConnected()
})
}
// Send the front end event letting them know LND is synced to the blockchain
const sendLndSyncing = () => {
let sendLndSyncingInterval = setInterval(() => {
if (didFinishLoad) {
clearInterval(sendLndSyncingInterval)
if (mainWindow) {
console.log('SENDING SYNCING')
startedSync = true
mainWindow.webContents.send('lndSyncing')
}
}
}, 1000)
}
// Send the front end event letting them know LND is synced to the blockchain
const sendLndSynced = () => {
let sendLndSyncedInterval = setInterval(() => {
if (didFinishLoad && startedSync) {
clearInterval(sendLndSyncedInterval)
if (mainWindow) {
console.log('SENDING SYNCED')
mainWindow.webContents.send('lndSynced')
}
}
}, 1000)
}
// Send the front end event letting them know the gRPC connection has started
const sendGrpcDisconnected = () => {
let sendGrpcDisonnectedInterval = setInterval(() => {
if (didFinishLoad) {
clearInterval(sendGrpcDisonnectedInterval)
if (mainWindow) {
sentGrpcDisconnect = true
mainWindow.webContents.send('grpcDisconnected')
}
}
}, 1000)
}
// Send the front end event letting them know the gRPC connection has started
const sendGrpcConnected = () => {
let sendGrpcConnectedInterval = setInterval(() => {
if (didFinishLoad && sentGrpcDisconnect) {
clearInterval(sendGrpcConnectedInterval)
if (mainWindow) {
mainWindow.webContents.send('grpcConnected')
}
}
}, 1000)
}
export default { startLnd }

94
app/menu.js

@ -1,48 +1,46 @@
/* eslint-disable */
// @flow
import { app, Menu, shell, BrowserWindow } from 'electron';
import { app, Menu, shell, BrowserWindow } from 'electron'
export default class MenuBuilder {
mainWindow: BrowserWindow;
constructor(mainWindow: BrowserWindow) {
this.mainWindow = mainWindow;
this.mainWindow = mainWindow
}
buildMenu() {
if (process.env.NODE_ENV === 'development' || process.env.DEBUG_PROD === 'true') {
this.setupDevelopmentEnvironment();
this.setupDevelopmentEnvironment()
}
let template;
let template
if (process.platform === 'darwin') {
template = this.buildDarwinTemplate();
template = this.buildDarwinTemplate()
} else {
template = this.buildDefaultTemplate();
template = this.buildDefaultTemplate()
}
const menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
return menu;
return menu
}
setupDevelopmentEnvironment() {
this.mainWindow.openDevTools();
this.mainWindow.openDevTools()
this.mainWindow.webContents.on('context-menu', (e, props) => {
const { x, y } = props;
const { x, y } = props
Menu
.buildFromTemplate([{
label: 'Inspect element',
click: () => {
this.mainWindow.inspectElement(x, y);
this.mainWindow.inspectElement(x, y)
}
}])
.popup(this.mainWindow);
});
.popup(this.mainWindow)
})
}
buildDarwinTemplate() {
@ -57,9 +55,9 @@ export default class MenuBuilder {
{ label: 'Hide Others', accelerator: 'Command+Shift+H', selector: 'hideOtherApplications:' },
{ label: 'Show All', selector: 'unhideAllApplications:' },
{ type: 'separator' },
{ label: 'Quit', accelerator: 'Command+Q', click: () => { app.quit(); } }
{ label: 'Quit', accelerator: 'Command+Q', click: () => { app.quit() } }
]
};
}
const subMenuEdit = {
label: 'Edit',
submenu: [
@ -71,21 +69,29 @@ export default class MenuBuilder {
{ label: 'Paste', accelerator: 'Command+V', selector: 'paste:' },
{ label: 'Select All', accelerator: 'Command+A', selector: 'selectAll:' }
]
};
}
const subMenuViewDev = {
label: 'View',
submenu: [
{ label: 'Reload', accelerator: 'Command+R', click: () => { this.mainWindow.webContents.reload(); } },
{ label: 'Toggle Full Screen', accelerator: 'Ctrl+Command+F', click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); } },
{ label: 'Toggle Developer Tools', accelerator: 'Alt+Command+I', click: () => { this.mainWindow.toggleDevTools(); } }
{ label: 'Reload', accelerator: 'Command+R', click: () => { this.mainWindow.webContents.reload() } },
{
label: 'Toggle Full Screen',
accelerator: 'Ctrl+Command+F',
click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()) }
},
{ label: 'Toggle Developer Tools', accelerator: 'Alt+Command+I', click: () => { this.mainWindow.toggleDevTools() } }
]
};
}
const subMenuViewProd = {
label: 'View',
submenu: [
{ label: 'Toggle Full Screen', accelerator: 'Ctrl+Command+F', click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()); } }
{
label: 'Toggle Full Screen',
accelerator: 'Ctrl+Command+F',
click: () => { this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen()) }
}
]
};
}
const subMenuWindow = {
label: 'Window',
submenu: [
@ -94,20 +100,20 @@ export default class MenuBuilder {
{ type: 'separator' },
{ label: 'Bring All to Front', selector: 'arrangeInFront:' }
]
};
}
const subMenuHelp = {
label: 'Help',
submenu: [
{ label: 'Learn More', click() { shell.openExternal('http://electron.atom.io'); } },
{ label: 'Documentation', click() { shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme'); } },
{ label: 'Community Discussions', click() { shell.openExternal('https://discuss.atom.io/c/electron'); } },
{ label: 'Search Issues', click() { shell.openExternal('https://github.com/atom/electron/issues'); } }
{ label: 'Learn More', click() { shell.openExternal('http://electron.atom.io') } },
{ label: 'Documentation', click() { shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme') } },
{ label: 'Community Discussions', click() { shell.openExternal('https://discuss.atom.io/c/electron') } },
{ label: 'Search Issues', click() { shell.openExternal('https://github.com/atom/electron/issues') } }
]
};
}
const subMenuView = process.env.NODE_ENV === 'development'
? subMenuViewDev
: subMenuViewProd;
: subMenuViewProd
return [
subMenuAbout,
@ -115,7 +121,7 @@ export default class MenuBuilder {
subMenuView,
subMenuWindow,
subMenuHelp
];
]
}
buildDefaultTemplate() {
@ -128,7 +134,7 @@ export default class MenuBuilder {
label: '&Close',
accelerator: 'Ctrl+W',
click: () => {
this.mainWindow.close();
this.mainWindow.close()
}
}]
}, {
@ -137,25 +143,25 @@ export default class MenuBuilder {
label: '&Reload',
accelerator: 'Ctrl+R',
click: () => {
this.mainWindow.webContents.reload();
this.mainWindow.webContents.reload()
}
}, {
label: 'Toggle &Full Screen',
accelerator: 'F11',
click: () => {
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen());
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen())
}
}, {
label: 'Toggle &Developer Tools',
accelerator: 'Alt+Ctrl+I',
click: () => {
this.mainWindow.toggleDevTools();
this.mainWindow.toggleDevTools()
}
}] : [{
label: 'Toggle &Full Screen',
accelerator: 'F11',
click: () => {
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen());
this.mainWindow.setFullScreen(!this.mainWindow.isFullScreen())
}
}]
}, {
@ -163,26 +169,26 @@ export default class MenuBuilder {
submenu: [{
label: 'Learn More',
click() {
shell.openExternal('http://electron.atom.io');
shell.openExternal('http://electron.atom.io')
}
}, {
label: 'Documentation',
click() {
shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme');
shell.openExternal('https://github.com/atom/electron/tree/master/docs#readme')
}
}, {
label: 'Community Discussions',
click() {
shell.openExternal('https://discuss.atom.io/c/electron');
shell.openExternal('https://discuss.atom.io/c/electron')
}
}, {
label: 'Search Issues',
click() {
shell.openExternal('https://github.com/atom/electron/issues');
shell.openExternal('https://github.com/atom/electron/issues')
}
}]
}];
}]
return templateDefault;
return templateDefault
}
}

29
app/reducers/channels.js

@ -178,7 +178,7 @@ export const pushchannelupdated = (event, { pubkey }) => (dispatch) => {
}
// Receive IPC event for channel end
export const pushchannelend = event => (dispatch) => { // eslint-disable-line
export const pushchannelend = event => (dispatch) => { // eslint-disable-line no-unused-vars
dispatch(fetchChannels())
}
@ -190,7 +190,7 @@ export const pushchannelerror = (event, { pubkey, error }) => (dispatch) => {
}
// Receive IPC event for channel status
export const pushchannelstatus = (event, data) => (dispatch) => { // eslint-disable-line
export const pushchannelstatus = (event, data) => (dispatch) => { // eslint-disable-line no-unused-vars
dispatch(fetchChannels())
}
@ -271,7 +271,7 @@ export const channelGraphData = (event, data) => (dispatch, getState) => {
// Construct the notification
const otherParty = info.data.identity_pubkey === advertising_node ? connecting_node : advertising_node
let notifBody = `No new friends, just new channels. Your channel with ${otherParty}` // eslint-disable-line
const notifBody = `No new friends, just new channels. Your channel with ${otherParty}`
const notifTitle = 'New channel detected'
// HTML 5 notification for channel updates involving our node
@ -423,15 +423,26 @@ const allChannels = createSelector(
pendingForceClosedChannelsSelector,
channelSearchQuerySelector,
(activeChannels, nonActiveChannels, pendingOpenChannels, pendingClosedChannels, pendingForcedClosedChannels, searchQuery) => {
const filteredActiveChannels = activeChannels.filter(channel => channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery)) // eslint-disable-line
const filteredNonActiveChannels = nonActiveChannels.filter(channel => channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery)) // eslint-disable-line
const filterChannel = channel =>
channel.remote_pubkey.includes(searchQuery) || channel.channel_point.includes(searchQuery)
const filteredPendingOpenChannels = pendingOpenChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) // eslint-disable-line
const filteredPendingClosedChannels = pendingClosedChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) // eslint-disable-line
const filteredPendingForcedClosedChannels = pendingForcedClosedChannels.filter(channel => channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)) // eslint-disable-line
const filteredActiveChannels = activeChannels.filter(filterChannel)
const filteredNonActiveChannels = nonActiveChannels.filter(filterChannel)
const filterPendingChannel = channel =>
channel.channel.remote_node_pub.includes(searchQuery) || channel.channel.channel_point.includes(searchQuery)
return [...filteredActiveChannels, ...filteredPendingOpenChannels, ...filteredPendingClosedChannels, ...filteredPendingForcedClosedChannels, ...filteredNonActiveChannels] // eslint-disable-line
const filteredPendingOpenChannels = pendingOpenChannels.filter(filterPendingChannel)
const filteredPendingClosedChannels = pendingClosedChannels.filter(filterPendingChannel)
const filteredPendingForcedClosedChannels = pendingForcedClosedChannels.filter(filterPendingChannel)
return [
...filteredActiveChannels,
...filteredPendingOpenChannels,
...filteredPendingClosedChannels,
...filteredPendingForcedClosedChannels,
...filteredNonActiveChannels
]
}
)

4
app/reducers/lnd.js

@ -52,12 +52,12 @@ export const lndStdout = (event, line) => (dispatch) => {
if (line.includes('Caught up to height')) {
trimmed = line.slice(line.indexOf('Caught up to height') + 'Caught up to height'.length).trim()
height = trimmed.split(' ')[0].split(/(\r\n|\n|\r)/gm)[0] // eslint-disable-line
height = trimmed.split(' ')[0].split(/(\r\n|\n|\r)/gm)[0]
}
if (line.includes('Catching up block hashes to height')) {
trimmed = line.slice(line.indexOf('Catching up block hashes to height') + 'Catching up block hashes to height'.length).trim()
height = trimmed.match(/[-]{0,1}[\d.]*[\d]+/g)[0] // eslint-disable-line
height = trimmed.match(/[-]{0,1}[\d.]*[\d]+/g)[0]
}
dispatch({ type: RECEIVE_LINE, lndBlockHeight: height })

2
app/reducers/transaction.js

@ -85,7 +85,7 @@ export const newTransaction = (event, { transaction }) => (dispatch) => {
// HTML 5 desktop notification for the new transaction
const notifTitle = transaction.amount > 0 ? 'On-chain Transaction Received!' : 'On-chain Transaction Sent!'
const notifBody = transaction.amount > 0 ? 'Lucky you, you just received a new on-chain transaction. I\'m jealous.' : 'Hate to see \'em go but love to watch \'em leave. Your on-chain transaction successfully sent.' // eslint-disable-line
const notifBody = transaction.amount > 0 ? 'Lucky you, you just received a new on-chain transaction. I\'m jealous.' : 'Hate to see \'em go but love to watch \'em leave. Your on-chain transaction successfully sent.' // eslint-disable-line max-len
showNotification(notifTitle, notifBody)

3
app/utils/bech32.js

@ -1,7 +1,5 @@
// Using bech32 here just without the 90 char length: https://github.com/bitcoinjs/bech32/blob/master/index.js
/* eslint-disable */
'use strict'
let ALPHABET = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
@ -147,4 +145,3 @@ export default {
toWords,
fromWords
}

6
internals/scripts/CheckNodeEnv.js

@ -7,11 +7,7 @@ export default function CheckNodeEnv(expectedEnv: string) {
}
if (process.env.NODE_ENV !== expectedEnv) {
/* eslint-disable */
console.log(chalk.whiteBright.bgRed.bold(
`"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config`
))
/* eslint-enable */
console.log(chalk.whiteBright.bgRed.bold(`"process.env.NODE_ENV" must be "${expectedEnv}" to use this webpack config`))
process.exit(2)
}
}

61
test/e2e/e2e.spec.js

@ -1,54 +1,41 @@
/* eslint-disable */
import { Application } from 'spectron'
import electronPath from 'electron'
import path from 'path'
import { Application } from 'spectron';
import electronPath from 'electron';
import path from 'path';
jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000
jasmine.DEFAULT_TIMEOUT_INTERVAL = 15000;
const delay = time => new Promise(resolve => setTimeout(resolve, time));
const delay = time => new Promise(resolve => setTimeout(resolve, time))
describe('main window', function spec() {
beforeAll(async () => {
this.app = new Application({
path: electronPath,
args: [path.join(__dirname, '..', '..', 'app')]
});
return this.app.start();
});
afterAll(() => {
if (this.app && this.app.isRunning()) {
return this.app.stop();
}
});
})
const findCounter = () => this.app.client.element('[data-tid="counter"]');
return this.app.start()
})
const findButtons = async () => {
const { value } = await this.app.client.elements('[data-tclass="btn"]');
return value.map(btn => btn.ELEMENT);
};
afterAll(() => this.app && this.app.isRunning() && this.app.stop())
it('should open window', async () => {
const { client, browserWindow } = this.app;
const { client, browserWindow } = this.app
await client.waitUntilWindowLoaded();
await delay(500);
const title = await browserWindow.getTitle();
expect(title).toBe('Zap');
});
await client.waitUntilWindowLoaded()
await delay(500)
const title = await browserWindow.getTitle()
expect(title).toBe('Zap')
})
it('should haven\'t any logs in console of main window', async () => {
const { client } = this.app;
const logs = await client.getRenderProcessLogs();
const { client } = this.app
const logs = await client.getRenderProcessLogs()
// Print renderer process logs
logs.forEach((log) => {
console.log(log.message);
console.log(log.source);
console.log(log.level);
});
expect(logs).toHaveLength(0);
});
});
console.log(log.message)
console.log(log.source)
console.log(log.level)
})
expect(logs).toHaveLength(0)
})
})

23
webpack.config.renderer.dev.js

@ -1,4 +1,3 @@
/* eslint-disable */
/* eslint global-require: 0, import/no-dynamic-require: 0 */
/**
@ -18,21 +17,19 @@ import ExtractTextPlugin from 'extract-text-webpack-plugin'
import baseConfig from './webpack.config.base'
import CheckNodeEnv from './internals/scripts/CheckNodeEnv'
CheckNodeEnv('development');
CheckNodeEnv('development')
const port = process.env.PORT || 1212;
const publicPath = `http://localhost:${port}/dist`;
const dll = path.resolve(process.cwd(), 'dll');
const manifest = path.resolve(dll, 'renderer.json');
const port = process.env.PORT || 1212
const publicPath = `http://localhost:${port}/dist`
const dll = path.resolve(process.cwd(), 'dll')
const manifest = path.resolve(dll, 'renderer.json')
/**
* Warn if the DLL is not built
*/
if (!(fs.existsSync(dll) && fs.existsSync(manifest))) {
console.log(chalk.black.bgYellow.bold(
'The DLL files are missing. Sit back while we build them for you with "npm run build-dll"'
));
execSync('npm run build-dll');
console.log(chalk.black.bgYellow.bold('The DLL files are missing. Sit back while we build them for you with "npm run build-dll"'))
execSync('npm run build-dll')
}
export default merge.smart(baseConfig, {
@ -267,15 +264,15 @@ export default merge.smart(baseConfig, {
},
setup() {
if (process.env.START_HOT) {
console.log('Starting Main Process...');
console.log('Starting Main Process...')
spawn(
'npm',
['run', 'start-main-dev'],
{ shell: true, env: process.env, stdio: 'inherit' }
)
.on('close', code => process.exit(code))
.on('error', spawnError => console.error(spawnError));
.on('error', spawnError => console.error(spawnError))
}
}
}
});
})

Loading…
Cancel
Save