proof-of-take-sdk 3.0.1 → 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/index.d.ts +5 -0
- package/dist/index.js +3 -0
- 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.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
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
}
|
package/dist/getters/index.d.ts
CHANGED
|
@@ -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";
|
package/dist/getters/index.js
CHANGED
|
@@ -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;
|
package/dist/index.d.ts
CHANGED
|
@@ -30,6 +30,9 @@ export { viewCurrentSeason } from "./instructions/viewCurrentSeason";
|
|
|
30
30
|
export * from "./utils/pdas";
|
|
31
31
|
export * from "./utils/constants";
|
|
32
32
|
export * from "./utils/accountUpdates";
|
|
33
|
+
export * from "./utils/accountConverters";
|
|
34
|
+
export * from "./utils/depositTier";
|
|
35
|
+
export * from "./utils/fetchAccount";
|
|
33
36
|
export declare const getProgram: typeof _getProgram;
|
|
34
37
|
export * from "./utils/signerHelpers";
|
|
35
38
|
export * from "./utils/conversions";
|
|
@@ -42,6 +45,8 @@ export * from "./constants/season";
|
|
|
42
45
|
export * from "./types";
|
|
43
46
|
export * from "./types/instructionResults";
|
|
44
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";
|
|
45
50
|
export type { ProofOfTake } from "./types/proof_of_take";
|
|
46
51
|
export { IDL } from "./idl/idl";
|
|
47
52
|
export { createProgram, createProgramWithId, getProgramReadOnly, } from "./client";
|
package/dist/index.js
CHANGED
|
@@ -68,6 +68,9 @@ Object.defineProperty(exports, "viewCurrentSeason", { enumerable: true, get: fun
|
|
|
68
68
|
__exportStar(require("./utils/pdas"), exports);
|
|
69
69
|
__exportStar(require("./utils/constants"), exports);
|
|
70
70
|
__exportStar(require("./utils/accountUpdates"), exports);
|
|
71
|
+
__exportStar(require("./utils/accountConverters"), exports);
|
|
72
|
+
__exportStar(require("./utils/depositTier"), exports);
|
|
73
|
+
__exportStar(require("./utils/fetchAccount"), exports);
|
|
71
74
|
exports.getProgram = programHelpers_1.getProgram;
|
|
72
75
|
__exportStar(require("./utils/signerHelpers"), exports);
|
|
73
76
|
__exportStar(require("./utils/conversions"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BN } from "@coral-xyz/anchor";
|
|
2
|
-
import { Connection, PublicKey
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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:
|
|
13
|
+
windowNumber: WindowNumberLike;
|
|
14
14
|
/** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
|
|
15
|
-
tier:
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
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,
|
|
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,
|
|
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
|
|
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
|
|
3
|
-
import { SeasonSettings, Season, RewardWindow, UserWindowParticipation, SeasonMembership } from "../types";
|
|
4
|
-
import {
|
|
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:
|
|
30
|
+
windowNumber: WindowNumberLike;
|
|
23
31
|
/** Tier number: 1=copper, 2=silver, 3=gold, 4=platinum, 5=mithril */
|
|
24
|
-
tier:
|
|
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
|
|
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,
|
|
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 =
|
|
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
|
}
|