@lightprotocol/stateless.js 0.17.2-alpha.0 → 0.17.2-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 (67) hide show
  1. package/dist/cjs/browser/constants.d.ts +2 -0
  2. package/dist/cjs/browser/idl.d.ts +1015 -0
  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 +1 -0
  6. package/dist/cjs/browser/rpc-interface.d.ts +110 -117
  7. package/dist/cjs/browser/rpc.d.ts +2 -57
  8. package/dist/cjs/browser/state/types.d.ts +5 -0
  9. package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +2 -3
  10. package/dist/cjs/browser/utils/test-utils.d.ts +8 -0
  11. package/dist/cjs/node/constants.d.ts +2 -0
  12. package/dist/cjs/node/idl.d.ts +1015 -0
  13. package/dist/cjs/node/index.cjs +1 -1
  14. package/dist/cjs/node/index.cjs.map +1 -1
  15. package/dist/cjs/node/index.d.ts +1 -0
  16. package/dist/cjs/node/rpc-interface.d.ts +110 -117
  17. package/dist/cjs/node/rpc.d.ts +2 -57
  18. package/dist/cjs/node/state/types.d.ts +5 -0
  19. package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +2 -3
  20. package/dist/cjs/node/utils/test-utils.d.ts +8 -0
  21. package/dist/types/index.d.ts +1036 -193
  22. package/package.json +9 -8
  23. package/dist/cjs/browser/connection-interface.d.ts +0 -125
  24. package/dist/cjs/node/connection-interface.d.ts +0 -125
  25. package/dist/es/browser/actions/common.d.ts +0 -3
  26. package/dist/es/browser/actions/compress.d.ts +0 -16
  27. package/dist/es/browser/actions/create-account.d.ts +0 -41
  28. package/dist/es/browser/actions/decompress.d.ts +0 -16
  29. package/dist/es/browser/actions/index.d.ts +0 -5
  30. package/dist/es/browser/actions/transfer.d.ts +0 -20
  31. package/dist/es/browser/connection-interface.d.ts +0 -125
  32. package/dist/es/browser/constants.d.ts +0 -63
  33. package/dist/es/browser/errors.d.ts +0 -74
  34. package/dist/es/browser/index.d.ts +0 -10
  35. package/dist/es/browser/index.js +0 -2
  36. package/dist/es/browser/index.js.map +0 -1
  37. package/dist/es/browser/instruction/index.d.ts +0 -1
  38. package/dist/es/browser/instruction/pack-compressed-accounts.d.ts +0 -35
  39. package/dist/es/browser/programs/index.d.ts +0 -2
  40. package/dist/es/browser/programs/layout.d.ts +0 -25
  41. package/dist/es/browser/programs/system.d.ts +0 -199
  42. package/dist/es/browser/rpc-interface.d.ts +0 -1179
  43. package/dist/es/browser/rpc.d.ts +0 -330
  44. package/dist/es/browser/state/BN254.d.ts +0 -14
  45. package/dist/es/browser/state/compressed-account.d.ts +0 -31
  46. package/dist/es/browser/state/index.d.ts +0 -3
  47. package/dist/es/browser/state/types.d.ts +0 -91
  48. package/dist/es/browser/test-helpers/index.d.ts +0 -2
  49. package/dist/es/browser/test-helpers/merkle-tree/index.d.ts +0 -2
  50. package/dist/es/browser/test-helpers/merkle-tree/indexed-array.d.ts +0 -85
  51. package/dist/es/browser/test-helpers/merkle-tree/merkle-tree.d.ts +0 -92
  52. package/dist/es/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +0 -7
  53. package/dist/es/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +0 -40
  54. package/dist/es/browser/test-helpers/test-rpc/get-parsed-events.d.ts +0 -13
  55. package/dist/es/browser/test-helpers/test-rpc/index.d.ts +0 -3
  56. package/dist/es/browser/test-helpers/test-rpc/test-rpc.d.ts +0 -250
  57. package/dist/es/browser/utils/address.d.ts +0 -63
  58. package/dist/es/browser/utils/airdrop.d.ts +0 -7
  59. package/dist/es/browser/utils/calculate-compute-unit-price.d.ts +0 -7
  60. package/dist/es/browser/utils/conversion.d.ts +0 -31
  61. package/dist/es/browser/utils/index.d.ts +0 -10
  62. package/dist/es/browser/utils/parse-validity-proof.d.ts +0 -20
  63. package/dist/es/browser/utils/pipe.d.ts +0 -2
  64. package/dist/es/browser/utils/send-and-confirm.d.ts +0 -52
  65. package/dist/es/browser/utils/sleep.d.ts +0 -1
  66. package/dist/es/browser/utils/test-utils.d.ts +0 -23
  67. package/dist/es/browser/utils/validation.d.ts +0 -4
