proof-of-take-sdk 5.0.2 → 5.0.4

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.
@@ -3029,55 +3029,11 @@
3029
3029
  "docs": [
3030
3030
  "SPL Token-2022 mint for the launchpad token.",
3031
3031
  "Created when the Moonpool is first initialized.",
3032
- "Mint authority is the Moonpool PDA itself."
3032
+ "Mint authority is the Moonpool PDA itself.",
3033
+ "NOTE: This is a Keypair (not a PDA) to allow creating fresh mints with updated decimals."
3033
3034
  ],
3034
3035
  "writable": true,
3035
- "pda": {
3036
- "seeds": [
3037
- {
3038
- "kind": "const",
3039
- "value": [
3040
- 108,
3041
- 97,
3042
- 117,
3043
- 110,
3044
- 99,
3045
- 104,
3046
- 112,
3047
- 97,
3048
- 100,
3049
- 95,
3050
- 116,
3051
- 111,
3052
- 107,
3053
- 101,
3054
- 110,
3055
- 95,
3056
- 109,
3057
- 105,
3058
- 110,
3059
- 116
3060
- ]
3061
- },
3062
- {
3063
- "kind": "account",
3064
- "path": "token_mint"
3065
- },
3066
- {
3067
- "kind": "const",
3068
- "value": [
3069
- 1,
3070
- 0,
3071
- 0,
3072
- 0,
3073
- 0,
3074
- 0,
3075
- 0,
3076
- 0
3077
- ]
3078
- }
3079
- ]
3080
- }
3036
+ "signer": true
3081
3037
  },
