From f4283855710f792e131a39a0347d881ae714b575 Mon Sep 17 00:00:00 2001 From: Pileks Date: Thu, 13 Aug 2026 21:18:37 -0700 Subject: [PATCH] team sponsor via squads script --- Anchor.toml | 1 + scripts/v0.6/sponsorProposal.ts | 61 +++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 scripts/v0.6/sponsorProposal.ts diff --git a/Anchor.toml b/Anchor.toml index 1faca827..25689bad 100644 --- a/Anchor.toml +++ b/Anchor.toml @@ -57,6 +57,7 @@ v06-collect-meteora-damm-fees = "yarn run tsx scripts/v0.6/collectMeteoraDammFee v06-return-funds = "yarn run tsx scripts/v0.6/returnFunds.ts" v06-dump-daos = "yarn run tsx scripts/v0.6/dumpDaos.ts" v06-migrate-daos = "yarn run tsx scripts/v0.6/migrateDaos.ts" +v06-sponsor-proposal = "yarn run tsx scripts/v0.6/sponsorProposal.ts" v07-collect-meteora-damm-fees = "yarn run tsx scripts/v0.7/collectMeteoraDammFees.ts" v07-launch-template = "yarn run tsx scripts/v0.7/launchTemplate.ts" v07-start-launch = "yarn run tsx scripts/v0.7/startLaunch.ts" diff --git a/scripts/v0.6/sponsorProposal.ts b/scripts/v0.6/sponsorProposal.ts new file mode 100644 index 00000000..a9cd583b --- /dev/null +++ b/scripts/v0.6/sponsorProposal.ts @@ -0,0 +1,61 @@ +import * as anchor from "@coral-xyz/anchor"; +import { FutarchyClient } from "@metadaoproject/programs/futarchy/v0.6"; +import { PublicKey, TransactionMessage } from "@solana/web3.js"; +import bs58 from "bs58"; + +// Set the DAO and the proposal its team wants to sponsor before running the script +const DAO = new PublicKey(""); +const PROPOSAL = new PublicKey(""); + +const provider = anchor.AnchorProvider.env(); +const futarchyClient = FutarchyClient.createClient({ provider }); + +const sponsorProposal = async () => { + const dao = await futarchyClient.fetchDao(DAO); + + if (!dao) { + throw new Error("DAO not found"); + } + + const proposal = await futarchyClient.fetchProposal(PROPOSAL); + + if (!proposal) { + throw new Error("Proposal not found"); + } + + if (!proposal.dao.equals(DAO)) { + throw new Error( + `Proposal belongs to DAO ${proposal.dao.toBase58()}, not ${DAO.toBase58()}`, + ); + } + + console.log(`Proposal: ${PROPOSAL.toBase58()}`); + console.log(`DAO: ${DAO.toBase58()}`); + console.log(`Team address: ${dao.teamAddress.toBase58()}`); + + const sponsorIx = await futarchyClient + .sponsorProposalIx({ + proposal: PROPOSAL, + dao: DAO, + teamAddress: dao.teamAddress, + }) + .instruction(); + + const transactionMessage = new TransactionMessage({ + instructions: [sponsorIx], + payerKey: dao.teamAddress, + recentBlockhash: (await provider.connection.getLatestBlockhash()).blockhash, + }); + + const serializedMessage = transactionMessage + .compileToLegacyMessage() + .serialize(); + + console.log("\nTransaction message (base58):"); + console.log(bs58.encode(serializedMessage)); + + console.log("\nTransaction message (base64):"); + console.log(serializedMessage.toString("base64")); +}; + +sponsorProposal().catch(console.error);