hardhat-output-validator
Version:
Zero-config Hardhat plugin to check the build output of Solidity contracts
46 lines • 1.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.checkEvent = void 0;
const types_1 = require("../types");
const index_1 = require("../index");
const utils_1 = require("../utils");
const checkEvent = (entity, { addError }, info) => {
var _a, _b, _c, _d;
const config = (0, index_1.getConfig)();
const defaultSeverity = (0, index_1.getDefaultSeverity)();
if (!config.checks.events) {
return;
}
let hasUserDoc = true;
let hasDevDoc = true;
if (config.checks.missingUserDoc &&
((_a = config.checks.userDoc) === null || _a === void 0 ? void 0 : _a.events) &&
info.userdoc) {
const userDocEntry = (0, utils_1.findByName)(info.userdoc.events, entity.name);
if (!userDocEntry || !userDocEntry.notice) {
hasUserDoc = false;
}
}
if (config.checks.missingDevDoc &&
((_b = config.checks.devDoc) === null || _b === void 0 ? void 0 : _b.events) &&
info.devdoc) {
const devDocEntry = (0, utils_1.findByName)(info.devdoc.events, entity.name);
if (!devDocEntry) {
hasDevDoc = false;
}
}
if (!config.strict) {
if (!hasDevDoc && !hasUserDoc) {
addError(types_1.ErrorType.MissingUserOrDevDoc, defaultSeverity, `Event: (${entity.name})`);
}
}
else {
// STRICT
const userSev = ((_c = config.checks.userDoc) === null || _c === void 0 ? void 0 : _c.events) || config.checks.missingUserDoc;
addError(types_1.ErrorType.MissingUserDoc, userSev, `Event: (${entity.name})`);
const severity = ((_d = config.checks.devDoc) === null || _d === void 0 ? void 0 : _d.events) || config.checks.missingDevDoc;
addError(types_1.ErrorType.MissingUserDoc, severity, `Event: (${entity.name})`);
}
};
exports.checkEvent = checkEvent;
//# sourceMappingURL=0events.js.map