3082
3038
  {
3083
3039
  "name": "sunpool",
@@ -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
  /**
@@ -21,6 +21,16 @@ export interface JoinSeasonOptions {
21
21
  star?: boolean;
22
22
  /** If true, join uses launchpad mode (SOL in, virtual tokens escrowed; no SPL token accounts needed). */
23
23
  launchpad?: boolean;
24
+ /**
25
+ * Launchpad token mint keypair. OPTIONAL.
26
+ *
27
+ * - If NOT provided and launchpad=true: SDK will automatically generate a new keypair
28
+ * for the mint and return it in the result.
29
+ * - If provided: SDK will use this keypair (useful for testing with specific keys).
30
+ *
31
+ * The SDK automatically adds the keypair as a signer to the transaction.
32
+ */
33
+ launchpadTokenMintKeypair?: Keypair;
24
34
  /** Launchpad slippage cap (lamports). Only used when launchpad=true. Defaults to u64::MAX. */
25
35
  maxSolInLamports?: BN;
26
36
  /**
@@ -101,6 +111,10 @@ type JoinSeasonPdas = {
101
111
  userJoinCredit: PublicKey;
102
112
  userJoinCreditVault: PublicKey;
103
113
  };
114
+ type JoinSeasonMeta = {
115
+ /** The keypair used for the launchpad mint (only set if auto-generated) */
116
+ launchpadTokenMintKeypair?: Keypair;
117
+ };
104
118
  type JoinSeasonUpdatedAccounts = {
105
119
  seasonSettings?: SeasonSettings;
106
120
  season?: Season;
@@ -120,19 +134,19 @@ type JoinSeasonUpdatedAccounts = {
120
134
  * @param options - Join season options
121
135
  * @returns Instructions, signers, PDAs, and optimistically created/updated accounts
122
136
  */
123
- export declare function joinSeason(options: JoinSeasonOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts>>;
137
+ export declare function joinSeason(options: JoinSeasonOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts, JoinSeasonMeta>>;
124
138
  /**
125
139
  * Convenience wrapper: classic (non-launchpad) joinSeason.
126
140
  * - Keeps the existing MIZD-based join behavior.
127
141
  * - App code never passes nullable optional accounts.
128
142
  */
129
- export declare function joinSeasonClassic(options: JoinSeasonClassicOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts>>;
143
+ export declare function joinSeasonClassic(options: JoinSeasonClassicOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts, JoinSeasonMeta>>;
130
144
  /**
131
145
  * Convenience wrapper: launchpad joinSeason.
132
146
  * - Uses SOL in + virtual token escrow.
133
147
  * - App code never passes nullable optional accounts.
134
148
  */
135
- export declare function joinSeasonLaunchpad(options: JoinSeasonLaunchpadOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts>>;
149
+ export declare function joinSeasonLaunchpad(options: JoinSeasonLaunchpadOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts, JoinSeasonMeta>>;
136
150
  /**
137
151
  * Join season AND initialize it (first joiner).
138
152
  * Use this when you know the season doesn't exist yet.
@@ -140,7 +154,7 @@ export declare function joinSeasonLaunchpad(options: JoinSeasonLaunchpadOptions)
140
154
  * @param options - Options with REQUIRED starFlagPrompt
141
155
  * @throws Error if starFlagPrompt is empty or exceeds 33 characters
142
156
  */
143
- export declare function joinSeasonAndInitialize(options: JoinSeasonAndInitializeOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts>>;
157
+ export declare function joinSeasonAndInitialize(options: JoinSeasonAndInitializeOptions): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts, JoinSeasonMeta>>;
144
158
  /**
145
159
  * Join season AND initialize it in launchpad mode (first joiner).
146
160
  * Use this when you know the season doesn't exist yet and want launchpad mode.
@@ -150,5 +164,5 @@ export declare function joinSeasonAndInitialize(options: JoinSeasonAndInitialize
150
164
  */
151
165
  export declare function joinSeasonLaunchpadAndInitialize(options: Omit<JoinSeasonLaunchpadOptions, "starFlagPrompt"> & {
152
166
  starFlagPrompt: string;
153
- }): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts>>;
167
+ }): Promise<StandardInstructionResultWithPdas<JoinSeasonPdas, JoinSeasonUpdatedAccounts, JoinSeasonMeta>>;
154
168
  export {};
@@ -38,6 +38,33 @@ async function joinSeason(options) {
38
38
  tier: options.tier,
39
39
  tokenMint,
40
40
  });
41
+ // Auto-generate keypair for launchpad mode if not provided
42
+ let launchpadTokenMintKeypair = options.launchpadTokenMintKeypair;
43
+ let launchpadTokenMintPubkey;
44
+ if (launchpad) {
45
+ if (launchpadTokenMintKeypair) {
46
+ // Use provided keypair
47
+ launchpadTokenMintPubkey = launchpadTokenMintKeypair.publicKey;
48
+ }
49
+ else {
50
+ // Check if mint account already exists
51
+ const mintAccountInfo = await options.connection.getAccountInfo(pdasBase.launchpadTokenMint);
52
+ if (mintAccountInfo) {
53
+ // Mint already exists, use the existing PDA address
54
+ launchpadTokenMintPubkey = pdasBase.launchpadTokenMint;
55
+ }
56
+ else {
57
+ // Mint doesn't exist, generate a new keypair
58
+ launchpadTokenMintKeypair = web3_js_1.Keypair.generate();
59
+ launchpadTokenMintPubkey = launchpadTokenMintKeypair.publicKey;
60
+ console.log("[joinSeason] Auto-generated launchpad mint keypair:", launchpadTokenMintPubkey.toString());
61
+ }
62
+ }
63
+ }
64
+ else {
65
+ // Non-launchpad mode, use PDA
66
+ launchpadTokenMintPubkey = pdasBase.launchpadTokenMint;
67
+ }
41
68
  const rootAdminTokenAccount = launchpad
42
69
  ? null
43
70
  : (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, constants_1.ADMIN_PUBLIC_KEY);
@@ -50,6 +77,7 @@ async function joinSeason(options) {
50
77
  : (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, pdasBase.userJoinCredit, true);
51
78
  const pdas = {
52
79
  ...pdasBase,
80
+ launchpadTokenMint: launchpadTokenMintPubkey,
53
81
  userJoinCreditVault: userJoinCreditVault ?? web3_js_1.PublicKey.default,
54
82
  };
55
83
  const accounts = {
@@ -105,7 +133,16 @@ async function joinSeason(options) {
105
133
  // For star joins, make the transaction fully sponsored: force the fee payer to be the root admin.
106
134
  // This prevents clients from accidentally using an unfunded/nonexistent fee payer account.
107
135
  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);
136
+ // Build signers array
137
+ const signersList = [(0, signerHelpers_1.asAdminSigner)(constants_1.ADMIN_PUBLIC_KEY), (0, signerHelpers_1.asUserSigner)(options.user)];
138
+ // Add launchpad token mint keypair as signer if it exists (either provided or auto-generated)
139
+ if (launchpad && launchpadTokenMintKeypair) {
140
+ signersList.push({
141
+ publicKey: launchpadTokenMintKeypair.publicKey,
142
+ role: "payer", // Use 'payer' role for the mint keypair
143
+ });
144
+ }
145
+ const signers = (0, signerHelpers_1.buildSigners)(signersList, feePayer);
109
146
  // OPTIMISTIC UPDATES
110
147
  const curr = options.currentAccounts || {};
111
148
  const now = (0, optimistic_1.getCurrentTimestamp)(options.now);
@@ -148,6 +185,13 @@ async function joinSeason(options) {
148
185
  },
149
186
  }
150
187
  : {}),
188
+ ...(launchpadTokenMintKeypair
189
+ ? {
190
+ meta: {
191
+ launchpadTokenMintKeypair,
192
+ },
193
+ }
194
+ : {}),
151
195
  };
152
196
  }
153
197
  /**
@@ -3035,55 +3035,11 @@ export type ProofOfTake = {
3035
3035
  "docs": [
3036
3036
  "SPL Token-2022 mint for the launchpad token.",
3037
3037
  "Created when the Moonpool is first initialized.",
3038
- "Mint authority is the Moonpool PDA itself."
3038
+ "Mint authority is the Moonpool PDA itself.",
3039
+ "NOTE: This is a Keypair (not a PDA) to allow creating fresh mints with updated decimals."
3039
3040
  ];
3040
3041
  "writable": true;
3041
- "pda": {
3042
- "seeds": [
3043
- {
3044
- "kind": "const";
3045
- "value": [
3046
- 108,
3047
- 97,
3048
- 117,
3049
- 110,
3050
- 99,
3051
- 104,
3052
- 112,
3053
- 97,
3054
- 100,
3055
- 95,
3056
- 116,
3057
- 111,
3058
- 107,
3059
- 101,
3060
- 110,
3061
- 95,
3062
- 109,
3063
- 105,
3064
- 110,
3065
- 116
3066
- ];
3067
- },
3068
- {
3069
- "kind": "account";
3070
- "path": "tokenMint";
3071
- },
3072
- {
3073
- "kind": "const";
3074
- "value": [
3075
- 1,
3076
- 0,
3077
- 0,
3078
- 0,
3079
- 0,
3080
- 0,
3081
- 0,
3082
- 0
3083
- ];
3084
- }
3085
- ];
3086
- };
3042
+ "signer": true;
3087
3043
  },
3088
3044
  {
3089
3045
  "name": "sunpool";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proof-of-take-sdk",
3
- "version": "5.0.2",
3
+ "version": "5.0.4",
4
4
  "description": "TypeScript SDK for Proof of Take Solana program",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",