UNPKG

hardhat-abi-exporter

Version:

Export Ethereum smart contract ABIs on compilation

49 lines (48 loc) 1.81 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const package_json_1 = require("../package.json"); require("./tasks/clean"); require("./tasks/clear_abi"); require("./tasks/compile"); require("./tasks/export_abi"); const config_1 = require("hardhat/config"); const plugins_1 = require("hardhat/plugins"); require("hardhat/types/config"); const path_1 = __importDefault(require("path")); const DEFAULT_CONFIG = { path: './abi', runOnCompile: false, clear: false, flat: false, only: [], except: [], spacing: 2, pretty: false, filter: () => true, // `rename` is not defaulted as it may depend on `flat` option // `format` is not defaulted as it may depend on `pretty` option }; (0, config_1.extendConfig)((config, userConfig) => { config.abiExporter = [userConfig.abiExporter].flat().map((el) => { const conf = Object.assign({}, DEFAULT_CONFIG, el); if (conf.flat && conf.rename) { throw new plugins_1.HardhatPluginError(package_json_1.name, '`flat` & `rename` config cannot be specified together'); } if (conf.pretty && conf.format) { throw new plugins_1.HardhatPluginError(package_json_1.name, '`pretty` & `format` config cannot be specified together'); } if (conf.flat) { conf.rename = (sourceName, contractName) => contractName; } if (!conf.rename) { conf.rename = (sourceName, contractName) => path_1.default.join(sourceName, contractName); } if (!conf.format) { conf.format = conf.pretty ? 'minimal' : 'json'; } return conf; }); });