Skip to content

Commit dc26318

Browse files
dirtycajunricearcoraven
authored andcommitted
fix all biome errors (#815)
* bump yarn to berry * fix all biome errors * bring back pinned resolved deps, fix whitepsace --------- Co-authored-by: Phillip Ho <arcoraven@gmail.com>
1 parent d8fc016 commit dc26318

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2028
-2863
lines changed

.github/workflows/build-image-tag.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
matrix:
1515
include:
1616
- platform: linux/amd64
17-
runner: ubuntu-latest
17+
runner: ubuntu-24.04
1818
arch: amd64
1919
- platform: linux/arm64
2020
runner: ubuntu-24.04-arm64
@@ -53,7 +53,7 @@ jobs:
5353

5454
merge-manifests:
5555
needs: build
56-
runs-on: ubuntu-latest
56+
runs-on: ubuntu-24.04
5757
env:
5858
LATEST_TAG: ${{ github.event.release.target_commitish == 'main' && 'thirdweb/engine:latest' || '' }}
5959
steps:

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: pull_request
44

55
jobs:
66
build:
7-
runs-on: ubuntu-latest
7+
runs-on: ubuntu-24.04
88
steps:
99
- name: Checkout code
1010
uses: actions/checkout@v4
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
node-version: "18"
1818
cache: "yarn"
19-
19+
2020
- name: Install dependencies
2121
run: yarn install
2222

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on: pull_request
44

55
jobs:
66
lint:
7-
runs-on: ubuntu-latest
7+
runs-on: ubuntu-24.04
88
steps:
99
- name: Checkout code
1010
uses: actions/checkout@v4
@@ -16,7 +16,7 @@ jobs:
1616
with:
1717
node-version: "18"
1818
cache: "yarn"
19-
19+
2020
- name: Install dependencies
2121
run: yarn install
2222

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
matrix:
1616
include:
1717
- platform: linux/amd64
18-
runner: ubuntu-latest
18+
runner: ubuntu-24.04
1919
arch: amd64
2020
- platform: linux/arm64
2121
runner: ubuntu-24.04-arm64
@@ -48,7 +48,7 @@ jobs:
4848

4949
merge-manifests:
5050
needs: build
51-
runs-on: ubuntu-latest
51+
runs-on: ubuntu-24.04
5252
steps:
5353
- name: Set up Docker Buildx
5454
uses: docker/setup-buildx-action@v3

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55

66
jobs:
77
build:
8-
runs-on: ubuntu-latest
8+
runs-on: ubuntu-24.04
99
steps:
1010
- name: Checkout code
1111
uses: actions/checkout@v4

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313
stale:
1414

15-
runs-on: ubuntu-latest
15+
runs-on: ubuntu-24.04
1616
permissions:
1717
issues: write
1818
pull-requests: write

.yarnrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
--ignore-engines true
1+
--ignore-engines true

package.json

Lines changed: 1 addition & 2 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
},
@@ -94,8 +95,6 @@
9495
"resolutions": {
9596
"@thirdweb-dev/auth/**/axios": ">=1.7.8",
9697
"@thirdweb-dev/auth/**/web3-utils": ">=4.2.1",
97-
"ethers-gcp-kms-signer/**/protobufjs": ">=7.2.5",
98-
"fastify/**/find-my-way": ">=8.2.2",
9998
"@grpc/grpc-js": ">=1.8.22",
10099
"body-parser": ">=1.20.3",
101100
"cookie": ">=0.7.0",

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 & 3 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,
@@ -70,8 +71,7 @@ export async function signTransaction(fastify: FastifyInstance) {
7071
);
7172
}
7273

73-
// @TODO: Assert type to viem TransactionSerializable.
74-
const serializableTransaction: any = {
74+
const serializableTransaction = {
7575
chainId: transaction.chainId,
7676
to: getChecksumAddress(transaction.to),
7777
nonce: maybeInt(transaction.nonce),
@@ -86,7 +86,7 @@ export async function signTransaction(fastify: FastifyInstance) {
8686
maxFeePerGas: maybeBigInt(transaction.maxFeePerGas),
8787
maxPriorityFeePerGas: maybeBigInt(transaction.maxPriorityFeePerGas),
8888
ccipReadEnabled: transaction.ccipReadEnabled,
89-
};
89+
} as TransactionSerializable;
9090
const signature = await account.signTransaction(serializableTransaction);
9191

9292
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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { TransactionHashSchema } from "../../../schemas/address";
88
import { standardResponseSchema } from "../../../schemas/shared-api-schemas";
99
import { walletChainParamSchema } from "../../../schemas/wallet";
1010
import { getChainIdFromChain } from "../../../utils/chain";
11+
import { prettifyError } from "../../../../shared/utils/error";
1112

1213
const UserOp = Type.Object({
1314
sender: Type.String(),
@@ -86,10 +87,10 @@ 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) {
9091
return res.status(400).send({
9192
error: {
92-
message: `Invalid signed user operation. - ${err.message || err}`,
93+
message: `Invalid signed user operation. - ${prettifyError(err)}`,
9394
},
9495
});
9596
}

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/server/utils/wallets/get-aws-kms-account.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,5 @@ export async function getAwsKmsAccount(
117117
signMessage,
118118
signTypedData,
119119
signTransaction,
120-
} satisfies Account;
120+
} as AwsKmsAccount satisfies Account;
121121
}

src/server/utils/wallets/get-gcp-kms-account.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,5 @@ export async function getGcpKmsAccount(
133133
signMessage,
134134
signTypedData,
135135
signTransaction,
136-
} satisfies Account;
136+
} as GcpKmsAccount satisfies Account;
137137
}

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/lib/cache/swr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export class SWRCache<K, V> {
7575
private set(key: K, data: V): void {
7676
if (this.cache.size >= this.options.maxEntries) {
7777
const firstKey = this.cache.keys().next().value;
78-
this.cache.delete(firstKey);
78+
this.cache.delete(firstKey as K);
7979
}
8080

8181
this.cache.set(key, {

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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const winstonLogger = createLogger({
5959
colorizeFormat(),
6060
format.printf(({ level, message, timestamp, error }) => {
6161
if (error) {
62-
return `[${timestamp}] ${level}: ${message} - ${error.stack}`;
62+
return `[${timestamp}] ${level}: ${message} - ${(error as Error).stack}`;
6363
}
6464
return `[${timestamp}] ${level}: ${message}`;
6565
}),
@@ -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?: {

0 commit comments

Comments
 (0)