@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;