@nosana/kit 1.0.2 → 1.0.7

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 (49) hide show
  1. package/.gitlab-ci.yml +2 -2
  2. package/dist/config/defaultConfigs.js +2 -0
  3. package/dist/config/types.d.ts +1 -0
  4. package/dist/generated_clients/merkle_distributor/accounts/claimStatus.d.ts +53 -0
  5. package/dist/generated_clients/merkle_distributor/accounts/claimStatus.js +65 -0
  6. package/dist/generated_clients/merkle_distributor/accounts/index.d.ts +9 -0
  7. package/dist/generated_clients/merkle_distributor/accounts/index.js +9 -0
  8. package/dist/generated_clients/merkle_distributor/accounts/merkleDistributor.d.ts +109 -0
  9. package/dist/generated_clients/merkle_distributor/accounts/merkleDistributor.js +93 -0
  10. package/dist/generated_clients/merkle_distributor/errors/index.d.ts +8 -0
  11. package/dist/generated_clients/merkle_distributor/errors/index.js +8 -0
  12. package/dist/generated_clients/merkle_distributor/errors/merkleDistributor.d.ts +63 -0
  13. package/dist/generated_clients/merkle_distributor/errors/merkleDistributor.js +89 -0
  14. package/dist/generated_clients/merkle_distributor/index.d.ts +11 -0
  15. package/dist/generated_clients/merkle_distributor/index.js +11 -0
  16. package/dist/generated_clients/merkle_distributor/instructions/claimLocked.d.ts +69 -0
  17. package/dist/generated_clients/merkle_distributor/instructions/claimLocked.js +84 -0
  18. package/dist/generated_clients/merkle_distributor/instructions/clawback.d.ts +69 -0
  19. package/dist/generated_clients/merkle_distributor/instructions/clawback.js +88 -0
  20. package/dist/generated_clients/merkle_distributor/instructions/closeClaimStatus.d.ts +45 -0
  21. package/dist/generated_clients/merkle_distributor/instructions/closeClaimStatus.js +73 -0
  22. package/dist/generated_clients/merkle_distributor/instructions/closeDistributor.d.ts +64 -0
  23. package/dist/generated_clients/merkle_distributor/instructions/closeDistributor.js +84 -0
  24. package/dist/generated_clients/merkle_distributor/instructions/index.d.ts +16 -0
  25. package/dist/generated_clients/merkle_distributor/instructions/index.js +16 -0
  26. package/dist/generated_clients/merkle_distributor/instructions/newClaim.d.ts +78 -0
  27. package/dist/generated_clients/merkle_distributor/instructions/newClaim.js +101 -0
  28. package/dist/generated_clients/merkle_distributor/instructions/newDistributor.d.ts +113 -0
  29. package/dist/generated_clients/merkle_distributor/instructions/newDistributor.js +122 -0
  30. package/dist/generated_clients/merkle_distributor/instructions/setAdmin.d.ts +48 -0
  31. package/dist/generated_clients/merkle_distributor/instructions/setAdmin.js +70 -0
  32. package/dist/generated_clients/merkle_distributor/instructions/setClawbackReceiver.d.ts +48 -0
  33. package/dist/generated_clients/merkle_distributor/instructions/setClawbackReceiver.js +76 -0
  34. package/dist/generated_clients/merkle_distributor/instructions/setEnableSlot.d.ts +47 -0
  35. package/dist/generated_clients/merkle_distributor/instructions/setEnableSlot.js +73 -0
  36. package/dist/generated_clients/merkle_distributor/programs/index.d.ts +8 -0
  37. package/dist/generated_clients/merkle_distributor/programs/index.js +8 -0
  38. package/dist/generated_clients/merkle_distributor/programs/merkleDistributor.d.ts +50 -0
  39. package/dist/generated_clients/merkle_distributor/programs/merkleDistributor.js +67 -0
  40. package/dist/generated_clients/merkle_distributor/shared/index.d.ts +49 -0
  41. package/dist/generated_clients/merkle_distributor/shared/index.js +86 -0
  42. package/dist/index.d.ts +5 -0
  43. package/dist/index.js +5 -0
  44. package/dist/programs/MerkleDistributorProgram.d.ts +101 -0
  45. package/dist/programs/MerkleDistributorProgram.js +296 -0
  46. package/dist/services/NosService.js +5 -0
  47. package/eslint.config.js +1 -3
  48. package/package.json +13 -12
  49. package/scripts/generate-clients.ts +11 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, transformEncoder, } from '@solana/kit';
