proof-of-take-sdk 3.0.7 → 3.0.8

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 (48) hide show
  1. package/dist/idl/proof_of_take.json +132 -12
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +1 -0
  4. package/dist/instructions/claimReferralPenaltyForWindow.d.ts +1 -1
  5. package/dist/instructions/claimReferralPenaltyForWindow.js +2 -1
  6. package/dist/instructions/claimWindowRewards.d.ts +1 -1
  7. package/dist/instructions/claimWindowRewards.js +2 -1
  8. package/dist/instructions/closeAuxiliaryAccounts.js +19 -12
  9. package/dist/instructions/confirmedPostOnX.d.ts +1 -1
  10. package/dist/instructions/confirmedPostOnX.js +5 -1
  11. package/dist/instructions/createMiztake.d.ts +1 -1
  12. package/dist/instructions/createMiztake.js +7 -3
  13. package/dist/instructions/initializeEscrowVault.js +5 -4
  14. package/dist/instructions/initializeRewardWindow.js +5 -4
  15. package/dist/instructions/initializeSeasonSettings.js +6 -7
  16. package/dist/instructions/initializeSeasonVault.js +6 -7
  17. package/dist/instructions/initializeStatistics.js +5 -5
  18. package/dist/instructions/joinSeason.d.ts +1 -1
  19. package/dist/instructions/joinSeason.js +20 -5
  20. package/dist/instructions/toggleSeasonPause.js +6 -7
  21. package/dist/instructions/updateSeasonAdmin.js +6 -7
  22. package/dist/instructions/viewSeasonMembershipStatus.d.ts +1 -1
  23. package/dist/instructions/viewSeasonMembershipStatus.js +1 -1
  24. package/dist/instructions/withdrawSeasonDeposit.d.ts +1 -1
  25. package/dist/instructions/withdrawSeasonDeposit.js +2 -1
  26. package/dist/types/accountTypes.d.ts +3 -0
  27. package/dist/types/proof_of_take.d.ts +132 -12
  28. package/dist/types.d.ts +4 -2
  29. package/dist/utils/accountConverters.js +1 -0
  30. package/dist/utils/accountUpdates.d.ts +3 -3
  31. package/dist/utils/accountUpdates.js +4 -3
  32. package/dist/utils/instructionResultHelpers.d.ts +7 -0
  33. package/dist/utils/instructionResultHelpers.js +9 -0
  34. package/dist/utils/pdas.d.ts +4 -4
  35. package/dist/utils/pdas.js +8 -7
  36. package/dist/utils/programErrors.d.ts +13 -0
  37. package/dist/utils/programErrors.js +47 -0
  38. package/dist/utils/remainingAccounts.d.ts +17 -0
  39. package/dist/utils/remainingAccounts.js +38 -0
  40. package/dist/utils/signerHelpers.d.ts +20 -0
  41. package/dist/utils/signerHelpers.js +64 -5
  42. package/dist/utils/tierPenalty.d.ts +2 -2
  43. package/dist/utils/tierPenalty.js +9 -9
  44. package/dist/utils/tierSeeds.d.ts +8 -0
  45. package/dist/utils/tierSeeds.js +14 -0
  46. package/dist/utils/transactionBuilder.d.ts +1 -0
  47. package/dist/utils/transactionBuilder.js +11 -9
  48. package/package.json +1 -1
@@ -1596,6 +1596,100 @@
1596
1596
  "name": "mizd_mint",
1597
1597
  "address": "mizdS9fDNUKWZcXBeRhJoJQHJJmsTeF4fFRyPdXWv99"
1598
1598
  },
