@lightprotocol/stateless.js 0.22.1-alpha.0 → 0.22.1-alpha.2

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 (96) hide show
  1. package/README.md +4 -1
  2. package/dist/cjs/browser/constants.d.ts +41 -7
  3. package/dist/cjs/browser/index.cjs +1 -1
  4. package/dist/cjs/browser/index.cjs.map +1 -1
  5. package/dist/cjs/browser/index.d.ts +0 -1
  6. package/dist/cjs/browser/programs/system/pack.d.ts +10 -79
  7. package/dist/cjs/browser/rpc-interface.d.ts +371 -277
  8. package/dist/cjs/browser/rpc.d.ts +79 -12
  9. package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +0 -2
  10. package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +12 -6
  11. package/dist/cjs/browser/utils/address.d.ts +7 -19
  12. package/dist/cjs/browser/utils/conversion.d.ts +1 -1
  13. package/dist/cjs/browser/utils/get-state-tree-infos.d.ts +15 -0
  14. package/dist/cjs/browser/utils/index.d.ts +2 -1
  15. package/dist/cjs/browser/utils/instruction.d.ts +35 -0
  16. package/dist/cjs/browser/utils/pack-decompress.d.ts +31 -0
  17. package/dist/cjs/node/constants.d.ts +41 -7
  18. package/dist/cjs/node/index.cjs +1 -1
  19. package/dist/cjs/node/index.cjs.map +1 -1
  20. package/dist/cjs/node/index.d.ts +0 -1
  21. package/dist/cjs/node/programs/system/pack.d.ts +10 -79
  22. package/dist/cjs/node/rpc-interface.d.ts +371 -277
  23. package/dist/cjs/node/rpc.d.ts +79 -12
  24. package/dist/cjs/node/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +0 -2
  25. package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +12 -6
  26. package/dist/cjs/node/utils/address.d.ts +7 -19
  27. package/dist/cjs/node/utils/conversion.d.ts +1 -1
  28. package/dist/cjs/node/utils/get-state-tree-infos.d.ts +15 -0
  29. package/dist/cjs/node/utils/index.d.ts +2 -1
  30. package/dist/cjs/node/utils/instruction.d.ts +35 -0
  31. package/dist/cjs/node/utils/pack-decompress.d.ts +31 -0
  32. package/dist/es/browser/actions/compress.d.ts +18 -0
  33. package/dist/es/browser/actions/create-account.d.ts +38 -0
  34. package/dist/es/browser/actions/decompress.d.ts +15 -0
  35. package/dist/es/browser/actions/index.d.ts +5 -0
  36. package/dist/es/browser/actions/transfer.d.ts +16 -0
  37. package/dist/es/browser/constants.d.ts +176 -0
  38. package/dist/es/browser/errors.d.ts +74 -0
  39. package/dist/es/browser/index.d.ts +9 -0
  40. package/dist/es/browser/index.js +2 -0
  41. package/dist/es/browser/index.js.map +1 -0
  42. package/dist/es/browser/programs/index.d.ts +1 -0
  43. package/dist/es/browser/programs/system/idl.d.ts +997 -0
  44. package/dist/es/browser/programs/system/index.d.ts +5 -0
  45. package/dist/es/browser/programs/system/layout.d.ts +77 -0
  46. package/dist/es/browser/programs/system/pack.d.ts +74 -0
  47. package/dist/es/browser/programs/system/program.d.ts +175 -0
  48. package/dist/es/browser/programs/system/select-compressed-accounts.d.ts +10 -0
  49. package/dist/es/browser/rpc-interface.d.ts +2873 -0
  50. package/dist/es/browser/rpc.d.ts +361 -0
  51. package/dist/es/browser/state/BN254.d.ts +13 -0
  52. package/dist/es/browser/state/bn.d.ts +3 -0
  53. package/dist/es/browser/state/compressed-account.d.ts +205 -0
  54. package/dist/es/browser/state/index.d.ts +4 -0
  55. package/dist/es/browser/state/types.d.ts +449 -0
  56. package/dist/es/browser/test-helpers/index.d.ts +3 -0
  57. package/dist/es/browser/test-helpers/merkle-tree/index.d.ts +2 -0
  58. package/dist/es/browser/test-helpers/merkle-tree/indexed-array.d.ts +85 -0
  59. package/dist/es/browser/test-helpers/merkle-tree/merkle-tree.d.ts +92 -0
  60. package/dist/es/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +7 -0
  61. package/dist/es/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +38 -0
  62. package/dist/es/browser/test-helpers/test-rpc/get-parsed-events.d.ts +15 -0
  63. package/dist/es/browser/test-helpers/test-rpc/index.d.ts +3 -0
  64. package/dist/es/browser/test-helpers/test-rpc/test-rpc.d.ts +245 -0
  65. package/dist/es/browser/test-helpers/test-utils.d.ts +31 -0
  66. package/dist/es/browser/utils/address.d.ts +64 -0
  67. package/dist/es/browser/utils/airdrop.d.ts +7 -0
  68. package/dist/es/browser/utils/calculate-compute-unit-price.d.ts +7 -0
  69. package/dist/es/browser/utils/conversion.d.ts +36 -0
  70. package/dist/es/browser/utils/dedupe-signer.d.ts +3 -0
  71. package/dist/es/browser/utils/get-state-tree-infos.d.ts +63 -0
  72. package/dist/es/browser/utils/index.d.ts +14 -0
  73. package/dist/es/browser/utils/instruction.d.ts +35 -0
  74. package/dist/es/browser/utils/pack-decompress.d.ts +31 -0
  75. package/dist/es/browser/utils/parse-validity-proof.d.ts +20 -0
  76. package/dist/es/browser/utils/pipe.d.ts +2 -0
  77. package/dist/es/browser/utils/send-and-confirm.d.ts +52 -0
  78. package/dist/es/browser/utils/sleep.d.ts +1 -0
  79. package/dist/es/browser/utils/state-tree-lookup-table.d.ts +68 -0
  80. package/dist/es/browser/utils/validation.d.ts +8 -0
  81. package/dist/types/index.d.ts +340 -661
  82. package/package.json +18 -10
  83. package/dist/cjs/browser/compressible/action.d.ts +0 -77
  84. package/dist/cjs/browser/compressible/index.d.ts +0 -13
  85. package/dist/cjs/browser/compressible/instruction.d.ts +0 -177
  86. package/dist/cjs/browser/compressible/layout.d.ts +0 -47
  87. package/dist/cjs/browser/compressible/types.d.ts +0 -112
  88. package/dist/cjs/browser/compressible/utils.d.ts +0 -16
  89. package/dist/cjs/browser/utils/packed-accounts.d.ts +0 -161
  90. package/dist/cjs/node/compressible/action.d.ts +0 -77
  91. package/dist/cjs/node/compressible/index.d.ts +0 -13
  92. package/dist/cjs/node/compressible/instruction.d.ts +0 -177
  93. package/dist/cjs/node/compressible/layout.d.ts +0 -47
  94. package/dist/cjs/node/compressible/types.d.ts +0 -112
  95. package/dist/cjs/node/compressible/utils.d.ts +0 -16
  96. package/dist/cjs/node/utils/packed-accounts.d.ts +0 -161
