@lightprotocol/stateless.js 0.21.0 → 0.22.1-alpha.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.
Files changed (77) hide show
  1. package/README.md +10 -10
  2. package/dist/cjs/browser/actions/compress.d.ts +2 -2
  3. package/dist/cjs/browser/actions/create-account.d.ts +3 -3
  4. package/dist/cjs/browser/actions/transfer.d.ts +1 -2
  5. package/dist/cjs/browser/compressible/action.d.ts +77 -0
  6. package/dist/cjs/browser/compressible/index.d.ts +13 -0
  7. package/dist/cjs/browser/compressible/instruction.d.ts +177 -0
  8. package/dist/cjs/browser/compressible/layout.d.ts +47 -0
  9. package/dist/cjs/browser/compressible/types.d.ts +112 -0
  10. package/dist/cjs/browser/compressible/utils.d.ts +16 -0
  11. package/dist/cjs/browser/constants.d.ts +31 -6
  12. package/dist/cjs/browser/index.cjs +1 -1
  13. package/dist/cjs/browser/index.cjs.map +1 -1
  14. package/dist/cjs/browser/index.d.ts +1 -2
  15. package/dist/cjs/browser/programs/index.d.ts +0 -1
  16. package/dist/cjs/browser/{idl.d.ts → programs/system/idl.d.ts} +5 -27
  17. package/dist/cjs/browser/programs/system/index.d.ts +5 -0
  18. package/dist/cjs/{node/programs → browser/programs/system}/layout.d.ts +10 -1
  19. package/dist/cjs/browser/programs/system/pack.d.ts +143 -0
  20. package/dist/cjs/browser/programs/{system.d.ts → system/program.d.ts} +13 -28
  21. package/dist/cjs/browser/programs/system/select-compressed-accounts.d.ts +10 -0
  22. package/dist/cjs/browser/rpc-interface.d.ts +1593 -51
  23. package/dist/cjs/browser/rpc.d.ts +31 -37
  24. package/dist/cjs/browser/state/compressed-account.d.ts +140 -6
  25. package/dist/cjs/browser/state/types.d.ts +265 -26
  26. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +1 -10
  27. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +2 -2
  28. package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +20 -40
  29. package/dist/cjs/browser/utils/address.d.ts +13 -0
  30. package/dist/cjs/browser/utils/calculate-compute-unit-price.d.ts +1 -1
  31. package/dist/cjs/browser/utils/conversion.d.ts +3 -0
  32. package/dist/cjs/browser/utils/get-state-tree-infos.d.ts +16 -9
  33. package/dist/cjs/browser/utils/index.d.ts +2 -2
  34. package/dist/cjs/browser/utils/packed-accounts.d.ts +161 -0
  35. package/dist/cjs/browser/utils/send-and-confirm.d.ts +1 -1
  36. package/dist/cjs/browser/utils/validation.d.ts +2 -2
  37. package/dist/cjs/node/actions/compress.d.ts +2 -2
  38. package/dist/cjs/node/actions/create-account.d.ts +3 -3
  39. package/dist/cjs/node/actions/transfer.d.ts +1 -2
  40. package/dist/cjs/node/compressible/action.d.ts +77 -0
  41. package/dist/cjs/node/compressible/index.d.ts +13 -0
  42. package/dist/cjs/node/compressible/instruction.d.ts +177 -0
  43. package/dist/cjs/node/compressible/layout.d.ts +47 -0
  44. package/dist/cjs/node/compressible/types.d.ts +112 -0
  45. package/dist/cjs/node/compressible/utils.d.ts +16 -0
  46. package/dist/cjs/node/constants.d.ts +31 -6
  47. package/dist/cjs/node/index.cjs +1 -1
  48. package/dist/cjs/node/index.cjs.map +1 -1
  49. package/dist/cjs/node/index.d.ts +1 -2
  50. package/dist/cjs/node/programs/index.d.ts +0 -1
  51. package/dist/cjs/node/{idl.d.ts → programs/system/idl.d.ts} +5 -27
  52. package/dist/cjs/node/programs/system/index.d.ts +5 -0
  53. package/dist/cjs/{browser/programs → node/programs/system}/layout.d.ts +10 -1
  54. package/dist/cjs/node/programs/system/pack.d.ts +143 -0
  55. package/dist/cjs/node/programs/{system.d.ts → system/program.d.ts} +13 -28
  56. package/dist/cjs/node/programs/system/select-compressed-accounts.d.ts +10 -0
  57. package/dist/cjs/node/rpc-interface.d.ts +1593 -51
  58. package/dist/cjs/node/rpc.d.ts +31 -37
  59. package/dist/cjs/node/state/compressed-account.d.ts +140 -6
  60. package/dist/cjs/node/state/types.d.ts +265 -26
  61. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-accounts.d.ts +1 -10
  62. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +2 -2
  63. package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +20 -40
  64. package/dist/cjs/node/utils/address.d.ts +13 -0
  65. package/dist/cjs/node/utils/calculate-compute-unit-price.d.ts +1 -1
  66. package/dist/cjs/node/utils/conversion.d.ts +3 -0
  67. package/dist/cjs/node/utils/get-state-tree-infos.d.ts +16 -9
  68. package/dist/cjs/node/utils/index.d.ts +2 -2
  69. package/dist/cjs/node/utils/packed-accounts.d.ts +161 -0
  70. package/dist/cjs/node/utils/send-and-confirm.d.ts +1 -1
  71. package/dist/cjs/node/utils/validation.d.ts +2 -2
  72. package/dist/types/index.d.ts +3391 -864
  73. package/package.json +13 -6
  74. package/dist/cjs/browser/instruction/index.d.ts +0 -1
  75. package/dist/cjs/browser/instruction/pack-compressed-accounts.d.ts +0 -49
  76. package/dist/cjs/node/instruction/index.d.ts +0 -1
  77. package/dist/cjs/node/instruction/pack-compressed-accounts.d.ts +0 -49
