Skip to content

fix all biome errors #815

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build-image-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the implication of this one. cc @d4mr

runner: ubuntu-24.04
arch: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm64
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:

merge-manifests:
needs: build
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
env:
LATEST_TAG: ${{ github.event.release.target_commitish == 'main' && 'thirdweb/engine:latest' || '' }}
steps:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: pull_request

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -16,7 +16,7 @@ jobs:
with:
node-version: "18"
cache: "yarn"

- name: Install dependencies
run: yarn install

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: pull_request

jobs:
lint:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -16,7 +16,7 @@ jobs:
with:
node-version: "18"
cache: "yarn"

- name: Install dependencies
run: yarn install

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
runner: ubuntu-24.04
arch: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm64
Expand Down Expand Up @@ -48,7 +48,7 @@ jobs:

merge-manifests:
needs: build
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ on:
jobs:
stale:

runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
issues: write
pull-requests: write
Expand Down
2 changes: 1 addition & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
--ignore-engines true
--ignore-engines true
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"superjson": "^2.2.1",
"thirdweb": "^5.71.0",
"uuid": "^9.0.1",
"viem": "^2.21.54",
"winston": "^3.14.1",
"zod": "^3.23.8"
},
Expand All @@ -94,8 +95,6 @@
"resolutions": {
"@thirdweb-dev/auth/**/axios": ">=1.7.8",
"@thirdweb-dev/auth/**/web3-utils": ">=4.2.1",
"ethers-gcp-kms-signer/**/protobufjs": ">=7.2.5",
"fastify/**/find-my-way": ">=8.2.2",
"@grpc/grpc-js": ">=1.8.22",
"body-parser": ">=1.20.3",
"cookie": ">=0.7.0",
Expand Down
3 changes: 2 additions & 1 deletion src/polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as crypto from "node:crypto";

if (typeof globalThis.crypto === "undefined") {
(globalThis as any).crypto = crypto;
// @ts-expect-error
globalThis.crypto = crypto;
}
2 changes: 1 addition & 1 deletion src/server/listeners/update-tx-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const updateTxListener = async (): Promise<void> => {
});
});

connection.on("error", async (err: any) => {
connection.on("error", async (err: unknown) => {
logger({
service: "server",
level: "error",
Expand Down
2 changes: 1 addition & 1 deletion src/server/middleware/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export async function withAuth(server: FastifyInstance) {
}if (error) {
message = error;
}
} catch (err: any) {
} catch (err: unknown) {
logger({
service: "server",
level: "warn",
Expand Down
12 changes: 6 additions & 6 deletions src/server/middleware/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const badChainError = (chain: string | number): CustomError =>
"INVALID_CHAIN",
);

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

const isZodError = (err: unknown): boolean => {
Expand Down Expand Up @@ -72,15 +72,15 @@ export function withErrorHandler(server: FastifyInstance) {
message: "code" in error ? error.code : error.message,
reason: error.message,
statusCode: 400,
stack: env.NODE_ENV !== "production" ? error.stack : undefined,
stack: env.NODE_ENV === "production" ? undefined : error.stack,
},
});
}

// Zod Typings Errors
if (isZodError(error)) {
const _error = error as ZodError;
let parsedMessage: any[] = [];
let parsedMessage: unknown;

try {
parsedMessage = JSON.parse(_error.message);
Expand All @@ -98,7 +98,7 @@ export function withErrorHandler(server: FastifyInstance) {
message: errorObject.message ?? "Invalid Request",
reason: errorObject ?? undefined,
statusCode: 400,
stack: env.NODE_ENV !== "production" ? _error.stack : undefined,
stack: env.NODE_ENV === "production" ? undefined : _error.stack,
},
});
}
Expand All @@ -118,7 +118,7 @@ export function withErrorHandler(server: FastifyInstance) {
code,
message,
statusCode,
stack: env.NODE_ENV !== "production" ? error.stack : undefined,
stack: env.NODE_ENV === "production" ? undefined : error.stack,
},
});
}
Expand All @@ -128,7 +128,7 @@ export function withErrorHandler(server: FastifyInstance) {
statusCode: 500,
code: "INTERNAL_SERVER_ERROR",
message: error.message || ReasonPhrases.INTERNAL_SERVER_ERROR,
stack: env.NODE_ENV !== "production" ? error.stack : undefined,
stack: env.NODE_ENV === "production" ? undefined : error.stack,
},
});
},
Expand Down
6 changes: 3 additions & 3 deletions src/server/routes/backend-wallet/sign-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Type, type Static } from "@sinclair/typebox";
import type { FastifyInstance } from "fastify";
import { StatusCodes } from "http-status-codes";
import type { Hex } from "thirdweb";
import type { TransactionSerializable } from "viem";
import { getAccount } from "../../../shared/utils/account";
import {
getChecksumAddress,
Expand Down Expand Up @@ -70,8 +71,7 @@ export async function signTransaction(fastify: FastifyInstance) {
);
}

