Skip to content

Commit 2ba9f41

Browse files
fix all biome errors
1 parent f76cbc0 commit 2ba9f41

34 files changed

+185
-123
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ jobs:
1111
with:
1212
ref: ${{ github.ref }}
1313

14+
- name: Enable Corepack
15+
run: corepack enable
16+
1417
- name: Set up Node.js
1518
uses: actions/setup-node@v4
1619
with:
1720
node-version: "18"
1821
cache: "yarn"
19-
22+
2023
- name: Install dependencies
2124
run: yarn install
2225

.github/workflows/lint.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,15 @@ jobs:
1111
with:
1212
ref: ${{ github.ref }}
1313

14+
- name: Enable Corepack
15+
run: corepack enable
16+
1417
- name: Set up Node.js
1518
uses: actions/setup-node@v4
1619
with:
1720
node-version: "18"
1821
cache: "yarn"
19-
22+
2023
- name: Install dependencies
2124
run: yarn install
2225

.github/workflows/npm-publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
with:
1313
ref: ${{ github.ref }}
1414

15+
- name: Enable Corepack
16+
run: corepack enable
17+
1518
- name: Set up Node.js
1619
uses: actions/setup-node@v4
1720
with:

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
"superjson": "^2.2.1",
7070
"thirdweb": "^5.71.0",
7171
"uuid": "^9.0.1",
72+
"viem": "^2.21.54",
7273
"winston": "^3.14.1",
7374
"zod": "^3.23.8"
7475
},

src/polyfill.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as crypto from "node:crypto";
22

33
if (typeof globalThis.crypto === "undefined") {
4-
(globalThis as any).crypto = crypto;
4+
// @ts-expect-error
5+
globalThis.crypto = crypto;
56
}

src/server/listeners/update-tx-listener.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const updateTxListener = async (): Promise<void> => {
6868
});
6969
});
7070

71-
connection.on("error", async (err: any) => {
71+
connection.on("error", async (err: unknown) => {
7272
logger({
7373
service: "server",
7474
level: "error",

src/server/middleware/auth.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export async function withAuth(server: FastifyInstance) {
126126
}if (error) {
127127
message = error;
128128
}
129-
} catch (err: any) {
129+
} catch (err: unknown) {
130130
logger({
131131
service: "server",
132132
level: "warn",

src/server/middleware/error.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const badChainError = (chain: string | number): CustomError =>
4242
"INVALID_CHAIN",
4343
);
4444

45-
const flipObject = (data: any) =>
45+
const flipObject = (data: object) =>
4646
Object.fromEntries(Object.entries(data).map(([key, value]) => [value, key]));
4747

4848
const isZodError = (err: unknown): boolean => {
@@ -72,15 +72,15 @@ export function withErrorHandler(server: FastifyInstance) {
7272
message: "code" in error ? error.code : error.message,
7373
reason: error.message,
7474
statusCode: 400,
75-
stack: env.NODE_ENV !== "production" ? error.stack : undefined,
75+
stack: env.NODE_ENV === "production" ? undefined : error.stack,
7676
},
7777
});
7878
}
7979

8080
// Zod Typings Errors
8181
if (isZodError(error)) {
8282
const _error = error as ZodError;
83-
let parsedMessage: any[] = [];
83+
let parsedMessage: unknown;
8484

8585
try {
8686
parsedMessage = JSON.parse(_error.message);
@@ -98,7 +98,7 @@ export function withErrorHandler(server: FastifyInstance) {
9898
message: errorObject.message ?? "Invalid Request",
9999
reason: errorObject ?? undefined,
100100
statusCode: 400,
101-
stack: env.NODE_ENV !== "production" ? _error.stack : undefined,
101+
stack: env.NODE_ENV === "production" ? undefined : _error.stack,
102102
},
103103
});
104104
}
@@ -118,7 +118,7 @@ export function withErrorHandler(server: FastifyInstance) {
118118
code,
119119
message,
120120
statusCode,
121-
stack: env.NODE_ENV !== "production" ? error.stack : undefined,
121+
stack: env.NODE_ENV === "production" ? undefined : error.stack,
122122
},
123123
});
124124
}
@@ -128,7 +128,7 @@ export function withErrorHandler(server: FastifyInstance) {
128128
statusCode: 500,
129129
code: "INTERNAL_SERVER_ERROR",
130130
message: error.message || ReasonPhrases.INTERNAL_SERVER_ERROR,
131-
stack: env.NODE_ENV !== "production" ? error.stack : undefined,
131+
stack: env.NODE_ENV === "production" ? undefined : error.stack,
132132
},
133133
});
134134
},