9
+ import { MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS } from '../programs';
10
+ import { getAccountMetaFactory } from '../shared';
11
+ export const SET_CLAWBACK_RECEIVER_DISCRIMINATOR = new Uint8Array([
12
+ 153, 217, 34, 20, 19, 29, 229, 75,
13
+ ]);
14
+ export function getSetClawbackReceiverDiscriminatorBytes() {
15
+ return fixEncoderSize(getBytesEncoder(), 8).encode(SET_CLAWBACK_RECEIVER_DISCRIMINATOR);
16
+ }
17
+ export function getSetClawbackReceiverInstructionDataEncoder() {
18
+ return transformEncoder(getStructEncoder([['discriminator', fixEncoderSize(getBytesEncoder(), 8)]]), (value) => ({
19
+ ...value,
20
+ discriminator: SET_CLAWBACK_RECEIVER_DISCRIMINATOR,
21
+ }));
22
+ }
23
+ export function getSetClawbackReceiverInstructionDataDecoder() {
24
+ return getStructDecoder([
25
+ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
26
+ ]);
27
+ }
28
+ export function getSetClawbackReceiverInstructionDataCodec() {
29
+ return combineCodec(getSetClawbackReceiverInstructionDataEncoder(), getSetClawbackReceiverInstructionDataDecoder());
30
+ }
31
+ export function getSetClawbackReceiverInstruction(input, config) {
32
+ // Program address.
33
+ const programAddress = config?.programAddress ?? MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS;
34
+ // Original accounts.
35
+ const originalAccounts = {
36
+ distributor: { value: input.distributor ?? null, isWritable: true },
37
+ newClawbackAccount: {
38
+ value: input.newClawbackAccount ?? null,
39
+ isWritable: false,
40
+ },
41
+ admin: { value: input.admin ?? null, isWritable: true },
42
+ };
43
+ const accounts = originalAccounts;
44
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
45
+ const instruction = {
46
+ accounts: [
47
+ getAccountMeta(accounts.distributor),
48
+ getAccountMeta(accounts.newClawbackAccount),
49
+ getAccountMeta(accounts.admin),
50
+ ],
51
+ programAddress,
52
+ data: getSetClawbackReceiverInstructionDataEncoder().encode({}),
53
+ };
54
+ return instruction;
55
+ }
56
+ export function parseSetClawbackReceiverInstruction(instruction) {
57
+ if (instruction.accounts.length < 3) {
58
+ // TODO: Coded error.
59
+ throw new Error('Not enough accounts');
60
+ }
61
+ let accountIndex = 0;
62
+ const getNextAccount = () => {
63
+ const accountMeta = instruction.accounts[accountIndex];
64
+ accountIndex += 1;
65
+ return accountMeta;
66
+ };
67
+ return {
68
+ programAddress: instruction.programAddress,
69
+ accounts: {
70
+ distributor: getNextAccount(),
71
+ newClawbackAccount: getNextAccount(),
72
+ admin: getNextAccount(),
73
+ },
74
+ data: getSetClawbackReceiverInstructionDataDecoder().decode(instruction.data),
75
+ };
76
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { type Address, type Codec, type Decoder, type Encoder, type IAccountMeta, type IAccountSignerMeta, type IInstruction, type IInstructionWithAccounts, type IInstructionWithData, type ReadonlyUint8Array, type TransactionSigner, type WritableAccount, type WritableSignerAccount } from '@solana/kit';
9
+ import { MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS } from '../programs';
10
+ export declare const SET_ENABLE_SLOT_DISCRIMINATOR: Uint8Array<ArrayBuffer>;
11
+ export declare function getSetEnableSlotDiscriminatorBytes(): ReadonlyUint8Array;
12
+ export type SetEnableSlotInstruction<TProgram extends string = typeof MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS, TAccountDistributor extends string | IAccountMeta<string> = string, TAccountAdmin extends string | IAccountMeta<string> = string, TRemainingAccounts extends readonly IAccountMeta<string>[] = []> = IInstruction<TProgram> & IInstructionWithData<Uint8Array> & IInstructionWithAccounts<[
13
+ TAccountDistributor extends string ? WritableAccount<TAccountDistributor> : TAccountDistributor,
14
+ TAccountAdmin extends string ? WritableSignerAccount<TAccountAdmin> & IAccountSignerMeta<TAccountAdmin> : TAccountAdmin,
15
+ ...TRemainingAccounts
16
+ ]>;
17
+ export type SetEnableSlotInstructionData = {
18
+ discriminator: ReadonlyUint8Array;
19
+ enableSlot: bigint;
20
+ };
21
+ export type SetEnableSlotInstructionDataArgs = {
22
+ enableSlot: number | bigint;
23
+ };
24
+ export declare function getSetEnableSlotInstructionDataEncoder(): Encoder<SetEnableSlotInstructionDataArgs>;
25
+ export declare function getSetEnableSlotInstructionDataDecoder(): Decoder<SetEnableSlotInstructionData>;
26
+ export declare function getSetEnableSlotInstructionDataCodec(): Codec<SetEnableSlotInstructionDataArgs, SetEnableSlotInstructionData>;
27
+ export type SetEnableSlotInput<TAccountDistributor extends string = string, TAccountAdmin extends string = string> = {
28
+ /** [MerkleDistributor]. */
29
+ distributor: Address<TAccountDistributor>;
30
+ /** Payer to create the distributor. */
31
+ admin: TransactionSigner<TAccountAdmin>;
32
+ enableSlot: SetEnableSlotInstructionDataArgs['enableSlot'];
33
+ };
34
+ export declare function getSetEnableSlotInstruction<TAccountDistributor extends string, TAccountAdmin extends string, TProgramAddress extends Address = typeof MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS>(input: SetEnableSlotInput<TAccountDistributor, TAccountAdmin>, config?: {
35
+ programAddress?: TProgramAddress;
36
+ }): SetEnableSlotInstruction<TProgramAddress, TAccountDistributor, TAccountAdmin>;
37
+ export type ParsedSetEnableSlotInstruction<TProgram extends string = typeof MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS, TAccountMetas extends readonly IAccountMeta[] = readonly IAccountMeta[]> = {
38
+ programAddress: Address<TProgram>;
39
+ accounts: {
40
+ /** [MerkleDistributor]. */
41
+ distributor: TAccountMetas[0];
42
+ /** Payer to create the distributor. */
43
+ admin: TAccountMetas[1];
44
+ };
45
+ data: SetEnableSlotInstructionData;
46
+ };
47
+ export declare function parseSetEnableSlotInstruction<TProgram extends string, TAccountMetas extends readonly IAccountMeta[]>(instruction: IInstruction<TProgram> & IInstructionWithAccounts<TAccountMetas> & IInstructionWithData<Uint8Array>): ParsedSetEnableSlotInstruction<TProgram, TAccountMetas>;
@@ -0,0 +1,73 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { combineCodec, fixDecoderSize, fixEncoderSize, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, transformEncoder, } from '@solana/kit';
9
+ import { MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS } from '../programs';
10
+ import { getAccountMetaFactory } from '../shared';
11
+ export const SET_ENABLE_SLOT_DISCRIMINATOR = new Uint8Array([
12
+ 5, 52, 73, 33, 150, 115, 97, 206,
13
+ ]);
14
+ export function getSetEnableSlotDiscriminatorBytes() {
15
+ return fixEncoderSize(getBytesEncoder(), 8).encode(SET_ENABLE_SLOT_DISCRIMINATOR);
16
+ }
17
+ export function getSetEnableSlotInstructionDataEncoder() {
18
+ return transformEncoder(getStructEncoder([
19
+ ['discriminator', fixEncoderSize(getBytesEncoder(), 8)],
20
+ ['enableSlot', getU64Encoder()],
21
+ ]), (value) => ({ ...value, discriminator: SET_ENABLE_SLOT_DISCRIMINATOR }));
22
+ }
23
+ export function getSetEnableSlotInstructionDataDecoder() {
24
+ return getStructDecoder([
25
+ ['discriminator', fixDecoderSize(getBytesDecoder(), 8)],
26
+ ['enableSlot', getU64Decoder()],
27
+ ]);
28
+ }
29
+ export function getSetEnableSlotInstructionDataCodec() {
30
+ return combineCodec(getSetEnableSlotInstructionDataEncoder(), getSetEnableSlotInstructionDataDecoder());
31
+ }
32
+ export function getSetEnableSlotInstruction(input, config) {
33
+ // Program address.
34
+ const programAddress = config?.programAddress ?? MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS;
35
+ // Original accounts.
36
+ const originalAccounts = {
37
+ distributor: { value: input.distributor ?? null, isWritable: true },
38
+ admin: { value: input.admin ?? null, isWritable: true },
39
+ };
40
+ const accounts = originalAccounts;
41
+ // Original args.
42
+ const args = { ...input };
43
+ const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
44
+ const instruction = {
45
+ accounts: [
46
+ getAccountMeta(accounts.distributor),
47
+ getAccountMeta(accounts.admin),
48
+ ],
49
+ programAddress,
50
+ data: getSetEnableSlotInstructionDataEncoder().encode(args),
51
+ };
52
+ return instruction;
53
+ }
54
+ export function parseSetEnableSlotInstruction(instruction) {
55
+ if (instruction.accounts.length < 2) {
56
+ // TODO: Coded error.
57
+ throw new Error('Not enough accounts');
58
+ }
59
+ let accountIndex = 0;
60
+ const getNextAccount = () => {
61
+ const accountMeta = instruction.accounts[accountIndex];
62
+ accountIndex += 1;
63
+ return accountMeta;
64
+ };
65
+ return {
66
+ programAddress: instruction.programAddress,
67
+ accounts: {
68
+ distributor: getNextAccount(),
69
+ admin: getNextAccount(),
70
+ },
71
+ data: getSetEnableSlotInstructionDataDecoder().decode(instruction.data),
72
+ };
73
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ export * from './merkleDistributor';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ export * from './merkleDistributor';
@@ -0,0 +1,50 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { type Address, type ReadonlyUint8Array } from '@solana/kit';
9
+ import { type ParsedClaimLockedInstruction, type ParsedClawbackInstruction, type ParsedCloseClaimStatusInstruction, type ParsedCloseDistributorInstruction, type ParsedNewClaimInstruction, type ParsedNewDistributorInstruction, type ParsedSetAdminInstruction, type ParsedSetClawbackReceiverInstruction, type ParsedSetEnableSlotInstruction } from '../instructions';
10
+ export declare const MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS: Address<"">;
11
+ export declare enum MerkleDistributorAccount {
12
+ ClaimStatus = 0,
13
+ MerkleDistributor = 1
14
+ }
15
+ export declare function identifyMerkleDistributorAccount(account: {
16
+ data: ReadonlyUint8Array;
17
+ } | ReadonlyUint8Array): MerkleDistributorAccount;
18
+ export declare enum MerkleDistributorInstruction {
19
+ NewDistributor = 0,
20
+ CloseDistributor = 1,
21
+ CloseClaimStatus = 2,
22
+ SetEnableSlot = 3,
23
+ NewClaim = 4,
24
+ ClaimLocked = 5,
25
+ Clawback = 6,
26
+ SetClawbackReceiver = 7,
27
+ SetAdmin = 8
28
+ }
29
+ export declare function identifyMerkleDistributorInstruction(instruction: {
30
+ data: ReadonlyUint8Array;
31
+ } | ReadonlyUint8Array): MerkleDistributorInstruction;
32
+ export type ParsedMerkleDistributorInstruction<TProgram extends string = ''> = ({
33
+ instructionType: MerkleDistributorInstruction.NewDistributor;
34
+ } & ParsedNewDistributorInstruction<TProgram>) | ({
35
+ instructionType: MerkleDistributorInstruction.CloseDistributor;
36
+ } & ParsedCloseDistributorInstruction<TProgram>) | ({
37
+ instructionType: MerkleDistributorInstruction.CloseClaimStatus;
38
+ } & ParsedCloseClaimStatusInstruction<TProgram>) | ({
39
+ instructionType: MerkleDistributorInstruction.SetEnableSlot;
40
+ } & ParsedSetEnableSlotInstruction<TProgram>) | ({
41
+ instructionType: MerkleDistributorInstruction.NewClaim;
42
+ } & ParsedNewClaimInstruction<TProgram>) | ({
43
+ instructionType: MerkleDistributorInstruction.ClaimLocked;
44
+ } & ParsedClaimLockedInstruction<TProgram>) | ({
45
+ instructionType: MerkleDistributorInstruction.Clawback;
46
+ } & ParsedClawbackInstruction<TProgram>) | ({
47
+ instructionType: MerkleDistributorInstruction.SetClawbackReceiver;
48
+ } & ParsedSetClawbackReceiverInstruction<TProgram>) | ({
49
+ instructionType: MerkleDistributorInstruction.SetAdmin;
50
+ } & ParsedSetAdminInstruction<TProgram>);
@@ -0,0 +1,67 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { containsBytes, fixEncoderSize, getBytesEncoder, } from '@solana/kit';
9
+ export const MERKLE_DISTRIBUTOR_PROGRAM_ADDRESS = '';
10
+ export var MerkleDistributorAccount;
11
+ (function (MerkleDistributorAccount) {
12
+ MerkleDistributorAccount[MerkleDistributorAccount["ClaimStatus"] = 0] = "ClaimStatus";
13
+ MerkleDistributorAccount[MerkleDistributorAccount["MerkleDistributor"] = 1] = "MerkleDistributor";
14
+ })(MerkleDistributorAccount || (MerkleDistributorAccount = {}));
15
+ export function identifyMerkleDistributorAccount(account) {
16
+ const data = 'data' in account ? account.data : account;
17
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([22, 183, 249, 157, 247, 95, 150, 96])), 0)) {
18
+ return MerkleDistributorAccount.ClaimStatus;
19
+ }
20
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([77, 119, 139, 70, 84, 247, 12, 26])), 0)) {
21
+ return MerkleDistributorAccount.MerkleDistributor;
22
+ }
23
+ throw new Error('The provided account could not be identified as a merkleDistributor account.');
24
+ }
25
+ export var MerkleDistributorInstruction;
26
+ (function (MerkleDistributorInstruction) {
27
+ MerkleDistributorInstruction[MerkleDistributorInstruction["NewDistributor"] = 0] = "NewDistributor";
28
+ MerkleDistributorInstruction[MerkleDistributorInstruction["CloseDistributor"] = 1] = "CloseDistributor";
29
+ MerkleDistributorInstruction[MerkleDistributorInstruction["CloseClaimStatus"] = 2] = "CloseClaimStatus";
30
+ MerkleDistributorInstruction[MerkleDistributorInstruction["SetEnableSlot"] = 3] = "SetEnableSlot";
31
+ MerkleDistributorInstruction[MerkleDistributorInstruction["NewClaim"] = 4] = "NewClaim";
32
+ MerkleDistributorInstruction[MerkleDistributorInstruction["ClaimLocked"] = 5] = "ClaimLocked";
33
+ MerkleDistributorInstruction[MerkleDistributorInstruction["Clawback"] = 6] = "Clawback";
34
+ MerkleDistributorInstruction[MerkleDistributorInstruction["SetClawbackReceiver"] = 7] = "SetClawbackReceiver";
35
+ MerkleDistributorInstruction[MerkleDistributorInstruction["SetAdmin"] = 8] = "SetAdmin";
36
+ })(MerkleDistributorInstruction || (MerkleDistributorInstruction = {}));
37
+ export function identifyMerkleDistributorInstruction(instruction) {
38
+ const data = 'data' in instruction ? instruction.data : instruction;
39
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([32, 139, 112, 171, 0, 2, 225, 155])), 0)) {
40
+ return MerkleDistributorInstruction.NewDistributor;
41
+ }
42
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([202, 56, 180, 143, 46, 104, 106, 112])), 0)) {
43
+ return MerkleDistributorInstruction.CloseDistributor;
44
+ }
45
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([163, 214, 191, 165, 245, 188, 17, 185])), 0)) {
46
+ return MerkleDistributorInstruction.CloseClaimStatus;
47
+ }
48
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([5, 52, 73, 33, 150, 115, 97, 206])), 0)) {
49
+ return MerkleDistributorInstruction.SetEnableSlot;
50
+ }
51
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([78, 177, 98, 123, 210, 21, 187, 83])), 0)) {
52
+ return MerkleDistributorInstruction.NewClaim;
53
+ }
54
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([34, 206, 181, 23, 11, 207, 147, 90])), 0)) {
55
+ return MerkleDistributorInstruction.ClaimLocked;
56
+ }
57
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([111, 92, 142, 79, 33, 234, 82, 27])), 0)) {
58
+ return MerkleDistributorInstruction.Clawback;
59
+ }
60
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([153, 217, 34, 20, 19, 29, 229, 75])), 0)) {
61
+ return MerkleDistributorInstruction.SetClawbackReceiver;
62
+ }
63
+ if (containsBytes(data, fixEncoderSize(getBytesEncoder(), 8).encode(new Uint8Array([251, 163, 0, 52, 91, 194, 187, 92])), 0)) {
64
+ return MerkleDistributorInstruction.SetAdmin;
65
+ }
66
+ throw new Error('The provided instruction could not be identified as a merkleDistributor instruction.');
67
+ }
@@ -0,0 +1,49 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { type Address, type IAccountMeta, type IAccountSignerMeta, type ProgramDerivedAddress, type TransactionSigner } from '@solana/kit';
9
+ /**
10
+ * Asserts that the given value is not null or undefined.
11
+ * @internal
12
+ */
13
+ export declare function expectSome<T>(value: T | null | undefined): T;
14
+ /**
15
+ * Asserts that the given value is a PublicKey.
16
+ * @internal
17
+ */
18
+ export declare function expectAddress<T extends string = string>(value: Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null | undefined): Address<T>;
19
+ /**
20
+ * Asserts that the given value is a PDA.
21
+ * @internal
22
+ */
23
+ export declare function expectProgramDerivedAddress<T extends string = string>(value: Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null | undefined): ProgramDerivedAddress<T>;
24
+ /**
25
+ * Asserts that the given value is a TransactionSigner.
26
+ * @internal
27
+ */
28
+ export declare function expectTransactionSigner<T extends string = string>(value: Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null | undefined): TransactionSigner<T>;
29
+ /**
30
+ * Defines an instruction account to resolve.
31
+ * @internal
32
+ */
33
+ export type ResolvedAccount<T extends string = string, U extends Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null = Address<T> | ProgramDerivedAddress<T> | TransactionSigner<T> | null> = {
34
+ isWritable: boolean;
35
+ value: U;
36
+ };
37
+ /**
38
+ * Defines an instruction that stores additional bytes on-chain.
39
+ * @internal
40
+ */
41
+ export type IInstructionWithByteDelta = {
42
+ byteDelta: number;
43
+ };
44
+ /**
45
+ * Get account metas and signers from resolved accounts.
46
+ * @internal
47
+ */
48
+ export declare function getAccountMetaFactory(programAddress: Address, optionalAccountStrategy: 'omitted' | 'programId'): (account: ResolvedAccount) => IAccountMeta | IAccountSignerMeta | undefined;
49
+ export declare function isTransactionSigner<TAddress extends string = string>(value: Address<TAddress> | ProgramDerivedAddress<TAddress> | TransactionSigner<TAddress>): value is TransactionSigner<TAddress>;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+ import { AccountRole, isProgramDerivedAddress, isTransactionSigner as kitIsTransactionSigner, upgradeRoleToSigner, } from '@solana/kit';
9
+ /**
10
+ * Asserts that the given value is not null or undefined.
11
+ * @internal
12
+ */
13
+ export function expectSome(value) {
14
+ if (value == null) {
15
+ throw new Error('Expected a value but received null or undefined.');
16
+ }
17
+ return value;
18
+ }
19
+ /**
20
+ * Asserts that the given value is a PublicKey.
21
+ * @internal
22
+ */
23
+ export function expectAddress(value) {
24
+ if (!value) {
25
+ throw new Error('Expected a Address.');
26
+ }
27
+ if (typeof value === 'object' && 'address' in value) {
28
+ return value.address;
29
+ }
30
+ if (Array.isArray(value)) {
31
+ return value[0];
32
+ }
33
+ return value;
34
+ }
35
+ /**
36
+ * Asserts that the given value is a PDA.
37
+ * @internal
38
+ */
39
+ export function expectProgramDerivedAddress(value) {
40
+ if (!value || !Array.isArray(value) || !isProgramDerivedAddress(value)) {
41
+ throw new Error('Expected a ProgramDerivedAddress.');
42
+ }
43
+ return value;
44
+ }
45
+ /**
46
+ * Asserts that the given value is a TransactionSigner.
47
+ * @internal
48
+ */
49
+ export function expectTransactionSigner(value) {
50
+ if (!value || !isTransactionSigner(value)) {
51
+ throw new Error('Expected a TransactionSigner.');
52
+ }
53
+ return value;
54
+ }
55
+ /**
56
+ * Get account metas and signers from resolved accounts.
57
+ * @internal
58
+ */
59
+ export function getAccountMetaFactory(programAddress, optionalAccountStrategy) {
60
+ return (account) => {
61
+ if (!account.value) {
62
+ if (optionalAccountStrategy === 'omitted')
63
+ return;
64
+ return Object.freeze({
65
+ address: programAddress,
66
+ role: AccountRole.READONLY,
67
+ });
68
+ }
69
+ const writableRole = account.isWritable
70
+ ? AccountRole.WRITABLE
71
+ : AccountRole.READONLY;
72
+ return Object.freeze({
73
+ address: expectAddress(account.value),
74
+ role: isTransactionSigner(account.value)
75
+ ? upgradeRoleToSigner(writableRole)
76
+ : writableRole,
77
+ ...(isTransactionSigner(account.value) ? { signer: account.value } : {}),
78
+ });
79
+ };
80
+ }
81
+ export function isTransactionSigner(value) {
82
+ return (!!value &&
83
+ typeof value === 'object' &&
84
+ 'address' in value &&
85
+ kitIsTransactionSigner(value));
86
+ }
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { ClientConfig, NosanaNetwork, PartialClientConfig, WalletConfig } from '
2
2
  import { Logger } from './logger/Logger.js';
