UNPKG

@vechain/vebetterdao-contracts

Version:

Open-source repository that houses the smart contracts powering the decentralized VeBetterDAO on the VeChain Thor blockchain.

48 lines (47 loc) 1.78 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("@repo/config"); const typechain_types_1 = require("../../typechain-types"); const hardhat_1 = require("hardhat"); const promises_1 = __importDefault(require("fs/promises")); /** * Starts a new round of emissions. * * @throws if the round cannot be started. */ const getGmOwners = async () => { const [signer] = await hardhat_1.ethers.getSigners(); const galaxyMember = typechain_types_1.GalaxyMember__factory.connect((0, config_1.getConfig)().galaxyMemberContractAddress, signer); const totalSupply = await galaxyMember.totalSupply(); const owners = []; for (let i = 1; i <= Number(totalSupply) + 1; i++) { console.log(`Getting owner of token ${i}`); try { const owner = await galaxyMember.ownerOf(i); owners.push({ owner, tokenId: i.toString() }); } catch (e) { console.log(`Token ${i} does not exist or has been burned`); } } // Remove duplicate owners, keeping only the first occurrence const uniqueOwners = []; const seenOwners = new Set(); for (const item of owners) { if (!seenOwners.has(item.owner)) { seenOwners.add(item.owner); uniqueOwners.push(item); } } // Save the unique owners to a file await promises_1.default.writeFile("gmOwners.json", JSON.stringify({ recipients: uniqueOwners }, null, 2)); }; getGmOwners() .then(() => process.exit(0)) .catch(error => { console.error("Error starting the round:", error); process.exit(1); });