@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
39 lines (38 loc) • 1.78 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("@repo/config");
const typechain_types_1 = require("../../typechain-types");
const hardhat_1 = require("hardhat");
const helpers_1 = require("../../test/helpers");
/**
* Mints blocks on the local Thor solo node (which runs in --on-demand mode)
* by sending dummy VET transfers, until the chain reaches the block at which
* the next emissions cycle (round) can start.
*
* Does NOT call `Emissions.distribute()` — only advances the block height.
*/
const advanceToNextRound = async () => {
const [signer] = await hardhat_1.ethers.getSigners();
const emissions = typechain_types_1.Emissions__factory.connect((0, config_1.getConfig)().emissionsContractAddress, signer);
const currentCycle = await emissions.getCurrentCycle();
const nextCycleBlock = await emissions.getNextCycleBlock();
const currentBlock = await hardhat_1.ethers.provider.getBlockNumber();
const blocksToMint = Number(nextCycleBlock) - currentBlock;
console.log(`Current cycle: ${currentCycle}`);
console.log(`Current block: ${currentBlock}`);
console.log(`Next cycle block: ${nextCycleBlock}`);
if (blocksToMint <= 0) {
console.log("Already at or past the next cycle block. Nothing to mint.");
return;
}
console.log(`Minting ${blocksToMint} block(s) via VTHO transfers...`);
await (0, helpers_1.moveBlocks)(blocksToMint);
const newBlock = await hardhat_1.ethers.provider.getBlockNumber();
console.log(`Reached block ${newBlock}. Next round can now be started.`);
};
advanceToNextRound()
.then(() => process.exit(0))
.catch(error => {
console.error("Error advancing to next round:", error);
process.exit(1);
});