3
3
  import { JobsProgram } from './programs/JobsProgram.js';
4
4
  import { StakeProgram } from './programs/StakeProgram.js';
5
+ import { MerkleDistributorProgram } from './programs/MerkleDistributorProgram.js';
5
6
  import { SolanaService } from './services/SolanaService.js';
6
7
  import { NosService } from './services/NosService.js';
7
8
  import { IPFS } from './ipfs/IPFS.js';
@@ -10,6 +11,7 @@ export declare class NosanaClient {
10
11
  readonly config: ClientConfig;
11
12
  readonly jobs: JobsProgram;
12
13
  readonly stake: StakeProgram;
14
+ readonly merkleDistributor: MerkleDistributorProgram;
13
15
  readonly solana: SolanaService;
14
16
  readonly nos: NosService;
15
17
  readonly ipfs: IPFS;
@@ -25,9 +27,12 @@ export { JobsProgram, JobState, MarketQueueType } from './programs/JobsProgram.j
25
27
  export type { Job, Market, Run } from './programs/JobsProgram.js';
26
28
  export { StakeProgram } from './programs/StakeProgram.js';
27
29
  export type { Stake } from './programs/StakeProgram.js';
30
+ export { MerkleDistributorProgram, ClaimTarget } from './programs/MerkleDistributorProgram.js';
31
+ export type { MerkleDistributor, ClaimStatus } from './programs/MerkleDistributorProgram.js';
28
32
  export * from './ipfs/IPFS.js';
29
33
  export { NosService } from './services/NosService.js';
30
34
  export type { TokenAccount, TokenAccountWithBalance } from './services/NosService.js';
31
35
  export * as JobsClient from './generated_clients/jobs/index.js';
32
36
  export * as StakingClient from './generated_clients/staking/index.js';
37
+ export * as MerkleDistributorClient from './generated_clients/merkle_distributor/index.js';
33
38
  export * from 'gill';
package/dist/index.js CHANGED
@@ -2,6 +2,7 @@ import { getNosanaConfig, NosanaNetwork, } from './config/index.js';
2
2
  import { Logger } from './logger/Logger.js';
3
3
  import { JobsProgram } from './programs/JobsProgram.js';
4
4
  import { StakeProgram } from './programs/StakeProgram.js';
5
+ import { MerkleDistributorProgram } from './programs/MerkleDistributorProgram.js';
5
6
  import { SolanaService } from './services/SolanaService.js';
6
7
  import { NosService } from './services/NosService.js';
7
8
  import { IPFS } from './ipfs/IPFS.js';
@@ -14,6 +15,7 @@ export class NosanaClient {
14
15
  }
15
16
  this.jobs = new JobsProgram(this);
16
17
  this.stake = new StakeProgram(this);
18
+ this.merkleDistributor = new MerkleDistributorProgram(this);
17
19
  this.logger = Logger.getInstance();
18
20
  this.solana = new SolanaService(this);
19
21
  this.nos = new NosService(this);
@@ -32,6 +34,8 @@ export * from './logger/Logger.js';
32
34
  export { JobsProgram, JobState, MarketQueueType } from './programs/JobsProgram.js';
33
35
  // Export StakeProgram and related types
34
36
  export { StakeProgram } from './programs/StakeProgram.js';
37
+ // Export MerkleDistributorProgram and related types
38
+ export { MerkleDistributorProgram, ClaimTarget } from './programs/MerkleDistributorProgram.js';
35
39
  // Export IPFS utilities
36
40
  export * from './ipfs/IPFS.js';
37
41
  // Export NOS token service
@@ -39,5 +43,6 @@ export { NosService } from './services/NosService.js';
39
43
  // Export generated clients under namespaces to avoid naming conflicts
40
44
  export * as JobsClient from './generated_clients/jobs/index.js';
41
45
  export * as StakingClient from './generated_clients/staking/index.js';
46
+ export * as MerkleDistributorClient from './generated_clients/merkle_distributor/index.js';
42
47
  // Export dependencies
43
48
  export * from 'gill';
@@ -0,0 +1,101 @@
1
+ import { BaseProgram } from './BaseProgram.js';
2
+ import { Address, Account, ReadonlyUint8Array, KeyPairSigner } from 'gill';
3
+ import { NosanaClient } from '../index.js';
4
+ import * as programClient from '../generated_clients/merkle_distributor/index.js';
5
+ import { ConvertTypesForDb } from '../utils/index.js';
6
+ /**
7
+ * Claim target enum for merkle distributor.
8
+ * Determines which address receives the claimed tokens.
9
+ */
10
+ export declare enum ClaimTarget {
11
+ YES = "YES",
12
+ NO = "NO"
13
+ }
14
+ /**
15
+ * Allowed addresses for receiving claimed tokens from merkle distributor.
16
+ * The `to` account must be the ATA of one of these addresses.
17
+ */
18
+ export declare const ALLOWED_RECEIVE_ADDRESSES: {
19
+ readonly YES: Address<"YessuvqUauj9yW4B3eERcyRLWmQtWpFc2ERKmaedmCE">;
20
+ readonly NO: Address<"NopXntmRdXhYNkoZaNTMUMShJ3aVG5RvwpiyPdd4bMh">;
21
+ };
22
+ export type MerkleDistributor = ConvertTypesForDb<programClient.MerkleDistributorArgs> & {
23
+ address: Address;
24
+ };
25
+ export type ClaimStatus = ConvertTypesForDb<programClient.ClaimStatusArgs> & {
26
+ address: Address;
27
+ };
28
+ /**
29
+ * Error thrown when a claim status account is not found
30
+ */
31
+ export declare class ClaimStatusNotFoundError extends Error {
32
+ constructor(address: Address);
33
+ }
34
+ export declare class MerkleDistributorProgram extends BaseProgram {
35
+ readonly client: typeof programClient;
36
+ constructor(sdk: NosanaClient);
37
+ protected getProgramId(): Address;
38
+ /**
39
+ * Derive the ClaimStatus PDA address for a given distributor and optional claimant.
40
+ * If claimant is not provided, uses the wallet's address.
41
+ *
42
+ * @param distributor The address of the merkle distributor
43
+ * @param claimant Optional claimant address. If not provided, uses the wallet's address.
44
+ * @returns The ClaimStatus PDA address
45
+ * @throws Error if wallet is not set and claimant is not provided
46
+ */
47
+ getClaimStatusPda(distributor: Address, claimant?: Address): Promise<Address>;
48
+ /**
49
+ * Fetch a merkle distributor account by address
50
+ */
51
+ get(addr: Address): Promise<MerkleDistributor>;
52
+ /**
53
+ * Fetch all merkle distributor accounts
54
+ */
55
+ all(): Promise<MerkleDistributor[]>;
56
+ /**
57
+ * Fetch a claim status account by address
58
+ */
59
+ getClaimStatus(addr: Address): Promise<ClaimStatus>;
60
+ /**
61
+ * Fetch claim status for a specific distributor and optional claimant.
62
+ * Derives the ClaimStatus PDA using the claimant address (or wallet's address if not provided) and the distributor address.
63
+ *
64
+ * @param distributor The address of the merkle distributor
65
+ * @param claimant Optional claimant address. If not provided, uses the wallet's address.
66
+ * @returns The claim status if it exists, null otherwise
67
+ * @throws Error if wallet is not set and claimant is not provided
68
+ */
69
+ getClaimStatusForDistributor(distributor: Address, claimant?: Address): Promise<ClaimStatus | null>;
70
+ /**
71
+ * Fetch all claim status accounts
72
+ * TODO: add filter for claimant and distributor
73
+ */
74
+ allClaimStatus(): Promise<ClaimStatus[]>;
75
+ /**
76
+ * Transform merkle distributor account to include address and convert BigInt to numbers
77
+ */
78
+ transformMerkleDistributorAccount(distributorAccount: Account<programClient.MerkleDistributor>): MerkleDistributor;
79
+ /**
80
+ * Transform claim status account to include address and convert BigInt to numbers
81
+ */
82
+ transformClaimStatusAccount(claimStatusAccount: Account<programClient.ClaimStatus>): ClaimStatus;
83
+ /**
84
+ * Claim tokens from a merkle distributor.
85
+ * This function creates a new ClaimStatus account and claims the tokens in a single instruction.
86
+ *
87
+ * @param params Parameters for claiming tokens
88
+ * @param params.claimant Optional claimant signer. If not provided, uses the wallet.
89
+ * @returns The newClaim instruction
90
+ * @throws NosanaError if tokens have already been claimed
91
+ * @throws Error if wallet is not set and claimant is not provided
92
+ */
93
+ claim(params: {
94
+ distributor: Address;
95
+ amountUnlocked: number | bigint;
96
+ amountLocked: number | bigint;
97
+ proof: Array<ReadonlyUint8Array>;
98
+ target: ClaimTarget;
99
+ claimant?: KeyPairSigner;
100
+ }): Promise<ReturnType<typeof programClient.getNewClaimInstruction>>;
101
+ }