"use strict";
/* eslint-disable @typescript-eslint/no-empty-interface */
Object.defineProperty(exports, "__esModule", { value: true });
exports.definePOIDisputeModels = exports.POIDispute = void 0;
const sequelize_1 = require("sequelize");
const ethers_1 = require("ethers");
class POIDispute extends sequelize_1.Model {
    // eslint-disable-next-line @typescript-eslint/ban-types
    toGraphQL() {
        return Object.assign(Object.assign({}, this.toJSON()), { __typename: 'POIDispute' });
    }
}
exports.POIDispute = POIDispute;
exports.definePOIDisputeModels = (sequelize) => {
    POIDispute.init({
        allocationID: {
            type: sequelize_1.DataTypes.STRING,
            allowNull: false,
            primaryKey: true,
            unique: true,
            validate: {
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                isHex: (value) => {
                    if (typeof value !== 'string') {
                        throw new Error('Allocation ID must be a string');
                    }
                    // "0x..." is ok
                    if (ethers_1.utils.isHexString(value, 20)) {
                        return;
                    }
                    throw new Error(`Allocation ID must be a valid hex string`);
                },
            },
        },
        subgraphDeploymentID: {
            type: sequelize_1.DataTypes.STRING,
            allowNull: false,
            validate: {
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                isHex: (value) => {
                    if (typeof value !== 'string') {
                        throw new Error('Subgraph deployment ID must be a string');
                    }
                    return;
                },
            },
        },
        allocationIndexer: {
            type: sequelize_1.DataTypes.STRING,
            allowNull: false,
            validate: {
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                isValid: (value) => {
                    if (typeof value !== 'string') {
                        throw new Error('Allocation Indexer ID must be a string');
                    }
                    // "0x..." is ok
                    if (ethers_1.utils.isHexString(value, 20)) {
                        return;
                    }
                    //TODO: Ensure this error message gets logged when this throws (repeat for each validation function)
                    throw new Error(`Allocation Indexer ID must be a valid hex string`);
                },
            },
        },
        allocationAmount: {
            type: sequelize_1.DataTypes.DECIMAL,
            allowNull: false,
            validate: {
                min: 0.0,
            },
        },
        allocationProof: {
            type: sequelize_1.DataTypes.STRING,
            allowNull: false,
            validate: {
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                isHex: (value) => {
                    if (typeof value !== 'string') {
                        throw new Error('Allocation POI must be a string');
                    }
                    // "0x..." is ok
                    if (ethers_1.utils.isHexString(value, 32)) {
                        return;
                    }
                    throw new Error(`Allocation POI must be a valid hex string`);
                },
            },
        },
        closedEpoch: {
            type: sequelize_1.DataTypes.INTEGER,
            allowNull: false,
        },
        closedEpochReferenceProof: {
            type: sequelize_1.DataTypes.STRING,
            allowNull: true,
            validate: {
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                isHex: (value) => {
                    if (typeof value !== 'string') {
                        throw new Error('Allocation POI must be a string');
                    }
                    // "0x..." is ok
                    if (ethers_1.utils.isHexString(value, 32)) {
                        return;
                    }
                    throw new Error(`Allocation POI must be a valid hex string`);
                },
            },
        },
        closedEpochStartBlockHash: {
            type: sequelize_1.DataTypes.STRING,
            allowNull: false,
            validate: {
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                isHex: (value) => {
                    if (typeof value !== 'string') {
                        throw new Error('Allocation closed block hash must be a string');
                    }
                    // "0x..." is ok
                    if (ethers_1.utils.isHexString(value, 32)) {
                        return;
                    }
                    throw new Error(`Allocation closed block hash must be a valid hex string`);
                },
            },
        },
        closedEpochStartBlockNumber: {
            type: sequelize_1.DataTypes.INTEGER,
            allowNull: false,
        },
        previousEpochReferenceProof: {
            type: sequelize_1.DataTypes.STRING,
            allowNull: true,
            validate: {
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                isHex: (value) => {
                    if (typeof value !== 'string') {
                        throw new Error('Allocation POI must be a string');
                    }
                    // "0x..." is ok
                    if (ethers_1.utils.isHexString(value, 32)) {
                        return;
                    }
                    throw new Error(`Allocation POI must be a valid hex string`);
                },
            },
        },
        previousEpochStartBlockHash: {
            type: sequelize_1.DataTypes.STRING,
            allowNull: false,
            validate: {
                // eslint-disable-next-line @typescript-eslint/no-explicit-any
                isHex: (value) => {
                    if (typeof value !== 'string') {
                        throw new Error('Allocation closed block hash must be a string');
                    }
                    // "0x..." is ok
                    if (ethers_1.utils.isHexString(value, 32)) {
                        return;
                    }
                    throw new Error(`Allocation closed block hash must be a valid hex string`);
                },
            },
        },
        previousEpochStartBlockNumber: {
            type: sequelize_1.DataTypes.INTEGER,
            allowNull: false,
        },
        status: {
            type: sequelize_1.DataTypes.STRING,
            allowNull: false,
        },
    }, {
        modelName: 'POIDispute',
        sequelize,
    });
    return {
        ['POIDispute']: POIDispute,
    };
};
//# sourceMappingURL=poi-dispute.js.map