proof-of-take-sdk 1.0.0 → 2.1.0
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/getters/index.d.ts +0 -1
- package/dist/getters/index.js +0 -1
- package/dist/idl/proof_of_take.json +54 -458
- package/dist/instructions/claimReferralPenaltyForWindow.d.ts +2 -1
- package/dist/instructions/claimReferralPenaltyForWindow.js +4 -4
- package/dist/instructions/claimWindowRewards.d.ts +2 -1
- package/dist/instructions/claimWindowRewards.js +2 -2
- package/dist/instructions/confirmedPostOnX.d.ts +3 -1
- package/dist/instructions/confirmedPostOnX.js +4 -10
- package/dist/instructions/createMiztake.d.ts +3 -2
- package/dist/instructions/createMiztake.js +5 -5
- package/dist/instructions/joinSeason.d.ts +3 -3
- package/dist/instructions/joinSeason.js +9 -20
- package/dist/instructions/viewSeasonMembershipStatus.d.ts +2 -2
- package/dist/instructions/viewSeasonMembershipStatus.js +3 -3
- package/dist/instructions/withdrawSeasonDeposit.d.ts +3 -1
- package/dist/instructions/withdrawSeasonDeposit.js +3 -7
- package/dist/optimistic/index.d.ts +1 -1
- package/dist/optimistic/index.js +2 -1
- package/dist/types/proof_of_take.d.ts +43 -447
- package/dist/types.d.ts +0 -3
- package/dist/utils/accountUpdates.d.ts +34 -6
- package/dist/utils/accountUpdates.js +57 -10
- package/dist/utils/constants.d.ts +0 -1
- package/dist/utils/constants.js +1 -2
- package/dist/utils/pdaManager.d.ts +6 -6
- package/dist/utils/pdaManager.js +11 -11
- package/dist/utils/pdas.d.ts +21 -12
- package/dist/utils/pdas.js +36 -20
- package/dist/utils/tierPenalty.d.ts +8 -0
- package/dist/utils/tierPenalty.js +30 -0
- package/package.json +1 -1
- package/dist/getters/getTokenVault.d.ts +0 -30
- package/dist/getters/getTokenVault.js +0 -56
|
@@ -16,7 +16,7 @@ async function claimReferralPenaltyForWindow(options) {
|
|
|
16
16
|
referredUser: options.referredUser,
|
|
17
17
|
seasonNumber: options.seasonNumber,
|
|
18
18
|
windowNumber: options.windowNumber,
|
|
19
|
-
|
|
19
|
+
tier: options.tier,
|
|
20
20
|
});
|
|
21
21
|
const accounts = {
|
|
22
22
|
seasonSettings: pdas.seasonSettings,
|
|
@@ -34,7 +34,7 @@ async function claimReferralPenaltyForWindow(options) {
|
|
|
34
34
|
const instruction = await program.methods
|
|
35
35
|
.claimReferralPenaltyForWindow(
|
|
36
36
|
// Anchor expects BN for u64 args.
|
|
37
|
-
options.seasonNumber, options.windowNumber, options.referredUser, options.
|
|
37
|
+
options.seasonNumber, options.windowNumber, options.referredUser, options.tier)
|
|
38
38
|
.accounts(accounts)
|
|
39
39
|
.instruction();
|
|
40
40
|
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.claimant, role: "claimant" }], options.feePayer);
|
|
@@ -45,7 +45,7 @@ async function claimReferralPenaltyForWindow(options) {
|
|
|
45
45
|
const claimedAt = (0, optimistic_1.getCurrentTimestamp)(options.now);
|
|
46
46
|
// The program `init_if_needed` for participation; if caller doesn't provide it, assume it doesn't exist.
|
|
47
47
|
const participation = curr.userWindowParticipation ??
|
|
48
|
-
(0, optimistic_1.initializeUserWindowParticipation)(options.referredUser, options.seasonNumber, options.windowNumber, options.
|
|
48
|
+
(0, optimistic_1.initializeUserWindowParticipation)(options.referredUser, options.seasonNumber, options.windowNumber, options.tier, new anchor_1.BN(0) // miztake_id = 0 for total no-show windows
|
|
49
49
|
);
|
|
50
50
|
// Keep this in sync with on-chain: membership.deposit_tier.penalty_per_window_amount()
|
|
51
51
|
const perWindowPenalty = (0, tierPenalty_1.getTierPenaltyPerWindow)(curr.seasonMembership.depositTier);
|
|
@@ -53,7 +53,7 @@ async function claimReferralPenaltyForWindow(options) {
|
|
|
53
53
|
referredUser: options.referredUser,
|
|
54
54
|
seasonNumber: options.seasonNumber,
|
|
55
55
|
windowNumber: options.windowNumber,
|
|
56
|
-
|
|
56
|
+
tier: options.tier,
|
|
57
57
|
claimant: options.claimant,
|
|
58
58
|
perWindowPenalty,
|
|
59
59
|
claimedAt,
|
|
@@ -20,7 +20,8 @@ export interface ClaimWindowRewardsOptions {
|
|
|
20
20
|
referrerTokenAccount?: PublicKey;
|
|
21
21
|
seasonNumber: BN;
|
|
22
22
|
windowNumber: BN;
|
|
23
|
-
|
|
23
|
+
/** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
|
|
24
|
+
tier: number;
|
|
24
25
|
feePayer?: PublicKey;
|
|
25
26
|
currentAccounts?: {
|
|
26
27
|
seasonSettings?: SeasonSettings;
|
|
@@ -26,7 +26,7 @@ async function claimWindowRewards(options) {
|
|
|
26
26
|
user: options.user,
|
|
27
27
|
seasonNumber: options.seasonNumber,
|
|
28
28
|
windowNumber: options.windowNumber,
|
|
29
|
-
|
|
29
|
+
tier: options.tier,
|
|
30
30
|
});
|
|
31
31
|
const accounts = {
|
|
32
32
|
seasonSettings: pdas.seasonSettings,
|
|
@@ -44,7 +44,7 @@ async function claimWindowRewards(options) {
|
|
|
44
44
|
};
|
|
45
45
|
const instruction = await program.methods
|
|
46
46
|
// Anchor expects BN for u64 args.
|
|
47
|
-
.claimWindowRewards(options.seasonNumber, options.windowNumber)
|
|
47
|
+
.claimWindowRewards(options.seasonNumber, options.windowNumber, options.tier)
|
|
48
48
|
.accounts(accounts)
|
|
49
49
|
.instruction();
|
|
50
50
|
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.user, role: "user" }], options.feePayer);
|
|
@@ -17,7 +17,9 @@ export interface ConfirmedPostOnXOptions {
|
|
|
17
17
|
connection: Connection;
|
|
18
18
|
adminKey: PublicKey;
|
|
19
19
|
user: PublicKey;
|
|
20
|
-
|
|
20
|
+
seasonNumber: BN;
|
|
21
|
+
/** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
|
|
22
|
+
tier: number;
|
|
21
23
|
windowNumber: BN;
|
|
22
24
|
/** SHA-256 hex string (64 chars). On-chain expects the raw 32-byte digest. */
|
|
23
25
|
miztakeShaHash: string;
|
|
@@ -20,15 +20,11 @@ const optimistic_1 = require("../optimistic");
|
|
|
20
20
|
async function confirmedPostOnX(options) {
|
|
21
21
|
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
22
22
|
const curr = options.currentAccounts || {};
|
|
23
|
-
if (!curr.seasonMembership) {
|
|
24
|
-
throw new Error("seasonMembership required for confirmedPostOnX");
|
|
25
|
-
}
|
|
26
|
-
const seasonNumber = curr.seasonMembership.seasonNumber;
|
|
27
23
|
const pdas = pdaManager_1.PDAManager.deriveConfirmedPostPdas({
|
|
28
24
|
user: options.user,
|
|
29
|
-
seasonNumber,
|
|
25
|
+
seasonNumber: options.seasonNumber,
|
|
30
26
|
windowNumber: options.windowNumber,
|
|
31
|
-
|
|
27
|
+
tier: options.tier,
|
|
32
28
|
miztakeShaHash: options.miztakeShaHash,
|
|
33
29
|
});
|
|
34
30
|
const accounts = {
|
|
@@ -41,9 +37,7 @@ async function confirmedPostOnX(options) {
|
|
|
41
37
|
admin: options.adminKey,
|
|
42
38
|
};
|
|
43
39
|
const instruction = await program.methods
|
|
44
|
-
.confirmedPostOnX(options.user,
|
|
45
|
-
// Anchor expects BN for u64 args.
|
|
46
|
-
options.seasonMembershipId, options.windowNumber, Array.from((0, conversions_1.sha256HexToBytes32)(options.miztakeShaHash)))
|
|
40
|
+
.confirmedPostOnX(options.user, options.tier, options.windowNumber, Array.from((0, conversions_1.sha256HexToBytes32)(options.miztakeShaHash)))
|
|
47
41
|
.accounts(accounts)
|
|
48
42
|
.instruction();
|
|
49
43
|
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.adminKey, role: "admin" }], options.feePayer);
|
|
@@ -66,7 +60,7 @@ async function confirmedPostOnX(options) {
|
|
|
66
60
|
season: (0, optimistic_1.updateSeasonForConfirmation)(curr.season, options.isOnTime, stakeAmount),
|
|
67
61
|
}),
|
|
68
62
|
...(curr.miztake && {
|
|
69
|
-
miztake: (0, optimistic_1.updateMiztakeForSeasonUse)(curr.miztake, seasonNumber, options.windowNumber),
|
|
63
|
+
miztake: (0, optimistic_1.updateMiztakeForSeasonUse)(curr.miztake, options.seasonNumber, options.windowNumber),
|
|
70
64
|
}),
|
|
71
65
|
};
|
|
72
66
|
}
|
|
@@ -12,7 +12,8 @@ export interface CreateMiztakeOptions {
|
|
|
12
12
|
admin: PublicKey;
|
|
13
13
|
seasonNumber: BN;
|
|
14
14
|
windowNumber: BN;
|
|
15
|
-
|
|
15
|
+
/** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
|
|
16
|
+
tier: number;
|
|
16
17
|
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
17
18
|
now?: BN;
|
|
18
19
|
feePayer?: PublicKey;
|
|
@@ -72,7 +73,7 @@ export interface CreateMiztakeResult {
|
|
|
72
73
|
* admin: adminWallet.publicKey,
|
|
73
74
|
* seasonNumber: new BN(1),
|
|
74
75
|
* windowNumber: new BN(5),
|
|
75
|
-
*
|
|
76
|
+
* tier: 2, // silver
|
|
76
77
|
* currentAccounts: {
|
|
77
78
|
* userStats: currentUserStats,
|
|
78
79
|
* miztakeStatistics: currentStats,
|
|
@@ -30,7 +30,7 @@ const enumHelpers_1 = require("../utils/enumHelpers");
|
|
|
30
30
|
* admin: adminWallet.publicKey,
|
|
31
31
|
* seasonNumber: new BN(1),
|
|
32
32
|
* windowNumber: new BN(5),
|
|
33
|
-
*
|
|
33
|
+
* tier: 2, // silver
|
|
34
34
|
* currentAccounts: {
|
|
35
35
|
* userStats: currentUserStats,
|
|
36
36
|
* miztakeStatistics: currentStats,
|
|
@@ -48,8 +48,8 @@ async function createMiztake(options) {
|
|
|
48
48
|
telegramId: options.params.telegramId,
|
|
49
49
|
seasonNumber: options.seasonNumber,
|
|
50
50
|
windowNumber: options.windowNumber,
|
|
51
|
-
seasonMembershipId: options.seasonMembershipId,
|
|
52
51
|
user: options.user,
|
|
52
|
+
tier: options.tier,
|
|
53
53
|
});
|
|
54
54
|
// Build typed accounts object
|
|
55
55
|
const accounts = {
|
|
@@ -70,7 +70,7 @@ async function createMiztake(options) {
|
|
|
70
70
|
const instruction = await program.methods
|
|
71
71
|
.createMiztake(
|
|
72
72
|
// Anchor expects BN for u64 args.
|
|
73
|
-
options.params.telegramId, options.params.telegramUsername, options.params.perceptualHash, options.params.averageHash, options.params.differenceHash, options.params.waveletHash, options.params.shaHash, Array.from(shaHashBytes), options.params.computedAt, options.seasonNumber, options.windowNumber, options.
|
|
73
|
+
options.params.telegramId, options.params.telegramUsername, options.params.perceptualHash, options.params.averageHash, options.params.differenceHash, options.params.waveletHash, options.params.shaHash, Array.from(shaHashBytes), options.params.computedAt, options.seasonNumber, options.windowNumber, options.tier)
|
|
74
74
|
.accounts(accounts)
|
|
75
75
|
.instruction();
|
|
76
76
|
// Build signers
|
|
@@ -97,7 +97,7 @@ async function createMiztake(options) {
|
|
|
97
97
|
newMiztakeId = new anchor_1.BN(1); // Placeholder
|
|
98
98
|
}
|
|
99
99
|
// 3. Initialize UserWindowParticipation
|
|
100
|
-
const updatedUserWindowParticipation = (0, optimistic_1.initializeUserWindowParticipation)(options.user, options.seasonNumber, options.windowNumber, options.
|
|
100
|
+
const updatedUserWindowParticipation = (0, optimistic_1.initializeUserWindowParticipation)(options.user, options.seasonNumber, options.windowNumber, options.tier, newMiztakeId);
|
|
101
101
|
// 4. Initialize RewardWindow if needed
|
|
102
102
|
let updatedRewardWindow;
|
|
103
103
|
if (curr.rewardWindow) {
|
|
@@ -160,7 +160,7 @@ function getMiztakePdaForParams(params) {
|
|
|
160
160
|
telegramId: params.telegramId,
|
|
161
161
|
seasonNumber: new anchor_1.BN(0),
|
|
162
162
|
windowNumber: new anchor_1.BN(0),
|
|
163
|
-
seasonMembershipId: new anchor_1.BN(0),
|
|
164
163
|
user: web3_js_1.PublicKey.default,
|
|
164
|
+
tier: 1,
|
|
165
165
|
}).miztake;
|
|
166
166
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BN } from "@coral-xyz/anchor";
|
|
2
2
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
3
|
-
import { Season, SeasonMembership, SeasonSettings
|
|
3
|
+
import { Season, SeasonMembership, SeasonSettings } from "../types";
|
|
4
4
|
import { SignerInfo } from "../utils/signerHelpers";
|
|
5
5
|
/**
|
|
6
6
|
* Options for joinSeason instruction
|
|
@@ -9,9 +9,9 @@ export interface JoinSeasonOptions {
|
|
|
9
9
|
connection: Connection;
|
|
10
10
|
user: PublicKey;
|
|
11
11
|
userTokenAccount: PublicKey;
|
|
12
|
-
seasonMembershipId: BN;
|
|
13
12
|
seasonNumber: BN;
|
|
14
|
-
|
|
13
|
+
/** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
|
|
14
|
+
tier: number;
|
|
15
15
|
/** Optional referrer (PublicKey.default means no referrer) */
|
|
16
16
|
referrer?: PublicKey;
|
|
17
17
|
/** Optional injected timestamp (seconds) for optimistic state calculation */
|
|
@@ -11,6 +11,7 @@ const programHelpers_1 = require("../utils/programHelpers");
|
|
|
11
11
|
const signerHelpers_1 = require("../utils/signerHelpers");
|
|
12
12
|
const optimistic_1 = require("../optimistic");
|
|
13
13
|
const pdas_1 = require("../utils/pdas");
|
|
14
|
+
const tierPenalty_1 = require("../utils/tierPenalty");
|
|
14
15
|
/**
|
|
15
16
|
* Join a season
|
|
16
17
|
*
|
|
@@ -26,7 +27,7 @@ async function joinSeason(options) {
|
|
|
26
27
|
const pdas = pdaManager_1.PDAManager.deriveJoinSeasonPdas({
|
|
27
28
|
user: options.user,
|
|
28
29
|
seasonNumber: options.seasonNumber,
|
|
29
|
-
|
|
30
|
+
tier: options.tier,
|
|
30
31
|
});
|
|
31
32
|
const accounts = {
|
|
32
33
|
seasonSettings: pdas.seasonSettings,
|
|
@@ -42,7 +43,7 @@ async function joinSeason(options) {
|
|
|
42
43
|
};
|
|
43
44
|
const instruction = await program.methods
|
|
44
45
|
// Anchor expects BN for u64 args.
|
|
45
|
-
.joinSeason(options.
|
|
46
|
+
.joinSeason(options.seasonNumber, options.tier, options.referrer ?? web3_js_1.PublicKey.default)
|
|
46
47
|
.accounts(accounts)
|
|
47
48
|
.instruction();
|
|
48
49
|
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.user, role: "user" }], options.feePayer);
|
|
@@ -52,12 +53,13 @@ async function joinSeason(options) {
|
|
|
52
53
|
let newSeasonMembership;
|
|
53
54
|
let updatedSeason;
|
|
54
55
|
if (curr.seasonSettings) {
|
|
55
|
-
const [, bump] = (0, pdas_1.getSeasonMembershipPda)(options.user, options.
|
|
56
|
+
const [, bump] = (0, pdas_1.getSeasonMembershipPda)(options.seasonNumber, options.user, options.tier);
|
|
56
57
|
// Mirror on-chain join_season.rs:
|
|
57
58
|
// current_window = (now - season.started_at) / window_duration (integer division)
|
|
58
59
|
// joined_window_number = current_window (after bounds checks)
|
|
59
60
|
const totalWindows = curr.seasonSettings.totalWindowsPerSeason;
|
|
60
|
-
const
|
|
61
|
+
const depositTier = (0, tierPenalty_1.tierNumberToDepositTier)(options.tier);
|
|
62
|
+
const perWindowPenalty = (0, tierPenalty_1.getTierPenaltyPerWindow)(depositTier);
|
|
61
63
|
const depositFull = perWindowPenalty.muln(totalWindows);
|
|
62
64
|
let joinedWindowNumber = new anchor_1.BN(0);
|
|
63
65
|
if (curr.season) {
|
|
@@ -82,9 +84,9 @@ async function joinSeason(options) {
|
|
|
82
84
|
}
|
|
83
85
|
const depositEscrowed = perWindowPenalty.mul(joinedWindowNumber);
|
|
84
86
|
const depositActive = depositFull.sub(depositEscrowed);
|
|
85
|
-
newSeasonMembership = (0, optimistic_1.initializeSeasonMembership)(options.user, options.
|
|
87
|
+
newSeasonMembership = (0, optimistic_1.initializeSeasonMembership)(options.user, options.seasonNumber, depositTier, options.referrer ?? web3_js_1.PublicKey.default, depositActive, depositEscrowed, now, joinedWindowNumber, bump);
|
|
86
88
|
if (curr.season) {
|
|
87
|
-
updatedSeason = (0, optimistic_1.updateSeasonForJoin)(curr.season, depositActive,
|
|
89
|
+
updatedSeason = (0, optimistic_1.updateSeasonForJoin)(curr.season, depositActive, depositTier, joinedWindowNumber, totalWindows);
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
return {
|
|
@@ -104,17 +106,4 @@ async function joinSeason(options) {
|
|
|
104
106
|
: {}),
|
|
105
107
|
};
|
|
106
108
|
}
|
|
107
|
-
|
|
108
|
-
// Base units (7 decimals): 1 MIZD = 10_000_000
|
|
109
|
-
if ("copper" in tier)
|
|
110
|
-
return new anchor_1.BN(1000000); // 0.1 MIZD
|
|
111
|
-
if ("silver" in tier)
|
|
112
|
-
return new anchor_1.BN(10000000); // 1 MIZD
|
|
113
|
-
if ("gold" in tier)
|
|
114
|
-
return new anchor_1.BN(100000000); // 10 MIZD
|
|
115
|
-
if ("platinum" in tier)
|
|
116
|
-
return new anchor_1.BN(1000000000); // 100 MIZD
|
|
117
|
-
if ("mithril" in tier)
|
|
118
|
-
return new anchor_1.BN(10000000000); // 1,000 MIZD
|
|
119
|
-
throw new Error("Unknown depositTier");
|
|
120
|
-
}
|
|
109
|
+
// getTierPenaltyPerWindow imported from ../utils/tierPenalty
|
|
@@ -9,8 +9,8 @@ import { SeasonMembershipStatusView } from "../types";
|
|
|
9
9
|
*
|
|
10
10
|
* @param connection - Solana connection
|
|
11
11
|
* @param user - User's public key
|
|
12
|
-
* @param seasonMembershipId - Membership ID
|
|
13
12
|
* @param seasonNumber - Season number
|
|
13
|
+
* @param tier - Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril
|
|
14
14
|
* @returns View data with membership status
|
|
15
15
|
*/
|
|
16
|
-
export declare function viewSeasonMembershipStatus(connection: Connection, user: PublicKey,
|
|
16
|
+
export declare function viewSeasonMembershipStatus(connection: Connection, user: PublicKey, seasonNumber: BN, tier: number): Promise<SeasonMembershipStatusView>;
|
|
@@ -11,14 +11,14 @@ const programHelpers_1 = require("../utils/programHelpers");
|
|
|
11
11
|
*
|
|
12
12
|
* @param connection - Solana connection
|
|
13
13
|
* @param user - User's public key
|
|
14
|
-
* @param seasonMembershipId - Membership ID
|
|
15
14
|
* @param seasonNumber - Season number
|
|
15
|
+
* @param tier - Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril
|
|
16
16
|
* @returns View data with membership status
|
|
17
17
|
*/
|
|
18
|
-
async function viewSeasonMembershipStatus(connection, user,
|
|
18
|
+
async function viewSeasonMembershipStatus(connection, user, seasonNumber, tier) {
|
|
19
19
|
const program = (0, programHelpers_1.getProgram)(connection);
|
|
20
20
|
const [seasonSettingsPda] = (0, pdas_1.getSeasonSettingsPda)();
|
|
21
|
-
const [seasonMembershipPda] = (0, pdas_1.getSeasonMembershipPda)(user,
|
|
21
|
+
const [seasonMembershipPda] = (0, pdas_1.getSeasonMembershipPda)(seasonNumber, user, tier);
|
|
22
22
|
const [seasonPda] = (0, pdas_1.getSeasonPda)(seasonNumber);
|
|
23
23
|
const accounts = {
|
|
24
24
|
seasonSettings: seasonSettingsPda,
|
|
@@ -14,7 +14,9 @@ export interface WithdrawSeasonDepositOptions {
|
|
|
14
14
|
connection: Connection;
|
|
15
15
|
user: PublicKey;
|
|
16
16
|
userTokenAccount: PublicKey;
|
|
17
|
-
|
|
17
|
+
seasonNumber: BN;
|
|
18
|
+
/** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
|
|
19
|
+
tier: number;
|
|
18
20
|
feePayer?: PublicKey;
|
|
19
21
|
currentAccounts?: {
|
|
20
22
|
seasonSettings?: SeasonSettings;
|
|
@@ -20,14 +20,10 @@ const optimistic_1 = require("../optimistic");
|
|
|
20
20
|
async function withdrawSeasonDeposit(options) {
|
|
21
21
|
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
22
22
|
const curr = options.currentAccounts || {};
|
|
23
|
-
if (!curr.seasonMembership) {
|
|
24
|
-
throw new Error("seasonMembership required for withdrawSeasonDeposit");
|
|
25
|
-
}
|
|
26
|
-
const seasonNumber = curr.seasonMembership.seasonNumber;
|
|
27
23
|
const pdas = pdaManager_1.PDAManager.deriveWithdrawDepositPdas({
|
|
28
24
|
user: options.user,
|
|
29
|
-
seasonNumber,
|
|
30
|
-
|
|
25
|
+
seasonNumber: options.seasonNumber,
|
|
26
|
+
tier: options.tier,
|
|
31
27
|
});
|
|
32
28
|
const accounts = {
|
|
33
29
|
seasonSettings: pdas.seasonSettings,
|
|
@@ -41,7 +37,7 @@ async function withdrawSeasonDeposit(options) {
|
|
|
41
37
|
tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
|
|
42
38
|
};
|
|
43
39
|
const instruction = await program.methods
|
|
44
|
-
.withdrawSeasonDeposit()
|
|
40
|
+
.withdrawSeasonDeposit(options.tier)
|
|
45
41
|
.accounts(accounts)
|
|
46
42
|
.instruction();
|
|
47
43
|
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.user, role: "user" }], options.feePayer);
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* This module contains all optimistic update logic separated from instruction building.
|
|
5
5
|
* Each function mirrors the on-chain logic to predict state changes before confirmation.
|
|
6
6
|
*/
|
|
7
|
-
export { getCurrentTimestamp, createEmptyUserStats, initializeUserStats, updateUserStatsForMiztakeCreation, updateMiztakeStatisticsForCreation, initializeUserWindowParticipation, initializeRewardWindow, updateMiztakeForSeasonUse, initializeSeasonMembership, updateSeasonForJoin, updateWindowForConfirmation, updateParticipationForConfirmation, updateMembershipForConfirmation, updateSeasonForConfirmation, updateWindowForFinalization, updateParticipationForClaim, updateMembershipForClaim, initializeReferralPenaltyClaim, calculateWithdrawalAmount, updateSeasonSettingsForPauseToggle, updateSeasonSettingsForAdminUpdate, } from "../utils/accountUpdates";
|
|
7
|
+
export { getCurrentTimestamp, expectedToBeLazyInitialized, createEmptyUserStats, initializeUserStats, updateUserStatsForMiztakeCreation, updateMiztakeStatisticsForCreation, initializeUserWindowParticipation, initializeRewardWindow, updateMiztakeForSeasonUse, initializeSeasonMembership, updateSeasonForJoin, updateWindowForConfirmation, updateParticipationForConfirmation, updateMembershipForConfirmation, updateSeasonForConfirmation, updateWindowForFinalization, updateParticipationForClaim, updateMembershipForClaim, initializeReferralPenaltyClaim, calculateWithdrawalAmount, updateSeasonSettingsForPauseToggle, updateSeasonSettingsForAdminUpdate, } from "../utils/accountUpdates";
|
package/dist/optimistic/index.js
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
* Each function mirrors the on-chain logic to predict state changes before confirmation.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.updateSeasonSettingsForAdminUpdate = exports.updateSeasonSettingsForPauseToggle = exports.calculateWithdrawalAmount = exports.initializeReferralPenaltyClaim = exports.updateMembershipForClaim = exports.updateParticipationForClaim = exports.updateWindowForFinalization = exports.updateSeasonForConfirmation = exports.updateMembershipForConfirmation = exports.updateParticipationForConfirmation = exports.updateWindowForConfirmation = exports.updateSeasonForJoin = exports.initializeSeasonMembership = exports.updateMiztakeForSeasonUse = exports.initializeRewardWindow = exports.initializeUserWindowParticipation = exports.updateMiztakeStatisticsForCreation = exports.updateUserStatsForMiztakeCreation = exports.initializeUserStats = exports.createEmptyUserStats = exports.getCurrentTimestamp = void 0;
|
|
9
|
+
exports.updateSeasonSettingsForAdminUpdate = exports.updateSeasonSettingsForPauseToggle = exports.calculateWithdrawalAmount = exports.initializeReferralPenaltyClaim = exports.updateMembershipForClaim = exports.updateParticipationForClaim = exports.updateWindowForFinalization = exports.updateSeasonForConfirmation = exports.updateMembershipForConfirmation = exports.updateParticipationForConfirmation = exports.updateWindowForConfirmation = exports.updateSeasonForJoin = exports.initializeSeasonMembership = exports.updateMiztakeForSeasonUse = exports.initializeRewardWindow = exports.initializeUserWindowParticipation = exports.updateMiztakeStatisticsForCreation = exports.updateUserStatsForMiztakeCreation = exports.initializeUserStats = exports.createEmptyUserStats = exports.expectedToBeLazyInitialized = exports.getCurrentTimestamp = void 0;
|
|
10
10
|
// Re-export all optimistic update functions from accountUpdates
|
|
11
11
|
// This provides a cleaner separation of concerns
|
|
12
12
|
var accountUpdates_1 = require("../utils/accountUpdates");
|
|
13
13
|
Object.defineProperty(exports, "getCurrentTimestamp", { enumerable: true, get: function () { return accountUpdates_1.getCurrentTimestamp; } });
|
|
14
|
+
Object.defineProperty(exports, "expectedToBeLazyInitialized", { enumerable: true, get: function () { return accountUpdates_1.expectedToBeLazyInitialized; } });
|
|
14
15
|
Object.defineProperty(exports, "createEmptyUserStats", { enumerable: true, get: function () { return accountUpdates_1.createEmptyUserStats; } });
|
|
15
16
|
Object.defineProperty(exports, "initializeUserStats", { enumerable: true, get: function () { return accountUpdates_1.initializeUserStats; } });
|
|
16
17
|
Object.defineProperty(exports, "updateUserStatsForMiztakeCreation", { enumerable: true, get: function () { return accountUpdates_1.updateUserStatsForMiztakeCreation; } });
|