1599
+ {
1600
+ "name": "root_admin",
1601
+ "address": "Lude4DE3jDXVViJ3s7bUfPXdXy8Zq7G1stMwHNQrc2s"
1602
+ },
1603
+ {
1604
+ "name": "root_admin_token_account",
1605
+ "writable": true,
1606
+ "pda": {
1607
+ "seeds": [
1608
+ {
1609
+ "kind": "account",
1610
+ "path": "root_admin"
1611
+ },
1612
+ {
1613
+ "kind": "const",
1614
+ "value": [
1615
+ 6,
1616
+ 221,
1617
+ 246,
1618
+ 225,
1619
+ 215,
1620
+ 101,
1621
+ 161,
1622
+ 147,
1623
+ 217,
1624
+ 203,
1625
+ 225,
1626
+ 70,
1627
+ 206,
1628
+ 235,
1629
+ 121,
1630
+ 172,
1631
+ 28,
1632
+ 180,
1633
+ 133,
1634
+ 237,
1635
+ 95,
1636
+ 91,
1637
+ 55,
1638
+ 145,
1639
+ 58,
1640
+ 140,
1641
+ 245,
1642
+ 133,
1643
+ 126,
1644
+ 255,
1645
+ 0,
1646
+ 169
1647
+ ]
1648
+ },
1649
+ {
1650
+ "kind": "account",
1651
+ "path": "mizd_mint"
1652
+ }
1653
+ ],
1654
+ "program": {
1655
+ "kind": "const",
1656
+ "value": [
1657
+ 140,
1658
+ 151,
1659
+ 37,
1660
+ 143,
1661
+ 78,
1662
+ 36,
1663
+ 137,
1664
+ 241,
1665
+ 187,
1666
+ 61,
1667
+ 16,
1668
+ 41,
1669
+ 20,
1670
+ 142,
1671
+ 13,
1672
+ 131,
1673
+ 11,
1674
+ 90,
1675
+ 19,
1676
+ 153,
1677
+ 218,
1678
+ 255,
1679
+ 16,
1680
+ 132,
1681
+ 4,
1682
+ 142,
1683
+ 123,
1684
+ 216,
1685
+ 219,
1686
+ 233,
1687
+ 248,
1688
+ 89
1689
+ ]
1690
+ }
1691
+ }
1692
+ },
1599
1693
  {
1600
1694
  "name": "user_token_account",
1601
1695
  "writable": true
@@ -1605,6 +1699,10 @@
1605
1699
  "writable": true,
1606
1700
  "signer": true
1607
1701
  },
1702
+ {
1703
+ "name": "associated_token_program",
1704
+ "address": "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
1705
+ },
1608
1706
  {
1609
1707
  "name": "token_program",
1610
1708
  "address": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
@@ -2831,43 +2929,58 @@
2831
2929
  },
2832
2930
  {
2833
2931
  "code": 6035,
2932
+ "name": "InvalidReferrerMembership",
2933
+ "msg": "Invalid referrer season membership account"
2934
+ },
2935
+ {
2936
+ "code": 6036,
2834
2937
  "name": "ReferralPenaltyAlreadyClaimed",
2835
2938
  "msg": "Referral penalty already claimed for this user/window"
2836
2939
  },
2837
2940
  {
2838
- "code": 6036,
2941
+ "code": 6037,
2839
2942
  "name": "ReferralPenaltyClaimNotAvailableYet",
2840
2943
  "msg": "Referral penalty claim not available yet (must wait until window end + claim buffer)"
2841
2944
  },
2842
2945
  {
2843
- "code": 6037,
2946
+ "code": 6038,
2844
2947
  "name": "ReferralPenaltyNotEligibleForWindow",
2845
2948
  "msg": "Referred user was not eligible for this window"
2846
2949
  },
2847
2950
  {
2848
- "code": 6038,
2951
+ "code": 6039,
2849
2952
  "name": "ReferralPenaltyNoMissedPenalty",
2850
2953
  "msg": "Referred user posted successfully (no penalty to claim)"
2851
2954
  },
2852
2955
  {
2853
- "code": 6039,
2956
+ "code": 6040,
2854
2957
  "name": "WindowAlreadyFinalized",
2855
2958
  "msg": "Window is already finalized"
2856
2959
  },
2857
2960
  {
2858
- "code": 6040,
2961
+ "code": 6041,
2859
2962
  "name": "WindowNotEmpty",
2860
2963
  "msg": "Window is not empty (has successful posters)"
2861
2964
  },
2862
2965
  {
2863
- "code": 6041,
2966
+ "code": 6042,
2864
2967
  "name": "CalculationError",
2865
2968
  "msg": "Calculation error"
2866
2969
  },
2867
2970
  {
2868
- "code": 6042,
2971
+ "code": 6043,
2869
2972
  "name": "InsufficientFunds",
2870
2973
  "msg": "Insufficient funds"
2974
+ },
2975
+ {
2976
+ "code": 6044,
2977
+ "name": "NoWindowRewardsToClaim",
2978
+ "msg": "Nothing to claim for this window (reward amount is 0)"
2979
+ },
2980
+ {
2981
+ "code": 6045,
2982
+ "name": "NoReferralPenaltyToClaim",
2983
+ "msg": "Nothing to claim for this window (referral penalty amount is 0)"
2871
2984
  }
