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.
- package/dist/client.js +3 -3
- package/dist/getters/getMiztake.d.ts +2 -2
- package/dist/getters/getMiztake.js +2 -15
- package/dist/getters/getMiztakeStatistics.js +2 -2
- package/dist/getters/getReferralPenaltyClaim.d.ts +9 -0
- package/dist/getters/getReferralPenaltyClaim.js +20 -0
- package/dist/getters/getRewardWindow.d.ts +9 -0
- package/dist/getters/getRewardWindow.js +20 -0
- package/dist/getters/getSeason.d.ts +8 -0
- package/dist/getters/getSeason.js +20 -0
- package/dist/getters/getSeasonMembership.d.ts +9 -0
- package/dist/getters/getSeasonMembership.js +18 -0
- package/dist/getters/getSeasonSettings.d.ts +8 -0
- package/dist/getters/getSeasonSettings.js +18 -0
- package/dist/getters/getUserStats.js +3 -10
- package/dist/getters/getUserWindowParticipation.d.ts +9 -0
- package/dist/getters/getUserWindowParticipation.js +20 -0
- package/dist/getters/index.d.ts +6 -0
- package/dist/getters/index.js +6 -0
- package/dist/idl/idl.d.ts +5 -0
- package/dist/idl/idl.js +5 -1
- package/dist/idl/proof_of_take.json +32 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +10 -2
- package/dist/instructions/claimReferralPenaltyForWindow.d.ts +17 -14
- package/dist/instructions/claimReferralPenaltyForWindow.js +7 -4
- package/dist/instructions/claimWindowRewards.d.ts +14 -10
- package/dist/instructions/claimWindowRewards.js +6 -3
- package/dist/instructions/closeAuxiliaryAccounts.d.ts +8 -26
- package/dist/instructions/confirmedPostOnX.d.ts +14 -11
- package/dist/instructions/confirmedPostOnX.js +8 -3
- package/dist/instructions/createMiztake.d.ts +25 -28
- package/dist/instructions/createMiztake.js +12 -9
- package/dist/instructions/initializeEscrowVault.d.ts +5 -9
- package/dist/instructions/initializeSeasonSettings.d.ts +5 -9
- package/dist/instructions/initializeSeasonVault.d.ts +5 -9
- package/dist/instructions/initializeStatistics.d.ts +6 -7
- package/dist/instructions/initializeStatistics.js +12 -8
- package/dist/instructions/joinSeason.d.ts +18 -20
- package/dist/instructions/joinSeason.js +2 -1
- package/dist/instructions/toggleSeasonPause.d.ts +7 -9
- package/dist/instructions/toggleSeasonPause.js +1 -0
- package/dist/instructions/updateSeasonAdmin.d.ts +7 -9
- package/dist/instructions/updateSeasonAdmin.js +1 -0
- package/dist/instructions/viewSeasonMembershipStatus.d.ts +2 -2
- package/dist/instructions/viewWindowStatus.d.ts +2 -2
- package/dist/instructions/viewWindowStatus.js +3 -1
- package/dist/instructions/withdrawSeasonDeposit.d.ts +2 -2
- package/dist/types/anchorAccounts.d.ts +18 -0
- package/dist/types/anchorAccounts.js +2 -0
- package/dist/types/anchorViews.d.ts +11 -0
- package/dist/types/anchorViews.js +2 -0
- package/dist/types/instructionResults.d.ts +18 -19
- package/dist/types/proof_of_take.d.ts +32 -0
- package/dist/types.d.ts +53 -5
- package/dist/utils/accountConverters.d.ts +19 -0
- package/dist/utils/accountConverters.js +153 -0
- package/dist/utils/accountUpdates.d.ts +3 -3
- package/dist/utils/accountUpdates.js +40 -31
- package/dist/utils/conversions.d.ts +21 -1
- package/dist/utils/conversions.js +57 -9
- package/dist/utils/depositTier.d.ts +3 -0
- package/dist/utils/depositTier.js +21 -0
- package/dist/utils/enumHelpers.d.ts +5 -13
- package/dist/utils/enumHelpers.js +8 -0
- package/dist/utils/fetchAccount.d.ts +11 -0
- package/dist/utils/fetchAccount.js +23 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/pdaManager.d.ts +15 -14
- package/dist/utils/pdaManager.js +33 -26
- package/dist/utils/pdas.d.ts +9 -8
- package/dist/utils/pdas.js +24 -20
- package/dist/utils/programHelpers.js +1 -1
- package/dist/utils/signerHelpers.d.ts +2 -1
- package/dist/utils/simulationHelpers.js +7 -6
- package/dist/utils/tierPenalty.d.ts +2 -2
- package/dist/utils/tierPenalty.js +13 -11
- package/dist/utils/transactionBuilder.js +9 -7
- 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:
|
|
51
|
-
|
|
52
|
-
|
|
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):
|
|
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
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
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
|
|
73
|
+
const sendOptions = {
|
|
74
74
|
skipPreflight: options?.skipPreflight ?? false,
|
|
75
75
|
preflightCommitment: options?.preflightCommitment ?? "confirmed",
|
|
76
|
-
maxRetries: options
|
|
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:
|
|
98
|
-
|
|
99
|
-
:
|
|
100
|
-
|
|
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) {
|