proof-of-take-sdk 3.0.2 → 3.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.
@@ -11,6 +11,8 @@ export declare const SEASON_CONSTANTS: {
11
11
  readonly SEASON_DURATION: 604800;
12
12
  /** Duration of each window in seconds (8 hours) */
13
13
  readonly WINDOW_DURATION: 28800;
14
+ /** Claim buffer duration in seconds (5 minutes) */
15
+ readonly CLAIM_BUFFER_DURATION: 300;
14
16
  /** Total number of windows per season */
15
17
  readonly TOTAL_WINDOWS_PER_SEASON: 21;
16
18
  /** Maximum members allowed per season (DOS protection) */
@@ -15,6 +15,8 @@ exports.SEASON_CONSTANTS = {
15
15
  SEASON_DURATION: 604800,
16
16
  /** Duration of each window in seconds (8 hours) */
17
17
  WINDOW_DURATION: 28800,
18
+ /** Claim buffer duration in seconds (5 minutes) */
19
+ CLAIM_BUFFER_DURATION: 300,
18
20
  /** Total number of windows per season */
19
21
  TOTAL_WINDOWS_PER_SEASON: 21,
20
22
  /** Maximum members allowed per season (DOS protection) */
@@ -1135,6 +1135,123 @@
1135
1135
  }
1136
1136
  ]
1137
1137
  },