2872
2985
  ],
2873
2986
  "types": [
@@ -3044,7 +3157,7 @@
3044
3157
  {
3045
3158
  "name": "tier",
3046
3159
  "docs": [
3047
- "Tier number used for the membership PDA (1..=5)"
3160
+ "Tier number used for the membership PDA (0..=4)"
3048
3161
  ],
3049
3162
  "type": "u8"
3050
3163
  },
@@ -3097,7 +3210,7 @@
3097
3210
  {
3098
3211
  "name": "tier",
3099
3212
  "docs": [
3100
- "Tier number used for the membership PDA (1..=5)"
3213
+ "Tier number used for the membership PDA (0..=4)"
3101
3214
  ],
3102
3215
  "type": "u8"
3103
3216
  },
@@ -3204,7 +3317,7 @@
3204
3317
  {
3205
3318
  "name": "tier",
3206
3319
  "docs": [
3207
- "Tier number used for the membership PDA (1..=5)"
3320
+ "Tier number used for the membership PDA (0..=4)"
3208
3321
  ],
3209
3322
  "type": "u8"
3210
3323
  },
@@ -3554,7 +3667,7 @@
3554
3667
  {
3555
3668
  "name": "tier",
3556
3669
  "docs": [
3557
- "Tier number used for the membership PDA (1..=5)"
3670
+ "Tier number used for the membership PDA (0..=4)"
3558
3671
  ],
3559
3672
  "type": "u8"
3560
3673
  },
@@ -3645,7 +3758,7 @@
3645
3758
  {
3646
3759
  "name": "tier",
3647
3760
  "docs": [
3648
- "Tier number used for the membership PDA (1..=5)"
3761
+ "Tier number used for the membership PDA (0..=4)"
3649
3762
  ],
3650
3763
  "type": "u8"
3651
3764
  },
@@ -3691,6 +3804,13 @@
3691
3804
  ],
3692
3805
  "type": "pubkey"
3693
3806
  },
3807
+ {
3808
+ "name": "referral_count",
3809
+ "docs": [
3810
+ "Total number of successful referrals for this membership (incremented when others join with this member as referrer)"
3811
+ ],
3812
+ "type": "u64"
3813
+ },
3694
3814
  {
3695
3815
  "name": "season_number",
3696
3816
  "docs": [
package/dist/index.d.ts CHANGED
@@ -44,6 +44,7 @@ export * from "./utils/conversions";
44
44
  export * from "./utils/transactionBuilder";
45
45
  export * from "./utils/simulationHelpers";
46
46
  export * from "./utils/enumHelpers";
47
+ export * from "./utils/programErrors";
47
48
  export { PDAManager } from "./utils/pdaManager";
48
49
  export * from "./optimistic";
49
50
  export * from "./constants/season";
package/dist/index.js CHANGED
@@ -83,6 +83,7 @@ __exportStar(require("./utils/conversions"), exports);
83
83
  __exportStar(require("./utils/transactionBuilder"), exports);
84
84
  __exportStar(require("./utils/simulationHelpers"), exports);
85
85
  __exportStar(require("./utils/enumHelpers"), exports);
86
+ __exportStar(require("./utils/programErrors"), exports);
86
87
  var pdaManager_1 = require("./utils/pdaManager");
87
88
  Object.defineProperty(exports, "PDAManager", { enumerable: true, get: function () { return pdaManager_1.PDAManager; } });
88
89
  // Export optimistic updates
@@ -11,7 +11,7 @@ export interface ClaimReferralPenaltyForWindowOptions {
11
11
  referredUser: PublicKey;
12
12
  seasonNumber: BN;
13
13
  windowNumber: WindowNumberLike;
14
- /** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
14
+ /** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
15
15
  tier: TierNumber;
16
16
  feePayer?: PublicKey;
17
17
  /**
@@ -39,7 +39,8 @@ async function claimReferralPenaltyForWindow(options) {
39
39
  options.seasonNumber, windowNumber, options.referredUser, options.tier)
40
40
  .accounts(accounts)
41
41
  .instruction();
42
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.claimant, role: "claimant" }], options.feePayer);
42
+ const feePayer = (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
43
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asClaimantSigner)(options.claimant)], feePayer);
43
44
  // OPTIMISTIC UPDATES
44
45
  let updatedAccounts = undefined;
45
46
  const curr = options.currentAccounts;
@@ -28,7 +28,7 @@ export interface ClaimWindowRewardsOptions {
28
28
  referrerTokenAccount?: PublicKey;
29
29
  seasonNumber: BN;
30
30
  windowNumber: WindowNumberLike;
31
- /** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
31
+ /** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
32
32
  tier: TierNumber;
33
33
  feePayer?: PublicKey;
34
34
  currentAccounts?: {
@@ -49,7 +49,8 @@ async function claimWindowRewards(options) {
49
49
  .claimWindowRewards(options.seasonNumber, windowNumber, options.tier)
50
50
  .accounts(accounts)
51
51
  .instruction();
52
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.user, role: "user" }], options.feePayer);
52
+ const feePayer = (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
53
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asUserSigner)(options.user)], feePayer);
53
54
  // OPTIMISTIC UPDATES
54
55
  const curr = options.currentAccounts || {};
55
56
  let updatedAccounts = undefined;
@@ -8,6 +8,7 @@ exports.closeUserWindowParticipation = closeUserWindowParticipation;
8
8
  exports.closeReferralPenaltyClaim = closeReferralPenaltyClaim;
9
9
  const programHelpers_1 = require("../utils/programHelpers");
10
10
  const signerHelpers_1 = require("../utils/signerHelpers");
11
+ const instructionResultHelpers_1 = require("../utils/instructionResultHelpers");
11
12
  /**
12
13
  * Close a Miztake account
13
14
  */
@@ -21,8 +22,9 @@ async function closeMiztake(options) {
21
22
  .closeMiztake()
22
23
  .accounts(accounts)
23
24
  .instruction();
24
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
25
- return { instructions: [instruction], signers };
25
+ const feePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer: options.feePayer, admin: options.admin });
26
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(options.admin)], feePayer);
27
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, { signers });
26
28
  }
