@lightprotocol/stateless.js 0.17.2-alpha.1 → 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 (60) 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 +107 -114
  7. package/dist/cjs/browser/state/types.d.ts +5 -0
  8. package/dist/cjs/browser/utils/test-utils.d.ts +8 -0
  9. package/dist/cjs/node/constants.d.ts +2 -0
  10. package/dist/cjs/node/idl.d.ts +1015 -0
  11. package/dist/cjs/node/index.cjs +1 -1
  12. package/dist/cjs/node/index.cjs.map +1 -1
  13. package/dist/cjs/node/index.d.ts +1 -0
  14. package/dist/cjs/node/rpc-interface.d.ts +107 -114
  15. package/dist/cjs/node/state/types.d.ts +5 -0
  16. package/dist/cjs/node/utils/test-utils.d.ts +8 -0
  17. package/dist/types/index.d.ts +1032 -9
  18. package/package.json +6 -5
  19. package/dist/es/browser/actions/common.d.ts +0 -3
  20. package/dist/es/browser/actions/compress.d.ts +0 -16
  21. package/dist/es/browser/actions/create-account.d.ts +0 -41
  22. package/dist/es/browser/actions/decompress.d.ts +0 -16
  23. package/dist/es/browser/actions/index.d.ts +0 -5
  24. package/dist/es/browser/actions/transfer.d.ts +0 -20
  25. package/dist/es/browser/constants.d.ts +0 -63
  26. package/dist/es/browser/errors.d.ts +0 -74
  27. package/dist/es/browser/index.d.ts +0 -10
  28. package/dist/es/browser/index.js +0 -2
  29. package/dist/es/browser/index.js.map +0 -1
  30. package/dist/es/browser/instruction/index.d.ts +0 -1
  31. package/dist/es/browser/instruction/pack-compressed-accounts.d.ts +0 -35
  32. package/dist/es/browser/programs/index.d.ts +0 -2
  33. package/dist/es/browser/programs/layout.d.ts +0 -25
  34. package/dist/es/browser/programs/system.d.ts +0 -199
  35. package/dist/es/browser/rpc-interface.d.ts +0 -1179
  36. package/dist/es/browser/rpc.d.ts +0 -275
  37. package/dist/es/browser/state/BN254.d.ts +0 -14
  38. package/dist/es/browser/state/compressed-account.d.ts +0 -31
  39. package/dist/es/browser/state/index.d.ts +0 -3
  40. package/dist/es/browser/state/types.d.ts +0 -91
  41. package/dist/es/browser/test-helpers/index.d.ts +0 -2
  42. package/dist/es/browser/test-helpers/merkle-tree/index.d.ts +0 -2
  43. package/dist/es/browser/test-helpers/merkle-tree/indexed-array.d.ts +0 -85
  44. package/dist/es/browser/test-helpers/merkle-tree/merkle-tree.d.ts +0 -92
  45. package/dist/es/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +0 -7
  46. package/dist/es/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +0 -40
  47. package/dist/es/browser/test-helpers/test-rpc/get-parsed-events.d.ts +0 -13
  48. package/dist/es/browser/test-helpers/test-rpc/index.d.ts +0 -3
  49. package/dist/es/browser/test-helpers/test-rpc/test-rpc.d.ts +0 -249
  50. package/dist/es/browser/utils/address.d.ts +0 -63
  51. package/dist/es/browser/utils/airdrop.d.ts +0 -7
  52. package/dist/es/browser/utils/calculate-compute-unit-price.d.ts +0 -7
  53. package/dist/es/browser/utils/conversion.d.ts +0 -31
  54. package/dist/es/browser/utils/index.d.ts +0 -10
  55. package/dist/es/browser/utils/parse-validity-proof.d.ts +0 -20
  56. package/dist/es/browser/utils/pipe.d.ts +0 -2
  57. package/dist/es/browser/utils/send-and-confirm.d.ts +0 -52
  58. package/dist/es/browser/utils/sleep.d.ts +0 -1
  59. package/dist/es/browser/utils/test-utils.d.ts +0 -23
  60. package/dist/es/browser/utils/validation.d.ts +0 -4
