@vechain/vebetterdao-contracts
Version:
Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.
57 lines (56 loc) โข 2.9 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("@repo/config");
const contracts_1 = require("@repo/config/contracts");
const hardhat_1 = require("hardhat");
async function main() {
if (!process.env.NEXT_PUBLIC_APP_ENV) {
throw new Error("Missing NEXT_PUBLIC_APP_ENV");
}
const config = (0, config_1.getConfig)(process.env.NEXT_PUBLIC_APP_ENV);
const contractsConfig = (0, contracts_1.getContractsConfig)(process.env.NEXT_PUBLIC_APP_ENV);
const levels = [2, 3, 4, 5, 6, 7, 8, 9, 10];
const b3trToUpgrade = contractsConfig.GM_NFT_B3TR_REQUIRED_TO_UPGRADE_TO_LEVEL_V2;
console.log(`๐ฃ Executing function: setB3TRtoUpgradeToLevel`);
console.log(`๐ Contract Address: ${config.galaxyMemberContractAddress}`);
console.log(`๐ Network: ${config.network.name}`);
console.log(`๐ ๏ธ Parameters:`);
console.table(levels.map((level, index) => ({
Level: level,
"B3TR ": b3trToUpgrade[index].toString(),
"B3TR (formatted)": Number(hardhat_1.ethers.formatEther(b3trToUpgrade[index].toString())).toFixed(2),
})));
const emissionsContract = await hardhat_1.ethers.getContractAt("Emissions", config.emissionsContractAddress);
const emissionsVersion = await emissionsContract.version();
if (parseInt(emissionsVersion) !== 3) {
console.error(`โ Emissions version is not 3: ${emissionsVersion}`);
console.error("Please upgrade Emissions contract first");
process.exit(1);
}
const voterRewardsContract = await hardhat_1.ethers.getContractAt("VoterRewards", config.voterRewardsContractAddress);
const voterRewardsVersion = await voterRewardsContract.version();
if (parseInt(voterRewardsVersion) !== 5) {
console.error(`โ VoterRewards version is not 5: ${voterRewardsVersion}`);
console.error("Please upgrade VoterRewards contract first");
process.exit(1);
}
const galaxyMemberContract = await hardhat_1.ethers.getContractAt("GalaxyMember", config.galaxyMemberContractAddress);
const tx = await galaxyMemberContract.setB3TRtoUpgradeToLevel(b3trToUpgrade);
await tx.wait();
console.log(`๐ Transaction executed @Block: ${tx.blockNumber}`);
console.log(`๐งพ Transaction Hash: ${tx.hash}`);
console.log(`๐ Verifying new B3TR upgrade costs...`);
const levelChecks = await Promise.all(Array.from({ length: 10 }, (_, i) => galaxyMemberContract.getB3TRtoUpgradeToLevel(i + 1)));
console.table(levelChecks.map((amount, i) => ({
Level: i + 1,
"B3TR ": amount.toString(),
"B3TR (formatted)": Number(hardhat_1.ethers.formatEther(amount)).toFixed(2),
})));
console.log(`โ
Execution completed successfully!`);
process.exit(0);
}
// Execute the main function
main().catch(error => {
console.error(error);
process.exit(1);
});