src/server/routes/backend-wallet/sign-transaction.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Type, type Static } from "@sinclair/typebox";
22
import type { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import type { Hex } from "thirdweb";
5+
import type { TransactionSerializable } from "viem";
56
import { getAccount } from "../../../shared/utils/account";
67
import {
78
getChecksumAddress,
@@ -71,7 +72,7 @@ export async function signTransaction(fastify: FastifyInstance) {
7172
}
7273

7374
// @TODO: Assert type to viem TransactionSerializable.
74-
const serializableTransaction: any = {
75+
const serializableTransaction = {
7576
chainId: transaction.chainId,
7677
to: getChecksumAddress(transaction.to),
7778
nonce: maybeInt(transaction.nonce),
@@ -86,7 +87,7 @@ export async function signTransaction(fastify: FastifyInstance) {
8687
maxFeePerGas: maybeBigInt(transaction.maxFeePerGas),
8788
maxPriorityFeePerGas: maybeBigInt(transaction.maxPriorityFeePerGas),
8889
ccipReadEnabled: transaction.ccipReadEnabled,
89-
};
90+
} as TransactionSerializable;
9091
const signature = await account.signTransaction(serializableTransaction);
9192

9293
reply.status(StatusCodes.OK).send({

src/server/routes/contract/extensions/erc20/read/allowance-of.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export async function erc20AllowanceOf(fastify: FastifyInstance) {
6767
chainId,
6868
contractAddress,
6969
});
70-
const returnData: any = await contract.erc20.allowanceOf(
70+
const returnData = await contract.erc20.allowanceOf(
7171
ownerWallet ? ownerWallet : "",
7272
spenderWallet ? spenderWallet : "",
7373
);

src/server/routes/contract/extensions/erc20/read/get.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ export async function erc20GetMetadata(fastify: FastifyInstance) {
5454
chainId,
5555
contractAddress,
5656
});
57-
const returnData: any = await contract.erc20.get();
57+
const returnData = await contract.erc20.get();
5858
reply.status(StatusCodes.OK).send({
5959
result: {
6060
symbol: returnData.symbol,
6161
name: returnData.name,
62-
decimals: returnData.decimals,
62+
decimals: returnData.decimals.toString(),
6363
},
6464
});
6565
},

src/server/routes/transaction/blockchain/send-signed-user-op.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Type, type Static } from "@sinclair/typebox";
22
import { Value } from "@sinclair/typebox/value";
3+
import { TransformDecodeError } from "@sinclair/typebox/value/transform";
34
import type { FastifyInstance } from "fastify";
45
import { StatusCodes } from "http-status-codes";
56
import { env } from "../../../../shared/utils/env";
@@ -47,15 +48,15 @@ const responseBodySchema = Type.Union([
4748

4849
type RpcResponse =
4950
| {
50-
result: string;
51-
error: undefined;
52-
}
51+
result: string;
52+
error: undefined;
53+
}
5354
| {
54-
result: undefined;
55-
error: {
56-
message: string;
57-
};
58-
};
55+
result: undefined;
56+
error: {
57+
message: string;
58+
};
59+
};
5960

6061
export async function sendSignedUserOp(fastify: FastifyInstance) {
6162
fastify.route<{
@@ -68,7 +69,7 @@ export async function sendSignedUserOp(fastify: FastifyInstance) {
6869
schema: {
6970
summary: "Send a signed user operation",
7071
description: "Send a signed user operation",
71-
tags: ["Transaction"],
72+
tags: [ "Transaction" ],
7273
operationId: "sendSignedUserOp",
7374
params: walletChainParamSchema,
7475
body: requestBodySchema,
@@ -86,10 +87,11 @@ export async function sendSignedUserOp(fastify: FastifyInstance) {
8687
if (typeof signedUserOp === "string") {
8788
try {
8889
userOp = Value.Decode(UserOpString, signedUserOp);
89-
} catch (err: any) {
90+
} catch (err: unknown) {
91+
const msg = err instanceof TransformDecodeError ? err.message : err;
9092
return res.status(400).send({
9193
error: {
92-
message: `Invalid signed user operation. - ${err.message || err}`,
94+
message: `Invalid signed user operation. - ${msg}`,
9395
},
9496
});
9597
}
@@ -109,12 +111,14 @@ export async function sendSignedUserOp(fastify: FastifyInstance) {
109111
id: 1,
110112
jsonrpc: "2.0",
111113
method: "eth_sendUserOperation",
112-
params: [userOp, entryPointAddress],
114+
params: [ userOp, entryPointAddress ],
113115
}),
114116
});
115117

116118
const { result: userOpHash, error } =
117-
(await userOpRes.json()) as RpcResponse;
119+
(
120+
await userOpRes.json()
121+
) as RpcResponse;
118122

119123
if (error) {
120124
return res.status(400).send({

src/server/utils/convertor.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { BigNumber } from "ethers";
22

3-
export const bigNumberReplacer = (value: any): any => {
3+
const isHexBigNumber = (value: unknown) => {
4+
const isNonNullObject = typeof value === "object" && value !== null;
5+
const hasType = isNonNullObject && "type" in value;
6+
return hasType && value.type === "BigNumber" && "hex" in value
7+
}
8+
export const bigNumberReplacer = (value: unknown): unknown => {
49
// if we find a BigNumber then make it into a string (since that is safe)
5-
if (
6-
BigNumber.isBigNumber(value) ||
7-
(typeof value === "object" &&
8-
value !== null &&
9-
value.type === "BigNumber" &&
10-
"hex" in value)
11-
) {
10+
if (BigNumber.isBigNumber(value) || isHexBigNumber(value)) {
1211
return BigNumber.from(value).toString();
1312
}
1413

src/shared/db/transactions/queue-tx.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { parseTransactionOverrides } from "../../../server/utils/transaction-ove
99

1010
interface QueueTxParams {
1111
// we should move away from Transaction type (v4 SDK)
12-
tx: Transaction<any> | DeployTransaction;
12+
tx: Transaction<unknown> | DeployTransaction;
1313
chainId: number;
1414
extension: ContractExtension;
1515
// TODO: These shouldn't be in here

src/shared/utils/ethers.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export interface EthersError extends Error {
2020
*
2121
* This is generally helpful mostly for human-based debugging.
2222
*/
23-
info?: Record<string, any>;
23+
info?: Record<string, unknown>;
2424

2525
/**
2626
* Any related error.
@@ -35,17 +35,14 @@ export const ETHERS_ERROR_CODES = new Set(Object.values(ethers.errors));
3535
* @param error
3636
* @returns EthersError | null
3737
*/
38-
export const parseEthersError = (error: any): EthersError | null => {
39-
if (
40-
error &&
41-
typeof error === "object" &&
42-
"code" in error &&
43-
ETHERS_ERROR_CODES.has(error.code)
44-
) {
38+
export const parseEthersError = (error: unknown): EthersError | null => {
39+
const isNonNullObject = error && typeof error === "object";
40+
const hasCodeProperty = isNonNullObject && "code" in error;
41+
if (hasCodeProperty && ETHERS_ERROR_CODES.has(error.code as ethers.errors)) {
4542
return error as EthersError;
4643
}
4744
return null;
4845
};
4946

50-
export const isEthersErrorCode = (error: any, code: ethers.errors) =>
47+
export const isEthersErrorCode = (error: unknown, code: ethers.errors) =>
5148
parseEthersError(error)?.code === code;

src/shared/utils/logger.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ interface LoggerParams {
8282
level: (typeof env)["LOG_LEVEL"];
8383
message: string;
8484
queueId?: string | null;
85-
error?: any;
86-
data?: any;
85+
error?: unknown;
86+
data?: unknown;
8787
}
8888

8989
export const logger = ({

src/shared/utils/transaction/simulate-queued-transaction.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { TransactionError } from "@thirdweb-dev/sdk";
12
import {
23
prepareTransaction,
34
simulateTransaction,
@@ -70,7 +71,10 @@ export const doSimulateTransaction = async (
7071
account,
7172
});
7273
return null;
73-
} catch (e: any) {
74+
} catch (e: unknown) {
75+
if (!(e instanceof TransactionError)) {
76+
throw e;
77+
}
7478
// Error should be of type TransactionError in the thirdweb SDK.
7579
return `${e.name}: ${e.message}`;
7680
}

src/shared/utils/transaction/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type InsertedTransaction = {
2323

2424
data?: Hex;
2525
functionName?: string;
26-
functionArgs?: any[];
26+
functionArgs?: unknown[];
2727

2828
// User-provided overrides.
2929
overrides?: {

src/worker/listeners/config-listener.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const newConfigurationListener = async (): Promise<void> => {
3535
});
3636
});
3737

38-
connection.on("error", async (err: any) => {
38+
connection.on("error", async (err: unknown) => {
3939
logger({
4040
service: "worker",
4141
level: "error",
@@ -93,7 +93,7 @@ export const updatedConfigurationListener = async (): Promise<void> => {
9393
});
9494
});
9595

96-
connection.on("error", async (err: any) => {
96+
connection.on("error", async (err: unknown) => {
9797
logger({
9898
service: "worker",
9999
level: "error",

src/worker/listeners/webhook-listener.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const newWebhooksListener = async (): Promise<void> => {
3838
});
3939
});
4040

41-
connection.on("error", async (err: any) => {
41+
connection.on("error", async (err: unknown) => {
4242
logger({
4343
service: "worker",
4444
level: "error",
@@ -94,7 +94,7 @@ export const updatedWebhooksListener = async (): Promise<void> => {
9494
});
9595
});
9696

97-
connection.on("error", async (err: any) => {
97+
connection.on("error", async (err: unknown) => {
9898
logger({
9999
service: "worker",
100100
level: "error",

src/worker/queues/send-webhook-queue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class SendWebhookQueue {
7171
logger({
7272
service: "worker",
7373
level: "warn",
74-
message: `Unexpected webhook type: ${(data as any).type}`,
74+
message: `Unexpected webhook type: ${(data as { type: unknown }).type}`,
7575
});
7676
}
7777
};

0 commit comments

Comments
 (0)