UNPKG

hardhat-output-validator

Version:

Zero-config Hardhat plugin to check the build output of Solidity contracts

46 lines 2.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkForErrors = void 0; const types_1 = require("../types"); const errors_1 = require("../errors"); const utils_1 = require("../utils"); const _0ctor_1 = require("./0ctor"); const _0events_1 = require("./0events"); const _0funcs_1 = require("./0funcs"); const index_1 = require("../index"); const checkForErrors = (info) => { var _a, _b; const config = (0, index_1.getConfig)(); const buildInfo = (0, index_1.getFullBuildInfo)(); const errorHandler = (0, errors_1.getErrorHandler)(info.filePath, info.fileName); const { addError, getAll } = errorHandler; if (config.checks.title && !((_a = info.devdoc) === null || _a === void 0 ? void 0 : _a.title)) { addError(types_1.ErrorType.MissingTitle, config.checks.title); } if (config.checks.details && !((_b = info.devdoc) === null || _b === void 0 ? void 0 : _b.details)) { addError(types_1.ErrorType.MissingDetails, config.checks.details); } if (Array.isArray(info.abi)) { // Loops through the abi and for each function/event/var check in the user/dev doc. info.abi.forEach((entity) => { entity.name = `${entity.name}(${entity.inputs ? entity.inputs.map((i) => i.type).join(',') : ''})`; const isExternal = (0, utils_1.checkIsExternalDependency)(info.filePath, info.fileName, entity, buildInfo); if (isExternal) { return; } if (entity.type === 'constructor') { (0, _0ctor_1.checkConstructor)(entity, errorHandler, info); } else if (entity.type === 'event') { (0, _0events_1.checkEvent)(entity, errorHandler, info); } else if (entity.type === 'function') { (0, _0funcs_1.checkFunction)(entity, errorHandler, info, buildInfo); } }); } // TODO: check for userDoc.errors return getAll(); }; exports.checkForErrors = checkForErrors; //# sourceMappingURL=index.js.map