diff --git a/packages/worker/src/entities/addressTransaction.entity.ts b/packages/worker/src/entities/addressTransaction.entity.ts index 2cbece61cd..a15dab3970 100644 --- a/packages/worker/src/entities/addressTransaction.entity.ts +++ b/packages/worker/src/entities/addressTransaction.entity.ts @@ -4,7 +4,6 @@ import { Block } from "./block.entity"; import { Transaction } from "./transaction.entity"; import { hexTransformer } from "../transformers/hex.transformer"; import { bigIntNumberTransformer } from "../transformers/bigIntNumber.transformer"; -import { stringDateTransformer } from "../transformers/stringDate.transformer"; @Entity({ name: "addressTransactions" }) @Index(["address", "blockNumber", "receivedAt", "transactionIndex"]) @@ -31,7 +30,7 @@ export class AddressTransaction extends BaseEntity { @Column({ type: "bigint", transformer: bigIntNumberTransformer }) public readonly blockNumber: number; - @Column({ type: "timestamp", transformer: stringDateTransformer }) + @Column({ type: "timestamp" }) public readonly receivedAt: string; @Column({ type: "int" }) diff --git a/packages/worker/src/entities/addressTransfer.entity.ts b/packages/worker/src/entities/addressTransfer.entity.ts index 310c6e1943..22fb701c39 100644 --- a/packages/worker/src/entities/addressTransfer.entity.ts +++ b/packages/worker/src/entities/addressTransfer.entity.ts @@ -5,7 +5,6 @@ import { Transfer } from "./transfer.entity"; import { TokenType } from "./token.entity"; import { hexTransformer } from "../transformers/hex.transformer"; import { bigIntNumberTransformer } from "../transformers/bigIntNumber.transformer"; -import { stringDateTransformer } from "../transformers/stringDate.transformer"; import { TransferFields } from "../dataFetcher/types"; @Entity({ name: "addressTransfers" }) @@ -39,7 +38,7 @@ export class AddressTransfer extends BaseEntity { @Column({ type: "bigint", transformer: bigIntNumberTransformer }) public readonly blockNumber: number; - @Column({ type: "timestamp", transformer: stringDateTransformer }) + @Column({ type: "timestamp" }) public readonly timestamp: string; @Column({ type: "enum", enum: TokenType, default: TokenType.ETH }) diff --git a/packages/worker/src/entities/log.entity.ts b/packages/worker/src/entities/log.entity.ts index fb476e3ffc..a8efdc868b 100644 --- a/packages/worker/src/entities/log.entity.ts +++ b/packages/worker/src/entities/log.entity.ts @@ -5,7 +5,6 @@ import { hash64HexTransformer } from "../transformers/hash64Hex.transformer"; import { hexTransformer } from "../transformers/hex.transformer"; import { hexArrayTransformer } from "../transformers/hexArray.transformer"; import { bigIntNumberTransformer } from "../transformers/bigIntNumber.transformer"; -import { stringDateTransformer } from "../transformers/stringDate.transformer"; import { BaseEntity } from "./base.entity"; @Entity({ name: "logs" }) @@ -49,6 +48,6 @@ export class Log extends BaseEntity { @Column({ type: "int" }) public readonly logIndex: number; - @Column({ type: "timestamp", transformer: stringDateTransformer }) + @Column({ type: "timestamp" }) public readonly timestamp: string; } diff --git a/packages/worker/src/entities/transaction.entity.ts b/packages/worker/src/entities/transaction.entity.ts index bc21f471ba..75d1090398 100644 --- a/packages/worker/src/entities/transaction.entity.ts +++ b/packages/worker/src/entities/transaction.entity.ts @@ -1,5 +1,4 @@ import { Entity, Column, PrimaryColumn, JoinColumn, ManyToOne, Index } from "typeorm"; -import { stringDateTransformer } from "../transformers/stringDate.transformer"; import { bigIntNumberTransformer } from "../transformers/bigIntNumber.transformer"; import { hexTransformer } from "../transformers/hex.transformer"; import { Batch } from "./batch.entity"; @@ -84,7 +83,7 @@ export class Transaction extends CountableEntity { @Column({ type: "boolean" }) public readonly isL1Originated: boolean; - @Column({ type: "timestamp", transformer: stringDateTransformer }) + @Column({ type: "timestamp" }) public readonly receivedAt: string; @Column({ type: "int", default: 1 }) diff --git a/packages/worker/src/entities/transfer.entity.ts b/packages/worker/src/entities/transfer.entity.ts index 8aa11a495c..8411a189ed 100644 --- a/packages/worker/src/entities/transfer.entity.ts +++ b/packages/worker/src/entities/transfer.entity.ts @@ -6,7 +6,6 @@ import { TokenType } from "./token.entity"; import { hash64HexTransformer } from "../transformers/hash64Hex.transformer"; import { hexTransformer } from "../transformers/hex.transformer"; import { bigIntNumberTransformer } from "../transformers/bigIntNumber.transformer"; -import { stringDateTransformer } from "../transformers/stringDate.transformer"; import { TransferFields } from "../dataFetcher/types"; export enum TransferType { @@ -49,7 +48,7 @@ export class Transfer extends CountableEntity { @Column({ type: "bytea", nullable: true, transformer: hash64HexTransformer }) public readonly transactionHash?: string; - @Column({ type: "timestamp", transformer: stringDateTransformer }) + @Column({ type: "timestamp" }) public readonly timestamp: string; @Column({ type: "int" }) diff --git a/packages/worker/src/transformers/stringDate.transformer.spec.ts b/packages/worker/src/transformers/stringDate.transformer.spec.ts deleted file mode 100644 index 830d02658a..0000000000 --- a/packages/worker/src/transformers/stringDate.transformer.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { stringDateTransformer } from "./stringDate.transformer"; - -describe("stringDateTransformer", () => { - describe("to", () => { - it("returns null for null input", () => { - const result = stringDateTransformer.to(null); - expect(result).toBeNull(); - }); - - it("returns Date parsed from string", () => { - const strDate = "2023-12-28T17:49:03.048Z"; - const result = stringDateTransformer.to(strDate); - expect(result).toStrictEqual(new Date(strDate)); - }); - }); - - describe("from", () => { - it("returns null for null input", () => { - const result = stringDateTransformer.from(null); - expect(result).toBeNull(); - }); - - it("returns ISO string for the Date", () => { - const strDate = "2023-12-28T17:49:03.048Z"; - const result = stringDateTransformer.from(new Date(strDate)); - expect(result).toBe(strDate); - }); - }); -}); diff --git a/packages/worker/src/transformers/stringDate.transformer.ts b/packages/worker/src/transformers/stringDate.transformer.ts deleted file mode 100644 index d1c84815fa..0000000000 --- a/packages/worker/src/transformers/stringDate.transformer.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ValueTransformer } from "typeorm"; - -export const stringDateTransformer: ValueTransformer = { - to(strDate: string | null): Date | null { - if (!strDate) { - return null; - } - return new Date(strDate); - }, - from(date: Date | null): string | null { - if (!date) { - return null; - } - return date.toISOString(); - }, -};