//
// 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 Proposal {
  @PrimaryColumn('varchar')
    id!: string;

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

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

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

  @Column('varchar')
    description!: string;

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

  @Column('boolean')
    executed!: boolean;

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

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

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

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

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

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

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

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