@enjinstarter/hardhat-oklink-verify
Version:
Hardhat plugin for verifying contracts on OKLink
46 lines (43 loc) • 1.94 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.oklinkConfigExtender = exports.verifyAllowedChains = void 0;
const plugins_1 = require("hardhat/plugins");
const ChainConfig_1 = require("./ChainConfig");
const constants_1 = require("./constants");
const verifyAllowedChains = (oklinkConfig) => {
if (oklinkConfig.apiKey === null ||
oklinkConfig.apiKey === undefined ||
typeof oklinkConfig.apiKey !== "object") {
return;
}
// check if any of the configured api keys is for an unsupported network
const builtinChains = Object.keys(ChainConfig_1.chainConfig);
const customChains = oklinkConfig.customChains.map((x) => x.network);
const allowedChains = [...builtinChains, ...customChains];
const actual = Object.keys(oklinkConfig.apiKey);
const invalidNetwork = actual.find((chain) => !allowedChains.includes(chain));
if (invalidNetwork !== undefined) {
throw new plugins_1.NomicLabsHardhatPluginError(constants_1.pluginName, `You set an OKLink API token for the network "${invalidNetwork}" but the plugin doesn't support it, or it's spelled incorrectly.
To see the list of supported networks, run this command:
npx hardhat oklink-verify --list-networks
Learn more at https://hardhat.org/verify-multiple-networks`);
}
};
exports.verifyAllowedChains = verifyAllowedChains;
const oklinkConfigExtender = (resolvedConfig, config) => {
const defaultConfig = {
apiKey: "",
customChains: [],
licenseType: "",
};
if (config.oklink !== undefined) {
const { cloneDeep } = require("lodash");
const customConfig = cloneDeep(config.oklink);
resolvedConfig.oklink = Object.assign(Object.assign({}, defaultConfig), customConfig);
}
else {
resolvedConfig.oklink = defaultConfig;
}
};
exports.oklinkConfigExtender = oklinkConfigExtender;
//# sourceMappingURL=config.js.map