import { __decorate, __metadata } from "tslib";
import { AliasHash } from '@polyaztec/barretenberg/account_id';
import { GrumpkinAddress } from '@polyaztec/barretenberg/address';
import { AfterLoad, Column, Entity, Index, PrimaryColumn } from 'typeorm';
import { Alias } from '../database.js';
import { aliasHashTransformer, grumpkinAddressTransformer } from './transformer.js';
let AliasDao = class AliasDao {
    constructor(init) {
        Object.assign(this, init);
    }
    afterLoad() {
        if (this.noteCommitment1 === null) {
            delete this.noteCommitment1;
        }
        if (this.spendingPublicKeyX === null) {
            delete this.spendingPublicKeyX;
        }
    }
};
__decorate([
    PrimaryColumn('blob', { transformer: [aliasHashTransformer] }),
    __metadata("design:type", AliasHash)
], AliasDao.prototype, "aliasHash", void 0);
__decorate([
    Column('blob', { transformer: [grumpkinAddressTransformer] }),
    Index(),
    __metadata("design:type", GrumpkinAddress)
], AliasDao.prototype, "accountPublicKey", void 0);
__decorate([
    Column(),
    __metadata("design:type", Number)
], AliasDao.prototype, "index", void 0);
__decorate([
    Column({ nullable: true }),
    __metadata("design:type", Buffer)
], AliasDao.prototype, "noteCommitment1", void 0);
__decorate([
    Column({ nullable: true }),
    __metadata("design:type", Buffer)
], AliasDao.prototype, "spendingPublicKeyX", void 0);
__decorate([
    AfterLoad(),
    __metadata("design:type", Function),
    __metadata("design:paramtypes", []),
    __metadata("design:returntype", void 0)
], AliasDao.prototype, "afterLoad", null);
AliasDao = __decorate([
    Entity({ name: 'alias' }),
    __metadata("design:paramtypes", [Alias])
], AliasDao);
export { AliasDao };
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWxpYXNfZGFvLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2RhdGFiYXNlL25vZGUvYWxpYXNfZGFvLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sb0NBQW9DLENBQUM7QUFDL0QsT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