@lightprotocol/stateless.js 0.20.9 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/cjs/browser/actions/compress.d.ts +9 -7
  2. package/dist/cjs/browser/actions/create-account.d.ts +25 -28
  3. package/dist/cjs/browser/actions/decompress.d.ts +6 -7
  4. package/dist/cjs/browser/actions/index.d.ts +1 -1
  5. package/dist/cjs/browser/actions/transfer.d.ts +7 -11
  6. package/dist/cjs/browser/constants.d.ts +40 -7
  7. package/dist/cjs/browser/index.cjs +1 -1
  8. package/dist/cjs/browser/index.cjs.map +1 -1
  9. package/dist/cjs/browser/index.d.ts +1 -3
  10. package/dist/cjs/browser/programs/index.d.ts +0 -1
  11. package/dist/cjs/{node → browser/programs/system}/idl.d.ts +5 -27
  12. package/dist/cjs/browser/programs/system/index.d.ts +5 -0
  13. package/dist/cjs/browser/programs/{layout.d.ts → system/layout.d.ts} +37 -1
  14. package/dist/cjs/browser/programs/system/pack.d.ts +74 -0
  15. package/dist/cjs/browser/programs/{system.d.ts → system/program.d.ts} +25 -49
  16. package/dist/cjs/browser/programs/system/select-compressed-accounts.d.ts +10 -0
  17. package/dist/cjs/browser/rpc-interface.d.ts +1689 -82
  18. package/dist/cjs/browser/rpc.d.ts +27 -67
  19. package/dist/cjs/browser/state/BN254.d.ts +0 -1
  20. package/dist/cjs/browser/state/bn.d.ts +3 -0
  21. package/dist/cjs/browser/state/compressed-account.d.ts +189 -15
  22. package/dist/cjs/browser/state/index.d.ts +1 -0
  23. package/dist/cjs/browser/state/types.d.ts +345 -31
  24. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +3 -3
  25. package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +21 -49
  26. package/dist/cjs/browser/utils/calculate-compute-unit-price.d.ts +1 -1
  27. package/dist/cjs/browser/utils/conversion.d.ts +2 -0
  28. package/dist/cjs/browser/utils/get-state-tree-infos.d.ts +48 -0
  29. package/dist/cjs/browser/utils/index.d.ts +4 -2
  30. package/dist/cjs/browser/utils/parse-validity-proof.d.ts +3 -3
  31. package/dist/cjs/browser/utils/send-and-confirm.d.ts +1 -1
  32. package/dist/cjs/browser/utils/state-tree-lookup-table.d.ts +68 -0
  33. package/dist/cjs/browser/utils/validation.d.ts +2 -2
  34. package/dist/cjs/node/actions/compress.d.ts +9 -7
  35. package/dist/cjs/node/actions/create-account.d.ts +25 -28
  36. package/dist/cjs/node/actions/decompress.d.ts +6 -7
  37. package/dist/cjs/node/actions/index.d.ts +1 -1
  38. package/dist/cjs/node/actions/transfer.d.ts +7 -11
  39. package/dist/cjs/node/constants.d.ts +40 -7
  40. package/dist/cjs/node/index.cjs +1 -1
  41. package/dist/cjs/node/index.cjs.map +1 -1
  42. package/dist/cjs/node/index.d.ts +1 -3
  43. package/dist/cjs/node/programs/index.d.ts +0 -1
  44. package/dist/cjs/{browser → node/programs/system}/idl.d.ts +5 -27
  45. package/dist/cjs/node/programs/system/index.d.ts +5 -0
  46. package/dist/cjs/node/programs/{layout.d.ts → system/layout.d.ts} +37 -1
  47. package/dist/cjs/node/programs/system/pack.d.ts +74 -0
  48. package/dist/cjs/node/programs/{system.d.ts → system/program.d.ts} +25 -49
  49. package/dist/cjs/node/programs/system/select-compressed-accounts.d.ts +10 -0
  50. package/dist/cjs/node/rpc-interface.d.ts +1689 -82
  51. package/dist/cjs/node/rpc.d.ts +27 -67
  52. package/dist/cjs/node/state/BN254.d.ts +0 -1
  53. package/dist/cjs/node/state/bn.d.ts +3 -0
  54. package/dist/cjs/node/state/compressed-account.d.ts +189 -15
  55. package/dist/cjs/node/state/index.d.ts +1 -0
  56. package/dist/cjs/node/state/types.d.ts +345 -31
  57. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +3 -3
  58. package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +21 -49
  59. package/dist/cjs/node/utils/calculate-compute-unit-price.d.ts +1 -1
  60. package/dist/cjs/node/utils/conversion.d.ts +2 -0
  61. package/dist/cjs/node/utils/get-state-tree-infos.d.ts +48 -0
  62. package/dist/cjs/node/utils/index.d.ts +4 -2
  63. package/dist/cjs/node/utils/parse-validity-proof.d.ts +3 -3
  64. package/dist/cjs/node/utils/send-and-confirm.d.ts +1 -1
  65. package/dist/cjs/node/utils/state-tree-lookup-table.d.ts +68 -0
  66. package/dist/cjs/node/utils/validation.d.ts +2 -2
  67. package/dist/types/index.d.ts +3177 -1063
  68. package/package.json +16 -8
  69. package/dist/cjs/browser/instruction/index.d.ts +0 -1
  70. package/dist/cjs/browser/instruction/pack-compressed-accounts.d.ts +0 -51
  71. package/dist/cjs/browser/utils/get-light-state-tree-info.d.ts +0 -76
  72. package/dist/cjs/node/instruction/index.d.ts +0 -1
  73. package/dist/cjs/node/instruction/pack-compressed-accounts.d.ts +0 -51
  74. package/dist/cjs/node/utils/get-light-state-tree-info.d.ts +0 -76
  75. /package/dist/cjs/browser/{actions/common.d.ts → utils/dedupe-signer.d.ts} +0 -0
  76. /package/dist/cjs/node/{actions/common.d.ts → utils/dedupe-signer.d.ts} +0 -0
