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
@@ -43,15 +43,16 @@ async function simulateInstruction(connection, instructions, signers, feePayer)
43
43
  transaction.recentBlockhash = blockhash;
44
44
  try {
45
45
  const simulation = await connection.simulateTransaction(transaction, undefined, [...signers.map((s) => s.publicKey)]);
46
+ const error = simulation.value.err !== null ? JSON.stringify(simulation.value.err) : undefined;
47
+ const returnData = simulation.value.returnData ?? undefined;
48
+ const accounts = simulation.value.accounts ?? undefined;
46
49
  return {
47
50
  success: simulation.value.err === null,
48
51
  logs: simulation.value.logs || [],
49
52
  unitsConsumed: simulation.value.unitsConsumed || 0,
50
- error: simulation.value.err
51
- ? JSON.stringify(simulation.value.err)
52
- : undefined,
53
- returnData: simulation.value.returnData || undefined,
54
- accounts: simulation.value.accounts || undefined,
53
+ ...(error !== undefined ? { error } : {}),
54
+ ...(returnData !== undefined ? { returnData } : {}),
55
+ ...(accounts !== undefined ? { accounts } : {}),
55
56
  };
56
57
  }
57
58
  catch (error) {
@@ -143,9 +144,9 @@ async function dryRun(connection, instructions, signers) {
143
144
  const result = await simulateInstruction(connection, instructions, signers);
144
145
  return {
145
146
  willSucceed: result.success,
146
- error: result.error,
147
147
  logs: result.logs,
148
148
  unitsConsumed: result.unitsConsumed,
149
+ ...(result.error !== undefined ? { error: result.error } : {}),
149
150
  };
150
151
  }
151
152
  /**
@@ -1,9 +1,9 @@
1
1
  import { BN } from "@coral-xyz/anchor";
2
- import { SeasonDepositTier } from "../types";
2
+ import { SeasonDepositTier, TierNumber } from "../types";
3
3
  /**
4
4
  * Validate and normalize a tier number (1..=5).
5
5
  */
6
- export declare function assertValidTierNumber(tier: number): number;
6
+ export declare function assertValidTierNumber(tier: number): TierNumber;
7
7
  /**
8
8
  * Convert numeric tier (1..=5) to the Anchor enum representation.
9
9
  */
@@ -4,6 +4,7 @@ exports.assertValidTierNumber = assertValidTierNumber;
4
4
  exports.tierNumberToDepositTier = tierNumberToDepositTier;
5
5
  exports.getTierPenaltyPerWindow = getTierPenaltyPerWindow;
6
6
  const anchor_1 = require("@coral-xyz/anchor");
7
+ const depositTier_1 = require("./depositTier");
7
8
  /**
8
9
  * Validate and normalize a tier number (1..=5).
9
10
  */
@@ -40,15 +41,16 @@ function tierNumberToDepositTier(tier) {
40
41
  */
41
42
  function getTierPenaltyPerWindow(tier) {
42
43
  // Base units (7 decimals): 1 MIZD = 10_000_000
43
- if ("copper" in tier)
44
- return new anchor_1.BN(1000000); // 0.1 MIZD
45
- if ("silver" in tier)
46
- return new anchor_1.BN(10000000); // 1 MIZD
47
- if ("gold" in tier)
48
- return new anchor_1.BN(100000000); // 10 MIZD
49
- if ("platinum" in tier)
50
- return new anchor_1.BN(1000000000); // 100 MIZD
51
- if ("mithril" in tier)
52
- return new anchor_1.BN(10000000000); // 1,000 MIZD
53
- throw new Error("Unknown depositTier");
44
+ switch ((0, depositTier_1.getDepositTierName)(tier)) {
45
+ case "copper":
46
+ return new anchor_1.BN(1000000); // 0.1 MIZD
47
+ case "silver":
48
+ return new anchor_1.BN(10000000); // 1 MIZD
49
+ case "gold":
50
+ return new anchor_1.BN(100000000); // 10 MIZD
51
+ case "platinum":
52
+ return new anchor_1.BN(1000000000); // 100 MIZD
53
+ case "mithril":
54
+ return new anchor_1.BN(10000000000); // 1,000 MIZD
55
+ }
54
56
  }
@@ -70,11 +70,12 @@ class TransactionBuilder {
70
70
  // Sign transaction
71
71
  const signedTx = await this.signTransaction(transaction, signers);
72
72
  // Send transaction
73
- const signature = await this.connection.sendRawTransaction(signedTx.serialize(), {
73
+ const sendOptions = {
74
74
  skipPreflight: options?.skipPreflight ?? false,
75
75
  preflightCommitment: options?.preflightCommitment ?? "confirmed",
76
- maxRetries: options?.maxRetries,
77
- });
76
+ ...(options?.maxRetries !== undefined ? { maxRetries: options.maxRetries } : {}),
77
+ };
78
+ const signature = await this.connection.sendRawTransaction(signedTx.serialize(), sendOptions);
78
79
  // Confirm transaction
79
80
  await this.connection.confirmTransaction(signature, options?.commitment ?? "confirmed");
80
81
  return signature;
@@ -90,14 +91,15 @@ class TransactionBuilder {
90
91
  const transaction = await this.buildTransaction(instructions, feePayer);
91
92
  try {
92
93
  const simulation = await this.connection.simulateTransaction(transaction);
94
+ const error = simulation.value.err !== null ? JSON.stringify(simulation.value.err) : undefined;
93
95
  return {
94
96
  success: simulation.value.err === null,
95
97
  logs: simulation.value.logs || [],
96
98
  unitsConsumed: simulation.value.unitsConsumed || 0,
97
- error: simulation.value.err
98
- ? JSON.stringify(simulation.value.err)
99
- : undefined,
100
- returnData: simulation.value.returnData,
99
+ ...(error !== undefined ? { error } : {}),
100
+ ...(simulation.value.returnData !== null && simulation.value.returnData !== undefined
101
+ ? { returnData: simulation.value.returnData }
102
+ : {}),
101
103
  };
102
104
  }
103
105
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "proof-of-take-sdk",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "TypeScript SDK for Proof of Take Solana program",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",