import { Model, RelationMappings, RelationMappingsThunk } from 'objection';
import { BaseModel } from './base.model';

export class Wallet extends BaseModel {
  static tableName = 'wallets';

  id!: string;
  address!: string;
  encryptedPrivateKey!: string;
  ownerType!: 'USER' | 'DEPARTMENT';
  ownerId!: string;
  isActive!: boolean;
  createdAt!: Date;
  updatedAt!: Date;

  static get jsonSchema() {
    return {
      type: 'object',
      required: ['address', 'encryptedPrivateKey', 'ownerType', 'ownerId'],
      properties: {
        id: { type: 'string', format: 'uuid' },
        address: { type: 'string', maxLength: 42 },
        encryptedPrivateKey: { type: 'string' },
        ownerType: { type: 'string', enum: ['USER', 'DEPARTMENT'] },
        ownerId: { type: 'string', format: 'uuid' },
        isActive: { type: 'boolean', default: true },
        createdAt: { type: 'string', format: 'date-time' },
        updatedAt: { type: 'string', format: 'date-time' },
      },
    };
  }
}
