Skip to content

Commit

Permalink
Merge pull request #733 from bcnmy/chore/fix-eslint
Browse files Browse the repository at this point in the history
Chore/fix eslint
  • Loading branch information
TheDivic authored Oct 28, 2024
2 parents 64e9af2 + ca5a5fa commit 4f4d4e0
Show file tree
Hide file tree
Showing 109 changed files with 843 additions and 916 deletions.
1 change: 0 additions & 1 deletion .eslintignore

This file was deleted.

41 changes: 0 additions & 41 deletions .eslintrc.json

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ Other useful commands:
- `docker compose up -d`: runs the containers in the background without blocking the current terminal sessions.
- 💡 `docker compose build server`: run this whenever you add a new package to `package.json` or it won't be reflected in the container.
- `docker compose build --no-cache <service_name>`: build without cache if you suspect caching problems.

## Troubleshooting

### ESLint is not working in VS Code
- Make sure your Microsoft ESLint extension is the latest version
- In your VS Code settings make sure `ESLint: Use Flat Config` is enabled
3 changes: 2 additions & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
module.exports = { presets: ['@babel/preset-env'] };
// eslint-disable-next-line no-undef
module.exports = { presets: ["@babel/preset-env"] };
11 changes: 11 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import globals from "globals";
import pluginJs from "@eslint/js";
import tseslint from "typescript-eslint";

