@lightprotocol/stateless.js 0.18.0 → 0.20.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.
@@ -2,6 +2,30 @@ import BN from 'bn.js';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import { Buffer } from 'buffer';
4
4
  import { NewAddressParamsPacked } from '../utils';
5
+ export declare enum TreeType {
6
+ /**
7
+ * v1 state merkle tree
8
+ */
9
+ State = 0,
10
+ /**
11
+ * v1 address merkle tree
12
+ */
13
+ Address = 1,
14
+ /**
15
+ * v2 state merkle tree
16
+ */
17
+ BatchedState = 2,
18
+ /**
19
+ * v2 address merkle tree
20
+ */
21
+ BatchedAddress = 3
22
+ }
23
+ export type ActiveTreeBundle = {
24
+ tree: PublicKey;
25
+ queue: PublicKey | null;
26
+ cpiContext: PublicKey | null;
27
+ treeType: TreeType;
28
+ };
5
29
  export interface PackedCompressedAccountWithMerkleContext {
6
30
  compressedAccount: CompressedAccount;
7
31
  merkleContext: PackedMerkleContext;
@@ -1,2 +1,3 @@
1
1
  export * from './merkle-tree';
2
2
  export * from './test-rpc';
3
+ export * from './test-utils';
@@ -4,6 +4,7 @@ import { AddressWithTree, CompressedMintTokenHolders, CompressedTransaction, Get
4
4
  import { CompressedProofWithContext, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, ParsedTokenAccount, TokenBalance } from '../../rpc-interface';
5
5
  import { BN254, CompressedAccountWithMerkleContext, MerkleContextWithMerkleProof } from '../../state';
6
6
  import { MerkleContextWithNewAddressProof } from '../../rpc';
7
+ import { ActiveTreeBundle } from '../../state/types';
7
8
  export interface TestRpcConfig {
8
9
  /**
9
10
  * Address of the state tree to index. Default: public default test state
@@ -74,6 +75,7 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
74
75
  lightWasm: LightWasm;
75
76
  depth: number;
76
77
  log: boolean;
78
+ activeStateTreeInfo: ActiveTreeBundle[] | null;
77
79
  /**
78
80
  * Establish a Compression-compatible JSON RPC mock-connection
79
81
  *
@@ -87,6 +89,18 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
87
89
  * @param testRpcConfig Config for the mock rpc
88
90
  */
89
91
  constructor(endpoint: string, hasher: LightWasm, compressionApiEndpoint: string, proverEndpoint: string, connectionConfig?: ConnectionConfig, testRpcConfig?: TestRpcConfig);
92
+ /**
93
+ * Manually set state tree addresses
94
+ */
95
+ setStateTreeInfo(info: ActiveTreeBundle[]): void;
96
+ /**
97
+ * Returns local test state trees.
98
+ */
99
+ getCachedActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
100
+ /**
101
+ * Returns local test state trees.
102
+ */
103
+ getLatestActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
90
104
  /**
91
105
  * Fetch the compressed account for the specified account hash
92
106
  */
@@ -0,0 +1,76 @@
1
+ import { Connection, Keypair, PublicKey } from '@solana/web3.js';
2
+ import { ActiveTreeBundle } from '../state/types';
3
+ /**
4
+ * Create two lookup tables storing all public state tree and queue addresses
5
+ * returns lookup table addresses and txId
6
+ *
7
+ * @internal
8
+ * @param connection - Connection to the Solana network
9
+ * @param payer - Keypair of the payer
10
+ * @param authority - Keypair of the authority
11
+ * @param recentSlot - Slot of the recent block
12
+ */
13
+ export declare function createStateTreeLookupTable({ connection, payer, authority, recentSlot, }: {
14
+ connection: Connection;
15
+ payer: Keypair;
16
+ authority: Keypair;
17
+ recentSlot: number;
18
+ }): Promise<{
19
+ address: PublicKey;
20
+ txId: string;
21
+ }>;
22
+ /**
23
+ * Extend state tree lookup table with new state tree and queue addresses
24
+ * @internal
25
+ * @param connection - Connection to the Solana network
26
+ * @param tableAddress - Address of the lookup table to extend
27
+ * @param newStateTreeAddresses - Addresses of the new state trees to add
28
+ * @param newQueueAddresses - Addresses of the new queues to add
29
+ * @param newCpiContextAddresses - Addresses of the new cpi contexts to add
30
+ * @param payer - Keypair of the payer
31
+ * @param authority - Keypair of the authority
32
+ */
33
+ export declare function extendStateTreeLookupTable({ connection, tableAddress, newStateTreeAddresses, newQueueAddresses, newCpiContextAddresses, payer, authority, }: {
34
+ connection: Connection;
35
+ tableAddress: PublicKey;
36
+ newStateTreeAddresses: PublicKey[];
37
+ newQueueAddresses: PublicKey[];
38
+ newCpiContextAddresses: PublicKey[];
39
+ payer: Keypair;
40
+ authority: Keypair;
41
+ }): Promise<{
42
+ tableAddress: PublicKey;
43
+ txId: string;
44
+ }>;
45
+ /**
46
+ * Adds state tree address to lookup table. Acts as nullifier lookup for rolled
47
+ * over state trees.
48
+ * @internal
49
+ * @param connection - Connection to the Solana network
50
+ * @param stateTreeAddress - Address of the state tree to nullify
51
+ * @param nullifyTableAddress - Address of the nullifier lookup table to store
52
+ * address in
53
+ * @param stateTreeLookupTableAddress - lookup table storing all state tree
54
+ * addresses
55
+ * @param payer - Keypair of the payer
56
+ * @param authority - Keypair of the authority
57
+ */
58
+ export declare function nullifyLookupTable({ connection, fullStateTreeAddress, nullifyTableAddress, stateTreeLookupTableAddress, payer, authority, }: {
59
+ connection: Connection;
60
+ fullStateTreeAddress: PublicKey;
61
+ nullifyTableAddress: PublicKey;
62
+ stateTreeLookupTableAddress: PublicKey;
63
+ payer: Keypair;
64
+ authority: Keypair;
65
+ }): Promise<{
66
+ txId: string;
67
+ }>;
68
+ /**
69
+ * Get most recent , active state tree data
70
+ * we store in lookup table for each public state tree
71
+ */
72
+ export declare function getLightStateTreeInfo({ connection, stateTreeLookupTableAddress, nullifyTableAddress, }: {
73
+ connection: Connection;
74
+ stateTreeLookupTableAddress: PublicKey;
75
+ nullifyTableAddress: PublicKey;
76
+ }): Promise<ActiveTreeBundle[]>;
@@ -5,6 +5,6 @@ export * from './parse-validity-proof';
5
5
  export * from './pipe';
6
6
  export * from './send-and-confirm';
7
7
  export * from './sleep';
8
- export * from './test-utils';
9
8
  export * from './validation';
10
9
  export * from './calculate-compute-unit-price';
10
+ export * from './get-light-state-tree-info';
@@ -193,36 +193,6 @@ declare function buildAndSignTx(instructions: TransactionInstruction[], payer: S
193
193
 
194
194
  declare function sleep(ms: number): Promise<void>;
195
195
 
196
- declare const ALICE: Keypair;
197
- declare const BOB: Keypair;
198
- declare const CHARLIE: Keypair;
199
- declare const DAVE: Keypair;
200
- /**
201
- * Deep comparison of two objects. Handles BN comparison correctly.
202
- *
203
- * @param ref - The reference object to compare.
204
- * @param val - The value object to compare.
205
- * @returns True if the objects are deeply equal, false otherwise.
206
- */
207
- declare function deepEqual(ref: any, val: any): boolean;
208
- /**
209
- * Create a new account and airdrop lamports to it
210
- *
211
- * @param rpc connection to use
212
- * @param lamports amount of lamports to airdrop
213
- * @param counter counter to use for generating the keypair.
214
- * If undefined or >255, generates random keypair.
215
- */
216
- declare function newAccountWithLamports(rpc: Rpc, lamports?: number, counter?: number | undefined): Promise<Signer>;
217
- declare function getConnection(): Connection;
218
- /**
219
- * For use in tests.
220
- * Generate a unique keypair by passing in a counter <255. If no counter
221
- * is supplied, it uses and increments a global counter.
222
- * if counter > 255, generates random keypair
223
- */
224
- declare function getTestKeypair(counter?: number | undefined): Keypair;
225
-
226
196
  declare const validateSufficientBalance: (balance: BN) => void;
227
197
  declare const validateSameOwner: (compressedAccounts: CompressedAccount[] | CompressedAccountWithMerkleContext[]) => void;
228
198
 
@@ -234,6 +204,105 @@ declare const validateSameOwner: (compressedAccounts: CompressedAccount[] | Comp
234
204
  */
235
205
  declare function calculateComputeUnitPrice(targetLamports: number, computeUnits: number): number;
236
206
 
207
+ /**
208
+ * Create two lookup tables storing all public state tree and queue addresses
209
+ * returns lookup table addresses and txId
210
+ *
211
+ * @internal
212
+ * @param connection - Connection to the Solana network
213
+ * @param payer - Keypair of the payer
214
+ * @param authority - Keypair of the authority
215
+ * @param recentSlot - Slot of the recent block
216
+ */
217
+ declare function createStateTreeLookupTable({ connection, payer, authority, recentSlot, }: {
218
+ connection: Connection;
219
+ payer: Keypair;
220
+ authority: Keypair;
221
+ recentSlot: number;
222
+ }): Promise<{
223
+ address: PublicKey;
224
+ txId: string;
225
+ }>;
226
+ /**
227
+ * Extend state tree lookup table with new state tree and queue addresses
228
+ * @internal
229
+ * @param connection - Connection to the Solana network
230
+ * @param tableAddress - Address of the lookup table to extend
231
+ * @param newStateTreeAddresses - Addresses of the new state trees to add
232
+ * @param newQueueAddresses - Addresses of the new queues to add
233
+ * @param newCpiContextAddresses - Addresses of the new cpi contexts to add
234
+ * @param payer - Keypair of the payer
235
+ * @param authority - Keypair of the authority
236
+ */
237
+ declare function extendStateTreeLookupTable({ connection, tableAddress, newStateTreeAddresses, newQueueAddresses, newCpiContextAddresses, payer, authority, }: {
238
+ connection: Connection;
239
+ tableAddress: PublicKey;
240
+ newStateTreeAddresses: PublicKey[];
241
+ newQueueAddresses: PublicKey[];
242
+ newCpiContextAddresses: PublicKey[];
243
+ payer: Keypair;
244
+ authority: Keypair;
245
+ }): Promise<{
246
+ tableAddress: PublicKey;
247
+ txId: string;
248
+ }>;
249
+ /**
250
+ * Adds state tree address to lookup table. Acts as nullifier lookup for rolled
251
+ * over state trees.
252
+ * @internal
253
+ * @param connection - Connection to the Solana network
254
+ * @param stateTreeAddress - Address of the state tree to nullify
255
+ * @param nullifyTableAddress - Address of the nullifier lookup table to store
256
+ * address in
257
+ * @param stateTreeLookupTableAddress - lookup table storing all state tree
258
+ * addresses
259
+ * @param payer - Keypair of the payer
260
+ * @param authority - Keypair of the authority
261
+ */
262
+ declare function nullifyLookupTable({ connection, fullStateTreeAddress, nullifyTableAddress, stateTreeLookupTableAddress, payer, authority, }: {
263
+ connection: Connection;
264
+ fullStateTreeAddress: PublicKey;
265
+ nullifyTableAddress: PublicKey;
266
+ stateTreeLookupTableAddress: PublicKey;
267
+ payer: Keypair;
268
+ authority: Keypair;
269
+ }): Promise<{
270
+ txId: string;
271
+ }>;
272
+ /**
273
+ * Get most recent , active state tree data
274
+ * we store in lookup table for each public state tree
275
+ */
276
+ declare function getLightStateTreeInfo({ connection, stateTreeLookupTableAddress, nullifyTableAddress, }: {
277
+ connection: Connection;
278
+ stateTreeLookupTableAddress: PublicKey;
279
+ nullifyTableAddress: PublicKey;
280
+ }): Promise<ActiveTreeBundle[]>;
281
+
282
+ declare enum TreeType {
283
+ /**
284
+ * v1 state merkle tree
285
+ */
286
+ State = 0,
287
+ /**
288
+ * v1 address merkle tree
289
+ */
290
+ Address = 1,
291
+ /**
292
+ * v2 state merkle tree
293
+ */
294
+ BatchedState = 2,
295
+ /**
296
+ * v2 address merkle tree
297
+ */
298
+ BatchedAddress = 3
299
+ }
300
+ type ActiveTreeBundle = {
301
+ tree: PublicKey;
302
+ queue: PublicKey | null;
303
+ cpiContext: PublicKey | null;
304
+ treeType: TreeType;
305
+ };
237
306
  interface PackedCompressedAccountWithMerkleContext {
238
307
  compressedAccount: CompressedAccount;
239
308
  merkleContext: PackedMerkleContext;
@@ -1594,6 +1663,7 @@ declare class TestRpc extends Connection implements CompressionApiInterface {
1594
1663
  lightWasm: LightWasm;
1595
1664
  depth: number;
1596
1665
  log: boolean;
1666
+ activeStateTreeInfo: ActiveTreeBundle[] | null;
1597
1667
  /**
1598
1668
  * Establish a Compression-compatible JSON RPC mock-connection
1599
1669
  *
@@ -1607,6 +1677,18 @@ declare class TestRpc extends Connection implements CompressionApiInterface {
1607
1677
  * @param testRpcConfig Config for the mock rpc
1608
1678
  */
1609
1679
  constructor(endpoint: string, hasher: LightWasm, compressionApiEndpoint: string, proverEndpoint: string, connectionConfig?: ConnectionConfig, testRpcConfig?: TestRpcConfig);
1680
+ /**
1681
+ * Manually set state tree addresses
1682
+ */
1683
+ setStateTreeInfo(info: ActiveTreeBundle[]): void;
1684
+ /**
1685
+ * Returns local test state trees.
1686
+ */
1687
+ getCachedActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
1688
+ /**
1689
+ * Returns local test state trees.
1690
+ */
1691
+ getLatestActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
1610
1692
  /**
1611
1693
  * Fetch the compressed account for the specified account hash
1612
1694
  */
@@ -1988,6 +2070,36 @@ declare function getCompressedTokenAccountsByOwnerTest(rpc: Rpc, owner: PublicKe
1988
2070
  declare function getCompressedTokenAccountsByDelegateTest(rpc: Rpc, delegate: PublicKey, mint: PublicKey): Promise<WithCursor<ParsedTokenAccount[]>>;
1989
2071
  declare function getCompressedTokenAccountByHashTest(rpc: Rpc, hash: BN): Promise<ParsedTokenAccount>;
1990
2072
 
2073
+ declare const ALICE: Keypair;
2074
+ declare const BOB: Keypair;
2075
+ declare const CHARLIE: Keypair;
2076
+ declare const DAVE: Keypair;
2077
+ /**
2078
+ * Deep comparison of two objects. Handles BN comparison correctly.
2079
+ *
2080
+ * @param ref - The reference object to compare.
2081
+ * @param val - The value object to compare.
2082
+ * @returns True if the objects are deeply equal, false otherwise.
2083
+ */
2084
+ declare function deepEqual(ref: any, val: any): boolean;
2085
+ /**
2086
+ * Create a new account and airdrop lamports to it
2087
+ *
2088
+ * @param rpc connection to use
2089
+ * @param lamports amount of lamports to airdrop
2090
+ * @param counter counter to use for generating the keypair.
2091
+ * If undefined or >255, generates random keypair.
2092
+ */
2093
+ declare function newAccountWithLamports(rpc: Rpc, lamports?: number, counter?: number | undefined): Promise<Signer>;
2094
+ declare function getConnection(): Connection;
2095
+ /**
2096
+ * For use in tests.
2097
+ * Generate a unique keypair by passing in a counter <255. If no counter
2098
+ * is supplied, it uses and increments a global counter.
2099
+ * if counter > 255, generates random keypair
2100
+ */
2101
+ declare function getTestKeypair(counter?: number | undefined): Keypair;
2102
+
1991
2103
  /** @internal */
1992
2104
  declare function parseAccountData({ discriminator, data, dataHash, }: {
1993
2105
  discriminator: BN;
@@ -2045,23 +2157,56 @@ type NonInclusionJsonStruct = {
2045
2157
  };
2046
2158
  declare function convertMerkleProofsWithContextToHex(merkleProofsWithContext: MerkleContextWithMerkleProof[]): HexInputsForProver[];
2047
2159
  declare function convertNonInclusionMerkleProofInputsToHex(nonInclusionMerkleProofInputs: MerkleContextWithNewAddressProof[]): NonInclusionJsonStruct[];
2048
-
2049
2160
  declare function getPublicInputHash(accountProofs: MerkleContextWithMerkleProof[], accountHashes: BN254[], newAddressProofs: MerkleContextWithNewAddressProof[], lightWasm: LightWasm): BN;
2161
+ /**
2162
+ * Get the queue for a given tree
2163
+ *
2164
+ * @param info - The active state tree addresses
2165
+ * @param tree - The tree to get the queue for
2166
+ * @returns The queue for the given tree, or undefined if not found
2167
+ */
2168
+ declare function getQueueForTree(info: ActiveTreeBundle[], tree: PublicKey): PublicKey;
2169
+ /**
2170
+ * Get the tree for a given queue
2171
+ *
2172
+ * @param info - The active state tree addresses
2173
+ * @param queue - The queue to get the tree for
2174
+ * @returns The tree for the given queue, or undefined if not found
2175
+ */
2176
+ declare function getTreeForQueue(info: ActiveTreeBundle[], queue: PublicKey): PublicKey;
2177
+ /**
2178
+ * Get a random tree and queue from the active state tree addresses.
2179
+ *
2180
+ * Prevents write lock contention on state trees.
2181
+ *
2182
+ * @param info - The active state tree addresses
2183
+ * @returns A random tree and queue
2184
+ */
2185
+ declare function pickRandomTreeAndQueue(info: ActiveTreeBundle[]): {
2186
+ tree: PublicKey;
2187
+ queue: PublicKey;
2188
+ };
2050
2189
  /**
2051
2190
  *
2052
2191
  */
2053
2192
  declare class Rpc extends Connection implements CompressionApiInterface {
2054
2193
  compressionApiEndpoint: string;
2055
2194
  proverEndpoint: string;
2195
+ activeStateTreeInfo: ActiveTreeBundle[] | null;
2196
+ constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
2056
2197
  /**
2057
- * Establish a Compression-compatible JSON RPC connection
2058
- *
2059
- * @param endpoint Endpoint to the solana cluster
2060
- * @param compressionApiEndpoint Endpoint to the compression server
2061
- * @param proverEndpoint Endpoint to the prover server.
2062
- * @param connectionConfig Optional connection config
2198
+ * Manually set state tree addresses
2063
2199
  */
2064
- constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
2200
+ setStateTreeInfo(info: ActiveTreeBundle[]): void;
2201
+ /**
2202
+ * Get the active state tree addresses from the cluster.
2203
+ * If not already cached, fetches from the cluster.
2204
+ */
2205
+ getCachedActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
2206
+ /**
2207
+ * Fetch the latest state tree addresses from the cluster.
2208
+ */
2209
+ getLatestActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
2065
2210
  /**
2066
2211
  * Fetch the compressed account for the specified account address or hash
2067
2212
  */
@@ -2211,6 +2356,10 @@ declare class Rpc extends Connection implements CompressionApiInterface {
2211
2356
  */
2212
2357
  getValidityProofDirect(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
2213
2358
  /**
2359
+ * @deprecated use {@link getValidityProofV0} instead.
2360
+ *
2361
+ *
2362
+ *
2214
2363
  * Fetch the latest validity proof for (1) compressed accounts specified by
2215
2364
  * an array of account hashes. (2) new unique addresses specified by an
2216
2365
  * array of addresses.
@@ -2352,7 +2501,22 @@ declare function transfer(rpc: Rpc, payer: Signer, lamports: number | BN, owner:
2352
2501
  * present
2353
2502
  * */
2354
2503
  declare function getIndexOrAdd(accountsArray: PublicKey[], key: PublicKey): number;
2355
- /** @internal */
2504
+ /**
2505
+ * @internal
2506
+ * Pads output state trees with the 0th state tree of the input state.
2507
+ *
2508
+ * @param outputStateMerkleTrees Optional output state trees to be
2509
+ * inserted into the output state.
2510
+ * Defaults to the 0th state tree of
2511
+ * the input state. Gets padded to the
2512
+ * length of outputCompressedAccounts.
2513
+ * @param numberOfOutputCompressedAccounts The number of output compressed
2514
+ * accounts.
2515
+ * @param inputCompressedAccountsWithMerkleContext The input compressed accounts
2516
+ * with merkle context.
2517
+ *
2518
+ * @returns Padded output state trees.
2519
+ */
2356
2520
  declare function padOutputStateMerkleTrees(outputStateMerkleTrees: PublicKey[] | PublicKey | undefined, numberOfOutputCompressedAccounts: number, inputCompressedAccountsWithMerkleContext: CompressedAccountWithMerkleContext[]): PublicKey[];
2357
2521
  declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountMeta[];
2358
2522
  /**
@@ -2360,6 +2524,7 @@ declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountMeta[];
2360
2524
  *
2361
2525
  * Replaces PublicKey with index pointer to remaining accounts.
2362
2526
  *
2527
+ *
2363
2528
  * @param inputCompressedAccounts Ix input state to be consumed
2364
2529
  * @param inputStateRootIndices The recent state root indices of the
2365
2530
  * input state. The expiry is tied to
@@ -2613,6 +2778,29 @@ declare const defaultStaticAccountsStruct: () => {
2613
2778
  accountCompressionAuthority: PublicKey;
2614
2779
  cpiSignatureAccount: null;
2615
2780
  };
2781
+ type StateTreeLUTPair = {
2782
+ stateTreeLookupTable: PublicKey;
2783
+ nullifyTable: PublicKey;
2784
+ };
2785
+ /**
2786
+ * Returns the Default Public State Tree LUTs for Devnet and Mainnet-Beta.
2787
+ */
2788
+ declare const defaultStateTreeLookupTables: () => {
2789
+ mainnet: StateTreeLUTPair[];
2790
+ devnet: StateTreeLUTPair[];
2791
+ };
2792
+ /**
2793
+ * @internal
2794
+ */
2795
+ declare const isLocalTest: (url: string) => boolean;
2796
+ /**
2797
+ * @internal
2798
+ */
2799
+ declare const localTestActiveStateTreeInfo: () => ActiveTreeBundle[];
2800
+ /**
2801
+ * Use only with Localnet testing.
2802
+ * For public networks, fetch via {@link defaultStateTreeLookupTables} and {@link getLightStateTreeInfo}.
2803
+ */
2616
2804
  declare const defaultTestStateTreeAccounts: () => {
2617
2805
  nullifierQueue: PublicKey;
2618
2806
  merkleTree: PublicKey;
@@ -2620,10 +2808,25 @@ declare const defaultTestStateTreeAccounts: () => {
2620
2808
  addressTree: PublicKey;
2621
2809
  addressQueue: PublicKey;
2622
2810
  };
2811
+ /**
2812
+ * @internal testing only
2813
+ */
2814
+ declare const defaultTestStateTreeAccounts2: () => {
2815
+ nullifierQueue2: PublicKey;
2816
+ merkleTree2: PublicKey;
2817
+ };
2818
+ declare const stateTreeLookupTableMainnet = "7i86eQs3GSqHjN47WdWLTCGMW6gde1q96G2EVnUyK2st";
2819
+ declare const nullifiedStateTreeLookupTableMainnet = "H9QD4u1fG7KmkAzn2tDXhheushxFe1EcrjGGyEFXeMqT";
2820
+ declare const stateTreeLookupTableDevnet = "8n8rH2bFRVA6cSGNDpgqcKHCndbFCT1bXxAQG89ejVsh";
2821
+ declare const nullifiedStateTreeLookupTableDevnet = "5dhaJLBjnVBQFErr8oiCJmcVsx3Zj6xDekGB2zULPsnP";
2623
2822
  declare const nullifierQueuePubkey = "nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148";
2823
+ declare const cpiContextPubkey = "cpi1uHzrEhBG733DoEJNgHCyRS3XmmyVNZx5fonubE4";
2624
2824
  declare const merkletreePubkey = "smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT";
2625
2825
  declare const addressTree = "amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2";
2626
2826
  declare const addressQueue = "aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F";
2827
+ declare const merkleTree2Pubkey = "smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho";
2828
+ declare const nullifierQueue2Pubkey = "nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X";
2829
+ declare const cpiContext2Pubkey = "cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK";
2627
2830
  declare const confirmConfig: ConfirmOptions;
2628
2831
  declare const DEFAULT_MERKLE_TREE_HEIGHT = 26;
2629
2832
  declare const DEFAULT_MERKLE_TREE_ROOTS = 2800;
@@ -3745,9 +3948,13 @@ type LightSystemProgram = {
3745
3948
  {
3746
3949
  code: 6037;
3747
3950
  name: 'InvalidAddressTreeHeight';
3951
+ },
3952
+ {
3953
+ code: 6038;
3954
+ name: 'InvalidStateTreeHeight';
3748
3955
  }
3749
3956
  ];
3750
3957
  };
3751
3958
  declare const IDL: LightSystemProgram;
3752
3959
 
3753
- export { ADDRESS_QUEUE_ROLLOVER_FEE, ADDRESS_TREE_NETWORK_FEE, ALICE, AccountProofResult, type AddressWithTree, type BN254, BOB, BalanceResult, CHARLIE, type ClientSubscriptionId, type CompressedAccount, type CompressedAccountData, CompressedAccountLayout, CompressedAccountResult, type CompressedAccountWithMerkleContext, CompressedAccountsByOwnerResult, type CompressedMintTokenHolders, CompressedMintTokenHoldersResult, type CompressedProof, type CompressedProofWithContext, CompressedTokenAccountResult, CompressedTokenAccountsByOwnerOrDelegateResult, type CompressedTransaction, CompressedTransactionResult, type CompressionApiInterface, CreateUtxoError, CreateUtxoErrorCode, DAVE, DEFAULT_MERKLE_TREE_HEIGHT, DEFAULT_MERKLE_TREE_ROOTS, DEFAULT_ZERO, type EventWithParsedTokenTlvData, FIELD_SIZE, type GetCompressedAccountConfig, type GetCompressedAccountsByOwnerConfig, type GetCompressedAccountsConfig, type GetCompressedAccountsFilter, type GetCompressedTokenAccountsByOwnerOrDelegateOptions, HIGHEST_ADDRESS_PLUS_ONE, HashError, HashErrorCode, type HashWithTree, HealthResult, type HexBatchInputsForProver, type HexInputsForProver, IDL, INVOKE_DISCRIMINATOR, IndexedArray, IndexedElement, IndexedElementBundle, type InputTokenDataWithContext, type InstructionDataInvoke, InstructionDataInvokeLayout, type LatestNonVotingSignatures, type LatestNonVotingSignaturesPaginated, LatestNonVotingSignaturesResult, LatestNonVotingSignaturesResultPaginated, LightSystemProgram$1 as LightSystemProgram, type LightSystemProgram as LightSystemProgramIDL, type LightWasm, LookupTableError, LookupTableErrorCode, MerkeProofResult, type MerkleContext, MerkleContextLayout, type MerkleContextWithMerkleProof, type MerkleContextWithNewAddressProof, MerkleTree, MerkleTreeError, MerkleTreeErrorCode, type MerkleTreeSequenceNumber, MultipleCompressedAccountsResult, MultipleMerkleProofsResult, NativeBalanceResult, type NewAddressParams, NewAddressParamsLayout, type NewAddressParamsPacked, NewAddressProofResult, type NonInclusionJsonStruct, type NonInclusionMerkleProofInputs, type OutputCompressedAccountWithPackedContext, type PackedCompressedAccountWithMerkleContext, type PackedMerkleContext, type PaginatedOptions, type ParsedTokenAccount, ProofError, ProofErrorCode, type PublicTransactionEvent, PublicTransactionEventLayout, type QueueIndex, Rpc, RpcError, RpcErrorCode, type RpcResult, type RpcResultError, type RpcResultSuccess, STATE_MERKLE_TREE_NETWORK_FEE, STATE_MERKLE_TREE_ROLLOVER_FEE, SelectInUtxosError, SelectInUtxosErrorCode, SignatureListResult, SignatureListWithCursorResult, type SignatureWithMetadata, SlotResult, TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD, TestRpc, type TestRpcConfig, type TokenBalance, TokenBalanceListResult, TokenBalanceListResultV2, TokenBalanceResult, type TokenData$1 as TokenData, TokenDataLayout, TokenDataResult, UTXO_MERGE_MAXIMUM, UTXO_MERGE_THRESHOLD, UtilsError, UtilsErrorCode, UtxoError, UtxoErrorCode, ValidityProofResult, type WithContext, type WithCursor, type WithRpcContext, accountCompressionProgram, addressQueue, addressTree, airdropSol, bn, bufToDecStr, buildAndSignTx, buildTx, byteArrayToKeypair, calculateComputeUnitPrice, checkValidityProofShape, compress, confirmConfig, confirmTransaction, confirmTx, convertMerkleProofsWithContextToHex, convertNonInclusionMerkleProofInputsToHex, createAccount, createAccountWithLamports, createBN254, createCompressedAccount, createCompressedAccountWithMerkleContext, createMerkleContext, createRpc, createRpcResult, decodeInstructionDataInvoke, decodePublicTransactionEvent, decompress, dedupeSigner, deepEqual, defaultStaticAccounts, defaultStaticAccountsStruct, defaultTestStateTreeAccounts, deriveAddress, deriveAddressSeed, encodeBN254toBase58, encodeInstructionDataInvoke, encodePublicTransactionEvent, getAccountCompressionAuthority, getCompressedTokenAccountByHashTest, getCompressedTokenAccounts, getCompressedTokenAccountsByDelegateTest, getCompressedTokenAccountsByOwnerTest, getConnection, getIndexOrAdd, getParsedEvents, getPublicInputHash, getRegisteredProgramPda, getTestKeypair, getTestRpc, hashToBn254FieldSizeBe, hashvToBn254FieldSizeBe, invokeAccountsLayout, type invokeAccountsLayoutParams, jsonRpcResult, jsonRpcResultAndContext, lightProgram, merkletreePubkey, negateAndCompressProof, newAccountWithLamports, noopProgram, nullifierQueuePubkey, packCompressedAccounts, packNewAddressParams, padOutputStateMerkleTrees, parseAccountData, parseEvents, parsePublicTransactionEventWithIdl, parseTokenLayoutWithIdl, pipe, placeholderValidityProof, proofFromJsonStruct, proverRequest, pushUniqueItems, rpcRequest, selectMinCompressedSolAccountsForTransfer, sendAndConfirmTx, sleep, sumUpLamports, toAccountMetas, toArray, toCamelCase, toHex, toUnixTimestamp, transfer, validateSameOwner, validateSufficientBalance };
3960
+ export { ADDRESS_QUEUE_ROLLOVER_FEE, ADDRESS_TREE_NETWORK_FEE, ALICE, AccountProofResult, type ActiveTreeBundle, type AddressWithTree, type BN254, BOB, BalanceResult, CHARLIE, type ClientSubscriptionId, type CompressedAccount, type CompressedAccountData, CompressedAccountLayout, CompressedAccountResult, type CompressedAccountWithMerkleContext, CompressedAccountsByOwnerResult, type CompressedMintTokenHolders, CompressedMintTokenHoldersResult, type CompressedProof, type CompressedProofWithContext, CompressedTokenAccountResult, CompressedTokenAccountsByOwnerOrDelegateResult, type CompressedTransaction, CompressedTransactionResult, type CompressionApiInterface, CreateUtxoError, CreateUtxoErrorCode, DAVE, DEFAULT_MERKLE_TREE_HEIGHT, DEFAULT_MERKLE_TREE_ROOTS, DEFAULT_ZERO, type EventWithParsedTokenTlvData, FIELD_SIZE, type GetCompressedAccountConfig, type GetCompressedAccountsByOwnerConfig, type GetCompressedAccountsConfig, type GetCompressedAccountsFilter, type GetCompressedTokenAccountsByOwnerOrDelegateOptions, HIGHEST_ADDRESS_PLUS_ONE, HashError, HashErrorCode, type HashWithTree, HealthResult, type HexBatchInputsForProver, type HexInputsForProver, IDL, INVOKE_DISCRIMINATOR, IndexedArray, IndexedElement, IndexedElementBundle, type InputTokenDataWithContext, type InstructionDataInvoke, InstructionDataInvokeLayout, type LatestNonVotingSignatures, type LatestNonVotingSignaturesPaginated, LatestNonVotingSignaturesResult, LatestNonVotingSignaturesResultPaginated, LightSystemProgram$1 as LightSystemProgram, type LightSystemProgram as LightSystemProgramIDL, type LightWasm, LookupTableError, LookupTableErrorCode, MerkeProofResult, type MerkleContext, MerkleContextLayout, type MerkleContextWithMerkleProof, type MerkleContextWithNewAddressProof, MerkleTree, MerkleTreeError, MerkleTreeErrorCode, type MerkleTreeSequenceNumber, MultipleCompressedAccountsResult, MultipleMerkleProofsResult, NativeBalanceResult, type NewAddressParams, NewAddressParamsLayout, type NewAddressParamsPacked, NewAddressProofResult, type NonInclusionJsonStruct, type NonInclusionMerkleProofInputs, type OutputCompressedAccountWithPackedContext, type PackedCompressedAccountWithMerkleContext, type PackedMerkleContext, type PaginatedOptions, type ParsedTokenAccount, ProofError, ProofErrorCode, type PublicTransactionEvent, PublicTransactionEventLayout, type QueueIndex, Rpc, RpcError, RpcErrorCode, type RpcResult, type RpcResultError, type RpcResultSuccess, STATE_MERKLE_TREE_NETWORK_FEE, STATE_MERKLE_TREE_ROLLOVER_FEE, SelectInUtxosError, SelectInUtxosErrorCode, SignatureListResult, SignatureListWithCursorResult, type SignatureWithMetadata, SlotResult, type StateTreeLUTPair, TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD, TestRpc, type TestRpcConfig, type TokenBalance, TokenBalanceListResult, TokenBalanceListResultV2, TokenBalanceResult, type TokenData$1 as TokenData, TokenDataLayout, TokenDataResult, TreeType, UTXO_MERGE_MAXIMUM, UTXO_MERGE_THRESHOLD, UtilsError, UtilsErrorCode, UtxoError, UtxoErrorCode, ValidityProofResult, type WithContext, type WithCursor, type WithRpcContext, accountCompressionProgram, addressQueue, addressTree, airdropSol, bn, bufToDecStr, buildAndSignTx, buildTx, byteArrayToKeypair, calculateComputeUnitPrice, checkValidityProofShape, compress, confirmConfig, confirmTransaction, confirmTx, convertMerkleProofsWithContextToHex, convertNonInclusionMerkleProofInputsToHex, cpiContext2Pubkey, cpiContextPubkey, createAccount, createAccountWithLamports, createBN254, createCompressedAccount, createCompressedAccountWithMerkleContext, createMerkleContext, createRpc, createRpcResult, createStateTreeLookupTable, decodeInstructionDataInvoke, decodePublicTransactionEvent, decompress, dedupeSigner, deepEqual, defaultStateTreeLookupTables, defaultStaticAccounts, defaultStaticAccountsStruct, defaultTestStateTreeAccounts, defaultTestStateTreeAccounts2, deriveAddress, deriveAddressSeed, encodeBN254toBase58, encodeInstructionDataInvoke, encodePublicTransactionEvent, extendStateTreeLookupTable, getAccountCompressionAuthority, getCompressedTokenAccountByHashTest, getCompressedTokenAccounts, getCompressedTokenAccountsByDelegateTest, getCompressedTokenAccountsByOwnerTest, getConnection, getIndexOrAdd, getLightStateTreeInfo, getParsedEvents, getPublicInputHash, getQueueForTree, getRegisteredProgramPda, getTestKeypair, getTestRpc, getTreeForQueue, hashToBn254FieldSizeBe, hashvToBn254FieldSizeBe, invokeAccountsLayout, type invokeAccountsLayoutParams, isLocalTest, jsonRpcResult, jsonRpcResultAndContext, lightProgram, localTestActiveStateTreeInfo, merkleTree2Pubkey, merkletreePubkey, negateAndCompressProof, newAccountWithLamports, noopProgram, nullifiedStateTreeLookupTableDevnet, nullifiedStateTreeLookupTableMainnet, nullifierQueue2Pubkey, nullifierQueuePubkey, nullifyLookupTable, packCompressedAccounts, packNewAddressParams, padOutputStateMerkleTrees, parseAccountData, parseEvents, parsePublicTransactionEventWithIdl, parseTokenLayoutWithIdl, pickRandomTreeAndQueue, pipe, placeholderValidityProof, proofFromJsonStruct, proverRequest, pushUniqueItems, rpcRequest, selectMinCompressedSolAccountsForTransfer, sendAndConfirmTx, sleep, stateTreeLookupTableDevnet, stateTreeLookupTableMainnet, sumUpLamports, toAccountMetas, toArray, toCamelCase, toHex, toUnixTimestamp, transfer, validateSameOwner, validateSufficientBalance };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightprotocol/stateless.js",
3
- "version": "0.18.0",
3
+ "version": "0.20.0",
4
4
  "description": "JavaScript API for Light & ZK Compression",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/node/index.cjs",
@@ -102,8 +102,9 @@
102
102
  "test:e2e:compress": "pnpm test-validator && vitest run tests/e2e/compress.test.ts --reporter=verbose",
103
103
  "test:e2e:test-rpc": "pnpm test-validator && vitest run tests/e2e/test-rpc.test.ts",
104
104
  "test:e2e:rpc-interop": "pnpm test-validator && vitest run tests/e2e/rpc-interop.test.ts",
105
+ "test:e2e:rpc-multi-trees": "pnpm test-validator && vitest run tests/e2e/rpc-multi-trees.test.ts",
105
106
  "test:e2e:browser": "pnpm playwright test",
106
- "test:e2e:all": "pnpm test-validator && vitest run tests/e2e/test-rpc.test.ts && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/rpc-interop.test.ts",
107
+ "test:e2e:all": "pnpm test-validator && vitest run tests/e2e/test-rpc.test.ts && vitest run tests/e2e/compress.test.ts && vitest run tests/e2e/transfer.test.ts && vitest run tests/e2e/rpc-interop.test.ts && vitest run tests/e2e/rpc-multi-trees.test.ts && vitest run tests/e2e/layout.test.ts",
107
108
  "test:index": "vitest run tests/e2e/program.test.ts",
108
109
  "test:e2e:layout": "vitest run tests/e2e/layout.test.ts --reporter=verbose",
109
110
  "test:verbose": "vitest run --reporter=verbose",