1138
+ {
1139
+ "name": "initialize_reward_window",
1140
+ "discriminator": [
1141
+ 206,
1142
+ 116,
1143
+ 55,
1144
+ 128,
1145
+ 199,
1146
+ 75,
1147
+ 194,
1148
+ 213
1149
+ ],
1150
+ "accounts": [
1151
+ {
1152
+ "name": "season_settings",
1153
+ "pda": {
1154
+ "seeds": [
1155
+ {
1156
+ "kind": "const",
1157
+ "value": [
1158
+ 115,
1159
+ 101,
1160
+ 97,
1161
+ 115,
1162
+ 111,
1163
+ 110,
1164
+ 95,
1165
+ 115,
1166
+ 101,
1167
+ 116,
1168
+ 116,
1169
+ 105,
1170
+ 110,
1171
+ 103,
1172
+ 115
1173
+ ]
1174
+ }
1175
+ ]
1176
+ }
1177
+ },
1178
+ {
1179
+ "name": "season",
1180
+ "pda": {
1181
+ "seeds": [
1182
+ {
1183
+ "kind": "const",
1184
+ "value": [
1185
+ 115,
1186
+ 101,
1187
+ 97,
1188
+ 115,
1189
+ 111,
1190
+ 110
1191
+ ]
1192
+ },
1193
+ {
1194
+ "kind": "arg",
1195
+ "path": "season_number"
1196
+ }
1197
+ ]
1198
+ }
1199
+ },
1200
+ {
1201
+ "name": "reward_window",
1202
+ "writable": true,
1203
+ "pda": {
1204
+ "seeds": [
1205
+ {
1206
+ "kind": "const",
1207
+ "value": [
1208
+ 114,
1209
+ 101,
1210
+ 119,
1211
+ 97,
1212
+ 114,
1213
+ 100,
1214
+ 95,
1215
+ 119,
1216
+ 105,
1217
+ 110,
1218
+ 100,
1219
+ 111,
1220
+ 119
1221
+ ]
1222
+ },
1223
+ {
1224
+ "kind": "arg",
1225
+ "path": "season_number"
1226
+ },
1227
+ {
1228
+ "kind": "arg",
1229
+ "path": "window_number"
1230
+ }
1231
+ ]
1232
+ }
1233
+ },
1234
+ {
1235
+ "name": "admin",
1236
+ "writable": true,
1237
+ "signer": true
1238
+ },
1239
+ {
1240
+ "name": "system_program",
1241
+ "address": "11111111111111111111111111111111"
1242
+ }
1243
+ ],
1244
+ "args": [
1245
+ {
1246
+ "name": "season_number",
1247
+ "type": "u64"
1248
+ },
1249
+ {
1250
+ "name": "window_number",
1251
+ "type": "u64"
1252
+ }
1253
+ ]
1254
+ },
1138
1255
  {
1139
1256
  "name": "initialize_season_settings",
1140
1257
  "discriminator": [
package/dist/index.d.ts CHANGED
@@ -22,6 +22,8 @@ export { claimReferralPenaltyForWindow } from "./instructions/claimReferralPenal
22
22
  export type { ClaimReferralPenaltyForWindowOptions } from "./instructions/claimReferralPenaltyForWindow";
23
23
  export { withdrawSeasonDeposit } from "./instructions/withdrawSeasonDeposit";
24
24
  export type { WithdrawSeasonDepositOptions } from "./instructions/withdrawSeasonDeposit";
25
+ export { initializeRewardWindow } from "./instructions/initializeRewardWindow";
26
+ export type { InitializeRewardWindowOptions, InitializeRewardWindowPdas, } from "./instructions/initializeRewardWindow";
25
27
  export { toggleSeasonPause } from "./instructions/toggleSeasonPause";
26
28
  export { updateSeasonAdmin } from "./instructions/updateSeasonAdmin";
27
29
  export { viewSeasonMembershipStatus } from "./instructions/viewSeasonMembershipStatus";
@@ -45,7 +47,7 @@ export * from "./constants/season";
45
47
  export * from "./types";
46
48
  export * from "./types/instructionResults";
47
49
  export * from "./types/accountTypes";
48
- export type { ProofOfTakeIdlAccounts, AnchorMiztake, AnchorMiztakeStatistics, AnchorUserStats, AnchorSeasonSettings, AnchorSeason, AnchorSeasonMembership, AnchorRewardWindow, AnchorUserWindowParticipation, AnchorReferralPenaltyClaim, ProofOfTakeIdlTypes, AnchorCurrentSeasonView, AnchorSeasonMembershipStatusView, AnchorWindowStatusView, TierNumber, Sha256HexString, Bytes32, WindowIndex, WindowNumberLike, DepositTierName, SeasonDepositTier, SeasonStateAnchor, WindowStateAnchor, SeasonStateLike, WindowStateLike, FixedLengthArray, EligibleStakePerWindow, } from "./types";
50
+ export type { ProofOfTakeIdlAccounts, AnchorMiztake, AnchorMiztakeStatistics, AnchorUserStats, AnchorSeasonSettings, AnchorSeason, AnchorSeasonMembership, AnchorRewardWindow, AnchorUserWindowParticipation, AnchorReferralPenaltyClaim, ProofOfTakeIdlTypes, AnchorCurrentSeasonView, AnchorSeasonMembershipStatusView, AnchorWindowStatusView, TierNumber, Sha256HexString, Bytes32, WindowIndex, WindowNumberLike, SeasonNumberLike, DepositTierName, SeasonDepositTier, SeasonStateAnchor, WindowStateAnchor, SeasonStateLike, WindowStateLike, FixedLengthArray, EligibleStakePerWindow, } from "./types";
49
51
  export type { StandardInstructionResult, StandardInstructionResultWithPdas, StandardInstructionResultWithPdasAndAccounts, } from "./types/instructionResults";
50
52
  export type { ProofOfTake } from "./types/proof_of_take";
51
53
  export { IDL } from "./idl/idl";
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
21
21
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.VERSION = exports.getProgramReadOnly = exports.createProgramWithId = exports.createProgram = exports.IDL = exports.PDAManager = exports.getProgram = exports.viewCurrentSeason = exports.viewWindowStatus = exports.viewSeasonMembershipStatus = exports.updateSeasonAdmin = exports.toggleSeasonPause = exports.withdrawSeasonDeposit = exports.claimReferralPenaltyForWindow = exports.claimWindowRewards = exports.confirmedPostOnX = exports.joinSeason = exports.initializeEscrowVault = exports.initializeSeasonVault = exports.initializeSeasonSettings = exports.initializeStatistics = exports.getMiztakePdaForParams = exports.createMiztake = void 0;
24
+ exports.VERSION = exports.getProgramReadOnly = exports.createProgramWithId = exports.createProgram = exports.IDL = exports.PDAManager = exports.getProgram = exports.viewCurrentSeason = exports.viewWindowStatus = exports.viewSeasonMembershipStatus = exports.updateSeasonAdmin = exports.toggleSeasonPause = exports.initializeRewardWindow = exports.withdrawSeasonDeposit = exports.claimReferralPenaltyForWindow = exports.claimWindowRewards = exports.confirmedPostOnX = exports.joinSeason = exports.initializeEscrowVault = exports.initializeSeasonVault = exports.initializeSeasonSettings = exports.initializeStatistics = exports.getMiztakePdaForParams = exports.createMiztake = void 0;
25
25
  // NOTE:
26
26
  // We intentionally export `getProgram` via a local const assignment (instead of `export * from ...`)
27
27
  // so that the compiled CommonJS output uses a writable property. This makes it possible to mock
@@ -53,6 +53,8 @@ Object.defineProperty(exports, "claimReferralPenaltyForWindow", { enumerable: tr
53
53
  var withdrawSeasonDeposit_1 = require("./instructions/withdrawSeasonDeposit");
54
54
  Object.defineProperty(exports, "withdrawSeasonDeposit", { enumerable: true, get: function () { return withdrawSeasonDeposit_1.withdrawSeasonDeposit; } });
55
55
  // Season admin instructions
56
+ var initializeRewardWindow_1 = require("./instructions/initializeRewardWindow");
57
+ Object.defineProperty(exports, "initializeRewardWindow", { enumerable: true, get: function () { return initializeRewardWindow_1.initializeRewardWindow; } });
56
58
  var toggleSeasonPause_1 = require("./instructions/toggleSeasonPause");
57
59
  Object.defineProperty(exports, "toggleSeasonPause", { enumerable: true, get: function () { return toggleSeasonPause_1.toggleSeasonPause; } });
58
60
  var updateSeasonAdmin_1 = require("./instructions/updateSeasonAdmin");
@@ -0,0 +1,23 @@
1
+ import { Connection, PublicKey } from "@solana/web3.js";
2
+ import { StandardInstructionResultWithPdas } from "../types/instructionResults";
3
+ import type { SeasonNumberLike, WindowNumberLike } from "../types";
4
+ export type InitializeRewardWindowPdas = {
5
+ seasonSettings: PublicKey;
6
+ season: PublicKey;
7
+ rewardWindow: PublicKey;
8
+ };
9
+ export interface InitializeRewardWindowOptions {
10
+ connection: Connection;
11
+ /** Root admin public key (must sign and pays for account creation). */
12
+ admin: PublicKey;
13
+ seasonNumber: SeasonNumberLike;
14
+ windowNumber: WindowNumberLike;
15
+ feePayer?: PublicKey;
16
+ }
17
+ /**
18
+ * Initialize (materialize) a missing RewardWindow PDA (root-admin only).
19
+ *
20
+ * This is a maintenance instruction used to ensure a `RewardWindow` exists even in windows with
21
+ * no miztake creation, so empty windows can be finalized and season accounting can be reconciled.
22
+ */
23
+ export declare function initializeRewardWindow(options: InitializeRewardWindowOptions): Promise<StandardInstructionResultWithPdas<InitializeRewardWindowPdas>>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initializeRewardWindow = initializeRewardWindow;
4
+ const web3_js_1 = require("@solana/web3.js");
5
+ const pdas_1 = require("../utils/pdas");
6
+ const programHelpers_1 = require("../utils/programHelpers");
7
+ const signerHelpers_1 = require("../utils/signerHelpers");
8
+ const conversions_1 = require("../utils/conversions");
9
+ /**
10
+ * Initialize (materialize) a missing RewardWindow PDA (root-admin only).
11
+ *
12
+ * This is a maintenance instruction used to ensure a `RewardWindow` exists even in windows with
13
+ * no miztake creation, so empty windows can be finalized and season accounting can be reconciled.
14
+ */
15
+ async function initializeRewardWindow(options) {
16
+ const program = (0, programHelpers_1.getProgram)(options.connection);
17
+ const seasonNumberBn = (0, conversions_1.toSeasonNumberBn)(options.seasonNumber);
18
+ const windowNumberBn = (0, conversions_1.toWindowNumberBn)(options.windowNumber);
19
+ const [seasonSettings] = (0, pdas_1.getSeasonSettingsPda)();
20
+ const [season] = (0, pdas_1.getSeasonPda)(seasonNumberBn);
21
+ const [rewardWindow] = (0, pdas_1.getRewardWindowPda)(seasonNumberBn, windowNumberBn);
22
+ const accounts = {
23
+ seasonSettings,
24
+ season,
25
+ rewardWindow,
26
+ admin: options.admin,
27
+ systemProgram: web3_js_1.SystemProgram.programId,
28
+ };
29
+ const instruction = await program.methods
30
+ .initializeRewardWindow(seasonNumberBn, windowNumberBn)
31
+ .accounts(accounts)
32
+ .instruction();
33
+ const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
34
+ return {
35
+ instructions: [instruction],
36
+ signers,
37
+ pdas: { seasonSettings, season, rewardWindow },
38
+ };
39
+ }
@@ -35,6 +35,13 @@ export interface InitializeEscrowVaultAccounts {
35
35
  tokenProgram: PublicKey;
36
36
  systemProgram: PublicKey;
37
37
  }
38
+ export interface InitializeRewardWindowAccounts {
39
+ seasonSettings: PublicKey;
40
+ season: PublicKey;
41
+ rewardWindow: PublicKey;
42
+ admin: PublicKey;
43
+ systemProgram: PublicKey;
44
+ }
38
45
  export interface InitializeStatisticsAccounts {
39
46
  miztakeStatistics: PublicKey;
40
47
  admin: PublicKey;
@@ -1141,6 +1141,123 @@ export type ProofOfTake = {
1141
1141
  }
1142
1142
  ];
1143
1143
  },
1144
+ {
1145
+ "name": "initializeRewardWindow";
1146
+ "discriminator": [
1147
+ 206,
1148
+ 116,
1149
+ 55,
1150
+ 128,
1151
+ 199,
1152
+ 75,
1153
+ 194,
1154
+ 213
1155
+ ];
1156
+ "accounts": [
1157
+ {
1158
+ "name": "seasonSettings";
1159
+ "pda": {
1160
+ "seeds": [
1161
+ {
1162
+ "kind": "const";
1163
+ "value": [
1164
+ 115,
1165
+ 101,
1166
+ 97,
1167
+ 115,
1168
+ 111,
1169
+ 110,
1170
+ 95,
1171
+ 115,
1172
+ 101,
1173
+ 116,
1174
+ 116,
1175
+ 105,
1176
+ 110,
1177
+ 103,
1178
+ 115
1179
+ ];
1180
+ }
1181
+ ];
1182
+ };
1183
+ },
1184
+ {
1185
+ "name": "season";
1186
+ "pda": {
1187
+ "seeds": [
1188
+ {
1189
+ "kind": "const";
1190
+ "value": [
1191
+ 115,
1192
+ 101,
1193
+ 97,
1194
+ 115,
1195
+ 111,
1196
+ 110
1197
+ ];
1198
+ },
1199
+ {
1200
+ "kind": "arg";
1201
+ "path": "seasonNumber";
1202
+ }
1203
+ ];
1204
+ };
1205
+ },
1206
+ {
1207
+ "name": "rewardWindow";
1208
+ "writable": true;
1209
+ "pda": {
1210
+ "seeds": [
1211
+ {
1212
+ "kind": "const";
1213
+ "value": [
1214
+ 114,
1215
+ 101,
1216
+ 119,
1217
+ 97,
1218
+ 114,
1219
+ 100,
1220
+ 95,
1221
+ 119,
1222
+ 105,
1223
+ 110,
1224
+ 100,
1225
+ 111,
1226
+ 119
1227
+ ];
1228
+ },
1229
+ {
1230
+ "kind": "arg";
1231
+ "path": "seasonNumber";
1232
+ },
1233
+ {
1234
+ "kind": "arg";
1235
+ "path": "windowNumber";
1236
+ }
1237
+ ];
1238
+ };
1239
+ },
1240
+ {
1241
+ "name": "admin";
1242
+ "writable": true;
1243
+ "signer": true;
1244
+ },
1245
+ {
1246
+ "name": "systemProgram";
1247
+ "address": "11111111111111111111111111111111";
1248
+ }
1249
+ ];
1250
+ "args": [
1251
+ {
1252
+ "name": "seasonNumber";
1253
+ "type": "u64";
1254
+ },
1255
+ {
1256
+ "name": "windowNumber";
1257
+ "type": "u64";
1258
+ }
1259
+ ];
1260
+ },
1144
1261
  {
1145
1262
  "name": "initializeSeasonSettings";
1146
1263
  "discriminator": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proof-of-take-sdk",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "TypeScript SDK for Proof of Take Solana program",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",