proof-of-take-sdk 3.0.0 → 3.0.2

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.
Files changed (79) hide show
  1. package/dist/client.js +3 -3
  2. package/dist/getters/getMiztake.d.ts +2 -2
  3. package/dist/getters/getMiztake.js +2 -15
  4. package/dist/getters/getMiztakeStatistics.js +2 -2
  5. package/dist/getters/getReferralPenaltyClaim.d.ts +9 -0
  6. package/dist/getters/getReferralPenaltyClaim.js +20 -0
  7. package/dist/getters/getRewardWindow.d.ts +9 -0
  8. package/dist/getters/getRewardWindow.js +20 -0
  9. package/dist/getters/getSeason.d.ts +8 -0
  10. package/dist/getters/getSeason.js +20 -0
  11. package/dist/getters/getSeasonMembership.d.ts +9 -0
  12. package/dist/getters/getSeasonMembership.js +18 -0
  13. package/dist/getters/getSeasonSettings.d.ts +8 -0
  14. package/dist/getters/getSeasonSettings.js +18 -0
  15. package/dist/getters/getUserStats.js +3 -10
  16. package/dist/getters/getUserWindowParticipation.d.ts +9 -0
  17. package/dist/getters/getUserWindowParticipation.js +20 -0
  18. package/dist/getters/index.d.ts +6 -0
  19. package/dist/getters/index.js +6 -0
  20. package/dist/idl/idl.d.ts +5 -0
  21. package/dist/idl/idl.js +5 -1
  22. package/dist/idl/proof_of_take.json +32 -0
  23. package/dist/index.d.ts +7 -1
  24. package/dist/index.js +10 -2
  25. package/dist/instructions/claimReferralPenaltyForWindow.d.ts +17 -14
  26. package/dist/instructions/claimReferralPenaltyForWindow.js +7 -4
  27. package/dist/instructions/claimWindowRewards.d.ts +14 -10
  28. package/dist/instructions/claimWindowRewards.js +6 -3
  29. package/dist/instructions/closeAuxiliaryAccounts.d.ts +8 -26
  30. package/dist/instructions/confirmedPostOnX.d.ts +14 -11
  31. package/dist/instructions/confirmedPostOnX.js +8 -3
  32. package/dist/instructions/createMiztake.d.ts +25 -28
  33. package/dist/instructions/createMiztake.js +12 -9
  34. package/dist/instructions/initializeEscrowVault.d.ts +5 -9
  35. package/dist/instructions/initializeSeasonSettings.d.ts +5 -9
  36. package/dist/instructions/initializeSeasonVault.d.ts +5 -9
  37. package/dist/instructions/initializeStatistics.d.ts +6 -7
  38. package/dist/instructions/initializeStatistics.js +12 -8
  39. package/dist/instructions/joinSeason.d.ts +18 -20
  40. package/dist/instructions/joinSeason.js +2 -1
  41. package/dist/instructions/toggleSeasonPause.d.ts +7 -9
  42. package/dist/instructions/toggleSeasonPause.js +1 -0
  43. package/dist/instructions/updateSeasonAdmin.d.ts +7 -9
  44. package/dist/instructions/updateSeasonAdmin.js +1 -0
  45. package/dist/instructions/viewSeasonMembershipStatus.d.ts +2 -2
  46. package/dist/instructions/viewWindowStatus.d.ts +2 -2
  47. package/dist/instructions/viewWindowStatus.js +3 -1
  48. package/dist/instructions/withdrawSeasonDeposit.d.ts +2 -2
  49. package/dist/types/anchorAccounts.d.ts +18 -0
  50. package/dist/types/anchorAccounts.js +2 -0
  51. package/dist/types/anchorViews.d.ts +11 -0
  52. package/dist/types/anchorViews.js +2 -0
  53. package/dist/types/instructionResults.d.ts +18 -19
  54. package/dist/types/proof_of_take.d.ts +32 -0
  55. package/dist/types.d.ts +53 -5
  56. package/dist/utils/accountConverters.d.ts +19 -0
  57. package/dist/utils/accountConverters.js +153 -0
  58. package/dist/utils/accountUpdates.d.ts +3 -3
  59. package/dist/utils/accountUpdates.js +40 -31
  60. package/dist/utils/conversions.d.ts +21 -1
  61. package/dist/utils/conversions.js +57 -9
  62. package/dist/utils/depositTier.d.ts +3 -0
  63. package/dist/utils/depositTier.js +21 -0
  64. package/dist/utils/enumHelpers.d.ts +5 -13
  65. package/dist/utils/enumHelpers.js +8 -0
  66. package/dist/utils/fetchAccount.d.ts +11 -0
  67. package/dist/utils/fetchAccount.js +23 -0
  68. package/dist/utils/index.js +1 -0
  69. package/dist/utils/pdaManager.d.ts +15 -14
  70. package/dist/utils/pdaManager.js +33 -26
  71. package/dist/utils/pdas.d.ts +9 -8
  72. package/dist/utils/pdas.js +24 -20
  73. package/dist/utils/programHelpers.js +1 -1
  74. package/dist/utils/signerHelpers.d.ts +2 -1
  75. package/dist/utils/simulationHelpers.js +7 -6
  76. package/dist/utils/tierPenalty.d.ts +2 -2
  77. package/dist/utils/tierPenalty.js +13 -11
  78. package/dist/utils/transactionBuilder.js +9 -7
  79. package/package.json +1 -1
