@lightprotocol/stateless.js 0.17.2-alpha.2 → 0.19.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.
@@ -6,7 +6,22 @@ import { CompressedAccountWithMerkleContext } from '../state/compressed-account'
6
6
  * present
7
7
  * */
8
8
  export declare function getIndexOrAdd(accountsArray: PublicKey[], key: PublicKey): number;
9
- /** @internal */
9
+ /**
10
+ * @internal
11
+ * Pads output state trees with the 0th state tree of the input state.
12
+ *
13
+ * @param outputStateMerkleTrees Optional output state trees to be
14
+ * inserted into the output state.
15
+ * Defaults to the 0th state tree of
16
+ * the input state. Gets padded to the
17
+ * length of outputCompressedAccounts.
18
+ * @param numberOfOutputCompressedAccounts The number of output compressed
19
+ * accounts.
20
+ * @param inputCompressedAccountsWithMerkleContext The input compressed accounts
21
+ * with merkle context.
22
+ *
23
+ * @returns Padded output state trees.
24
+ */
10
25
  export declare function padOutputStateMerkleTrees(outputStateMerkleTrees: PublicKey[] | PublicKey | undefined, numberOfOutputCompressedAccounts: number, inputCompressedAccountsWithMerkleContext: CompressedAccountWithMerkleContext[]): PublicKey[];
11
26
  export declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountMeta[];
12
27
  /**
@@ -14,6 +29,7 @@ export declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountM
14
29
  *
15
30
  * Replaces PublicKey with index pointer to remaining accounts.
16
31
  *
32
+ *
17
33
  * @param inputCompressedAccounts Ix input state to be consumed
18
34
  * @param inputStateRootIndices The recent state root indices of the
19
35
  * input state. The expiry is tied to
@@ -3,6 +3,8 @@ import { Buffer } from 'buffer';
3
3
  import { CompressedProofWithContext, CompressedTransaction, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, HexInputsForProver, ParsedTokenAccount, SignatureWithMetadata, LatestNonVotingSignatures, LatestNonVotingSignaturesPaginated, WithContext, GetCompressedAccountsByOwnerConfig, WithCursor, AddressWithTree, HashWithTree, CompressedMintTokenHolders, TokenBalance, PaginatedOptions } from './rpc-interface';
4
4
  import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, CompressedProof } from './state';
5
5
  import BN from 'bn.js';
6
+ import { LightWasm } from './test-helpers';
7
+ import { ActiveStateTreeAddresses } from './utils/get-light-state-tree-info';
6
8
  /** @internal */
