proof-of-take-sdk 5.0.3 → 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.
|
@@ -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
|
-
|
|
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
|
/**
|