import { __decorate, __metadata } from "tslib";
import { GrumpkinAddress } from '@polyaztec/barretenberg/address';
import { BridgeCallData } from '@polyaztec/barretenberg/bridge_call_data';
import { TxId } from '@polyaztec/barretenberg/tx_id';
import { AfterInsert, AfterLoad, AfterUpdate, Column, Entity, Index, PrimaryColumn } from 'typeorm';
import { bigintTransformer, bridgeCallDataTransformer, grumpkinAddressTransformer, txIdTransformer, } from './transformer.js';
let DefiTxDao = class DefiTxDao {
    constructor(init) {
        Object.assign(this, init);
    }
    afterLoad() {
        if (this.settled === null) {
            delete this.settled;
        }
        if (this.interactionNonce === null) {
            delete this.interactionNonce;
        }
        if (this.isAsync === null) {
            delete this.isAsync;
        }
        if (this.success === null) {
            delete this.success;
        }
        if (this.outputValueA === null) {
            delete this.outputValueA;
        }
        if (this.outputValueB === null) {
            delete this.outputValueB;
        }
        if (this.finalised === null) {
            delete this.finalised;
        }
        if (this.claimSettled === null) {
            delete this.claimSettled;
        }
        if (this.claimTxId === null) {
            delete this.claimTxId;
        }
    }
};
__decorate([
    PrimaryColumn('blob', { transformer: [txIdTransformer] }),
    __metadata("design:type", TxId)
], DefiTxDao.prototype, "txId", void 0);
__decorate([
    Index({ unique: false }),
    Column('blob', { transformer: [grumpkinAddressTransformer] }),
    __metadata("design:type", GrumpkinAddress)
], DefiTxDao.prototype, "userId", void 0);
__decorate([
    Column('blob', { transformer: [bridgeCallDataTransformer] }),
    __metadata("design:type", BridgeCallData)
], DefiTxDao.prototype, "bridgeCallData", void 0);
__decorate([
    Column('text', { transformer: [bigintTransformer] }),
    __metadata("design:type", typeof BigInt === "function" ? BigInt : Object)
], DefiTxDao.prototype, "depositValue", void 0);
__decorate([
    Column('text', { transformer: [bigintTransformer] }),
    __metadata("design:type", typeof BigInt === "function" ? BigInt : Object)
], DefiTxDao.prototype, "txFee", void 0);
__decorate([
    Column(),
    __metadata("design:type", Number)
], DefiTxDao.prototype, "txRefNo", void 0);
__decorate([
    Column(),
    __metadata("design:type", Date)
], DefiTxDao.prototype, "created", void 0);
__decorate([
    Column(),
    __metadata("design:type", Buffer)
], DefiTxDao.prototype, "partialState", void 0);
__decorate([
    Column(),
    __metadata("design:type", Buffer)
], DefiTxDao.prototype, "partialStateSecret", void 0);
__decorate([
    Column({ nullable: true }),
    Index(),
    __metadata("design:type", Buffer)
], DefiTxDao.prototype, "nullifier", void 0);
__decorate([
    Column({ nullable: true }),
    __metadata("design:type", Date)
], DefiTxDao.prototype, "settled", void 0);
__decorate([
    Index({ unique: false }),
    Column({ nullable: true }),
    __metadata("design:type", Number)
], DefiTxDao.prototype, "interactionNonce", void 0);
__decorate([
    Column({ nullable: true }),
    __metadata("design:type", Boolean)
], DefiTxDao.prototype, "isAsync", void 0);
__decorate([
    Column({ nullable: true }),
    __metadata("design:type", Boolean)
], DefiTxDao.prototype, "success", void 0);
__decorate([
    Column('text', { transformer: [bigintTransformer], nullable: true }),
    __metadata("design:type", typeof BigInt === "function" ? BigInt : Object)
], DefiTxDao.prototype, "outputValueA", void 0);
__decorate([
    Column('text', { transformer: [bigintTransformer], nullable: true }),
    __metadata("design:type", typeof BigInt === "function" ? BigInt : Object)
], DefiTxDao.prototype, "outputValueB", void 0);
__decorate([
    Column({ nullable: true }),
    __metadata("design:type", Date)
], DefiTxDao.prototype, "finalised", void 0);
__decorate([
    Column({ nullable: true }),
    __metadata("design:type", Date)
], DefiTxDao.prototype, "claimSettled", void 0);
__decorate([
    Column('blob', { nullable: true, transformer: [txIdTransformer] }),
    __metadata("design:type", TxId)
], DefiTxDao.prototype, "claimTxId", void 0);
__decorate([
    AfterLoad(),
    AfterInsert(),
    AfterUpdate(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], DefiTxDao.prototype, "afterLoad", null);
DefiTxDao = __decorate([
    Entity({ name: 'defiTx' }),
    __metadata("design:paramtypes", [Object])
], DefiTxDao);
export { DefiTxDao };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjo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