@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
@@ -0,0 +1,112 @@
1
+ import { PublicKey, AccountMeta } from '@solana/web3.js';
2
+ import { ValidityProof } from '../state/types';
3
+ import { CompressedAccountMeta } from '../state/compressed-account';
4
+ /**
5
+ * Standard instruction discriminators for compressible instructions
6
+ * These match the Rust implementation discriminators
7
+ */
8
+ export declare const COMPRESSIBLE_DISCRIMINATORS: {
9
+ readonly INITIALIZE_COMPRESSION_CONFIG: readonly [133, 228, 12, 169, 56, 76, 222, 61];
10
+ readonly UPDATE_COMPRESSION_CONFIG: readonly [135, 215, 243, 81, 163, 146, 33, 70];
11
+ readonly DECOMPRESS_ACCOUNTS_IDEMPOTENT: readonly [114, 67, 61, 123, 234, 31, 1, 112];
12
+ };
13
+ /**
14
+ * Generic compressed account data structure for decompress operations
15
+ * This is generic over the account variant type, allowing programs to use their specific enums
16
+ */
17
+ export type CompressedAccountData<T = any> = {
18
+ /** The compressed account metadata containing tree info, address, and output index */
19
+ meta: CompressedAccountMeta;
20
+ /** Program-specific account variant enum */
21
+ data: T;
22
+ /** PDA seeds (without bump) used to derive the PDA address */
23
+ seeds: Uint8Array[];
24
+ };
25
+ /**
26
+ * Instruction data structure for decompress_accounts_idempotent
27
+ * This matches the exact format expected by Anchor programs
28
+ */
29
+ export type DecompressMultipleAccountsIdempotentData<T = any> = {
30
+ proof: ValidityProof;
31
+ compressedAccounts: CompressedAccountData<T>[];
32
+ bumps: number[];
33
+ systemAccountsOffset: number;
34
+ };
35
+ /**
36
+ * Instruction data for update compression config
37
+ */
38
+ export type UpdateCompressionConfigData = {
39
+ newCompressionDelay: number | null;
40
+ newRentRecipient: PublicKey | null;
41
+ newAddressSpace: PublicKey[] | null;
42
+ newUpdateAuthority: PublicKey | null;
43
+ };
44
+ /**
45
+ * Generic instruction data for compress account
46
+ * This matches the expected format for compress account instructions
47
+ */
48
+ export type GenericCompressAccountInstruction = {
49
+ proof: ValidityProof;
50
+ compressedAccountMeta: CompressedAccountMeta;
51
+ };
52
+ /**
53
+ * Existing CompressionConfigIxData type (re-exported for compatibility)
54
+ */
55
+ export type CompressionConfigIxData = {
56
+ compressionDelay: number;
57
+ rentRecipient: PublicKey;
58
+ addressSpace: PublicKey[];
59
+ configBump: number | null;
60
+ };
61
+ /**
62
+ * Common instruction builder parameters
63
+ */
64
+ export type InstructionBuilderParams = {
65
+ programId: PublicKey;
66
+ discriminator: Uint8Array | number[];
67
+ };
68
+ /**
69
+ * Initialize compression config instruction parameters
70
+ */
71
+ export type InitializeCompressionConfigParams = InstructionBuilderParams & {
72
+ payer: PublicKey;
73
+ authority: PublicKey;
74
+ compressionDelay: number;
75
+ rentRecipient: PublicKey;
76
+ addressSpace: PublicKey[];
77
+ configBump?: number | null;
78
+ };
79
+ /**
80
+ * Update compression config instruction parameters
81
+ */
82
+ export type UpdateCompressionConfigParams = InstructionBuilderParams & {
83
+ authority: PublicKey;
84
+ newCompressionDelay?: number | null;
85
+ newRentRecipient?: PublicKey | null;
86
+ newAddressSpace?: PublicKey[] | null;
87
+ newUpdateAuthority?: PublicKey | null;
88
+ };
89
+ /**
90
+ * Compress account instruction parameters
91
+ */
92
+ export type CompressAccountParams = InstructionBuilderParams & {
93
+ payer: PublicKey;
94
+ pdaToCompress: PublicKey;
95
+ rentRecipient: PublicKey;
96
+ compressedAccountMeta: CompressedAccountMeta;
97
+ validityProof: ValidityProof;
98
+ systemAccounts?: AccountMeta[];
99
+ };
100
+ /**
101
+ * Decompress accounts idempotent instruction parameters
102
+ */
103
+ export type DecompressAccountsIdempotentParams<T = any> = InstructionBuilderParams & {
104
+ feePayer: PublicKey;
105
+ rentPayer: PublicKey;
106
+ solanaAccounts: PublicKey[];
107
+ compressedAccountsData: CompressedAccountData<T>[];
108
+ bumps: number[];
109
+ validityProof: ValidityProof;
110
+ systemAccounts?: AccountMeta[];
111
+ dataSchema?: any;
112
+ };
@@ -0,0 +1,16 @@
1
+ import { Connection, PublicKey, AccountInfo } from '@solana/web3.js';
2
+ /**
3
+ * Derive the compression config PDA address
4
+ */
5
+ export declare function deriveCompressionConfigAddress(programId: PublicKey, configIndex?: number): [PublicKey, number];
6
+ /**
7
+ * Get the program data account address and its raw data for a given program.
8
+ */
9
+ export declare function getProgramDataAccount(programId: PublicKey, connection: Connection): Promise<{
10
+ programDataAddress: PublicKey;
11
+ programDataAccountInfo: AccountInfo<Buffer>;
12
+ }>;
13
+ /**
14
+ * Check that the provided authority matches the program's upgrade authority.
15
+ */
16
+ export declare function checkProgramUpdateAuthority(programDataAccountInfo: AccountInfo<Buffer>, providedAuthority: PublicKey): void;
@@ -1,15 +1,36 @@
1
1
  import BN from 'bn.js';
