diff --git a/commitlint.config.js b/commitlint.config.js
index 3347cb9..422b194 100644
--- a/commitlint.config.js
+++ b/commitlint.config.js
@@ -1 +1 @@
-module.exports = {extends: ['@commitlint/config-conventional']};
+module.exports = { extends: ['@commitlint/config-conventional'] };
diff --git a/fetch-solana-install-init.js b/fetch-solana-install-init.js
index aa397df..cd0edb2 100644
--- a/fetch-solana-install-init.js
+++ b/fetch-solana-install-init.js
@@ -59,13 +59,13 @@ async function main() {
case 'Windows_NT':
download(
'solana-install-init-x86_64-pc-windows-msvc.exe',
- 'solana-install-init.exe',
+ 'solana-install-init.exe'
);
break;
case 'Darwin':
download(
'solana-install-init-x86_64-apple-darwin',
- 'solana-install-init',
+ 'solana-install-init'
);
// Set user write bit so that ShipIt can remove the quarantine attribute
// after unzipping an update archive, otherwise the update fails
@@ -74,7 +74,7 @@ async function main() {
case 'Linux':
download(
'solana-install-init-x86_64-unknown-linux-gnu',
- 'solana-install-init',
+ 'solana-install-init'
);
fs.chmodSync('solana-install-init', 0o555);
break;
diff --git a/src/app.jsx b/src/app.jsx
index 85f2ebd..83a09e4 100644
--- a/src/app.jsx
+++ b/src/app.jsx
@@ -1,3 +1,9 @@
+/* eslint no-console: ["error", { allow: ["log", "warn", "info", "error"] }] */
+/* eslint max-classes-per-file: 0 */
+/* eslint react/prefer-stateless-function: 0 */
+/* eslint react/destructuring-assignment: 0 */
+/* eslint react/sort-comp: 0 */
+
import Container from '@material-ui/core/Container';
import CssBaseline from '@material-ui/core/CssBaseline';
import FormControlLabel from '@material-ui/core/FormControlLabel';
@@ -11,16 +17,16 @@ import Switch from '@material-ui/core/Switch';
import TextField from '@material-ui/core/TextField';
import Typography from '@material-ui/core/Typography';
import log from 'electron-log';
-import {Connection, PublicKey} from '@solana/web3.js';
-import {withStyles} from '@material-ui/core/styles';
+import { Connection, PublicKey } from '@solana/web3.js';
+import { withStyles } from '@material-ui/core/styles';
import Store from 'electron-store';
import IconButton from '@material-ui/core/IconButton';
import SaveIcon from '@material-ui/icons/Save';
import autoscroll from 'autoscroll-react';
-import {Hook, Console, Decode} from 'console-feed';
+import { Hook, Console, Decode } from 'console-feed';
-import {url} from './url';
-import {Replicator} from './replicator';
+import url from './url';
+import Replicator from './replicator';
const styles = theme => ({
root: {
@@ -69,7 +75,7 @@ class LogConsole extends React.Component {
overflowY: 'hidden',
}}
>
-
@@ -110,13 +116,13 @@ class App extends React.Component {
Hook(console, newLog => {
const decodeLog = Decode(newLog);
log.info('term:', decodeLog.data[0]);
- const {logs} = this.state;
+ const { logs } = this.state;
logs.push(decodeLog);
const max = 20;
if (logs.length > max) {
logs.splice(0, logs.length - max);
}
- this.setState({logs});
+ this.setState({ logs });
});
this.connection = new Connection(url);
@@ -139,7 +145,7 @@ class App extends React.Component {
}
clearTerminal() {
- this.setState({logs: []});
+ this.setState({ logs: [] });
}
clusterRestart() {
@@ -157,7 +163,7 @@ class App extends React.Component {
if (transactionCount < this.state.transactionCount / 2) {
console.warn(
- `Transaction count decreased from ${this.state.transactionCount} to ${transactionCount}`,
+ `Transaction count decreased from ${this.state.transactionCount} to ${transactionCount}`
);
this.clusterRestart();
return;
@@ -165,13 +171,13 @@ class App extends React.Component {
const totalSupply = await this.connection.getTotalSupply();
const newMined = await this.replicator.adjustedReplicatorBalance();
- let totalMined = this.state.totalMined;
+ let { totalMined } = this.state;
if (newMined > this.state.depositMinimumLamports) {
if (isValidPublicKey(this.depositPublicKey)) {
const success = await this.replicator.depositMiningRewards(
new PublicKey(this.depositPublicKey),
- newMined,
+ newMined
);
if (success) {
totalMined += newMined;
@@ -184,12 +190,12 @@ class App extends React.Component {
if (isValidPublicKey(this.depositPublicKey)) {
try {
const balance = await this.connection.getBalance(
- new PublicKey(this.depositPublicKey),
+ new PublicKey(this.depositPublicKey)
);
depositPublicKeyBalance = `Account Balance: ${balance} lamports`;
} catch (err) {
log.warn(
- `Unable to getBalance of ${this.depositPublicKey}: ${err.message}`,
+ `Unable to getBalance of ${this.depositPublicKey}: ${err.message}`
);
}
}
@@ -209,7 +215,7 @@ class App extends React.Component {
onEnabledSwitch = event => {
const enabled = event.target.checked;
this.store.set('enabled', enabled);
- this.setState({enabled});
+ this.setState({ enabled });
if (enabled) {
this.clearTerminal();
this.replicator.start();
@@ -223,7 +229,7 @@ class App extends React.Component {
const unsavedDepositPublicKey = event.target.value;
const unsavedDepositPublicKeyValid = isValidPublicKey(
- unsavedDepositPublicKey,
+ unsavedDepositPublicKey
);
const unsavedDepositPublicKeySavePrompt =
unsavedDepositPublicKeyValid &&
@@ -265,7 +271,7 @@ class App extends React.Component {
};
render() {
- const {classes} = this.props;
+ const { classes } = this.props;
const AutoscrollLogConsole = autoscroll(LogConsole, {
isScrolledDownThreshold: 0,
@@ -273,7 +279,7 @@ class App extends React.Component {
// eslint-disable-next-line no-restricted-properties
const totalSupplySOL = (this.state.totalSupply / Math.pow(2, 34)).toFixed(
- 2,
+ 2
);
return (
@@ -283,7 +289,7 @@ class App extends React.Component {
diff --git a/src/index.js b/src/index.js
index 250d82b..a884885 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,4 +1,6 @@
-import {app, ipcMain, BrowserWindow, Menu} from 'electron';
+/* eslint no-console: ["error", { allow: ["log", "warn", "info", "error"] }] */
+
+import { app, ipcMain, BrowserWindow, Menu } from 'electron';
import installExtension, {
REACT_DEVELOPER_TOOLS,
} from 'electron-devtools-installer';
@@ -7,8 +9,8 @@ import path from 'path';
import os from 'os';
import log from 'electron-log';
import './updater';
-import {Replicator} from './replicator';
-import {sleep} from './sleep';
+import Replicator from './replicator';
+import sleep from './sleep';
// eslint-disable-next-line global-require
if (require('electron-squirrel-startup')) app.quit();
@@ -91,12 +93,12 @@ app.on('ready', async () => {
{
label: 'Edit',
submenu: [
- {label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:'},
- {label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:'},
- {label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:'},
+ { label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
+ { label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
+ { label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
],
},
- ]),
+ ])
);
}
diff --git a/src/renderer.jsx b/src/renderer.jsx
index f73a97c..5a1a539 100644
--- a/src/renderer.jsx
+++ b/src/renderer.jsx
@@ -1,6 +1,6 @@
import React from 'react';
import ReactDOM from 'react-dom';
-import {AppContainer} from 'react-hot-loader';
+import { AppContainer } from 'react-hot-loader';
import App from './app';
import pkg from '../package.json';
@@ -11,7 +11,7 @@ const render = () => {
,
- document.getElementById('App'),
+ document.getElementById('App')
);
};
diff --git a/src/replicator.js b/src/replicator.js
index 87bf300..6282585 100644
--- a/src/replicator.js
+++ b/src/replicator.js
@@ -1,5 +1,8 @@
+/* eslint no-console: ["error", { allow: ["log", "warn", "info", "error"] }] */
+/* eslint react/destructuring-assignment: 0 */
+
import log from 'electron-log';
-import {spawn} from 'promisify-child-process';
+import { spawn } from 'promisify-child-process';
import path from 'path';
import os from 'os';
import electron from 'electron';
@@ -11,14 +14,14 @@ import {
SystemProgram,
} from '@solana/web3.js';
import fs from 'mz/fs';
-import {solanaInstallInit} from './solana-install-init';
-import {sleep} from './sleep';
-import {url} from './url';
+import solanaInstallInit from './solana-install-init';
+import sleep from './sleep';
+import url from './url';
// TODO: https://github.com/solana-labs/solana/issues/4344
const airdropAmount = 100000;
-export class Replicator {
+export default class Replicator {
constructor(connection) {
const userDataPath = electron.remote.app.getPath('userData');
@@ -32,7 +35,7 @@ export class Replicator {
userDataPath,
'install',
'active_release',
- 'bin',
+ 'bin'
),
replicatorKeypair: null,
replicatorKeypairFile: path.join(userDataPath, 'replicator-keypair.json'),
@@ -66,7 +69,7 @@ export class Replicator {
],
{
force: true,
- },
+ }
);
} catch (err) {
log.debug('fkill errored with:', err);
@@ -105,11 +108,11 @@ export class Replicator {
if (this.replicatorKeypair !== null) {
try {
const realBalance = await this.connection.getBalance(
- this.replicatorKeypair.publicKey,
+ this.replicatorKeypair.publicKey
);
const adjustedBalance = Math.max(0, realBalance - airdropAmount);
log.info(
- `adjustedReplicatorBalance: real=${realBalance} adjusted=${adjustedBalance}`,
+ `adjustedReplicatorBalance: real=${realBalance} adjusted=${adjustedBalance}`
);
return adjustedBalance;
} catch (err) {
@@ -130,26 +133,26 @@ export class Replicator {
try {
log.info(
- `depositMiningRewards: ${amount} lamports to ${destinationPublicKey}`,
+ `depositMiningRewards: ${amount} lamports to ${destinationPublicKey}`
);
const transaction = SystemProgram.transfer(
this.replicatorKeypair.publicKey,
destinationPublicKey,
- amount,
+ amount
);
const signature = await sendAndConfirmTransaction(
this.connection,
transaction,
- this.replicatorKeypair,
+ this.replicatorKeypair
);
console.info(
- `Deposited mining rewards (${amount} lamports). Transaction signature: ${signature}`,
+ `Deposited mining rewards (${amount} lamports). Transaction signature: ${signature}`
);
return true;
} catch (err) {
console.error(
`Deposit mining rewards failed (${amount} lamports):`,
- err.message,
+ err.message
);
return false;
} finally {
@@ -166,8 +169,8 @@ export class Replicator {
}
console.log(`$ ${command} ${args.join(' ')}`);
log.info(`$ ${command} ${args.join(' ')}`);
- const env = Object.assign({}, {RUST_LOG: 'solana=info'}, process.env);
- const child = spawn(command, args, {env});
+ const env = { RUST_LOG: 'solana=info', ...process.env };
+ const child = spawn(command, args, { env });
log.info(`pid ${child.pid}`);
function logData(data) {
@@ -210,7 +213,7 @@ export class Replicator {
try {
await fs.access(keypairFile, fs.constants.R_OK);
const keypair = new Account(
- Buffer.from(jsonfile.readFileSync(keypairFile)),
+ Buffer.from(jsonfile.readFileSync(keypairFile))
);
const balance = await this.connection.getBalance(keypair.publicKey);
if (balance > 0) {
@@ -250,29 +253,29 @@ export class Replicator {
]);
const newReplicatorKeypair = await this.maybeGenerateKeypair(
- this.replicatorKeypairFile,
+ this.replicatorKeypairFile
);
const newStorageKeypair = await this.maybeGenerateKeypair(
this.storageKeypairFile,
- newReplicatorKeypair,
+ newReplicatorKeypair
);
console.info(`identity keypair: ${this.replicatorKeypairFile}`);
console.info(`storage keypair: ${this.storageKeypairFile}`);
const replicatorKeypair = new Account(
- Buffer.from(jsonfile.readFileSync(this.replicatorKeypairFile)),
+ Buffer.from(jsonfile.readFileSync(this.replicatorKeypairFile))
);
this.replicatorKeypair = replicatorKeypair;
const storageKeypair = new Account(
- Buffer.from(jsonfile.readFileSync(this.storageKeypairFile)),
+ Buffer.from(jsonfile.readFileSync(this.storageKeypairFile))
);
console.info(`identity pubkey: ${replicatorKeypair.publicKey}`);
console.info(`storage pubkey: ${storageKeypair.publicKey}`);
const replicatorStartingBalance = await this.connection.getBalance(
- this.replicatorKeypair.publicKey,
+ this.replicatorKeypair.publicKey
);
if (replicatorStartingBalance < airdropAmount) {
await this.cmd(solanaCli, [
diff --git a/src/sleep.js b/src/sleep.js
index a9a1d67..c7b033d 100644
--- a/src/sleep.js
+++ b/src/sleep.js
@@ -1,3 +1,3 @@
-export function sleep(ms) {
+export default function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
diff --git a/src/solana-install-init.js b/src/solana-install-init.js
index daf57e2..128e021 100644
--- a/src/solana-install-init.js
+++ b/src/solana-install-init.js
@@ -5,6 +5,8 @@ import path from 'path';
const isDevMode = process.execPath.match(/[\\/]electron/);
const dotexe = os.type() === 'Windows_NT' ? '.exe' : '';
-export const solanaInstallInit = isDevMode
+const solanaInstallInit = isDevMode
? `solana-install-init${dotexe}` // in dev mode assume it's in the path
: path.join(process.resourcesPath, `solana-install-init${dotexe}`); // bundled in the app when not in dev mode
+
+export default solanaInstallInit;
diff --git a/src/updater.js b/src/updater.js
index 0a9d0c8..2db51cb 100644
--- a/src/updater.js
+++ b/src/updater.js
@@ -1,4 +1,4 @@
-import {autoUpdater} from 'electron';
+import { autoUpdater } from 'electron';
import updateElectronApp from 'update-electron-app';
import log from 'electron-log';
diff --git a/src/url.js b/src/url.js
index 8239ac0..f9480c3 100644
--- a/src/url.js
+++ b/src/url.js
@@ -1,7 +1,7 @@
-// @noflow
+import { testnetChannelEndpoint } from '@solana/web3.js';
-import {testnetChannelEndpoint} from '@solana/web3.js';
-
-export const url = !process.env.LOCAL
+const url = !process.env.LOCAL
? testnetChannelEndpoint(process.env.CHANNEL || 'stable', false)
: 'http://localhost:8899';
+
+export default url;
diff --git a/webpack.rules.js b/webpack.rules.js
index 647b904..94630c6 100644
--- a/webpack.rules.js
+++ b/webpack.rules.js
@@ -8,7 +8,7 @@ module.exports = [
{
test: /\.(m?js|node)$/,
exclude: /(.webpack|node_modules)/,
- parser: {amd: false},
+ parser: { amd: false },
use: {
loader: '@marshallofsound/webpack-asset-relocator-loader',
options: {