@@ -2,134 +2,448 @@ 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
+ import { PackedCompressedAccountWithMerkleContext } from './compressed-account';
5
6
  export declare enum TreeType {
6
7
  /**
7
8
  * v1 state merkle tree
8
9
  */
9
- State = 0,
10
+ StateV1 = 1,
10
11
  /**
11
12
  * v1 address merkle tree
12
13
  */
13
- Address = 1,
14
+ AddressV1 = 2,
14
15
  /**
15
16
  * v2 state merkle tree
16
17
  */
17
- BatchedState = 2,
18
+ StateV2 = 3,
18
19
  /**
19
20
  * v2 address merkle tree
20
21
  */
21
- BatchedAddress = 3
22
+ AddressV2 = 4
22
23
  }
24
+ /**
25
+ * @deprecated Use {@link TreeInfo} instead.
26
+ *
27
+ * A bundle of active trees for a given tree type.
28
+ */
23
29
  export type ActiveTreeBundle = {
30
+ /**
31
+ * Tree.
32
+ */
24
33
  tree: PublicKey;
34
+ /**
35
+ * Queue.
36
+ */
25
37
  queue: PublicKey | null;
38
+ /**
39
+ * CPI context.
40
+ */
26
41
  cpiContext: PublicKey | null;
42
+ /**
43
+ * Tree type.
44
+ */
27
45
  treeType: TreeType;
28
46
  };