2
2
  import { Buffer } from 'buffer';
3
3
  import { ConfirmOptions, PublicKey } from '@solana/web3.js';
4
- import { StateTreeInfo, TreeType } from './state/types';
4
+ import { TreeInfo, TreeType } from './state/types';
5
+ export declare enum VERSION {
6
+ V1 = "V1",
7
+ V2 = "V2"
8
+ }
9
+ /**
10
+ /**
11
+ * @internal
12
+ * Feature flags. Only use if you know what you are doing.
13
+ */
14
+ export declare const featureFlags: {
15
+ version: VERSION;
16
+ isV2: () => boolean;
17
+ };
18
+ /**
19
+ * Returns the correct endpoint name for the current API version. E.g.
20
+ * versionedEndpoint('getCompressedAccount') -> 'getCompressedAccount' (V1)
21
+ * or 'getCompressedAccountV2' (V2)
22
+ */
23
+ export declare const versionedEndpoint: (base: string) => string;
5
24
  export declare const FIELD_SIZE: BN;
6
25
  export declare const HIGHEST_ADDRESS_PLUS_ONE: BN;
7
26
  export declare const COMPUTE_BUDGET_PATTERN: number[];
8
- export declare const INVOKE_DISCRIMINATOR: Buffer;
9
- export declare const INVOKE_CPI_DISCRIMINATOR: Buffer;
10
- export declare const INSERT_INTO_QUEUES_DISCRIMINATOR: Buffer;
27
+ export declare const INVOKE_DISCRIMINATOR: Buffer<ArrayBuffer>;
28
+ export declare const INVOKE_CPI_DISCRIMINATOR: Buffer<ArrayBuffer>;
29
+ export declare const INVOKE_CPI_WITH_READ_ONLY_DISCRIMINATOR: Buffer<ArrayBuffer>;
30
+ export declare const INVOKE_CPI_WITH_ACCOUNT_INFO_DISCRIMINATOR: Buffer<ArrayBuffer>;
31
+ export declare const INSERT_INTO_QUEUES_DISCRIMINATOR: Buffer<ArrayBuffer>;
11
32
  export declare const noopProgram = "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV";
12
- export declare const lightProgram = "SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7";
33
+ export declare const lightSystemProgram = "SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7";
13
34
  export declare const accountCompressionProgram = "compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq";
14
35
  export declare const getRegisteredProgramPda: () => PublicKey;
15
36
  export declare const getAccountCompressionAuthority: () => PublicKey;
@@ -39,7 +60,7 @@ export declare const isLocalTest: (url: string) => boolean;
39
60
  /**
40
61
  * @internal
41
62
  */
42
- export declare const localTestActiveStateTreeInfo: () => StateTreeInfo[];
63
+ export declare const localTestActiveStateTreeInfos: () => TreeInfo[];
43
64
  export declare const getDefaultAddressTreeInfo: () => {
44
65
  tree: PublicKey;
45
66
  queue: PublicKey;
@@ -77,9 +98,13 @@ export declare const cpiContextPubkey = "cpi1uHzrEhBG733DoEJNgHCyRS3XmmyVNZx5fon
77
98
  export declare const merkletreePubkey = "smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT";
78
99
  export declare const addressTree = "amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2";
79
100
  export declare const addressQueue = "aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F";
101
+ export declare const addressTreeV2: PublicKey;
80
102
  export declare const merkleTree2Pubkey = "smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho";
81
103
  export declare const nullifierQueue2Pubkey = "nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X";
82
104
  export declare const cpiContext2Pubkey = "cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK";
105
+ export declare const batchMerkleTree = "HLKs5NJ8FXkJg8BrzJt56adFYYuwg5etzDtBbQYTsixu";
106
+ export declare const batchQueue = "6L7SzhYB3anwEQ9cphpJ1U7Scwj57bx2xueReg7R9cKU";
107
+ export declare const batchCpiContext = "7Hp52chxaew8bW1ApR4fck2bh6Y8qA1pu3qwH6N9zaLj";
83
108
  export declare const confirmConfig: ConfirmOptions;
84
109
  export declare const DEFAULT_MERKLE_TREE_HEIGHT = 26;
85
110
  export declare const DEFAULT_MERKLE_TREE_ROOTS = 2800;