Skip to content

Breaking change: Require Redis (for v1.0.0) #550

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 1 commit into from
Jun 21, 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
10 changes: 5 additions & 5 deletions src/server/routes/chain/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ const responseSchema = Type.Object({
responseSchema.examples = [
{
result: {
name: "Mumbai",
name: "Polygon Amoy Testnet",
chain: "Polygon",
rpc: ["https://mumbai.rpc.thirdweb.com/${THIRDWEB_API_SECRET_KEY}"],
rpc: ["https://80002.rpc.thirdweb.com/${THIRDWEB_API_SECRET_KEY}"],
nativeCurrency: {
name: "MATIC",
symbol: "MATIC",
decimals: 18,
},
shortName: "maticmum",
chainId: 80001,
shortName: "polygonamoy",
chainId: 80002,
testnet: true,
slug: "mumbai",
slug: "polygon-amoy-testnet",
},
},
];
Expand Down
2 changes: 1 addition & 1 deletion src/server/routes/transaction/blockchain/getTxReceipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const requestSchema = Type.Object({
pattern: "^0x([A-Fa-f0-9]{64})$",
}),
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain ID or name",
}),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const requestSchema = Type.Object({
pattern: "^0x([A-Fa-f0-9]{64})$",
}),
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain ID or name",
}),
});
Expand Down
2 changes: 1 addition & 1 deletion src/server/schemas/prebuilts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export const commonTrustedForwarderSchema = Type.Object({

export const prebuiltDeployContractParamSchema = Type.Object({
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain ID or name",
}),
});
Expand Down
14 changes: 7 additions & 7 deletions src/server/schemas/sharedApiSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const baseReplyErrorSchema = Type.Object({
*/
export const contractParamSchema = Type.Object({
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain ID or name",
}),
contractAddress: Type.String({
Expand All @@ -37,7 +37,7 @@ export const requestQuerystringSchema = Type.Object({

export const prebuiltDeployParamSchema = Type.Object({
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain ID or name",
}),
contractType: Type.String({
Expand All @@ -48,7 +48,7 @@ export const prebuiltDeployParamSchema = Type.Object({

export const publishedDeployParamSchema = Type.Object({
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain ID or name",
}),
publisher: Type.String({
Expand Down Expand Up @@ -176,7 +176,7 @@ transactionWritesResponseSchema.example = {
*/
export const erc20ContractParamSchema = Type.Object({
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain ID or name",
}),
contractAddress: Type.String({
Expand All @@ -190,7 +190,7 @@ export const erc20ContractParamSchema = Type.Object({
*/
export const erc1155ContractParamSchema = Type.Object({
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain ID or name",
}),
contractAddress: Type.String({
Expand All @@ -204,7 +204,7 @@ export const erc1155ContractParamSchema = Type.Object({
*/
export const erc721ContractParamSchema = Type.Object({
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain ID or name",
}),
contractAddress: Type.String({
Expand Down Expand Up @@ -234,7 +234,7 @@ export enum Status {

export const marketplaceV3ContractParamSchema = Type.Object({
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain ID or name",
}),
contractAddress: Type.String({
Expand Down
2 changes: 1 addition & 1 deletion src/server/schemas/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const walletWithAAHeaderSchema = Type.Object({

export const walletParamSchema = Type.Object({
chain: Type.String({
examples: ["mumbai"],
examples: ["80002"],
description: "Chain name",
}),
walletAddress: Type.String({
Expand Down
2 changes: 1 addition & 1 deletion src/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const env = createEnv({
.number()
.nonnegative()
.default(0),
REDIS_URL: z.string().optional(),
REDIS_URL: z.string(),
},
clientPrefix: "NEVER_USED",
client: {},
Expand Down
74 changes: 31 additions & 43 deletions src/utils/redis/redis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,35 @@ import Redis from "ioredis";
import { env } from "../env";
import { logger } from "../logger";

export let redis: Redis | null;
export const redis = new Redis(env.REDIS_URL, {
maxRetriesPerRequest: null,
});

if (env.REDIS_URL) {
try {
redis = new Redis(env.REDIS_URL, {
maxRetriesPerRequest: null,
});

redis.on("error", (err) => () => {
logger({
level: "error",
message: `Redis error: ${err}`,
service: "worker",
});
});
redis.on("connect", () =>
logger({
level: "info",
message: "Redis connected",
service: "worker",
}),
);
redis.on("reconnecting", () =>
logger({
level: "info",
message: "Redis reconnecting",
service: "worker",
}),
);
redis.on("ready", () => {
logger({
level: "info",
message: "Redis ready",
service: "worker",
});
});
} catch (e) {
logger({
level: "error",
message: `Error initializing Redis: ${e}`,
service: "worker",
});
}
}
redis.on("error", (err) => () => {
logger({
level: "error",
message: `Redis error: ${err}`,
service: "worker",
});
});
redis.on("connect", () =>
logger({
level: "info",
message: "Redis connected",
service: "worker",
}),
);
redis.on("reconnecting", () =>
logger({
level: "info",
message: "Redis reconnecting",
service: "worker",
}),
);
redis.on("ready", () => {
logger({
level: "info",
message: "Redis ready",
service: "worker",
});
});
2 changes: 1 addition & 1 deletion src/worker/tasks/processTransactionReceiptsWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const getFormattedTransactionReceipts = async ({
transactionIndex: receipt.transactionIndex,
gasUsed: receipt.gasUsed.toString(),
effectiveGasPrice: receipt.effectiveGasPrice.toString(),
status: receipt.status ? 1 : 0,
status: receipt.status === "success" ? 1 : 0,
});
}

Expand Down
Loading