proof-of-take-sdk 5.0.3 → 5.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -339,6 +339,42 @@ await claimReward(program, {
339
339
 
340
340
  ---
341
341
 
342
+ ## Launchpad Integration (Moonpool/Sunpool)
343
+
344
+ For bot developers integrating the launchpad functionality with automatic keypair generation, see the comprehensive guide:
345
+
346
+ **📘 [LAUNCHPAD_BOT_INTEGRATION.md](../LAUNCHPAD_BOT_INTEGRATION.md)**
347
+
348
+ ### Quick Example
349
+
350
+ ```typescript
351
+ import { joinSeason } from "@proof-of-miztake/sdk";
352
+ import { BN } from "@coral-xyz/anchor";
353
+
354
+ // Call joinSeason with launchpad mode
355
+ const result = await joinSeason({
356
+ connection,
357
+ user: userPublicKey,
358
+ seasonNumber: new BN(1),
359
+ tier: 4,
360
+ launchpad: true, // Enable launchpad mode
361
+ });
362
+
363
+ // ✅ CRITICAL: Extract and use the auto-generated keypair
364
+ const signers = [adminWallet, userWallet];
365
+ if (result.meta?.launchpadTokenMintKeypair) {
366
+ signers.push(result.meta.launchpadTokenMintKeypair);
367
+ console.log("Added launchpad mint keypair");
368
+ }
369
+
370
+ // Sign and send transaction with all signers
371
+ tx.sign(...signers);
372
+ ```
373
+
374
+ **Important:** The SDK auto-generates the launchpad mint keypair, but your bot must extract it from `result.meta.launchpadTokenMintKeypair` and include it when signing the transaction. See the full guide for details.
375
+
376
+ ---
377
+
342
378
  ## Building from Source
343
379
 
344
380
  ```bash
@@ -1,5 +1,5 @@
1
1
  import { BN } from "@coral-xyz/anchor";
2
- import { Connection, PublicKey } from "@solana/web3.js";
2
+ import { Connection, Keypair, PublicKey } from "@solana/web3.js";
3
3
  import { Season, SeasonMembership, SeasonSettings, TierNumber } from "../types";
4
4
  import { StandardInstructionResultWithPdas } from "../types/instructionResults";
5
5
  /**
@@ -48,6 +48,7 @@ export interface JoinSeasonOptions {
48
48
  currentAccounts?: {
49
49
  seasonSettings?: SeasonSettings;
50
50
  season?: Season;
51
+ moonpool?: any;
51
52
  };
52
53
  }
53
54
  /**
@@ -101,6 +102,10 @@ type JoinSeasonPdas = {
101
102
  userJoinCredit: PublicKey;
102
103
  userJoinCreditVault: PublicKey;
103
104
  };
105
+ type JoinSeasonMeta = {
106
+ /** The keypair used for the launchpad mint (only set if auto-generated) */
107
+ launchpadTokenMintKeypair?: Keypair;
108
+ };
104
109
  type JoinSeasonUpdatedAccounts = {
105
110
  seasonSettings?: SeasonSettings;
106
111
  season?: Season;
@@ -120,19 +125,19 @@ type JoinSeasonUpdatedAccounts = {
120
125
  * @param options - Join season options
121
126
  * @returns Instructions, signers, PDAs, and optimistically created/updated accounts
122
127
  */
123
- export declare function joinSeason(options: JoinSeasonOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts>>;
128
+ export declare function joinSeason(options: JoinSeasonOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts, JoinSeasonMeta>>;
124
129
  /**
125
130
  * Convenience wrapper: classic (non-launchpad) joinSeason.
126
131
  * - Keeps the existing MIZD-based join behavior.
127
132
  * - App code never passes nullable optional accounts.
128
133
  */
129
- export declare function joinSeasonClassic(options: JoinSeasonClassicOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts>>;
134
+ export declare function joinSeasonClassic(options: JoinSeasonClassicOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts, JoinSeasonMeta>>;
130
135
  /**
131
136
  * Convenience wrapper: launchpad joinSeason.
132
137
  * - Uses SOL in + virtual token escrow.
133
138
  * - App code never passes nullable optional accounts.
134
139
  */
135
- export declare function joinSeasonLaunchpad(options: JoinSeasonLaunchpadOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts>>;
140
+ export declare function joinSeasonLaunchpad(options: JoinSeasonLaunchpadOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts, JoinSeasonMeta>>;
136
141
  /**
137
142
  * Join season AND initialize it (first joiner).
138
143
  * Use this when you know the season doesn't exist yet.
@@ -140,7 +145,7 @@ export declare function joinSeasonLaunchpad(options: JoinSeasonLaunchpadOptions)
140
145
  * @param options - Options with REQUIRED starFlagPrompt
141
146
  * @throws Error if starFlagPrompt is empty or exceeds 33 characters
142
147
  */
143
- export declare function joinSeasonAndInitialize(options: JoinSeasonAndInitializeOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts>>;
148
+ export declare function joinSeasonAndInitialize(options: JoinSeasonAndInitializeOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts, JoinSeasonMeta>>;
144
149
  /**
145
150
  * Join season AND initialize it in launchpad mode (first joiner).
146
151
  * Use this when you know the season doesn't exist yet and want launchpad mode.
@@ -150,5 +155,5 @@ export declare function joinSeasonAndInitialize(options: JoinSeasonAndInitialize
150
155
  */
151
156
  export declare function joinSeasonLaunchpadAndInitialize(options: Omit<JoinSeasonLaunchpadOptions, "starFlagPrompt"> & {
152
157
  starFlagPrompt: string;
153
- }): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts>>;
158
+ }): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts, JoinSeasonMeta>>;
154
159
  export {};
@@ -38,6 +38,41 @@ async function joinSeason(options) {
38
38
  tier: options.tier,
39
39
  tokenMint,
40
40
  });
41
+ // Auto-generate keypair for launchpad mode when moonpool is being initialized
42
+ let launchpadTokenMintKeypair;
43
+ let launchpadTokenMintPubkey;
44
+ if (launchpad) {
45
+ // Check if moonpool is already initialized
46
+ // First check currentAccounts (for LiteSVM or optimistic updates)
47
+ let moonpoolData = options.currentAccounts?.moonpool ?? null;
48
+ // If not provided, try to fetch it from the network
49
+ if (!moonpoolData) {
50
+ try {
51
+ moonpoolData = await program.account.moonpool.fetch(pdasBase.moonpool);
52
+ console.log("[joinSeason] Moonpool data fetched, launchpadTokenMint:", moonpoolData.launchpadTokenMint.toString());
53
+ }
54
+ catch (error) {
55
+ // Moonpool doesn't exist (first join scenario) or network error - treat as first join
56
+ moonpoolData = null;
57
+ }
58
+ }
59
+ if (!moonpoolData || moonpoolData.launchpadTokenMint.equals(web3_js_1.PublicKey.default)) {
60
+ // Moonpool doesn't exist yet (first join) - generate a keypair for the mint
61
+ // The mint will be created and stored in the moonpool during initialization
62
+ launchpadTokenMintKeypair = web3_js_1.Keypair.generate();
63
+ launchpadTokenMintPubkey = launchpadTokenMintKeypair.publicKey;
64
+ console.log("[joinSeason] First join - generated launchpad mint keypair:", launchpadTokenMintPubkey.toString());
65
+ }
66
+ else {
67
+ // Moonpool is already initialized - use the mint address stored in moonpool
68
+ launchpadTokenMintPubkey = moonpoolData.launchpadTokenMint;
69
+ console.log("[joinSeason] Moonpool exists - using stored mint address:", launchpadTokenMintPubkey.toString());
70
+ }
71
+ }
72
+ else {
73
+ // Non-launchpad mode, use PDA
74
+ launchpadTokenMintPubkey = pdasBase.launchpadTokenMint;
75
+ }
41
76
  const rootAdminTokenAccount = launchpad
42
77
  ? null
43
78
  : (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, constants_1.ADMIN_PUBLIC_KEY);
@@ -50,6 +85,7 @@ async function joinSeason(options) {
50
85
  : (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, pdasBase.userJoinCredit, true);
51
86
  const pdas = {
52
87
  ...pdasBase,
88
+ launchpadTokenMint: launchpadTokenMintPubkey,
53
89
  userJoinCreditVault: userJoinCreditVault ?? web3_js_1.PublicKey.default,
54
90
  };
55
91
  const accounts = {
@@ -105,7 +141,16 @@ async function joinSeason(options) {
105
141
  // For star joins, make the transaction fully sponsored: force the fee payer to be the root admin.
106
142
  // This prevents clients from accidentally using an unfunded/nonexistent fee payer account.
107
143
  const feePayer = options.star ? constants_1.ADMIN_PUBLIC_KEY : (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
108
- const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(constants_1.ADMIN_PUBLIC_KEY), (0, signerHelpers_1.asUserSigner)(options.user)], feePayer);
144
+ // Build signers array
145
+ const signersList = [(0, signerHelpers_1.asAdminSigner)(constants_1.ADMIN_PUBLIC_KEY), (0, signerHelpers_1.asUserSigner)(options.user)];
146
+ // Add launchpad token mint keypair as signer if it exists (either provided or auto-generated)
147
+ if (launchpad && launchpadTokenMintKeypair) {
148
+ signersList.push({
149
+ publicKey: launchpadTokenMintKeypair.publicKey,
150
+ role: "payer", // Use 'payer' role for the mint keypair
151
+ });
152
+ }
153
+ const signers = (0, signerHelpers_1.buildSigners)(signersList, feePayer);
109
154
  // OPTIMISTIC UPDATES
110
155
  const curr = options.currentAccounts || {};
111
156
  const now = (0, optimistic_1.getCurrentTimestamp)(options.now);
@@ -148,6 +193,13 @@ async function joinSeason(options) {
148
193
  },
149
194
  }
150
195
  : {}),
196
+ ...(launchpadTokenMintKeypair
197
+ ? {
198
+ meta: {
199
+ launchpadTokenMintKeypair,
200
+ },
201
+ }
202
+ : {}),
151
203
  };
152
204
  }
153
205
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proof-of-take-sdk",
3
- "version": "5.0.3",
3
+ "version": "5.0.5",
4
4
  "description": "TypeScript SDK for Proof of Take Solana program",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",