UNPKG

@vechain/vebetterdao-contracts

Version:

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

52 lines (51 loc) 2.08 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 getGmSelectedTokens = 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 ownersWithoutSelectedToken = []; for (let i = 1; i <= Number(totalSupply) + 1; i++) { console.log(`Getting owner of token ${i}`); try { const owner = await galaxyMember.ownerOf(i); const selectedTokenId = await galaxyMember.getSelectedTokenId(owner); if (selectedTokenId === 0n) { console.log(`Token ${i} of owner ${owner} is not selected`); ownersWithoutSelectedToken.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 ownersWithoutSelectedToken) { if (!seenOwners.has(item.owner)) { seenOwners.add(item.owner); uniqueOwners.push(item); } } // Save the unique owners to a file await promises_1.default.writeFile("gmOwnersWithSelected.json", JSON.stringify({ recipients: uniqueOwners }, null, 2)); }; getGmSelectedTokens() .then(() => process.exit(0)) .catch(error => { console.error("Error starting the round:", error); process.exit(1); });