diff --git a/package.json b/package.json index 60f533ed..383a4bf8 100644 --- a/package.json +++ b/package.json @@ -126,7 +126,7 @@ "_build-dist": "rollup -c && uglifyjs ./dist/quais.js -o ./dist/quais.min.js && uglifyjs ./dist/quais.umd.js -o ./dist/quais.umd.min.js && uglifyjs ./dist/wordlists-extra.js -o ./dist/wordlists-extra.min.js", "_dist-stats": "gzip -k9f -S '.gz' ./dist/quais.min.js && gzip -k9f -S '.gz' ./dist/quais.umd.min.js && gzip -k9f -S '.gz' ./dist/wordlists-extra.min.js && du -hs ./dist/*.gz && echo '' && du -hs ./dist/*.js", "auto-build": "npm run build -- -w", - "lint": "eslint src.ts/**/*.ts", + "lint": "eslint src.ts/**/*.ts --fix", "build": "tsc --project tsconfig.esm.json", "build-all": "npm run build && npm run build-commonjs", "build-clean": "npm run clean && npm run build && npm run build-all && npm run _build-dist && npm run _dist-stats", diff --git a/src.ts/_admin/test-browser.ts b/src.ts/_admin/test-browser.ts index a5d46fe1..837bacff 100644 --- a/src.ts/_admin/test-browser.ts +++ b/src.ts/_admin/test-browser.ts @@ -72,6 +72,7 @@ export class CDPSession { this.#id = 1; this.#resp = new Map(); + // eslint-disable-next-line @typescript-eslint/no-unused-vars this.#exit = (status: number) => {}; this.#done = new Promise((resolve) => { this.#exit = resolve; @@ -80,6 +81,7 @@ export class CDPSession { this.#target = ''; this.#session = ''; + // eslint-disable-next-line @typescript-eslint/no-unused-vars const readyOpen: Promise = new Promise((resolve, reject) => { this.websocket.onopen = async () => { resolve(); @@ -133,6 +135,7 @@ export class CDPSession { } console.log(text); //console.log(msg.params.message.text, `${ msg.params.message.url }:${ msg.params.message.line }`); + // eslint-disable-next-line no-empty } else if (msg.method === 'Target.attachedToTarget') { } else { console.log(`WARN: Unhandled event - ${JSON.stringify(msg)}`); @@ -199,7 +202,7 @@ const TestData = (function () { return [String(data.length), zlib.deflateRawSync(data).toString('base64')].join(','); } - let data: Array = []; + const data: Array = []; data.push(`import { quais } from "/index.js";`); data.push(`import { inflate } from "/static/tiny-inflate.js";`); data.push(`const fs = new Map();`); @@ -322,6 +325,7 @@ export function start(_root: string, options: Options): Promise { } }); + // eslint-disable-next-line @typescript-eslint/no-unused-vars return new Promise((resolve, reject) => { server.listen(options.port, () => { console.log(`Server running on: http://localhost:${options.port}`); @@ -351,7 +355,8 @@ export function start(_root: string, options: Options): Promise { const args = ['--headless', '--disable-gpu', '--remote-debugging-port=8022']; const browser = child_process.spawn(cmd, args); - let url: string = await new Promise((resolve, reject) => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const url: string = await new Promise((resolve, reject) => { browser.stdout.on('data', (data) => { console.log('OUT', data.toString()); }); diff --git a/src.ts/_admin/update-changelog.ts b/src.ts/_admin/update-changelog.ts index 697cb27b..ad6113ba 100644 --- a/src.ts/_admin/update-changelog.ts +++ b/src.ts/_admin/update-changelog.ts @@ -70,7 +70,7 @@ type PresentVersion = { { const content = fs.readFileSync(resolve('CHANGELOG.md')).toString(); for (const line of content.split('\n')) { - let match = line.match(/^ethers\/v(\S+)\s/); + const match = line.match(/^ethers\/v(\S+)\s/); if (match) { present.push({ version: match[1], body: [line] }); } else { @@ -188,12 +188,14 @@ type PresentVersion = { let line = ` - ${change.message} (`; line += change.issues .map((i) => { + // eslint-disable-next-line no-useless-escape return `[#${i}](https:/\/github.com/ethers-io/ethers.js/issues/${i})`; }) .join(', '); if (change.issues.length) { line += '; '; } + // eslint-disable-next-line no-useless-escape line += `[${change.commit.substring(0, 7)}](https:/\/github.com/ethers-io/ethers.js/commit/${change.commit})).`; output.push(line); } diff --git a/src.ts/_tests/create-provider.ts b/src.ts/_tests/create-provider.ts index 41959bd6..3e0d6e17 100644 --- a/src.ts/_tests/create-provider.ts +++ b/src.ts/_tests/create-provider.ts @@ -74,6 +74,8 @@ export function getProvider(provider: string, network: string): null | AbstractP return null; } +// TODO: `newtork` is not used, remove or re-write +// eslint-disable-next-line @typescript-eslint/no-unused-vars export function checkProvider(provider: string, network: string): boolean { const creator = getCreator(provider); return creator != null; diff --git a/src.ts/_tests/test-contract.ts b/src.ts/_tests/test-contract.ts index 1db725a4..5146fe82 100644 --- a/src.ts/_tests/test-contract.ts +++ b/src.ts/_tests/test-contract.ts @@ -281,6 +281,8 @@ describe('Test Typed Contract Interaction', function () { 'int248', 'int256', ], + // TODO: `type` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars valueFunc: (type: string) => { return 42; }, @@ -333,18 +335,24 @@ describe('Test Typed Contract Interaction', function () { }, { types: ['bool'], + // TODO: `type` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars valueFunc: (type: string) => { return true; }, }, { types: ['address'], + // TODO: `type` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars valueFunc: (type: string) => { return '0x643aA0A61eADCC9Cc202D1915D942d35D005400C'; }, }, { types: ['string'], + // TODO: `type` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars valueFunc: (type: string) => { return 'someString'; }, diff --git a/src.ts/_tests/test-crypto-algoswap.ts b/src.ts/_tests/test-crypto-algoswap.ts index ea72a428..766aeb74 100644 --- a/src.ts/_tests/test-crypto-algoswap.ts +++ b/src.ts/_tests/test-crypto-algoswap.ts @@ -119,6 +119,8 @@ describe('test registration', function () { it('prevents swapping after locked', function () { lock(); + // TODO: `params` and `hijackTag` are not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars tests.forEach(({ name, params, hijackTag, algorithm }) => { assert.throws( function () { diff --git a/src.ts/_tests/test-provider-jsonrpc.ts b/src.ts/_tests/test-provider-jsonrpc.ts index 95e4336e..8e0fc518 100644 --- a/src.ts/_tests/test-provider-jsonrpc.ts +++ b/src.ts/_tests/test-provider-jsonrpc.ts @@ -47,6 +47,8 @@ function createProvider(testFunc: ProcessRequest): JsonRpcProvider { }; const req = new FetchRequest('http://localhost:8082/'); + // TODO: `signal` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars req.getUrlFunc = async (_req, signal) => { const req = JSON.parse(_req.hasBody() ? toUtf8String(_req.body) : ''); @@ -161,6 +163,8 @@ describe('Ensure Catchable Errors', function () { // A provider which is mocked to return a "missing v" // in getTransaction + // TODO: `blockNumber` and `params` are not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars const provider = createProvider((method, params, blockNumber) => { switch (method) { case 'quai_sendTransaction': diff --git a/src.ts/_tests/test-providers-data.ts b/src.ts/_tests/test-providers-data.ts index e9dd02b3..777c0824 100644 --- a/src.ts/_tests/test-providers-data.ts +++ b/src.ts/_tests/test-providers-data.ts @@ -47,7 +47,7 @@ function equals(name: string, actual: any, expected: any): void { assert.ok(false, name + ' - actual object null'); } - let keys: { [key: string]: boolean } = {}; + const keys: { [key: string]: boolean } = {}; Object.keys(expected).forEach((key) => { keys[key] = true; }); @@ -100,7 +100,7 @@ async function sendTransaction(to: string) { do { typeValue = getTxType(wallet.address, to); const gas = await getRPCGasPrice(process.env.CYPRUS1URL); - let tx: { + const tx: { from: string; to: string; value: any; @@ -142,6 +142,8 @@ async function sendTransaction(to: string) { } async function fetchRPCBlock(blockNumber: string | null) { + // TODO: this is supposedly an un-needed try-catch, consider revising + // eslint-disable-next-line no-useless-catch try { let response; do { @@ -232,10 +234,11 @@ describe('Test Provider Block operations', function () { }); it('should fetch block by number', async function () { - let responseBlock = (await providerC1.getBlock('0,0', '0xA')) as quais.Block; + const responseBlock = (await providerC1.getBlock('0,0', '0xA')) as quais.Block; assert.ok(responseBlock != null, 'block != null'); - - let { provider, ...formatBlock } = { + // TODO: `provider` is not used, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { provider, ...formatBlock } = { ...responseBlock, transactions: responseBlock.transactions, extTransactions: responseBlock.extTransactions, @@ -245,10 +248,11 @@ describe('Test Provider Block operations', function () { it('should fetch block by hash', async function () { assert.ok(block.hash != null, 'block.hash != null'); - let responseBlock = (await providerC1.getBlock('0,0', block.hash)) as quais.Block; + const responseBlock = (await providerC1.getBlock('0,0', block.hash)) as quais.Block; assert.ok(responseBlock != null, 'block != null'); - - let { provider, ...formatBlock } = { + // TODO: `provider` is not used, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { provider, ...formatBlock } = { ...responseBlock, transactions: responseBlock.transactions, extTransactions: responseBlock.extTransactions, @@ -293,7 +297,9 @@ describe('Test Transaction operations', function () { type: receipt.type, }; const receiptResponse = await providerC1.getTransactionReceipt(internalTx.hash); - let { provider, ...receiptResult } = { + // TODO: `provider` is not used, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { provider, ...receiptResult } = { ...receiptResponse, logs: receiptResponse?.logs, }; @@ -343,7 +349,9 @@ describe('Test Transaction operations', function () { type: Number(receipt.type), }; const receiptResponse = await providerC1.getTransactionReceipt(internalToExternalTx.hash); - let { provider, ...receiptResult } = { + // TODO: `provider` is not used, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { provider, ...receiptResult } = { ...receiptResponse, logs: receiptResponse?.logs, }; diff --git a/src.ts/_tests/test-wordlists.ts b/src.ts/_tests/test-wordlists.ts index 7f9e4e1a..f05d0ca6 100644 --- a/src.ts/_tests/test-wordlists.ts +++ b/src.ts/_tests/test-wordlists.ts @@ -10,7 +10,7 @@ describe('Check Wordlists', function () { const tests = loadTests('wordlists'); tests.forEach((test) => { - let wordlist = wordlists[test.locale]; + const wordlist = wordlists[test.locale]; if (wordlist == null) { return; } @@ -20,7 +20,7 @@ describe('Check Wordlists', function () { let check = ''; for (let i = 0; i < 2048; i++) { - let word = wordlist.getWord(i); + const word = wordlist.getWord(i); check += word + '\n'; assert.equal(word, words[i]); assert.equal(wordlist.getWordIndex(word), i); @@ -31,7 +31,7 @@ describe('Check Wordlists', function () { }); tests.forEach((test) => { - let wordlist = wordlists[test.locale]; + const wordlist = wordlists[test.locale]; if (wordlist == null) { return; } @@ -53,7 +53,7 @@ describe('Check Wordlists', function () { }); tests.forEach((test) => { - let wordlist = wordlists[test.locale]; + const wordlist = wordlists[test.locale]; if (wordlist == null) { return; } diff --git a/src.ts/_tests/utils.ts b/src.ts/_tests/utils.ts index 9f2c6de3..ccfc63da 100644 --- a/src.ts/_tests/utils.ts +++ b/src.ts/_tests/utils.ts @@ -6,6 +6,7 @@ import zlib from 'zlib'; const root = (function () { let root = process.cwd(); + // eslint-disable-next-line no-constant-condition while (true) { if (fs.existsSync(path.join(root, 'output'))) { return root; diff --git a/src.ts/abi/abi-coder.ts b/src.ts/abi/abi-coder.ts index 978fcfcb..64ce21f3 100644 --- a/src.ts/abi/abi-coder.ts +++ b/src.ts/abi/abi-coder.ts @@ -157,7 +157,7 @@ export class AbiCoder { // u?int[0-9]* let match = param.type.match(paramTypeNumber); if (match) { - let size = parseInt(match[2] || '256'); + const size = parseInt(match[2] || '256'); assertArgument( size !== 0 && size <= 256 && size % 8 === 0, 'invalid ' + match[1] + ' bit length', @@ -170,7 +170,7 @@ export class AbiCoder { // bytes[0-9]+ match = param.type.match(paramTypeBytes); if (match) { - let size = parseInt(match[1]); + const size = parseInt(match[1]); assertArgument(size !== 0 && size <= 32, 'invalid bytes length', 'param', param); return new FixedBytesCoder(size, param.name); } @@ -219,7 +219,8 @@ export class AbiCoder { * * @param {(string | ParamType)[]} types - Array of parameter types. * @param {BytesLike} data - The ABI data to decode. - * @param {boolean} [loose=false] - Enable loose decoding. Default is `false` Default is `false` + * @param {boolean} [loose=false] - Enable loose decoding. Default is `false` Default is `false` Default is `false` + * Default is `false` * * @returns {Result} The decoded values. */ diff --git a/src.ts/abi/fragments.ts b/src.ts/abi/fragments.ts index 18ede417..0a5abb01 100644 --- a/src.ts/abi/fragments.ts +++ b/src.ts/abi/fragments.ts @@ -337,8 +337,8 @@ function lex(text: string): TokenString { throw new Error(`invalid token ${token} at ${offset}: ${message}`); }; - let brackets: Array = []; - let commas: Array = []; + const brackets: Array = []; + const commas: Array = []; let offset = 0; while (offset < text.length) { @@ -362,7 +362,7 @@ function lex(text: string): TokenString { }; tokens.push(token); - let type = SimpleTokens[cur[0]] || ''; + const type = SimpleTokens[cur[0]] || ''; if (type) { token.type = type; token.text = cur[0]; @@ -440,7 +440,7 @@ function lex(text: string): TokenString { // Check only one of `allowed` is in `set` function allowSingle(set: ReadonlySet, allowed: ReadonlySet): void { - let included: Array = []; + const included: Array = []; for (const key in allowed.keys()) { if (set.has(key)) { included.push(key); @@ -468,6 +468,7 @@ function consumeName(type: string, tokens: TokenString): string { // ...all keywords matching allowed, returning the keywords function consumeKeywords(tokens: TokenString, allowed?: ReadonlySet): ReadonlySet { const keywords: Set = new Set(); + // eslint-disable-next-line no-constant-condition while (true) { const keyword = tokens.peekType('KEYWORD'); @@ -487,7 +488,7 @@ function consumeKeywords(tokens: TokenString, allowed?: ReadonlySet): Re // ...all visibility keywords, returning the coalesced mutability function consumeMutability(tokens: TokenString): 'payable' | 'nonpayable' | 'view' | 'pure' { - let modifiers = consumeKeywords(tokens, KwVisib); + const modifiers = consumeKeywords(tokens, KwVisib); // Detect conflicting modifiers allowSingle(modifiers, setify('constant payable nonpayable'.split(' '))); @@ -794,6 +795,7 @@ export class ParamType { if (this.arrayLength !== -1 && value.length !== this.arrayLength) { throw new Error('array is wrong length'); } + // eslint-disable-next-line @typescript-eslint/no-this-alias const _this = this; return value.map((v) => _this.arrayChildren.walk(v, process)); } @@ -805,6 +807,7 @@ export class ParamType { if (value.length !== this.components.length) { throw new Error('array is wrong length'); } + // eslint-disable-next-line @typescript-eslint/no-this-alias const _this = this; return value.map((v, i) => _this.components[i].walk(v, process)); } @@ -977,7 +980,7 @@ export class ParamType { let type = obj.type; - let arrayMatch = type.match(regexArrayType); + const arrayMatch = type.match(regexArrayType); if (arrayMatch) { const arrayLength = parseInt(arrayMatch[2] || '-1'); const arrayChildren = ParamType.from({ @@ -1053,6 +1056,7 @@ export abstract class Fragment { // Try parsing JSON... try { Fragment.from(JSON.parse(obj)); + // eslint-disable-next-line no-empty } catch (e) {} // ...otherwise, use the human-readable lexer diff --git a/src.ts/abi/interface.ts b/src.ts/abi/interface.ts index b9bfaf9d..77ca70d3 100644 --- a/src.ts/abi/interface.ts +++ b/src.ts/abi/interface.ts @@ -750,6 +750,8 @@ export class Interface { * * If the `key` and `values` do not refine to a single error in the ABI, this will throw. */ + // TODO: `values` is not used, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars getError(key: string, values?: Array): null | ErrorFragment { if (isHexString(key)) { const selector = key.toLowerCase(); @@ -1206,6 +1208,8 @@ export class Interface { const nonIndexed: Array = []; const dynamic: Array = []; + // TODO: `index` is not used, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars fragment.inputs.forEach((param, index) => { if (param.indexed) { if ( @@ -1283,6 +1287,8 @@ export class Interface { return new TransactionDescription(fragment, fragment.selector, args, value); } + // TODO: not implemented + // eslint-disable-next-line @typescript-eslint/no-unused-vars parseCallResult(data: BytesLike): Result { throw new Error('@TODO'); } diff --git a/src.ts/abi/typed.ts b/src.ts/abi/typed.ts index ca4504e6..6be50461 100644 --- a/src.ts/abi/typed.ts +++ b/src.ts/abi/typed.ts @@ -130,7 +130,7 @@ export class Typed { /** * @ignore */ - readonly _typedSymbol!: Symbol; + readonly _typedSymbol!: symbol; /** * @ignore diff --git a/src.ts/address/checks.ts b/src.ts/address/checks.ts index 2b60a630..0200c714 100644 --- a/src.ts/address/checks.ts +++ b/src.ts/address/checks.ts @@ -66,6 +66,7 @@ export function isAddress(value: any): value is string { try { getAddress(value); return true; + // eslint-disable-next-line no-empty } catch (error) {} return false; } diff --git a/src.ts/contract/contract.ts b/src.ts/contract/contract.ts index ae5bfc68..36729fa9 100644 --- a/src.ts/contract/contract.ts +++ b/src.ts/contract/contract.ts @@ -634,6 +634,7 @@ async function getSub(contract: BaseContract, operation: string, event: Contract if (foundFragment == null) { try { foundFragment = contract.interface.getEvent(log.topics[0]); + // eslint-disable-next-line no-empty } catch (error) {} } @@ -665,7 +666,7 @@ async function getSub(contract: BaseContract, operation: string, event: Contract return; } - let started = starting; + const started = starting; starting = []; await Promise.all(started); provider.off(filter, listener); @@ -705,6 +706,7 @@ async function _emit( } try { listener.call(contract, ...passArgs); + // eslint-disable-next-line no-empty } catch (error) {} return !once; }); @@ -725,6 +727,7 @@ async function emit( ): Promise { try { await lastEmit; + // eslint-disable-next-line no-empty } catch (error) {} const resultPromise = _emit(contract, event, args, payloadFunc); @@ -814,7 +817,7 @@ export class BaseContract implements Addressable, EventEmitterableprovider, _deployTx); } - let subs = new Map(); + const subs = new Map(); // Resolve the target as the address if (typeof target === 'string') { @@ -1018,6 +1021,8 @@ export class BaseContract implements Addressable, EventEmitterable> { throw new Error('@TODO'); } @@ -1076,6 +1081,7 @@ export class BaseContract implements Addressable, EventEmitterable = Array, I = BaseContract const sender = String(tx.from); const toShard = getShardForAddress(sender); - var i = 0; - var startingData = tx.data; + let i = 0; + const startingData = tx.data; while (i < 10000) { - var contractAddress = getContractAddress(sender, BigInt(tx.nonce || 0), tx.data || ''); - var contractShard = getShardForAddress(contractAddress); + const contractAddress = getContractAddress(sender, BigInt(tx.nonce || 0), tx.data || ''); + const contractShard = getShardForAddress(contractAddress); console.log('contractAddress ', contractAddress); - var utxo = isUTXOAddress(contractAddress); + const utxo = isUTXOAddress(contractAddress); if (contractShard === toShard && !utxo) { return tx; } - var salt = randomBytes(32); + const salt = randomBytes(32); tx.data = hexlify(concat([String(startingData), salt])); i++; } diff --git a/src.ts/hash/namehash.ts b/src.ts/hash/namehash.ts index 4757e7b7..9ca9d14d 100644 --- a/src.ts/hash/namehash.ts +++ b/src.ts/hash/namehash.ts @@ -67,6 +67,7 @@ export function ensNormalize(name: string): string { export function isValidName(name: string): name is string { try { return ensNameSplit(name).length !== 0; + // eslint-disable-next-line no-empty } catch (error) {} return false; } diff --git a/src.ts/hash/solidity.ts b/src.ts/hash/solidity.ts index 400d610a..cd0b92b2 100644 --- a/src.ts/hash/solidity.ts +++ b/src.ts/hash/solidity.ts @@ -29,7 +29,7 @@ function _pack(type: string, value: any, isArray?: boolean): Uint8Array { case 'bytes': return getBytes(value); case 'bool': - value = !!value ? '0x01' : '0x00'; + value = value ? '0x01' : '0x00'; if (isArray) { return getBytes(zeroPadValue(value, 32)); } @@ -38,7 +38,7 @@ function _pack(type: string, value: any, isArray?: boolean): Uint8Array { let match = type.match(regexNumber); if (match) { - let signed = match[1] === 'int'; + const signed = match[1] === 'int'; let size = parseInt(match[2] || '256'); assertArgument( diff --git a/src.ts/hash/typed-data.ts b/src.ts/hash/typed-data.ts index 42f64f18..20ebabbc 100644 --- a/src.ts/hash/typed-data.ts +++ b/src.ts/hash/typed-data.ts @@ -128,6 +128,7 @@ const domainChecks: Record any> = { verifyingContract: function (value: any) { try { return getAddress(value).toLowerCase(); + // eslint-disable-next-line no-empty } catch (error) {} assertArgument(false, `invalid domain value "verifyingContract"`, 'domain.verifyingContract', value); }, diff --git a/src.ts/providers/abstract-provider.ts b/src.ts/providers/abstract-provider.ts index 8abaea1d..5a4d2679 100644 --- a/src.ts/providers/abstract-provider.ts +++ b/src.ts/providers/abstract-provider.ts @@ -253,6 +253,8 @@ export class UnmanagedSubscriber implements Subscriber { start(): void {} stop(): void {} + // TODO: `dropWhilePaused` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars pause(dropWhilePaused?: boolean): void {} resume(): void {} } @@ -278,6 +280,8 @@ function concisify(items: Array): Array { return items; } +// TODO: `provider` is not used, remove or re-write +// eslint-disable-next-line @typescript-eslint/no-unused-vars async function getSubscription(_event: ProviderEvent, provider: AbstractProvider): Promise { if (_event == null) { throw new Error('invalid event'); @@ -728,7 +732,7 @@ export class AbstractProvider implements Provider { } async shardFromAddress(_address: AddressLike): Promise { - let address: string | Promise = this._getAddress(_address); + const address: string | Promise = this._getAddress(_address); return (await address).slice(0, 4); } @@ -872,6 +876,8 @@ export class AbstractProvider implements Provider { * * @returns {Block} The wrapped block. */ + // TODO: `newtork` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars _wrapBlock(value: BlockParams, network: Network): Block { // Handle known node by -> remove null values from the number array value.number = Array.isArray(value.number) ? value.number.filter((n: any) => n != null) : value.number; @@ -887,6 +893,8 @@ export class AbstractProvider implements Provider { * * @returns {Log} The wrapped log. */ + // TODO: `newtork` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars _wrapLog(value: LogParams, network: Network): Log { return new Log(formatLog(value), this); } @@ -900,6 +908,8 @@ export class AbstractProvider implements Provider { * * @returns {TransactionReceipt} The wrapped transaction receipt. */ + // TODO: `newtork` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars _wrapTransactionReceipt(value: TransactionReceiptParams, network: Network): TransactionReceipt { return new TransactionReceipt(formatTransactionReceipt(value), this); } @@ -913,6 +923,8 @@ export class AbstractProvider implements Provider { * * @returns {TransactionResponse} The wrapped transaction response. */ + // TODO: `newtork` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars _wrapTransactionResponse(tx: TransactionResponseParams, network: Network): TransactionResponse { if ('from' in tx) { return new QuaiTransactionResponse(formatTransactionResponse(tx) as QuaiTransactionResponseParams, this); @@ -930,6 +942,7 @@ export class AbstractProvider implements Provider { * * @returns {Promise} A promise resolving to the network. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars _detectNetwork(shard?: string): Promise { assert(false, 'sub-classes must implement this', 'UNSUPPORTED_OPERATION', { operation: '_detectNetwork', @@ -1088,7 +1101,7 @@ export class AbstractProvider implements Provider { }; // Addresses could be async (ENS names or Addressables) - let address: Array> = []; + const address: Array> = []; if (filter.address) { if (Array.isArray(filter.address)) { for (const addr of filter.address) { @@ -1274,6 +1287,7 @@ export class AbstractProvider implements Provider { ? await this.#perform({ method: 'getMaxPriorityFeePerGas', shard: shard }) : 0; return getBigInt(value, '%response'); + // eslint-disable-next-line no-empty } catch (error) {} return null; })(), @@ -1323,17 +1337,16 @@ export class AbstractProvider implements Provider { ); } + // TODO: `attempt` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars async #call(tx: PerformActionTransaction, blockTag: string, attempt: number): Promise { // This came in as a PerformActionTransaction, so to/from are safe; we can cast const transaction = copyRequest(tx); - - try { - return hexlify(await this._perform({ method: 'call', transaction, blockTag })); - } catch (error: any) { - throw error; - } + return hexlify(await this._perform({ method: 'call', transaction, blockTag })); } + // TODO: `shard` is not used, remove or re-write + // eslint-disable-next-line @typescript-eslint/no-unused-vars async #checkNetwork(promise: Promise, shard?: string): Promise { const { value } = await resolveProperties({ network: this.getNetwork(), @@ -1410,7 +1423,7 @@ export class AbstractProvider implements Provider { network: this.getNetwork(), }); - let tx = type == 2 ? QiTransaction.from(signedTx) : QuaiTransaction.from(signedTx); + const tx = type == 2 ? QiTransaction.from(signedTx) : QuaiTransaction.from(signedTx); this.#validateTransactionHash(tx.hash || '', hash); return this._wrapTransactionResponse(tx, network).replaceableTransaction(blockNumber); @@ -1521,7 +1534,8 @@ export class AbstractProvider implements Provider { return params.map((p) => this._wrapLog(p, network)); } - // ENS + // TODO: unsupported, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars _getProvider(chainId: number): AbstractProvider { assert(false, 'provider cannot connect to target network', 'UNSUPPORTED_OPERATION', { operation: '_getProvider()', @@ -1539,6 +1553,7 @@ export class AbstractProvider implements Provider { return this.getTransactionReceipt(hash); } + // eslint-disable-next-line no-async-promise-executor return new Promise(async (resolve, reject) => { let timer: null | Timer = null; @@ -1577,6 +1592,8 @@ export class AbstractProvider implements Provider { }); } + // TODO: not implemented yet + // eslint-disable-next-line @typescript-eslint/no-unused-vars async waitForBlock(shard: string, blockTag?: BlockTag): Promise { assert(false, 'not implemented yet', 'NOT_IMPLEMENTED', { operation: 'waitForBlock', @@ -1753,6 +1770,7 @@ export class AbstractProvider implements Provider { const payload = new EventPayload(this, once ? null : listener, event); try { listener.call(this, ...args, payload); + // eslint-disable-next-line no-empty } catch (error) {} return !once; }); diff --git a/src.ts/providers/abstract-signer.ts b/src.ts/providers/abstract-signer.ts index c381741a..e4f94432 100644 --- a/src.ts/providers/abstract-signer.ts +++ b/src.ts/providers/abstract-signer.ts @@ -36,7 +36,7 @@ function checkProvider(signer: AbstractSigner, operation: string): Provider { } async function populate(signer: AbstractSigner, tx: TransactionRequest): Promise { - let pop: any = copyRequest(tx); + const pop: any = copyRequest(tx); if (pop.to != null) { pop.to = resolveAddress(pop.to); @@ -84,7 +84,7 @@ export abstract class AbstractSigner

{ - let address: string | Promise = this._getAddress(_address); + const address: string | Promise = this._getAddress(_address); return (await address).slice(0, 4); } /** @@ -130,7 +130,7 @@ export abstract class AbstractSigner

{ const provider = checkProvider(this, 'sendTransaction'); - let sender = await this.getAddress(); + const sender = await this.getAddress(); const shard = await this.shardFromAddress(addressFromTransactionRequest(tx)); let pop; @@ -246,17 +246,28 @@ export class VoidSigner extends AbstractSigner { assert(false, `VoidSigner cannot sign ${suffix}`, 'UNSUPPORTED_OPERATION', { operation }); } + // TODO: `domain`, `types` and `value` are not used, remove? + // TODO: this function only throws, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars async signTransaction(tx: TransactionRequest): Promise { this.#throwUnsupported('transactions', 'signTransaction'); } + // TODO: `domain`, `types` and `value` are not used, remove? + // TODO: this function only throws, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars async signMessage(message: string | Uint8Array): Promise { this.#throwUnsupported('messages', 'signMessage'); } + // TODO: `domain`, `types` and `value` are not used, remove? + // TODO: this function only throws, remove? async signTypedData( + // eslint-disable-next-line @typescript-eslint/no-unused-vars domain: TypedDataDomain, + // eslint-disable-next-line @typescript-eslint/no-unused-vars types: Record>, + // eslint-disable-next-line @typescript-eslint/no-unused-vars value: Record, ): Promise { this.#throwUnsupported('typed-data', 'signTypedData'); diff --git a/src.ts/providers/default-provider.ts b/src.ts/providers/default-provider.ts index 35bf8fb9..f83f7aa4 100644 --- a/src.ts/providers/default-provider.ts +++ b/src.ts/providers/default-provider.ts @@ -110,6 +110,7 @@ export function getDefaultProvider( let staticNetwork: null | Network = null; try { staticNetwork = Network.from(network); + // eslint-disable-next-line no-empty } catch (error) {} const providers: Array = []; diff --git a/src.ts/providers/network.ts b/src.ts/providers/network.ts index 8840a371..5bf74d04 100644 --- a/src.ts/providers/network.ts +++ b/src.ts/providers/network.ts @@ -122,6 +122,7 @@ export class Network { if (typeof other === 'string') { try { return this.chainId === getBigInt(other); + // eslint-disable-next-line no-empty } catch (error) {} return this.name === other; } @@ -129,6 +130,7 @@ export class Network { if (typeof other === 'number' || typeof other === 'bigint') { try { return this.chainId === getBigInt(other); + // eslint-disable-next-line no-empty } catch (error) {} return false; } @@ -137,6 +139,7 @@ export class Network { if (other.chainId != null) { try { return this.chainId === getBigInt(other.chainId); + // eslint-disable-next-line no-empty } catch (error) {} return false; } diff --git a/src.ts/providers/plugin-fallback.ts b/src.ts/providers/plugin-fallback.ts index c5c63bbb..f39c3653 100644 --- a/src.ts/providers/plugin-fallback.ts +++ b/src.ts/providers/plugin-fallback.ts @@ -12,12 +12,15 @@ export class CheckQualifiedPlugin implements AbstractProviderPlugin { defineProperties(this, { name: PluginIdFallbackProvider }); } + // TODO: `provider` is not used, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars connect(provider: AbstractProvider): CheckQualifiedPlugin { return this; } - // Retruns true if this value should be considered qualified for - // inclusion in the quorum. + // Retruns true if this value should be considered qualified for inclusion in the quorum. + // TODO: `action` and `result` are not used, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars isQualified(action: PerformActionRequest, result: any): boolean { return true; } diff --git a/src.ts/providers/provider-fallback.ts b/src.ts/providers/provider-fallback.ts index 043df819..d0134188 100644 --- a/src.ts/providers/provider-fallback.ts +++ b/src.ts/providers/provider-fallback.ts @@ -798,7 +798,7 @@ export class FallbackProvider extends AbstractProvider { if (req.method === 'broadcastTransaction') { // Once any broadcast provides a positive result, use it. No // need to wait for anyone else - const results: Array = this.#configs.map((c) => null); + const results: Array = this.#configs.map(() => null); const broadcasts = this.#configs.map(async ({ provider, weight }, index) => { try { const result = await provider._perform(req); @@ -809,6 +809,7 @@ export class FallbackProvider extends AbstractProvider { }); // As each promise finishes... + // eslint-disable-next-line no-constant-condition while (true) { // Check for a valid broadcast result const done = >results.filter((r) => r != null); @@ -855,6 +856,7 @@ export class FallbackProvider extends AbstractProvider { // Bootstrap enough runners to meet quorum const running: Set = new Set(); let inflightQuorum = 0; + // eslint-disable-next-line no-constant-condition while (true) { const runner = this.#addRunner(running, req); if (runner == null) { diff --git a/src.ts/providers/provider-ipcsocket.ts b/src.ts/providers/provider-ipcsocket.ts index 29688192..1db60f91 100644 --- a/src.ts/providers/provider-ipcsocket.ts +++ b/src.ts/providers/provider-ipcsocket.ts @@ -12,6 +12,7 @@ function splitBuffer(data: Buffer): { messages: Array; remaining: Buffer const messages: Array = []; let lastStart = 0; + // eslint-disable-next-line no-constant-condition while (true) { const nl = data.indexOf(10, lastStart); if (nl === -1) { diff --git a/src.ts/providers/provider-jsonrpc.ts b/src.ts/providers/provider-jsonrpc.ts index cfcc23c3..e758e1d1 100644 --- a/src.ts/providers/provider-jsonrpc.ts +++ b/src.ts/providers/provider-jsonrpc.ts @@ -309,6 +309,8 @@ export class JsonRpcSigner extends AbstractSigner { defineProperties(this, { address }); } + // TODO: `provider` is passed in, but not used, remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars connect(provider: null | Provider): Signer { assert(false, 'cannot reconnect JsonRpcSigner', 'UNSUPPORTED_OPERATION', { operation: 'signer.connect', @@ -602,7 +604,7 @@ export abstract class JsonRpcApiProvider extends AbstractProvi } } - let rawResult: Array> = []; + const rawResult: Array> = []; await Promise.all( Array.from(payloadMap).map(async ([key, value]) => { const payload = value.length === 1 ? value[0] : value; @@ -749,7 +751,7 @@ export abstract class JsonRpcApiProvider extends AbstractProvi await this.initPromise; } if (req.method === 'call' || req.method === 'estimateGas') { - let tx = req.transaction; + const tx = req.transaction; if (tx && tx.type != null && getBigInt(tx.type)) { // If there are no EIP-1559 properties, it might be non-EIP-a559 if (tx.maxFeePerGas == null && tx.maxPriorityFeePerGas == null) { @@ -1444,6 +1446,7 @@ function spelunkData(value: any): null | { message: string; data: string } { if (typeof value === 'string') { try { return spelunkData(JSON.parse(value)); + // eslint-disable-next-line no-empty } catch (error) {} } @@ -1471,6 +1474,7 @@ function _spelunkMessage(value: any, result: Array): void { if (typeof value === 'string') { try { return _spelunkMessage(JSON.parse(value), result); + // eslint-disable-next-line no-empty } catch (error) {} } } diff --git a/src.ts/providers/provider-socket.ts b/src.ts/providers/provider-socket.ts index 33b30034..94374645 100644 --- a/src.ts/providers/provider-socket.ts +++ b/src.ts/providers/provider-socket.ts @@ -119,6 +119,7 @@ export class SocketSubscriber implements Subscriber { /** * Sub-classes **must** override this to emit the events on the provider. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars async _emit(provider: SocketProvider, message: any): Promise { throw new Error('sub-classes must implemente this; _emit'); } @@ -369,6 +370,7 @@ export class SocketProvider extends JsonRpcApiProvider { /** * Sub-classes **must** override this to send `message` over their transport. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars async _write(message: string, shard?: string): Promise { throw new Error('sub-classes must override this'); } diff --git a/src.ts/providers/provider.ts b/src.ts/providers/provider.ts index f368ab10..820f876e 100644 --- a/src.ts/providers/provider.ts +++ b/src.ts/providers/provider.ts @@ -1586,7 +1586,7 @@ export class QuaiTransactionResponse implements QuaiTransactionLike, QuaiTransac */ toJSON(): any { const { blockNumber, blockHash, index, hash, type, to, from, nonce, data, signature, accessList } = this; - let result = { + const result = { _type: 'TransactionReceipt', accessList, blockNumber, @@ -2025,7 +2025,6 @@ export class QiTransactionResponse implements QiTransactionLike, QiTransactionRe readonly txOutputs?: Array; - // @ts-ignore #startBlock: number; /** * @ignore @@ -2055,7 +2054,7 @@ export class QiTransactionResponse implements QiTransactionLike, QiTransactionRe */ toJSON(): any { const { blockNumber, blockHash, index, hash, type, signature, txInputs, txOutputs } = this; - let result = { + const result = { _type: 'TransactionReceipt', blockNumber, blockHash, diff --git a/src.ts/providers/subscriber-filterid.ts b/src.ts/providers/subscriber-filterid.ts index c94f5ff7..e1504854 100644 --- a/src.ts/providers/subscriber-filterid.ts +++ b/src.ts/providers/subscriber-filterid.ts @@ -53,6 +53,7 @@ export class FilterIdSubscriber implements Subscriber { /** * Sub-classes **must** override this to begin the subscription. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars _subscribe(provider: JsonRpcApiProvider): Promise { throw new Error('subclasses must override this'); } @@ -60,6 +61,7 @@ export class FilterIdSubscriber implements Subscriber { /** * Sub-classes **must** override this handle the events. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars _emitResults(provider: AbstractProvider, result: Array): Promise { throw new Error('subclasses must override this'); } @@ -67,10 +69,13 @@ export class FilterIdSubscriber implements Subscriber { /** * Sub-classes **must** override this handle recovery on errors. */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars _recover(provider: AbstractProvider): Subscriber { throw new Error('subclasses must override this'); } + // TODO: `blockNumber` is not used, should it be removed? + // eslint-disable-next-line @typescript-eslint/no-unused-vars async #poll(blockNumber: number): Promise { try { // Subscribe if necessary diff --git a/src.ts/providers/subscriber-polling.ts b/src.ts/providers/subscriber-polling.ts index 1b96dc48..17e49682 100644 --- a/src.ts/providers/subscriber-polling.ts +++ b/src.ts/providers/subscriber-polling.ts @@ -155,6 +155,8 @@ export class OnBlockSubscriber implements Subscriber { /** * Called on every new block. */ + // TODO: implement this + // eslint-disable-next-line @typescript-eslint/no-unused-vars async _poll(blockNumber: number, provider: AbstractProvider): Promise { throw new Error('sub-classes must override this'); } @@ -178,6 +180,8 @@ export class OnBlockSubscriber implements Subscriber { this.#provider.off('block', this.#poll); } + // TODO: `dropWhilePaused` is not used; remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars pause(dropWhilePaused?: boolean): void { this.stop(); } @@ -197,6 +201,8 @@ export class PollingOrphanSubscriber extends OnBlockSubscriber { this.#filter = copy(filter); } + // TODO: implement this + // eslint-disable-next-line @typescript-eslint/no-unused-vars async _poll(blockNumber: number, provider: AbstractProvider): Promise { throw new Error('@TODO'); console.log(this.#filter); diff --git a/src.ts/transaction/qi-transaction.ts b/src.ts/transaction/qi-transaction.ts index fdd6a98a..048c4c26 100644 --- a/src.ts/transaction/qi-transaction.ts +++ b/src.ts/transaction/qi-transaction.ts @@ -88,7 +88,7 @@ export class QiTransaction extends AbstractTransaction implements QiTran const hashHex = keccak256(dataBuffer); const hashBuffer = Buffer.from(hashHex.substring(2), 'hex'); - let origin = this.originShard ? parseInt(this.originShard, 16) : 0; + const origin = this.originShard ? parseInt(this.originShard, 16) : 0; hashBuffer[0] = origin; hashBuffer[1] |= 0x80; hashBuffer[2] = origin; diff --git a/src.ts/transaction/quai-transaction.ts b/src.ts/transaction/quai-transaction.ts index 9637470d..a9cb63c5 100644 --- a/src.ts/transaction/quai-transaction.ts +++ b/src.ts/transaction/quai-transaction.ts @@ -149,7 +149,7 @@ export class QuaiTransaction extends AbstractTransaction implements Q const hashHex = keccak256(dataBuffer); const hashBuffer = Buffer.from(hashHex.substring(2), 'hex'); - let origin = this.originShard ? parseInt(this.originShard, 16) : 0; + const origin = this.originShard ? parseInt(this.originShard, 16) : 0; hashBuffer[0] = origin; hashBuffer[1] &= 0x7f; hashBuffer[2] = origin; diff --git a/src.ts/utils/errors.ts b/src.ts/utils/errors.ts index 41b6b229..b38f336f 100644 --- a/src.ts/utils/errors.ts +++ b/src.ts/utils/errors.ts @@ -169,6 +169,8 @@ export type ErrorCode = * * @category Utils */ +// TODO: +// eslint-disable-next-line @typescript-eslint/no-unused-vars export interface quaisError extends Error { /** * The string error code. @@ -677,7 +679,7 @@ export function makeError>( code: K, info?: ErrorInfo, ): T { - let shortMessage = message; + const shortMessage = message; { const details: Array = []; @@ -810,6 +812,7 @@ const _normalizeForms = ['NFD', 'NFC', 'NFKD', 'NFKC'].reduce( } accum.push(form); + // eslint-disable-next-line no-empty } catch (error) {} return accum; diff --git a/src.ts/utils/fetch.ts b/src.ts/utils/fetch.ts index b738effd..f10ddacb 100644 --- a/src.ts/utils/fetch.ts +++ b/src.ts/utils/fetch.ts @@ -96,6 +96,8 @@ const reIpfs = new RegExp('^ipfs://(ipfs/)?(.*)$', 'i'); let locked = false; // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URLs +// TODO: `signal` is not used; remove? +// eslint-disable-next-line @typescript-eslint/no-unused-vars async function dataGatewayFunc(url: string, signal?: FetchCancelSignal): Promise { try { const match = url.match(reData); @@ -125,6 +127,8 @@ async function dataGatewayFunc(url: string, signal?: FetchCancelSignal): Promise * @returns {FetchGatewayFunc} The gateway function. */ function getIpfsGatewayFunc(baseUrl: string): FetchGatewayFunc { + // TODO: `signal` is not used; remove? + // eslint-disable-next-line @typescript-eslint/no-unused-vars async function gatewayIpfs(url: string, signal?: FetchCancelSignal): Promise { try { const match = url.match(reIpfs); @@ -599,6 +603,7 @@ export class FetchRequest implements Iterable<[key: string, value: string]> { try { const location = response.headers.location || ''; return req.redirect(location).#send(attempt + 1, expires, 0, _request, response); + // eslint-disable-next-line no-empty } catch (error) {} // Things won't get any better on another attempt; abort @@ -1062,6 +1067,7 @@ export class FetchResponse implements Iterable<[key: string, value: string]> { if (this.ok()) { return; } + // eslint-disable-next-line prefer-const let { message, error } = this.#error; if (message === '') { message = `server response ${this.statusCode} ${this.statusMessage}`; diff --git a/src.ts/utils/fixednumber.ts b/src.ts/utils/fixednumber.ts index 71fbfeb9..d408e24d 100644 --- a/src.ts/utils/fixednumber.ts +++ b/src.ts/utils/fixednumber.ts @@ -751,8 +751,8 @@ export class FixedNumber { const format = getFormat(_format); - let whole = match[2] || '0', - decimal = match[3] || ''; + const whole = match[2] || '0'; + let decimal = match[3] || ''; // Pad out the decimals while (decimal.length < format.decimals) { diff --git a/src.ts/utils/geturl-browser.ts b/src.ts/utils/geturl-browser.ts index cb7edea0..c4564d51 100644 --- a/src.ts/utils/geturl-browser.ts +++ b/src.ts/utils/geturl-browser.ts @@ -25,7 +25,8 @@ declare global { } // @TODO: timeout is completely ignored; start a Promise.any with a reject? - +// TODO: `options` is not used; remove? +// eslint-disable-next-line @typescript-eslint/no-unused-vars export function createGetUrl(options?: Record): FetchGetUrlFunc { async function getUrl(req: FetchRequest, _signal?: FetchCancelSignal): Promise { const protocol = req.url.split(':')[0].toLowerCase(); diff --git a/src.ts/utils/properties.ts b/src.ts/utils/properties.ts index bffe1269..92df268c 100644 --- a/src.ts/utils/properties.ts +++ b/src.ts/utils/properties.ts @@ -77,8 +77,8 @@ export function defineProperties( values: { [K in keyof T]?: T[K] }, types?: { [K in keyof T]?: string }, ): void { - for (let key in values) { - let value = values[key]; + for (const key in values) { + const value = values[key]; const type = types ? types[key] : null; if (type) { diff --git a/src.ts/utils/units.ts b/src.ts/utils/units.ts index 746378cd..5618b0e3 100644 --- a/src.ts/utils/units.ts +++ b/src.ts/utils/units.ts @@ -29,7 +29,8 @@ const names = ['wei', 'kwei', 'mwei', 'gwei', 'szabo', 'finney', 'ether']; * * @category Utils * @param {BigNumberish} value - The value to convert. - * @param {string | Numeric} [unit=18] - The unit to convert to. Default is `18` Default is `18` + * @param {string | Numeric} [unit=18] - The unit to convert to. Default is `18` Default is `18` Default is `18` Default + * is `18` * * @returns {string} The converted value. * @throws {Error} If the unit is invalid. @@ -53,7 +54,8 @@ export function formatUnits(value: BigNumberish, unit?: string | Numeric): strin * * @category Utils * @param {string} value - The value to convert. - * @param {string | Numeric} [unit=18] - The unit to convert from. Default is `18` Default is `18` + * @param {string | Numeric} [unit=18] - The unit to convert from. Default is `18` Default is `18` Default is `18` + * Default is `18` * * @returns {bigint} The converted value. * @throws {Error} If the unit is invalid. diff --git a/src.ts/utils/utf8.ts b/src.ts/utils/utf8.ts index 9ae1edd0..732541cb 100644 --- a/src.ts/utils/utf8.ts +++ b/src.ts/utils/utf8.ts @@ -79,21 +79,27 @@ export type Utf8ErrorFunc = ( badCodepoint?: number, ) => number; +// `output` and `badCodepoint` are passed to calls below, but not used in the function function errorFunc( reason: Utf8ErrorReason, offset: number, bytes: Uint8Array, + // eslint-disable-next-line @typescript-eslint/no-unused-vars output: Array, + // eslint-disable-next-line @typescript-eslint/no-unused-vars badCodepoint?: number, ): number { assertArgument(false, `invalid codepoint at offset ${offset}; ${reason}`, 'bytes', bytes); } +// `output` and `badCodepoint` are passed to calls below, but not used in the function function ignoreFunc( reason: Utf8ErrorReason, offset: number, bytes: Uint8Array, + // eslint-disable-next-line @typescript-eslint/no-unused-vars output: Array, + // eslint-disable-next-line @typescript-eslint/no-unused-vars badCodepoint?: number, ): number { // If there is an invalid prefix (including stray continuation), skip any additional continuation bytes @@ -221,7 +227,7 @@ function getUtf8CodePoints(_bytes: BytesLike, onError?: Utf8ErrorFunc): Array = []; + const result: Array = []; for (let i = 0; i < str.length; i++) { const c = str.charCodeAt(i); diff --git a/src.ts/wallet/base-wallet.ts b/src.ts/wallet/base-wallet.ts index 2d8c85c6..1fd7142a 100644 --- a/src.ts/wallet/base-wallet.ts +++ b/src.ts/wallet/base-wallet.ts @@ -73,6 +73,8 @@ export class BaseWallet extends AbstractSigner { return this.signingKey.privateKey; } + // TODO: `_zone` is not used, should it be removed? + // eslint-disable-next-line @typescript-eslint/no-unused-vars async getAddress(_zone?: string): Promise { return this.#address; } diff --git a/src.ts/wallet/hdwallet.ts b/src.ts/wallet/hdwallet.ts index 38c30d16..42d56ad5 100644 --- a/src.ts/wallet/hdwallet.ts +++ b/src.ts/wallet/hdwallet.ts @@ -288,7 +288,7 @@ export abstract class HDWallet extends BaseWallet implements HDNodeLike this)(...params); diff --git a/src.ts/wallet/json-crowdsale.ts b/src.ts/wallet/json-crowdsale.ts index ea25fca6..77da22ab 100644 --- a/src.ts/wallet/json-crowdsale.ts +++ b/src.ts/wallet/json-crowdsale.ts @@ -35,6 +35,7 @@ export function isCrowdsaleJson(json: string): boolean { if (data.encseed) { return true; } + // eslint-disable-next-line no-empty } catch (error) {} return false; } diff --git a/src.ts/wallet/json-keystore.ts b/src.ts/wallet/json-keystore.ts index de67a1b3..990f41e3 100644 --- a/src.ts/wallet/json-keystore.ts +++ b/src.ts/wallet/json-keystore.ts @@ -72,6 +72,7 @@ export function isKeystoreJson(json: string): boolean { if (version === 3) { return true; } + // eslint-disable-next-line no-empty } catch (error) {} return false; } @@ -154,7 +155,7 @@ type KdfParams = algorithm: 'sha256' | 'sha512'; }; -function getDecryptKdfParams(data: any): KdfParams { +function getDecryptKdfParams(data: any): KdfParams { const kdf = spelunk(data, 'crypto.kdf:string'); if (kdf && typeof kdf === 'string') { if (kdf.toLowerCase() === 'scrypt') { diff --git a/src.ts/wallet/mnemonic.ts b/src.ts/wallet/mnemonic.ts index 9034cc3f..8b16fdfd 100644 --- a/src.ts/wallet/mnemonic.ts +++ b/src.ts/wallet/mnemonic.ts @@ -42,7 +42,7 @@ function mnemonicToEntropy(mnemonic: string, wordlist?: null | Wordlist): string let offset = 0; for (let i = 0; i < words.length; i++) { - let index = wordlist.getWordIndex(words[i].normalize('NFKD')); + const index = wordlist.getWordIndex(words[i].normalize('NFKD')); assertArgument(index >= 0, `invalid mnemonic word at index ${i}`, 'mnemonic', '[ REDACTED ]'); for (let bit = 0; bit < 11; bit++) { @@ -258,6 +258,7 @@ export class Mnemonic { try { mnemonicToEntropy(phrase, wordlist); return true; + // eslint-disable-next-line no-empty } catch (error) {} return false; } diff --git a/src.ts/wallet/quai-hdwallet.ts b/src.ts/wallet/quai-hdwallet.ts index 34d3c14d..527bc253 100644 --- a/src.ts/wallet/quai-hdwallet.ts +++ b/src.ts/wallet/quai-hdwallet.ts @@ -265,7 +265,7 @@ export class QuaiHDWallet extends BaseWallet { let newDepth = this.depth + 1; let path = this.path; if (path) { - let pathFields = path.split('/'); + const pathFields = path.split('/'); if (pathFields.length == 6) { pathFields.pop(); path = pathFields.join('/'); @@ -282,7 +282,7 @@ export class QuaiHDWallet extends BaseWallet { const ki = new SigningKey(toBeHex((toBigInt(IL) + BigInt(this.privateKey)) % N, 32)); //BIP44 if we are at the account depth get that fingerprint, otherwise continue with the current one - let newFingerprint = this.depth == 3 ? this.fingerprint : this.accountFingerprint; + const newFingerprint = this.depth == 3 ? this.fingerprint : this.accountFingerprint; return new QuaiHDWallet( _guard, diff --git a/src.ts/wallet/wallet.ts b/src.ts/wallet/wallet.ts index bb80b7ca..561ef844 100644 --- a/src.ts/wallet/wallet.ts +++ b/src.ts/wallet/wallet.ts @@ -44,7 +44,7 @@ export class Wallet extends BaseWallet { key = '0x' + key; } - let signingKey = typeof key === 'string' ? new SigningKey(key) : key; + const signingKey = typeof key === 'string' ? new SigningKey(key) : key; super(signingKey, provider); } diff --git a/src.ts/wordlists/decode-owl.ts b/src.ts/wordlists/decode-owl.ts index 4e0b1798..5ba08256 100644 --- a/src.ts/wordlists/decode-owl.ts +++ b/src.ts/wordlists/decode-owl.ts @@ -32,7 +32,7 @@ export function decode(data: string, subs: string): Array { // Get all tle clumps; each suffix, first-increment and second-increment const clumps: Array = []; - const leftover = data.replace(/(:|([0-9])|([A-Z][a-z]*))/g, (all, item, semi, word) => { + const leftover = data.replace(/(:|([0-9])|([A-Z][a-z]*))/g, (item, semi) => { if (semi) { for (let i = parseInt(semi); i >= 0; i--) { clumps.push(';');