@@ -0,0 +1,361 @@
1
+ import { AccountInfo, Commitment, Connection, ConnectionConfig, GetAccountInfoConfig, PublicKey, SignaturesForAddressOptions } from '@solana/web3.js';
2
+ import { Buffer } from 'buffer';
3
+ import { ValidityProofWithContext, CompressedTransaction, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, HexInputsForProver, ParsedTokenAccount, SignatureWithMetadata, LatestNonVotingSignatures, LatestNonVotingSignaturesPaginated, WithContext, GetCompressedAccountsByOwnerConfig, WithCursor, AddressWithTree, HashWithTree, CompressedMintTokenHolders, TokenBalance, PaginatedOptions, DerivationMode, AddressWithTreeInfoV2, SignaturesForAddressInterfaceResult, UnifiedSignatureInfo, UnifiedTokenBalance, UnifiedBalance } from './rpc-interface';
4
+ import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, ValidityProof, AddressTreeInfo, MerkleContext } from './state';
5
+ import BN from 'bn.js';
6
+ import { ConfirmedSignatureInfo } from '@solana/web3.js';
7
+ import { LightWasm } from './test-helpers';
8
+ import { TreeInfo } from './state/types';
9
+ /** @internal */
10
+ export declare function parseAccountData({ discriminator, data, dataHash, }: {
11
+ discriminator: BN;
12
+ data: string;
13
+ dataHash: BN;
14
+ }): {
15
+ discriminator: number[];
16
+ data: Buffer<ArrayBuffer>;
17
+ dataHash: number[];
18
+ };
19
+ /**
20
+ * Establish a Compression-compatible JSON RPC connection
21
+ *
22
+ * @param endpointOrWeb3JsConnection endpoint to the solana cluster or
23
+ * Connection object
24
+ * @param compressionApiEndpoint Endpoint to the compression server
25
+ * @param proverEndpoint Endpoint to the prover server. defaults
26
+ * to endpoint
27
+ * @param connectionConfig Optional connection config
28
+ */
29
+ export declare function createRpc(endpointOrWeb3JsConnection?: string | Connection, compressionApiEndpoint?: string, proverEndpoint?: string, config?: ConnectionConfig): Rpc;
30
+ /**
31
+ * Helper function to preprocess the response to wrap numbers as strings
32
+ * @param {string} text - The JSON string to preprocess
33
+ * @returns {string} - The preprocessed JSON string with numbers wrapped as strings
34
+ */
35
+ export declare function wrapBigNumbersAsStrings(text: string): string;
36
+ /** @internal */
37
+ export declare const rpcRequest: (rpcEndpoint: string, method: string, params?: any, convertToCamelCase?: boolean, debug?: boolean) => Promise<any>;
38
+ /** @internal */
39
+ export declare const proverRequest: (proverEndpoint: string, method: "inclusion" | "new-address" | "combined", params?: any, log?: boolean, _publicInputHash?: BN | undefined) => Promise<ValidityProof>;
40
+ export type NonInclusionMerkleProofInputs = {
41
+ root: BN;
42
+ value: BN;
43
+ leaf_lower_range_value: BN;
44
+ leaf_higher_range_value: BN;
45
+ nextIndex: BN;
46
+ merkle_proof_hashed_indexed_element_leaf: BN[];
47
+ index_hashed_indexed_element_leaf: BN;
48
+ };
49
+ export type MerkleContextWithNewAddressProof = {
50
+ root: BN;
51
+ rootIndex: number;
52
+ value: BN;
53
+ leafLowerRangeValue: BN;
54
+ leafHigherRangeValue: BN;
55
+ nextIndex: BN;
56
+ merkleProofHashedIndexedElementLeaf: BN[];
57
+ indexHashedIndexedElementLeaf: BN;
58
+ treeInfo: AddressTreeInfo;
59
+ };
60
+ export type NonInclusionJsonStruct = {
61
+ root: string;
62
+ value: string;
63
+ pathIndex: number;
64
+ pathElements: string[];
65
+ leafLowerRangeValue: string;
66
+ leafHigherRangeValue: string;
67
+ nextIndex: number;
68
+ };
69
+ export declare function convertMerkleProofsWithContextToHex(merkleProofsWithContext: MerkleContextWithMerkleProof[]): HexInputsForProver[];
70
+ export declare function convertNonInclusionMerkleProofInputsToHex(nonInclusionMerkleProofInputs: MerkleContextWithNewAddressProof[]): NonInclusionJsonStruct[];
71
+ export declare function getPublicInputHash(accountProofs: MerkleContextWithMerkleProof[], accountHashes: BN254[], newAddressProofs: MerkleContextWithNewAddressProof[], lightWasm: LightWasm): BN;
72
+ export interface NullifierMetadata {
73
+ nullifier: BN254;
74
+ txHash: BN254;
75
+ }
76
+ /**
77
+ * Merge signatures from Solana RPC and compression indexer.
78
+ * Deduplicates by signature, tracking sources in the `sources` array.
79
+ * When a signature exists in both, uses Solana data (richer) but marks both sources.
80
+ */
81
+ export declare function mergeSignatures(solanaSignatures: ConfirmedSignatureInfo[], compressedSignatures: SignatureWithMetadata[]): UnifiedSignatureInfo[];
82
+ /**
83
+ *
84
+ */
85
+ export declare class Rpc extends Connection implements CompressionApiInterface {
86
+ compressionApiEndpoint: string;
87
+ proverEndpoint: string;
88
+ allStateTreeInfos: TreeInfo[] | null;
89
+ lastStateTreeFetchTime: number | null;
90
+ CACHE_TTL: number;
91
+ fetchPromise: Promise<TreeInfo[]> | null;
92
+ constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
93
+ /**
94
+ * @deprecated Use {@link getStateTreeInfos} instead
95
+ */
96
+ getCachedActiveStateTreeInfo(): Promise<void>;
97
+ /**
98
+ * @deprecated Use {@link getStateTreeInfos} instead
99
+ */
100
+ getCachedActiveStateTreeInfos(): Promise<void>;
101
+ /**
102
+ * Get a list of all state tree infos. If not already cached, fetches from
103
+ * the cluster.
104
+ */
105
+ getStateTreeInfos(): Promise<TreeInfo[]>;
106
+ /**
107
+ * @internal
108
+ */
109
+ doFetch(): Promise<TreeInfo[]>;
110
+ /**
111
+ * Get a V2 address tree info.
112
+ */
113
+ getAddressTreeInfoV2(): Promise<TreeInfo>;
114
+ /**
115
+ * Fetch the compressed account for the specified account address or hash
116
+ */
117
+ getCompressedAccount(address?: BN254, hash?: BN254): Promise<CompressedAccountWithMerkleContext | null>;
118
+ /**
119
+ * Fetch the compressed balance for the specified account address or hash
120
+ */
121
+ getCompressedBalance(address?: BN254, hash?: BN254): Promise<BN>;
122
+ /**
123
+ * Fetch the total compressed balance for the specified owner public key
124
+ */
125
+ getCompressedBalanceByOwner(owner: PublicKey): Promise<BN>;
126
+ /**
127
+ * Fetch the latest merkle proof for the specified account hash from the
128
+ * cluster
129
+ */
130
+ getCompressedAccountProof(hash: BN254): Promise<MerkleContextWithMerkleProof>;
131
+ /**
132
+ * Fetch all the account info for multiple compressed accounts specified by
133
+ * an array of account hashes
134
+ */
135
+ getMultipleCompressedAccounts(hashes: BN254[]): Promise<CompressedAccountWithMerkleContext[]>;
136
+ /**
137
+ * Fetch the latest merkle proofs for multiple compressed accounts specified
138
+ * by an array account hashes
139
+ */
140
+ getMultipleCompressedAccountProofs(hashes: BN254[]): Promise<MerkleContextWithMerkleProof[]>;
141
+ /**
142
+ * Fetch all the compressed accounts owned by the specified public key.
143
+ * Owner can be a program or user account
144
+ */
145
+ getCompressedAccountsByOwner(owner: PublicKey, config?: GetCompressedAccountsByOwnerConfig | undefined): Promise<WithCursor<CompressedAccountWithMerkleContext[]>>;
146
+ /**
147
+ * Fetch all the compressed token accounts owned by the specified public
148
+ * key. Owner can be a program or user account
149
+ */
150
+ getCompressedTokenAccountsByOwner(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<ParsedTokenAccount[]>>;
151
+ /**
152
+ * Fetch all the compressed accounts delegated to the specified public key.
153
+ */
154
+ getCompressedTokenAccountsByDelegate(delegate: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<ParsedTokenAccount[]>>;
155
+ /**
156
+ * Fetch the compressed token balance for the specified account hash
157
+ */
158
+ getCompressedTokenAccountBalance(hash: BN254): Promise<{
159
+ amount: BN;
160
+ }>;
161
+ /**
162
+ * @deprecated use {@link getCompressedTokenBalancesByOwnerV2} instead.
163
+ *
164
+ * Fetch all the compressed token balances owned by the specified public
165
+ * key. Can filter by mint. Returns without context.
166
+ */
167
+ getCompressedTokenBalancesByOwner(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<TokenBalance[]>>;
168
+ /**
169
+ * Fetch the compressed token balances owned by the specified public
170
+ * key. Paginated. Can filter by mint. Returns with context.
171
+ */
172
+ getCompressedTokenBalancesByOwnerV2(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithContext<WithCursor<TokenBalance[]>>>;
173
+ /**
174
+ * Returns confirmed compression signatures for transactions involving the specified
175
+ * account hash forward in time from genesis to the most recent confirmed
176
+ * block
177
+ *
178
+ * @param hash queried account hash
179
+ */
180
+ getCompressionSignaturesForAccount(hash: BN254): Promise<SignatureWithMetadata[]>;
181
+ /**
182
+ * Fetch a confirmed or finalized transaction from the cluster. Return with
183
+ * CompressionInfo
184
+ */
185
+ getTransactionWithCompressionInfo(signature: string): Promise<CompressedTransaction | null>;
186
+ /**
187
+ * Returns confirmed signatures for transactions involving the specified
188
+ * address forward in time from genesis to the most recent confirmed block
189
+ *
190
+ * @param address queried compressed account address
191
+ */
192
+ getCompressionSignaturesForAddress(address: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
193
+ /**
194
+ * Returns confirmed signatures for compression transactions involving the
195
+ * specified account owner forward in time from genesis to the
196
+ * most recent confirmed block
197
+ *
198
+ * @param owner queried owner public key
199
+ */
200
+ getCompressionSignaturesForOwner(owner: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
201
+ /**
202
+ * Returns confirmed signatures for compression transactions involving the
203
+ * specified token account owner forward in time from genesis to the most
204
+ * recent confirmed block
205
+ */
206
+ getCompressionSignaturesForTokenOwner(owner: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
207
+ /**
208
+ * Fetch the current indexer health status
209
+ */
210
+ getIndexerHealth(): Promise<string>;
211
+ /**
212
+ * Ensure that the Compression Indexer has already indexed the transaction
213
+ */
214
+ confirmTransactionIndexed(slot: number): Promise<boolean>;
215
+ /**
216
+ * Fetch the current slot that the node is processing
217
+ */
218
+ getIndexerSlot(): Promise<number>;
219
+ /**
220
+ * Fetch all the compressed token holders for a given mint. Paginated.
221
+ */
222
+ getCompressedMintTokenHolders(mint: PublicKey, options?: PaginatedOptions): Promise<WithContext<WithCursor<CompressedMintTokenHolders[]>>>;
223
+ /**
224
+ * Fetch the latest compression signatures on the cluster. Results are
225
+ * paginated.
226
+ */
227
+ getLatestCompressionSignatures(cursor?: string, limit?: number): Promise<LatestNonVotingSignaturesPaginated>;
228
+ /**
229
+ * Fetch all non-voting signatures
230
+ */
231
+ getLatestNonVotingSignatures(limit?: number, cursor?: string): Promise<LatestNonVotingSignatures>;
232
+ /**
233
+ * Fetch the latest address proofs for new unique addresses specified by an
234
+ * array of addresses.
235
+ *
236
+ * the proof states that said address have not yet been created in
237
+ * respective address tree.
238
+ * @param addresses Array of BN254 new addresses
239
+ * @returns Array of validity proofs for new addresses
240
+ */
241
+ getMultipleNewAddressProofs(addresses: BN254[]): Promise<MerkleContextWithNewAddressProof[]>;
242
+ /**
243
+ * @deprecated use {@link getValidityProofV0} instead.
244
+ *
245
+ * Fetch the latest validity proof for (1) compressed accounts specified by
246
+ * an array of account hashes. (2) new unique addresses specified by an
247
+ * array of addresses.
248
+ *
249
+ * Validity proofs prove the presence of compressed accounts in state trees
250
+ * and the non-existence of addresses in address trees, respectively. They
251
+ * enable verification without recomputing the merkle proof path, thus
252
+ * lowering verification and data costs.
253
+ *
254
+ * @param hashes Array of BN254 hashes.
255
+ * @param newAddresses Array of BN254 new addresses.
256
+ * @returns validity proof with context
257
+ */
258
+ getValidityProof(hashes?: BN254[], newAddresses?: BN254[]): Promise<ValidityProofWithContext>;
259
+ /**
260
+ * Fetch the latest validity proof for (1) compressed accounts specified by
261
+ * an array of account hashes. (2) new unique addresses specified by an
262
+ * array of addresses.
263
+ *
264
+ * Validity proofs prove the presence of compressed accounts in state trees
265
+ * and the non-existence of addresses in address trees, respectively. They
266
+ * enable verification without recomputing the merkle proof path, thus
267
+ * lowering verification and data costs.
268
+ *
269
+ * @param hashes Array of { hash: BN254, tree: PublicKey, queue: PublicKey }.
270
+ * @param newAddresses Array of { address: BN254, tree: PublicKey, queue: PublicKey }.
271
+ * @returns validity proof with context
272
+ */
273
+ getValidityProofV0(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<ValidityProofWithContext>;
274
+ /**
275
+ * Fetch the latest validity proof for (1) compressed accounts specified by
276
+ * an array of account Merkle contexts, and (2) new unique addresses specified by
277
+ * an array of address objects with tree info.
278
+ *
279
+ * Validity proofs prove the presence of compressed accounts in state trees
280
+ * and the non-existence of addresses in address trees, respectively. They
281
+ * enable verification without recomputing the merkle proof path, thus
282
+ * lowering verification and data costs.
283
+ */
284
+ getValidityProofV2(accountMerkleContexts?: (MerkleContext | undefined)[], newAddresses?: AddressWithTreeInfoV2[], derivationMode?: DerivationMode): Promise<ValidityProofWithContext>;
285
+ /**
286
+ * Fetch the latest validity proof for (1) compressed accounts specified by
287
+ * an array of account hashes. (2) new unique addresses specified by an
288
+ * array of addresses. Returns with context slot.
289
+ *
290
+ * Validity proofs prove the presence of compressed accounts in state trees
291
+ * and the non-existence of addresses in address trees, respectively. They
292
+ * enable verification without recomputing the merkle proof path, thus
293
+ * lowering verification and data costs.
294
+ *
295
+ * @param hashes Array of BN254 hashes.
296
+ * @param newAddresses Array of BN254 new addresses. Optionally specify the
297
+ * tree and queue for each address. Default to public
298
+ * state tree/queue.
299
+ * @returns validity proof with context
300
+ */
301
+ getValidityProofAndRpcContext(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<WithContext<ValidityProofWithContext>>;
302
+ /**
303
+ * Fetch the account info for the specified public key. Returns metadata
304
+ * to load in case the account is cold.
305
+ * @param address The account address to fetch.
306
+ * @param programId The owner program ID.
307
+ * @param commitmentOrConfig Optional. The commitment or config to use
308
+ * for the onchain account fetch.
309
+ * @param addressSpace Optional. The address space info that was
310
+ * used at init.
311
+ *
312
+ * @returns Account info with load info, or null if
313
+ * account doesn't exist. LoadContext is always
314
+ * some if the account is compressible. isCold
315
+ * indicates the current state of the account,
316
+ * if true the account must referenced in a
317
+ * load instruction before use.
318
+ */
319
+ getAccountInfoInterface(address: PublicKey, programId: PublicKey, commitmentOrConfig?: Commitment | GetAccountInfoConfig, addressSpace?: TreeInfo): Promise<{
320
+ accountInfo: AccountInfo<Buffer>;
321
+ isCold: boolean;
322
+ loadContext?: MerkleContext;
323
+ } | null>;
324
+ /**
325
+ * Get signatures for an address from both Solana and compression indexer.
326
+ *
327
+ * @param address Address to fetch signatures for.
328
+ * @param options Options for the Solana getSignaturesForAddress call.
329
+ * @param compressedOptions Options for the compression getCompressionSignaturesForAddress call.
330
+ * @returns Unified signatures from both sources.
331
+ */
332
+ getSignaturesForAddressInterface(address: PublicKey, options?: SignaturesForAddressOptions, compressedOptions?: PaginatedOptions): Promise<SignaturesForAddressInterfaceResult>;
333
+ /**
334
+ * Get signatures for an owner from both Solana and compression indexer.
335
+ *
336
+ * @param owner Owner address to fetch signatures for.
337
+ * @param options Options for the Solana getSignaturesForAddress call.
338
+ * @param compressedOptions Options for the compression getCompressionSignaturesForOwner call.
339
+ * @returns Unified signatures from both sources.
340
+ */
341
+ getSignaturesForOwnerInterface(owner: PublicKey, options?: SignaturesForAddressOptions, compressedOptions?: PaginatedOptions): Promise<SignaturesForAddressInterfaceResult>;
342
+ /**
343
+ * Get token account balance for an address, regardless of whether the token
344
+ * account is hot or cold.
345
+ *
346
+ * @param address Token account address.
347
+ * @param owner Owner public key.
348
+ * @param mint Mint public key.
349
+ * @param commitment Commitment level for on-chain query.
350
+ * @returns Unified token balance from both sources.
351
+ */
352
+ getTokenAccountBalanceInterface(address: PublicKey, owner: PublicKey, mint: PublicKey, commitment?: Commitment): Promise<UnifiedTokenBalance>;
353
+ /**
354
+ * Get SOL balance for an address, regardless of whether the account is hot or cold.
355
+ *
356
+ * @param address Address to fetch balance for.
357
+ * @param commitment Commitment level for on-chain query.
358
+ * @returns Unified SOL balance.
359
+ */
360
+ getBalanceInterface(address: PublicKey, commitment?: Commitment): Promise<UnifiedBalance>;
361
+ }
@@ -0,0 +1,13 @@
1
+ import BN from 'bn.js';
2
+ import { Buffer } from 'buffer';
3
+ /**
4
+ * bignumber with <254-bit max size. Anchor serialization doesn't support native
5
+ * bigint yet, so we wrap BN. This wrapper has simple base10 encoding which is
6
+ * needed for zk circuit compat, in addition to the base58 encoding that users
7
+ * are used to from working with the web3.js PublicKey type.
8
+ */
9
+ export type BN254 = BN;
10
+ /** Create a bigint instance with <254-bit max size and base58 capabilities */
11
+ export declare const createBN254: (number: string | number | BN | Buffer | Uint8Array | number[], base?: number | "hex" | "base58" | undefined) => BN254;
12
+ /** Convert <254-bit bigint to Base58 string. */
13
+ export declare function encodeBN254toBase58(bigintNumber: BN): string;
@@ -0,0 +1,3 @@
1
+ import BN from 'bn.js';
2
+ import { Buffer } from 'buffer';
3
+ export declare const bn: (number: string | number | BN | Buffer | Uint8Array | number[], base?: number | "hex" | undefined, endian?: BN.Endianness | undefined) => BN;
@@ -0,0 +1,205 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+ import { CompressedAccountData, CompressedAccountLegacy, PackedMerkleContextLegacy, TreeInfo } from './types';
3
+ import BN from 'bn.js';
4
+ import { BN254 } from './BN254';
5
+ /**
6
+ * @deprecated use {@link CompressedAccount} instead
7
+ */
8
+ export type CompressedAccountWithMerkleContext = CompressedAccount & MerkleContext & {
9
+ readOnly: boolean;
10
+ };
11
+ /**
12
+ * @deprecated use {@link CompressedAccount} instead
13
+ */
14
+ export type CompressedAccountWithMerkleContextLegacy = CompressedAccount & MerkleContext;
15
+ /**
16
+ * Compressed account + metadata about the state tree in which the account is
17
+ * stored.
18
+ */
19
+ export type CompressedAccount = {
20
+ /**
21
+ * Public key of program or user owning the account.
22
+ */
23
+ owner: PublicKey;
24
+ /**
25
+ * Lamports attached to the account.
26
+ */
27
+ lamports: BN;
28
+ /**
29
+ * Optional unique account ID that is persistent across transactions.
30
+ */
31
+ address: number[] | null;
32
+ /**
33
+ * Optional data attached to the account.
34
+ */
35
+ data: CompressedAccountData | null;
36
+ } & MerkleContext & {
37
+ /**
38
+ * Read only.
39
+ */
40
+ readOnly: boolean;
41
+ };
42
+ /**
43
+ * @deprecated use {@link MerkleContext} instead.
44
+ *
45
+ * Legacy MerkleContext.
46
+ */
47
+ export type MerkleContextLegacy = {
48
+ /**
49
+ * State tree
50
+ */
51
+ merkleTree: PublicKey;
52
+ /**
53
+ * Nullifier queue
54
+ */
55
+ nullifierQueue: PublicKey;
56
+ /**
57
+ * Poseidon hash of the account. Stored as leaf in state tree
58
+ */
59
+ hash: number[];
60
+ /**
61
+ * Position of `hash` in the State tree
62
+ */
63
+ leafIndex: number;
64
+ };
65
+ /**
66
+ * Context for compressed account stored in a state tree
67
+ */
68
+ export type MerkleContext = {
69
+ /**
70
+ * Tree info
71
+ */
72
+ treeInfo: TreeInfo;
73
+ /**
74
+ * Poseidon hash of the account. Stored as leaf in state tree
75
+ */
76
+ hash: BN;
77
+ /**
78
+ * Position of `hash` in the State tree
79
+ */
80
+ leafIndex: number;
81
+ /**
82
+ * Whether the account can be proven by index or by merkle proof
83
+ */
84
+ proveByIndex: boolean;
85
+ };
86
+ /**
87
+ * MerkleContext with merkle proof
88
+ */
89
+ export type MerkleContextWithMerkleProof = MerkleContext & {
90
+ /**
91
+ * Recent valid 'hash' proof path, expires after n slots
92
+ */
93
+ merkleProof: BN254[];
94
+ /**
95
+ * Index of state root the merkleproof is valid for, expires after n slots
96
+ */
97
+ rootIndex: number;
98
+ /**
99
+ * Current root
100
+ */
101
+ root: BN254;
102
+ };
103
+ /**
104
+ * Packed compressed account and state tree info.
105
+ */
106
+ export type PackedStateTreeInfo = {
107
+ /**
108
+ * Recent valid root index.
109
+ */
110
+ rootIndex: number;
111
+ /**
112
+ * Whether the account can be proven by index or by merkle proof
113
+ */
114
+ proveByIndex: boolean;
115
+ /**
116
+ * Index of the merkle tree in which the account is stored.
117
+ */
118
+ merkleTreePubkeyIndex: number;
119
+ /**
120
+ * Index of the queue in which the account is stored.
121
+ */
122
+ queuePubkeyIndex: number;
123
+ /**
124
+ * Index of the leaf in the state tree.
125
+ */
126
+ leafIndex: number;
127
+ };
128
+ /**
129
+ * Packed tree info for a new program-derived address (PDA).
130
+ */
131
+ export type PackedAddressTreeInfo = {
132
+ /**
133
+ * Index of the merkle tree in which the account is stored.
134
+ */
135
+ addressMerkleTreePubkeyIndex: number;
136
+ /**
137
+ * Index of the queue in which the account is stored.
138
+ */
139
+ addressQueuePubkeyIndex: number;
140
+ /**
141
+ * Recent valid root index.
142
+ */
143
+ rootIndex: number;
144
+ };
145
+ /**
146
+ * Compressed account meta in instruction.
147
+ *
148
+ */
149
+ export type CompressedAccountMeta = {
150
+ /**
151
+ * Packed Tree info.
152
+ */
153
+ treeInfo: PackedStateTreeInfo;
154
+ /**
155
+ * Address.
156
+ */
157
+ address: number[] | null;
158
+ /**
159
+ * Lamports.
160
+ */
161
+ lamports: BN | null;
162
+ /**
163
+ * index of state tree in which the new account state is stored.
164
+ */
165
+ outputStateTreeIndex: number;
166
+ };
167
+ /**
168
+ * Create an output compressed account meta for a new account.
169
+ * Client-side only.
170
+ */
171
+ export declare const createCompressedAccountMeta: (treeInfo: PackedStateTreeInfo, outputStateTreeIndex: number, address?: number[], lamports?: BN) => CompressedAccountMeta;
172
+ /**
173
+ * @deprecated Use {@link PackedStateTreeInfo} instead.
174
+ * Packed compressed account with merkle context.
175
+ */
176
+ export interface PackedCompressedAccountWithMerkleContext {
177
+ /**
178
+ * Compressed account.
179
+ */
180
+ compressedAccount: CompressedAccountLegacy;
181
+ /**
182
+ * Merkle context.
183
+ */
184
+ merkleContext: PackedMerkleContextLegacy;
185
+ /**
186
+ * Root index.
187
+ */
188
+ rootIndex: number;
189
+ /**
190
+ * Read only.
191
+ */
192
+ readOnly: boolean;
193
+ }
194
+ /**
195
+ * @deprecated use {@link createCompressedAccountMeta} instead.
196
+ */
197
+ export declare const createCompressedAccountLegacy: (owner: PublicKey, lamports?: BN, data?: CompressedAccountData, address?: number[]) => CompressedAccountLegacy;
198
+ /**
199
+ * @deprecated.
200
+ */
201
+ export declare const createCompressedAccountWithMerkleContextLegacy: (merkleContext: MerkleContext, owner: PublicKey, lamports?: BN, data?: CompressedAccountData, address?: number[]) => CompressedAccountWithMerkleContext;
202
+ /**
203
+ * @deprecated use {@link createCompressedAccountMeta} instead.
204
+ */
205
+ export declare const createMerkleContextLegacy: (treeInfo: TreeInfo, hash: BN254, leafIndex: number, proveByIndex?: boolean) => MerkleContext;
@@ -0,0 +1,4 @@
1
+ export * from './BN254';
2
+ export * from './bn';
3
+ export * from './compressed-account';
4
+ export * from './types';