27
29
  /**
28
30
  * Close a UserStats account
@@ -37,8 +39,9 @@ async function closeUserStats(options) {
37
39
  .closeUserStats()
38
40
  .accounts(accounts)
39
41
  .instruction();
40
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
41
- return { instructions: [instruction], signers };
42
+ const feePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer: options.feePayer, admin: options.admin });
43
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(options.admin)], feePayer);
44
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, { signers });
42
45
  }
43
46
  /**
44
47
  * Close a SeasonMembership account
@@ -53,8 +56,9 @@ async function closeSeasonMembership(options) {
53
56
  .closeSeasonMembership()
54
57
  .accounts(accounts)
55
58
  .instruction();
56
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
57
- return { instructions: [instruction], signers };
59
+ const feePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer: options.feePayer, admin: options.admin });
60
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(options.admin)], feePayer);
61
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, { signers });
58
62
  }
59
63
  /**
60
64
  * Close a RewardWindow account
@@ -69,8 +73,9 @@ async function closeRewardWindow(options) {
69
73
  .closeRewardWindow()
70
74
  .accounts(accounts)
71
75
  .instruction();
72
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
73
- return { instructions: [instruction], signers };
76
+ const feePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer: options.feePayer, admin: options.admin });
77
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(options.admin)], feePayer);
78
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, { signers });
74
79
  }
75
80
  /**
76
81
  * Close a UserWindowParticipation account
@@ -85,8 +90,9 @@ async function closeUserWindowParticipation(options) {
85
90
  .closeUserWindowParticipation()
86
91
  .accounts(accounts)
87
92
  .instruction();
88
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
89
- return { instructions: [instruction], signers };
93
+ const feePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer: options.feePayer, admin: options.admin });
94
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(options.admin)], feePayer);
95
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, { signers });
90
96
  }
91
97
  /**
92
98
  * Close a ReferralPenaltyClaim account
@@ -101,6 +107,7 @@ async function closeReferralPenaltyClaim(options) {
101
107
  .closeReferralPenaltyClaim()
102
108
  .accounts(accounts)
103
109
  .instruction();
104
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
105
- return { instructions: [instruction], signers };
110
+ const feePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer: options.feePayer, admin: options.admin });
111
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(options.admin)], feePayer);
112
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, { signers });
106
113
  }
@@ -18,7 +18,7 @@ export interface ConfirmedPostOnXOptions {
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 */
21
+ /** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
22
22
  tier: TierNumber;
23
23
  windowNumber: WindowNumberLike;
24
24
  /** SHA-256 hex string (64 chars). On-chain expects the raw 32-byte digest. */