// @TODO: Assert type to viem TransactionSerializable.
const serializableTransaction: any = {
const serializableTransaction = {
chainId: transaction.chainId,
to: getChecksumAddress(transaction.to),
nonce: maybeInt(transaction.nonce),
Expand All @@ -86,7 +86,7 @@ export async function signTransaction(fastify: FastifyInstance) {
maxFeePerGas: maybeBigInt(transaction.maxFeePerGas),
maxPriorityFeePerGas: maybeBigInt(transaction.maxPriorityFeePerGas),
ccipReadEnabled: transaction.ccipReadEnabled,
};
} as TransactionSerializable;
const signature = await account.signTransaction(serializableTransaction);

reply.status(StatusCodes.OK).send({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export async function erc20AllowanceOf(fastify: FastifyInstance) {
chainId,
contractAddress,
});
const returnData: any = await contract.erc20.allowanceOf(
const returnData = await contract.erc20.allowanceOf(
ownerWallet ? ownerWallet : "",
spenderWallet ? spenderWallet : "",
);
Expand Down
4 changes: 2 additions & 2 deletions src/server/routes/contract/extensions/erc20/read/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ export async function erc20GetMetadata(fastify: FastifyInstance) {
chainId,
contractAddress,
});
const returnData: any = await contract.erc20.get();
const returnData = await contract.erc20.get();
reply.status(StatusCodes.OK).send({
result: {
symbol: returnData.symbol,
name: returnData.name,
decimals: returnData.decimals,
decimals: returnData.decimals.toString(),
},
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { TransactionHashSchema } from "../../../schemas/address";
import { standardResponseSchema } from "../../../schemas/shared-api-schemas";
import { walletChainParamSchema } from "../../../schemas/wallet";
import { getChainIdFromChain } from "../../../utils/chain";
import { prettifyError } from "../../../../shared/utils/error";

const UserOp = Type.Object({
sender: Type.String(),
Expand Down Expand Up @@ -86,10 +87,10 @@ export async function sendSignedUserOp(fastify: FastifyInstance) {
if (typeof signedUserOp === "string") {
try {
userOp = Value.Decode(UserOpString, signedUserOp);
} catch (err: any) {
} catch (err) {
return res.status(400).send({
error: {
message: `Invalid signed user operation. - ${err.message || err}`,
message: `Invalid signed user operation. - ${prettifyError(err)}`,
},
});
}
Expand Down
15 changes: 7 additions & 8 deletions src/server/utils/convertor.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { BigNumber } from "ethers";

export const bigNumberReplacer = (value: any): any => {
const isHexBigNumber = (value: unknown) => {
const isNonNullObject = typeof value === "object" && value !== null;
const hasType = isNonNullObject && "type" in value;
return hasType && value.type === "BigNumber" && "hex" in value
}
export const bigNumberReplacer = (value: unknown): unknown => {
// if we find a BigNumber then make it into a string (since that is safe)
if (
BigNumber.isBigNumber(value) ||
(typeof value === "object" &&
value !== null &&
value.type === "BigNumber" &&
"hex" in value)
) {
if (BigNumber.isBigNumber(value) || isHexBigNumber(value)) {
return BigNumber.from(value).toString();
}

Expand Down
2 changes: 1 addition & 1 deletion src/server/utils/wallets/get-aws-kms-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,5 +117,5 @@ export async function getAwsKmsAccount(
signMessage,
signTypedData,
signTransaction,
} satisfies Account;
} as AwsKmsAccount satisfies Account;
}
2 changes: 1 addition & 1 deletion src/server/utils/wallets/get-gcp-kms-account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,5 @@ export async function getGcpKmsAccount(
signMessage,
signTypedData,
signTransaction,
} satisfies Account;
} as GcpKmsAccount satisfies Account;
}
2 changes: 1 addition & 1 deletion src/shared/db/transactions/queue-tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { parseTransactionOverrides } from "../../../server/utils/transaction-ove

interface QueueTxParams {
// we should move away from Transaction type (v4 SDK)
tx: Transaction<any> | DeployTransaction;
tx: Transaction<unknown> | DeployTransaction;
chainId: number;
extension: ContractExtension;
// TODO: These shouldn't be in here
Expand Down
2 changes: 1 addition & 1 deletion src/shared/lib/cache/swr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class SWRCache<K, V> {
private set(key: K, data: V): void {
if (this.cache.size >= this.options.maxEntries) {
const firstKey = this.cache.keys().next().value;
this.cache.delete(firstKey);
this.cache.delete(firstKey as K);
}

this.cache.set(key, {
Expand Down
15 changes: 6 additions & 9 deletions src/shared/utils/ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface EthersError extends Error {
*
* This is generally helpful mostly for human-based debugging.
*/
info?: Record<string, any>;
info?: Record<string, unknown>;

/**
* Any related error.
Expand All @@ -35,17 +35,14 @@ export const ETHERS_ERROR_CODES = new Set(Object.values(ethers.errors));
* @param error
* @returns EthersError | null
*/
export const parseEthersError = (error: any): EthersError | null => {
if (
error &&
typeof error === "object" &&
"code" in error &&
ETHERS_ERROR_CODES.has(error.code)
) {
export const parseEthersError = (error: unknown): EthersError | null => {
const isNonNullObject = error && typeof error === "object";
const hasCodeProperty = isNonNullObject && "code" in error;
if (hasCodeProperty && ETHERS_ERROR_CODES.has(error.code as ethers.errors)) {
return error as EthersError;
}
return null;
};

export const isEthersErrorCode = (error: any, code: ethers.errors) =>
export const isEthersErrorCode = (error: unknown, code: ethers.errors) =>
parseEthersError(error)?.code === code;
6 changes: 3 additions & 3 deletions src/shared/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const winstonLogger = createLogger({
colorizeFormat(),
format.printf(({ level, message, timestamp, error }) => {
if (error) {
return `[${timestamp}] ${level}: ${message} - ${error.stack}`;
return `[${timestamp}] ${level}: ${message} - ${(error as Error).stack}`;
}
return `[${timestamp}] ${level}: ${message}`;
}),
Expand All @@ -82,8 +82,8 @@ interface LoggerParams {
level: (typeof env)["LOG_LEVEL"];
message: string;
queueId?: string | null;
error?: any;
data?: any;
error?: unknown;
data?: unknown;
}

export const logger = ({
Expand Down
6 changes: 5 additions & 1 deletion src/shared/utils/transaction/simulate-queued-transaction.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TransactionError } from "@thirdweb-dev/sdk";
import {
prepareTransaction,
simulateTransaction,
Expand Down Expand Up @@ -70,7 +71,10 @@ export const doSimulateTransaction = async (
account,
});
return null;
} catch (e: any) {
} catch (e: unknown) {
if (!(e instanceof TransactionError)) {
throw e;
}
// Error should be of type TransactionError in the thirdweb SDK.
return `${e.name}: ${e.message}`;
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/utils/transaction/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type InsertedTransaction = {

data?: Hex;
functionName?: string;
functionArgs?: any[];
functionArgs?: unknown[];

// User-provided overrides.
overrides?: {
Expand Down
Loading
Loading