Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Anchor.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
solana_version = "1.17.34"

Expand Down Expand Up @@ -57,6 +57,7 @@
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"
Expand Down
61 changes: 61 additions & 0 deletions scripts/v0.6/sponsorProposal.ts
Original file line number Diff line number Diff line change
@@ -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);
Loading