Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/indexer-database/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"license": "ISC",
"dependencies": {
"@across-protocol/sdk": "^4.3.75",
"ethers": "^5.8.0",
"pg": "^8.4.0",
"reflect-metadata": "^0.1.13",
"superstruct": "2.0.3-1",
Expand Down
45 changes: 45 additions & 0 deletions packages/indexer-database/src/entities/CctpFinalizerJob.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import {
Column,
CreateDateColumn,
Entity,
JoinColumn,
OneToOne,
PrimaryGeneratedColumn,
Unique,
UpdateDateColumn,
} from "typeorm";
import { DepositForBurn } from "./evm/DepositForBurn";

/**
* Table to store the burn events sent to be finalized by the
* finalizer bot. Each row points to a burn event that has
* been sent successfully to the finalizer bot.
*/
@Entity()
@Unique("UK_cctpFinalizerJob_burnEventId", ["burnEventId"])
export class CctpFinalizerJob {
@PrimaryGeneratedColumn()
id: number;

@Column()
attestation: string;

@Column()
message: string;

@Column()
burnEventId: number;

@Column({ nullable: true })
sponsoredDepositForBurnId?: number;

Comment on lines +33 to +35
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to generate the migration for this.

@OneToOne(() => DepositForBurn, (burnEvent) => burnEvent.id)
@JoinColumn({ name: "burnEventId" })
burnEvent: DepositForBurn;

@CreateDateColumn()
createdAt: Date;

@UpdateDateColumn()
updatedAt: Date;
}
89 changes: 89 additions & 0 deletions packages/indexer-database/src/entities/OftTransfer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import {
Column,
CreateDateColumn,
Entity,
Index,
JoinColumn,
OneToOne,
PrimaryGeneratedColumn,
Unique,
UpdateDateColumn,
} from "typeorm";
import { OFTSent } from "./evm/OftSent";
import { OFTReceived } from "./evm/OftReceived";
import { RelayStatus } from "./RelayHashInfo";

@Entity()
@Unique("UK_oft_transfer_guid", ["guid"])
@Index("IX_oft_transfer_origin_txn_ref", ["originTxnRef"])
@Index("IX_oft_transfer_status", ["status"])
export class OftTransfer {
@PrimaryGeneratedColumn()
id: number;

@Column()
guid: string;

@Column({ type: "bigint" })
originChainId: string;

@Column({ type: "bigint" })
destinationChainId: string;

@Column({ nullable: true })
originTokenAddress?: string;

@Column({ nullable: true })
destinationTokenAddress?: string;

@Column({ type: "decimal", nullable: true })
originTokenAmount?: string;

@Column({ type: "decimal", nullable: true })
destinationTokenAmount?: string;

@Column({ nullable: true })
originTxnRef?: string;

@Column({ nullable: true })
destinationTxnRef?: string;

@Column({ nullable: true })
oftSentEventId?: number;

@OneToOne(() => OFTSent, (oftSentEvent) => oftSentEvent.id)
@JoinColumn({ name: "oftSentEventId" })
oftSentEvent?: OFTSent;

@Column({ nullable: true })
oftReceivedEventId?: number;

@OneToOne(() => OFTReceived, (oftReceivedEvent) => oftReceivedEvent.id)
@JoinColumn({ name: "oftReceivedEventId" })
oftReceivedEvent?: OFTReceived;

/** For consistency this shares the same status as the RelayHashInfo.
* If other values than `unfilled` and `filled` are needed,
* then we can create a new type for this
*/
@Column({ type: "enum", enum: RelayStatus, default: RelayStatus.Unfilled })
status: RelayStatus;

@Column({ nullable: true, type: "decimal" })
bridgeFeeUsd?: string;

@Column({ nullable: true, type: "decimal" })
originGasFee?: string;

@Column({ nullable: true, type: "decimal" })
originGasFeeUsd?: string;

@Column({ nullable: true, type: "decimal" })
originGasTokenPriceUsd?: string;

@CreateDateColumn()
createdAt: Date;

@UpdateDateColumn()
updatedAt: Date;
}
85 changes: 85 additions & 0 deletions packages/indexer-database/src/entities/evm/DepositForBurn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import {
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
Index,
OneToOne,
PrimaryGeneratedColumn,
Unique,
} from "typeorm";
import { CctpFinalizerJob } from "../CctpFinalizerJob";

@Entity({ schema: "evm" })
@Unique("UK_depositForBurn_chain_block_txn_log", [
"chainId",
"blockNumber",
"transactionHash",
"logIndex",
])
@Index("IX_depositForBurn_finalised", ["finalised"])
@Index("IX_depositForBurn_deletedAt", ["deletedAt"])
export class DepositForBurn {
@PrimaryGeneratedColumn()
id: number;

@Column()
burnToken: string;

@Column({ type: "decimal" })
amount: string;

@Column()
depositor: string;

@Column()
mintRecipient: string;

@Column()
destinationDomain: number;

@Column()
destinationTokenMessenger: string;

@Column()
destinationCaller: string;

@Column({ type: "decimal" })
maxFee: string;

@Column()
minFinalityThreshold: number;

@Column()
hookData: string;

@Column({ type: "bigint" })
chainId: string;

@Column()
blockNumber: number;

@Column()
transactionHash: string;

@Column()
transactionIndex: number;

@Column()
logIndex: number;

@Column()
finalised: boolean;

@Column()
blockTimestamp: Date;

@CreateDateColumn()
createdAt: Date;

@DeleteDateColumn({ nullable: true })
deletedAt?: Date;

@OneToOne(() => CctpFinalizerJob, (finalizerJob) => finalizerJob.burnEvent)
finalizerJob: CctpFinalizerJob;
}
68 changes: 68 additions & 0 deletions packages/indexer-database/src/entities/evm/MessageReceived.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import {
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
Index,
PrimaryGeneratedColumn,
Unique,
} from "typeorm";

@Entity({ schema: "evm" })
@Unique("UK_messageReceived_chain_block_txn_log", [
"chainId",
"blockNumber",
"transactionHash",
"logIndex",
])
@Index("IX_messageReceived_finalised", ["finalised"])
@Index("IX_messageReceived_deletedAt", ["deletedAt"])
export class MessageReceived {
@PrimaryGeneratedColumn()
id: number;

@Column()
caller: string;

@Column()
sourceDomain: number;

@Column()
nonce: string;

@Column()
sender: string;

@Column()
finalityThresholdExecuted: number;

@Column()
messageBody: string;

@Column({ type: "bigint" })
chainId: string;

@Column()
blockNumber: number;

@Column()
transactionHash: string;

@Column()
transactionIndex: number;

@Column()
logIndex: number;

@Column()
finalised: boolean;

@Column()
blockTimestamp: Date;

@CreateDateColumn()
createdAt: Date;

@DeleteDateColumn({ nullable: true })
deletedAt?: Date;
}
83 changes: 83 additions & 0 deletions packages/indexer-database/src/entities/evm/MessageSent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
import {
Column,
CreateDateColumn,
DeleteDateColumn,
Entity,
Index,
PrimaryGeneratedColumn,
Unique,
} from "typeorm";

@Entity({ schema: "evm" })
@Unique("UK_messageSent_chain_block_txn_log", [
"chainId",
"blockNumber",
"transactionHash",
"logIndex",
])
@Index("IX_messageSent_finalised", ["finalised"])
@Index("IX_messageSent_deletedAt", ["deletedAt"])
export class MessageSent {
@PrimaryGeneratedColumn()
id: number;

@Column()
message: string;

@Column()
version: number;

@Column()
sourceDomain: number;

@Column()
destinationDomain: number;

@Column()
nonce: string;

@Column()
sender: string;

@Column()
recipient: string;

@Column()
destinationCaller: string;

@Column()
minFinalityThreshold: number;

@Column()
finalityThresholdExecuted: number;

@Column()
messageBody: string;

@Column({ type: "bigint" })
chainId: string;

@Column()
blockNumber: number;

@Column()
transactionHash: string;

@Column()
transactionIndex: number;

@Column()
logIndex: number;

@Column()
finalised: boolean;

@Column()
blockTimestamp: Date;

@CreateDateColumn()
createdAt: Date;

@DeleteDateColumn({ nullable: true })
deletedAt?: Date;
}
Loading