SplitEventModel.ts
1 import type { 2 InferAttributes, 3 InferCreationAttributes, 4 Sequelize, 5 } from 'sequelize'; 6 import { DataTypes, Model } from 'sequelize'; 7 import type { AccountId, Address, BigIntString } from '../core/types'; 8 import getSchema from '../utils/getSchema'; 9 import { COMMON_EVENT_INIT_ATTRIBUTES } from '../core/constants'; 10 import type { IEventModel } from '../events/types'; 11 12 export default class SplitEventModel 13 extends Model< 14 InferAttributes<SplitEventModel>, 15 InferCreationAttributes<SplitEventModel> 16 > 17 implements IEventModel 18 { 19 declare public accountId: AccountId; 20 declare public receiver: AccountId; 21 declare public erc20: Address; 22 declare public amt: BigIntString; 23 24 declare public logIndex: number; 25 declare public blockNumber: number; 26 declare public blockTimestamp: Date; 27 declare public transactionHash: string; 28 29 public static initialize(sequelize: Sequelize): void { 30 this.init( 31 { 32 accountId: { 33 allowNull: false, 34 type: DataTypes.STRING, 35 }, 36 receiver: { 37 allowNull: false, 38 type: DataTypes.STRING, 39 }, 40 erc20: { 41 allowNull: false, 42 type: DataTypes.STRING, 43 }, 44 amt: { 45 allowNull: false, 46 type: DataTypes.STRING, 47 }, 48 ...COMMON_EVENT_INIT_ATTRIBUTES, 49 }, 50 { 51 sequelize, 52 schema: getSchema(), 53 tableName: 'split_events', 54 underscored: true, 55 timestamps: true, 56 indexes: [ 57 { 58 fields: ['receiver'], 59 name: `idx_split_events_receiver`, 60 }, 61 { 62 fields: ['accountId', 'receiver'], 63 name: `idx_split_events_accountId_receiver`, 64 }, 65 ], 66 }, 67 ); 68 } 69 }