From 98365afb127a683c49609cc8ac57684691fc32e7 Mon Sep 17 00:00:00 2001 From: Chewing Glass Date: Tue, 17 Oct 2023 14:11:45 -0400 Subject: [PATCH] fix close gov script --- packages/crons/src/close-governance.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/crons/src/close-governance.ts b/packages/crons/src/close-governance.ts index 9ae3d9910..ff7cf2785 100644 --- a/packages/crons/src/close-governance.ts +++ b/packages/crons/src/close-governance.ts @@ -32,6 +32,7 @@ import pLimit from "p-limit"; const stateProgram = await initState(provider); const proposalProgram = await initProposal(provider); const vsrProgram = await initVsr(provider); + let closedProposals = new Set(); for (const orgName of ["Helium", "Helium MOBILE", "Helium IOT"]) { console.log(`Checking for expired proposals in ${orgName}`); const organizationK = organizationKey(orgName)[0]; @@ -66,6 +67,17 @@ import pLimit from "p-limit"; }) ); + const proposalsNow = await Promise.all( + proposalKeys.map(async (p) => ({ + account: await proposalProgram.account.proposalV0.fetch(p), + pubkey: p, + })) + ); + for (const proposal of proposalsNow) { + if (typeof proposal.account.state.voting === "undefined") { + closedProposals.add(proposal.pubkey.toBase58()); + } + } const txs = chunks(resolveIxs, 10).map((ixs) => { const tx = new Transaction({ feePayer: provider.wallet.publicKey, @@ -78,7 +90,9 @@ import pLimit from "p-limit"; } const markers = (await vsrProgram.account.voteMarkerV0.all()).filter( - (m) => !m.account.relinquished + (m) => + !m.account.relinquished && + closedProposals.has(m.account.proposal.toBase58()) ); const limit = pLimit(100); const relinquishIxns = await Promise.all(