@@ -1,6 +1,11 @@
1
1
  import { Connection, PublicKey } from '@solana/web3.js';
2
- import { StateTreeInfo, TreeType } from '../state/types';
2
+ import { TreeInfo, TreeType } from '../state/types';
3
3
  import { StateTreeLUTPair } from '../constants';
4
+ /**
5
+ * @deprecated use {@link getTreeInfoByPubkey} instead
6
+ */
7
+ export declare function getStateTreeInfoByPubkey(treeInfos: TreeInfo[], treeOrQueue: PublicKey): TreeInfo;
8
+ export declare function getTreeInfoByPubkey(treeInfos: TreeInfo[], treeOrQueue: PublicKey): TreeInfo;
4
9
  /**
5
10
  * @deprecated use {@link selectStateTreeInfo} instead.
6
11
  *
@@ -9,24 +14,26 @@ import { StateTreeLUTPair } from '../constants';
9
14
  * @param infos Set of state tree infos
10
15
  * @returns A random tree and queue
11
16
  */
12
- export declare function pickRandomTreeAndQueue(infos: StateTreeInfo[]): {
17
+ export declare function pickRandomTreeAndQueue(infos: TreeInfo[]): {
13
18
  tree: PublicKey;
14
19
  queue: PublicKey;
15
20
  };
16
21
  /**
17
- * Get a pseudo-random active state tree info from the set of provided state
22
+ * Select a pseudo-random active state tree info from the set of provided state
18
23
  * tree infos.
19
24
  *
20
- * Using this mitigates write lock contention on state trees.
25
+ * Using this reduces write-lock contention on state trees.
21
26
  *
22
27
  * @param infos Set of state tree infos
23
- * @param treeType The type of tree. Defaults to `TreeType.StateV1`
24
- * @param useMaxConcurrency If true, return all infos. If false, return at
25
- * most {@link MAX_HOTSPOTS}. Defaults to `false`.
28
+ *
29
+ * @param treeType Optional: Only use if you know what you are
30
+ * doing. The type of tree.
31
+ * @param useMaxConcurrency Optional: Only use if you know what you are
32
+ * doing. If true, select from all infos.
26
33
  *
27
34
  * @returns A pseudo-randomly selected tree info
28
35
  */
29
- export declare function selectStateTreeInfo(infos: StateTreeInfo[], treeType?: TreeType, useMaxConcurrency?: boolean): StateTreeInfo;
36
+ export declare function selectStateTreeInfo(infos: TreeInfo[], treeType?: TreeType, useMaxConcurrency?: boolean): TreeInfo;
30
37
  /**
31
38
  * Get active state tree infos from LUTs.
32
39
  *
@@ -38,4 +45,4 @@ export declare function selectStateTreeInfo(infos: StateTreeInfo[], treeType?: T
38
45
  export declare function getAllStateTreeInfos({ connection, stateTreeLUTPairs, }: {
39
46
  connection: Connection;
40
47
  stateTreeLUTPairs: StateTreeLUTPair[];
41
- }): Promise<StateTreeInfo[]>;
48
+ }): Promise<TreeInfo[]>;
@@ -3,11 +3,11 @@ export * from './airdrop';
3
3
  export * from './calculate-compute-unit-price';
4
4
  export * from './conversion';
5
5
  export * from './dedupe-signer';
6
- export * from './get-state-tree-infos';
7
6
  export * from './parse-validity-proof';
8
7
  export * from './pipe';
9
8
  export * from './send-and-confirm';
10
9
  export * from './sleep';
11
- export * from './state-tree-lookup-table';
12
10
  export * from './validation';
11
+ export * from './state-tree-lookup-table';
13
12
  export * from './get-state-tree-infos';
13
+ export * from './packed-accounts';
@@ -0,0 +1,161 @@
1
+ import { AccountMeta, PublicKey } from '@solana/web3.js';
2
+ /**
3
+ * This file provides two variants of packed accounts for Light Protocol:
4
+ *
5
+ * 1. PackedAccounts - Matches CpiAccounts (11 system accounts)
6
+ * - Includes: LightSystemProgram, Authority, RegisteredProgramPda, NoopProgram,
7
+ * AccountCompressionAuthority, AccountCompressionProgram, InvokingProgram,
8
+ * [Optional: SolPoolPda, DecompressionRecipient], SystemProgram, [Optional: CpiContext]
9
+ *
10
+ * 2. PackedAccountsSmall - Matches CpiAccountsSmall (9 system accounts max)
11
+ * - Includes: LightSystemProgram, Authority, RegisteredProgramPda,
12
+ * AccountCompressionAuthority, AccountCompressionProgram, SystemProgram,
13
+ * [Optional: SolPoolPda, DecompressionRecipient, CpiContext]
14
+ * - Excludes: NoopProgram and InvokingProgram for a more compact structure
15
+ */
16
+ /**
17
+ * Create a PackedAccounts instance to pack the light protocol system accounts
18
+ * for your custom program instruction. Typically, you will append them to the
19
+ * end of your instruction's accounts / remainingAccounts.
20
+ *
21
+ * This matches the full CpiAccounts structure with 11 system accounts including
22
+ * NoopProgram and InvokingProgram. For a more compact version, use PackedAccountsSmall.
23
+ *
24
+ * @example
25
+ * ```ts
26
+ * const packedAccounts = PackedAccounts.newWithSystemAccounts(config);
27
+ *
28
+ * const instruction = new TransactionInstruction({
29
+ * keys: [...yourInstructionAccounts, ...packedAccounts.toAccountMetas()],
30
+ * programId: selfProgram,
31
+ * data: data,
32
+ * });
33
+ * ```
34
+ */
35
+ export declare class PackedAccounts {
36
+ private preAccounts;
37
+ private systemAccounts;
38
+ private nextIndex;
39
+ private map;
40
+ static newWithSystemAccounts(config: SystemAccountMetaConfig): PackedAccounts;
41
+ addPreAccountsSigner(pubkey: PublicKey): void;
42
+ addPreAccountsSignerMut(pubkey: PublicKey): void;
43
+ addPreAccountsMeta(accountMeta: AccountMeta): void;
44
+ addSystemAccounts(config: SystemAccountMetaConfig): void;
45
+ insertOrGet(pubkey: PublicKey): number;
46
+ insertOrGetReadOnly(pubkey: PublicKey): number;
47
+ insertOrGetConfig(pubkey: PublicKey, isSigner: boolean, isWritable: boolean): number;
48
+ private hashSetAccountsToMetas;
49
+ private getOffsets;
50
+ toAccountMetas(): {
51
+ remainingAccounts: AccountMeta[];
52
+ systemStart: number;
53
+ packedStart: number;
54
+ };
55
+ }
56
+ /**
57
+ * Creates a PackedAccounts instance with system accounts for the specified
58
+ * program. This is a convenience wrapper around SystemAccountMetaConfig.new()
59
+ * and PackedAccounts.newWithSystemAccounts().
60
+ *
61
+ * @param programId - The program ID that will be using these system accounts
62
+ * @returns A new PackedAccounts instance with system accounts configured
63
+ *
64
+ * @example
65
+ * ```ts
66
+ * const packedAccounts = createPackedAccounts(myProgram.programId);
67
+ *
68
+ * const instruction = new TransactionInstruction({
69
+ * keys: [...yourInstructionAccounts, ...packedAccounts.toAccountMetas().remainingAccounts],
70
+ * programId: myProgram.programId,
71
+ * data: instructionData,
72
+ * });
73
+ * ```
74
+ */
75
+ export declare function createPackedAccounts(programId: PublicKey): PackedAccounts;
76
+ /**
77
+ * Creates a PackedAccounts instance with system accounts and CPI context for the specified program.
78
+ * This is a convenience wrapper that includes CPI context configuration.
79
+ *
80
+ * @param programId - The program ID that will be using these system accounts
81
+ * @param cpiContext - The CPI context account public key
82
+ * @returns A new PackedAccounts instance with system accounts and CPI context configured
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * const packedAccounts = createPackedAccountsWithCpiContext(
87
+ * myProgram.programId,
88
+ * cpiContextAccount
89
+ * );
90
+ * ```
91
+ */
92
+ export declare function createPackedAccountsWithCpiContext(programId: PublicKey, cpiContext: PublicKey): PackedAccounts;
93
+ export declare class SystemAccountMetaConfig {
94
+ selfProgram: PublicKey;
95
+ cpiContext?: PublicKey;
96
+ solCompressionRecipient?: PublicKey;
97
+ solPoolPda?: PublicKey;
98
+ private constructor();
99
+ static new(selfProgram: PublicKey): SystemAccountMetaConfig;
100
+ static newWithCpiContext(selfProgram: PublicKey, cpiContext: PublicKey): SystemAccountMetaConfig;
101
+ }
102
+ /**
103
+ * Get the light protocol system accounts for your custom program instruction.
104
+ * Use via `link PackedAccounts.addSystemAccounts(config)`.
105
+ */
106
+ export declare function getLightSystemAccountMetas(config: SystemAccountMetaConfig): AccountMeta[];
107
+ /**
108
+ * PackedAccountsSmall matches the CpiAccountsSmall structure with simplified account ordering.
109
+ * This is a more compact version that excludes NoopProgram and InvokingProgram.
110
+ */
111
+ export declare class PackedAccountsSmall {
112
+ private preAccounts;
113
+ private systemAccounts;
114
+ private nextIndex;
115
+ private map;
116
+ static newWithSystemAccounts(config: SystemAccountMetaConfig): PackedAccountsSmall;
117
+ /**
118
+ * Returns the internal map of pubkey to [index, AccountMeta].
119
+ * For debugging purposes only.
120
+ */
121
+ getNamedMetas(): Map<string, [number, AccountMeta]>;
122
+ addPreAccountsSigner(pubkey: PublicKey): void;
123
+ addPreAccountsSignerMut(pubkey: PublicKey): void;
124
+ addPreAccountsMeta(accountMeta: AccountMeta): void;
125
+ addSystemAccounts(config: SystemAccountMetaConfig): void;
126
+ insertOrGet(pubkey: PublicKey): number;
127
+ insertOrGetReadOnly(pubkey: PublicKey): number;
128
+ insertOrGetConfig(pubkey: PublicKey, isSigner: boolean, isWritable: boolean): number;
129
+ private hashSetAccountsToMetas;
130
+ private getOffsets;
131
+ toAccountMetas(): {
132
+ remainingAccounts: AccountMeta[];
133
+ systemStart: number;
134
+ packedStart: number;
135
+ };
136
+ }
137
+ /**
138
+ * Get the light protocol system accounts for the small variant.
139
+ * This matches CpiAccountsSmall ordering: removes NoopProgram and InvokingProgram.
140
+ */
141
+ export declare function getLightSystemAccountMetasSmall(config: SystemAccountMetaConfig): AccountMeta[];
142
+ /**
143
+ * Creates a PackedAccountsSmall instance with system accounts for the specified program.
144
+ * This uses the simplified account ordering that matches CpiAccountsSmall.
145
+ */
146
+ export declare function createPackedAccountsSmall(programId: PublicKey): PackedAccountsSmall;
147
+ /**
148
+ * Creates a PackedAccountsSmall instance with system accounts and CPI context.
149
+ */
150
+ export declare function createPackedAccountsSmallWithCpiContext(programId: PublicKey, cpiContext: PublicKey): PackedAccountsSmall;
151
+ export declare class SystemAccountPubkeys {
152
+ lightSystemProgram: PublicKey;
153
+ systemProgram: PublicKey;
154
+ accountCompressionProgram: PublicKey;
155
+ accountCompressionAuthority: PublicKey;
156
+ registeredProgramPda: PublicKey;
157
+ noopProgram: PublicKey;
158
+ solPoolPda: PublicKey;
159
+ private constructor();
160
+ static default(): SystemAccountPubkeys;
161
+ }
@@ -34,7 +34,7 @@ export declare function sendAndConfirmTx(rpc: Rpc, tx: VersionedTransaction, con
34
34
  * @param blockHashCtx blockhash context for confirmation
35
35
  * @return SignatureResult
36
36
  */
37
- export declare function confirmTx(rpc: Rpc, txId: string, confirmOptions?: ConfirmOptions, blockHashCtx?: {
37
+ export declare function confirmTx(rpc: Rpc, txId: string, confirmOptions?: ConfirmOptions, _blockHashCtx?: {
38
38
  blockhash: string;
39
39
  lastValidBlockHeight: number;
40
40
  }): Promise<RpcResponseAndContext<SignatureResult>>;
@@ -1,7 +1,7 @@
1
1
  import BN from 'bn.js';
2
- import { CompressedAccount, CompressedAccountWithMerkleContext } from '../state';
2
+ import { CompressedAccountLegacy, CompressedAccountWithMerkleContext } from '../state';
3
3
  export declare const validateSufficientBalance: (balance: BN) => void;
4
- export declare const validateSameOwner: (compressedAccounts: CompressedAccount[] | CompressedAccountWithMerkleContext[]) => void;
4
+ export declare const validateSameOwner: (compressedAccounts: CompressedAccountLegacy[] | CompressedAccountWithMerkleContext[]) => void;
5
5
  export declare const validateNumbersForProof: (hashesLength: number, newAddressesLength: number) => void;
6
6
  export declare const validateNumbersForInclusionProof: (hashesLength: number) => void;
7
7
  export declare const validateNumbersForNonInclusionProof: (newAddressesLength: number) => void;
@@ -1,7 +1,7 @@
1
1
  import { ConfirmOptions, PublicKey, Signer, TransactionSignature } from '@solana/web3.js';
2
2
  import { Rpc } from '../rpc';
3
3
  import BN from 'bn.js';
4
- import { StateTreeInfo } from '../state';
4
+ import { TreeInfo } from '../state';
5
5
  /**
6
6
  * Compress lamports to a solana address
7
7
  *
@@ -15,4 +15,4 @@ import { StateTreeInfo } from '../state';
15
15
  *
16
16
  * @return Transaction signature
17
17
  */
18
- export declare function compress(rpc: Rpc, payer: Signer, lamports: number | BN, toAddress: PublicKey, outputStateTreeInfo?: StateTreeInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
18
+ export declare function compress(rpc: Rpc, payer: Signer, lamports: number | BN, toAddress: PublicKey, outputStateTreeInfo?: TreeInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
@@ -1,6 +1,6 @@
1
1
  import { ConfirmOptions, PublicKey, Signer, TransactionSignature } from '@solana/web3.js';
2
2
  import { Rpc } from '../rpc';
3
- import { AddressTreeInfo, StateTreeInfo } from '../state';
3
+ import { AddressTreeInfo, TreeInfo } from '../state';
4
4
  import BN from 'bn.js';
5
5
  /**
6
6
  * Create compressed account with address
@@ -17,7 +17,7 @@ import BN from 'bn.js';
17
17
  *
18
18
  * @return Transaction signature
19
19
  */
20
- export declare function createAccount(rpc: Rpc, payer: Signer, seeds: Uint8Array[], programId: PublicKey, addressTreeInfo?: AddressTreeInfo, outputStateTreeInfo?: StateTreeInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
20
+ export declare function createAccount(rpc: Rpc, payer: Signer, seeds: Uint8Array[], programId: PublicKey, addressTreeInfo?: AddressTreeInfo, outputStateTreeInfo?: TreeInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
21
21
  /**
22
22
  * Create compressed account with address and lamports
23
23
  *
@@ -35,4 +35,4 @@ export declare function createAccount(rpc: Rpc, payer: Signer, seeds: Uint8Array
35
35
  *
36
36
  * @return Transaction signature
37
37
  */
38
- export declare function createAccountWithLamports(rpc: Rpc, payer: Signer, seeds: Uint8Array[], lamports: number | BN, programId: PublicKey, addressTreeInfo?: AddressTreeInfo, outputStateTreeInfo?: StateTreeInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
38
+ export declare function createAccountWithLamports(rpc: Rpc, payer: Signer, seeds: Uint8Array[], lamports: number | BN, programId: PublicKey, addressTreeInfo?: AddressTreeInfo, outputStateTreeInfo?: TreeInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
@@ -1,7 +1,6 @@
1
1
  import { ConfirmOptions, PublicKey, Signer, TransactionSignature } from '@solana/web3.js';
2
2
  import BN from 'bn.js';
3
3
  import { Rpc } from '../rpc';
4
- import { StateTreeInfo } from '../state';
5
4
  /**
6
5
  * Transfer compressed lamports from one owner to another
7
6
  *
@@ -14,4 +13,4 @@ import { StateTreeInfo } from '../state';
14
13
  *
15
14
  * @return Signature of the confirmed transaction
16
15
  */
17
- export declare function transfer(rpc: Rpc, payer: Signer, lamports: number | BN, owner: Signer, toAddress: PublicKey, outputStateTreeInfo?: StateTreeInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
16
+ export declare function transfer(rpc: Rpc, payer: Signer, lamports: number | BN, owner: Signer, toAddress: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
@@ -0,0 +1,77 @@
1
+ import { ConfirmOptions, PublicKey, Signer, TransactionSignature, AccountMeta } from '@solana/web3.js';
2
+ import { Rpc } from '../rpc';
3
+ import { ValidityProof } from '../state/types';
4
+ import { CompressedAccountMeta } from '../state/compressed-account';
5
+ import { CompressedAccountData } from './types';
6
+ /**
7
+ * Initialize a compression config for a compressible program
8
+ *
9
+ * @param rpc RPC connection to use
10
+ * @param payer Fee payer
11
+ * @param programId Program ID for the compressible program
12
+ * @param authority Program upgrade authority
13
+ * @param compressionDelay Compression delay (in slots)
14
+ * @param rentRecipient Rent recipient public key
15
+ * @param addressSpace Array of address space public keys
16
+ * @param configBump Optional config bump (defaults to 0)
17
+ * @param discriminator Optional custom discriminator (defaults to standard)
18
+ * @param confirmOptions Options for confirming the transaction
19
+ *
20
+ * @return Signature of the confirmed transaction
21
+ */
22
+ export declare function initializeCompressionConfig(rpc: Rpc, payer: Signer, programId: PublicKey, authority: Signer, compressionDelay: number, rentRecipient: PublicKey, addressSpace: PublicKey[], configBump?: number | null, discriminator?: Uint8Array | number[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
23
+ /**
24
+ * Update a compression config for a compressible program
25
+ *
26
+ * @param rpc RPC connection to use
27
+ * @param payer Fee payer
28
+ * @param programId Program ID for the compressible program
29
+ * @param authority Current config authority
30
+ * @param newCompressionDelay Optional new compression delay
31
+ * @param newRentRecipient Optional new rent recipient
32
+ * @param newAddressSpace Optional new address space array
33
+ * @param newUpdateAuthority Optional new update authority
34
+ * @param discriminator Optional custom discriminator (defaults to standard)
35
+ * @param confirmOptions Options for confirming the transaction
36
+ *
37
+ * @return Signature of the confirmed transaction
38
+ */
39
+ export declare function updateCompressionConfig(rpc: Rpc, payer: Signer, programId: PublicKey, authority: Signer, newCompressionDelay?: number | null, newRentRecipient?: PublicKey | null, newAddressSpace?: PublicKey[] | null, newUpdateAuthority?: PublicKey | null, discriminator?: Uint8Array | number[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
40
+ /**
41
+ * Compress a generic compressible account
42
+ *
43
+ * @param rpc RPC connection to use
44
+ * @param payer Fee payer and signer
45
+ * @param programId Program ID for the compressible program
46
+ * @param pdaToCompress PDA to compress
47
+ * @param rentRecipient Rent recipient public key
48
+ * @param compressedAccountMeta Compressed account metadata
49
+ * @param validityProof Validity proof for compression
50
+ * @param systemAccounts Additional system accounts (trees, queues, etc.)
51
+ * @param discriminator Custom instruction discriminator (8 bytes)
52
+ * @param confirmOptions Options for confirming the transaction
53
+ *
54
+ * @return Signature of the confirmed transaction
55
+ */
56
+ export declare function compressAccount(rpc: Rpc, payer: Signer, programId: PublicKey, pdaToCompress: PublicKey, rentRecipient: PublicKey, compressedAccountMeta: CompressedAccountMeta, validityProof: ValidityProof, systemAccounts: AccountMeta[], discriminator: Uint8Array | number[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
57
+ /**
58
+ * Decompress one or more compressed accounts idempotently
59
+ *
60
+ * @param rpc RPC connection to use
61
+ * @param payer Fee payer
62
+ * @param programId Program ID for the compressible program
63
+ * @param feePayer Fee payer (can be same as payer)
64
+ * @param rentPayer Rent payer
65
+ * @param solanaAccounts Array of PDA accounts to decompress
66
+ * @param compressedAccountsData Array of compressed account data
67
+ * @param bumps Array of PDA bumps
68
+ * @param validityProof Validity proof for decompression
69
+ * @param systemAccounts Additional system accounts (trees, queues, etc.)
70
+ * @param dataSchema Borsh schema for account data serialization
71
+ * @param discriminator Optional custom discriminator (defaults to standard)
72
+ * @param confirmOptions Options for confirming the transaction
73
+ *
74
+ * @return Signature of the confirmed transaction
75
+ */
76
+ export declare function decompressAccountsIdempotent<T = any>(rpc: Rpc, payer: Signer, programId: PublicKey, feePayer: Signer, rentPayer: Signer, solanaAccounts: PublicKey[], compressedAccountsData: CompressedAccountData<T>[], bumps: number[], validityProof: ValidityProof, systemAccounts: AccountMeta[], dataSchema: any, // borsh.Layout<T>
77
+ discriminator?: Uint8Array | number[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
@@ -0,0 +1,13 @@
1
+ export { COMPRESSIBLE_DISCRIMINATORS, DecompressMultipleAccountsIdempotentData, UpdateCompressionConfigData, GenericCompressAccountInstruction, } from './types';
2
+ export { UpdateCompressionConfigSchema, ValidityProofSchema, PackedStateTreeInfoSchema, CompressedAccountMetaSchema, GenericCompressAccountInstructionSchema, createCompressedAccountDataSchema, createDecompressMultipleAccountsIdempotentDataSchema, serializeInstructionData, } from './layout';
3
+ export { createInitializeCompressionConfigInstruction, createUpdateCompressionConfigInstruction, createCompressAccountInstruction, createDecompressAccountsIdempotentInstruction, CompressibleInstruction, } from './instruction';
4
+ export { initializeCompressionConfig, updateCompressionConfig, compressAccount, decompressAccountsIdempotent, } from './action';
5
+ export { deriveCompressionConfigAddress, getProgramDataAccount, checkProgramUpdateAuthority, } from './utils';
6
+ export { serializeInitializeCompressionConfigData } from './layout';
7
+ import { CompressedAccount } from '../state/compressed-account';
8
+ import { CompressedAccountData } from './types';
9
+ /**
10
+ * Convert a compressed account to the format expected by instruction builders
11
+ */
12
+ export declare function createCompressedAccountData<T>(compressedAccount: CompressedAccount, data: T, seeds: Uint8Array[], outputStateTreeIndex: number): CompressedAccountData<T>;
13
+ export { CompressibleInstruction as compressibleInstruction } from './instruction';
@@ -0,0 +1,177 @@
1
+ import { PublicKey, TransactionInstruction, AccountMeta } from '@solana/web3.js';
2
+ import { CompressedAccountData } from './types';
3
+ import { CompressedAccount } from '../state/compressed-account';
4
+ /**
5
+ * Create an instruction to initialize a compression config.
6
+ *
7
+ * @param programId Program ID for the compressible program
8
+ * @param discriminator Instruction discriminator (8 bytes)
9
+ * @param payer Fee payer
10
+ * @param authority Program upgrade authority
11
+ * @param compressionDelay Compression delay (in slots)
12
+ * @param rentRecipient Rent recipient public key
13
+ * @param addressSpace Array of address space public keys
14
+ * @param configBump Optional config bump (defaults to 0)
15
+ * @returns TransactionInstruction
16
+ */
17
+ export declare function createInitializeCompressionConfigInstruction(programId: PublicKey, discriminator: Uint8Array | number[], payer: PublicKey, authority: PublicKey, compressionDelay: number, rentRecipient: PublicKey, addressSpace: PublicKey[], configBump?: number | null): TransactionInstruction;
18
+ /**
19
+ * Create an instruction to update a compression config.
20
+ *
21
+ * @param programId Program ID for the compressible program
22
+ * @param discriminator Instruction discriminator (8 bytes)
23
+ * @param authority Current config authority
24
+ * @param newCompressionDelay Optional new compression delay
25
+ * @param newRentRecipient Optional new rent recipient
26
+ * @param newAddressSpace Optional new address space array
27
+ * @param newUpdateAuthority Optional new update authority
28
+ * @returns TransactionInstruction
29
+ */
30
+ export declare function createUpdateCompressionConfigInstruction(programId: PublicKey, discriminator: Uint8Array | number[], authority: PublicKey, newCompressionDelay?: number | null, newRentRecipient?: PublicKey | null, newAddressSpace?: PublicKey[] | null, newUpdateAuthority?: PublicKey | null): TransactionInstruction;
31
+ /**
32
+ * Create an instruction to compress a generic compressible account.
33
+ *
34
+ * @param programId Program ID for the compressible program
35
+ * @param discriminator Instruction discriminator (8 bytes)
36
+ * @param payer Fee payer
37
+ * @param pdaToCompress PDA to compress
38
+ * @param rentRecipient Rent recipient public key
39
+ * @param compressedAccountMeta Compressed account metadata
40
+ * @param validityProof Validity proof for compression
41
+ * @param systemAccounts Additional system accounts (optional)
42
+ * @returns TransactionInstruction
43
+ */
44
+ export declare function createCompressAccountInstruction(programId: PublicKey, discriminator: Uint8Array | number[], payer: PublicKey, pdaToCompress: PublicKey, rentRecipient: PublicKey, compressedAccountMeta: import('../state/compressed-account').CompressedAccountMeta, validityProof: import('../state/types').ValidityProof, systemAccounts?: AccountMeta[]): TransactionInstruction;
45
+ /**
46
+ * Create an instruction to decompress one or more compressed accounts idempotently.
47
+ *
48
+ * @param programId Program ID for the compressible program
49
+ * @param discriminator Instruction discriminator (8 bytes)
50
+ * @param feePayer Fee payer
51
+ * @param rentPayer Rent payer
52
+ * @param solanaAccounts Array of PDA accounts to decompress
53
+ * @param compressedAccountsData Array of compressed account data
54
+ * @param bumps Array of PDA bumps
55
+ * @param validityProof Validity proof for decompression
56
+ * @param systemAccounts Additional system accounts (optional)
57
+ * @param coder Borsh schema for account data
58
+ * @returns TransactionInstruction
59
+ */
60
+ export declare function createDecompressAccountsIdempotentInstruction<T = any>(programId: PublicKey, discriminator: Uint8Array | number[], feePayer: PublicKey, rentPayer: PublicKey, solanaAccounts: PublicKey[], compressedAccountsData: import('./types').CompressedAccountData<T>[], bumps: number[], validityProof: import('../state/types').ValidityProof, systemAccounts: AccountMeta[] | undefined, coder: (data: any) => Buffer): TransactionInstruction;
61
+ /**
62
+ * Instruction builders for compressible accounts, following Solana SDK patterns.
63
+ */
64
+ export declare class CompressibleInstruction {
65
+ /**
66
+ * Create an instruction to initialize a compression config.
67
+ *
68
+ * @param programId Program ID for the compressible program
69
+ * @param discriminator Instruction discriminator (8 bytes)
70
+ * @param payer Fee payer
71
+ * @param authority Program upgrade authority
72
+ * @param compressionDelay Compression delay (in slots)
73
+ * @param rentRecipient Rent recipient public key
74
+ * @param addressSpace Array of address space public keys
75
+ * @param configBump Optional config bump (defaults to 0)
76
+ * @returns TransactionInstruction
77
+ */
78
+ static initializeCompressionConfig(programId: PublicKey, discriminator: Uint8Array | number[], payer: PublicKey, authority: PublicKey, compressionDelay: number, rentRecipient: PublicKey, addressSpace: PublicKey[], configBump?: number | null): TransactionInstruction;
79
+ /**
80
+ * Create an instruction to update a compression config.
81
+ *
82
+ * @param programId Program ID for the compressible program
83
+ * @param discriminator Instruction discriminator (8 bytes)
84
+ * @param authority Current config authority
85
+ * @param newCompressionDelay Optional new compression delay
86
+ * @param newRentRecipient Optional new rent recipient
87
+ * @param newAddressSpace Optional new address space array
88
+ * @param newUpdateAuthority Optional new update authority
89
+ * @returns TransactionInstruction
90
+ */
91
+ static updateCompressionConfig(programId: PublicKey, discriminator: Uint8Array | number[], authority: PublicKey, newCompressionDelay?: number | null, newRentRecipient?: PublicKey | null, newAddressSpace?: PublicKey[] | null, newUpdateAuthority?: PublicKey | null): TransactionInstruction;
92
+ /**
93
+ * Create an instruction to compress a generic compressible account.
94
+ *
95
+ * @param programId Program ID for the compressible program
96
+ * @param discriminator Instruction discriminator (8 bytes)
97
+ * @param payer Fee payer
98
+ * @param pdaToCompress PDA to compress
99
+ * @param rentRecipient Rent recipient public key
100
+ * @param compressedAccountMeta Compressed account metadata
101
+ * @param validityProof Validity proof for compression
102
+ * @param systemAccounts Additional system accounts (optional)
103
+ * @returns TransactionInstruction
104
+ */
105
+ static compressAccount(programId: PublicKey, discriminator: Uint8Array | number[], payer: PublicKey, pdaToCompress: PublicKey, rentRecipient: PublicKey, compressedAccountMeta: import('../state/compressed-account').CompressedAccountMeta, validityProof: import('../state/types').ValidityProof, systemAccounts?: AccountMeta[]): TransactionInstruction;
106
+ /**
107
+ * Create an instruction to decompress one or more compressed accounts idempotently.
108
+ *
109
+ * @param programId Program ID for the compressible program
110
+ * @param discriminator Instruction discriminator (8 bytes)
111
+ * @param feePayer Fee payer
112
+ * @param rentPayer Rent payer
113
+ * @param solanaAccounts Array of PDA accounts to decompress
114
+ * @param compressedAccountsData Array of compressed account data
115
+ * @param bumps Array of PDA bumps
116
+ * @param validityProof Validity proof for decompression
117
+ * @param systemAccounts Additional system accounts (optional)
118
+ * @param dataSchema Borsh schema for account data
119
+ * @returns TransactionInstruction
120
+ */
121
+ static decompressAccountsIdempotent<T = any>(programId: PublicKey, discriminator: Uint8Array | number[], feePayer: PublicKey, rentPayer: PublicKey, solanaAccounts: PublicKey[], compressedAccountsData: import('./types').CompressedAccountData<T>[], bumps: number[], validityProof: import('../state/types').ValidityProof, systemAccounts?: AccountMeta[], dataSchema?: any): TransactionInstruction;
122
+ /**
123
+ * Standard instruction discriminators for compressible instructions
124
+ */
125
+ static readonly DISCRIMINATORS: {
126
+ readonly INITIALIZE_COMPRESSION_CONFIG: readonly [133, 228, 12, 169, 56, 76, 222, 61];
127
+ readonly UPDATE_COMPRESSION_CONFIG: readonly [135, 215, 243, 81, 163, 146, 33, 70];
128
+ readonly DECOMPRESS_ACCOUNTS_IDEMPOTENT: readonly [114, 67, 61, 123, 234, 31, 1, 112];
129
+ };
130
+ /**
131
+ * Derive the compression config PDA address
132
+ *
133
+ * @param programId Program ID for the compressible program
134
+ * @param configIndex Config index (defaults to 0)
135
+ * @returns [PDA address, bump seed]
136
+ */
137
+ static deriveCompressionConfigAddress(programId: PublicKey, configIndex?: number): [PublicKey, number];
138
+ /**
139
+ * Get the program data account address and its raw data for a given program
140
+ *
141
+ * @param programId Program ID
142
+ * @param connection Solana connection
143
+ * @returns Program data address and account info
144
+ */
145
+ static getProgramDataAccount(programId: PublicKey, connection: import('@solana/web3.js').Connection): Promise<{
146
+ programDataAddress: PublicKey;
147
+ programDataAccountInfo: import('@solana/web3.js').AccountInfo<Buffer>;
148
+ }>;
149
+ /**
150
+ * Check that the provided authority matches the program's upgrade authority
151
+ *
152
+ * @param programDataAccountInfo Program data account info
153
+ * @param providedAuthority Authority to validate
154
+ * @throws Error if authority doesn't match
155
+ */
156
+ static checkProgramUpdateAuthority(programDataAccountInfo: import('@solana/web3.js').AccountInfo<Buffer>, providedAuthority: PublicKey): void;
157
+ /**
158
+ * Serialize instruction data for initializeCompressionConfig using Borsh
159
+ *
160
+ * @param compressionDelay Compression delay (in slots)
161
+ * @param rentRecipient Rent recipient public key
162
+ * @param addressSpace Array of address space public keys
163
+ * @param configBump Optional config bump
164
+ * @returns Serialized instruction data with discriminator
165
+ */
166
+ static serializeInitializeCompressionConfigData(compressionDelay: number, rentRecipient: PublicKey, addressSpace: PublicKey[], configBump: number | null): Buffer;
167
+ /**
168
+ * Convert a compressed account to the format expected by instruction builders
169
+ *
170
+ * @param compressedAccount Compressed account from state
171
+ * @param data Program-specific account data
172
+ * @param seeds PDA seeds (without bump)
173
+ * @param outputStateTreeIndex Output state tree index
174
+ * @returns Compressed account data for instructions
175
+ */
176
+ static createCompressedAccountData<T>(compressedAccount: CompressedAccount, data: T, seeds: Uint8Array[], outputStateTreeIndex: number): CompressedAccountData<T>;
177
+ }
@@ -0,0 +1,47 @@
1
+ import * as borsh from '@coral-xyz/borsh';
2
+ import { ValidityProof } from '../state/types';
3
+ import { PackedStateTreeInfo, CompressedAccountMeta } from '../state/compressed-account';
4
+ import { CompressionConfigIxData, UpdateCompressionConfigData, GenericCompressAccountInstruction, CompressedAccountData, DecompressMultipleAccountsIdempotentData } from './types';
5
+ /**
6
+ * Borsh schema for initializeCompressionConfig instruction data
7
+ * Note: This is also available from '@lightprotocol/stateless.js' main exports
8
+ */
9
+ export declare const InitializeCompressionConfigSchema: borsh.Layout<CompressionConfigIxData>;
10
+ /**
11
+ * Borsh schema for updateCompressionConfig instruction data
12
+ */
13
+ export declare const UpdateCompressionConfigSchema: borsh.Layout<UpdateCompressionConfigData>;
14
+ /**
15
+ * Borsh schema for ValidityProof
16
+ */
17
+ export declare const ValidityProofSchema: borsh.Layout<ValidityProof>;
18
+ /**
19
+ * Borsh schema for PackedStateTreeInfo
20
+ */
21
+ export declare const PackedStateTreeInfoSchema: borsh.Layout<PackedStateTreeInfo>;
22
+ /**
23
+ * Borsh schema for CompressedAccountMeta
24
+ */
25
+ export declare const CompressedAccountMetaSchema: borsh.Layout<CompressedAccountMeta>;
26
+ /**
27
+ * Borsh schema for GenericCompressAccountInstruction
28
+ */
29
+ export declare const GenericCompressAccountInstructionSchema: borsh.Layout<GenericCompressAccountInstruction>;
30
+ /**
31
+ * Helper function to create borsh schema for CompressedAccountData
32
+ * This is generic to work with any data type T
33
+ */
34
+ export declare function createCompressedAccountDataSchema<T>(dataSchema: borsh.Layout<T>): borsh.Layout<CompressedAccountData<T>>;
35
+ /**
36
+ * Helper function to create borsh schema for DecompressMultipleAccountsIdempotentData
37
+ * This is generic to work with any data type T
38
+ */
39
+ export declare function createDecompressMultipleAccountsIdempotentDataSchema<T>(dataSchema: borsh.Layout<T>): borsh.Layout<DecompressMultipleAccountsIdempotentData<T>>;
40
+ /**
41
+ * Serialize instruction data with custom discriminator
42
+ */
43
+ export declare function serializeInstructionData<T>(schema: borsh.Layout<T>, data: T, discriminator: Uint8Array | number[]): Buffer;
44
+ /**
45
+ * Serialize instruction data for initializeCompressionConfig using Borsh
46
+ */
47
+ export declare function serializeInitializeCompressionConfigData(compressionDelay: number, rentRecipient: import('@solana/web3.js').PublicKey, addressSpace: import('@solana/web3.js').PublicKey[], configBump: number | null): Buffer;