proof-of-take-sdk 2.0.0 → 3.0.0
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/idl/proof_of_take.json +704 -39
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -0
- package/dist/instructions/closeAuxiliaryAccounts.d.ts +74 -0
- package/dist/instructions/closeAuxiliaryAccounts.js +106 -0
- package/dist/instructions/initializeEscrowVault.d.ts +2 -1
- package/dist/instructions/initializeEscrowVault.js +3 -3
- package/dist/instructions/initializeSeasonVault.d.ts +2 -1
- package/dist/instructions/initializeSeasonVault.js +3 -3
- package/dist/optimistic/index.d.ts +1 -1
- package/dist/optimistic/index.js +2 -1
- package/dist/types/closeAccountsTypes.d.ts +28 -0
- package/dist/types/closeAccountsTypes.js +2 -0
- package/dist/types/proof_of_take.d.ts +703 -38
- package/dist/utils/accountUpdates.d.ts +28 -0
- package/dist/utils/accountUpdates.js +50 -0
- package/dist/utils/pdaManager.js +6 -6
- package/dist/utils/pdas.d.ts +2 -2
- package/dist/utils/pdas.js +4 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -45,4 +45,6 @@ export type { ProofOfTake } from "./types/proof_of_take";
|
|
|
45
45
|
export { IDL } from "./idl/idl";
|
|
46
46
|
export { createProgram, createProgramWithId, getProgramReadOnly, } from "./client";
|
|
47
47
|
export * from "./getters";
|
|
48
|
+
export * from "./instructions/closeAuxiliaryAccounts";
|
|
49
|
+
export * from "./types/closeAccountsTypes";
|
|
48
50
|
export declare const VERSION = "1.0.0";
|
package/dist/index.js
CHANGED
|
@@ -88,5 +88,8 @@ Object.defineProperty(exports, "createProgramWithId", { enumerable: true, get: f
|
|
|
88
88
|
Object.defineProperty(exports, "getProgramReadOnly", { enumerable: true, get: function () { return client_1.getProgramReadOnly; } });
|
|
89
89
|
// Export getters
|
|
90
90
|
__exportStar(require("./getters"), exports);
|
|
91
|
+
// Export close instructions
|
|
92
|
+
__exportStar(require("./instructions/closeAuxiliaryAccounts"), exports);
|
|
93
|
+
__exportStar(require("./types/closeAccountsTypes"), exports);
|
|
91
94
|
// Version
|
|
92
95
|
exports.VERSION = "1.0.0";
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
import { SignerInfo } from "../utils/signerHelpers";
|
|
3
|
+
/**
|
|
4
|
+
* Close a Miztake account
|
|
5
|
+
*/
|
|
6
|
+
export declare function closeMiztake(options: {
|
|
7
|
+
connection: Connection;
|
|
8
|
+
admin: PublicKey;
|
|
9
|
+
accountToClose: PublicKey;
|
|
10
|
+
feePayer?: PublicKey;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
instructions: TransactionInstruction[];
|
|
13
|
+
signers: SignerInfo[];
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Close a UserStats account
|
|
17
|
+
*/
|
|
18
|
+
export declare function closeUserStats(options: {
|
|
19
|
+
connection: Connection;
|
|
20
|
+
admin: PublicKey;
|
|
21
|
+
accountToClose: PublicKey;
|
|
22
|
+
feePayer?: PublicKey;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
instructions: TransactionInstruction[];
|
|
25
|
+
signers: SignerInfo[];
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Close a SeasonMembership account
|
|
29
|
+
*/
|
|
30
|
+
export declare function closeSeasonMembership(options: {
|
|
31
|
+
connection: Connection;
|
|
32
|
+
admin: PublicKey;
|
|
33
|
+
accountToClose: PublicKey;
|
|
34
|
+
feePayer?: PublicKey;
|
|
35
|
+
}): Promise<{
|
|
36
|
+
instructions: TransactionInstruction[];
|
|
37
|
+
signers: SignerInfo[];
|
|
38
|
+
}>;
|
|
39
|
+
/**
|
|
40
|
+
* Close a RewardWindow account
|
|
41
|
+
*/
|
|
42
|
+
export declare function closeRewardWindow(options: {
|
|
43
|
+
connection: Connection;
|
|
44
|
+
admin: PublicKey;
|
|
45
|
+
accountToClose: PublicKey;
|
|
46
|
+
feePayer?: PublicKey;
|
|
47
|
+
}): Promise<{
|
|
48
|
+
instructions: TransactionInstruction[];
|
|
49
|
+
signers: SignerInfo[];
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Close a UserWindowParticipation account
|
|
53
|
+
*/
|
|
54
|
+
export declare function closeUserWindowParticipation(options: {
|
|
55
|
+
connection: Connection;
|
|
56
|
+
admin: PublicKey;
|
|
57
|
+
accountToClose: PublicKey;
|
|
58
|
+
feePayer?: PublicKey;
|
|
59
|
+
}): Promise<{
|
|
60
|
+
instructions: TransactionInstruction[];
|
|
61
|
+
signers: SignerInfo[];
|
|
62
|
+
}>;
|
|
63
|
+
/**
|
|
64
|
+
* Close a ReferralPenaltyClaim account
|
|
65
|
+
*/
|
|
66
|
+
export declare function closeReferralPenaltyClaim(options: {
|
|
67
|
+
connection: Connection;
|
|
68
|
+
admin: PublicKey;
|
|
69
|
+
accountToClose: PublicKey;
|
|
70
|
+
feePayer?: PublicKey;
|
|
71
|
+
}): Promise<{
|
|
72
|
+
instructions: TransactionInstruction[];
|
|
73
|
+
signers: SignerInfo[];
|
|
74
|
+
}>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.closeMiztake = closeMiztake;
|
|
4
|
+
exports.closeUserStats = closeUserStats;
|
|
5
|
+
exports.closeSeasonMembership = closeSeasonMembership;
|
|
6
|
+
exports.closeRewardWindow = closeRewardWindow;
|
|
7
|
+
exports.closeUserWindowParticipation = closeUserWindowParticipation;
|
|
8
|
+
exports.closeReferralPenaltyClaim = closeReferralPenaltyClaim;
|
|
9
|
+
const programHelpers_1 = require("../utils/programHelpers");
|
|
10
|
+
const signerHelpers_1 = require("../utils/signerHelpers");
|
|
11
|
+
/**
|
|
12
|
+
* Close a Miztake account
|
|
13
|
+
*/
|
|
14
|
+
async function closeMiztake(options) {
|
|
15
|
+
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
16
|
+
const accounts = {
|
|
17
|
+
admin: options.admin,
|
|
18
|
+
accountToClose: options.accountToClose,
|
|
19
|
+
};
|
|
20
|
+
const instruction = await program.methods
|
|
21
|
+
.closeMiztake()
|
|
22
|
+
.accounts(accounts)
|
|
23
|
+
.instruction();
|
|
24
|
+
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
|
|
25
|
+
return { instructions: [instruction], signers };
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Close a UserStats account
|
|
29
|
+
*/
|
|
30
|
+
async function closeUserStats(options) {
|
|
31
|
+
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
32
|
+
const accounts = {
|
|
33
|
+
admin: options.admin,
|
|
34
|
+
accountToClose: options.accountToClose,
|
|
35
|
+
};
|
|
36
|
+
const instruction = await program.methods
|
|
37
|
+
.closeUserStats()
|
|
38
|
+
.accounts(accounts)
|
|
39
|
+
.instruction();
|
|
40
|
+
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
|
|
41
|
+
return { instructions: [instruction], signers };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Close a SeasonMembership account
|
|
45
|
+
*/
|
|
46
|
+
async function closeSeasonMembership(options) {
|
|
47
|
+
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
48
|
+
const accounts = {
|
|
49
|
+
admin: options.admin,
|
|
50
|
+
accountToClose: options.accountToClose,
|
|
51
|
+
};
|
|
52
|
+
const instruction = await program.methods
|
|
53
|
+
.closeSeasonMembership()
|
|
54
|
+
.accounts(accounts)
|
|
55
|
+
.instruction();
|
|
56
|
+
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
|
|
57
|
+
return { instructions: [instruction], signers };
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Close a RewardWindow account
|
|
61
|
+
*/
|
|
62
|
+
async function closeRewardWindow(options) {
|
|
63
|
+
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
64
|
+
const accounts = {
|
|
65
|
+
admin: options.admin,
|
|
66
|
+
accountToClose: options.accountToClose,
|
|
67
|
+
};
|
|
68
|
+
const instruction = await program.methods
|
|
69
|
+
.closeRewardWindow()
|
|
70
|
+
.accounts(accounts)
|
|
71
|
+
.instruction();
|
|
72
|
+
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
|
|
73
|
+
return { instructions: [instruction], signers };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Close a UserWindowParticipation account
|
|
77
|
+
*/
|
|
78
|
+
async function closeUserWindowParticipation(options) {
|
|
79
|
+
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
80
|
+
const accounts = {
|
|
81
|
+
admin: options.admin,
|
|
82
|
+
accountToClose: options.accountToClose,
|
|
83
|
+
};
|
|
84
|
+
const instruction = await program.methods
|
|
85
|
+
.closeUserWindowParticipation()
|
|
86
|
+
.accounts(accounts)
|
|
87
|
+
.instruction();
|
|
88
|
+
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
|
|
89
|
+
return { instructions: [instruction], signers };
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Close a ReferralPenaltyClaim account
|
|
93
|
+
*/
|
|
94
|
+
async function closeReferralPenaltyClaim(options) {
|
|
95
|
+
const program = (0, programHelpers_1.getProgram)(options.connection);
|
|
96
|
+
const accounts = {
|
|
97
|
+
admin: options.admin,
|
|
98
|
+
accountToClose: options.accountToClose,
|
|
99
|
+
};
|
|
100
|
+
const instruction = await program.methods
|
|
101
|
+
.closeReferralPenaltyClaim()
|
|
102
|
+
.accounts(accounts)
|
|
103
|
+
.instruction();
|
|
104
|
+
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: options.admin, role: "admin" }], options.feePayer);
|
|
105
|
+
return { instructions: [instruction], signers };
|
|
106
|
+
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
2
|
import { SignerInfo } from "../utils/signerHelpers";
|
|
3
|
+
import { BN } from "@coral-xyz/anchor";
|
|
3
4
|
/**
|
|
4
5
|
* Initialize season escrow vault
|
|
5
6
|
*
|
|
6
7
|
* Single signer: admin (pays for account creation)
|
|
7
8
|
* This initializes the token vault for escrowed (protected) deposits.
|
|
8
9
|
*/
|
|
9
|
-
export declare function initializeEscrowVault(connection: Connection, admin: PublicKey, feePayer?: PublicKey): Promise<{
|
|
10
|
+
export declare function initializeEscrowVault(connection: Connection, admin: PublicKey, seasonNumber: BN, feePayer?: PublicKey): Promise<{
|
|
10
11
|
instructions: TransactionInstruction[];
|
|
11
12
|
signers: SignerInfo[];
|
|
12
13
|
pdas: {
|
|
@@ -13,9 +13,9 @@ const signerHelpers_1 = require("../utils/signerHelpers");
|
|
|
13
13
|
* Single signer: admin (pays for account creation)
|
|
14
14
|
* This initializes the token vault for escrowed (protected) deposits.
|
|
15
15
|
*/
|
|
16
|
-
async function initializeEscrowVault(connection, admin, feePayer) {
|
|
16
|
+
async function initializeEscrowVault(connection, admin, seasonNumber, feePayer) {
|
|
17
17
|
const program = (0, programHelpers_1.getProgram)(connection);
|
|
18
|
-
const [vaultPda] = (0, pdas_1.getSeasonEscrowVaultPda)();
|
|
18
|
+
const [vaultPda] = (0, pdas_1.getSeasonEscrowVaultPda)(seasonNumber);
|
|
19
19
|
const accounts = {
|
|
20
20
|
seasonEscrowVault: vaultPda,
|
|
21
21
|
mizdMint: constants_1.MIZD_TOKEN_MINT,
|
|
@@ -24,7 +24,7 @@ async function initializeEscrowVault(connection, admin, feePayer) {
|
|
|
24
24
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
25
25
|
};
|
|
26
26
|
const instruction = await program.methods
|
|
27
|
-
.initializeEscrowVault()
|
|
27
|
+
.initializeEscrowVault(seasonNumber)
|
|
28
28
|
.accounts(accounts)
|
|
29
29
|
.instruction();
|
|
30
30
|
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: admin, role: "admin" }], feePayer);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Connection, PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
2
|
import { SignerInfo } from "../utils/signerHelpers";
|
|
3
|
+
import { BN } from "@coral-xyz/anchor";
|
|
3
4
|
/**
|
|
4
5
|
* Initialize season deposit vault
|
|
5
6
|
*
|
|
@@ -11,7 +12,7 @@ import { SignerInfo } from "../utils/signerHelpers";
|
|
|
11
12
|
* @param feePayer - Optional separate fee payer for transaction fees
|
|
12
13
|
* @returns Instructions, signers array, and vault PDA
|
|
13
14
|
*/
|
|
14
|
-
export declare function initializeSeasonVault(connection: Connection, admin: PublicKey, feePayer?: PublicKey): Promise<{
|
|
15
|
+
export declare function initializeSeasonVault(connection: Connection, admin: PublicKey, seasonNumber: BN, feePayer?: PublicKey): Promise<{
|
|
15
16
|
instructions: TransactionInstruction[];
|
|
16
17
|
signers: SignerInfo[];
|
|
17
18
|
pdas: {
|
|
@@ -18,9 +18,9 @@ const signerHelpers_1 = require("../utils/signerHelpers");
|
|
|
18
18
|
* @param feePayer - Optional separate fee payer for transaction fees
|
|
19
19
|
* @returns Instructions, signers array, and vault PDA
|
|
20
20
|
*/
|
|
21
|
-
async function initializeSeasonVault(connection, admin, feePayer) {
|
|
21
|
+
async function initializeSeasonVault(connection, admin, seasonNumber, feePayer) {
|
|
22
22
|
const program = (0, programHelpers_1.getProgram)(connection);
|
|
23
|
-
const [vaultPda] = (0, pdas_1.getSeasonDepositVaultPda)();
|
|
23
|
+
const [vaultPda] = (0, pdas_1.getSeasonDepositVaultPda)(seasonNumber);
|
|
24
24
|
const accounts = {
|
|
25
25
|
seasonDepositVault: vaultPda,
|
|
26
26
|
mizdMint: constants_1.MIZD_TOKEN_MINT,
|
|
@@ -29,7 +29,7 @@ async function initializeSeasonVault(connection, admin, feePayer) {
|
|
|
29
29
|
systemProgram: web3_js_1.SystemProgram.programId,
|
|
30
30
|
};
|
|
31
31
|
const instruction = await program.methods
|
|
32
|
-
.initializeSeasonVault()
|
|
32
|
+
.initializeSeasonVault(seasonNumber)
|
|
33
33
|
.accounts(accounts)
|
|
34
34
|
.instruction();
|
|
35
35
|
const signers = (0, signerHelpers_1.buildSigners)([{ publicKey: admin, role: "admin" }], feePayer);
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* This module contains all optimistic update logic separated from instruction building.
|
|
5
5
|
* Each function mirrors the on-chain logic to predict state changes before confirmation.
|
|
6
6
|
*/
|
|
7
|
-
export { getCurrentTimestamp, createEmptyUserStats, initializeUserStats, updateUserStatsForMiztakeCreation, updateMiztakeStatisticsForCreation, initializeUserWindowParticipation, initializeRewardWindow, updateMiztakeForSeasonUse, initializeSeasonMembership, updateSeasonForJoin, updateWindowForConfirmation, updateParticipationForConfirmation, updateMembershipForConfirmation, updateSeasonForConfirmation, updateWindowForFinalization, updateParticipationForClaim, updateMembershipForClaim, initializeReferralPenaltyClaim, calculateWithdrawalAmount, updateSeasonSettingsForPauseToggle, updateSeasonSettingsForAdminUpdate, } from "../utils/accountUpdates";
|
|
7
|
+
export { getCurrentTimestamp, expectedToBeLazyInitialized, createEmptyUserStats, initializeUserStats, updateUserStatsForMiztakeCreation, updateMiztakeStatisticsForCreation, initializeUserWindowParticipation, initializeRewardWindow, updateMiztakeForSeasonUse, initializeSeasonMembership, updateSeasonForJoin, updateWindowForConfirmation, updateParticipationForConfirmation, updateMembershipForConfirmation, updateSeasonForConfirmation, updateWindowForFinalization, updateParticipationForClaim, updateMembershipForClaim, initializeReferralPenaltyClaim, calculateWithdrawalAmount, updateSeasonSettingsForPauseToggle, updateSeasonSettingsForAdminUpdate, } from "../utils/accountUpdates";
|
package/dist/optimistic/index.js
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
* Each function mirrors the on-chain logic to predict state changes before confirmation.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.updateSeasonSettingsForAdminUpdate = exports.updateSeasonSettingsForPauseToggle = exports.calculateWithdrawalAmount = exports.initializeReferralPenaltyClaim = exports.updateMembershipForClaim = exports.updateParticipationForClaim = exports.updateWindowForFinalization = exports.updateSeasonForConfirmation = exports.updateMembershipForConfirmation = exports.updateParticipationForConfirmation = exports.updateWindowForConfirmation = exports.updateSeasonForJoin = exports.initializeSeasonMembership = exports.updateMiztakeForSeasonUse = exports.initializeRewardWindow = exports.initializeUserWindowParticipation = exports.updateMiztakeStatisticsForCreation = exports.updateUserStatsForMiztakeCreation = exports.initializeUserStats = exports.createEmptyUserStats = exports.getCurrentTimestamp = void 0;
|
|
9
|
+
exports.updateSeasonSettingsForAdminUpdate = exports.updateSeasonSettingsForPauseToggle = exports.calculateWithdrawalAmount = exports.initializeReferralPenaltyClaim = exports.updateMembershipForClaim = exports.updateParticipationForClaim = exports.updateWindowForFinalization = exports.updateSeasonForConfirmation = exports.updateMembershipForConfirmation = exports.updateParticipationForConfirmation = exports.updateWindowForConfirmation = exports.updateSeasonForJoin = exports.initializeSeasonMembership = exports.updateMiztakeForSeasonUse = exports.initializeRewardWindow = exports.initializeUserWindowParticipation = exports.updateMiztakeStatisticsForCreation = exports.updateUserStatsForMiztakeCreation = exports.initializeUserStats = exports.createEmptyUserStats = exports.expectedToBeLazyInitialized = exports.getCurrentTimestamp = void 0;
|
|
10
10
|
// Re-export all optimistic update functions from accountUpdates
|
|
11
11
|
// This provides a cleaner separation of concerns
|
|
12
12
|
var accountUpdates_1 = require("../utils/accountUpdates");
|
|
13
13
|
Object.defineProperty(exports, "getCurrentTimestamp", { enumerable: true, get: function () { return accountUpdates_1.getCurrentTimestamp; } });
|
|
14
|
+
Object.defineProperty(exports, "expectedToBeLazyInitialized", { enumerable: true, get: function () { return accountUpdates_1.expectedToBeLazyInitialized; } });
|
|
14
15
|
Object.defineProperty(exports, "createEmptyUserStats", { enumerable: true, get: function () { return accountUpdates_1.createEmptyUserStats; } });
|
|
15
16
|
Object.defineProperty(exports, "initializeUserStats", { enumerable: true, get: function () { return accountUpdates_1.initializeUserStats; } });
|
|
16
17
|
Object.defineProperty(exports, "updateUserStatsForMiztakeCreation", { enumerable: true, get: function () { return accountUpdates_1.updateUserStatsForMiztakeCreation; } });
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Typed account interfaces for closing auxiliary accounts
|
|
4
|
+
*/
|
|
5
|
+
export interface CloseMiztakeAccounts {
|
|
6
|
+
admin: PublicKey;
|
|
7
|
+
accountToClose: PublicKey;
|
|
8
|
+
}
|
|
9
|
+
export interface CloseUserStatsAccounts {
|
|
10
|
+
admin: PublicKey;
|
|
11
|
+
accountToClose: PublicKey;
|
|
12
|
+
}
|
|
13
|
+
export interface CloseSeasonMembershipAccounts {
|
|
14
|
+
admin: PublicKey;
|
|
15
|
+
accountToClose: PublicKey;
|
|
16
|
+
}
|
|
17
|
+
export interface CloseRewardWindowAccounts {
|
|
18
|
+
admin: PublicKey;
|
|
19
|
+
accountToClose: PublicKey;
|
|
20
|
+
}
|
|
21
|
+
export interface CloseUserWindowParticipationAccounts {
|
|
22
|
+
admin: PublicKey;
|
|
23
|
+
accountToClose: PublicKey;
|
|
24
|
+
}
|
|
25
|
+
export interface CloseReferralPenaltyClaimAccounts {
|
|
26
|
+
admin: PublicKey;
|
|
27
|
+
accountToClose: PublicKey;
|
|
28
|
+
}
|