@lightprotocol/stateless.js 0.20.1 → 0.20.3

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 (74) hide show
  1. package/dist/cjs/browser/actions/common.d.ts +4 -1
  2. package/dist/cjs/browser/actions/compress.d.ts +14 -2
  3. package/dist/cjs/browser/actions/create-account.d.ts +27 -3
  4. package/dist/cjs/browser/actions/decompress.d.ts +14 -2
  5. package/dist/cjs/browser/actions/transfer.d.ts +15 -2
  6. package/dist/cjs/browser/constants.d.ts +30 -15
  7. package/dist/cjs/browser/errors.d.ts +40 -49
  8. package/dist/cjs/browser/idl.d.ts +45 -45
  9. package/dist/cjs/browser/index.cjs +9611 -1
  10. package/dist/cjs/browser/index.cjs.map +1 -1
  11. package/dist/cjs/browser/index.d.ts +0 -1
  12. package/dist/cjs/browser/instruction/pack-compressed-accounts.d.ts +24 -5
  13. package/dist/cjs/browser/programs/layout.d.ts +39 -17
  14. package/dist/cjs/browser/programs/system.d.ts +61 -10
  15. package/dist/cjs/browser/rpc-interface.d.ts +1127 -871
  16. package/dist/cjs/browser/rpc.d.ts +164 -34
  17. package/dist/cjs/browser/state/BN254.d.ts +9 -2
  18. package/dist/cjs/browser/state/compressed-account.d.ts +23 -6
  19. package/dist/cjs/browser/state/types.d.ts +1 -1
  20. package/dist/cjs/browser/test-helpers/merkle-tree/indexed-array.d.ts +18 -4
  21. package/dist/cjs/browser/test-helpers/merkle-tree/merkle-tree.d.ts +19 -6
  22. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +12 -3
  23. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +21 -5
  24. package/dist/cjs/browser/test-helpers/test-rpc/get-parsed-events.d.ts +14 -4
  25. package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +135 -31
  26. package/dist/cjs/browser/test-helpers/test-utils.d.ts +5 -1
  27. package/dist/cjs/browser/utils/address.d.ts +12 -3
  28. package/dist/cjs/browser/utils/airdrop.d.ts +14 -2
  29. package/dist/cjs/browser/utils/calculate-compute-unit-price.d.ts +4 -1
  30. package/dist/cjs/browser/utils/conversion.d.ts +9 -3
  31. package/dist/cjs/browser/utils/get-light-state-tree-info.d.ts +28 -4
  32. package/dist/cjs/browser/utils/parse-validity-proof.d.ts +3 -1
  33. package/dist/cjs/browser/utils/pipe.d.ts +4 -1
  34. package/dist/cjs/browser/utils/send-and-confirm.d.ts +42 -11
  35. package/dist/cjs/browser/utils/validation.d.ts +9 -2
  36. package/dist/cjs/node/actions/common.d.ts +4 -1
  37. package/dist/cjs/node/actions/compress.d.ts +14 -2
  38. package/dist/cjs/node/actions/create-account.d.ts +27 -3
  39. package/dist/cjs/node/actions/decompress.d.ts +14 -2
  40. package/dist/cjs/node/actions/transfer.d.ts +15 -2
  41. package/dist/cjs/node/constants.d.ts +30 -15
  42. package/dist/cjs/node/errors.d.ts +40 -49
  43. package/dist/cjs/node/idl.d.ts +45 -45
  44. package/dist/cjs/node/index.cjs +8310 -1
  45. package/dist/cjs/node/index.cjs.map +1 -1
  46. package/dist/cjs/node/index.d.ts +0 -1
  47. package/dist/cjs/node/instruction/pack-compressed-accounts.d.ts +24 -5
  48. package/dist/cjs/node/programs/layout.d.ts +39 -17
  49. package/dist/cjs/node/programs/system.d.ts +61 -10
  50. package/dist/cjs/node/rpc-interface.d.ts +1127 -871
  51. package/dist/cjs/node/rpc.d.ts +164 -34
  52. package/dist/cjs/node/state/BN254.d.ts +9 -2
  53. package/dist/cjs/node/state/compressed-account.d.ts +23 -6
  54. package/dist/cjs/node/state/types.d.ts +1 -1
  55. package/dist/cjs/node/test-helpers/merkle-tree/indexed-array.d.ts +18 -4
  56. package/dist/cjs/node/test-helpers/merkle-tree/merkle-tree.d.ts +19 -6
  57. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-accounts.d.ts +12 -3
  58. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +21 -5
  59. package/dist/cjs/node/test-helpers/test-rpc/get-parsed-events.d.ts +14 -4
  60. package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +135 -31
  61. package/dist/cjs/node/test-helpers/test-utils.d.ts +5 -1
  62. package/dist/cjs/node/utils/address.d.ts +12 -3
  63. package/dist/cjs/node/utils/airdrop.d.ts +14 -2
  64. package/dist/cjs/node/utils/calculate-compute-unit-price.d.ts +4 -1
  65. package/dist/cjs/node/utils/conversion.d.ts +9 -3
  66. package/dist/cjs/node/utils/get-light-state-tree-info.d.ts +28 -4
  67. package/dist/cjs/node/utils/parse-validity-proof.d.ts +3 -1
  68. package/dist/cjs/node/utils/pipe.d.ts +4 -1
  69. package/dist/cjs/node/utils/send-and-confirm.d.ts +42 -11
  70. package/dist/cjs/node/utils/validation.d.ts +9 -2
  71. package/dist/types/index.d.ts +2115 -1139
  72. package/package.json +1 -3
  73. package/dist/cjs/browser/logger.d.ts +0 -1
  74. package/dist/cjs/node/logger.d.ts +0 -1
