Skip to content

Commit 035cb16

Browse files
authored
fix: Enforce Address schema wherever an address is expected (#657)
* fix: Enforce Address schema wherever an address is expected * More instances of string types * fix indentation * format
1 parent 468dea0 commit 035cb16

File tree

68 files changed

+286
-185
lines changed

Some content is hidden

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

68 files changed

+286
-185
lines changed

src/server/routes/admin/nonces.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,17 @@ import {
1616
import { getChain } from "../../../utils/chain";
1717
import { redis } from "../../../utils/redis/redis";
1818
import { thirdwebClient } from "../../../utils/sdk";
19+
import { AddressSchema } from "../../schemas/address";
1920
import { standardResponseSchema } from "../../schemas/sharedApiSchemas";
2021
import { walletWithAddressParamSchema } from "../../schemas/wallet";
2122

2223
export const responseBodySchema = Type.Object({
2324
result: Type.Array(
2425
Type.Object({
25-
walletAddress: Type.String({
26-
description: "Backend Wallet Address",
27-
examples: ["0xcedf3b4d8f7f1f7e0f7f0f7f0f7f0f7f0f7f0f7f"],
28-
}),
26+
walletAddress: {
27+
...AddressSchema,
28+
description: "Backend wallet address",
29+
},
2930
chainId: Type.Number({
3031
description: "Chain ID",
3132
examples: [80002],

src/server/routes/auth/access-tokens/getAll.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { Static, Type } from "@sinclair/typebox";
22
import { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { getAccessTokens } from "../../../../db/tokens/getAccessTokens";
5+
import { AddressSchema } from "../../../schemas/address";
56
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";
67

78
export const AccessTokenSchema = Type.Object({
89
id: Type.String(),
910
tokenMask: Type.String(),
10-
walletAddress: Type.String(),
11+
walletAddress: AddressSchema,
1112
createdAt: Type.String(),
1213
expiresAt: Type.String(),
1314
label: Type.Union([Type.String(), Type.Null()]),

src/server/routes/auth/permissions/getAll.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { Static, Type } from "@sinclair/typebox";
22
import { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { prisma } from "../../../../db/client";
5+
import { AddressSchema } from "../../../schemas/address";
56
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";
67

78
const responseBodySchema = Type.Object({
89
result: Type.Array(
910
Type.Object({
10-
walletAddress: Type.String(),
11+
walletAddress: AddressSchema,
1112
permissions: Type.String(),
1213
label: Type.Union([Type.String(), Type.Null()]),
1314
}),

src/server/routes/auth/permissions/grant.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { Static, Type } from "@sinclair/typebox";
22
import { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { updatePermissions } from "../../../../db/permissions/updatePermissions";
5+
import { AddressSchema } from "../../../schemas/address";
56
import { permissionsSchema } from "../../../schemas/auth";
67
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";
78

89
const requestBodySchema = Type.Object({
9-
walletAddress: Type.String(),
10+
walletAddress: AddressSchema,
1011
permissions: permissionsSchema,
1112
label: Type.Optional(Type.String()),
1213
});

src/server/routes/auth/permissions/revoke.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ import { Static, Type } from "@sinclair/typebox";
22
import { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { deletePermissions } from "../../../../db/permissions/deletePermissions";
5+
import { AddressSchema } from "../../../schemas/address";
56
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";
67

78
const requestBodySchema = Type.Object({
8-
walletAddress: Type.String(),
9+
walletAddress: AddressSchema,
910
});
1011

1112
const responseBodySchema = Type.Object({

src/server/routes/backend-wallet/create.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { WalletType } from "../../../schema/wallet";
55
import { getConfig } from "../../../utils/cache/getConfig";
6+
import { AddressSchema } from "../../schemas/address";
67
import { standardResponseSchema } from "../../schemas/sharedApiSchemas";
78
import { createAwsKmsWallet } from "../../utils/wallets/createAwsKmsWallet";
89
import { createGcpKmsWallet } from "../../utils/wallets/createGcpKmsWallet";
@@ -14,7 +15,7 @@ const requestBodySchema = Type.Object({
1415

1516
const responseSchema = Type.Object({
1617
result: Type.Object({
17-
walletAddress: Type.String(),
18+
walletAddress: AddressSchema,
1819
status: Type.String(),
1920
}),
2021
});

src/server/routes/backend-wallet/getBalance.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Static, Type } from "@sinclair/typebox";
22
import { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { getSdk } from "../../../utils/cache/getSdk";
5+
import { AddressSchema } from "../../schemas/address";
56
import {
67
currencyValueSchema,
78
standardResponseSchema,
@@ -11,7 +12,7 @@ import { getChainIdFromChain } from "../../utils/chain";
1112

1213
const responseSchema = Type.Object({
1314
result: Type.Object({
14-
walletAddress: Type.String(),
15+
walletAddress: AddressSchema,
1516
...currencyValueSchema.properties,
1617
}),
1718
});

src/server/routes/backend-wallet/import.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { StatusCodes } from "http-status-codes";
44
import { WalletType } from "../../../schema/wallet";
55
import { getConfig } from "../../../utils/cache/getConfig";
66
import { createCustomError } from "../../middleware/error";
7+
import { AddressSchema } from "../../schemas/address";
78
import { standardResponseSchema } from "../../schemas/sharedApiSchemas";
89
import { importAwsKmsWallet } from "../../utils/wallets/importAwsKmsWallet";
910
import { importGcpKmsWallet } from "../../utils/wallets/importGcpKmsWallet";
@@ -80,7 +81,7 @@ RequestBodySchema.examples = [
8081

8182
const ResponseSchema = Type.Object({
8283
result: Type.Object({
83-
walletAddress: Type.String(),
84+
walletAddress: AddressSchema,
8485
status: Type.String(),
8586
}),
8687
});

src/server/routes/backend-wallet/remove.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
44
import { Address } from "thirdweb";
55
import { deleteWalletDetails } from "../../../db/wallets/deleteWalletDetails";
6+
import { AddressSchema } from "../../schemas/address";
67
import { standardResponseSchema } from "../../schemas/sharedApiSchemas";
78

89
const requestParamSchema = Type.Object({
9-
walletAddress: Type.String(),
10+
walletAddress: AddressSchema,
1011
});
1112

1213
const responseSchema = Type.Object({

src/server/routes/backend-wallet/sendTransaction.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { StatusCodes } from "http-status-codes";
44
import { Address, Hex } from "thirdweb";
55
import { maybeBigInt } from "../../../utils/primitiveTypes";
66
import { insertTransaction } from "../../../utils/transaction/insertTransaction";
7+
import { AddressSchema } from "../../schemas/address";
78
import {
89
requestQuerystringSchema,
910
standardResponseSchema,
@@ -18,11 +19,7 @@ import {
1819
import { getChainIdFromChain } from "../../utils/chain";
1920

2021
const requestBodySchema = Type.Object({
21-
toAddress: Type.Optional(
22-
Type.String({
23-
examples: ["0x..."],
24-
}),
25-
),
22+
toAddress: Type.Optional(AddressSchema),
2623
data: Type.String({
2724
examples: ["0x..."],
2825
}),

0 commit comments

Comments
 (0)