@@ -1,275 +0,0 @@
1
- import { Connection, ConnectionConfig, PublicKey } 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
- export declare function getPublicInputHash(accountProofs: MerkleContextWithMerkleProof[], accountHashes: BN254[], newAddressProofs: MerkleContextWithNewAddressProof[], lightWasm: LightWasm): BN;
65
- /**
66
- *
67
- */
68
- export declare class Rpc extends Connection implements CompressionApiInterface {
69
- compressionApiEndpoint: string;
70
- proverEndpoint: string;
71
- /**
72
- * Establish a Compression-compatible JSON RPC connection
73
- *
74
- * @param endpoint Endpoint to the solana cluster
75
- * @param compressionApiEndpoint Endpoint to the compression server
76
- * @param proverEndpoint Endpoint to the prover server.
77
- * @param connectionConfig Optional connection config
78
- */
79
- constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
80
- /**
81
- * Fetch the compressed account for the specified account address or hash
82
- */
83
- getCompressedAccount(address?: BN254, hash?: BN254): Promise<CompressedAccountWithMerkleContext | null>;
84
- /**
85
- * Fetch the compressed balance for the specified account address or hash
86
- */
87
- getCompressedBalance(address?: BN254, hash?: BN254): Promise<BN>;
88
- /**
89
- * Fetch the total compressed balance for the specified owner public key
90
- */
91
- getCompressedBalanceByOwner(owner: PublicKey): Promise<BN>;
92
- /**
93
- * Fetch the latest merkle proof for the specified account hash from the
94
- * cluster
95
- */
96
- getCompressedAccountProof(hash: BN254): Promise<MerkleContextWithMerkleProof>;
97
- /**
98
- * Fetch all the account info for multiple compressed accounts specified by
99
- * an array of account hashes
100
- */
101
- getMultipleCompressedAccounts(hashes: BN254[]): Promise<CompressedAccountWithMerkleContext[]>;
102
- /**
103
- * Fetch the latest merkle proofs for multiple compressed accounts specified
104
- * by an array account hashes
105
- */
106
- getMultipleCompressedAccountProofs(hashes: BN254[]): Promise<MerkleContextWithMerkleProof[]>;
107
- /**
108
- * Fetch all the compressed accounts owned by the specified public key.
109
- * Owner can be a program or user account
110
- */
111
- getCompressedAccountsByOwner(owner: PublicKey, config?: GetCompressedAccountsByOwnerConfig | undefined): Promise<WithCursor<CompressedAccountWithMerkleContext[]>>;
112
- /**
113
- * Fetch all the compressed token accounts owned by the specified public
114
- * key. Owner can be a program or user account
115
- */
116
- getCompressedTokenAccountsByOwner(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<ParsedTokenAccount[]>>;
117
- /**
118
- * Fetch all the compressed accounts delegated to the specified public key.
119
- */
120
- getCompressedTokenAccountsByDelegate(delegate: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<ParsedTokenAccount[]>>;
121
- /**
122
- * Fetch the compressed token balance for the specified account hash
123
- */
124
- getCompressedTokenAccountBalance(hash: BN254): Promise<{
125
- amount: BN;
126
- }>;
127
- /**
128
- * @deprecated use {@link getCompressedTokenBalancesByOwnerV2} instead.
129
- *
130
- * Fetch all the compressed token balances owned by the specified public
131
- * key. Can filter by mint. Returns without context.
132
- */
133
- getCompressedTokenBalancesByOwner(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithCursor<TokenBalance[]>>;
134
- /**
135
- * Fetch the compressed token balances owned by the specified public
136
- * key. Paginated. Can filter by mint. Returns with context.
137
- */
138
- getCompressedTokenBalancesByOwnerV2(owner: PublicKey, options?: GetCompressedTokenAccountsByOwnerOrDelegateOptions): Promise<WithContext<WithCursor<TokenBalance[]>>>;
139
- /**
140
- * Returns confirmed compression signatures for transactions involving the specified
141
- * account hash forward in time from genesis to the most recent confirmed
142
- * block
143
- *
144
- * @param hash queried account hash
145
- */
146
- getCompressionSignaturesForAccount(hash: BN254): Promise<SignatureWithMetadata[]>;
147
- /**
148
- * Fetch a confirmed or finalized transaction from the cluster. Return with
149
- * CompressionInfo
150
- */
151
- getTransactionWithCompressionInfo(signature: string): Promise<CompressedTransaction | null>;
152
- /**
153
- * Returns confirmed signatures for transactions involving the specified
154
- * address forward in time from genesis to the most recent confirmed block
155
- *
156
- * @param address queried compressed account address
157
- */
158
- getCompressionSignaturesForAddress(address: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
159
- /**
160
- * Returns confirmed signatures for compression transactions involving the
161
- * specified account owner forward in time from genesis to the
162
- * most recent confirmed block
163
- *
164
- * @param owner queried owner public key
165
- */
166
- getCompressionSignaturesForOwner(owner: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
167
- /**
168
- * Returns confirmed signatures for compression transactions involving the
169
- * specified token account owner forward in time from genesis to the most
170
- * recent confirmed block
171
- */
172
- getCompressionSignaturesForTokenOwner(owner: PublicKey, options?: PaginatedOptions): Promise<WithCursor<SignatureWithMetadata[]>>;
173
- /**
174
- * Fetch the current indexer health status
175
- */
176
- getIndexerHealth(): Promise<string>;
177
- /**
178
- * Ensure that the Compression Indexer has already indexed the transaction
179
- */
180
- confirmTransactionIndexed(slot: number): Promise<boolean>;
181
- /**
182
- * Fetch the current slot that the node is processing
183
- */
184
- getIndexerSlot(): Promise<number>;
185
- /**
186
- * Fetch all the compressed token holders for a given mint. Paginated.
187
- */
188
- getCompressedMintTokenHolders(mint: PublicKey, options?: PaginatedOptions): Promise<WithContext<WithCursor<CompressedMintTokenHolders[]>>>;
189
- /**
190
- * Fetch the latest compression signatures on the cluster. Results are
191
- * paginated.
192
- */
193
- getLatestCompressionSignatures(cursor?: string, limit?: number): Promise<LatestNonVotingSignaturesPaginated>;
194
- /**
195
- * Fetch all non-voting signatures
196
- */
197
- getLatestNonVotingSignatures(limit?: number, cursor?: string): Promise<LatestNonVotingSignatures>;
198
- /**
199
- * Fetch the latest address proofs for new unique addresses specified by an
200
- * array of addresses.
201
- *
202
- * the proof states that said address have not yet been created in
203
- * respective address tree.
204
- * @param addresses Array of BN254 new addresses
205
- * @returns Array of validity proofs for new addresses
206
- */
207
- getMultipleNewAddressProofs(addresses: BN254[]): Promise<MerkleContextWithNewAddressProof[]>;
208
- /**
209
- * Advanced usage of getValidityProof: fetches ZKP directly from a custom
210
- * non-rpcprover. Note: This uses the proverEndpoint specified in the
211
- * constructor. For normal usage, please use {@link getValidityProof}
212
- * instead.
213
- *
214
- * Fetch the latest validity proof for (1) compressed accounts specified by
215
- * an array of account hashes. (2) new unique addresses specified by an
216
- * array of addresses.
217
- *
218
- * Validity proofs prove the presence of compressed accounts in state trees
219
- * and the non-existence of addresses in address trees, respectively. They
220
- * enable verification without recomputing the merkle proof path, thus
221
- * lowering verification and data costs.
222
- *
223
- * @param hashes Array of BN254 hashes.
224
- * @param newAddresses Array of BN254 new addresses.
225
- * @returns validity proof with context
226
- */
227
- getValidityProofDirect(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
228
- /**
229
- * Fetch the latest validity proof for (1) compressed accounts specified by
230
- * an array of account hashes. (2) new unique addresses specified by an
231
- * array of addresses.
232
- *
233
- * Validity proofs prove the presence of compressed accounts in state trees
234
- * and the non-existence of addresses in address trees, respectively. They
235
- * enable verification without recomputing the merkle proof path, thus
236
- * lowering verification and data costs.
237
- *
238
- * @param hashes Array of BN254 hashes.
239
- * @param newAddresses Array of BN254 new addresses.
240
- * @returns validity proof with context
241
- */
242
- getValidityProof(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
243
- /**
244
- * Fetch the latest validity proof for (1) compressed accounts specified by
245
- * an array of account hashes. (2) new unique addresses specified by an
246
- * array of addresses.
247
- *
248
- * Validity proofs prove the presence of compressed accounts in state trees
249
- * and the non-existence of addresses in address trees, respectively. They
250
- * enable verification without recomputing the merkle proof path, thus
251
- * lowering verification and data costs.
252
- *
253
- * @param hashes Array of { hash: BN254, tree: PublicKey, queue: PublicKey }.
254
- * @param newAddresses Array of { address: BN254, tree: PublicKey, queue: PublicKey }.
255
- * @returns validity proof with context
256
- */
257
- getValidityProofV0(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<CompressedProofWithContext>;
258
- /**
259
- * Fetch the latest validity proof for (1) compressed accounts specified by
260
- * an array of account hashes. (2) new unique addresses specified by an
261
- * array of addresses. Returns with context slot.
262
- *
263
- * Validity proofs prove the presence of compressed accounts in state trees
264
- * and the non-existence of addresses in address trees, respectively. They
265
- * enable verification without recomputing the merkle proof path, thus
266
- * lowering verification and data costs.
267
- *
268
- * @param hashes Array of BN254 hashes.
269
- * @param newAddresses Array of BN254 new addresses. Optionally specify the
270
- * tree and queue for each address. Default to public
271
- * state tree/queue.
272
- * @returns validity proof with context
273
- */
274
- getValidityProofAndRpcContext(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<WithContext<CompressedProofWithContext>>;
275
- }
@@ -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[]>;
@@ -1,40 +0,0 @@
1
- import { PublicKey } from '@solana/web3.js';
2
- import BN from 'bn.js';
3
- import { Rpc } from '../../rpc';
4
- import { ParsedTokenAccount, WithCursor } from '../../rpc-interface';
5
- import { CompressedAccount, PublicTransactionEvent } from '../../state';
6
- import { Layout } from '@coral-xyz/borsh';
7
- type TokenData = {
8
- mint: PublicKey;
9
- owner: PublicKey;
10
- amount: BN;
11
- delegate: PublicKey | null;
12
- state: number;
13
- tlv: Buffer | null;
14
- };
15
- export declare const TokenDataLayout: Layout<TokenData>;
16
- export type EventWithParsedTokenTlvData = {
17
- inputCompressedAccountHashes: number[][];
18
- outputCompressedAccounts: ParsedTokenAccount[];
19
- };
20
- /**
21
- * Manually parse the compressed token layout for a given compressed account.
22
- * @param compressedAccount - The compressed account
23
- * @returns The parsed token data
24
- */
25
- export declare function parseTokenLayoutWithIdl(compressedAccount: CompressedAccount, programId?: PublicKey): TokenData | null;
26
- /**
27
- * Retrieves all compressed token accounts for a given mint and owner.
28
- *
29
- * Note: This function is intended for testing purposes only. For production, use rpc.getCompressedTokenAccounts.
30
- *
31
- * @param events Public transaction events
32
- * @param owner PublicKey of the token owner
33
- * @param mint PublicKey of the token mint
34
- */
35
- export declare function getCompressedTokenAccounts(events: PublicTransactionEvent[]): Promise<ParsedTokenAccount[]>;
36
- /** @internal */
37
- export declare function getCompressedTokenAccountsByOwnerTest(rpc: Rpc, owner: PublicKey, mint: PublicKey): Promise<WithCursor<ParsedTokenAccount[]>>;
38
- export declare function getCompressedTokenAccountsByDelegateTest(rpc: Rpc, delegate: PublicKey, mint: PublicKey): Promise<WithCursor<ParsedTokenAccount[]>>;
39
- export declare function getCompressedTokenAccountByHashTest(rpc: Rpc, hash: BN): Promise<ParsedTokenAccount>;
40
- export {};
@@ -1,13 +0,0 @@
1
- import { ParsedTransactionWithMeta } from '@solana/web3.js';
2
- import { Rpc } from '../../rpc';
3
- import { PublicTransactionEvent } from '../../state';
4
- type Deserializer<T> = (data: Buffer, tx: ParsedTransactionWithMeta) => T;
5
- /**
6
- * @internal
7
- * Returns newest first.
8
- *
9
- * */
10
- export declare function getParsedEvents(rpc: Rpc): Promise<PublicTransactionEvent[]>;
11
- export declare const parseEvents: <T>(indexerEventsTransactions: (ParsedTransactionWithMeta | null)[], deserializeFn: Deserializer<T>) => NonNullable<T>[];
12
- export declare const parsePublicTransactionEventWithIdl: (data: Buffer) => PublicTransactionEvent | null;
13
- export {};
@@ -1,3 +0,0 @@
1
- export * from './test-rpc';
2
- export * from './get-parsed-events';
3
- export * from './get-compressed-token-accounts';