@@ -1,12 +1,39 @@
1
1
  import { Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
2
2
  import { Buffer } from 'buffer';
3
- import { CompressedProofWithContext, CompressedTransaction, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, HexInputsForProver, ParsedTokenAccount, SignatureWithMetadata, LatestNonVotingSignatures, LatestNonVotingSignaturesPaginated, WithContext, GetCompressedAccountsByOwnerConfig, WithCursor, AddressWithTree, HashWithTree, CompressedMintTokenHolders, TokenBalance, PaginatedOptions } from './rpc-interface';
4
- import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, CompressedProof } from './state';
3
+ import {
4
+ CompressedProofWithContext,
5
+ CompressedTransaction,
6
+ CompressionApiInterface,
7
+ GetCompressedTokenAccountsByOwnerOrDelegateOptions,
8
+ HexInputsForProver,
9
+ ParsedTokenAccount,
10
+ SignatureWithMetadata,
11
+ LatestNonVotingSignatures,
12
+ LatestNonVotingSignaturesPaginated,
13
+ WithContext,
14
+ GetCompressedAccountsByOwnerConfig,
15
+ WithCursor,
16
+ AddressWithTree,
17
+ HashWithTree,
18
+ CompressedMintTokenHolders,
19
+ TokenBalance,
20
+ PaginatedOptions,
21
+ } from './rpc-interface';
22
+ import {
23
+ MerkleContextWithMerkleProof,
24
+ BN254,
25
+ CompressedAccountWithMerkleContext,
26
+ CompressedProof,
27
+ } from './state';
5
28
  import BN from 'bn.js';
6
29
  import { LightWasm } from './test-helpers';
7
30
  import { ActiveTreeBundle } from './state/types';
8
31
  /** @internal */
