UNPKG

@atixlabs/hardhat-time-n-mine

Version:

Hardhat plugin to manipulate time and mine blocks

30 lines 2.23 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const config_1 = require("hardhat/config"); const plugins_1 = require("hardhat/plugins"); const time_and_mine_1 = __importDefault(require("./time-and-mine")); config_1.extendEnvironment((hre) => (hre.timeAndMine = plugins_1.lazyObject(() => time_and_mine_1.default(hre)))); config_1.task("mine") .setDescription("mines a single block") .addOptionalParam("amount", "amount of blocks to be mined", 1, config_1.types.int) .setAction((args, hre) => hre.timeAndMine.mine(args.amount)); config_1.task("setTime") .setDescription("mines a single block with a given time, effectively setting the time of the blockchain") .addPositionalParam("time", "timestamp of the next block", undefined, config_1.types.int, false) .setAction((args, hre) => hre.timeAndMine.setTime(args.time)); config_1.task("setTimeIncrease") .setDescription("makes the next block timestamp increase the given delta with respect to the current block timestamp") .addPositionalParam("delta", "difference between the current timestamp and the next. Can be a number representing the seconds or a string representing the delta", undefined, config_1.types.string, false) .setAction((args, hre) => hre.timeAndMine.setTimeIncrease(args.delta)); config_1.task("increaseTime") .setDescription("adds the given delta. NOTICE: this counts 'real' ellapsing time and is not idempotent, we recommend you user setTimeIncrease") .addPositionalParam("delta", "difference to add to the current time tracker. Can be a number representing the seconds or a string representing the delta", undefined, config_1.types.string, false) .setAction((args, hre) => hre.timeAndMine.increaseTime(args.delta)); config_1.task("setTimeNextBlock") .setDescription("set the timestamp of the next block(does not actually mine)") .addPositionalParam("time", "timestamp of the next block", undefined, config_1.types.int, false) .setAction((args, hre) => hre.timeAndMine.setTimeNextBlock(args.time)); //# sourceMappingURL=index.js.map