proof-of-take-sdk 3.0.17 → 3.1.1
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/dist/idl/proof_of_take.json +106 -1
- package/dist/instructions/joinSeason.d.ts +2 -1
- package/dist/instructions/joinSeason.js +5 -3
- package/dist/types/proof_of_take.d.ts +105 -0
- package/dist/types.d.ts +6 -0
- package/dist/utils/accountConverters.js +3 -0
- package/dist/utils/accountUpdates.d.ts +1 -1
- package/dist/utils/accountUpdates.js +4 -1
- package/package.json +1 -1
|
@@ -2053,7 +2053,96 @@
|
|
|
2053
2053
|
},
|
|
2054
2054
|
{
|
|
2055
2055
|
"name": "user_token_account",
|
|
2056
|
-
"
|
|
2056
|
+
"docs": [
|
|
2057
|
+
"User MIZD ATA (canonical). Created if missing; root admin pays."
|
|
2058
|
+
],
|
|
2059
|
+
"writable": true,
|
|
2060
|
+
"pda": {
|
|
2061
|
+
"seeds": [
|
|
2062
|
+
{
|
|
2063
|
+
"kind": "account",
|
|
2064
|
+
"path": "user"
|
|
2065
|
+
},
|
|
2066
|
+
{
|
|
2067
|
+
"kind": "const",
|
|
2068
|
+
"value": [
|
|
2069
|
+
6,
|
|
2070
|
+
221,
|
|
2071
|
+
246,
|
|
2072
|
+
225,
|
|
2073
|
+
215,
|
|
2074
|
+
101,
|
|
2075
|
+
161,
|
|
2076
|
+
147,
|
|
2077
|
+
217,
|
|
2078
|
+
203,
|
|
2079
|
+
225,
|
|
2080
|
+
70,
|
|
2081
|
+
206,
|
|
2082
|
+
235,
|
|
2083
|
+
121,
|
|
2084
|
+
172,
|
|
2085
|
+
28,
|
|
2086
|
+
180,
|
|
2087
|
+
133,
|
|
2088
|
+
237,
|
|
2089
|
+
95,
|
|
2090
|
+
91,
|
|
2091
|
+
55,
|
|
2092
|
+
145,
|
|
2093
|
+
58,
|
|
2094
|
+
140,
|
|
2095
|
+
245,
|
|
2096
|
+
133,
|
|
2097
|
+
126,
|
|
2098
|
+
255,
|
|
2099
|
+
0,
|
|
2100
|
+
169
|
|
2101
|
+
]
|
|
2102
|
+
},
|
|
2103
|
+
{
|
|
2104
|
+
"kind": "account",
|
|
2105
|
+
"path": "mizd_mint"
|
|
2106
|
+
}
|
|
2107
|
+
],
|
|
2108
|
+
"program": {
|
|
2109
|
+
"kind": "const",
|
|
2110
|
+
"value": [
|
|
2111
|
+
140,
|
|
2112
|
+
151,
|
|
2113
|
+
37,
|
|
2114
|
+
143,
|
|
2115
|
+
78,
|
|
2116
|
+
36,
|
|
2117
|
+
137,
|
|
2118
|
+
241,
|
|
2119
|
+
187,
|
|
2120
|
+
61,
|
|
2121
|
+
16,
|
|
2122
|
+
41,
|
|
2123
|
+
20,
|
|
2124
|
+
142,
|
|
2125
|
+
13,
|
|
2126
|
+
131,
|
|
2127
|
+
11,
|
|
2128
|
+
90,
|
|
2129
|
+
19,
|
|
2130
|
+
153,
|
|
2131
|
+
218,
|
|
2132
|
+
255,
|
|
2133
|
+
16,
|
|
2134
|
+
132,
|
|
2135
|
+
4,
|
|
2136
|
+
142,
|
|
2137
|
+
123,
|
|
2138
|
+
216,
|
|
2139
|
+
219,
|
|
2140
|
+
233,
|
|
2141
|
+
248,
|
|
2142
|
+
89
|
|
2143
|
+
]
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2057
2146
|
},
|
|
2058
2147
|
{
|
|
2059
2148
|
"name": "user",
|
|
@@ -2089,6 +2178,10 @@
|
|
|
2089
2178
|
{
|
|
2090
2179
|
"name": "referrer_tier",
|
|
2091
2180
|
"type": "u8"
|
|
2181
|
+
},
|
|
2182
|
+
{
|
|
2183
|
+
"name": "star",
|
|
2184
|
+
"type": "bool"
|
|
2092
2185
|
}
|
|
2093
2186
|
]
|
|
2094
2187
|
},
|
|
@@ -3560,6 +3653,11 @@
|
|
|
3560
3653
|
"code": 6050,
|
|
3561
3654
|
"name": "InvalidSignupRewardsVaultTokenAccount",
|
|
3562
3655
|
"msg": "Invalid signup rewards vault token account"
|
|
3656
|
+
},
|
|
3657
|
+
{
|
|
3658
|
+
"code": 6051,
|
|
3659
|
+
"name": "StarOnlyForCopperTier",
|
|
3660
|
+
"msg": "Star join is only allowed for Copper tier"
|
|
3563
3661
|
}
|
|
3564
3662
|
],
|
|
3565
3663
|
"types": [
|
|
@@ -4465,6 +4563,13 @@
|
|
|
4465
4563
|
],
|
|
4466
4564
|
"type": "u64"
|
|
4467
4565
|
},
|
|
4566
|
+
{
|
|
4567
|
+
"name": "is_star",
|
|
4568
|
+
"docs": [
|
|
4569
|
+
"Star membership flag (admin-sponsored join flow)"
|
|
4570
|
+
],
|
|
4571
|
+
"type": "bool"
|
|
4572
|
+
},
|
|
4468
4573
|
{
|
|
4469
4574
|
"name": "total_penalties_paid",
|
|
4470
4575
|
"docs": [
|
|
@@ -8,7 +8,6 @@ import { StandardInstructionResultWithPdas } from "../types/instructionResults";
|
|
|
8
8
|
export interface JoinSeasonOptions {
|
|
9
9
|
connection: Connection;
|
|
10
10
|
user: PublicKey;
|
|
11
|
-
userTokenAccount: PublicKey;
|
|
12
11
|
seasonNumber: BN;
|
|
13
12
|
/** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
|
|
14
13
|
tier: TierNumber;
|
|
@@ -16,6 +15,8 @@ export interface JoinSeasonOptions {
|
|
|
16
15
|
referrer?: PublicKey;
|
|
17
16
|
/** Referrer's tier (required if referrer is provided; must match the tier they joined with) */
|
|
18
17
|
referrerTier?: TierNumber;
|
|
18
|
+
/** If true, root admin funds join fee + deposit (currently only allowed for tier=0 on-chain). */
|
|
19
|
+
star?: boolean;
|
|
19
20
|
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
20
21
|
now?: BN;
|
|
21
22
|
feePayer?: PublicKey;
|
|
@@ -36,6 +36,7 @@ async function joinSeason(options) {
|
|
|
36
36
|
tier: options.tier,
|
|
37
37
|
});
|
|
38
38
|
const rootAdminTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, constants_1.ADMIN_PUBLIC_KEY);
|
|
39
|
+
const userMizdAta = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, options.user);
|
|
39
40
|
const accounts = {
|
|
40
41
|
seasonSettings: pdas.seasonSettings,
|
|
41
42
|
season: pdas.season,
|
|
@@ -45,7 +46,8 @@ async function joinSeason(options) {
|
|
|
45
46
|
mizdMint: constants_1.MIZD_TOKEN_MINT,
|
|
46
47
|
rootAdmin: constants_1.ADMIN_PUBLIC_KEY,
|
|
47
48
|
rootAdminTokenAccount,
|
|
48
|
-
|
|
49
|
+
// Always pass the canonical ATA; it may not exist yet (created on-chain with root admin as payer).
|
|
50
|
+
userTokenAccount: userMizdAta,
|
|
49
51
|
user: options.user,
|
|
50
52
|
associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
|
|
51
53
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
@@ -68,7 +70,7 @@ async function joinSeason(options) {
|
|
|
68
70
|
const methodBuilder = program.methods
|
|
69
71
|
// Anchor expects BN for u64 args.
|
|
70
72
|
// referrerTier defaults to 0 if no referrer (ignored on-chain)
|
|
71
|
-
.joinSeason(options.seasonNumber, options.tier, referrer, options.referrerTier ?? 0)
|
|
73
|
+
.joinSeason(options.seasonNumber, options.tier, referrer, options.referrerTier ?? 0, options.star ?? false)
|
|
72
74
|
.accounts(accounts);
|
|
73
75
|
if (remainingAccounts.length > 0) {
|
|
74
76
|
methodBuilder.remainingAccounts(remainingAccounts);
|
|
@@ -113,7 +115,7 @@ async function joinSeason(options) {
|
|
|
113
115
|
}
|
|
114
116
|
const depositEscrowed = perWindowPenalty.mul(joinedWindowNumber);
|
|
115
117
|
const depositActive = depositFull.sub(depositEscrowed);
|
|
116
|
-
newSeasonMembership = (0, optimistic_1.initializeSeasonMembership)(options.user, options.seasonNumber, depositTier, options.referrer ?? web3_js_1.PublicKey.default, depositActive, depositEscrowed, now, joinedWindowNumber, bump);
|
|
118
|
+
newSeasonMembership = (0, optimistic_1.initializeSeasonMembership)(options.user, options.seasonNumber, depositTier, options.referrer ?? web3_js_1.PublicKey.default, depositActive, depositEscrowed, now, joinedWindowNumber, bump, options.star ?? false);
|
|
117
119
|
if (curr.season) {
|
|
118
120
|
updatedSeason = (0, optimistic_1.updateSeasonForJoin)(curr.season, depositActive, depositTier, joinedWindowNumber, totalWindows);
|
|
119
121
|
}
|
|
@@ -2059,7 +2059,96 @@ export type ProofOfTake = {
|
|
|
2059
2059
|
},
|
|
2060
2060
|
{
|
|
2061
2061
|
"name": "userTokenAccount";
|
|
2062
|
+
"docs": [
|
|
2063
|
+
"User MIZD ATA (canonical). Created if missing; root admin pays."
|
|
2064
|
+
];
|
|
2062
2065
|
"writable": true;
|
|
2066
|
+
"pda": {
|
|
2067
|
+
"seeds": [
|
|
2068
|
+
{
|
|
2069
|
+
"kind": "account";
|
|
2070
|
+
"path": "user";
|
|
2071
|
+
},
|
|
2072
|
+
{
|
|
2073
|
+
"kind": "const";
|
|
2074
|
+
"value": [
|
|
2075
|
+
6,
|
|
2076
|
+
221,
|
|
2077
|
+
246,
|
|
2078
|
+
225,
|
|
2079
|
+
215,
|
|
2080
|
+
101,
|
|
2081
|
+
161,
|
|
2082
|
+
147,
|
|
2083
|
+
217,
|
|
2084
|
+
203,
|
|
2085
|
+
225,
|
|
2086
|
+
70,
|
|
2087
|
+
206,
|
|
2088
|
+
235,
|
|
2089
|
+
121,
|
|
2090
|
+
172,
|
|
2091
|
+
28,
|
|
2092
|
+
180,
|
|
2093
|
+
133,
|
|
2094
|
+
237,
|
|
2095
|
+
95,
|
|
2096
|
+
91,
|
|
2097
|
+
55,
|
|
2098
|
+
145,
|
|
2099
|
+
58,
|
|
2100
|
+
140,
|
|
2101
|
+
245,
|
|
2102
|
+
133,
|
|
2103
|
+
126,
|
|
2104
|
+
255,
|
|
2105
|
+
0,
|
|
2106
|
+
169
|
|
2107
|
+
];
|
|
2108
|
+
},
|
|
2109
|
+
{
|
|
2110
|
+
"kind": "account";
|
|
2111
|
+
"path": "mizdMint";
|
|
2112
|
+
}
|
|
2113
|
+
];
|
|
2114
|
+
"program": {
|
|
2115
|
+
"kind": "const";
|
|
2116
|
+
"value": [
|
|
2117
|
+
140,
|
|
2118
|
+
151,
|
|
2119
|
+
37,
|
|
2120
|
+
143,
|
|
2121
|
+
78,
|
|
2122
|
+
36,
|
|
2123
|
+
137,
|
|
2124
|
+
241,
|
|
2125
|
+
187,
|
|
2126
|
+
61,
|
|
2127
|
+
16,
|
|
2128
|
+
41,
|
|
2129
|
+
20,
|
|
2130
|
+
142,
|
|
2131
|
+
13,
|
|
2132
|
+
131,
|
|
2133
|
+
11,
|
|
2134
|
+
90,
|
|
2135
|
+
19,
|
|
2136
|
+
153,
|
|
2137
|
+
218,
|
|
2138
|
+
255,
|
|
2139
|
+
16,
|
|
2140
|
+
132,
|
|
2141
|
+
4,
|
|
2142
|
+
142,
|
|
2143
|
+
123,
|
|
2144
|
+
216,
|
|
2145
|
+
219,
|
|
2146
|
+
233,
|
|
2147
|
+
248,
|
|
2148
|
+
89
|
|
2149
|
+
];
|
|
2150
|
+
};
|
|
2151
|
+
};
|
|
2063
2152
|
},
|
|
2064
2153
|
{
|
|
2065
2154
|
"name": "user";
|
|
@@ -2095,6 +2184,10 @@ export type ProofOfTake = {
|
|
|
2095
2184
|
{
|
|
2096
2185
|
"name": "referrerTier";
|
|
2097
2186
|
"type": "u8";
|
|
2187
|
+
},
|
|
2188
|
+
{
|
|
2189
|
+
"name": "star";
|
|
2190
|
+
"type": "bool";
|
|
2098
2191
|
}
|
|
2099
2192
|
];
|
|
2100
2193
|
},
|
|
@@ -3566,6 +3659,11 @@ export type ProofOfTake = {
|
|
|
3566
3659
|
"code": 6050;
|
|
3567
3660
|
"name": "invalidSignupRewardsVaultTokenAccount";
|
|
3568
3661
|
"msg": "Invalid signup rewards vault token account";
|
|
3662
|
+
},
|
|
3663
|
+
{
|
|
3664
|
+
"code": 6051;
|
|
3665
|
+
"name": "starOnlyForCopperTier";
|
|
3666
|
+
"msg": "Star join is only allowed for Copper tier";
|
|
3569
3667
|
}
|
|
3570
3668
|
];
|
|
3571
3669
|
"types": [
|
|
@@ -4471,6 +4569,13 @@ export type ProofOfTake = {
|
|
|
4471
4569
|
];
|
|
4472
4570
|
"type": "u64";
|
|
4473
4571
|
},
|
|
4572
|
+
{
|
|
4573
|
+
"name": "isStar";
|
|
4574
|
+
"docs": [
|
|
4575
|
+
"Star membership flag (admin-sponsored join flow)"
|
|
4576
|
+
];
|
|
4577
|
+
"type": "bool";
|
|
4578
|
+
},
|
|
4474
4579
|
{
|
|
4475
4580
|
"name": "totalPenaltiesPaid";
|
|
4476
4581
|
"docs": [
|
package/dist/types.d.ts
CHANGED
|
@@ -180,6 +180,12 @@ export interface SeasonMembership {
|
|
|
180
180
|
joinedWindowNumber: BN;
|
|
181
181
|
successfulPostsCount: BN;
|
|
182
182
|
totalRewardsClaimed: BN;
|
|
183
|
+
/** Total signup referral rewards accrued for this membership. */
|
|
184
|
+
totalSignupRewards: BN;
|
|
185
|
+
/** Remaining (unclaimed) signup referral rewards for this membership. */
|
|
186
|
+
remainingSignupRewards: BN;
|
|
187
|
+
/** Star membership flag (admin-sponsored join flow). */
|
|
188
|
+
isStar: boolean;
|
|
183
189
|
totalPenaltiesPaid: BN;
|
|
184
190
|
/** Whether the user has already withdrawn their season deposit (prevents double-withdraw). */
|
|
185
191
|
depositWithdrawn: boolean;
|
|
@@ -102,6 +102,9 @@ function toSdkSeasonMembership(a) {
|
|
|
102
102
|
joinedWindowNumber: a.joinedWindowNumber,
|
|
103
103
|
successfulPostsCount: a.successfulPostsCount,
|
|
104
104
|
totalRewardsClaimed: a.totalRewardsClaimed,
|
|
105
|
+
totalSignupRewards: a.totalSignupRewards,
|
|
106
|
+
remainingSignupRewards: a.remainingSignupRewards,
|
|
107
|
+
isStar: a.isStar,
|
|
105
108
|
totalPenaltiesPaid: a.totalPenaltiesPaid,
|
|
106
109
|
depositWithdrawn: a.depositWithdrawn,
|
|
107
110
|
isActive: a.isActive,
|
|
@@ -134,7 +134,7 @@ export declare function updateMiztakeForSeasonUse(miztake: Miztake, seasonNumber
|
|
|
134
134
|
* @param joinedWindowNumber - Window number when joined
|
|
135
135
|
* @returns Initialized SeasonMembership object
|
|
136
136
|
*/
|
|
137
|
-
export declare function initializeSeasonMembership(user: PublicKey, seasonNumber: BN, depositTier: SeasonDepositTier, referrer: PublicKey, depositAmount: BN, depositEscrowedAmount: BN, joinedAt: BN, joinedWindowNumber: BN, bump: number): SeasonMembership;
|
|
137
|
+
export declare function initializeSeasonMembership(user: PublicKey, seasonNumber: BN, depositTier: SeasonDepositTier, referrer: PublicKey, depositAmount: BN, depositEscrowedAmount: BN, joinedAt: BN, joinedWindowNumber: BN, bump: number, isStar?: boolean): SeasonMembership;
|
|
138
138
|
/**
|
|
139
139
|
* Update Season after a user joins
|
|
140
140
|
* Mirrors the update from join_season.rs (lines 98-104)
|
|
@@ -264,7 +264,7 @@ function updateMiztakeForSeasonUse(miztake, seasonNumber, windowNumber) {
|
|
|
264
264
|
* @param joinedWindowNumber - Window number when joined
|
|
265
265
|
* @returns Initialized SeasonMembership object
|
|
266
266
|
*/
|
|
267
|
-
function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, depositAmount, depositEscrowedAmount, joinedAt, joinedWindowNumber, bump) {
|
|
267
|
+
function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, depositAmount, depositEscrowedAmount, joinedAt, joinedWindowNumber, bump, isStar = false) {
|
|
268
268
|
return {
|
|
269
269
|
owner: user,
|
|
270
270
|
referrer,
|
|
@@ -277,6 +277,9 @@ function initializeSeasonMembership(user, seasonNumber, depositTier, referrer, d
|
|
|
277
277
|
joinedWindowNumber,
|
|
278
278
|
successfulPostsCount: new anchor_1.BN(0),
|
|
279
279
|
totalRewardsClaimed: new anchor_1.BN(0),
|
|
280
|
+
totalSignupRewards: new anchor_1.BN(0),
|
|
281
|
+
remainingSignupRewards: new anchor_1.BN(0),
|
|
282
|
+
isStar,
|
|
280
283
|
totalPenaltiesPaid: new anchor_1.BN(0),
|
|
281
284
|
depositWithdrawn: false,
|
|
282
285
|
isActive: true,
|