hardhat
Version:
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
25 lines • 1.22 kB
JavaScript
import { setGasAnalyticsManager } from "../helpers/accessors.js";
let GasAnalyticsManagerImplementation;
export default async () => ({
created: async (context, hre) => {
if (!context.globalOptions.gasStats &&
context.globalOptions.gasStatsJson === undefined) {
return;
}
if (GasAnalyticsManagerImplementation === undefined) {
({ GasAnalyticsManagerImplementation } = await import("../gas-analytics-manager.js"));
}
const gasAnalyticsManager = new GasAnalyticsManagerImplementation(hre.config.paths.cache);
setGasAnalyticsManager(hre, gasAnalyticsManager);
// NOTE: We register this hook dynamically to avoid a circular dependency
// between gas-analytics and network-manager plugins. The network-manager
// checks for the existence of onGasReported handlers to determine if gas
// analytics is enabled, rather than directly checking the global option.
hre.hooks.registerHandlers("network", {
onGasMeasurement: (_context, gasMeasurement) => {
gasAnalyticsManager.addGasMeasurement(gasMeasurement);
},
});
},
});
//# sourceMappingURL=hre.js.map