Skip to content

Commit

Permalink
fix: make isEvmLike not nullable, update on contract change
Browse files Browse the repository at this point in the history
  • Loading branch information
Romsters committed Dec 19, 2024
1 parent e37496e commit 93ff034
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 33 deletions.
4 changes: 2 additions & 2 deletions packages/api/src/address/address.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export class Address extends BaseEntity {
@Column({ type: "bytea", nullable: true, transformer: normalizeAddressTransformer })
public readonly creatorAddress?: string;

@Column({ type: "boolean", nullable: true })
public readonly isEvmLike?: boolean;
@Column({ type: "boolean", default: false })
public readonly isEvmLike: boolean;
}
10 changes: 5 additions & 5 deletions packages/api/test/address.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -790,7 +790,7 @@ describe("AddressController (e2e)", () => {
createdInBlockNumber: 10,
creatorAddress: "0x91d0a23f34e535e44Df8Ba84c53a0945cf0eEB60",
creatorTxHash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
isEvmLike: false,
totalTransactions: 4,
type: "contract",
})
Expand Down Expand Up @@ -850,7 +850,7 @@ describe("AddressController (e2e)", () => {
createdInBlockNumber: 10,
creatorAddress: "0x91d0a23f34e535e44Df8Ba84c53a0945cf0eEB60",
creatorTxHash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
isEvmLike: false,
totalTransactions: 4,
type: "contract",
})
Expand Down Expand Up @@ -910,7 +910,7 @@ describe("AddressController (e2e)", () => {
createdInBlockNumber: 10,
creatorAddress: "0x91d0a23f34e535e44Df8Ba84c53a0945cf0eEB60",
creatorTxHash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
isEvmLike: false,
totalTransactions: 4,
type: "contract",
})
Expand Down Expand Up @@ -970,7 +970,7 @@ describe("AddressController (e2e)", () => {
createdInBlockNumber: 10,
creatorAddress: "0x91d0a23f34e535e44Df8Ba84c53a0945cf0eEB60",
creatorTxHash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
isEvmLike: false,
totalTransactions: 4,
type: "contract",
})
Expand All @@ -991,7 +991,7 @@ describe("AddressController (e2e)", () => {
createdInBlockNumber: 10,
creatorAddress: "0x91d0a23f34e535e44Df8Ba84c53a0945cf0eEB60",
creatorTxHash: "0x8a008b8dbbc18035e56370abb820e736b705d68d6ac12b203603db8d9ea87e15",
isEvmLike: null,
isEvmLike: false,
totalTransactions: 0,
type: "contract",
})
Expand Down
4 changes: 1 addition & 3 deletions packages/app/src/components/common/Title.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import Badge from "./Badge.vue";
import CopyButton from "@/components/common/CopyButton.vue";
import type { PropType } from "vue";
import { shortValue } from "@/utils/formatters";
defineProps({
Expand All @@ -38,7 +36,7 @@ defineProps({
type: Boolean,
},
isEvmLike: {
type: [Boolean, null] as PropType<boolean | null>,
type: Boolean,
default: false,
required: false,
},
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/composables/common/Api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ declare namespace Api {
creatorTxHash: string;
createdInBlockNumber: number;
totalTransactions: number;
isEvmLike: boolean;
};
}
}
2 changes: 1 addition & 1 deletion packages/app/src/composables/useAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export type Balances = Api.Response.Balances;
export type Account = Api.Response.Account;
export type Contract = Api.Response.Contract & {
verificationInfo: null | ContractVerificationInfo;
isEvmLike?: boolean | null;
isEvmLike: boolean;
proxyInfo: null | {
implementation: {
address: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ export interface ContractAddress {
creatorAddress: string;
logIndex: number;
bytecode?: string;
isEvmLike?: boolean;
isEvmLike: boolean;
}
2 changes: 1 addition & 1 deletion packages/worker/src/dataFetcher/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface ContractAddress {
creatorAddress: string;
logIndex: number;
bytecode?: string;
isEvmLike?: boolean;
isEvmLike: boolean;
}

export interface LogsData {
Expand Down
4 changes: 2 additions & 2 deletions packages/worker/src/entities/address.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ export class Address extends BaseEntity {
@Column({ type: "bytea", nullable: true, transformer: hexTransformer })
public readonly creatorAddress?: string;

@Column({ type: "boolean", nullable: true })
public readonly isEvmLike?: boolean;
@Column({ type: "boolean", default: false })
public readonly isEvmLike: boolean;
}
13 changes: 0 additions & 13 deletions packages/worker/src/migrations/1732834401560-AddIsEvmLikeField.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import { MigrationInterface, QueryRunner } from "typeorm";

export class MakeTransactionToFieldOptional1734453474315 implements MigrationInterface {
name = "MakeTransactionToFieldOptional1734453474315";
export class ChangesForEvmEquivalence1734649984378 implements MigrationInterface {
name = "ChangesForEvmEquivalence1734649984378";

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "addresses" ADD "isEvmLike" boolean NOT NULL DEFAULT false`);
await queryRunner.query(`ALTER TABLE "transactions" ALTER COLUMN "to" DROP NOT NULL`);
await queryRunner.query(`ALTER TABLE "addressTransactions" ALTER COLUMN "address" DROP NOT NULL`);
await queryRunner.query(`ALTER TABLE "transactionReceipts" ALTER COLUMN "to" DROP NOT NULL`);
await queryRunner.query(`ALTER TABLE "addressTransactions" ALTER COLUMN "address" DROP NOT NULL`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "transactionReceipts" ALTER COLUMN "to" SET NOT NULL`);
await queryRunner.query(`ALTER TABLE "addressTransactions" ALTER COLUMN "address" SET NOT NULL`);
await queryRunner.query(`ALTER TABLE "transactionReceipts" ALTER COLUMN "to" SET NOT NULL`);
await queryRunner.query(`ALTER TABLE "transactions" ALTER COLUMN "to" SET NOT NULL`);
await queryRunner.query(`ALTER TABLE "addresses" DROP COLUMN "isEvmLike"`);
}
}
3 changes: 2 additions & 1 deletion packages/worker/src/repositories/address.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export class AddressRepository extends BaseRepository<Address> {
"createdInBlockNumber" = EXCLUDED."createdInBlockNumber",
"creatorTxHash" = EXCLUDED."creatorTxHash",
"creatorAddress" = EXCLUDED."creatorAddress",
"createdInLogIndex" = EXCLUDED."createdInLogIndex"
"createdInLogIndex" = EXCLUDED."createdInLogIndex",
"isEvmLike" = EXCLUDED."isEvmLike"
WHERE
addresses."createdInBlockNumber" IS NULL OR
EXCLUDED."createdInBlockNumber" > addresses."createdInBlockNumber" OR
Expand Down

0 comments on commit 93ff034

Please sign in to comment.