Skip to content
  •  
  •  
  •  
18 changes: 0 additions & 18 deletions .eslintrc.json

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,6 @@ https
# Auto generated OpenAPI file
openapi.json
.aider*

# jetbrains
.idea
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
"start:run": "node --experimental-specifier-resolution=node ./dist/index.js",
"start:docker": "docker compose --profile engine --env-file ./.env up --remove-orphans",
"start:docker-force-build": "docker compose --profile engine --env-file ./.env up --remove-orphans --build",
"lint:fix": "eslint --fix 'src/**/*.ts'",
"biome:format": "yarn biome format",
"biome:format:fix": "yarn biome format --write",
"biome:lint": "yarn biome lint",
"biome:lint:fix": "yarn biome lint --write",
"biome:check": "yarn biome check",
"biome:check:fix": "yarn biome check --write",
"test:unit": "vitest",
"test:coverage": "vitest run --coverage",
"copy-files": "cp -r ./src/prisma ./dist/"
Expand Down Expand Up @@ -84,11 +89,7 @@
"@types/pg": "^8.6.6",
"@types/uuid": "^9.0.1",
"@types/ws": "^8.5.5",
"@typescript-eslint/eslint-plugin": "^5.55.0",
"@typescript-eslint/parser": "^5.55.0",
"@vitest/coverage-v8": "^2.0.3",
"eslint": "^9.3.0",
"eslint-config-prettier": "^8.7.0",
"openapi-typescript-codegen": "^0.25.0",
"prettier": "^2.8.7",
"typescript": "^5.1.3",
Expand All @@ -113,5 +114,6 @@
"micromatch": ">=4.0.8",
"secp256k1": ">=4.0.4",
"ws": ">=8.17.1"
}
},
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
}
6 changes: 3 additions & 3 deletions src/db/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { PrismaClient } from "@prisma/client";
import pg, { Knex } from "knex";
import { PrismaTransaction } from "../schema/prisma";
import pg, { type Knex } from "knex";
import type { PrismaTransaction } from "../schema/prisma";
import { env } from "../utils/env";

