hardhat-graph-protocol
Version:
A hardhat plugin that extends the runtime environment to inject additional functionality related to the usage of the Graph Protocol.
32 lines • 1.25 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.useHardhatProject = useHardhatProject;
exports.loadHardhatContext = loadHardhatContext;
exports.resetHardhatContext = resetHardhatContext;
const plugins_testing_1 = require("hardhat/plugins-testing");
const path_1 = __importDefault(require("path"));
function useHardhatProject(fixtureProjectName, network) {
beforeEach('Loading hardhat environment', function () {
this.hre = loadHardhatContext(fixtureProjectName, network);
});
afterEach('Resetting hardhat', function () {
resetHardhatContext();
});
}
function loadHardhatContext(fixtureProjectName, network) {
resetHardhatContext();
delete process.env.HARDHAT_NETWORK;
process.chdir(path_1.default.join(__dirname, 'fixtures', fixtureProjectName));
if (network !== undefined) {
process.env.HARDHAT_NETWORK = network;
}
return require('hardhat');
}
function resetHardhatContext() {
(0, plugins_testing_1.resetHardhatContext)();
delete process.env.HARDHAT_NETWORK;
}
//# sourceMappingURL=helpers.js.map