Skip to content

Commit ba59e74

Browse files
authored
Refactor chainId from number to string in contractSubscriptions (#759)
1 parent b5582d9 commit ba59e74

File tree

5 files changed

+8
-6
lines changed

5 files changed

+8
-6
lines changed

src/db/contractSubscriptions/createContractSubscription.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const createContractSubscription = async ({
2121
}: CreateContractSubscriptionParams) => {
2222
return prisma.contractSubscriptions.create({
2323
data: {
24-
chainId,
24+
chainId: chainId.toString(),
2525
contractAddress,
2626
webhookId,
2727
processEventLogs,

src/db/contractSubscriptions/getContractSubscriptions.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export const isContractSubscribed = async ({
1111
}: GetContractSubscriptionsParams) => {
1212
const contractSubscription = await prisma.contractSubscriptions.findFirst({
1313
where: {
14-
chainId,
14+
chainId: chainId.toString(),
1515
contractAddress,
1616
deletedAt: null,
1717
},
@@ -25,7 +25,7 @@ export const getContractSubscriptionsByChainId = async (
2525
) => {
2626
return await prisma.contractSubscriptions.findMany({
2727
where: {
28-
chainId,
28+
chainId: chainId.toString(),
2929
deletedAt: null,
3030
},
3131
include: {
@@ -56,5 +56,5 @@ export const getContractSubscriptionsUniqueChainIds = async () => {
5656
},
5757
});
5858

59-
return uniqueChainIds.map((contract) => contract.chainId);
59+
return uniqueChainIds.map((contract) => Number.parseInt(contract.chainId));
6060
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
-- AlterTable
2+
ALTER TABLE "contract_subscriptions" ALTER COLUMN "chainId" SET DATA TYPE TEXT;

src/prisma/schema.prisma

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ model Relayers {
202202

203203
model ContractSubscriptions {
204204
id String @id @default(uuid()) @map("id")
205-
chainId Int
205+
chainId String
206206
contractAddress String
207207
webhookId Int?
208208
processEventLogs Boolean @default(true)

src/server/schemas/contractSubscription.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const toContractSubscriptionSchema = (
2222
contractSubscription: ContractSubscriptions & { webhook: Webhooks | null },
2323
): Static<typeof contractSubscriptionSchema> => ({
2424
id: contractSubscription.id,
25-
chainId: contractSubscription.chainId,
25+
chainId: Number.parseInt(contractSubscription.chainId),
2626
contractAddress: contractSubscription.contractAddress,
2727
webhook: contractSubscription.webhook
2828
? toWebhookSchema(contractSubscription.webhook)

0 commit comments

Comments
 (0)