export const prisma = new PrismaClient({
Expand All @@ -26,7 +26,7 @@ export const isDatabaseReachable = async () => {
try {
await prisma.walletDetails.findFirst();
return true;
} catch (error) {
} catch {
return false;
}
};
4 changes: 2 additions & 2 deletions src/db/contractEventLogs/createContractEventLogs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContractEventLogs, Prisma } from "@prisma/client";
import { PrismaTransaction } from "../../schema/prisma";
import type { ContractEventLogs, Prisma } from "@prisma/client";
import type { PrismaTransaction } from "../../schema/prisma";
import { getPrismaWithPostgresTx } from "../client";

export interface BulkInsertContractLogsParams {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ContractTransactionReceipts, Prisma } from "@prisma/client";
import { PrismaTransaction } from "../../schema/prisma";
import type { ContractTransactionReceipts, Prisma } from "@prisma/client";
import type { PrismaTransaction } from "../../schema/prisma";
import { getPrismaWithPostgresTx } from "../client";

export interface BulkInsertContractLogsParams {
Expand Down
2 changes: 1 addition & 1 deletion src/db/keypair/delete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Keypairs } from "@prisma/client";
import type { Keypairs } from "@prisma/client";
import { prisma } from "../client";

export const deleteKeypair = async ({
Expand Down
2 changes: 1 addition & 1 deletion src/db/keypair/get.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Keypairs } from "@prisma/client";
import { createHash } from "crypto";
import type { Keypairs } from "@prisma/client";
import { prisma } from "../client";

export const getKeypairByHash = async (
Expand Down
4 changes: 2 additions & 2 deletions src/db/keypair/insert.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Keypairs } from "@prisma/client";
import { createHash } from "crypto";
import { KeypairAlgorithm } from "../../server/schemas/keypairs";
import type { Keypairs } from "@prisma/client";
import type { KeypairAlgorithm } from "../../server/schemas/keypairs";
import { prisma } from "../client";

export const insertKeypair = async ({
Expand Down
2 changes: 1 addition & 1 deletion src/db/keypair/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Keypairs } from "@prisma/client";
import type { Keypairs } from "@prisma/client";
import { prisma } from "../client";

export const listKeypairs = async (): Promise<Keypairs[]> => {
Expand Down
2 changes: 1 addition & 1 deletion src/db/relayer/getRelayerById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const getRelayerById = async ({ id }: GetRelayerByIdParams) => {

return {
...relayer,
chainId: parseInt(relayer.chainId),
chainId: Number.parseInt(relayer.chainId),
allowedContracts: relayer.allowedContracts
? (JSON.parse(relayer.allowedContracts).map((contractAddress: string) =>
contractAddress.toLowerCase(),
Expand Down
2 changes: 1 addition & 1 deletion src/db/transactions/queueTx.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DeployTransaction, Transaction } from "@thirdweb-dev/sdk";
import type { ERC4337EthersSigner } from "@thirdweb-dev/wallets/dist/declarations/src/evm/connectors/smart-wallet/lib/erc4337-signer";
import { ZERO_ADDRESS, type Address } from "thirdweb";
import { type Address, ZERO_ADDRESS } from "thirdweb";
import type { ContractExtension } from "../../schema/extension";
import { parseTransactionOverrides } from "../../server/utils/transactionOverrides";
import { maybeBigInt, normalizeAddress } from "../../utils/primitiveTypes";
Expand Down
2 changes: 1 addition & 1 deletion src/db/wallets/deleteWalletDetails.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address } from "thirdweb";
import type { Address } from "thirdweb";
import { prisma } from "../client";

export const deleteWalletDetails = async (walletAddress: Address) => {
Expand Down
2 changes: 1 addition & 1 deletion src/db/wallets/getAllWallets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PrismaTransaction } from "../../schema/prisma";
import type { PrismaTransaction } from "../../schema/prisma";
import { getPrismaWithPostgresTx } from "../client";

interface GetAllWalletsParams {
Expand Down
6 changes: 3 additions & 3 deletions src/db/wallets/nonceMap.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Address } from "thirdweb";
import type { Address } from "thirdweb";
import { env } from "../../utils/env";
import { normalizeAddress } from "../../utils/primitiveTypes";
import { redis } from "../../utils/redis/redis";
Expand Down Expand Up @@ -53,7 +53,7 @@ export const getNonceMap = async (args: {
for (let i = 0; i < elementsWithScores.length; i += 2) {
result.push({
queueId: elementsWithScores[i],
nonce: parseInt(elementsWithScores[i + 1]),
nonce: Number.parseInt(elementsWithScores[i + 1]),
});
}
return result;
Expand All @@ -73,7 +73,7 @@ export const pruneNonceMaps = async () => {
let numDeleted = 0;
for (const [error, result] of results) {
if (!error) {
numDeleted += parseInt(result as string);
numDeleted += Number.parseInt(result as string);
}
}
return numDeleted;
Expand Down
2 changes: 1 addition & 1 deletion src/db/wallets/walletNonce.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
type Address,
eth_getTransactionCount,
getAddress,
getRpcClient,
type Address,
} from "thirdweb";
import { getChain } from "../../utils/chain";
import { logger } from "../../utils/logger";
Expand Down
4 changes: 2 additions & 2 deletions src/db/webhooks/createWebhook.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Webhooks } from "@prisma/client";
import { createHash, randomBytes } from "crypto";
import { WebhooksEventTypes } from "../../schema/webhooks";
import type { Webhooks } from "@prisma/client";
import type { WebhooksEventTypes } from "../../schema/webhooks";
import { prisma } from "../client";

interface CreateWebhooksParams {
Expand Down
2 changes: 1 addition & 1 deletion src/db/webhooks/getAllWebhooks.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Webhooks } from "@prisma/client";
import type { Webhooks } from "@prisma/client";
import { prisma } from "../client";

export const getAllWebhooks = async (): Promise<Webhooks[]> => {
Expand Down
1 change: 1 addition & 0 deletions src/lib/chain/chain-capabilities.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createSWRCache } from "../cache/swr";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const Services = [
"contracts",
"connect-sdk",
Expand Down
2 changes: 1 addition & 1 deletion src/schema/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Prisma, PrismaClient } from "@prisma/client";
import { DefaultArgs } from "@prisma/client/runtime/library";
import type { DefaultArgs } from "@prisma/client/runtime/library";

export type PrismaTransaction = Omit<
PrismaClient<Prisma.PrismaClientOptions, never, DefaultArgs>,
Expand Down
10 changes: 5 additions & 5 deletions src/scripts/generate-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function applyOperationIdMappings(
let newCode: string = originalCode;

for (const [newId, oldId] of Object.entries(mappings)) {
const regex: RegExp = new RegExp(`public\\s+${newId}\\(`, "g");
const regex = new RegExp(`public\\s+${newId}\\(`, "g");
const methods = newCode.match(regex);

if (methods) {
Expand Down Expand Up @@ -79,7 +79,7 @@ function processErcServices(
const replacementLog: string[] = [];
let newCode: string = originalCode;

const regex: RegExp = new RegExp(`public\\s+${tag}(\\w+)\\(`, "g");
const regex = new RegExp(`public\\s+${tag}(\\w+)\\(`, "g");
const methods = newCode.match(regex);

if (methods) {
Expand Down Expand Up @@ -127,7 +127,7 @@ async function main(): Promise<void> {
.readFileSync("./sdk/src/Engine.ts", "utf-8")
.replace("export class Engine", "class EngineLogic");

const newEngineCode: string = `${engineCode}
const newEngineCode = `${engineCode}
export class Engine extends EngineLogic {
constructor(config: { url: string; accessToken: string; }) {
super({ BASE: config.url, TOKEN: config.accessToken });
Expand All @@ -136,7 +136,7 @@ export class Engine extends EngineLogic {
`;
fs.writeFileSync("./sdk/src/Engine.ts", newEngineCode);

const servicesDir: string = "./sdk/src/services";
const servicesDir = "./sdk/src/services";
const serviceFiles: string[] = fs.readdirSync(servicesDir);

const ercServices: string[] = ["erc20", "erc721", "erc1155"];
Expand Down Expand Up @@ -176,4 +176,4 @@ export class Engine extends EngineLogic {
}
}

main();
main().then();
4 changes: 2 additions & 2 deletions src/server/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { TypeBoxTypeProvider } from "@fastify/type-provider-typebox";
import fastify, { type FastifyInstance } from "fastify";
import * as fs from "node:fs";
import path from "node:path";
import { URL } from "node:url";
import type { TypeBoxTypeProvider } from "@fastify/type-provider-typebox";
import fastify, { type FastifyInstance } from "fastify";
import { clearCacheCron } from "../utils/cron/clearCacheCron";
import { env } from "../utils/env";
import { logger } from "../utils/logger";
Expand Down
6 changes: 4 additions & 2 deletions src/server/listeners/updateTxListener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const updateTxListener = async (): Promise<void> => {
(sub) => sub.requestId === parsedPayload.id,
);

if (index == -1) {
if (index === -1) {
return;
}

Expand All @@ -47,7 +47,9 @@ export const updateTxListener = async (): Promise<void> => {
userSubscription.socket.send(
await formatSocketMessage(returnData, message),
);
closeConnection ? userSubscription.socket.close() : null;
if (closeConnection) {
userSubscription.socket.close();
}
},
);

Expand Down
6 changes: 4 additions & 2 deletions src/server/middleware/adminRoutes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { timingSafeEqual } from "crypto";
import { createBullBoard } from "@bull-board/api";
import { BullMQAdapter } from "@bull-board/api/bullMQAdapter";
import { FastifyAdapter } from "@bull-board/fastify";
import fastifyBasicAuth from "@fastify/basic-auth";
import type { Queue } from "bullmq";
import { timingSafeEqual } from "crypto";
import type { FastifyInstance } from "fastify";
import { StatusCodes } from "http-status-codes";
import { env } from "../../utils/env";
Expand Down Expand Up @@ -85,7 +85,9 @@ const assertAdminBasicAuth = (username: string, password: string) => {
const buf1 = Buffer.from(password.padEnd(100));
const buf2 = Buffer.from(ADMIN_ROUTES_PASSWORD.padEnd(100));
return timingSafeEqual(buf1, buf2);
} catch (e) {}
} catch {
/* empty */
}
}
return false;
};
6 changes: 3 additions & 3 deletions src/server/middleware/auth.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createHash } from "crypto";
import { parseJWT } from "@thirdweb-dev/auth";
import {
ThirdwebAuth,
getToken as getJWT,
type ThirdwebAuthUser,
getToken as getJWT,
} from "@thirdweb-dev/auth/fastify";
import { AsyncWallet } from "@thirdweb-dev/wallets/evm/wallets/async";
import { createHash } from "crypto";
import type { FastifyInstance } from "fastify";
import type { FastifyRequest } from "fastify/types/request";
import jsonwebtoken, { type JwtPayload } from "jsonwebtoken";
Expand Down Expand Up @@ -383,7 +383,7 @@ const handleAccessToken = async (

try {
token = await getAccessToken({ jwt });
} catch (e) {
} catch {
// Missing or invalid signature. This will occur if the JWT not intended for this auth pattern.
return { isAuthed: false };
}
Expand Down
5 changes: 3 additions & 2 deletions src/server/middleware/cors/cors.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
FastifyInstance,
FastifyReply,
FastifyRequest,
Expand All @@ -16,7 +16,7 @@ declare module "fastify" {
}
}

interface ArrayOfValueOrArray<T> extends Array<ValueOrArray<T>> {}
type ArrayOfValueOrArray<T> = Array<ValueOrArray<T>>;

type OriginCallback = (
err: Error | null,
Expand Down Expand Up @@ -155,6 +155,7 @@ export const fastifyCors = async (

let hideOptionsRoute = true;
if (opts.hideOptionsRoute !== undefined) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
hideOptionsRoute = opts.hideOptionsRoute;
}
const corsOptions = normalizeCorsOptions(opts);
Expand Down
2 changes: 1 addition & 1 deletion src/server/middleware/cors/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FastifyInstance } from "fastify";
import type { FastifyInstance } from "fastify";
import { fastifyCors } from "./cors";

export const withCors = async (server: FastifyInstance) => {
Expand Down
2 changes: 1 addition & 1 deletion src/server/middleware/cors/vary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function createAddFieldnameToVary(fieldname: string) {

validateFieldname(fieldname);

return function (reply: FastifyReply) {
return (reply: FastifyReply) => {
let header = reply.getHeader("Vary") as any;

if (!header) {
Expand Down
2 changes: 1 addition & 1 deletion src/server/middleware/engineMode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FastifyInstance } from "fastify";
import type { FastifyInstance } from "fastify";
import { env } from "../../utils/env";

export const withEnforceEngineMode = async (server: FastifyInstance) => {
Expand Down
2 changes: 1 addition & 1 deletion src/server/middleware/prometheus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
import type { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
import { env } from "../../utils/env";
import { recordMetrics } from "../../utils/prometheus";

Expand Down
2 changes: 1 addition & 1 deletion src/server/middleware/rateLimit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { OPENAPI_ROUTES } from "./open-api";
const SKIP_RATELIMIT_PATHS = ["/", ...OPENAPI_ROUTES];

export const withRateLimit = async (server: FastifyInstance) => {
server.addHook("onRequest", async (request, reply) => {
server.addHook("onRequest", async (request, _reply) => {
if (SKIP_RATELIMIT_PATHS.includes(request.url)) {
return;
}
Expand Down
Loading