@@ -1,330 +0,0 @@
1
- import { Connection, ConnectionConfig, Commitment, PublicKey, BlockhashWithExpiryBlockHeight, RpcResponseAndContext, GetBalanceConfig, GetSupplyConfig, Supply, GetTokenAccountsByOwnerConfig, GetProgramAccountsResponse, TokenAccountsFilter, AccountInfo, GetMultipleAccountsConfig, StakeActivationData, GetStakeActivationConfig, GetRecentPrioritizationFeesConfig, RecentPrioritizationFees, GetLatestBlockhashConfig, Version, ParsedConfirmedTransaction, GetAccountInfoConfig, GetLargestAccountsConfig, TokenAccountBalancePair, AccountBalancePair, ParsedAccountData, Finality, TransactionSignature, ConfirmedSignatureInfo, AddressLookupTableAccount, ParsedNoneModeBlockResponse, TokenAmount, GetNonceAndContextConfig, NonceAccount, GetNonceConfig, GetProgramAccountsConfig, GetParsedProgramAccountsConfig, Blockhash, IsBlockhashValidConfig, GetVersionedBlockConfig, ParsedAccountsModeBlockResponse, ConfirmedTransaction, ConfirmedSignaturesForAddress2Options, SignaturesForAddressOptions } from '@solana/web3.js';
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';
5
- import BN from 'bn.js';
6
- /** @internal */
7
- export declare function parseAccountData({ discriminator, data, dataHash, }: {
8
- discriminator: BN;
9
- data: string;
10
- dataHash: BN;
11
- }): {
12
- discriminator: number[];
13
- data: Buffer;
14
- dataHash: number[];
15
- };
16
- /**
17
- * Establish a Compression-compatible JSON RPC connection
18
- *
19
- * @param endpointOrWeb3JsConnection endpoint to the solana cluster or
20
- * Connection object
21
- * @param compressionApiEndpoint Endpoint to the compression server
22
- * @param proverEndpoint Endpoint to the prover server. defaults
23
- * to endpoint
24
- * @param connectionConfig Optional connection config
25
- */
26
- export declare function createRpc(endpointOrWeb3JsConnection?: string | Connection, compressionApiEndpoint?: string, proverEndpoint?: string, config?: ConnectionConfig): Rpc;
27
- /** @internal */
28
- export declare const rpcRequest: (rpcEndpoint: string, method: string, params?: any, convertToCamelCase?: boolean, debug?: boolean) => Promise<any>;
29
- /** @internal */
30
- export declare const proverRequest: (proverEndpoint: string, method: "inclusion" | "new-address" | "combined", params?: any, log?: boolean, publicInputHash?: BN | undefined) => Promise<CompressedProof>;
31
- export type NonInclusionMerkleProofInputs = {
32
- root: BN;
33
- value: BN;
34
- leaf_lower_range_value: BN;
35
- leaf_higher_range_value: BN;
36
- nextIndex: BN;
37
- merkle_proof_hashed_indexed_element_leaf: BN[];
38
- index_hashed_indexed_element_leaf: BN;
39
- };
40
- export type MerkleContextWithNewAddressProof = {
41
- root: BN;
42
- rootIndex: number;
43
- value: BN;
44
- leafLowerRangeValue: BN;
45
- leafHigherRangeValue: BN;
46
- nextIndex: BN;
47
- merkleProofHashedIndexedElementLeaf: BN[];
48
- indexHashedIndexedElementLeaf: BN;
49
- merkleTree: PublicKey;
50
- nullifierQueue: PublicKey;
51
- };
52
- export type NonInclusionJsonStruct = {
53
- root: string;
54
- value: string;
55
- pathIndex: number;
56
- pathElements: string[];
57
- leafLowerRangeValue: string;
58
- leafHigherRangeValue: string;
59
- nextIndex: number;
60
- };
61
- export declare function convertMerkleProofsWithContextToHex(merkleProofsWithContext: MerkleContextWithMerkleProof[]): HexInputsForProver[];
62
- export declare function convertNonInclusionMerkleProofInputsToHex(nonInclusionMerkleProofInputs: MerkleContextWithNewAddressProof[]): NonInclusionJsonStruct[];
63
- import { LightWasm } from './test-helpers';
64
- import { ConnectionInterface } from './connection-interface';
65
- export declare function getPublicInputHash(accountProofs: MerkleContextWithMerkleProof[], accountHashes: BN254[], newAddressProofs: MerkleContextWithNewAddressProof[], lightWasm: LightWasm): BN;
66
- /**
67
- *
68
- */
69
- export declare class Rpc extends Connection implements ConnectionInterface, CompressionApiInterface {
70
- connection: Connection;
71
- compressionApiEndpoint: string;
72
- proverEndpoint: string;
73
- /**
74
- * Establish a Compression-compatible JSON RPC connection
75
- *
76
- * @param endpoint Endpoint to the solana cluster
77
- * @param compressionApiEndpoint Endpoint to the compression server
78
- * @param proverEndpoint Endpoint to the prover server.
79
- * @param connectionConfig Optional connection config
80
- */
81
- constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
82
- get commitment(): Commitment | undefined;
83
- get rpcEndpoint(): string;
84
- getBalanceAndContext(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetBalanceConfig): Promise<RpcResponseAndContext<number>>;
85
- getBalance(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetBalanceConfig): Promise<number>;
86
- getBlockTime(slot: number): Promise<number | null>;
87
- getMinimumLedgerSlot(): Promise<number>;
88
- getFirstAvailableBlock(): Promise<number>;
89
- getSupply(config?: GetSupplyConfig | Commitment): Promise<RpcResponseAndContext<Supply>>;
90
- getTokenSupply(tokenMintAddress: PublicKey, commitment?: Commitment): Promise<RpcResponseAndContext<TokenAmount>>;
91
- getTokenAccountBalance(tokenAddress: PublicKey, commitment?: Commitment): Promise<RpcResponseAndContext<TokenAmount>>;
92
- getTokenAccountsByOwner(ownerAddress: PublicKey, filter: TokenAccountsFilter, commitmentOrConfig?: Commitment | GetTokenAccountsByOwnerConfig): Promise<RpcResponseAndContext<GetProgramAccountsResponse>>;
93
- getParsedTokenAccountsByOwner(ownerAddress: PublicKey, filter: TokenAccountsFilter, commitment?: Commitment): Promise<RpcResponseAndContext<Array<{
94
- pubkey: PublicKey;
95
- account: AccountInfo<ParsedAccountData>;
96
- }>>>;
97
- getLargestAccounts(config?: GetLargestAccountsConfig): Promise<RpcResponseAndContext<Array<AccountBalancePair>>>;
98
- getTokenLargestAccounts(mintAddress: PublicKey, commitment?: Commitment): Promise<RpcResponseAndContext<Array<TokenAccountBalancePair>>>;
99
- getAccountInfoAndContext(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<RpcResponseAndContext<AccountInfo<Buffer> | null>>;
100
- getParsedAccountInfo(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<RpcResponseAndContext<AccountInfo<Buffer | ParsedAccountData> | null>>;
101
- getAccountInfo(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetAccountInfoConfig): Promise<AccountInfo<Buffer> | null>;
102
- getMultipleParsedAccounts(publicKeys: PublicKey[], rawConfig?: GetMultipleAccountsConfig): Promise<RpcResponseAndContext<(AccountInfo<Buffer | ParsedAccountData> | null)[]>>;
103
- getMultipleAccountsInfoAndContext(publicKeys: PublicKey[], commitmentOrConfig?: Commitment | GetMultipleAccountsConfig): Promise<RpcResponseAndContext<(AccountInfo<Buffer> | null)[]>>;
104
- getMultipleAccountsInfo(publicKeys: PublicKey[], commitmentOrConfig?: Commitment | GetMultipleAccountsConfig): Promise<(AccountInfo<Buffer> | null)[]>;
105
- getStakeActivation(publicKey: PublicKey, commitmentOrConfig?: Commitment | GetStakeActivationConfig, epoch?: number): Promise<StakeActivationData>;
106
- getProgramAccounts(programId: PublicKey, configOrCommitment?: GetProgramAccountsConfig | Commitment): Promise<GetProgramAccountsResponse>;
107
- getProgramAccounts(programId: PublicKey, configOrCommitment: GetProgramAccountsConfig & {
108
- withContext: true;
109
- }): Promise<RpcResponseAndContext<GetProgramAccountsResponse>>;
110
- getParsedProgramAccounts(programId: PublicKey, configOrCommitment?: GetParsedProgramAccountsConfig | Commitment): Promise<Array<{
111
- pubkey: PublicKey;
112
- account: AccountInfo<Buffer | ParsedAccountData>;
113
- }>>;
114
- getParsedBlock(slot: number, rawConfig?: GetVersionedBlockConfig): Promise<ParsedAccountsModeBlockResponse>;
115
- getParsedBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
116
- transactionDetails: 'accounts';
117
- }): Promise<ParsedAccountsModeBlockResponse>;
118
- getParsedBlock(slot: number, rawConfig: GetVersionedBlockConfig & {
119
- transactionDetails: 'none';
120
- }): Promise<ParsedNoneModeBlockResponse>;
121
- getConfirmedTransaction(signature: TransactionSignature, commitment?: Finality): Promise<ConfirmedTransaction | null>;
122
- getParsedConfirmedTransaction(signature: TransactionSignature, commitment?: Finality): Promise<ParsedConfirmedTransaction | null>;
123
- getParsedConfirmedTransactions(signatures: TransactionSignature[], commitment?: Finality): Promise<(ParsedConfirmedTransaction | null)[]>;
124
- getConfirmedSignaturesForAddress(address: PublicKey, startSlot: number, endSlot: number): Promise<Array<TransactionSignature>>;
125
- getConfirmedSignaturesForAddress2(address: PublicKey, options?: ConfirmedSignaturesForAddress2Options, commitment?: Finality): Promise<Array<ConfirmedSignatureInfo>>;
126
- getSignaturesForAddress(address: PublicKey, options?: SignaturesForAddressOptions, commitment?: Finality): Promise<Array<ConfirmedSignatureInfo>>;
127
- getRecentPrioritizationFees(config?: GetRecentPrioritizationFeesConfig): Promise<RecentPrioritizationFees[]>;
128
- getLatestBlockhash(config?: GetLatestBlockhashConfig): Promise<BlockhashWithExpiryBlockHeight>;
129
- getLatestBlockhashAndContext(commitmentOrConfig?: Commitment | GetLatestBlockhashConfig): Promise<RpcResponseAndContext<BlockhashWithExpiryBlockHeight>>;
130
- isBlockhashValid(blockhash: Blockhash, config?: IsBlockhashValidConfig): Promise<RpcResponseAndContext<boolean>>;
131
- getVersion(): Promise<Version>;
132
- getAddressLookupTable(accountKey: PublicKey, config?: GetAccountInfoConfig): Promise<RpcResponseAndContext<AddressLookupTableAccount | null>>;
133
- getNonceAndContext(nonceAccount: PublicKey, commitmentOrConfig?: Commitment | GetNonceAndContextConfig): Promise<RpcResponseAndContext<NonceAccount | null>>;
134
- getNonce(nonceAccount: PublicKey, commitmentOrConfig?: Commitment | GetNonceConfig): Promise<NonceAccount | null>;
135
- /**
136
- * Fetch the compressed account for the specified account address or hash
137
- */
138
- getCompressedAccount(address?: BN254, hash?: BN254): Promise<CompressedAccountWithMerkleContext | null>;
139
- /**
140
- * Fetch the compressed balance for the specified account address or hash
141
- */
142
- getCompressedBalance(address?: BN254, hash?: BN254): Promise<BN>;
143
- /**
144
- * Fetch the total compressed balance for the specified owner public key
145
- */
146
- getCompressedBalanceByOwner(owner: PublicKey): Promise<BN>;
147
- /**
148
- * Fetch the latest merkle proof for the specified account hash from the
149
- * cluster
150
- */
151
- getCompressedAccountProof(hash: BN254): Promise<MerkleContextWithMerkleProof>;
152
- /**
153
- * Fetch all the account info for multiple compressed accounts specified by
154
- * an array of account hashes
155
- */
156
- getMultipleCompressedAccounts(hashes: BN254[]): Promise<CompressedAccountWithMerkleContext[]>;
157
- /**
158
- * Fetch the latest merkle proofs for multiple compressed accounts specified
159
- * by an array account hashes
160
- */
161
- getMultipleCompressedAccountProofs(hashes: BN254[]): Promise<MerkleContextWithMerkleProof[]>;
162
- /**
163
- * Fetch all the compressed accounts owned by the specified public key.
164
- * Owner can be a program or user account
165
- */
166
- getCompressedAccountsByOwner(owner: PublicKey, config?: GetCompressedAccountsByOwnerConfig | undefined): Promise<WithCursor<CompressedAccountWithMerkleContext[]>>;
167
- /**
168
- * Fetch all the compressed token accounts owned by the specified public
169
- * key. Owner can be a program or user account
170
- */
171
- getCompressedTokenAccountsByOwner(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<ParsedTokenAccount[]>>;
172
- /**
173
- * Fetch all the compressed accounts delegated to the specified public key.
174
- */
175
- getCompressedTokenAccountsByDelegate(delegate: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<ParsedTokenAccount[]>>;
176
- /**
177
- * Fetch the compressed token balance for the specified account hash
178
- */
179
- getCompressedTokenAccountBalance(hash: BN254): Promise<{
180
- amount: BN;
181
- }>;
182
- /**
183
- * @deprecated use {@link getCompressedTokenBalancesByOwnerV2} instead.
184
- *
185
- * Fetch all the compressed token balances owned by the specified public
186
- * key. Can filter by mint. Returns without context.
187
- */
188
- getCompressedTokenBalancesByOwner(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<TokenBalance[]>>;
189
- /**
190
- * Fetch the compressed token balances owned by the specified public
191
- * key. Paginated. Can filter by mint. Returns with context.
192
- */
193
- getCompressedTokenBalancesByOwnerV2(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithContext<WithCursor<TokenBalance[]>>>;
194
- /**
195
- * Returns confirmed compression signatures for transactions involving the specified
196
- * account hash forward in time from genesis to the most recent confirmed
197
- * block
198
- *
199
- * @param hash queried account hash
200
- */
201
- getCompressionSignaturesForAccount(hash: BN254): Promise<SignatureWithMetadata[]>;
202
- /**
203
- * Fetch a confirmed or finalized transaction from the cluster. Return with
204
- * CompressionInfo
205
- */
206
- getTransactionWithCompressionInfo(signature: string): Promise<CompressedTransaction | null>;
207
- /**
208
- * Returns confirmed signatures for transactions involving the specified
209
- * address forward in time from genesis to the most recent confirmed block
210
- *
211
- * @param address queried compressed account address
212
- */
213
- getCompressionSignaturesForAddress(address: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
214
- /**
215
- * Returns confirmed signatures for compression transactions involving the
216
- * specified account owner forward in time from genesis to the
217
- * most recent confirmed block
218
- *
219
- * @param owner queried owner public key
220
- */
221
- getCompressionSignaturesForOwner(owner: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
222
- /**
223
- * Returns confirmed signatures for compression transactions involving the
224
- * specified token account owner forward in time from genesis to the most
225
- * recent confirmed block
226
- */
227
- getCompressionSignaturesForTokenOwner(owner: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
228
- /**
229
- * Fetch the current indexer health status
230
- */
231
- getIndexerHealth(): Promise<string>;
232
- /**
233
- * Ensure that the Compression Indexer has already indexed the transaction
234
- */
235
- confirmTransactionIndexed(slot: number): Promise<boolean>;
236
- /**
237
- * Fetch the current slot that the node is processing
238
- */
239
- getIndexerSlot(): Promise<number>;
240
- /**
241
- * Fetch all the compressed token holders for a given mint. Paginated.
242
- */
243
- getCompressedMintTokenHolders(mint: PublicKey, options?: PaginatedOptions): Promise<WithContext<WithCursor<CompressedMintTokenHolders[]>>>;
244
- /**
245
- * Fetch the latest compression signatures on the cluster. Results are
246
- * paginated.
247
- */
248
- getLatestCompressionSignatures(cursor?: string, limit?: number): Promise<LatestNonVotingSignaturesPaginated>;
249
- /**
250
- * Fetch all non-voting signatures
251
- */
252
- getLatestNonVotingSignatures(limit?: number, cursor?: string): Promise<LatestNonVotingSignatures>;
253
- /**
254
- * Fetch the latest address proofs for new unique addresses specified by an
255
- * array of addresses.
256
- *
257
- * the proof states that said address have not yet been created in
258
- * respective address tree.
259
- * @param addresses Array of BN254 new addresses
260
- * @returns Array of validity proofs for new addresses
261
- */
262
- getMultipleNewAddressProofs(addresses: BN254[]): Promise<MerkleContextWithNewAddressProof[]>;
263
- /**
264
- * Advanced usage of getValidityProof: fetches ZKP directly from a custom
265
- * non-rpcprover. Note: This uses the proverEndpoint specified in the
266
- * constructor. For normal usage, please use {@link getValidityProof}
267
- * instead.
268
- *
269
- * Fetch the latest validity proof for (1) compressed accounts specified by
270
- * an array of account hashes. (2) new unique addresses specified by an
271
- * array of addresses.
272
- *
273
- * Validity proofs prove the presence of compressed accounts in state trees
274
- * and the non-existence of addresses in address trees, respectively. They
275
- * enable verification without recomputing the merkle proof path, thus
276
- * lowering verification and data costs.
277
- *
278
- * @param hashes Array of BN254 hashes.
279
- * @param newAddresses Array of BN254 new addresses.
280
- * @returns validity proof with context
281
- */
282
- getValidityProofDirect(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
283
- /**
284
- * Fetch the latest validity proof for (1) compressed accounts specified by
285
- * an array of account hashes. (2) new unique addresses specified by an
286
- * array of addresses.
287
- *
288
- * Validity proofs prove the presence of compressed accounts in state trees
289
- * and the non-existence of addresses in address trees, respectively. They
290
- * enable verification without recomputing the merkle proof path, thus
291
- * lowering verification and data costs.
292
- *
293
- * @param hashes Array of BN254 hashes.
294
- * @param newAddresses Array of BN254 new addresses.
295
- * @returns validity proof with context
296
- */
297
- getValidityProof(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
298
- /**
299
- * Fetch the latest validity proof for (1) compressed accounts specified by
300
- * an array of account hashes. (2) new unique addresses specified by an
301
- * array of addresses.
302
- *
303
- * Validity proofs prove the presence of compressed accounts in state trees
304
- * and the non-existence of addresses in address trees, respectively. They
305
- * enable verification without recomputing the merkle proof path, thus
306
- * lowering verification and data costs.
307
- *
308
- * @param hashes Array of { hash: BN254, tree: PublicKey, queue: PublicKey }.
309
- * @param newAddresses Array of { address: BN254, tree: PublicKey, queue: PublicKey }.
310
- * @returns validity proof with context
311
- */
312
- getValidityProofV0(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<CompressedProofWithContext>;
313
- /**
314
- * Fetch the latest validity proof for (1) compressed accounts specified by
315
- * an array of account hashes. (2) new unique addresses specified by an
316
- * array of addresses. Returns with context slot.
317
- *
318
- * Validity proofs prove the presence of compressed accounts in state trees
319
- * and the non-existence of addresses in address trees, respectively. They
320
- * enable verification without recomputing the merkle proof path, thus
321
- * lowering verification and data costs.
322
- *
323
- * @param hashes Array of BN254 hashes.
324
- * @param newAddresses Array of BN254 new addresses. Optionally specify the
325
- * tree and queue for each address. Default to public
326
- * state tree/queue.
327
- * @returns validity proof with context
328
- */
329
- getValidityProofAndRpcContext(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<WithContext<CompressedProofWithContext>>;
330
- }
@@ -1,14 +0,0 @@
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
- export declare const bn: (number: string | number | BN | Buffer | Uint8Array | number[], base?: number | "hex" | undefined, endian?: BN.Endianness | undefined) => BN;
11
- /** 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;
13
- /** Convert <254-bit bigint to Base58 string. */
14
- export declare function encodeBN254toBase58(bigintNumber: BN): string;
@@ -1,31 +0,0 @@
1
- import BN from 'bn.js';
2
- import { PublicKey } from '@solana/web3.js';
3
- import { CompressedAccount, CompressedAccountData } from './types';
4
- import { BN254 } from './BN254';
5
- export type CompressedAccountWithMerkleContext = CompressedAccount & MerkleContext & {
6
- readOnly: boolean;
7
- };
8
- /**
9
- * Context for compressed account inserted into a state Merkle tree
10
- * */
11
- export type MerkleContext = {
12
- /** State Merkle tree */
13
- merkleTree: PublicKey;
14
- /** The state nullfier queue belonging to merkleTree */
15
- nullifierQueue: PublicKey;
16
- /** Poseidon hash of the utxo preimage. Is a leaf in state merkle tree */
17
- hash: number[];
18
- /** 'hash' position within the Merkle tree */
19
- leafIndex: number;
20
- };
21
- export type MerkleContextWithMerkleProof = MerkleContext & {
22
- /** Recent valid 'hash' proof path, expires after n slots */
23
- merkleProof: BN254[];
24
- /** Index of state root the merkleproof is valid for, expires after n slots */
25
- rootIndex: number;
26
- /** Current root */
27
- root: BN254;
28
- };
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;
@@ -1,3 +0,0 @@
1
- export * from './BN254';
2
- export * from './compressed-account';
3
- export * from './types';
@@ -1,91 +0,0 @@
1
- import BN from 'bn.js';
2
- import { PublicKey } from '@solana/web3.js';
3
- import { Buffer } from 'buffer';
4
- import { NewAddressParamsPacked } from '../utils';
5
- export interface PackedCompressedAccountWithMerkleContext {
6
- compressedAccount: CompressedAccount;
7
- merkleContext: PackedMerkleContext;
8
- rootIndex: number;
9
- readOnly: boolean;
10
- }
11
- export interface PackedMerkleContext {
12
- merkleTreePubkeyIndex: number;
13
- nullifierQueuePubkeyIndex: number;
14
- leafIndex: number;
15
- queueIndex: null | QueueIndex;
16
- }
17
- export interface QueueIndex {
18
- queueId: number;
19
- index: number;
20
- }
21
- /**
22
- * Describe the generic compressed account details applicable to every
23
- * compressed account.
24
- * */
25
- export interface CompressedAccount {
26
- /** Public key of program or user that owns the account */
27
- owner: PublicKey;
28
- /** Lamports attached to the account */
29
- lamports: BN;
30
- /**
31
- * TODO: use PublicKey. Optional unique account ID that is persistent across
32
- * transactions.
33
- */
34
- address: number[] | null;
35
- /** Optional data attached to the account */
36
- data: CompressedAccountData | null;
37
- }
38
- /**
39
- * Describe the generic compressed account details applicable to every
40
- * compressed account.
41
- * */
42
- export interface OutputCompressedAccountWithPackedContext {
43
- compressedAccount: CompressedAccount;
44
- merkleTreeIndex: number;
45
- }
46
- export interface CompressedAccountData {
47
- discriminator: number[];
48
- data: Buffer;
49
- dataHash: number[];
50
- }
51
- export interface PublicTransactionEvent {
52
- inputCompressedAccountHashes: number[][];
53
- outputCompressedAccountHashes: number[][];
54
- outputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
55
- outputLeafIndices: number[];
56
- relayFee: BN | null;
57
- isCompress: boolean;
58
- compressOrDecompressLamports: BN | null;
59
- pubkeyArray: PublicKey[];
60
- message: Uint8Array | null;
61
- }
62
- export interface InstructionDataInvoke {
63
- proof: CompressedProof | null;
64
- inputCompressedAccountsWithMerkleContext: PackedCompressedAccountWithMerkleContext[];
65
- outputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
66
- relayFee: BN | null;
67
- newAddressParams: NewAddressParamsPacked[];
68
- compressOrDecompressLamports: BN | null;
69
- isCompress: boolean;
70
- }
71
- export interface CompressedProof {
72
- a: number[];
73
- b: number[];
74
- c: number[];
75
- }
76
- export interface InputTokenDataWithContext {
77
- amount: BN;
78
- delegateIndex: number | null;
79
- merkleContext: PackedMerkleContext;
80
- rootIndex: number;
81
- lamports: BN | null;
82
- tlv: Buffer | null;
83
- }
84
- export type TokenData = {
85
- mint: PublicKey;
86
- owner: PublicKey;
87
- amount: BN;
88
- delegate: PublicKey | null;
89
- state: number;
90
- tlv: Buffer | null;
91
- };
@@ -1,2 +0,0 @@
1
- export * from './merkle-tree';
2
- export * from './test-rpc';
@@ -1,2 +0,0 @@
1
- export * from './indexed-array';
2
- export * from './merkle-tree';
@@ -1,85 +0,0 @@
1
- import { LightWasm } from '../test-rpc/test-rpc';
2
- import BN from 'bn.js';
3
- export declare class IndexedElement {
4
- index: number;
5
- value: BN;
6
- nextIndex: number;
7
- constructor(index: number, value: BN, nextIndex: number);
8
- equals(other: IndexedElement): boolean;
9
- compareTo(other: IndexedElement): number;
10
- hash(lightWasm: LightWasm, nextValue: BN): Uint8Array;
11
- }
12
- export declare class IndexedElementBundle {
13
- newLowElement: IndexedElement;
14
- newElement: IndexedElement;
15
- newElementNextValue: BN;
16
- constructor(newLowElement: IndexedElement, newElement: IndexedElement, newElementNextValue: BN);
17
- }
18
- /**
19
- * This indexed array implementation mirrors the rust implementation of the
20
- * indexed merkle tree. It stores the elements of the indexed merkle tree.
21
- */
22
- export declare class IndexedArray {
23
- elements: Array<IndexedElement>;
24
- currentNodeIndex: number;
25
- highestElementIndex: number;
26
- constructor(elements: Array<IndexedElement>, currentNodeIndex: number, highestElementIndex: number);
27
- static default(): IndexedArray;
28
- get(index: number): IndexedElement | undefined;
29
- length(): number;
30
- isEmpty(): boolean;
31
- findElement(value: BN): IndexedElement | undefined;
32
- init(): IndexedElementBundle;
33
- /**
34
- * Finds the index of the low element for the given `value` which should not be part of the array.
35
- * Low element is the greatest element which still has a lower value than the provided one.
36
- * Low elements are used in non-membership proofs.
37
- */
38
- findLowElementIndex(value: BN): number | undefined;
39
- /**
40
- * Returns the low element for the given value and the next value for that low element.
41
- * Low element is the greatest element which still has lower value than the provided one.
42
- * Low elements are used in non-membership proofs.
43
- */
44
- findLowElement(value: BN): [IndexedElement | undefined, BN | undefined];
45
- /**
46
- * Returns the hash of the given element. That hash consists of:
47
- * - The value of the given element.
48
- * - The `nextIndex` of the given element.
49
- * - The value of the element pointed by `nextIndex`.
50
- */
51
- hashElement(lightWasm: LightWasm, index: number): Uint8Array | undefined;
52
- /**
53
- * Appends a new element with the given value to the indexed array.
54
- * It finds the low element index and uses it to append the new element correctly.
55
- * @param value The value of the new element to append.
56
- * @returns The new element and its low element after insertion.
57
- */
58
- append(value: BN): IndexedElementBundle;
59
- /**
60
- * Appends a new element with the given value to the indexed array using a specific low element index.
61
- * This method ensures the new element is placed correctly relative to the low element.
62
- * @param lowElementIndex The index of the low element.
63
- * @param value The value of the new element to append.
64
- * @returns The new element and its updated low element.
65
- */
66
- appendWithLowElementIndex(lowElementIndex: number, value: BN): IndexedElementBundle;
67
- /**
68
- * Finds the lowest element in the array.
69
- * @returns The lowest element or undefined if the array is empty.
70
- */
71
- lowest(): IndexedElement | undefined;
72
- /**
73
- * Creates a new element with the specified value and updates the low element index accordingly.
74
- * @param lowElementIndex The index of the low element.
75
- * @param value The value for the new element.
76
- * @returns A bundle containing the new element, the updated low element, and the value of the next element.
77
- */
78
- newElementWithLowElementIndex(lowElementIndex: number, value: BN): IndexedElementBundle;
79
- /**
80
- * Creates a new element with the specified value by first finding the appropriate low element index.
81
- * @param value The value for the new element.
82
- * @returns A bundle containing the new element, the updated low element, and the value of the next element.
83
- */
84
- newElement(value: BN): IndexedElementBundle;
85
- }
@@ -1,92 +0,0 @@
1
- import { LightWasm } from '../test-rpc/test-rpc';
2
- export declare const DEFAULT_ZERO = "0";
3
- /**
4
- * @callback hashFunction
5
- * @param left Left leaf
6
- * @param right Right leaf
7
- */
8
- /**
9
- * Merkle tree
10
- */
11
- export declare class MerkleTree {
12
- /**
13
- * Constructor
14
- * @param {number} levels Number of levels in the tree
15
- * @param {Array} [elements] Initial elements
16
- * @param {Object} options
17
- * @param {hashFunction} [options.hashFunction] Function used to hash 2 leaves
18
- * @param [options.zeroElement] Value for non-existent leaves
19
- */
20
- levels: number;
21
- capacity: number;
22
- zeroElement: string;
23
- _zeros: string[];
24
- _layers: string[][];
25
- _lightWasm: LightWasm;
26
- constructor(levels: number, lightWasm: LightWasm, elements?: string[], { zeroElement }?: {
27
- zeroElement?: string | undefined;
28
- });
29
- _rebuild(): void;
30
- /**
31
- * Get tree root
32
- * @returns {*}
33
- */
34
- root(): string;
35
- /**
36
- * Insert new element into the tree
37
- * @param element Element to insert
38
- */
39
- insert(element: string): void;
40
- /**
41
- * Insert multiple elements into the tree. Tree will be fully rebuilt during this operation.
42
- * @param {Array} elements Elements to insert
43
- */
44
- bulkInsert(elements: string[]): void;
45
- /**
46
- * Change an element in the tree
47
- * @param {number} index Index of element to change
48
- * @param element Updated element value
49
- */
50
- update(index: number, element: string): void;
51
- /**
52
- * Get merkle path to a leaf
53
- * @param {number} index Leaf index to generate path for
54
- * @returns {{pathElements: number[], pathIndex: number[]}} An object containing adjacent elements and left-right index
55
- */
56
- path(index: number): {
57
- pathElements: string[];
58
- pathIndices: number[];
59
- };
60
- /**
61
- * Find an element in the tree
62
- * @param element An element to find
63
- * @param comparator A function that checks leaf value equality
64
- * @returns {number} Index if element is found, otherwise -1
65
- */
66
- indexOf(element: string, comparator?: ((element: string, el: string) => boolean) | null): number;
67
- /**
68
- * Returns a copy of non-zero tree elements
69
- * @returns {Object[]}
70
- */
71
- elements(): string[];
72
- /**
73
- * Serialize entire tree state including intermediate layers into a plain object
74
- * Deserializing it back will not require to recompute any hashes
75
- * Elements are not converted to a plain type, this is responsibility of the caller
76
- */
77
- serialize(): {
78
- levels: number;
79
- _zeros: string[];
80
- _layers: string[][];
81
- };
82
- /**
83
- * Deserialize data into a MerkleTree instance
84
- * Make sure to provide the same hashFunction as was used in the source tree,
85
- * otherwise the tree state will be invalid
86
- *
87
- * @param data
88
- * @param hashFunction
89
- * @returns {MerkleTree}
90
- */
91
- static deserialize(data: any, hashFunction: (left: string, right: string) => string): any;
92
- }
@@ -1,7 +0,0 @@
1
- import { PublicKey } from '@solana/web3.js';
2
- import BN from 'bn.js';
3
- import { Rpc } from '../../rpc';
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[]>;