From f91f89ea2a8e046d754ec14c8d8733dc930874d0 Mon Sep 17 00:00:00 2001 From: Pileks Date: Tue, 23 Dec 2025 16:45:26 +0100 Subject: [PATCH] update v07 launch scripts --- scripts/v0.7/completeLaunch.ts | 23 ++++++----- scripts/v0.7/launchTemplate.ts | 6 ++- scripts/v0.7/startLaunch.ts | 74 ++++++++++++++++++++++++++++++++++ 3 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 scripts/v0.7/startLaunch.ts diff --git a/scripts/v0.7/completeLaunch.ts b/scripts/v0.7/completeLaunch.ts index 5be54a8b..d60325f6 100644 --- a/scripts/v0.7/completeLaunch.ts +++ b/scripts/v0.7/completeLaunch.ts @@ -7,28 +7,33 @@ import { } from "@solana/web3.js"; import { createLookupTableForTransaction } from "../utils/utils.js"; +const LAUNCH_TO_COMPLETE: PublicKey | undefined = undefined; +const BID_WALL_FEE_RECIPIENT: PublicKey | undefined = undefined; + const provider = anchor.AnchorProvider.env(); const payer = provider.wallet["payer"]; const launchpad: LaunchpadClient = LaunchpadClient.createClient({ provider }); -const BID_WALL_FEE_RECIPIENT: PublicKey | undefined = undefined; - export const completeLaunch = async () => { + if (LAUNCH_TO_COMPLETE === undefined) { + throw new Error( + "LAUNCH_TO_COMPLETE is not set. Please set it in the script.", + ); + } + if (BID_WALL_FEE_RECIPIENT === undefined) { throw new Error( "BID_WALL_FEE_RECIPIENT is not set. Please set it in the script.", ); } - const mintKp = new PublicKey("PRVT6TB7uss3FrUd2D9xs2zqDBsa3GbMJMwCQsgmeta"); - - const [launch] = getLaunchAddr(undefined, mintKp); + const launchAccount = await launchpad.fetchLaunch(LAUNCH_TO_COMPLETE); const tx = await launchpad .completeLaunchIx({ - launch, - baseMint: mintKp, + launch: LAUNCH_TO_COMPLETE, + baseMint: launchAccount.baseMint, launchAuthority: payer.publicKey, feeRecipient: BID_WALL_FEE_RECIPIENT, }) @@ -63,8 +68,8 @@ export const completeLaunch = async () => { const initializePerformancePackageTxHash = await launchpad .initializePerformancePackageIx({ - launch, - baseMint: mintKp, + launch: LAUNCH_TO_COMPLETE, + baseMint: launchAccount.baseMint, payer: payer.publicKey, }) .rpc(); diff --git a/scripts/v0.7/launchTemplate.ts b/scripts/v0.7/launchTemplate.ts index 3b41fa24..c0aaf271 100644 --- a/scripts/v0.7/launchTemplate.ts +++ b/scripts/v0.7/launchTemplate.ts @@ -77,7 +77,7 @@ export const launch = async () => { const txHash = await provider.connection.sendRawTransaction(tx.serialize()); await provider.connection.confirmTransaction(txHash, "confirmed"); - const launchIx = await launchpad + const initializeLaunchTxSignature = await launchpad .initializeLaunchIx({ tokenName: TOKEN_NAME, tokenSymbol: TOKEN_SYMBOL, @@ -101,7 +101,9 @@ export const launch = async () => { }) .rpc(); - console.log("Launch initialized", launchIx); + console.log("Launch initialized", initializeLaunchTxSignature); + + console.log("Launch address:", launch.toBase58()); // await launchpad.startLaunchIx({ launch }).rpc(); }; diff --git a/scripts/v0.7/startLaunch.ts b/scripts/v0.7/startLaunch.ts new file mode 100644 index 00000000..535aaa56 --- /dev/null +++ b/scripts/v0.7/startLaunch.ts @@ -0,0 +1,74 @@ +import { Keypair, PublicKey, Transaction } from "@solana/web3.js"; +import * as anchor from "@coral-xyz/anchor"; +import { LaunchpadClient } from "@metadaoproject/futarchy/v0.7"; + +import dotenv from "dotenv"; + +dotenv.config(); + +const provider = anchor.AnchorProvider.env(); +const payer = provider.wallet["payer"]; + +const LAUNCH_TO_START = new PublicKey( + "7DzBXBYSKhrXHPWT6mAKq394vKupaKaqLn9bK1wscpBz", +); + +const launchpad: LaunchpadClient = LaunchpadClient.createClient({ provider }); + +async function main() { + const launchAuthorityKeypair = payer; + + console.log( + "Launch authority public key:", + launchAuthorityKeypair.publicKey.toBase58(), + ); + + console.log("Starting launch..."); + + const tx = await launchpad + .startLaunchIx({ + launch: LAUNCH_TO_START, + launchAuthority: launchAuthorityKeypair.publicKey, + }) + .transaction(); + + await sendAndConfirmTransaction(tx, "Start launch", [launchAuthorityKeypair]); + + console.log("Launch started!"); + console.log("Launch address:", LAUNCH_TO_START.toBase58()); +} + +// Make sure the promise rejection is handled +main().catch((error) => { + console.error("Fatal error:", error); + process.exit(1); +}); + +async function sendAndConfirmTransaction( + tx: Transaction, + label: string, + signers: Keypair[] = [], +) { + tx.feePayer = payer.publicKey; + tx.recentBlockhash = ( + await provider.connection.getLatestBlockhash() + ).blockhash; + tx.partialSign(payer, ...signers); + const txHash = await provider.connection.sendRawTransaction(tx.serialize()); + console.log(`${label} transaction sent:`, txHash); + + await provider.connection.confirmTransaction(txHash, "confirmed"); + const txStatus = await provider.connection.getTransaction(txHash, { + maxSupportedTransactionVersion: 0, + commitment: "confirmed", + }); + if (txStatus?.meta?.err) { + throw new Error( + `Transaction failed: ${txHash}\nError: ${JSON.stringify( + txStatus?.meta?.err, + )}\n\n${txStatus?.meta?.logMessages?.join("\n")}`, + ); + } + console.log(`${label} transaction confirmed`); + return txHash; +}