# All files / dist/indexer-management/models poi-dispute.js

12.77% Statements 6/47
0% Branches 0/30
0% Functions 0/10
12.77% Lines 6/47

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182

    3x
    3x
    3x
    3x

    3x
    3x

     "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