//
// Copyright 2021 Vulcanize, Inc.
//

import { Entity, PrimaryColumn, Column, Index } from 'typeorm';
import { decimalTransformer, bigintTransformer } from '@cerc-io/util';
import { Decimal } from 'decimal.js';

@Entity()
@Index(['blockNumber'])
export class DistributionPeriod {
  @PrimaryColumn('varchar')
    id!: string;

  @PrimaryColumn('varchar', { length: 66 })
    blockHash!: string;

  @Column('integer')
    blockNumber!: number;

  @Column('numeric', { transformer: bigintTransformer })
    distributionId!: bigint;

  @Column('numeric', { transformer: bigintTransformer })
    startBlock!: bigint;

  @Column('numeric', { transformer: bigintTransformer })
    endBlock!: bigint;

  @Column('varchar', { nullable: true })
    topSlate!: string | null;

  @Column('varchar', { array: true })
    slatesSubmitted!: string[];

  @Column('numeric', { transformer: decimalTransformer })
    fundsAvailable!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    delegationRewardsClaimed!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    fundingVotePowerUsed!: Decimal;

  @Column('numeric', { transformer: decimalTransformer })
    screeningVotesCast!: Decimal;

  @Column('varchar', { array: true })
    votes!: string[];

  @Column('varchar', { array: true })
    proposals!: string[];

  @Column('numeric', { transformer: decimalTransformer })
    totalTokensDistributed!: Decimal;

  @Column('boolean', { default: false })
    isPruned!: boolean;

  @Column('boolean', { default: false })
    isRemoved!: boolean;
}