export default [
{ files: ["**/*.{js,mjs,cjs,ts}"] },
{ languageOptions: { globals: globals.browser } },
{ ignores: ["dist/"] },
pluginJs.configs.recommended,
...tseslint.configs.recommended,
];
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line no-undef
module.exports = {
preset: "ts-jest",
testTimeout: 600000,
Expand Down
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"scripts": {
"commit": "cz",
"changelog": "npx generate-changelog",
"lint": "eslint . --ext .ts",
"format": "eslint 'src' --ext .ts --fix",
"prepare": "husky install",
"dev": "nodemon",
"build": "tsc -p .",
Expand Down Expand Up @@ -61,6 +59,7 @@
"viem": "^2.21.28"
},
"devDependencies": {
"@eslint/js": "^9.13.0",
"@types/amqplib": "^0.8.2",
"@types/big.js": "^6.1.5",
"@types/consolidate": "^0.14.1",
Expand All @@ -72,21 +71,23 @@
"@types/morgan": "^1.9.3",
"@types/node-cron": "^3.0.4",
"@types/numeral": "^2.0.2",
"@typescript-eslint/eslint-plugin": "^5.40.0",
"@typescript-eslint/parser": "^5.40.0",
"@typescript-eslint/eslint-plugin": "^8.11.0",
"@typescript-eslint/parser": "^8.11.0",
"babel-jest": "^29.1.2",
"commitizen": "^4.3.1",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.25.0",
"eslint-config-airbnb-typescript": "^17.0.0",
"eslint": "^9.13.0",
"eslint-config-eslint": "^11.0.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-prettier": "^5.1.0",
"eslint-plugin-import": "^2.31.0",
"eslint-plugin-prettier": "^5.2.1",
"globals": "^15.11.0",
"jest": "^29.1.2",
"nodemon": "^3.0.1",
"prettier": "^3.1.1",
"prettier": "^3.3.3",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1"
"ts-node": "^10.9.1",
"typescript-eslint": "^8.11.0"
},
"config": {
"commitizen": {
Expand Down
3 changes: 1 addition & 2 deletions src/admin-cli/cancel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-console */
import { Command } from "commander";
import { config } from "dotenv";
import { privateKeyToAccount } from "viem/accounts";
Expand Down Expand Up @@ -86,7 +85,7 @@ async function main() {
const jsonBody = JSON.parse(responseBody);
console.log("Parsed JSON response:");
console.log(JSON.stringify(jsonBody, null, 2));
} catch (error) {
} catch {
// If parsing fails, it's not JSON, so we've already logged it as text
console.log("Response is not JSON");
}
Expand Down
27 changes: 27 additions & 0 deletions src/admin-scripts/getRequiredPrefund.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

function getRequiredPrefund(userOp: {
paymasterAndData: string;
callGasLimit: bigint;
verificationGasLimit: bigint;
preVerificationGas: bigint;
maxFeePerGas: bigint;
}) {
const multiplier = userOp.paymasterAndData !== "0x" ? 3n : 1n;

const requiredGas =
userOp.callGasLimit +
userOp.verificationGasLimit * multiplier +
userOp.preVerificationGas;

return requiredGas * userOp.maxFeePerGas;
}

const prefund = getRequiredPrefund({
paymasterAndData: "0x",
callGasLimit: 651983n,
verificationGasLimit: 1459741n,
preVerificationGas: 313507n,
maxFeePerGas: 15796905452n,
});

console.log(`Required prefund: ${prefund} wei`);
3 changes: 1 addition & 2 deletions src/common/cache/redis/RedisCacheService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-import-module-exports */
import Redlock, { Lock } from "redlock";
import Redis from "ioredis";
import nodeconfig from "config";
Expand Down Expand Up @@ -123,7 +122,7 @@ export class RedisCacheService implements ICacheService {
log.error(error);
}
});
this.redisClient.on("error", (err: any) => {
this.redisClient.on("error", (err: unknown) => {
log.error(`Redis redisClient Error ${err}`);
});
}
Expand Down
1 change: 1 addition & 0 deletions src/common/db/dao/TransactionDAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class TransactionDAO implements ITransactionDAO {
async updateMetaDataAndRelayerDestinationContractDataByTransactionId(
chainId: number,
id: string,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
metaData: any,
relayerDestinationContractAddress: string,
relayerDestinationContractName: string,
Expand Down
1 change: 1 addition & 0 deletions src/common/db/interface/IUserOperationDAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type FinalUserOperationDataType = {
actualGasCost: number;
actualGasUsed: number;
reason: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
logs: any;
};

Expand Down
1 change: 1 addition & 0 deletions src/common/db/interface/IUserOperationV07DAO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type FinalUserOperationV07DataType = {
actualGasCost: number;
actualGasUsed: number;
reason: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
logs: any;
};

Expand Down
4 changes: 1 addition & 3 deletions src/common/db/mongo/Mongo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable import/no-import-module-exports */
/* eslint-disable @typescript-eslint/no-explicit-any */
import mongoose, { Mongoose } from "mongoose";
import { config } from "../../../config";
import { logger } from "../../logger";
Expand Down Expand Up @@ -69,7 +68,6 @@ export class Mongo implements IDBService {
}
}

// eslint-disable-next-line class-methods-use-this
async createIndexes(
collectionObject: any,
compoundIndexOne: object,
Expand Down
1 change: 1 addition & 0 deletions src/common/db/mongo/interface/IBlockchainTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface IBlockchainTransaction {
relayerDestinationContractName: string;
relayerAddress: string;
walletAddress: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
metaData: any;
resubmitted: boolean;
creationTime: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-empty-object-type */
import mongoose from "mongoose";
import { config } from "../../../../../config";
import { IBlockchainTransaction } from "../../interface/IBlockchainTransaction";
Expand Down
1 change: 1 addition & 0 deletions src/common/db/mongo/models/user-operations-state/model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-empty-object-type */
import mongoose from "mongoose";
import { config } from "../../../../../config";
import { IUserOperationState } from "../../interface";
Expand Down
1 change: 1 addition & 0 deletions src/common/db/mongo/models/user-operations/model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-empty-object-type */
import mongoose from "mongoose";
import { config } from "../../../../../config";
import { IUserOperation, IUserOperationV07 } from "../../interface";
Expand Down
6 changes: 3 additions & 3 deletions src/common/entrypoint-v7/PackedUserOperation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export interface PackedUserOperation {
// * @returns A Hex string that represents the packed integers.
// */
export function packUint(high128: bigint, low128: bigint): Hex {
// eslint-disable-next-line no-bitwise
const packed = (BigInt(high128) << BigInt(128)) + BigInt(low128);
return pad(toHex(packed), { size: 32 });
}
Expand All @@ -55,9 +55,9 @@ export function packUint(high128: bigint, low128: bigint): Hex {
// */
export function unpackUint(packed: Hex): [high128: bigint, low128: bigint] {
const packedNumber = BigInt(fromHex(packed, "bigint"));
// eslint-disable-next-line no-bitwise
const high128 = packedNumber >> BigInt(128);
// eslint-disable-next-line no-bitwise
const low128 = packedNumber & ((BigInt(1) << BigInt(128)) - BigInt(1));
return [high128, low128];
}
Expand Down
2 changes: 0 additions & 2 deletions src/common/gas-price/GasPrice.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable prefer-const */
/* eslint-disable import/no-import-module-exports */
import { formatUnits, toHex } from "viem";
import { IEVMAccount } from "../../relayer/account";
import { ICacheService } from "../cache";
Expand Down
1 change: 0 additions & 1 deletion src/common/gas-price/jobs/CacheFees.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-import-module-exports */
import { CronJob } from "cron";
import { GasPriceService } from "../GasPrice";
import { logger } from "../../logger";
Expand Down
6 changes: 0 additions & 6 deletions src/common/interface/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,3 @@ export interface IQueue<TransactionMessageType> {
consume(onMessageReceived: () => void): Promise<boolean>;
ack(arg0: ConsumeMessage): Promise<void>;
}

export interface IRetryPolicy {
maxTries: number;
shouldRetry: (err: any) => Promise<boolean>;
incrementTry: () => void;
}
9 changes: 3 additions & 6 deletions src/common/network/EVMNetworkService.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable no-async-promise-executor */
/* eslint-disable import/no-import-module-exports */
/* eslint-disable @typescript-eslint/return-await */
/* eslint-disable new-cap */
// eslint-disable-next-line max-classes-per-file

import axios from "axios";
import {
Hex,
Expand Down Expand Up @@ -215,7 +213,6 @@ export class EVMNetworkService
return await this.sendRpcCall(EthMethodType.GET_TRANSACTION_COUNT, params);
}

// eslint-disable-next-line class-methods-use-this
async sendTransaction(
rawTransactionData: EVMRawTransactionType,
account: IEVMAccount,
Expand Down Expand Up @@ -333,6 +330,7 @@ export class EVMNetworkService
return await this.provider.getTransaction({
hash: transactionHash as `0x${string}`,
});
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
return null;
}
Expand All @@ -349,7 +347,6 @@ export class EVMNetworkService
return await this.sendRpcCall(AlchemyMethodType.SIMULATE_EXECUTION, params);
}

// eslint-disable-next-line class-methods-use-this
async verifySignature(
address: string,
message: string,
Expand Down
1 change: 1 addition & 0 deletions src/common/network/interface/INetworkService.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { PublicClient, Transaction, TransactionReceipt } from "viem";
import {
Type0TransactionGasPriceType,
Expand Down
1 change: 1 addition & 0 deletions src/common/notification/NotificationUtil.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { IEVMAccount } from "../../relayer/account";
import { TransactionType } from "../types";
import { parseError } from "../utils";
Expand Down
1 change: 0 additions & 1 deletion src/common/notification/slack/SlackNotificationService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-import-module-exports */
import { WebClient } from "@slack/web-api";
import { logger } from "../../logger";
import { ISlackNotificationService } from "../interface";
Expand Down
1 change: 0 additions & 1 deletion src/common/queue/BundlerTransactionQueue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-import-module-exports */
import amqp, { Channel, ConsumeMessage, Replies } from "amqplib";
import { config } from "../../config";
import { logger } from "../logger";
Expand Down
1 change: 0 additions & 1 deletion src/common/queue/RetryTransactionHandlerQueue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-import-module-exports */
import amqp, { Channel, ConsumeMessage, Replies } from "amqplib";
import { config } from "../../config";
import { logger } from "../logger";
Expand Down
1 change: 1 addition & 0 deletions src/common/queue/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type RetryTransactionQueueData = {
transactionId: string;
rawTransaction: EVMRawTransactionType;
walletAddress: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
metaData: any;
relayerManagerName: string;
};
1 change: 0 additions & 1 deletion src/common/relay-service/BundlerRelayService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable import/no-import-module-exports */
import { STATUSES } from "../../server/api/shared/middleware";
import { IQueue } from "../interface";
import { logger } from "../logger";
Expand Down
5 changes: 0 additions & 5 deletions src/common/service-manager/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* eslint-disable import/no-import-module-exports */
/* eslint-disable no-await-in-loop */
import { getContract, parseEther } from "viem";
import { chain } from "lodash";
import { ENTRY_POINT_ABI } from "entry-point-gas-estimations/dist/gas-estimator/entry-point-v6";
Expand Down Expand Up @@ -99,7 +97,6 @@ const retryTransactionQueueMap: {
} = {};
const networkServiceMap: Record<number, EVMNetworkService> = {};

// eslint-disable-next-line import/no-mutable-exports
let statusService: IStatusService;

(async () => {
Expand Down Expand Up @@ -305,7 +302,6 @@ let statusService: IStatusService;
);
log.info(`Retry transaction service setup for chainId: ${chainId}`);

// eslint-disable-next-line max-len
bundlerSimulationServiceMap[chainId] = new BundlerSimulationService(
networkService,
gasPriceService,
Expand Down Expand Up @@ -407,7 +403,6 @@ let statusService: IStatusService;
}
}

// eslint-disable-next-line no-new
statusService = new StatusService({
cacheService,
networkServiceMap,
Expand Down
Loading

0 comments on commit 4f4d4e0

Please sign in to comment.