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
23 changes: 14 additions & 9 deletions scripts/v0.7/completeLaunch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
Expand Down Expand Up @@ -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();
Expand Down
6 changes: 4 additions & 2 deletions scripts/v0.7/launchTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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();
};

Expand Down
74 changes: 74 additions & 0 deletions scripts/v0.7/startLaunch.ts
Original file line number Diff line number Diff line change
@@ -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;
}
Loading