package/dist/client.js CHANGED
@@ -20,7 +20,7 @@ const anchorHelpers_1 = require("./utils/anchorHelpers");
20
20
  * ```
21
21
  */
22
22
  function createProgram(provider) {
23
- return new anchor_1.Program(idl_1.IDL, provider);
23
+ return new anchor_1.Program(idl_1.ANCHOR_IDL, provider);
24
24
  }
25
25
  /**
26
26
  * Create a Proof of Take program instance with custom program ID
@@ -32,7 +32,7 @@ function createProgram(provider) {
32
32
  function createProgramWithId(provider, programId) {
33
33
  // Anchor v0.32 Program ctor does not accept a programId param; it uses `idl.address`.
34
34
  // So we clone the IDL and override its address to point at the provided programId.
35
- const idlWithAddress = (0, anchorHelpers_1.withIdlAddress)(idl_1.IDL, programId);
35
+ const idlWithAddress = (0, anchorHelpers_1.withIdlAddress)(idl_1.ANCHOR_IDL, programId);
36
36
  return new anchor_1.Program(idlWithAddress, provider);
37
37
  }
38
38
  /**
@@ -43,5 +43,5 @@ function createProgramWithId(provider, programId) {
43
43
  */
44
44
  function getProgramReadOnly(connection) {
45
45
  const provider = (0, anchorHelpers_1.createReadOnlyProvider)(connection, "confirmed");
46
- return new anchor_1.Program(idl_1.IDL, provider);
46
+ return new anchor_1.Program(idl_1.ANCHOR_IDL, provider);
47
47
  }
@@ -1,11 +1,11 @@
1
1
  import { Connection, PublicKey } from "@solana/web3.js";
2
- import { Miztake } from "../types";
2
+ import { Miztake, Sha256HexString } from "../types";
3
3
  /**
4
4
  * Get a miztake account by SHA hash
5
5
  * @param connection - Solana connection
6
6
  * @param shaHash - SHA hash of the miztake
7
7
  * @returns Miztake account data
8
8
  */
9
- export declare function getMiztake(connection: Connection, shaHash: string): Promise<Miztake & {
9
+ export declare function getMiztake(connection: Connection, shaHash: Sha256HexString | string): Promise<Miztake & {
10
10
  publicKey: PublicKey;
11
11
  }>;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMiztake = getMiztake;
4
4
  const pdas_1 = require("../utils/pdas");
5
5
  const programHelpers_1 = require("../utils/programHelpers");
6
+ const accountConverters_1 = require("../utils/accountConverters");
6
7
  /**
7
8
  * Get a miztake account by SHA hash
8
9
  * @param connection - Solana connection
@@ -15,20 +16,6 @@ async function getMiztake(connection, shaHash) {
15
16
  const miztake = await program.account.miztake.fetch(miztakePda);
16
17
  return {
17
18
  publicKey: miztakePda,
18
- id: miztake.id,
19
- telegramId: miztake.telegramId,
20
- telegramUsername: miztake.telegramUsername,
21
- perceptualHash: miztake.perceptualHash,
22
- averageHash: miztake.averageHash,
23
- differenceHash: miztake.differenceHash,
24
- waveletHash: miztake.waveletHash,
25
- shaHash: miztake.shaHash,
26
- computedAt: miztake.computedAt,
27
- creator: miztake.creator,
28
- userStats: miztake.userStats,
29
- userKey: miztake.userKey,
30
- onchainCreatedAt: miztake.onchainCreatedAt,
31
- usedInSeason: miztake.usedInSeason,
32
- usedInWindow: miztake.usedInWindow,
19
+ ...(0, accountConverters_1.toSdkMiztake)(miztake),
33
20
  };
34
21
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMiztakeStatistics = getMiztakeStatistics;
4
4
  const pdas_1 = require("../utils/pdas");
5
5
  const programHelpers_1 = require("../utils/programHelpers");
6
+ const accountConverters_1 = require("../utils/accountConverters");
6
7
  /**
7
8
  * Get miztake statistics account
8
9
  * @param connection - Solana connection
@@ -14,7 +15,6 @@ async function getMiztakeStatistics(connection) {
14
15
  const statistics = await program.account.miztakeStatistics.fetch(statisticsPda);
15
16
  return {
16
17
  publicKey: statisticsPda,
17
- totalMiztakes: statistics.totalMiztakes,
18
- bump: statistics.bump,
18
+ ...(0, accountConverters_1.toSdkMiztakeStatistics)(statistics),
19
19
  };
20
20
  }
@@ -0,0 +1,9 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
+ import { ReferralPenaltyClaim, TierNumber, WindowNumberLike } from "../types";
4
+ /**
5
+ * Get ReferralPenaltyClaim by seeds
6
+ */
7
+ export declare function getReferralPenaltyClaim(connection: Connection, seasonNumber: BN, referredUser: PublicKey, tier: TierNumber, windowNumber: WindowNumberLike): Promise<ReferralPenaltyClaim & {
8
+ publicKey: PublicKey;
9
+ }>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getReferralPenaltyClaim = getReferralPenaltyClaim;
4
+ const pdas_1 = require("../utils/pdas");
5
+ const programHelpers_1 = require("../utils/programHelpers");
6
+ const accountConverters_1 = require("../utils/accountConverters");
7
+ const conversions_1 = require("../utils/conversions");
8
+ /**
9
+ * Get ReferralPenaltyClaim by seeds
10
+ */
11
+ async function getReferralPenaltyClaim(connection, seasonNumber, referredUser, tier, windowNumber) {
12
+ const program = (0, programHelpers_1.getProgram)(connection);
13
+ const windowBn = (0, conversions_1.toWindowNumberBn)(windowNumber);
14
+ const [pda] = (0, pdas_1.getReferralPenaltyClaimPda)(seasonNumber, referredUser, tier, windowBn);
15
+ const claim = await program.account.referralPenaltyClaim.fetch(pda);
16
+ return {
17
+ publicKey: pda,
18
+ ...(0, accountConverters_1.toSdkReferralPenaltyClaim)(claim),
19
+ };
20
+ }
@@ -0,0 +1,9 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
+ import { RewardWindow, WindowNumberLike } from "../types";
4
+ /**
5
+ * Get RewardWindow by season + window number
6
+ */
7
+ export declare function getRewardWindow(connection: Connection, seasonNumber: BN, windowNumber: WindowNumberLike): Promise<RewardWindow & {
8
+ publicKey: PublicKey;
9
+ }>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRewardWindow = getRewardWindow;
4
+ const pdas_1 = require("../utils/pdas");
5
+ const programHelpers_1 = require("../utils/programHelpers");
6
+ const accountConverters_1 = require("../utils/accountConverters");
7
+ const conversions_1 = require("../utils/conversions");
8
+ /**
9
+ * Get RewardWindow by season + window number
10
+ */
11
+ async function getRewardWindow(connection, seasonNumber, windowNumber) {
12
+ const program = (0, programHelpers_1.getProgram)(connection);
13
+ const windowBn = (0, conversions_1.toWindowNumberBn)(windowNumber);
14
+ const [rewardWindowPda] = (0, pdas_1.getRewardWindowPda)(seasonNumber, windowBn);
15
+ const window = await program.account.rewardWindow.fetch(rewardWindowPda);
16
+ return {
17
+ publicKey: rewardWindowPda,
18
+ ...(0, accountConverters_1.toSdkRewardWindow)(window),
19
+ };
20
+ }
@@ -0,0 +1,8 @@
1
+ import { Connection, PublicKey } from "@solana/web3.js";
2
+ import { Season, SeasonNumberLike } from "../types";
3
+ /**
4
+ * Get Season by season number
5
+ */
6
+ export declare function getSeason(connection: Connection, seasonNumber: SeasonNumberLike): Promise<Season & {
7
+ publicKey: PublicKey;
8
+ }>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSeason = getSeason;
4
+ const pdas_1 = require("../utils/pdas");
5
+ const programHelpers_1 = require("../utils/programHelpers");
6
+ const accountConverters_1 = require("../utils/accountConverters");
7
+ const conversions_1 = require("../utils/conversions");
8
+ /**
9
+ * Get Season by season number
10
+ */
11
+ async function getSeason(connection, seasonNumber) {
12
+ const program = (0, programHelpers_1.getProgram)(connection);
13
+ const seasonBn = (0, conversions_1.toSeasonNumberBn)(seasonNumber);
14
+ const [seasonPda] = (0, pdas_1.getSeasonPda)(seasonBn);
15
+ const season = await program.account.season.fetch(seasonPda);
16
+ return {
17
+ publicKey: seasonPda,
18
+ ...(0, accountConverters_1.toSdkSeason)(season),
19
+ };
20
+ }
@@ -0,0 +1,9 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
+ import { SeasonMembership, TierNumber } from "../types";
4
+ /**
5
+ * Get SeasonMembership by seeds
6
+ */
7
+ export declare function getSeasonMembership(connection: Connection, seasonNumber: BN, user: PublicKey, tier: TierNumber): Promise<SeasonMembership & {
8
+ publicKey: PublicKey;
9
+ }>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSeasonMembership = getSeasonMembership;
4
+ const pdas_1 = require("../utils/pdas");
5
+ const programHelpers_1 = require("../utils/programHelpers");
6
+ const accountConverters_1 = require("../utils/accountConverters");
7
+ /**
8
+ * Get SeasonMembership by seeds
9
+ */
10
+ async function getSeasonMembership(connection, seasonNumber, user, tier) {
11
+ const program = (0, programHelpers_1.getProgram)(connection);
12
+ const [membershipPda] = (0, pdas_1.getSeasonMembershipPda)(seasonNumber, user, tier);
13
+ const membership = await program.account.seasonMembership.fetch(membershipPda);
14
+ return {
15
+ publicKey: membershipPda,
16
+ ...(0, accountConverters_1.toSdkSeasonMembership)(membership),
17
+ };
18
+ }
@@ -0,0 +1,8 @@
1
+ import { Connection, PublicKey } from "@solana/web3.js";
2
+ import { SeasonSettings } from "../types";
3
+ /**
4
+ * Get SeasonSettings (singleton)
5
+ */
6
+ export declare function getSeasonSettings(connection: Connection): Promise<SeasonSettings & {
7
+ publicKey: PublicKey;
8
+ }>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSeasonSettings = getSeasonSettings;
4
+ const pdas_1 = require("../utils/pdas");
5
+ const programHelpers_1 = require("../utils/programHelpers");
6
+ const accountConverters_1 = require("../utils/accountConverters");
7
+ /**
8
+ * Get SeasonSettings (singleton)
9
+ */
10
+ async function getSeasonSettings(connection) {
11
+ const program = (0, programHelpers_1.getProgram)(connection);
12
+ const [seasonSettingsPda] = (0, pdas_1.getSeasonSettingsPda)();
13
+ const settings = await program.account.seasonSettings.fetch(seasonSettingsPda);
14
+ return {
15
+ publicKey: seasonSettingsPda,
16
+ ...(0, accountConverters_1.toSdkSeasonSettings)(settings),
17
+ };
18
+ }
@@ -4,6 +4,7 @@ exports.getUserStats = getUserStats;
4
4
  exports.getUserStatsByPda = getUserStatsByPda;
5
5
  const pdas_1 = require("../utils/pdas");
6
6
  const programHelpers_1 = require("../utils/programHelpers");
7
+ const accountConverters_1 = require("../utils/accountConverters");
7
8
  /**
8
9
  * Get user stats account by telegram ID
9
10
  * @param connection - Solana connection
@@ -16,11 +17,7 @@ async function getUserStats(connection, telegramId) {
16
17
  const stats = await program.account.userStats.fetch(userStatsPda);
17
18
  return {
18
19
  publicKey: userStatsPda,
19
- telegramId: stats.telegramId,
20
- totalNumberOfMiztakes: stats.totalNumberOfMiztakes,
21
- onchainFirstMiztakeAt: stats.onchainFirstMiztakeAt,
22
- onchainLastMiztakeAt: stats.onchainLastMiztakeAt,
23
- bump: stats.bump,
20
+ ...(0, accountConverters_1.toSdkUserStats)(stats),
24
21
  };
25
22
  }
26
23
  /**
@@ -34,10 +31,6 @@ async function getUserStatsByPda(connection, userStatsPda) {
34
31
  const stats = await program.account.userStats.fetch(userStatsPda);
35
32
  return {
36
33
  publicKey: userStatsPda,
37
- telegramId: stats.telegramId,
38
- totalNumberOfMiztakes: stats.totalNumberOfMiztakes,
39
- onchainFirstMiztakeAt: stats.onchainFirstMiztakeAt,
40
- onchainLastMiztakeAt: stats.onchainLastMiztakeAt,
41
- bump: stats.bump,
34
+ ...(0, accountConverters_1.toSdkUserStats)(stats),
42
35
  };
43
36
  }
@@ -0,0 +1,9 @@
1
+ import { BN } from "@coral-xyz/anchor";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
+ import { TierNumber, UserWindowParticipation, WindowNumberLike } from "../types";
4
+ /**
5
+ * Get UserWindowParticipation by seeds
6
+ */
7
+ export declare function getUserWindowParticipation(connection: Connection, seasonNumber: BN, user: PublicKey, tier: TierNumber, windowNumber: WindowNumberLike): Promise<UserWindowParticipation & {
8
+ publicKey: PublicKey;
9
+ }>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUserWindowParticipation = getUserWindowParticipation;
4
+ const pdas_1 = require("../utils/pdas");
5
+ const programHelpers_1 = require("../utils/programHelpers");
6
+ const accountConverters_1 = require("../utils/accountConverters");
7
+ const conversions_1 = require("../utils/conversions");
8
+ /**
9
+ * Get UserWindowParticipation by seeds
10
+ */
11
+ async function getUserWindowParticipation(connection, seasonNumber, user, tier, windowNumber) {
12
+ const program = (0, programHelpers_1.getProgram)(connection);
13
+ const windowBn = (0, conversions_1.toWindowNumberBn)(windowNumber);
14
+ const [pda] = (0, pdas_1.getUserWindowParticipationPda)(seasonNumber, user, tier, windowBn);
15
+ const participation = await program.account.userWindowParticipation.fetch(pda);
16
+ return {
17
+ publicKey: pda,
18
+ ...(0, accountConverters_1.toSdkUserWindowParticipation)(participation),
19
+ };
20
+ }
@@ -4,3 +4,9 @@
4
4
  export * from "./getMiztake";
5
5
  export * from "./getUserStats";
6
6
  export * from "./getMiztakeStatistics";
7
+ export * from "./getSeasonSettings";
8
+ export * from "./getSeason";
9
+ export * from "./getSeasonMembership";
10
+ export * from "./getRewardWindow";
11
+ export * from "./getUserWindowParticipation";
12
+ export * from "./getReferralPenaltyClaim";
@@ -20,3 +20,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
20
20
  __exportStar(require("./getMiztake"), exports);
21
21
  __exportStar(require("./getUserStats"), exports);
22
22
  __exportStar(require("./getMiztakeStatistics"), exports);
23
+ __exportStar(require("./getSeasonSettings"), exports);
24
+ __exportStar(require("./getSeason"), exports);
25
+ __exportStar(require("./getSeasonMembership"), exports);
26
+ __exportStar(require("./getRewardWindow"), exports);
27
+ __exportStar(require("./getUserWindowParticipation"), exports);
28
+ __exportStar(require("./getReferralPenaltyClaim"), exports);
package/dist/idl/idl.d.ts CHANGED
@@ -1,2 +1,7 @@
1
+ import type { Idl } from "@coral-xyz/anchor";
1
2
  import { ProofOfTake } from "../types/proof_of_take";
2
3
  export declare const IDL: ProofOfTake;
4
+ /**
5
+ * Anchor-compatible IDL object (cast once here instead of at every call site).
6
+ */
7
+ export declare const ANCHOR_IDL: Idl;
package/dist/idl/idl.js CHANGED
@@ -3,6 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IDL = void 0;
6
+ exports.ANCHOR_IDL = exports.IDL = void 0;
7
7
  const proof_of_take_json_1 = __importDefault(require("./proof_of_take.json"));
8
8
  exports.IDL = proof_of_take_json_1.default;
9
+ /**
10
+ * Anchor-compatible IDL object (cast once here instead of at every call site).
11
+ */
12
+ exports.ANCHOR_IDL = proof_of_take_json_1.default;
@@ -336,6 +336,38 @@
336
336
  }
337
337
  ]
338
338
  },
339
+ {
340
+ "name": "close_generic_account",
341
+ "discriminator": [
342
+ 124,
343
+ 13,
344
+ 206,
345
+ 67,
346
+ 55,
347
+ 195,
348
+ 177,
349
+ 118
350
+ ],
351
+ "accounts": [
352
+ {
353
+ "name": "admin",
354
+ "docs": [
355
+ "Admin must sign and pay for the transaction"
356
+ ],
357
+ "writable": true,
358
+ "signer": true
359
+ },
360
+ {
361
+ "name": "account_to_close",
362
+ "docs": [
363
+ "The account to close (must be owned by this program)",
364
+ "We only verify it's owned by the program and transfer its lamports"
365
+ ],
366
+ "writable": true
367
+ }
368
+ ],
369
+ "args": []
370
+ },
339
371
  {
340
372
  "name": "close_miztake",
341
373
  "discriminator": [
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  *
6
6
  * @packageDocumentation
7
7
  */
8
+ import { getProgram as _getProgram } from "./utils/programHelpers";
8
9
  export { createMiztake, getMiztakePdaForParams, } from "./instructions/createMiztake";
9
10
  export type { CreateMiztakeOptions, CreateMiztakeResult, } from "./instructions/createMiztake";
10
11
  export { initializeStatistics } from "./instructions/initializeStatistics";
@@ -29,7 +30,10 @@ export { viewCurrentSeason } from "./instructions/viewCurrentSeason";
29
30
  export * from "./utils/pdas";
30
31
  export * from "./utils/constants";
31
32
  export * from "./utils/accountUpdates";
32
- export * from "./utils/programHelpers";
33
+ export * from "./utils/accountConverters";
34
+ export * from "./utils/depositTier";
35
+ export * from "./utils/fetchAccount";
36
+ export declare const getProgram: typeof _getProgram;
33
37
  export * from "./utils/signerHelpers";
34
38
  export * from "./utils/conversions";
35
39
  export * from "./utils/transactionBuilder";
@@ -41,6 +45,8 @@ export * from "./constants/season";
41
45
  export * from "./types";
42
46
  export * from "./types/instructionResults";
43
47
  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";
49
+ export type { StandardInstructionResult, StandardInstructionResultWithPdas, StandardInstructionResultWithPdasAndAccounts, } from "./types/instructionResults";
44
50
  export type { ProofOfTake } from "./types/proof_of_take";
45
51
  export { IDL } from "./idl/idl";
46
52
  export { createProgram, createProgramWithId, getProgramReadOnly, } from "./client";
package/dist/index.js CHANGED
@@ -21,7 +21,12 @@ 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.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.withdrawSeasonDeposit = exports.claimReferralPenaltyForWindow = exports.claimWindowRewards = exports.confirmedPostOnX = exports.joinSeason = exports.initializeEscrowVault = exports.initializeSeasonVault = exports.initializeSeasonSettings = exports.initializeStatistics = exports.getMiztakePdaForParams = exports.createMiztake = void 0;
25
+ // NOTE:
26
+ // We intentionally export `getProgram` via a local const assignment (instead of `export * from ...`)
27
+ // so that the compiled CommonJS output uses a writable property. This makes it possible to mock
28
+ // `getProgram` in Jest by reassigning the export in test environments.
29
+ const programHelpers_1 = require("./utils/programHelpers");
25
30
  // Export all instructions
26
31
  // Core miztake instructions
27
32
  var createMiztake_1 = require("./instructions/createMiztake");
@@ -63,7 +68,10 @@ Object.defineProperty(exports, "viewCurrentSeason", { enumerable: true, get: fun
63
68
  __exportStar(require("./utils/pdas"), exports);
64
69
  __exportStar(require("./utils/constants"), exports);
65
70
  __exportStar(require("./utils/accountUpdates"), exports);
66
- __exportStar(require("./utils/programHelpers"), exports);
71
+ __exportStar(require("./utils/accountConverters"), exports);
72
+ __exportStar(require("./utils/depositTier"), exports);
73
+ __exportStar(require("./utils/fetchAccount"), exports);
74
+ exports.getProgram = programHelpers_1.getProgram;
67
75
  __exportStar(require("./utils/signerHelpers"), exports);
68
76
  __exportStar(require("./utils/conversions"), exports);
69
77
  __exportStar(require("./utils/transactionBuilder"), exports);
@@ -1,7 +1,7 @@
1
1
  import { BN } from "@coral-xyz/anchor";
2
- import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
3
- import { SignerInfo } from "../utils/signerHelpers";
4
- import { ReferralPenaltyClaim, SeasonMembership, UserWindowParticipation } from "../types";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
+ import { ReferralPenaltyClaim, SeasonMembership, UserWindowParticipation, TierNumber, WindowNumberLike } from "../types";
4
+ import { StandardInstructionResultWithPdas } from "../types/instructionResults";
5
5
  export interface ClaimReferralPenaltyForWindowOptions {
6
6
  connection: Connection;
7
7
  /** Referrer (or root admin if no referrer) */
@@ -10,9 +10,9 @@ export interface ClaimReferralPenaltyForWindowOptions {
10
10
  recipientTokenAccount: PublicKey;
11
11
  referredUser: PublicKey;
12
12
  seasonNumber: BN;
13
- windowNumber: BN;
13
+ windowNumber: WindowNumberLike;
14
14
  /** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
15
- tier: number;
15
+ tier: TierNumber;
16
16
  feePayer?: PublicKey;
17
17
  /**
18
18
  * Optional timestamp override (Unix seconds) for optimistic `claimedAt`.
@@ -28,12 +28,15 @@ export interface ClaimReferralPenaltyForWindowOptions {
28
28
  userWindowParticipation?: UserWindowParticipation;
29
29
  };
30
30
  }
31
- export declare function claimReferralPenaltyForWindow(options: ClaimReferralPenaltyForWindowOptions): Promise<{
32
- instructions: TransactionInstruction[];
33
- signers: SignerInfo[];
34
- updatedAccounts?: {
35
- userWindowParticipation?: UserWindowParticipation;
36
- referralPenaltyClaim?: ReferralPenaltyClaim;
37
- seasonMembership?: SeasonMembership;
38
- };
39
- }>;
31
+ export declare function claimReferralPenaltyForWindow(options: ClaimReferralPenaltyForWindowOptions): Promise<StandardInstructionResultWithPdas<{
32
+ seasonSettings: PublicKey;
33
+ season: PublicKey;
34
+ seasonMembership: PublicKey;
35
+ userWindowParticipation: PublicKey;
36
+ referralPenaltyClaim: PublicKey;
37
+ seasonDepositVault: PublicKey;
38
+ }, {
39
+ userWindowParticipation?: UserWindowParticipation;
40
+ referralPenaltyClaim?: ReferralPenaltyClaim;
41
+ seasonMembership?: SeasonMembership;
42
+ }>>;
@@ -10,12 +10,14 @@ const programHelpers_1 = require("../utils/programHelpers");
10
10
  const signerHelpers_1 = require("../utils/signerHelpers");
11
11
  const optimistic_1 = require("../optimistic");
12
12
  const tierPenalty_1 = require("../utils/tierPenalty");
13
+ const conversions_1 = require("../utils/conversions");
13
14
  async function claimReferralPenaltyForWindow(options) {
15
+ const windowNumber = (0, conversions_1.toWindowNumberBn)(options.windowNumber);
14
16
  const program = (0, programHelpers_1.getProgram)(options.connection);
15
17
  const pdas = pdaManager_1.PDAManager.deriveClaimReferralPenaltyForWindowPdas({
16
18
  referredUser: options.referredUser,
17
19
  seasonNumber: options.seasonNumber,
18
- windowNumber: options.windowNumber,
20
+ windowNumber,
19
21
  tier: options.tier,
20
22
  });
21
23
  const accounts = {
@@ -34,7 +36,7 @@ async function claimReferralPenaltyForWindow(options) {
34
36
  const instruction = await program.methods
35
37
  .claimReferralPenaltyForWindow(
36
38
  // Anchor expects BN for u64 args.
37
- options.seasonNumber, options.windowNumber, options.referredUser, options.tier)
39
+ options.seasonNumber, windowNumber, options.referredUser, options.tier)
38
40
  .accounts(accounts)
39
41
  .instruction();
40
42
  const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.claimant, role: "claimant" }], options.feePayer);
@@ -45,14 +47,14 @@ async function claimReferralPenaltyForWindow(options) {
45
47
  const claimedAt = (0, optimistic_1.getCurrentTimestamp)(options.now);
46
48
  // The program `init_if_needed` for participation; if caller doesn't provide it, assume it doesn't exist.
47
49
  const participation = curr.userWindowParticipation ??
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
50
+ (0, optimistic_1.initializeUserWindowParticipation)(options.referredUser, options.seasonNumber, windowNumber, options.tier, new anchor_1.BN(0) // miztake_id = 0 for total no-show windows
49
51
  );
50
52
  // Keep this in sync with on-chain: membership.deposit_tier.penalty_per_window_amount()
51
53
  const perWindowPenalty = (0, tierPenalty_1.getTierPenaltyPerWindow)(curr.seasonMembership.depositTier);
52
54
  const claim = (0, optimistic_1.initializeReferralPenaltyClaim)({
53
55
  referredUser: options.referredUser,
54
56
  seasonNumber: options.seasonNumber,
55
- windowNumber: options.windowNumber,
57
+ windowNumber,
56
58
  tier: options.tier,
57
59
  claimant: options.claimant,
58
60
  perWindowPenalty,
@@ -67,6 +69,7 @@ async function claimReferralPenaltyForWindow(options) {
67
69
  return {
68
70
  instructions: [instruction],
69
71
  signers,
72
+ pdas,
70
73
  ...(updatedAccounts && { updatedAccounts }),
71
74
  };
72
75
  }
@@ -1,7 +1,7 @@
1
1
  import { BN } from "@coral-xyz/anchor";
2
- import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
3
- import { SeasonSettings, Season, RewardWindow, UserWindowParticipation, SeasonMembership } from "../types";
4
- import { SignerInfo } from "../utils/signerHelpers";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
+ import { SeasonSettings, Season, RewardWindow, UserWindowParticipation, SeasonMembership, TierNumber, WindowNumberLike } from "../types";
4
+ import { StandardInstructionResultWithPdas } from "../types/instructionResults";
5
5
  type ClaimWindowRewardsUpdatedAccounts = {
6
6
  seasonSettings?: SeasonSettings;
7
7
  season?: Season;
@@ -9,6 +9,14 @@ type ClaimWindowRewardsUpdatedAccounts = {
9
9
  userWindowParticipation?: UserWindowParticipation;
10
10
  seasonMembership?: SeasonMembership;
11
11
  };
12
+ type ClaimWindowRewardsPdas = {
13
+ seasonSettings: PublicKey;
14
+ season: PublicKey;
15
+ rewardWindow: PublicKey;
16
+ userWindowParticipation: PublicKey;
17
+ seasonMembership: PublicKey;
18
+ seasonDepositVault: PublicKey;
19
+ };
12
20
  /**
13
21
  * Options for claimWindowRewards instruction
14
22
  */
@@ -19,9 +27,9 @@ export interface ClaimWindowRewardsOptions {
19
27
  /** Referrer token account to receive referral share (only used when membership.referrer != default) */
20
28
  referrerTokenAccount?: PublicKey;
21
29
  seasonNumber: BN;
22
- windowNumber: BN;
30
+ windowNumber: WindowNumberLike;
23
31
  /** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
24
- tier: number;
32
+ tier: TierNumber;
25
33
  feePayer?: PublicKey;
26
34
  currentAccounts?: {
27
35
  seasonSettings?: SeasonSettings;
@@ -41,9 +49,5 @@ export interface ClaimWindowRewardsOptions {
41
49
  * @param options - Claim window rewards options
42
50
  * @returns Instructions, signers, and optimistically updated accounts
43
51
  */
44
- export declare function claimWindowRewards(options: ClaimWindowRewardsOptions): Promise<{
45
- instructions: TransactionInstruction[];
46
- signers: SignerInfo[];
47
- updatedAccounts?: ClaimWindowRewardsUpdatedAccounts;
48
- }>;
52
+ export declare function claimWindowRewards(options: ClaimWindowRewardsOptions): Promise<StandardInstructionResultWithPdas<ClaimWindowRewardsPdas, ClaimWindowRewardsUpdatedAccounts>>;
49
53
  export {};
@@ -10,6 +10,7 @@ const tierPenalty_1 = require("../utils/tierPenalty");
10
10
  const programHelpers_1 = require("../utils/programHelpers");
11
11
  const signerHelpers_1 = require("../utils/signerHelpers");
12
12
  const optimistic_1 = require("../optimistic");
13
+ const conversions_1 = require("../utils/conversions");
13
14
  /**
14
15
  * Claim window rewards
15
16
  *
@@ -22,10 +23,11 @@ const optimistic_1 = require("../optimistic");
22
23
  */
23
24
  async function claimWindowRewards(options) {
24
25
  const program = (0, programHelpers_1.getProgram)(options.connection);
26
+ const windowNumber = (0, conversions_1.toWindowNumberBn)(options.windowNumber);
25
27
  const pdas = pdaManager_1.PDAManager.deriveClaimWindowRewardsPdas({
26
28
  user: options.user,
27
29
  seasonNumber: options.seasonNumber,
28
- windowNumber: options.windowNumber,
30
+ windowNumber,
29
31
  tier: options.tier,
30
32
  });
31
33
  const accounts = {
@@ -44,7 +46,7 @@ async function claimWindowRewards(options) {
44
46
  };
45
47
  const instruction = await program.methods
46
48
  // Anchor expects BN for u64 args.
47
- .claimWindowRewards(options.seasonNumber, options.windowNumber, options.tier)
49
+ .claimWindowRewards(options.seasonNumber, windowNumber, options.tier)
48
50
  .accounts(accounts)
49
51
  .instruction();
50
52
  const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.user, role: "user" }], options.feePayer);
@@ -52,7 +54,7 @@ async function claimWindowRewards(options) {
52
54
  const curr = options.currentAccounts || {};
53
55
  let updatedAccounts = undefined;
54
56
  if (curr.rewardWindow && curr.seasonSettings && curr.season) {
55
- const idx = options.windowNumber.toNumber();
57
+ const idx = (0, conversions_1.assertWindowIndex)(windowNumber);
56
58
  const eligibleStakeX = curr.season.eligibleStakePerWindow[idx] ?? new anchor_1.BN(0);
57
59
  const updatedRewardWindow = !curr.rewardWindow.isFinalized
58
60
  ? (0, optimistic_1.updateWindowForFinalization)(curr.rewardWindow, eligibleStakeX)
@@ -89,6 +91,7 @@ async function claimWindowRewards(options) {
89
91
  return {
90
92
  instructions: [instruction],
91
93
  signers,
94
+ pdas,
92
95
  ...(updatedAccounts && { updatedAccounts }),
93
96
  };
94
97
  }