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