Skip to content

Commit

Permalink
fix all biome errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dirtycajunrice committed Dec 12, 2024
1 parent 21e3a89 commit a9a2068
Show file tree
Hide file tree
Showing 41 changed files with 11,482 additions and 16,731 deletions.
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
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
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--ignore-engines true
3 changes: 2 additions & 1 deletion 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 Down Expand Up @@ -101,5 +102,5 @@
"ws": ">=8.17.1",
"cross-spawn": ">=7.0.6"
},
"packageManager": "yarn@4.5.3"
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
}
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;

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

0 comments on commit a9a2068

Please sign in to comment.