proof-of-take-sdk 3.0.12 → 3.0.13
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.
|
@@ -14,6 +14,8 @@ export interface JoinSeasonOptions {
|
|
|
14
14
|
tier: TierNumber;
|
|
15
15
|
/** Optional referrer (PublicKey.default means no referrer) */
|
|
16
16
|
referrer?: PublicKey;
|
|
17
|
+
/** Referrer's tier (required if referrer is provided; must match the tier they joined with) */
|
|
18
|
+
referrerTier?: TierNumber;
|
|
17
19
|
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
18
20
|
now?: BN;
|
|
19
21
|
feePayer?: PublicKey;
|
|
@@ -41,6 +43,10 @@ type JoinSeasonUpdatedAccounts = {
|
|
|
41
43
|
* User pays for season (if needed) and membership accounts
|
|
42
44
|
* Transfers full tier deposit from user to vault, then escrows the pre-join portion
|
|
43
45
|
*
|
|
46
|
+
* IMPORTANT: If providing a referrer, you MUST also provide referrerTier.
|
|
47
|
+
* The referrerTier must match the tier the referrer actually joined the season with.
|
|
48
|
+
* The referrer must have already joined the season before being used as a referrer.
|
|
49
|
+
*
|
|
44
50
|
* @param options - Join season options
|
|
45
51
|
* @returns Instructions, signers, PDAs, and optimistically created/updated accounts
|
|
46
52
|
*/
|
|
@@ -21,6 +21,10 @@ const remainingAccounts_1 = require("../utils/remainingAccounts");
|
|
|
21
21
|
* User pays for season (if needed) and membership accounts
|
|
22
22
|
* Transfers full tier deposit from user to vault, then escrows the pre-join portion
|
|
23
23
|
*
|
|
24
|
+
* IMPORTANT: If providing a referrer, you MUST also provide referrerTier.
|
|
25
|
+
* The referrerTier must match the tier the referrer actually joined the season with.
|
|
26
|
+
* The referrer must have already joined the season before being used as a referrer.
|
|
27
|
+
*
|
|
24
28
|
* @param options - Join season options
|
|
25
29
|
* @returns Instructions, signers, PDAs, and optimistically created/updated accounts
|
|
26
30
|
*/
|
|
@@ -48,11 +52,19 @@ async function joinSeason(options) {
|
|
|
48
52
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
49
53
|
};
|
|
50
54
|
const referrer = options.referrer ?? web3_js_1.PublicKey.default;
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
referrer
|
|
55
|
-
}
|
|
55
|
+
const hasReferrer = !referrer.equals(web3_js_1.PublicKey.default);
|
|
56
|
+
// Validate: if referrer is provided, referrerTier must also be provided
|
|
57
|
+
if (hasReferrer && options.referrerTier === undefined) {
|
|
58
|
+
throw new Error("referrerTier is required when referrer is provided");
|
|
59
|
+
}
|
|
60
|
+
const remainingAccounts = hasReferrer
|
|
61
|
+
? (0, remainingAccounts_1.getJoinSeasonRemainingAccounts)({
|
|
62
|
+
seasonNumber: options.seasonNumber,
|
|
63
|
+
tier: options.tier,
|
|
64
|
+
referrer,
|
|
65
|
+
referrerTier: options.referrerTier,
|
|
66
|
+
})
|
|
67
|
+
: [];
|
|
56
68
|
const methodBuilder = program.methods
|
|
57
69
|
// Anchor expects BN for u64 args.
|
|
58
70
|
.joinSeason(options.seasonNumber, options.tier, referrer)
|
|
@@ -17,7 +17,7 @@ const constants_1 = require("./constants");
|
|
|
17
17
|
function getJoinSeasonRemainingAccounts(params) {
|
|
18
18
|
if (params.referrer.equals(web3_js_1.PublicKey.default))
|
|
19
19
|
return [];
|
|
20
|
-
const [referrerSeasonMembership] = (0, pdas_1.getSeasonMembershipPda)(params.seasonNumber, params.referrer, params.
|
|
20
|
+
const [referrerSeasonMembership] = (0, pdas_1.getSeasonMembershipPda)(params.seasonNumber, params.referrer, params.referrerTier);
|
|
21
21
|
const [signupRewardsPda] = (0, pdas_1.getSignupRewardsPda)(params.seasonNumber, params.referrer);
|
|
22
22
|
// IMPORTANT: PDA owners are off-curve; allowOwnerOffCurve must be true.
|
|
23
23
|
const signupRewardsMizdAta = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, signupRewardsPda, true);
|