From d3d191bdc0680f548b4567cb5c289a3ddf5e9ff6 Mon Sep 17 00:00:00 2001 From: petarTxFusion Date: Tue, 10 Dec 2024 21:40:16 +0100 Subject: [PATCH] fix: fix `to` and `contractAddress` null --- packages/api/src/transaction/dtos/transaction.dto.ts | 2 +- .../src/transaction/entities/addressTransaction.entity.ts | 7 ++----- .../api/src/transaction/entities/transaction.entity.ts | 6 +++--- .../data-fetcher/src/transaction/transaction.service.ts | 2 +- packages/worker/src/entities/addressTransaction.entity.ts | 3 --- .../src/migrations/1732834401560-AddIsEvmLikeField.ts | 2 -- 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/api/src/transaction/dtos/transaction.dto.ts b/packages/api/src/transaction/dtos/transaction.dto.ts index 5244b9b957..c93512f867 100644 --- a/packages/api/src/transaction/dtos/transaction.dto.ts +++ b/packages/api/src/transaction/dtos/transaction.dto.ts @@ -14,7 +14,7 @@ export class TransactionDto { description: "The address this transaction is to", example: "0xc7e0220d02d549c4846A6EC31D89C3B670Ebe35C", }) - public readonly to?: string; + public readonly to: string; @ApiProperty({ type: String, diff --git a/packages/api/src/transaction/entities/addressTransaction.entity.ts b/packages/api/src/transaction/entities/addressTransaction.entity.ts index 8a780c6810..2a0502aa51 100644 --- a/packages/api/src/transaction/entities/addressTransaction.entity.ts +++ b/packages/api/src/transaction/entities/addressTransaction.entity.ts @@ -19,8 +19,8 @@ export class AddressTransaction extends BaseEntity { @Column({ type: "bytea", transformer: hexTransformer }) public readonly transactionHash: string; - @Column({ type: "bytea", transformer: normalizeAddressTransformer, nullable: true }) - public readonly address?: string; + @Column({ type: "bytea", transformer: normalizeAddressTransformer }) + public readonly address: string; @Index() @Column({ type: "bigint", transformer: bigIntNumberTransformer }) @@ -31,7 +31,4 @@ export class AddressTransaction extends BaseEntity { @Column({ type: "int" }) public readonly transactionIndex: number; - - @Column({ type: "boolean", nullable: true }) - public readonly isEvmLike?: boolean; } diff --git a/packages/api/src/transaction/entities/transaction.entity.ts b/packages/api/src/transaction/entities/transaction.entity.ts index ecf27e7b7e..8ea25e5686 100644 --- a/packages/api/src/transaction/entities/transaction.entity.ts +++ b/packages/api/src/transaction/entities/transaction.entity.ts @@ -31,8 +31,8 @@ export class Transaction extends BaseEntity { @Column({ generated: true, type: "bigint" }) public number: number; - @Column({ type: "bytea", transformer: normalizeAddressTransformer, nullable: true }) - public readonly to?: string; + @Column({ type: "bytea", transformer: normalizeAddressTransformer }) + public readonly to: string; @Index() @Column({ type: "bytea", transformer: normalizeAddressTransformer }) @@ -110,7 +110,7 @@ export class Transaction extends BaseEntity { @Column({ type: "boolean", nullable: true }) public readonly isEvmLike?: boolean; - @Column({ type: "bytea", transformer: hexTransformer, nullable: true }) + @Column({ type: "bytea", transformer: normalizeAddressTransformer, nullable: true }) public readonly contractAddress?: string; public get status(): TransactionStatus { diff --git a/packages/data-fetcher/src/transaction/transaction.service.ts b/packages/data-fetcher/src/transaction/transaction.service.ts index de7e904719..ef6724f79f 100644 --- a/packages/data-fetcher/src/transaction/transaction.service.ts +++ b/packages/data-fetcher/src/transaction/transaction.service.ts @@ -86,7 +86,7 @@ export class TransactionService { const toAddress = isEvmLike ? "0x" : transactionInfo.to; const contractAddress = isEvmLike ? getCreateAddress({ from: transactionInfo.from, nonce: transactionInfo.nonce }) - : ""; + : "0x"; const updatedTransactionInfo = { ...transactionInfo, diff --git a/packages/worker/src/entities/addressTransaction.entity.ts b/packages/worker/src/entities/addressTransaction.entity.ts index 725719d17e..4e77806513 100644 --- a/packages/worker/src/entities/addressTransaction.entity.ts +++ b/packages/worker/src/entities/addressTransaction.entity.ts @@ -35,7 +35,4 @@ export class AddressTransaction extends BaseEntity { @Column({ type: "int" }) public readonly transactionIndex: number; - - @Column({ type: "boolean", nullable: true }) - public readonly isEvmLike?: boolean; } diff --git a/packages/worker/src/migrations/1732834401560-AddIsEvmLikeField.ts b/packages/worker/src/migrations/1732834401560-AddIsEvmLikeField.ts index a02b7c08a9..f212662822 100644 --- a/packages/worker/src/migrations/1732834401560-AddIsEvmLikeField.ts +++ b/packages/worker/src/migrations/1732834401560-AddIsEvmLikeField.ts @@ -5,14 +5,12 @@ export class AddIsEvmLikeField1732834401560 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "transactions" ADD "isEvmLike" boolean`); - await queryRunner.query(`ALTER TABLE "addressTransactions" ADD "isEvmLike" boolean`); await queryRunner.query(`ALTER TABLE "transactionReceipts" ADD "isEvmLike" boolean`); await queryRunner.query(`ALTER TABLE "addresses" ADD "isEvmLike" boolean`); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "transactionReceipts" DROP COLUMN "isEvmLike"`); - await queryRunner.query(`ALTER TABLE "addressTransactions" DROP COLUMN "isEvmLike"`); await queryRunner.query(`ALTER TABLE "transactions" DROP COLUMN "isEvmLike"`); await queryRunner.query(`ALTER TABLE "addresses" DROP COLUMN "isEvmLike"`); }