7
9
  export declare function parseAccountData({ discriminator, data, dataHash, }: {
8
10
  discriminator: BN;
@@ -60,23 +62,57 @@ export type NonInclusionJsonStruct = {
60
62
  };
61
63
  export declare function convertMerkleProofsWithContextToHex(merkleProofsWithContext: MerkleContextWithMerkleProof[]): HexInputsForProver[];
62
64
  export declare function convertNonInclusionMerkleProofInputsToHex(nonInclusionMerkleProofInputs: MerkleContextWithNewAddressProof[]): NonInclusionJsonStruct[];
63
- import { LightWasm } from './test-helpers';
64
65
  export declare function getPublicInputHash(accountProofs: MerkleContextWithMerkleProof[], accountHashes: BN254[], newAddressProofs: MerkleContextWithNewAddressProof[], lightWasm: LightWasm): BN;
66
+ /**
67
+ * Get the queue for a given tree
68
+ *
69
+ * @param info - The active state tree addresses
70
+ * @param tree - The tree to get the queue for
71
+ * @returns The queue for the given tree, or undefined if not found
72
+ */
73
+ export declare function getQueueForTree(info: ActiveStateTreeAddresses, tree: PublicKey): PublicKey;
74
+ /**
75
+ * Get the tree for a given queue
76
+ *
77
+ * @param info - The active state tree addresses
78
+ * @param queue - The queue to get the tree for
79
+ * @returns The tree for the given queue, or undefined if not found
80
+ */
81
+ export declare function getTreeForQueue(info: ActiveStateTreeAddresses, queue: PublicKey): PublicKey;
82
+ /**
83
+ * Get a random tree and queue from the active state tree addresses.
84
+ *
85
+ * Prevents write lock contention on state trees.
86
+ *
87
+ * @param info - The active state tree addresses
88
+ * @returns A random tree and queue
89
+ */
90
+ export declare function pickRandomTreeAndQueue(info: ActiveStateTreeAddresses): {
91
+ tree: PublicKey;
92
+ queue: PublicKey;
93
+ };
65
94
  /**
66
95
  *
67
96
  */
68
97
  export declare class Rpc extends Connection implements CompressionApiInterface {
69
98
  compressionApiEndpoint: string;
70
99
  proverEndpoint: string;
100
+ activeStateTreeInfo: ActiveStateTreeAddresses | null;
101
+ fetchStateTreePromise: Promise<ActiveStateTreeAddresses> | null;
102
+ constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
71
103
  /**
72
- * Establish a Compression-compatible JSON RPC connection
73
- *
74
- * @param endpoint Endpoint to the solana cluster
75
- * @param compressionApiEndpoint Endpoint to the compression server
76
- * @param proverEndpoint Endpoint to the prover server.
77
- * @param connectionConfig Optional connection config
104
+ * Manually set state tree addresses
78
105
  */
79
- constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
106
+ setStateTreeInfo(info: ActiveStateTreeAddresses): void;
107
+ /**
108
+ * Get the active state tree addresses from the cluster.
109
+ * If not already cached, fetches from the cluster.
110
+ */
111
+ getCachedActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
112
+ /**
113
+ * Fetch the latest state tree addresses from the cluster.
114
+ */
115
+ getLatestActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
80
116
  /**
81
117
  * Fetch the compressed account for the specified account address or hash
82
118
  */
@@ -226,6 +262,10 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
226
262
  */
227
263
  getValidityProofDirect(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
228
264
  /**
265
+ * @deprecated use {@link getValidityProofV0} instead.
266
+ *
267
+ *
268
+ *
229
269
  * Fetch the latest validity proof for (1) compressed accounts specified by
230
270
  * an array of account hashes. (2) new unique addresses specified by an
231
271
  * array of addresses.
@@ -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 { ActiveStateTreeAddresses } from '../../utils/get-light-state-tree-info';
7
8
  export interface TestRpcConfig {
8
9
  /**
9
10
  * Address of the state tree to index. Default: public default test state
@@ -74,6 +75,8 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
74
75
  lightWasm: LightWasm;
75
76
  depth: number;
76
77
  log: boolean;
78
+ activeStateTreeInfo: ActiveStateTreeAddresses | null;
79
+ fetchStateTreePromise: Promise<ActiveStateTreeAddresses> | null;
77
80
  /**
78
81
  * Establish a Compression-compatible JSON RPC mock-connection
79
82
  *
@@ -87,6 +90,18 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
87
90
  * @param testRpcConfig Config for the mock rpc
88
91
  */
89
92
  constructor(endpoint: string, hasher: LightWasm, compressionApiEndpoint: string, proverEndpoint: string, connectionConfig?: ConnectionConfig, testRpcConfig?: TestRpcConfig);
93
+ /**
94
+ * Manually set state tree addresses
95
+ */
96
+ setStateTreeInfo(info: ActiveStateTreeAddresses): void;
97
+ /**
98
+ * Returns local test state trees.
99
+ */
100
+ getCachedActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
101
+ /**
102
+ * Returns local test state trees.
103
+ */
104
+ getLatestActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
90
105
  /**
91
106
  * Fetch the compressed account for the specified account hash
92
107
  */
@@ -0,0 +1,74 @@
1
+ import { Connection, Keypair, PublicKey } from '@solana/web3.js';
2
+ /**
3
+ * Create two lookup tables storing all public state tree and queue addresses
4
+ * returns lookup table addresses and txId
5
+ *
6
+ * @internal
7
+ * @param connection - Connection to the Solana network
8
+ * @param payer - Keypair of the payer
9
+ * @param authority - Keypair of the authority
10
+ * @param recentSlot - Slot of the recent block
11
+ */
12
+ export declare function createStateTreeLookupTable({ connection, payer, authority, recentSlot, }: {
13
+ connection: Connection;
14
+ payer: Keypair;
15
+ authority: Keypair;
16
+ recentSlot: number;
17
+ }): Promise<{
18
+ address: PublicKey;
19
+ txId: string;
20
+ }>;
21
+ /**
22
+ * Extend state tree lookup table with new state tree and queue addresses
23
+ * @internal
24
+ * @param connection - Connection to the Solana network
25
+ * @param tableAddress - Address of the lookup table to extend
26
+ * @param newStateTreeAddresses - Addresses of the new state trees to add
27
+ * @param newQueueAddresses - Addresses of the new queues to add
28
+ * @param payer - Keypair of the payer
29
+ * @param authority - Keypair of the authority
30
+ */
31
+ export declare function extendStateTreeLookupTable({ connection, tableAddress, newStateTreeAddresses, newQueueAddresses, payer, authority, }: {
32
+ connection: Connection;
33
+ tableAddress: PublicKey;
34
+ newStateTreeAddresses: PublicKey[];
35
+ newQueueAddresses: PublicKey[];
36
+ payer: Keypair;
37
+ authority: Keypair;
38
+ }): Promise<{
39
+ tableAddress: PublicKey;
40
+ txId: string;
41
+ }>;
42
+ /**
43
+ * Adds full state tree address to lookup table. Acts as nullifier
44
+ * @internal
45
+ * @param connection - Connection to the Solana network
46
+ * @param stateTreeAddress - Address of the state tree to nullify
47
+ * @param nullifyTableAddress - Address nullifier lookup table to store address in
48
+ * @param stateTreeLookupTableAddress - lookup table storing all state tree addresses
49
+ * @param payer - Keypair of the payer
50
+ * @param authority - Keypair of the authority
51
+ */
52
+ export declare function nullifyLookupTable({ connection, fullStateTreeAddress, nullifyTableAddress, stateTreeLookupTableAddress, payer, authority, }: {
53
+ connection: Connection;
54
+ fullStateTreeAddress: PublicKey;
55
+ nullifyTableAddress: PublicKey;
56
+ stateTreeLookupTableAddress: PublicKey;
57
+ payer: Keypair;
58
+ authority: Keypair;
59
+ }): Promise<{
60
+ txId: string;
61
+ }>;
62
+ export type ActiveStateTreeAddresses = {
63
+ activeStateTrees: PublicKey[];
64
+ activeQueues: PublicKey[];
65
+ };
66
+ /**
67
+ * Get most recent , active state tree data
68
+ * we store in lookup table for each public state tree
69
+ */
70
+ export declare function getLightStateTreeInfo({ connection, stateTreeLookupTableAddress, nullifyTableAddress, }: {
71
+ connection: Connection;
72
+ stateTreeLookupTableAddress: PublicKey;
73
+ nullifyTableAddress: PublicKey;
74
+ }): Promise<ActiveStateTreeAddresses>;
@@ -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,80 @@ 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 payer - Keypair of the payer
234
+ * @param authority - Keypair of the authority
235
+ */
236
+ declare function extendStateTreeLookupTable({ connection, tableAddress, newStateTreeAddresses, newQueueAddresses, payer, authority, }: {
237
+ connection: Connection;
238
+ tableAddress: PublicKey;
239
+ newStateTreeAddresses: PublicKey[];
240
+ newQueueAddresses: PublicKey[];
241
+ payer: Keypair;
242
+ authority: Keypair;
243
+ }): Promise<{
244
+ tableAddress: PublicKey;
245
+ txId: string;
246
+ }>;
247
+ /**
248
+ * Adds full state tree address to lookup table. Acts as nullifier
249
+ * @internal
250
+ * @param connection - Connection to the Solana network
251
+ * @param stateTreeAddress - Address of the state tree to nullify
252
+ * @param nullifyTableAddress - Address nullifier lookup table to store address in
253
+ * @param stateTreeLookupTableAddress - lookup table storing all state tree addresses
254
+ * @param payer - Keypair of the payer
255
+ * @param authority - Keypair of the authority
256
+ */
257
+ declare function nullifyLookupTable({ connection, fullStateTreeAddress, nullifyTableAddress, stateTreeLookupTableAddress, payer, authority, }: {
258
+ connection: Connection;
259
+ fullStateTreeAddress: PublicKey;
260
+ nullifyTableAddress: PublicKey;
261
+ stateTreeLookupTableAddress: PublicKey;
262
+ payer: Keypair;
263
+ authority: Keypair;
264
+ }): Promise<{
265
+ txId: string;
266
+ }>;
267
+ type ActiveStateTreeAddresses = {
268
+ activeStateTrees: PublicKey[];
269
+ activeQueues: PublicKey[];
270
+ };
271
+ /**
272
+ * Get most recent , active state tree data
273
+ * we store in lookup table for each public state tree
274
+ */
275
+ declare function getLightStateTreeInfo({ connection, stateTreeLookupTableAddress, nullifyTableAddress, }: {
276
+ connection: Connection;
277
+ stateTreeLookupTableAddress: PublicKey;
278
+ nullifyTableAddress: PublicKey;
279
+ }): Promise<ActiveStateTreeAddresses>;
280
+
237
281
  interface PackedCompressedAccountWithMerkleContext {
238
282
  compressedAccount: CompressedAccount;
239
283
  merkleContext: PackedMerkleContext;
@@ -1594,6 +1638,8 @@ declare class TestRpc extends Connection implements CompressionApiInterface {
1594
1638
  lightWasm: LightWasm;
1595
1639
  depth: number;
1596
1640
  log: boolean;
1641
+ activeStateTreeInfo: ActiveStateTreeAddresses | null;
1642
+ fetchStateTreePromise: Promise<ActiveStateTreeAddresses> | null;
1597
1643
  /**
1598
1644
  * Establish a Compression-compatible JSON RPC mock-connection
1599
1645
  *
@@ -1607,6 +1653,18 @@ declare class TestRpc extends Connection implements CompressionApiInterface {
1607
1653
  * @param testRpcConfig Config for the mock rpc
1608
1654
  */
1609
1655
  constructor(endpoint: string, hasher: LightWasm, compressionApiEndpoint: string, proverEndpoint: string, connectionConfig?: ConnectionConfig, testRpcConfig?: TestRpcConfig);
1656
+ /**
1657
+ * Manually set state tree addresses
1658
+ */
1659
+ setStateTreeInfo(info: ActiveStateTreeAddresses): void;
1660
+ /**
1661
+ * Returns local test state trees.
1662
+ */
1663
+ getCachedActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
1664
+ /**
1665
+ * Returns local test state trees.
1666
+ */
1667
+ getLatestActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
1610
1668
  /**
1611
1669
  * Fetch the compressed account for the specified account hash
1612
1670
  */
@@ -1988,6 +2046,36 @@ declare function getCompressedTokenAccountsByOwnerTest(rpc: Rpc, owner: PublicKe
1988
2046
  declare function getCompressedTokenAccountsByDelegateTest(rpc: Rpc, delegate: PublicKey, mint: PublicKey): Promise<WithCursor<ParsedTokenAccount[]>>;
1989
2047
  declare function getCompressedTokenAccountByHashTest(rpc: Rpc, hash: BN): Promise<ParsedTokenAccount>;
1990
2048
 
2049
+ declare const ALICE: Keypair;
2050
+ declare const BOB: Keypair;
2051
+ declare const CHARLIE: Keypair;
2052
+ declare const DAVE: Keypair;
2053
+ /**
2054
+ * Deep comparison of two objects. Handles BN comparison correctly.
2055
+ *
2056
+ * @param ref - The reference object to compare.
2057
+ * @param val - The value object to compare.
2058
+ * @returns True if the objects are deeply equal, false otherwise.
2059
+ */
2060
+ declare function deepEqual(ref: any, val: any): boolean;
2061
+ /**
2062
+ * Create a new account and airdrop lamports to it
2063
+ *
2064
+ * @param rpc connection to use
2065
+ * @param lamports amount of lamports to airdrop
2066
+ * @param counter counter to use for generating the keypair.
2067
+ * If undefined or >255, generates random keypair.
2068
+ */
2069
+ declare function newAccountWithLamports(rpc: Rpc, lamports?: number, counter?: number | undefined): Promise<Signer>;
2070
+ declare function getConnection(): Connection;
2071
+ /**
2072
+ * For use in tests.
2073
+ * Generate a unique keypair by passing in a counter <255. If no counter
2074
+ * is supplied, it uses and increments a global counter.
2075
+ * if counter > 255, generates random keypair
2076
+ */
2077
+ declare function getTestKeypair(counter?: number | undefined): Keypair;
2078
+
1991
2079
  /** @internal */
1992
2080
  declare function parseAccountData({ discriminator, data, dataHash, }: {
1993
2081
  discriminator: BN;
@@ -2045,23 +2133,57 @@ type NonInclusionJsonStruct = {
2045
2133
  };
2046
2134
  declare function convertMerkleProofsWithContextToHex(merkleProofsWithContext: MerkleContextWithMerkleProof[]): HexInputsForProver[];
2047
2135
  declare function convertNonInclusionMerkleProofInputsToHex(nonInclusionMerkleProofInputs: MerkleContextWithNewAddressProof[]): NonInclusionJsonStruct[];
2048
-
2049
2136
  declare function getPublicInputHash(accountProofs: MerkleContextWithMerkleProof[], accountHashes: BN254[], newAddressProofs: MerkleContextWithNewAddressProof[], lightWasm: LightWasm): BN;
2137
+ /**
2138
+ * Get the queue for a given tree
2139
+ *
2140
+ * @param info - The active state tree addresses
2141
+ * @param tree - The tree to get the queue for
2142
+ * @returns The queue for the given tree, or undefined if not found
2143
+ */
2144
+ declare function getQueueForTree(info: ActiveStateTreeAddresses, tree: PublicKey): PublicKey;
2145
+ /**
2146
+ * Get the tree for a given queue
2147
+ *
2148
+ * @param info - The active state tree addresses
2149
+ * @param queue - The queue to get the tree for
2150
+ * @returns The tree for the given queue, or undefined if not found
2151
+ */
2152
+ declare function getTreeForQueue(info: ActiveStateTreeAddresses, queue: PublicKey): PublicKey;
2153
+ /**
2154
+ * Get a random tree and queue from the active state tree addresses.
2155
+ *
2156
+ * Prevents write lock contention on state trees.
2157
+ *
2158
+ * @param info - The active state tree addresses
2159
+ * @returns A random tree and queue
2160
+ */
2161
+ declare function pickRandomTreeAndQueue(info: ActiveStateTreeAddresses): {
2162
+ tree: PublicKey;
2163
+ queue: PublicKey;
2164
+ };
2050
2165
  /**
2051
2166
  *
2052
2167
  */
2053
2168
  declare class Rpc extends Connection implements CompressionApiInterface {
2054
2169
  compressionApiEndpoint: string;
2055
2170
  proverEndpoint: string;
2171
+ activeStateTreeInfo: ActiveStateTreeAddresses | null;
2172
+ fetchStateTreePromise: Promise<ActiveStateTreeAddresses> | null;
2173
+ constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
2056
2174
  /**
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
2175
+ * Manually set state tree addresses
2063
2176
  */
2064
- constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
2177
+ setStateTreeInfo(info: ActiveStateTreeAddresses): void;
2178
+ /**
2179
+ * Get the active state tree addresses from the cluster.
2180
+ * If not already cached, fetches from the cluster.
2181
+ */
2182
+ getCachedActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
2183
+ /**
2184
+ * Fetch the latest state tree addresses from the cluster.
2185
+ */
2186
+ getLatestActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
2065
2187
  /**
2066
2188
  * Fetch the compressed account for the specified account address or hash
2067
2189
  */
@@ -2211,6 +2333,10 @@ declare class Rpc extends Connection implements CompressionApiInterface {
2211
2333
  */
2212
2334
  getValidityProofDirect(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
2213
2335
  /**
2336
+ * @deprecated use {@link getValidityProofV0} instead.
2337
+ *
2338
+ *
2339
+ *
2214
2340
  * Fetch the latest validity proof for (1) compressed accounts specified by
2215
2341
  * an array of account hashes. (2) new unique addresses specified by an
2216
2342
  * array of addresses.
@@ -2352,7 +2478,22 @@ declare function transfer(rpc: Rpc, payer: Signer, lamports: number | BN, owner:
2352
2478
  * present
2353
2479
  * */
2354
2480
  declare function getIndexOrAdd(accountsArray: PublicKey[], key: PublicKey): number;
2355
- /** @internal */
2481
+ /**
2482
+ * @internal
2483
+ * Pads output state trees with the 0th state tree of the input state.
2484
+ *
2485
+ * @param outputStateMerkleTrees Optional output state trees to be
2486
+ * inserted into the output state.
2487
+ * Defaults to the 0th state tree of
2488
+ * the input state. Gets padded to the
2489
+ * length of outputCompressedAccounts.
2490
+ * @param numberOfOutputCompressedAccounts The number of output compressed
2491
+ * accounts.
2492
+ * @param inputCompressedAccountsWithMerkleContext The input compressed accounts
2493
+ * with merkle context.
2494
+ *
2495
+ * @returns Padded output state trees.
2496
+ */
2356
2497
  declare function padOutputStateMerkleTrees(outputStateMerkleTrees: PublicKey[] | PublicKey | undefined, numberOfOutputCompressedAccounts: number, inputCompressedAccountsWithMerkleContext: CompressedAccountWithMerkleContext[]): PublicKey[];
2357
2498
  declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountMeta[];
2358
2499
  /**
@@ -2360,6 +2501,7 @@ declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountMeta[];
2360
2501
  *
2361
2502
  * Replaces PublicKey with index pointer to remaining accounts.
2362
2503
  *
2504
+ *
2363
2505
  * @param inputCompressedAccounts Ix input state to be consumed
2364
2506
  * @param inputStateRootIndices The recent state root indices of the
2365
2507
  * input state. The expiry is tied to
@@ -2613,6 +2755,21 @@ declare const defaultStaticAccountsStruct: () => {
2613
2755
  accountCompressionAuthority: PublicKey;
2614
2756
  cpiSignatureAccount: null;
2615
2757
  };
2758
+ declare const defaultStateTreeLookupTables: () => {
2759
+ mainnet: {
2760
+ stateTreeLookupTable: PublicKey;
2761
+ nullifyTable: PublicKey;
2762
+ };
2763
+ devnet: {
2764
+ stateTreeLookupTable: PublicKey;
2765
+ nullifyTable: PublicKey;
2766
+ };
2767
+ };
2768
+ declare const isLocalTest: (url: string) => boolean;
2769
+ declare const localTestActiveStateTreeInfo: () => {
2770
+ activeStateTrees: PublicKey[];
2771
+ activeQueues: PublicKey[];
2772
+ };
2616
2773
  declare const defaultTestStateTreeAccounts: () => {
2617
2774
  nullifierQueue: PublicKey;
2618
2775
  merkleTree: PublicKey;
@@ -2620,10 +2777,20 @@ declare const defaultTestStateTreeAccounts: () => {
2620
2777
  addressTree: PublicKey;
2621
2778
  addressQueue: PublicKey;
2622
2779
  };
2780
+ declare const defaultTestStateTreeAccounts2: () => {
2781
+ nullifierQueue2: PublicKey;
2782
+ merkleTree2: PublicKey;
2783
+ };
2784
+ declare const stateTreeLookupTableMainnet = "ABwZ1gQYCrj74azGZvtSk6eBQ9PD7Ch1FCcETcjr9QcC";
2785
+ declare const nullifiedStateTreeLookupTableMainnet = "9cnE7YBEUQXDf7gbapCCnRR7cERYqac6ip1g1cfdF2nb";
2786
+ declare const stateTreeLookupTableDevnet = "zpuJRGT84P9nMzTwpBihvWrRwazj8caUJTya8JAVQnv";
2787
+ declare const nullifiedStateTreeLookupTableDevnet = "3rsYNhcaosPZcMrSiQubjbE3rTLuAYJQvSe78NCruqCB";
2623
2788
  declare const nullifierQueuePubkey = "nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148";
2624
2789
  declare const merkletreePubkey = "smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT";
2625
2790
  declare const addressTree = "amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2";
2626
2791
  declare const addressQueue = "aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F";
2792
+ declare const merkleTree2Pubkey = "smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho";
2793
+ declare const nullifierQueue2Pubkey = "nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X";
2627
2794
  declare const confirmConfig: ConfirmOptions;
2628
2795
  declare const DEFAULT_MERKLE_TREE_HEIGHT = 26;
2629
2796
  declare const DEFAULT_MERKLE_TREE_ROOTS = 2800;
@@ -3745,9 +3912,13 @@ type LightSystemProgram = {
3745
3912
  {
3746
3913
  code: 6037;
3747
3914
  name: 'InvalidAddressTreeHeight';
3915
+ },
3916
+ {
3917
+ code: 6038;
3918
+ name: 'InvalidStateTreeHeight';
3748
3919
  }
3749
3920
  ];
3750
3921
  };
3751
3922
  declare const IDL: LightSystemProgram;
3752
3923
 
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 };
3924
+ export { ADDRESS_QUEUE_ROLLOVER_FEE, ADDRESS_TREE_NETWORK_FEE, ALICE, AccountProofResult, type ActiveStateTreeAddresses, 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, 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.17.2-alpha.2",
3
+ "version": "0.19.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",