@@ -42,7 +42,11 @@ async function confirmedPostOnX(options) {
42
42
  .confirmedPostOnX(options.user, options.tier, windowNumber, Array.from((0, conversions_1.sha256HexToBytes32)(options.miztakeShaHash)))
43
43
  .accounts(accounts)
44
44
  .instruction();
45
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.adminKey, role: "admin" }], options.feePayer);
45
+ const feePayer = (0, signerHelpers_1.resolveFeePayer)({
46
+ feePayer: options.feePayer,
47
+ admin: options.adminKey,
48
+ });
49
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(options.adminKey)], feePayer);
46
50
  // OPTIMISTIC UPDATES
47
51
  let updatedAccounts = undefined;
48
52
  if (options.isOnTime !== undefined &&
@@ -12,7 +12,7 @@ export interface CreateMiztakeOptions {
12
12
  admin: PublicKey;
13
13
  seasonNumber: BN;
14
14
  windowNumber: WindowNumberLike;
15
- /** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
15
+ /** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
16
16
  tier: TierNumber;
17
17
  /** Optional injected timestamp (seconds) for optimistic state calculation */
18
18
  now?: BN;
@@ -77,10 +77,14 @@ async function createMiztake(options) {
77
77
  .accounts(accounts)
78
78
  .instruction();
79
79
  // Build signers
80
+ const feePayer = (0, signerHelpers_1.resolveFeePayer)({
81
+ feePayer: options.feePayer,
82
+ admin: options.admin,
83
+ });
80
84
  const signers = (0, signerHelpers_1.buildSigners)([
81
- { publicKey: options.user, role: "user" },
82
- { publicKey: options.admin, role: "admin" },
83
- ], options.feePayer);
85
+ (0, signerHelpers_1.asUserSigner)(options.user),
86
+ (0, signerHelpers_1.asAdminSigner)(options.admin),
87
+ ], feePayer);
84
88
  // OPTIMISTIC UPDATES
85
89
  const now = (0, optimistic_1.getCurrentTimestamp)(options.now);
86
90
  const curr = options.currentAccounts || {};
@@ -7,6 +7,7 @@ const pdas_1 = require("../utils/pdas");
7
7
  const constants_1 = require("../utils/constants");
8
8
  const programHelpers_1 = require("../utils/programHelpers");
9
9
  const signerHelpers_1 = require("../utils/signerHelpers");
10
+ const instructionResultHelpers_1 = require("../utils/instructionResultHelpers");
10
11
  /**
11
12
  * Initialize season escrow vault
12
13
  *
@@ -27,10 +28,10 @@ async function initializeEscrowVault(connection, admin, seasonNumber, feePayer)
27
28
  .initializeEscrowVault(seasonNumber)
28
29
  .accounts(accounts)
29
30
  .instruction();
30
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: admin, role: "admin" }], feePayer);
31
- return {
32
- instructions: [instruction],
31
+ const actualFeePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer, admin });
32
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(admin)], actualFeePayer);
33
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, {
33
34
  signers,
34
35
  pdas: { vault: vaultPda },
35
- };
36
+ });
36
37
  }
@@ -5,6 +5,7 @@ const web3_js_1 = require("@solana/web3.js");
5
5
  const pdas_1 = require("../utils/pdas");
6
6
  const programHelpers_1 = require("../utils/programHelpers");
7
7
  const signerHelpers_1 = require("../utils/signerHelpers");
8
+ const instructionResultHelpers_1 = require("../utils/instructionResultHelpers");
8
9
  const conversions_1 = require("../utils/conversions");
9
10
  /**
10
11
  * Initialize (materialize) a missing RewardWindow PDA (root-admin only).
@@ -30,10 +31,10 @@ async function initializeRewardWindow(options) {
30
31
  .initializeRewardWindow(seasonNumberBn, windowNumberBn)
31
32
  .accounts(accounts)
32
33
  .instruction();
33
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
34
- return {
35
- instructions: [instruction],
34
+ const feePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer: options.feePayer, admin: options.admin });
35
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(options.admin)], feePayer);
36
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, {
36
37
  signers,
37
38
  pdas: { seasonSettings, season, rewardWindow },
38
- };
39
+ });
39
40
  }
@@ -5,6 +5,7 @@ const web3_js_1 = require("@solana/web3.js");
5
5
  const pdas_1 = require("../utils/pdas");
6
6
  const programHelpers_1 = require("../utils/programHelpers");
7
7
  const signerHelpers_1 = require("../utils/signerHelpers");
8
+ const instructionResultHelpers_1 = require("../utils/instructionResultHelpers");
8
9
  /**
9
10
  * Initialize season settings
10
11
  *
@@ -28,12 +29,10 @@ async function initializeSeasonSettings(connection, admin, feePayer) {
28
29
  .initializeSeasonSettings()
29
30
  .accounts(accounts)
30
31
  .instruction();
31
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: admin, role: "admin" }], feePayer);
32
- return {
33
- instructions: [instruction],
32
+ const actualFeePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer, admin });
33
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(admin)], actualFeePayer);
34
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, {
34
35
  signers,
35
- pdas: {
36
- seasonSettings: seasonSettingsPda,
37
- },
38
- };
36
+ pdas: { seasonSettings: seasonSettingsPda },
37
+ });
39
38
  }
@@ -7,6 +7,7 @@ const pdas_1 = require("../utils/pdas");
7
7
  const constants_1 = require("../utils/constants");
8
8
  const programHelpers_1 = require("../utils/programHelpers");
9
9
  const signerHelpers_1 = require("../utils/signerHelpers");
10
+ const instructionResultHelpers_1 = require("../utils/instructionResultHelpers");
10
11
  /**
11
12
  * Initialize season deposit vault
12
13
  *
@@ -32,12 +33,10 @@ async function initializeSeasonVault(connection, admin, seasonNumber, feePayer)
32
33
  .initializeSeasonVault(seasonNumber)
33
34
  .accounts(accounts)
34
35
  .instruction();
35
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: admin, role: "admin" }], feePayer);
36
- return {
37
- instructions: [instruction],
36
+ const actualFeePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer, admin });
37
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(admin)], actualFeePayer);
38
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, {
38
39
  signers,
39
- pdas: {
40
- vault: vaultPda,
41
- },
42
- };
40
+ pdas: { vault: vaultPda },
41
+ });
43
42
  }
@@ -8,6 +8,7 @@ const pdas_1 = require("../utils/pdas");
8
8
  const idl_1 = require("../idl/idl");
9
9
  const anchorHelpers_1 = require("../utils/anchorHelpers");
10
10
  const signerHelpers_1 = require("../utils/signerHelpers");
11
+ const instructionResultHelpers_1 = require("../utils/instructionResultHelpers");
11
12
  /**
12
13
  * Initialize the global statistics PDA
13
14
  *
@@ -46,17 +47,16 @@ async function initializeStatistics(connection, admin, payer) {
46
47
  .accounts(accounts)
47
48
  .instruction();
48
49
  // Build signers list (admin always; payer if distinct)
49
- const required = [{ publicKey: admin, role: "admin" }];
50
+ const required = [(0, signerHelpers_1.asAdminSigner)(admin)];
50
51
  if (!actualPayer.equals(admin)) {
51
- required.push({ publicKey: actualPayer, role: "payer" });
52
+ required.push((0, signerHelpers_1.asPayerSigner)(actualPayer));
52
53
  }
53
54
  const signers = (0, signerHelpers_1.buildSigners)(required);
54
- return {
55
- instructions: [instruction],
55
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, {
56
56
  signers,
57
57
  pdas: { miztakeStatistics: miztakeStatisticsPda },
58
58
  miztakeStatisticsPda, // Back-compat alias
59
- };
59
+ });
60
60
  }
61
61
  /**
62
62
  * Check if statistics are already initialized
@@ -10,7 +10,7 @@ export interface JoinSeasonOptions {
10
10
  user: PublicKey;
11
11
  userTokenAccount: PublicKey;
12
12
  seasonNumber: BN;
13
- /** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
13
+ /** Tier number: 0=copper, 1=silver, 2=gold, 3=platinum, 4=mithril */
14
14
  tier: TierNumber;
15
15
  /** Optional referrer (PublicKey.default means no referrer) */
16
16
  referrer?: PublicKey;
@@ -13,6 +13,7 @@ const optimistic_1 = require("../optimistic");
13
13
  const pdas_1 = require("../utils/pdas");
14
14
  const tierPenalty_1 = require("../utils/tierPenalty");
15
15
  const enumHelpers_1 = require("../utils/enumHelpers");
16
+ const remainingAccounts_1 = require("../utils/remainingAccounts");
16
17
  /**
17
18
  * Join a season
18
19
  *
@@ -30,6 +31,7 @@ async function joinSeason(options) {
30
31
  seasonNumber: options.seasonNumber,
31
32
  tier: options.tier,
32
33
  });
34
+ const rootAdminTokenAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(constants_1.MIZD_TOKEN_MINT, constants_1.ADMIN_PUBLIC_KEY);
33
35
  const accounts = {
34
36
  seasonSettings: pdas.seasonSettings,
35
37
  season: pdas.season,
@@ -37,17 +39,30 @@ async function joinSeason(options) {
37
39
  seasonDepositVault: pdas.seasonDepositVault,
38
40
  seasonEscrowVault: pdas.seasonEscrowVault,
39
41
  mizdMint: constants_1.MIZD_TOKEN_MINT,
42
+ rootAdmin: constants_1.ADMIN_PUBLIC_KEY,
43
+ rootAdminTokenAccount,
40
44
  userTokenAccount: options.userTokenAccount,
41
45
  user: options.user,
46
+ associatedTokenProgram: spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID,
42
47
  tokenProgram: spl_token_1.TOKEN_PROGRAM_ID,
43
48
  systemProgram: web3_js_1.SystemProgram.programId,
44
49
  };
45
- const instruction = await program.methods
50
+ const referrer = options.referrer ?? web3_js_1.PublicKey.default;
51
+ const remainingAccounts = (0, remainingAccounts_1.getJoinSeasonRemainingAccounts)({
52
+ seasonNumber: options.seasonNumber,
53
+ tier: options.tier,
54
+ referrer,
55
+ });
56
+ const methodBuilder = program.methods
46
57
  // Anchor expects BN for u64 args.
47
- .joinSeason(options.seasonNumber, options.tier, options.referrer ?? web3_js_1.PublicKey.default)
48
- .accounts(accounts)
49
- .instruction();
50
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.user, role: "user" }], options.feePayer);
58
+ .joinSeason(options.seasonNumber, options.tier, referrer)
59
+ .accounts(accounts);
60
+ if (remainingAccounts.length > 0) {
61
+ methodBuilder.remainingAccounts(remainingAccounts);
62
+ }
63
+ const instruction = await methodBuilder.instruction();
64
+ const feePayer = (0, signerHelpers_1.getDefaultFeePayer)(options.feePayer);
65
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asUserSigner)(options.user)], feePayer);
51
66
  // OPTIMISTIC UPDATES
52
67
  const curr = options.currentAccounts || {};
53
68
  const now = (0, optimistic_1.getCurrentTimestamp)(options.now);
@@ -5,6 +5,7 @@ const pdas_1 = require("../utils/pdas");
5
5
  const programHelpers_1 = require("../utils/programHelpers");
6
6
  const signerHelpers_1 = require("../utils/signerHelpers");
7
7
  const optimistic_1 = require("../optimistic");
8
+ const instructionResultHelpers_1 = require("../utils/instructionResultHelpers");
8
9
  /**
9
10
  * Toggle season system pause
10
11
  *
@@ -28,16 +29,14 @@ async function toggleSeasonPause(connection, admin, feePayer, seasonSettings) {
28
29
  .toggleSeasonPause()
29
30
  .accounts(accounts)
30
31
  .instruction();
31
- const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: admin, role: "admin" }], feePayer);
32
+ const actualFeePayer = (0, signerHelpers_1.resolveFeePayer)({ feePayer, admin });
33
+ const signers = (0, signerHelpers_1.buildSigners)([(0, signerHelpers_1.asAdminSigner)(admin)], actualFeePayer);
32
34
  const updatedSettings = seasonSettings
33
35
  ? (0, optimistic_1.updateSeasonSettingsForPauseToggle)(seasonSettings)
34
36
  : undefined;
35
- return {
36
- instructions: [instruction],
37
+ return (0, instructionResultHelpers_1.singleInstruction)(instruction, {
37
38
  signers,
38
39
  pdas: { seasonSettings: seasonSettingsPda },
39
- ...(updatedSettings && {
40
- updatedAccounts: { seasonSettings: updatedSettings },
41
- }),
42
- };
40
+ ...(updatedSettings && { updatedAccounts: { seasonSettings: updatedSettings } }),
41
+ });
43
42
  }