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 2 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
8 changes: 4 additions & 4 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 All @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.event.release.target_commitish }}

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 Expand Up @@ -86,4 +86,4 @@ jobs:
- name: Inspect latest image (if applicable)
if: ${{ env.LATEST_TAG != '' }}
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:latest
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:latest
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ on: pull_request

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "yarn"

- name: Install dependencies
run: yarn install

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

jobs:
lint:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Set up Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "yarn"

- name: Install dependencies
run: yarn install

- name: Run lint
run: yarn lint
run: yarn lint
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
runner: ubuntu-24.04
arch: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm64
arch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
Expand All @@ -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 All @@ -67,4 +67,4 @@ jobs:

- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:nightly
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:nightly
6 changes: 3 additions & 3 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}

- name: Set up Node.js
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: "18"
cache: "yarn"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ on:
jobs:
stale:

runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
issues: write
pull-requests: write

steps:
- uses: actions/stale@v5
- uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: 'This PR is stale because it has been open for 7 days with no activity. Remove stale label or comment or this PR will be closed in 3 days.'
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
5 changes: 1 addition & 4 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 @@ -92,10 +93,6 @@
"schema": "./src/prisma/schema.prisma"
},
"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",
Copy link
Contributor

Choose a reason for hiding this comment

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

These are needed to pin versions that don't have reported vulnerabilities. synk test on this branch brings back these vulns if we remove this:

✗ Cross-site Request Forgery (CSRF) [High Severity][https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459] in axios@0.27.2
✗ Regular Expression Denial of Service (ReDoS) [Medium Severity][https://security.snyk.io/vuln/SNYK-JS-AXIOS-6124857] in axios@0.27.2
✗ Cross-site Scripting (XSS) [Medium Severity][https://security.snyk.io/vuln/SNYK-JS-AXIOS-6671926] in axios@0.27.2
✗ Prototype Pollution [High Severity][https://security.snyk.io/vuln/SNYK-JS-WEB3UTILS-6229337] in web3-utils@1.10.4

Copy link
Contributor

Choose a reason for hiding this comment

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

Some of these may be removable since I only see the first two deps in this vuln report list.

"@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
5 changes: 3 additions & 2 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 @@ -71,7 +72,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 +87,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
30 changes: 17 additions & 13 deletions src/server/routes/transaction/blockchain/send-signed-user-op.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Type, type Static } from "@sinclair/typebox";
import { Value } from "@sinclair/typebox/value";
import { TransformDecodeError } from "@sinclair/typebox/value/transform";
import type { FastifyInstance } from "fastify";
import { StatusCodes } from "http-status-codes";
import { env } from "../../../../shared/utils/env";
Expand Down Expand Up @@ -47,15 +48,15 @@ const responseBodySchema = Type.Union([

type RpcResponse =
| {
result: string;
error: undefined;
}
result: string;
error: undefined;
}
| {
result: undefined;
error: {
message: string;
};
};
result: undefined;
error: {
message: string;
};
};

export async function sendSignedUserOp(fastify: FastifyInstance) {
fastify.route<{
Expand All @@ -68,7 +69,7 @@ export async function sendSignedUserOp(fastify: FastifyInstance) {
schema: {
summary: "Send a signed user operation",
description: "Send a signed user operation",
tags: ["Transaction"],
tags: [ "Transaction" ],
operationId: "sendSignedUserOp",
params: walletChainParamSchema,
body: requestBodySchema,
Expand All @@ -86,10 +87,11 @@ export async function sendSignedUserOp(fastify: FastifyInstance) {
if (typeof signedUserOp === "string") {
try {
userOp = Value.Decode(UserOpString, signedUserOp);
} catch (err: any) {
} catch (err: unknown) {
const msg = err instanceof TransformDecodeError ? err.message : err;
return res.status(400).send({
error: {
message: `Invalid signed user operation. - ${err.message || err}`,
message: `Invalid signed user operation. - ${msg}`,
},
});
}
Expand All @@ -109,12 +111,14 @@ export async function sendSignedUserOp(fastify: FastifyInstance) {
id: 1,
jsonrpc: "2.0",
method: "eth_sendUserOperation",
params: [userOp, entryPointAddress],
params: [ userOp, entryPointAddress ],
}),
});

const { result: userOpHash, error } =
(await userOpRes.json()) as RpcResponse;
(
await userOpRes.json()
) as RpcResponse;
Copy link
Contributor

Choose a reason for hiding this comment

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

Did biome format this? This seems weird and lower redability.

Copy link
Contributor

Choose a reason for hiding this comment

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

My biome corrects this back


if (error) {
return res.status(400).send({
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
Loading
Loading