29
- export interface PackedCompressedAccountWithMerkleContext {
30
- compressedAccount: CompressedAccount;
31
- merkleContext: PackedMerkleContext;
32
- rootIndex: number;
33
- readOnly: boolean;
34
- }
35
- export interface PackedMerkleContext {
47
+ /**
48
+ * @deprecated Use {@link TreeInfo} instead.
49
+ *
50
+ * State tree info, versioned via {@link TreeType}. The protocol
51
+ * stores compressed accounts in state trees.
52
+ */
53
+ export type StateTreeInfo = TreeInfo;
54
+ /**
55
+ * Tree info, versioned via {@link TreeType}. The protocol
56
+ * stores compressed accounts in state trees, and PDAs in address trees.
57
+ *
58
+ * Onchain Accounts are subject to Solana's write-lock limits.
59
+ *
60
+ * To load balance transactions, use {@link selectStateTreeInfo} to
61
+ * randomly select a tree from a range of active trees.
62
+ *
63
+ * Example:
64
+ * ```typescript
65
+ * const infos = await rpc.getStateTreeInfos();
66
+ * const info = selectStateTreeInfo(infos);
67
+ * const ix = await CompressedTokenProgram.compress({
68
+ * // ...
69
+ * outputStateTreeInfo: info
70
+ * });
71
+ * ```
72
+ */
73
+ export type TreeInfo = {
74
+ /**
75
+ * Pubkey of the tree account.
76
+ */
77
+ tree: PublicKey;
78
+ /**
79
+ * Pubkey of the queue account associated with the tree.
80
+ */
81
+ queue: PublicKey;
82
+ /**
83
+ * The type of tree. One of {@link TreeType}.
84
+ */
85
+ treeType: TreeType;
86
+ /**
87
+ * Optional compressed cpi context account.
88
+ */
89
+ cpiContext?: PublicKey;
90
+ /**
91
+ * Next tree info. Is `some` if the next tree should be used for the next
92
+ * state transition.
93
+ */
94
+ nextTreeInfo: TreeInfo | null;
95
+ };
96
+ /**
97
+ * @deprecated Use {@link TreeInfo} instead.
98
+ *
99
+ * Address tree info, versioned via {@link TreeType}. The protocol
100
+ * stores PDAs in address trees.
101
+ */
102
+ export type AddressTreeInfo = Omit<StateTreeInfo, 'cpiContext' | 'nextTreeInfo'> & {
103
+ /**
104
+ * Next tree info.
105
+ */
106
+ nextTreeInfo: AddressTreeInfo | null;
107
+ };
108
+ /**
109
+ * Packed merkle context.
110
+ */
111
+ export interface PackedMerkleContextLegacy {
112
+ /**
113
+ * Merkle tree pubkey index.
114
+ */
36
115
  merkleTreePubkeyIndex: number;
37
- nullifierQueuePubkeyIndex: number;
116
+ /**
117
+ * Queue pubkey index in remaining accounts.
118
+ */
119
+ queuePubkeyIndex: number;
120
+ /**
121
+ * Leaf index.
122
+ */
38
123
  leafIndex: number;
39
- queueIndex: null | QueueIndex;
40
- }
41
- export interface QueueIndex {
42
- queueId: number;
43
- index: number;
124
+ /**
125
+ * Whether to prove by index or validity proof.
126
+ */
127
+ proveByIndex: boolean;
44
128
  }
45
129
  /**
130
+ * @deprecated Use {@link CompressedAccount} instead.
131
+ *
46
132
  * Describe the generic compressed account details applicable to every
47
133
  * compressed account.
134
+ *
48
135
  * */
49
- export interface CompressedAccount {
50
- /** Public key of program or user that owns the account */
136
+ export interface CompressedAccountLegacy {
137
+ /**
138
+ * Public key of program or user owning the account.
139
+ */
51
140
  owner: PublicKey;
52
- /** Lamports attached to the account */
141
+ /**
142
+ * Lamports attached to the account.
143
+ */
53
144
  lamports: BN;
54
145
  /**
55
- * TODO: use PublicKey. Optional unique account ID that is persistent across
56
- * transactions.
146
+ * Optional unique account ID that is persistent across transactions.
57
147
  */
58
148
  address: number[] | null;
59
- /** Optional data attached to the account */
149
+ /**
150
+ * Optional data attached to the account.
151
+ */
60
152
  data: CompressedAccountData | null;
61
153
  }
62
154
  /**
155
+ * @deprecated Use {@link CompressedAccountMeta} instead.
156
+ *
63
157
  * Describe the generic compressed account details applicable to every
64
158
  * compressed account.
65
- * */
159
+ */
66
160
  export interface OutputCompressedAccountWithPackedContext {
67
- compressedAccount: CompressedAccount;
161
+ compressedAccount: CompressedAccountLegacy;
68
162
  merkleTreeIndex: number;
69
163
  }
164
+ /**
165
+ * Compressed account-related proof metadata.
166
+ */
167
+ export type AccountProofInput = {
168
+ hash: BN;
169
+ treeInfo: TreeInfo;
170
+ leafIndex: number;
171
+ rootIndex: number;
172
+ proveByIndex: boolean;
173
+ };
174
+ /**
175
+ * New address proof metadata.
176
+ */
177
+ export type NewAddressProofInput = {
178
+ treeInfo: TreeInfo;
179
+ address: number[];
180
+ rootIndex: number;
181
+ root: BN;
182
+ };
183
+ /**
184
+ * Describes compressed account data.
185
+ */
70
186
  export interface CompressedAccountData {
187
+ /**
188
+ * 8 bytes.
189
+ */
71
190
  discriminator: number[];
191
+ /**
192
+ * Data.
193
+ */
72
194
  data: Buffer;
195
+ /**
196
+ * 32 bytes.
197
+ */
73
198
  dataHash: number[];
74
199
  }
200
+ /**
201
+ * Merkle tree sequence number.
202
+ */
75
203
  export interface MerkleTreeSequenceNumber {
204
+ /**
205
+ * Public key.
206
+ */
76
207
  pubkey: PublicKey;
208
+ /**
209
+ * Sequence number.
210
+ */
77
211
  seq: BN;
78
212
  }
213
+ /**
214
+ * Public transaction event.
215
+ */
79
216
  export interface PublicTransactionEvent {
217
+ /**
218
+ * Input compressed account hashes.
219
+ */
80
220
  inputCompressedAccountHashes: number[][];
221
+ /**
222
+ * Output compressed account hashes.
223
+ */
81
224
  outputCompressedAccountHashes: number[][];
225
+ /**
226
+ * Output compressed accounts.
227
+ */
82
228
  outputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
229
+ /**
230
+ * Output leaf indices.
231
+ */
83
232
  outputLeafIndices: number[];
233
+ /**
234
+ * Sequence numbers.
235
+ */
84
236
  sequenceNumbers: MerkleTreeSequenceNumber[];
237
+ /**
238
+ * Relay fee. Default is null.
239
+ */
85
240
  relayFee: BN | null;
241
+ /**
242
+ * Whether it's a compress or decompress instruction.
243
+ */
86
244
  isCompress: boolean;
245
+ /**
246
+ * If some, it's either a compress or decompress instruction.
247
+ */
87
248
  compressOrDecompressLamports: BN | null;
249
+ /**
250
+ * Public keys.
251
+ */
88
252
  pubkeyArray: PublicKey[];
253
+ /**
254
+ * Message. Default is null.
255
+ */
89
256
  message: Uint8Array | null;
90
257
  }
258
+ /**
259
+ * Instruction data for invoke.
260
+ */
91
261
  export interface InstructionDataInvoke {
92
- proof: CompressedProof | null;
262
+ /**
263
+ * Validity proof.
264
+ */
265
+ proof: ValidityProof | null;
266
+ /**
267
+ * Input compressed accounts with merkle context.
268
+ */
93
269
  inputCompressedAccountsWithMerkleContext: PackedCompressedAccountWithMerkleContext[];
270
+ /**
271
+ * Output compressed accounts.
272
+ */
94
273
  outputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
274
+ /**
275
+ * Relay fee. Default is null.
276
+ */
95
277
  relayFee: BN | null;
278
+ /**
279
+ * Params for creating new addresses.
280
+ */
96
281
  newAddressParams: NewAddressParamsPacked[];
282
+ /**
283
+ * If some, it's either a compress or decompress instruction.
284
+ */
97
285
  compressOrDecompressLamports: BN | null;
286
+ /**
287
+ * Whether it's a compress or decompress instruction.
288
+ */
98
289
  isCompress: boolean;
99
290
  }
291
+ /**
292
+ * Instruction data for invoking a CPI.
293
+ */
100
294
  export interface InstructionDataInvokeCpi {
101
- proof: CompressedProof | null;
295
+ /**
296
+ * Validity proof.
297
+ */
298
+ proof: ValidityProof | null;
299
+ /**
300
+ * Input compressed accounts with merkle context.
301
+ */
102
302
  inputCompressedAccountsWithMerkleContext: PackedCompressedAccountWithMerkleContext[];
303
+ /**
304
+ * Output compressed accounts.
305
+ */
103
306
  outputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
307
+ /**
308
+ * Relay fee. Default is null.
309
+ */
104
310
  relayFee: BN | null;
311
+ /**
312
+ * Params for creating new addresses.
313
+ */
105
314
  newAddressParams: NewAddressParamsPacked[];
315
+ /**
316
+ * If some, it's either a compress or decompress instruction.
317
+ */
106
318
  compressOrDecompressLamports: BN | null;
319
+ /**
320
+ * If `compressOrDecompressLamports` is some, whether it's a compress or
321
+ * decompress instruction.
322
+ */
107
323
  isCompress: boolean;
324
+ /**
325
+ * Optional compressed CPI context.
326
+ */
108
327
  compressedCpiContext: CompressedCpiContext | null;
109
328
  }
329
+ /**
330
+ * Compressed CPI context.
331
+ *
332
+ * Use if you want to use a single {@link ValidityProof} to update two
333
+ * compressed accounts owned by separate programs.
334
+ */
110
335
  export interface CompressedCpiContext {
111
- set_context: boolean;
112
- first_set_context: boolean;
113
- cpi_context_account_index: number;
336
+ /**
337
+ * Is set by the program that is invoking the CPI to signal that it should
338
+ * set the cpi context.
339
+ */
340
+ setContext: boolean;
341
+ /**
342
+ * Is set to wipe the cpi context since someone could have set it before
343
+ * with unrelated data.
344
+ */
345
+ firstSetContext: boolean;
346
+ /**
347
+ * Index of cpi context account in remaining accounts.
348
+ */
349
+ cpiContextAccountIndex: number;
114
350
  }
351
+ /**
352
+ * @deprecated Use {@link ValidityProof} instead.
353
+ */
115
354
  export interface CompressedProof {
355
+ /**
356
+ * 32 bytes.
357
+ */
116
358
  a: number[];
359
+ /**
360
+ * 64 bytes.
361
+ */
117
362
  b: number[];
363
+ /**
364
+ * 32 bytes.
365
+ */
118
366
  c: number[];
119
367
  }
368
+ /**
369
+ * Validity proof.
370
+ *
371
+ * You can request proofs via `rpc.getValidityProof` or
372
+ * `rpc.getValidityProofV0`.
373
+ *
374
+ * One proof can prove the existence of N compressed accounts or the uniqueness
375
+ * of N PDAs.
376
+ */
377
+ export interface ValidityProof {
378
+ /**
379
+ * 32 bytes.
380
+ */
381
+ a: number[];
382
+ /**
383
+ * 64 bytes.
384
+ */
385
+ b: number[];
386
+ /**
387
+ * 32 bytes.
388
+ */
389
+ c: number[];
390
+ }
391
+ /**
392
+ * Packed token data for input compressed accounts.
393
+ */
120
394
  export interface InputTokenDataWithContext {
395
+ /**
396
+ * Amount of tokens.
397
+ */
121
398
  amount: BN;
399
+ /**
400
+ * Delegate index.
401
+ */
122
402
  delegateIndex: number | null;
123
- merkleContext: PackedMerkleContext;
403
+ /**
404
+ * Merkle context.
405
+ */
406
+ merkleContext: PackedMerkleContextLegacy;
407
+ /**
408
+ * Root index.
409
+ */
124
410
  rootIndex: number;
411
+ /**
412
+ * Lamports.
413
+ */
125
414
  lamports: BN | null;
415
+ /**
416
+ * Tlv.
417
+ */
126
418
  tlv: Buffer | null;
127
419
  }
420
+ /**
421
+ * Token data.
422
+ */
128
423
  export type TokenData = {
424
+ /**
425
+ * The mint associated with this account.
426
+ */
129
427
  mint: PublicKey;
428
+ /**
429
+ * The owner of this account.
430
+ */
130
431
  owner: PublicKey;
432
+ /**
433
+ * The amount of tokens this account holds.
434
+ */
131
435
  amount: BN;
436
+ /**
437
+ * If `delegate` is `Some` then `delegated_amount` represents the amount
438
+ * authorized by the delegate.
439
+ */
132
440
  delegate: PublicKey | null;
441
+ /**
442
+ * The account's state.
443
+ */
133
444
  state: number;
445
+ /**
446
+ * Token extension tlv.
447
+ */
134
448
  tlv: Buffer | null;
135
449
  };
@@ -2,7 +2,7 @@ import { PublicKey } from '@solana/web3.js';
2
2
  import BN from 'bn.js';
3
3
  import { Rpc } from '../../rpc';
4
4
  import { ParsedTokenAccount, WithCursor } from '../../rpc-interface';
5
- import { CompressedAccount, PublicTransactionEvent } from '../../state';
5
+ import { PublicTransactionEvent, CompressedAccountLegacy } from '../../state';
6
6
  import { Layout } from '@coral-xyz/borsh';
7
7
  type TokenData = {
8
8
  mint: PublicKey;
@@ -22,7 +22,7 @@ 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(compressedAccount: CompressedAccountLegacy, programId?: PublicKey): TokenData | null;
26
26
  /**
27
27
  * Retrieves all compressed token accounts for a given mint and owner.
28
28
  *
@@ -32,7 +32,7 @@ export declare function parseTokenLayoutWithIdl(compressedAccount: CompressedAcc
32
32
  * @param owner PublicKey of the token owner
33
33
  * @param mint PublicKey of the token mint
34
34
  */
35
- export declare function getCompressedTokenAccounts(events: PublicTransactionEvent[]): Promise<ParsedTokenAccount[]>;
35
+ export declare function getCompressedTokenAccounts(events: PublicTransactionEvent[], rpc: Rpc): Promise<ParsedTokenAccount[]>;
36
36
  /** @internal */
37
37
  export declare function getCompressedTokenAccountsByOwnerTest(rpc: Rpc, owner: PublicKey, mint: PublicKey): Promise<WithCursor<ParsedTokenAccount[]>>;
38
38
  export declare function getCompressedTokenAccountsByDelegateTest(rpc: Rpc, delegate: PublicKey, mint: PublicKey): Promise<WithCursor<ParsedTokenAccount[]>>;
@@ -1,20 +1,11 @@
1
1
  import { Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
2
2
  import BN from 'bn.js';
3
3
  import { AddressWithTree, CompressedMintTokenHolders, CompressedTransaction, GetCompressedAccountsByOwnerConfig, PaginatedOptions, HashWithTree, LatestNonVotingSignatures, LatestNonVotingSignaturesPaginated, SignatureWithMetadata, WithContext, WithCursor } from '../../rpc-interface';
4
- import { CompressedProofWithContext, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, ParsedTokenAccount, TokenBalance } from '../../rpc-interface';
4
+ import { ValidityProofWithContext, 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
+ import { TreeInfo } from '../../state/types';
8
8
  export interface TestRpcConfig {
9
- /**
10
- * Address of the state tree to index. Default: public default test state
11
- * tree.
12
- */
13
- merkleTreeAddress?: PublicKey;
14
- /**
15
- * Nullifier queue associated with merkleTreeAddress
16
- */
17
- nullifierQueueAddress?: PublicKey;
18
9
  /**
19
10
  * Depth of state tree. Defaults to the public default test state tree depth
20
11
  */
@@ -23,15 +14,6 @@ export interface TestRpcConfig {
23
14
  * Log proof generation time
24
15
  */
25
16
  log?: boolean;
26
- /**
27
- * Address of the address tree to index. Default: public default test
28
- * address tree.
29
- */
30
- addressTreeAddress?: PublicKey;
31
- /**
32
- * Address queue associated with addressTreeAddress
33
- */
34
- addressQueueAddress?: PublicKey;
35
17
  }
36
18
  export type ClientSubscriptionId = number;
37
19
  export interface LightWasm {
@@ -55,27 +37,26 @@ export interface LightWasm {
55
37
  * @param depth Depth of the merkle tree.
56
38
  * @param log Log proof generation time.
57
39
  */
58
- export declare function getTestRpc(lightWasm: LightWasm, endpoint?: string, compressionApiEndpoint?: string, proverEndpoint?: string, merkleTreeAddress?: PublicKey, nullifierQueueAddress?: PublicKey, depth?: number, log?: boolean): Promise<TestRpc>;
40
+ export declare function getTestRpc(lightWasm: LightWasm, endpoint?: string, compressionApiEndpoint?: string, proverEndpoint?: string, depth?: number, log?: boolean): Promise<TestRpc>;
59
41
  /**
60
- * Simple mock rpc for unit tests that simulates the compression rpc interface.
61
- * Fetches, parses events and builds merkletree on-demand, i.e. it does not persist state.
42
+ * Mock RPC for unit tests that simulates the ZK Compression RPC interface.
43
+ * Parses events and builds merkletree on-demand. It does not persist state.
62
44
  * Constraints:
63
- * - Can only index 1 merkletree
64
45
  * - Can only index up to 1000 transactions
65
46
  *
66
- * For advanced testing use photon: https://github.com/helius-labs/photon
47
+ * For advanced testing use `Rpc` class which uses photon:
48
+ * https://github.com/helius-labs/photon
67
49
  */
68
50
  export declare class TestRpc extends Connection implements CompressionApiInterface {
69
51
  compressionApiEndpoint: string;
70
52
  proverEndpoint: string;
71
- merkleTreeAddress: PublicKey;
72
- nullifierQueueAddress: PublicKey;
73
- addressTreeAddress: PublicKey;
74
- addressQueueAddress: PublicKey;
75
53
  lightWasm: LightWasm;
76
54
  depth: number;
77
55
  log: boolean;
78
- activeStateTreeInfo: ActiveTreeBundle[] | null;
56
+ allStateTreeInfos: TreeInfo[] | null;
57
+ lastStateTreeFetchTime: number | null;
58
+ fetchPromise: Promise<TreeInfo[]> | null;
59
+ CACHE_TTL: number;
79
60
  /**
80
61
  * Establish a Compression-compatible JSON RPC mock-connection
81
62
  *
@@ -90,17 +71,18 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
90
71
  */
91
72
  constructor(endpoint: string, hasher: LightWasm, compressionApiEndpoint: string, proverEndpoint: string, connectionConfig?: ConnectionConfig, testRpcConfig?: TestRpcConfig);
92
73
  /**
93
- * Manually set state tree addresses
74
+ * @deprecated Use {@link getStateTreeInfos} instead
94
75
  */
95
- setStateTreeInfo(info: ActiveTreeBundle[]): void;
76
+ getCachedActiveStateTreeInfo(): Promise<void>;
96
77
  /**
97
- * Returns local test state trees.
78
+ * @deprecated Use {@link getStateTreeInfos} instead
98
79
  */
99
- getCachedActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
80
+ getCachedActiveStateTreeInfos(): Promise<void>;
100
81
  /**
101
82
  * Returns local test state trees.
102
83
  */
103
- getLatestActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
84
+ getStateTreeInfos(): Promise<TreeInfo[]>;
85
+ doFetch(): Promise<TreeInfo[]>;
104
86
  /**
105
87
  * Fetch the compressed account for the specified account hash
106
88
  */
@@ -188,7 +170,7 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
188
170
  * Fetch a confirmed or finalized transaction from the cluster. Return with
189
171
  * CompressionInfo
190
172
  */
191
- getTransactionWithCompressionInfo(_signature: string): Promise<CompressedTransaction | null>;
173
+ getTransactionWithCompressionInfo(_signature: string): Promise<CompressedTransaction>;
192
174
  /**
193
175
  * Returns confirmed signatures for transactions involving the specified
194
176
  * address forward in time from genesis to the most recent confirmed
@@ -229,21 +211,11 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
229
211
  */
230
212
  getMultipleNewAddressProofs(addresses: BN254[]): Promise<MerkleContextWithNewAddressProof[]>;
231
213
  getCompressedMintTokenHolders(_mint: PublicKey, _options?: PaginatedOptions): Promise<WithContext<WithCursor<CompressedMintTokenHolders[]>>>;
232
- /**
233
- * Advanced usage of getValidityProof: fetches ZKP directly from a custom
234
- * non-rpcprover. Note: This uses the proverEndpoint specified in the
235
- * constructor. For normal usage, please use {@link getValidityProof}
236
- * instead.
237
- *
238
- * Note: Use RPC class for forested trees. TestRpc is only for custom
239
- * testing purposes.
240
- */
241
- getValidityProofDirect(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
242
214
  /**
243
215
  * @deprecated This method is not available for TestRpc. Please use
244
216
  * {@link getValidityProof} instead.
245
217
  */
246
- getValidityProofAndRpcContext(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<WithContext<CompressedProofWithContext>>;
218
+ getValidityProofAndRpcContext(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<WithContext<ValidityProofWithContext>>;
247
219
  /**
248
220
  * Fetch the latest validity proof for (1) compressed accounts specified by
249
221
  * an array of account hashes. (2) new unique addresses specified by an
@@ -258,6 +230,6 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
258
230
  * @param newAddresses Array of BN254 new addresses.
259
231
  * @returns validity proof with context
260
232
  */
261
- getValidityProof(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
262
- getValidityProofV0(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<CompressedProofWithContext>;
233
+ getValidityProof(hashes?: BN254[], newAddresses?: BN254[]): Promise<ValidityProofWithContext>;
234
+ getValidityProofV0(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<ValidityProofWithContext>;
263
235
  }
@@ -2,6 +2,6 @@
2
2
  * @param targetLamports - Target priority fee in lamports
3
3
  * @param computeUnits - Expected compute units used by the transaction
4
4
  * @returns microLamports per compute unit (use in
5
- * `ComputeBudgetProgram.setComputeUnitPrice`)
5
+ * {@link https://github.com/solana-foundation/solana-web3.js/blob/maintenance/v1.x/src/programs/compute-budget.ts#L218})
6
6
  */
7
7
  export declare function calculateComputeUnitPrice(targetLamports: number, computeUnits: number): number;
@@ -1,6 +1,7 @@
1
1
  import { Buffer } from 'buffer';
2
2
  import { Keypair } from '@solana/web3.js';
3
3
  import BN from 'bn.js';
4
+ import { InstructionDataInvoke } from '../state';
4
5
  export declare function byteArrayToKeypair(byteArray: number[]): Keypair;
5
6
  /**
6
7
  * @internal
@@ -31,3 +32,4 @@ export declare function hashToBn254FieldSizeBe(bytes: Buffer): [Buffer, number]
31
32
  export declare function hashvToBn254FieldSizeBe(bytes: Uint8Array[]): Uint8Array;
32
33
  /** Mutates array in place */
33
34
  export declare function pushUniqueItems<T>(items: T[], map: T[]): void;
35
+ export declare function convertInvokeCpiWithReadOnlyToInvoke(data: any): InstructionDataInvoke;