proof-of-take-sdk 5.0.4 → 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 +36 -0
- package/dist/instructions/joinSeason.d.ts +1 -10
- package/dist/instructions/joinSeason.js +24 -16
- package/package.json +1 -1
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
|
|
@@ -21,16 +21,6 @@ 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;
|
|
34
24
|
/** Launchpad slippage cap (lamports). Only used when launchpad=true. Defaults to u64::MAX. */
|
|
35
25
|
maxSolInLamports?: BN;
|
|
36
26
|
/**
|
|
@@ -58,6 +48,7 @@ export interface JoinSeasonOptions {
|
|
|
58
48
|
currentAccounts?: {
|
|
59
49
|
seasonSettings?: SeasonSettings;
|
|
60
50
|
season?: Season;
|
|
51
|
+
moonpool?: any;
|
|
61
52
|
};
|
|
62
53
|
}
|
|
63
54
|
/**
|
|
@@ -38,27 +38,35 @@ async function joinSeason(options) {
|
|
|
38
38
|
tier: options.tier,
|
|
39
39
|
tokenMint,
|
|
40
40
|
});
|
|
41
|
-
// Auto-generate keypair for launchpad mode
|
|
42
|
-
let launchpadTokenMintKeypair
|
|
41
|
+
// Auto-generate keypair for launchpad mode when moonpool is being initialized
|
|
42
|
+
let launchpadTokenMintKeypair;
|
|
43
43
|
let launchpadTokenMintPubkey;
|
|
44
44
|
if (launchpad) {
|
|
45
|
-
if
|
|
46
|
-
|
|
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();
|
|
47
63
|
launchpadTokenMintPubkey = launchpadTokenMintKeypair.publicKey;
|
|
64
|
+
console.log("[joinSeason] First join - generated launchpad mint keypair:", launchpadTokenMintPubkey.toString());
|
|
48
65
|
}
|
|
49
66
|
else {
|
|
50
|
-
//
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
}
|
|
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());
|
|
62
70
|
}
|
|
63
71
|
}
|
|
64
72
|
else {
|