Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all linting warnings #466

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cypress.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from 'cypress';
import { existsSync, readFileSync } from 'fs';
import { existsSync } from 'fs';
import cypressPlayback from '@oreillymedia/cypress-playback/addTasks.js';
export default defineConfig({
e2e: {
Expand Down
3 changes: 0 additions & 3 deletions scripts/chain_params.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ export const COIN = 10 ** 8;
/** The maximum gap (absence of transactions within a range of derived addresses) before an account search ends */
export const MAX_ACCOUNT_GAP = 20;

/** The batch size of Shield block synchronisation */
export const SHIELD_BATCH_SYNC_SIZE = 32;

/** Transaction Sapling Version */
export const SAPLING_TX_VERSION = 3;

Expand Down
3 changes: 1 addition & 2 deletions scripts/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import { openDB } from 'idb';
import Masternode from './masternode.js';
import { Settings } from './settings.js';
import { cChainParams } from './chain_params.js';
import { confirmPopup, sanitizeHTML, isSameType, isEmpty } from './misc.js';
import { isSameType, isEmpty } from './misc.js';
import { createAlert } from './alerts/alert.js';
import { PromoWallet } from './promos.js';
import { ALERTS, translation } from './i18n.js';
import { Account } from './accounts.js';
import { COutpoint, CTxIn, CTxOut, Transaction } from './transaction.js';
import { debugError, debugLog, DebugTopics } from './debug.js';
Expand Down
1 change: 0 additions & 1 deletion scripts/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import Stake from './stake/Stake.vue';
import { createPinia } from 'pinia';
import { cOracle } from './prices.js';

import pIconCopy from '../assets/icons/icon-copy.svg';
import pIconCheck from '../assets/icons/icon-check.svg';
import SideNavbar from './SideNavbar.vue';
import { AsyncInterval } from './async_interval.js';
Expand Down
2 changes: 1 addition & 1 deletion scripts/network/__mocks__/network_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class TestNetwork {
return 1;
});

getTxPage = vi.fn((nStartHeight, addr, n) => {
getTxPage = vi.fn((nStartHeight, addr, _n) => {
if (addr === 'DTSTGkncpC86sbEUZ2rCBLEe2aXSeZPLnC') {
// 1) Legacy mainnet wallet
// tx_1 provides a spendable balance of 0.1 * 10^8 satoshi
Expand Down
14 changes: 7 additions & 7 deletions scripts/network/network.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ export class Network {
}

async submitProposal({
name,
url,
nPayments,
start,
address,
monthlyPayment,
txid,
_name,
_url,
_nPayments,
_start,
_address,
_monthlyPayment,
_txid,
}) {
throw new Error('submitProposal must be implemented');
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/network/network_manager.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExplorerNetwork, Network, RPCNodeNetwork } from './network.js';
import { ExplorerNetwork, RPCNodeNetwork } from './network.js';
import { cChainParams } from '../chain_params.js';
import { fAutoSwitch } from '../settings.js';
import { debugLog, DebugTopics, debugWarn } from '../debug.js';
Expand All @@ -7,17 +7,17 @@ import { getEventEmitter } from '../event_bus.js';

class NetworkManager {
/**
* @type {Network} - Current selected Explorer
* @type {import('./network.js').Network} - Current selected Explorer
*/
#currentExplorer;

/**
* @type {Network} - Current selected RPC node
* @type {import('./network.js').Network} - Current selected RPC node
*/
#currentNode;

/**
* @type {Array<Network>} - List of all available Networks
* @type {Array<import('./network.js').Network>} - List of all available Networks
*/
#networks = [];

Expand Down
50 changes: 0 additions & 50 deletions scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,56 +75,6 @@ export function arrayToCSV(data) {
.join('\r\n'); // rows starting on new lines
}

/**
* Start a batch of promises, processing them concurrently up to `batchSize`.
* This does *not* run them in parallel. Only 1 CPU core is used
* @template T
* @param {(number)=>Promise<T>} promiseFactory - Function that spawns promises based
* on a number. 0 is the first, length-1 is the last one.
* @param {number} length - How many promises to spawn
* @param {number} batchSize - How many promises to spawn at a time
* @returns {Promise<T[]>} array of the return value of the promise.
* It's guaranteed to be sorted, i.e. it will contain
* [ await promsieFactory(0), await promisefactory(1), ... ]
* If the promises depend on each other, then behavior is undefined
*/
export async function startBatch(
promiseFactory,
length,
batchSize,
retryTime = 10000
) {
if (length === 0) {
return;
}
return new Promise((res) => {
const running = [];
let i = 0;
const startNext = async (current) => {
let result;
try {
result = await promiseFactory(current);
} catch (e) {
// Try again later
await sleep(retryTime);
return await startNext(current);
}
i++;
if (i < length) {
running.push(startNext(i));
} else {
(async () => res(await Promise.all(running)))();
}
return result;
};
// Start fisrt batchsize promises
for (i = 0; i < batchSize && i < length; i++) {
running.push(startNext(i));
}
--i;
});
}

/**
* An artificial sleep function to pause code execution
*
Expand Down
6 changes: 3 additions & 3 deletions scripts/wallet.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { validateMnemonic } from 'bip39';
import { decrypt } from './aes-gcm.js';
import { bytesToNum, mergeUint8Arrays, parseWIF } from './encoding.js';
import { bytesToNum, parseWIF } from './encoding.js';
import { beforeUnloadListener, blockCount } from './global.js';
import { getNetwork } from './network/network_manager.js';
import { MAX_ACCOUNT_GAP, SHIELD_BATCH_SYNC_SIZE } from './chain_params.js';
import { MAX_ACCOUNT_GAP } from './chain_params.js';
import { HistoricalTx, HistoricalTxType } from './historical_tx.js';
import { COutpoint, Transaction } from './transaction.js';
import { confirmPopup, isShieldAddress } from './misc.js';
Expand All @@ -15,7 +15,7 @@ import { Database } from './database.js';
import { RECEIVE_TYPES } from './contacts-book.js';
import { Account } from './accounts.js';
import { fAdvancedMode } from './settings.js';
import { bytesToHex, hexToBytes, sleep, startBatch } from './utils.js';
import { bytesToHex, hexToBytes, sleep } from './utils.js';
import { strHardwareName } from './ledger.js';
import { OutpointState, Mempool } from './mempool.js';
import { getEventEmitter } from './event_bus.js';
Expand Down
39 changes: 0 additions & 39 deletions tests/unit/start_batch.test.js

This file was deleted.