9
- export declare function parseAccountData({ discriminator, data, dataHash, }: {
32
+ export declare function parseAccountData({
33
+ discriminator,
34
+ data,
35
+ dataHash,
36
+ }: {
10
37
  discriminator: BN;
11
38
  data: string;
12
39
  dataHash: BN;
@@ -25,11 +52,34 @@ export declare function parseAccountData({ discriminator, data, dataHash, }: {
25
52
  * to endpoint
26
53
  * @param connectionConfig Optional connection config
27
54
  */
28
- export declare function createRpc(endpointOrWeb3JsConnection?: string | Connection, compressionApiEndpoint?: string, proverEndpoint?: string, config?: ConnectionConfig): Rpc;
55
+ export declare function createRpc(
56
+ endpointOrWeb3JsConnection?: string | Connection,
57
+ compressionApiEndpoint?: string,
58
+ proverEndpoint?: string,
59
+ config?: ConnectionConfig,
60
+ ): Rpc;
61
+ /**
62
+ * Helper function to preprocess the response to wrap numbers as strings
63
+ * @param {string} text - The JSON string to preprocess
64
+ * @returns {string} - The preprocessed JSON string with numbers wrapped as strings
65
+ */
66
+ export declare function wrapBigNumbersAsStrings(text: string): string;
29
67
  /** @internal */
30
- export declare const rpcRequest: (rpcEndpoint: string, method: string, params?: any, convertToCamelCase?: boolean, debug?: boolean) => Promise<any>;
68
+ export declare const rpcRequest: (
69
+ rpcEndpoint: string,
70
+ method: string,
71
+ params?: any,
72
+ convertToCamelCase?: boolean,
73
+ debug?: boolean,
74
+ ) => Promise<any>;
31
75
  /** @internal */
32
- export declare const proverRequest: (proverEndpoint: string, method: "inclusion" | "new-address" | "combined", params?: any, log?: boolean, publicInputHash?: BN | undefined) => Promise<CompressedProof>;
76
+ export declare const proverRequest: (
77
+ proverEndpoint: string,
78
+ method: 'inclusion' | 'new-address' | 'combined',
79
+ params?: any,
80
+ log?: boolean,
81
+ publicInputHash?: BN | undefined,
82
+ ) => Promise<CompressedProof>;
33
83
  export type NonInclusionMerkleProofInputs = {
34
84
  root: BN;
35
85
  value: BN;
@@ -60,9 +110,18 @@ export type NonInclusionJsonStruct = {
60
110
  leafHigherRangeValue: string;
61
111
  nextIndex: number;
62
112
  };
63
- export declare function convertMerkleProofsWithContextToHex(merkleProofsWithContext: MerkleContextWithMerkleProof[]): HexInputsForProver[];
64
- export declare function convertNonInclusionMerkleProofInputsToHex(nonInclusionMerkleProofInputs: MerkleContextWithNewAddressProof[]): NonInclusionJsonStruct[];
65
- export declare function getPublicInputHash(accountProofs: MerkleContextWithMerkleProof[], accountHashes: BN254[], newAddressProofs: MerkleContextWithNewAddressProof[], lightWasm: LightWasm): BN;
113
+ export declare function convertMerkleProofsWithContextToHex(
114
+ merkleProofsWithContext: MerkleContextWithMerkleProof[],
115
+ ): HexInputsForProver[];
116
+ export declare function convertNonInclusionMerkleProofInputsToHex(
117
+ nonInclusionMerkleProofInputs: MerkleContextWithNewAddressProof[],
118
+ ): NonInclusionJsonStruct[];
119
+ export declare function getPublicInputHash(
120
+ accountProofs: MerkleContextWithMerkleProof[],
121
+ accountHashes: BN254[],
122
+ newAddressProofs: MerkleContextWithNewAddressProof[],
123
+ lightWasm: LightWasm,
124
+ ): BN;
66
125
  /**
67
126
  * Get the queue for a given tree
68
127
  *
@@ -70,7 +129,10 @@ export declare function getPublicInputHash(accountProofs: MerkleContextWithMerkl
70
129
  * @param tree - The tree to get the queue for
71
130
  * @returns The queue for the given tree, or undefined if not found
72
131
  */
73
- export declare function getQueueForTree(info: ActiveTreeBundle[], tree: PublicKey): PublicKey;
132
+ export declare function getQueueForTree(
133
+ info: ActiveTreeBundle[],
134
+ tree: PublicKey,
135
+ ): PublicKey;
74
136
  /**
75
137
  * Get the tree for a given queue
76
138
  *
@@ -78,7 +140,10 @@ export declare function getQueueForTree(info: ActiveTreeBundle[], tree: PublicKe
78
140
  * @param queue - The queue to get the tree for
79
141
  * @returns The tree for the given queue, or undefined if not found
80
142
  */
81
- export declare function getTreeForQueue(info: ActiveTreeBundle[], queue: PublicKey): PublicKey;
143
+ export declare function getTreeForQueue(
144
+ info: ActiveTreeBundle[],
145
+ queue: PublicKey,
146
+ ): PublicKey;
82
147
  /**
83
148
  * Get a random tree and queue from the active state tree addresses.
84
149
  *
@@ -98,7 +163,12 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
98
163
  compressionApiEndpoint: string;
99
164
  proverEndpoint: string;
100
165
  activeStateTreeInfo: ActiveTreeBundle[] | null;
101
- constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
166
+ constructor(
167
+ endpoint: string,
168
+ compressionApiEndpoint: string,
169
+ proverEndpoint: string,
170
+ config?: ConnectionConfig,
171
+ );
102
172
  /**
103
173
  * Manually set state tree addresses
104
174
  */
@@ -115,7 +185,10 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
115
185
  /**
116
186
  * Fetch the compressed account for the specified account address or hash
117
187
  */
118
- getCompressedAccount(address?: BN254, hash?: BN254): Promise<CompressedAccountWithMerkleContext | null>;
188
+ getCompressedAccount(
189
+ address?: BN254,
190
+ hash?: BN254,
191
+ ): Promise<CompressedAccountWithMerkleContext | null>;
119
192
  /**
120
193
  * Fetch the compressed balance for the specified account address or hash
121
194
  */
@@ -128,31 +201,46 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
128
201
  * Fetch the latest merkle proof for the specified account hash from the
129
202
  * cluster
130
203
  */
131
- getCompressedAccountProof(hash: BN254): Promise<MerkleContextWithMerkleProof>;
204
+ getCompressedAccountProof(
205
+ hash: BN254,
206
+ ): Promise<MerkleContextWithMerkleProof>;
132
207
  /**
133
208
  * Fetch all the account info for multiple compressed accounts specified by
134
209
  * an array of account hashes
135
210
  */
136
- getMultipleCompressedAccounts(hashes: BN254[]): Promise<CompressedAccountWithMerkleContext[]>;
211
+ getMultipleCompressedAccounts(
212
+ hashes: BN254[],
213
+ ): Promise<CompressedAccountWithMerkleContext[]>;
137
214
  /**
138
215
  * Fetch the latest merkle proofs for multiple compressed accounts specified
139
216
  * by an array account hashes
140
217
  */
141
- getMultipleCompressedAccountProofs(hashes: BN254[]): Promise<MerkleContextWithMerkleProof[]>;
218
+ getMultipleCompressedAccountProofs(
219
+ hashes: BN254[],
220
+ ): Promise<MerkleContextWithMerkleProof[]>;
142
221
  /**
143
222
  * Fetch all the compressed accounts owned by the specified public key.
144
223
  * Owner can be a program or user account
145
224
  */
146
- getCompressedAccountsByOwner(owner: PublicKey, config?: GetCompressedAccountsByOwnerConfig | undefined): Promise<WithCursor<CompressedAccountWithMerkleContext[]>>;
225
+ getCompressedAccountsByOwner(
226
+ owner: PublicKey,
227
+ config?: GetCompressedAccountsByOwnerConfig | undefined,
228
+ ): Promise<WithCursor<CompressedAccountWithMerkleContext[]>>;
147
229
  /**
148
230
  * Fetch all the compressed token accounts owned by the specified public
149
231
  * key. Owner can be a program or user account
150
232
  */
151
- getCompressedTokenAccountsByOwner(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<ParsedTokenAccount[]>>;
233
+ getCompressedTokenAccountsByOwner(
234
+ owner: PublicKey,
235
+ options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions,
236
+ ): Promise<WithCursor<ParsedTokenAccount[]>>;
152
237
  /**
153
238
  * Fetch all the compressed accounts delegated to the specified public key.
154
239
  */
155
- getCompressedTokenAccountsByDelegate(delegate: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<ParsedTokenAccount[]>>;
240
+ getCompressedTokenAccountsByDelegate(
241
+ delegate: PublicKey,
242
+ options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions,
243
+ ): Promise<WithCursor<ParsedTokenAccount[]>>;
156
244
  /**
157
245
  * Fetch the compressed token balance for the specified account hash
158
246
  */
@@ -165,12 +253,18 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
165
253
  * Fetch all the compressed token balances owned by the specified public
166
254
  * key. Can filter by mint. Returns without context.
167
255
  */
168
- getCompressedTokenBalancesByOwner(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<TokenBalance[]>>;
256
+ getCompressedTokenBalancesByOwner(
257
+ owner: PublicKey,
258
+ options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions,
259
+ ): Promise<WithCursor<TokenBalance[]>>;
169
260
  /**
170
261
  * Fetch the compressed token balances owned by the specified public
171
262
  * key. Paginated. Can filter by mint. Returns with context.
172
263
  */
173
- getCompressedTokenBalancesByOwnerV2(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithContext<WithCursor<TokenBalance[]>>>;
264
+ getCompressedTokenBalancesByOwnerV2(
265
+ owner: PublicKey,
266
+ options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions,
267
+ ): Promise<WithContext<WithCursor<TokenBalance[]>>>;
174
268
  /**
175
269
  * Returns confirmed compression signatures for transactions involving the specified
176
270
  * account hash forward in time from genesis to the most recent confirmed
@@ -178,19 +272,26 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
178
272
  *
179
273
  * @param hash queried account hash
180
274
  */
181
- getCompressionSignaturesForAccount(hash: BN254): Promise<SignatureWithMetadata[]>;
275
+ getCompressionSignaturesForAccount(
276
+ hash: BN254,
277
+ ): Promise<SignatureWithMetadata[]>;
182
278
  /**
183
279
  * Fetch a confirmed or finalized transaction from the cluster. Return with
184
280
  * CompressionInfo
185
281
  */
186
- getTransactionWithCompressionInfo(signature: string): Promise<CompressedTransaction | null>;
282
+ getTransactionWithCompressionInfo(
283
+ signature: string,
284
+ ): Promise<CompressedTransaction | null>;
187
285
  /**
188
286
  * Returns confirmed signatures for transactions involving the specified
189
287
  * address forward in time from genesis to the most recent confirmed block
190
288
  *
191
289
  * @param address queried compressed account address
192
290
  */
193
- getCompressionSignaturesForAddress(address: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
291
+ getCompressionSignaturesForAddress(
292
+ address: PublicKey,
293
+ options?: PaginatedOptions,
294
+ ): Promise<WithCursor<SignatureWithMetadata[]>>;
194
295
  /**
195
296
  * Returns confirmed signatures for compression transactions involving the
196
297
  * specified account owner forward in time from genesis to the
@@ -198,13 +299,19 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
198
299
  *
199
300
  * @param owner queried owner public key
200
301
  */
201
- getCompressionSignaturesForOwner(owner: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
302
+ getCompressionSignaturesForOwner(
303
+ owner: PublicKey,
304
+ options?: PaginatedOptions,
305
+ ): Promise<WithCursor<SignatureWithMetadata[]>>;
202
306
  /**
203
307
  * Returns confirmed signatures for compression transactions involving the
204
308
  * specified token account owner forward in time from genesis to the most
205
309
  * recent confirmed block
206
310
  */
207
- getCompressionSignaturesForTokenOwner(owner: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
311
+ getCompressionSignaturesForTokenOwner(
312
+ owner: PublicKey,
313
+ options?: PaginatedOptions,
314
+ ): Promise<WithCursor<SignatureWithMetadata[]>>;
208
315
  /**
209
316
  * Fetch the current indexer health status
210
317
  */
@@ -220,16 +327,25 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
220
327
  /**
221
328
  * Fetch all the compressed token holders for a given mint. Paginated.
222
329
  */
223
- getCompressedMintTokenHolders(mint: PublicKey, options?: PaginatedOptions): Promise<WithContext<WithCursor<CompressedMintTokenHolders[]>>>;
330
+ getCompressedMintTokenHolders(
331
+ mint: PublicKey,
332
+ options?: PaginatedOptions,
333
+ ): Promise<WithContext<WithCursor<CompressedMintTokenHolders[]>>>;
224
334
  /**
225
335
  * Fetch the latest compression signatures on the cluster. Results are
226
336
  * paginated.
227
337
  */
228
- getLatestCompressionSignatures(cursor?: string, limit?: number): Promise<LatestNonVotingSignaturesPaginated>;
338
+ getLatestCompressionSignatures(
339
+ cursor?: string,
340
+ limit?: number,
341
+ ): Promise<LatestNonVotingSignaturesPaginated>;
229
342
  /**
230
343
  * Fetch all non-voting signatures
231
344
  */
232
- getLatestNonVotingSignatures(limit?: number, cursor?: string): Promise<LatestNonVotingSignatures>;
345
+ getLatestNonVotingSignatures(
346
+ limit?: number,
347
+ cursor?: string,
348
+ ): Promise<LatestNonVotingSignatures>;
233
349
  /**
234
350
  * Fetch the latest address proofs for new unique addresses specified by an
235
351
  * array of addresses.
@@ -239,7 +355,9 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
239
355
  * @param addresses Array of BN254 new addresses
240
356
  * @returns Array of validity proofs for new addresses
241
357
  */
242
- getMultipleNewAddressProofs(addresses: BN254[]): Promise<MerkleContextWithNewAddressProof[]>;
358
+ getMultipleNewAddressProofs(
359
+ addresses: BN254[],
360
+ ): Promise<MerkleContextWithNewAddressProof[]>;
243
361
  /**
244
362
  * Advanced usage of getValidityProof: fetches ZKP directly from a custom
245
363
  * non-rpcprover. Note: This uses the proverEndpoint specified in the
@@ -259,7 +377,10 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
259
377
  * @param newAddresses Array of BN254 new addresses.
260
378
  * @returns validity proof with context
261
379
  */
262
- getValidityProofDirect(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
380
+ getValidityProofDirect(
381
+ hashes?: BN254[],
382
+ newAddresses?: BN254[],
383
+ ): Promise<CompressedProofWithContext>;
263
384
  /**
264
385
  * @deprecated use {@link getValidityProofV0} instead.
265
386
  *
@@ -278,7 +399,10 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
278
399
  * @param newAddresses Array of BN254 new addresses.
279
400
  * @returns validity proof with context
280
401
  */
281
- getValidityProof(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
402
+ getValidityProof(
403
+ hashes?: BN254[],
404
+ newAddresses?: BN254[],
405
+ ): Promise<CompressedProofWithContext>;
282
406
  /**
283
407
  * Fetch the latest validity proof for (1) compressed accounts specified by
284
408
  * an array of account hashes. (2) new unique addresses specified by an
@@ -293,7 +417,10 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
293
417
  * @param newAddresses Array of { address: BN254, tree: PublicKey, queue: PublicKey }.
294
418
  * @returns validity proof with context
295
419
  */
296
- getValidityProofV0(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<CompressedProofWithContext>;
420
+ getValidityProofV0(
421
+ hashes?: HashWithTree[],
422
+ newAddresses?: AddressWithTree[],
423
+ ): Promise<CompressedProofWithContext>;
297
424
  /**
298
425
  * Fetch the latest validity proof for (1) compressed accounts specified by
299
426
  * an array of account hashes. (2) new unique addresses specified by an
@@ -310,5 +437,8 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
310
437
  * state tree/queue.
311
438
  * @returns validity proof with context
312
439
  */
313
- getValidityProofAndRpcContext(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<WithContext<CompressedProofWithContext>>;
440
+ getValidityProofAndRpcContext(
441
+ hashes?: HashWithTree[],
442
+ newAddresses?: AddressWithTree[],
443
+ ): Promise<WithContext<CompressedProofWithContext>>;
314
444
  }
@@ -7,8 +7,15 @@ import { Buffer } from 'buffer';
7
7
  * are used to from working with the web3.js PublicKey type.
8
8
  */
9
9
  export type BN254 = BN;
10
- export declare const bn: (number: string | number | BN | Buffer | Uint8Array | number[], base?: number | "hex" | undefined, endian?: BN.Endianness | undefined) => BN;
10
+ export declare const bn: (
11
+ number: string | number | BN | Buffer | Uint8Array | number[],
12
+ base?: number | 'hex' | undefined,
13
+ endian?: BN.Endianness | undefined,
14
+ ) => BN;
11
15
  /** Create a bigint instance with <254-bit max size and base58 capabilities */
12
- export declare const createBN254: (number: string | number | BN | Buffer | Uint8Array | number[], base?: number | "hex" | "base58" | undefined) => BN254;
16
+ export declare const createBN254: (
17
+ number: string | number | BN | Buffer | Uint8Array | number[],
18
+ base?: number | 'hex' | 'base58' | undefined,
19
+ ) => BN254;
13
20
  /** Convert <254-bit bigint to Base58 string. */
14
21
  export declare function encodeBN254toBase58(bigintNumber: BN): string;
@@ -2,9 +2,10 @@ import BN from 'bn.js';
2
2
  import { PublicKey } from '@solana/web3.js';
3
3
  import { CompressedAccount, CompressedAccountData } from './types';
4
4
  import { BN254 } from './BN254';
5
- export type CompressedAccountWithMerkleContext = CompressedAccount & MerkleContext & {
6
- readOnly: boolean;
7
- };
5
+ export type CompressedAccountWithMerkleContext = CompressedAccount &
6
+ MerkleContext & {
7
+ readOnly: boolean;
8
+ };
8
9
  /**
9
10
  * Context for compressed account inserted into a state Merkle tree
10
11
  * */
@@ -26,6 +27,22 @@ export type MerkleContextWithMerkleProof = MerkleContext & {
26
27
  /** Current root */
27
28
  root: BN254;
28
29
  };
29
- export declare const createCompressedAccount: (owner: PublicKey, lamports?: BN, data?: CompressedAccountData, address?: number[]) => CompressedAccount;
30
- export declare const createCompressedAccountWithMerkleContext: (merkleContext: MerkleContext, owner: PublicKey, lamports?: BN, data?: CompressedAccountData, address?: number[]) => CompressedAccountWithMerkleContext;
31
- export declare const createMerkleContext: (merkleTree: PublicKey, nullifierQueue: PublicKey, hash: number[], leafIndex: number) => MerkleContext;
30
+ export declare const createCompressedAccount: (
31
+ owner: PublicKey,
32
+ lamports?: BN,
33
+ data?: CompressedAccountData,
34
+ address?: number[],
35
+ ) => CompressedAccount;
36
+ export declare const createCompressedAccountWithMerkleContext: (
37
+ merkleContext: MerkleContext,
38
+ owner: PublicKey,
39
+ lamports?: BN,
40
+ data?: CompressedAccountData,
41
+ address?: number[],
42
+ ) => CompressedAccountWithMerkleContext;
43
+ export declare const createMerkleContext: (
44
+ merkleTree: PublicKey,
45
+ nullifierQueue: PublicKey,
46
+ hash: number[],
47
+ leafIndex: number,
48
+ ) => MerkleContext;
@@ -18,7 +18,7 @@ export declare enum TreeType {
18
18
  /**
19
19
  * v2 address merkle tree
20
20
  */
21
- BatchedAddress = 3
21
+ BatchedAddress = 3,
22
22
  }
23
23
  export type ActiveTreeBundle = {
24
24
  tree: PublicKey;
@@ -13,7 +13,11 @@ export declare class IndexedElementBundle {
13
13
  newLowElement: IndexedElement;
14
14
  newElement: IndexedElement;
15
15
  newElementNextValue: BN;
16
- constructor(newLowElement: IndexedElement, newElement: IndexedElement, newElementNextValue: BN);
16
+ constructor(
17
+ newLowElement: IndexedElement,
18
+ newElement: IndexedElement,
19
+ newElementNextValue: BN,
20
+ );
17
21
  }
18
22
  /**
19
23
  * This indexed array implementation mirrors the rust implementation of the
@@ -23,7 +27,11 @@ export declare class IndexedArray {
23
27
  elements: Array<IndexedElement>;
24
28
  currentNodeIndex: number;
25
29
  highestElementIndex: number;
26
- constructor(elements: Array<IndexedElement>, currentNodeIndex: number, highestElementIndex: number);
30
+ constructor(
31
+ elements: Array<IndexedElement>,
32
+ currentNodeIndex: number,
33
+ highestElementIndex: number,
34
+ );
27
35
  static default(): IndexedArray;
28
36
  get(index: number): IndexedElement | undefined;
29
37
  length(): number;
@@ -63,7 +71,10 @@ export declare class IndexedArray {
63
71
  * @param value The value of the new element to append.
64
72
  * @returns The new element and its updated low element.
65
73
  */
66
- appendWithLowElementIndex(lowElementIndex: number, value: BN): IndexedElementBundle;
74
+ appendWithLowElementIndex(
75
+ lowElementIndex: number,
76
+ value: BN,
77
+ ): IndexedElementBundle;
67
78
  /**
68
79
  * Finds the lowest element in the array.
69
80
  * @returns The lowest element or undefined if the array is empty.
@@ -75,7 +86,10 @@ export declare class IndexedArray {
75
86
  * @param value The value for the new element.
76
87
  * @returns A bundle containing the new element, the updated low element, and the value of the next element.
77
88
  */
78
- newElementWithLowElementIndex(lowElementIndex: number, value: BN): IndexedElementBundle;
89
+ newElementWithLowElementIndex(
90
+ lowElementIndex: number,
91
+ value: BN,
92
+ ): IndexedElementBundle;
79
93
  /**
80
94
  * Creates a new element with the specified value by first finding the appropriate low element index.
81
95
  * @param value The value for the new element.
@@ -1,5 +1,5 @@
1
1
  import { LightWasm } from '../test-rpc/test-rpc';
2
- export declare const DEFAULT_ZERO = "0";
2
+ export declare const DEFAULT_ZERO = '0';
3
3
  /**
4
4
  * @callback hashFunction
5
5
  * @param left Left leaf
@@ -23,9 +23,16 @@ export declare class MerkleTree {
23
23
  _zeros: string[];
24
24
  _layers: string[][];
25
25
  _lightWasm: LightWasm;
26
- constructor(levels: number, lightWasm: LightWasm, elements?: string[], { zeroElement }?: {
27
- zeroElement?: string | undefined;
28
- });
26
+ constructor(
27
+ levels: number,
28
+ lightWasm: LightWasm,
29
+ elements?: string[],
30
+ {
31
+ zeroElement,
32
+ }?: {
33
+ zeroElement?: string | undefined;
34
+ },
35
+ );
29
36
  _rebuild(): void;
30
37
  /**
31
38
  * Get tree root
@@ -63,7 +70,10 @@ export declare class MerkleTree {
63
70
  * @param comparator A function that checks leaf value equality
64
71
  * @returns {number} Index if element is found, otherwise -1
65
72
  */
66
- indexOf(element: string, comparator?: ((element: string, el: string) => boolean) | null): number;
73
+ indexOf(
74
+ element: string,
75
+ comparator?: ((element: string, el: string) => boolean) | null,
76
+ ): number;
67
77
  /**
68
78
  * Returns a copy of non-zero tree elements
69
79
  * @returns {Object[]}
@@ -88,5 +98,8 @@ export declare class MerkleTree {
88
98
  * @param hashFunction
89
99
  * @returns {MerkleTree}
90
100
  */
91
- static deserialize(data: any, hashFunction: (left: string, right: string) => string): any;
101
+ static deserialize(
102
+ data: any,
103
+ hashFunction: (left: string, right: string) => string,
104
+ ): any;
92
105
  }
@@ -2,6 +2,15 @@ import { PublicKey } from '@solana/web3.js';
2
2
  import BN from 'bn.js';
3
3
  import { Rpc } from '../../rpc';
4
4
  import { CompressedAccountWithMerkleContext } from '../../state';
5
- export declare function getCompressedAccountsByOwnerTest(rpc: Rpc, owner: PublicKey): Promise<CompressedAccountWithMerkleContext[]>;
6
- export declare function getCompressedAccountByHashTest(rpc: Rpc, hash: BN): Promise<CompressedAccountWithMerkleContext | undefined>;
7
- export declare function getMultipleCompressedAccountsByHashTest(rpc: Rpc, hashes: BN[]): Promise<CompressedAccountWithMerkleContext[]>;
5
+ export declare function getCompressedAccountsByOwnerTest(
6
+ rpc: Rpc,
7
+ owner: PublicKey,
8
+ ): Promise<CompressedAccountWithMerkleContext[]>;
9
+ export declare function getCompressedAccountByHashTest(
10
+ rpc: Rpc,
11
+ hash: BN,
12
+ ): Promise<CompressedAccountWithMerkleContext | undefined>;
13
+ export declare function getMultipleCompressedAccountsByHashTest(
14
+ rpc: Rpc,
15
+ hashes: BN[],
16
+ ): Promise<CompressedAccountWithMerkleContext[]>;
@@ -22,7 +22,10 @@ export type EventWithParsedTokenTlvData = {
22
22
  * @param compressedAccount - The compressed account
23
23
  * @returns The parsed token data
24
24
  */
25
- export declare function parseTokenLayoutWithIdl(compressedAccount: CompressedAccount, programId?: PublicKey): TokenData | null;
25
+ export declare function parseTokenLayoutWithIdl(
26
+ compressedAccount: CompressedAccount,
27
+ programId?: PublicKey,
28
+ ): TokenData | null;
26
29
  /**
27
30
  * Retrieves all compressed token accounts for a given mint and owner.
28
31
  *
@@ -32,9 +35,22 @@ export declare function parseTokenLayoutWithIdl(compressedAccount: CompressedAcc
32
35
  * @param owner PublicKey of the token owner
33
36
  * @param mint PublicKey of the token mint
34
37
  */
35
- export declare function getCompressedTokenAccounts(events: PublicTransactionEvent[]): Promise<ParsedTokenAccount[]>;
38
+ export declare function getCompressedTokenAccounts(
39
+ events: PublicTransactionEvent[],
40
+ ): Promise<ParsedTokenAccount[]>;
36
41
  /** @internal */
37
- export declare function getCompressedTokenAccountsByOwnerTest(rpc: Rpc, owner: PublicKey, mint: PublicKey): Promise<WithCursor<ParsedTokenAccount[]>>;
38
- export declare function getCompressedTokenAccountsByDelegateTest(rpc: Rpc, delegate: PublicKey, mint: PublicKey): Promise<WithCursor<ParsedTokenAccount[]>>;
39
- export declare function getCompressedTokenAccountByHashTest(rpc: Rpc, hash: BN): Promise<ParsedTokenAccount>;
42
+ export declare function getCompressedTokenAccountsByOwnerTest(
43
+ rpc: Rpc,
44
+ owner: PublicKey,
45
+ mint: PublicKey,
46
+ ): Promise<WithCursor<ParsedTokenAccount[]>>;
47
+ export declare function getCompressedTokenAccountsByDelegateTest(
48
+ rpc: Rpc,
49
+ delegate: PublicKey,
50
+ mint: PublicKey,
51
+ ): Promise<WithCursor<ParsedTokenAccount[]>>;
52
+ export declare function getCompressedTokenAccountByHashTest(
53
+ rpc: Rpc,
54
+ hash: BN,
55
+ ): Promise<ParsedTokenAccount>;
40
56
  export {};
@@ -8,8 +8,18 @@ type Deserializer<T> = (data: Buffer, tx: ParsedTransactionWithMeta) => T;
8
8
  * Returns newest first.
9
9
  *
10
10
  * */
11
- export declare function getParsedEvents(rpc: Rpc): Promise<PublicTransactionEvent[]>;
12
- export declare const parseEvents: <T>(indexerEventsTransactions: (ParsedTransactionWithMeta | null)[], deserializeFn: Deserializer<T>) => NonNullable<T>[];
13
- export declare const parsePublicTransactionEventWithIdl: (data: Buffer) => PublicTransactionEvent | null;
14
- export declare function parseLightTransaction(dataVec: Uint8Array[], accountKeys: PublicKey[][]): PublicTransactionEvent | null | undefined;
11
+ export declare function getParsedEvents(
12
+ rpc: Rpc,
13
+ ): Promise<PublicTransactionEvent[]>;
14
+ export declare const parseEvents: <T>(
15
+ indexerEventsTransactions: (ParsedTransactionWithMeta | null)[],
16
+ deserializeFn: Deserializer<T>,
17
+ ) => NonNullable<T>[];
18
+ export declare const parsePublicTransactionEventWithIdl: (
19
+ data: Buffer,
20
+ ) => PublicTransactionEvent | null;
21
+ export declare function parseLightTransaction(
22
+ dataVec: Uint8Array[],
23
+ accountKeys: PublicKey[][],
24
+ ): PublicTransactionEvent | null | undefined;
15
25
  export {};