-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: assign spoke pool events to bundles (#77)
- Loading branch information
1 parent
8ba51e5
commit 15acb65
Showing
13 changed files
with
578 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
Column, | ||
Entity, | ||
ManyToOne, | ||
PrimaryGeneratedColumn, | ||
Unique, | ||
} from "typeorm"; | ||
import { Bundle } from "./Bundle"; | ||
|
||
export enum BundleEventType { | ||
Deposit = "deposit", | ||
ExpiredDeposit = "expiredDeposit", | ||
Fill = "fill", | ||
SlowFill = "slowFill", | ||
UnexecutableSlowFill = "unexecutableSlowFill", | ||
} | ||
|
||
@Entity() | ||
@Unique("UK_bundleEvent_eventType_relayHash", ["type", "relayHash"]) | ||
export class BundleEvent { | ||
@PrimaryGeneratedColumn() | ||
id: number; | ||
|
||
@ManyToOne(() => Bundle, (bundle) => bundle.events) | ||
bundle: Bundle; | ||
|
||
@Column() | ||
bundleId: number; | ||
|
||
@Column({ type: "enum", enum: BundleEventType }) | ||
type: BundleEventType; | ||
|
||
@Column() | ||
relayHash: string; | ||
|
||
@Column({ nullable: true }) | ||
repaymentChainId: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/indexer-database/src/migrations/1729644581993-BundleEvent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm"; | ||
|
||
export class BundleEvent1729644581993 implements MigrationInterface { | ||
name = "BundleEvent1729644581993"; | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TYPE "public"."bundle_event_type_enum" AS ENUM('deposit', 'expiredDeposit', 'fill', 'slowFill', 'unexecutableSlowFill')`, | ||
); | ||
await queryRunner.query( | ||
`CREATE TABLE "bundle_event" ( | ||
"id" SERIAL NOT NULL, | ||
"bundleId" integer NOT NULL, | ||
"type" "public"."bundle_event_type_enum" NOT NULL, | ||
"relayHash" character varying NOT NULL, | ||
"repaymentChainId" integer, | ||
CONSTRAINT "UK_bundleEvent_eventType_relayHash" UNIQUE ("type", "relayHash"), | ||
CONSTRAINT "PK_d633122fa4b52768e1b588bddee" PRIMARY KEY ("id"))`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "bundle" ADD "eventsAssociated" boolean NOT NULL DEFAULT false`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "bundle_event" ADD CONSTRAINT "FK_62dcd4f6f0d1713fab0c8542dba" FOREIGN KEY ("bundleId") REFERENCES "bundle"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "bundle_event" DROP CONSTRAINT "FK_62dcd4f6f0d1713fab0c8542dba"`, | ||
); | ||
await queryRunner.query( | ||
`ALTER TABLE "bundle" DROP COLUMN "eventsAssociated"`, | ||
); | ||
await queryRunner.query(`DROP TABLE "bundle_event"`); | ||
await queryRunner.query(`DROP TYPE "public"."bundle_event_type_enum"`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.