@lightprotocol/stateless.js 0.21.0 → 0.22.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/cjs/browser/actions/compress.d.ts +2 -2
- package/dist/cjs/browser/actions/create-account.d.ts +3 -3
- package/dist/cjs/browser/actions/transfer.d.ts +1 -2
- package/dist/cjs/browser/compressible/action.d.ts +77 -0
- package/dist/cjs/browser/compressible/index.d.ts +13 -0
- package/dist/cjs/browser/compressible/instruction.d.ts +177 -0
- package/dist/cjs/browser/compressible/layout.d.ts +47 -0
- package/dist/cjs/browser/compressible/types.d.ts +112 -0
- package/dist/cjs/browser/compressible/utils.d.ts +16 -0
- package/dist/cjs/browser/constants.d.ts +31 -6
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/index.d.ts +1 -2
- package/dist/cjs/browser/programs/index.d.ts +0 -1
- package/dist/cjs/browser/{idl.d.ts → programs/system/idl.d.ts} +5 -27
- package/dist/cjs/browser/programs/system/index.d.ts +5 -0
- package/dist/cjs/{node/programs → browser/programs/system}/layout.d.ts +10 -1
- package/dist/cjs/browser/programs/system/pack.d.ts +143 -0
- package/dist/cjs/browser/programs/{system.d.ts → system/program.d.ts} +13 -28
- package/dist/cjs/browser/programs/system/select-compressed-accounts.d.ts +10 -0
- package/dist/cjs/browser/rpc-interface.d.ts +1593 -51
- package/dist/cjs/browser/rpc.d.ts +31 -37
- package/dist/cjs/browser/state/compressed-account.d.ts +140 -6
- package/dist/cjs/browser/state/types.d.ts +265 -26
- package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-accounts.d.ts +1 -10
- package/dist/cjs/browser/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +2 -2
- package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +20 -40
- package/dist/cjs/browser/utils/address.d.ts +13 -0
- package/dist/cjs/browser/utils/calculate-compute-unit-price.d.ts +1 -1
- package/dist/cjs/browser/utils/conversion.d.ts +3 -0
- package/dist/cjs/browser/utils/get-state-tree-infos.d.ts +16 -9
- package/dist/cjs/browser/utils/index.d.ts +2 -2
- package/dist/cjs/browser/utils/packed-accounts.d.ts +161 -0
- package/dist/cjs/browser/utils/send-and-confirm.d.ts +1 -1
- package/dist/cjs/browser/utils/validation.d.ts +2 -2
- package/dist/cjs/node/actions/compress.d.ts +2 -2
- package/dist/cjs/node/actions/create-account.d.ts +3 -3
- package/dist/cjs/node/actions/transfer.d.ts +1 -2
- package/dist/cjs/node/compressible/action.d.ts +77 -0
- package/dist/cjs/node/compressible/index.d.ts +13 -0
- package/dist/cjs/node/compressible/instruction.d.ts +177 -0
- package/dist/cjs/node/compressible/layout.d.ts +47 -0
- package/dist/cjs/node/compressible/types.d.ts +112 -0
- package/dist/cjs/node/compressible/utils.d.ts +16 -0
- package/dist/cjs/node/constants.d.ts +31 -6
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/index.d.ts +1 -2
- package/dist/cjs/node/programs/index.d.ts +0 -1
- package/dist/cjs/node/{idl.d.ts → programs/system/idl.d.ts} +5 -27
- package/dist/cjs/node/programs/system/index.d.ts +5 -0
- package/dist/cjs/{browser/programs → node/programs/system}/layout.d.ts +10 -1
- package/dist/cjs/node/programs/system/pack.d.ts +143 -0
- package/dist/cjs/node/programs/{system.d.ts → system/program.d.ts} +13 -28
- package/dist/cjs/node/programs/system/select-compressed-accounts.d.ts +10 -0
- package/dist/cjs/node/rpc-interface.d.ts +1593 -51
- package/dist/cjs/node/rpc.d.ts +31 -37
- package/dist/cjs/node/state/compressed-account.d.ts +140 -6
- package/dist/cjs/node/state/types.d.ts +265 -26
- package/dist/cjs/node/test-helpers/test-rpc/get-compressed-accounts.d.ts +1 -10
- package/dist/cjs/node/test-helpers/test-rpc/get-compressed-token-accounts.d.ts +2 -2
- package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +20 -40
- package/dist/cjs/node/utils/address.d.ts +13 -0
- package/dist/cjs/node/utils/calculate-compute-unit-price.d.ts +1 -1
- package/dist/cjs/node/utils/conversion.d.ts +3 -0
- package/dist/cjs/node/utils/get-state-tree-infos.d.ts +16 -9
- package/dist/cjs/node/utils/index.d.ts +2 -2
- package/dist/cjs/node/utils/packed-accounts.d.ts +161 -0
- package/dist/cjs/node/utils/send-and-confirm.d.ts +1 -1
- package/dist/cjs/node/utils/validation.d.ts +2 -2
- package/dist/types/index.d.ts +3391 -864
- package/package.json +13 -6
- package/dist/cjs/browser/instruction/index.d.ts +0 -1
- package/dist/cjs/browser/instruction/pack-compressed-accounts.d.ts +0 -49
- package/dist/cjs/node/instruction/index.d.ts +0 -1
- package/dist/cjs/node/instruction/pack-compressed-accounts.d.ts +0 -49
package/dist/cjs/node/rpc.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
|
|
1
|
+
import { AccountInfo, Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { Buffer } from 'buffer';
|
|
3
3
|
import { ValidityProofWithContext, CompressedTransaction, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, HexInputsForProver, ParsedTokenAccount, SignatureWithMetadata, LatestNonVotingSignatures, LatestNonVotingSignaturesPaginated, WithContext, GetCompressedAccountsByOwnerConfig, WithCursor, AddressWithTree, HashWithTree, CompressedMintTokenHolders, TokenBalance, PaginatedOptions } from './rpc-interface';
|
|
4
|
-
import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, ValidityProof, AddressTreeInfo } from './state';
|
|
4
|
+
import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, ValidityProof, AddressTreeInfo, MerkleContext } from './state';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
import { LightWasm } from './test-helpers';
|
|
7
|
-
import {
|
|
7
|
+
import { TreeInfo } from './state/types';
|
|
8
8
|
/** @internal */
|
|
9
9
|
export declare function parseAccountData({ discriminator, data, dataHash, }: {
|
|
10
10
|
discriminator: BN;
|
|
@@ -12,7 +12,7 @@ export declare function parseAccountData({ discriminator, data, dataHash, }: {
|
|
|
12
12
|
dataHash: BN;
|
|
13
13
|
}): {
|
|
14
14
|
discriminator: number[];
|
|
15
|
-
data: Buffer
|
|
15
|
+
data: Buffer<ArrayBuffer>;
|
|
16
16
|
dataHash: number[];
|
|
17
17
|
};
|
|
18
18
|
/**
|
|
@@ -35,7 +35,7 @@ export declare function wrapBigNumbersAsStrings(text: string): string;
|
|
|
35
35
|
/** @internal */
|
|
36
36
|
export declare const rpcRequest: (rpcEndpoint: string, method: string, params?: any, convertToCamelCase?: boolean, debug?: boolean) => Promise<any>;
|
|
37
37
|
/** @internal */
|
|
38
|
-
export declare const proverRequest: (proverEndpoint: string, method: "inclusion" | "new-address" | "combined", params?: any, log?: boolean,
|
|
38
|
+
export declare const proverRequest: (proverEndpoint: string, method: "inclusion" | "new-address" | "combined", params?: any, log?: boolean, _publicInputHash?: BN | undefined) => Promise<ValidityProof>;
|
|
39
39
|
export type NonInclusionMerkleProofInputs = {
|
|
40
40
|
root: BN;
|
|
41
41
|
value: BN;
|
|
@@ -68,25 +68,25 @@ export type NonInclusionJsonStruct = {
|
|
|
68
68
|
export declare function convertMerkleProofsWithContextToHex(merkleProofsWithContext: MerkleContextWithMerkleProof[]): HexInputsForProver[];
|
|
69
69
|
export declare function convertNonInclusionMerkleProofInputsToHex(nonInclusionMerkleProofInputs: MerkleContextWithNewAddressProof[]): NonInclusionJsonStruct[];
|
|
70
70
|
export declare function getPublicInputHash(accountProofs: MerkleContextWithMerkleProof[], accountHashes: BN254[], newAddressProofs: MerkleContextWithNewAddressProof[], lightWasm: LightWasm): BN;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
* @param queue - The queue to get the tree for
|
|
76
|
-
* @returns The tree for the given queue, or undefined if not found
|
|
77
|
-
*/
|
|
78
|
-
export declare function getTreeForQueue(info: StateTreeInfo[], queue: PublicKey): PublicKey;
|
|
71
|
+
export interface NullifierMetadata {
|
|
72
|
+
nullifier: BN254;
|
|
73
|
+
txHash: BN254;
|
|
74
|
+
}
|
|
79
75
|
/**
|
|
80
76
|
*
|
|
81
77
|
*/
|
|
82
78
|
export declare class Rpc extends Connection implements CompressionApiInterface {
|
|
83
79
|
compressionApiEndpoint: string;
|
|
84
80
|
proverEndpoint: string;
|
|
85
|
-
allStateTreeInfos:
|
|
81
|
+
allStateTreeInfos: TreeInfo[] | null;
|
|
86
82
|
lastStateTreeFetchTime: number | null;
|
|
87
83
|
CACHE_TTL: number;
|
|
88
|
-
fetchPromise: Promise<
|
|
84
|
+
fetchPromise: Promise<TreeInfo[]> | null;
|
|
89
85
|
constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Use {@link getStateTreeInfos} instead
|
|
88
|
+
*/
|
|
89
|
+
getCachedActiveStateTreeInfo(): Promise<void>;
|
|
90
90
|
/**
|
|
91
91
|
* @deprecated Use {@link getStateTreeInfos} instead
|
|
92
92
|
*/
|
|
@@ -95,11 +95,11 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
|
|
|
95
95
|
* Get a list of all state tree infos. If not already cached, fetches from
|
|
96
96
|
* the cluster.
|
|
97
97
|
*/
|
|
98
|
-
getStateTreeInfos(): Promise<
|
|
98
|
+
getStateTreeInfos(): Promise<TreeInfo[]>;
|
|
99
99
|
/**
|
|
100
100
|
* @internal
|
|
101
101
|
*/
|
|
102
|
-
doFetch(): Promise<
|
|
102
|
+
doFetch(): Promise<TreeInfo[]>;
|
|
103
103
|
/**
|
|
104
104
|
* Fetch the compressed account for the specified account address or hash
|
|
105
105
|
*/
|
|
@@ -228,26 +228,6 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
|
|
|
228
228
|
* @returns Array of validity proofs for new addresses
|
|
229
229
|
*/
|
|
230
230
|
getMultipleNewAddressProofs(addresses: BN254[]): Promise<MerkleContextWithNewAddressProof[]>;
|
|
231
|
-
/**
|
|
232
|
-
* Advanced usage of getValidityProof: fetches ZKP directly from a custom
|
|
233
|
-
* non-rpcprover. Note: This uses the proverEndpoint specified in the
|
|
234
|
-
* constructor. For normal usage, please use {@link getValidityProof}
|
|
235
|
-
* instead.
|
|
236
|
-
*
|
|
237
|
-
* Fetch the latest validity proof for (1) compressed accounts specified by
|
|
238
|
-
* an array of account hashes. (2) new unique addresses specified by an
|
|
239
|
-
* array of addresses.
|
|
240
|
-
*
|
|
241
|
-
* Validity proofs prove the presence of compressed accounts in state trees
|
|
242
|
-
* and the non-existence of addresses in address trees, respectively. They
|
|
243
|
-
* enable verification without recomputing the merkle proof path, thus
|
|
244
|
-
* lowering verification and data costs.
|
|
245
|
-
*
|
|
246
|
-
* @param hashes Array of BN254 hashes.
|
|
247
|
-
* @param newAddresses Array of BN254 new addresses.
|
|
248
|
-
* @returns validity proof with context
|
|
249
|
-
*/
|
|
250
|
-
getValidityProofDirect(hashes?: BN254[], newAddresses?: BN254[]): Promise<ValidityProofWithContext>;
|
|
251
231
|
/**
|
|
252
232
|
* @deprecated use {@link getValidityProofV0} instead.
|
|
253
233
|
*
|
|
@@ -297,4 +277,18 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
|
|
|
297
277
|
* @returns validity proof with context
|
|
298
278
|
*/
|
|
299
279
|
getValidityProofAndRpcContext(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<WithContext<ValidityProofWithContext>>;
|
|
280
|
+
/**
|
|
281
|
+
* Get account info from either compressed or onchain storage.
|
|
282
|
+
* @param address The account address to fetch.
|
|
283
|
+
* @param programId The owner program ID.
|
|
284
|
+
* @param addressTreeInfo The address tree info used to store the account.
|
|
285
|
+
* @param rpc The RPC client to use.
|
|
286
|
+
*
|
|
287
|
+
* @returns Account info with compression info, or null if account
|
|
288
|
+
* doesn't exist.
|
|
289
|
+
*/
|
|
290
|
+
getCompressibleAccountInfo(address: PublicKey, programId: PublicKey, addressTreeInfo: TreeInfo, rpc: Rpc): Promise<{
|
|
291
|
+
accountInfo: AccountInfo<Buffer>;
|
|
292
|
+
merkleContext?: MerkleContext;
|
|
293
|
+
} | null>;
|
|
300
294
|
}
|
|
@@ -1,14 +1,48 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
|
-
import {
|
|
2
|
+
import { CompressedAccountData, CompressedAccountLegacy, PackedMerkleContextLegacy, TreeInfo } from './types';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
4
|
import { BN254 } from './BN254';
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated use {@link CompressedAccount} instead
|
|
7
|
+
*/
|
|
5
8
|
export type CompressedAccountWithMerkleContext = CompressedAccount & MerkleContext & {
|
|
6
9
|
readOnly: boolean;
|
|
7
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated use {@link CompressedAccount} instead
|
|
13
|
+
*/
|
|
14
|
+
export type CompressedAccountWithMerkleContextLegacy = CompressedAccount & MerkleContext;
|
|
15
|
+
/**
|
|
16
|
+
* Compressed account + metadata about the state tree in which the account is
|
|
17
|
+
* stored.
|
|
18
|
+
*/
|
|
19
|
+
export type CompressedAccount = {
|
|
20
|
+
/**
|
|
21
|
+
* Public key of program or user owning the account.
|
|
22
|
+
*/
|
|
23
|
+
owner: PublicKey;
|
|
24
|
+
/**
|
|
25
|
+
* Lamports attached to the account.
|
|
26
|
+
*/
|
|
27
|
+
lamports: BN;
|
|
28
|
+
/**
|
|
29
|
+
* Optional unique account ID that is persistent across transactions.
|
|
30
|
+
*/
|
|
31
|
+
address: number[] | null;
|
|
32
|
+
/**
|
|
33
|
+
* Optional data attached to the account.
|
|
34
|
+
*/
|
|
35
|
+
data: CompressedAccountData | null;
|
|
36
|
+
} & MerkleContext & {
|
|
37
|
+
/**
|
|
38
|
+
* Read only.
|
|
39
|
+
*/
|
|
40
|
+
readOnly: boolean;
|
|
41
|
+
};
|
|
8
42
|
/**
|
|
9
43
|
* @deprecated use {@link MerkleContext} instead.
|
|
10
44
|
*
|
|
11
|
-
* Legacy MerkleContext
|
|
45
|
+
* Legacy MerkleContext.
|
|
12
46
|
*/
|
|
13
47
|
export type MerkleContextLegacy = {
|
|
14
48
|
/**
|
|
@@ -35,7 +69,7 @@ export type MerkleContext = {
|
|
|
35
69
|
/**
|
|
36
70
|
* Tree info
|
|
37
71
|
*/
|
|
38
|
-
treeInfo:
|
|
72
|
+
treeInfo: TreeInfo;
|
|
39
73
|
/**
|
|
40
74
|
* Poseidon hash of the account. Stored as leaf in state tree
|
|
41
75
|
*/
|
|
@@ -66,6 +100,106 @@ export type MerkleContextWithMerkleProof = MerkleContext & {
|
|
|
66
100
|
*/
|
|
67
101
|
root: BN254;
|
|
68
102
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Packed compressed account and state tree info.
|
|
105
|
+
*/
|
|
106
|
+
export type PackedStateTreeInfo = {
|
|
107
|
+
/**
|
|
108
|
+
* Recent valid root index.
|
|
109
|
+
*/
|
|
110
|
+
rootIndex: number;
|
|
111
|
+
/**
|
|
112
|
+
* Whether the account can be proven by index or by merkle proof
|
|
113
|
+
*/
|
|
114
|
+
proveByIndex: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Index of the merkle tree in which the account is stored.
|
|
117
|
+
*/
|
|
118
|
+
merkleTreePubkeyIndex: number;
|
|
119
|
+
/**
|
|
120
|
+
* Index of the queue in which the account is stored.
|
|
121
|
+
*/
|
|
122
|
+
queuePubkeyIndex: number;
|
|
123
|
+
/**
|
|
124
|
+
* Index of the leaf in the state tree.
|
|
125
|
+
*/
|
|
126
|
+
leafIndex: number;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Packed tree info for a new program-derived address (PDA).
|
|
130
|
+
*/
|
|
131
|
+
export type PackedAddressTreeInfo = {
|
|
132
|
+
/**
|
|
133
|
+
* Index of the merkle tree in which the account is stored.
|
|
134
|
+
*/
|
|
135
|
+
addressMerkleTreePubkeyIndex: number;
|
|
136
|
+
/**
|
|
137
|
+
* Index of the queue in which the account is stored.
|
|
138
|
+
*/
|
|
139
|
+
addressQueuePubkeyIndex: number;
|
|
140
|
+
/**
|
|
141
|
+
* Recent valid root index.
|
|
142
|
+
*/
|
|
143
|
+
rootIndex: number;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Compressed account meta in instruction.
|
|
147
|
+
*
|
|
148
|
+
*/
|
|
149
|
+
export type CompressedAccountMeta = {
|
|
150
|
+
/**
|
|
151
|
+
* Packed Tree info.
|
|
152
|
+
*/
|
|
153
|
+
treeInfo: PackedStateTreeInfo;
|
|
154
|
+
/**
|
|
155
|
+
* Address.
|
|
156
|
+
*/
|
|
157
|
+
address: number[] | null;
|
|
158
|
+
/**
|
|
159
|
+
* Lamports.
|
|
160
|
+
*/
|
|
161
|
+
lamports: BN | null;
|
|
162
|
+
/**
|
|
163
|
+
* index of state tree in which the new account state is stored.
|
|
164
|
+
*/
|
|
165
|
+
outputStateTreeIndex: number;
|
|
166
|
+
};
|
|
167
|
+
/**
|
|
168
|
+
* Create an output compressed account meta for a new account.
|
|
169
|
+
* Client-side only.
|
|
170
|
+
*/
|
|
171
|
+
export declare const createCompressedAccountMeta: (treeInfo: PackedStateTreeInfo, outputStateTreeIndex: number, address?: number[], lamports?: BN) => CompressedAccountMeta;
|
|
172
|
+
/**
|
|
173
|
+
* @deprecated Use {@link PackedStateTreeInfo} instead.
|
|
174
|
+
* Packed compressed account with merkle context.
|
|
175
|
+
*/
|
|
176
|
+
export interface PackedCompressedAccountWithMerkleContext {
|
|
177
|
+
/**
|
|
178
|
+
* Compressed account.
|
|
179
|
+
*/
|
|
180
|
+
compressedAccount: CompressedAccountLegacy;
|
|
181
|
+
/**
|
|
182
|
+
* Merkle context.
|
|
183
|
+
*/
|
|
184
|
+
merkleContext: PackedMerkleContextLegacy;
|
|
185
|
+
/**
|
|
186
|
+
* Root index.
|
|
187
|
+
*/
|
|
188
|
+
rootIndex: number;
|
|
189
|
+
/**
|
|
190
|
+
* Read only.
|
|
191
|
+
*/
|
|
192
|
+
readOnly: boolean;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* @deprecated use {@link createCompressedAccountMeta} instead.
|
|
196
|
+
*/
|
|
197
|
+
export declare const createCompressedAccountLegacy: (owner: PublicKey, lamports?: BN, data?: CompressedAccountData, address?: number[]) => CompressedAccountLegacy;
|
|
198
|
+
/**
|
|
199
|
+
* @deprecated.
|
|
200
|
+
*/
|
|
201
|
+
export declare const createCompressedAccountWithMerkleContextLegacy: (merkleContext: MerkleContext, owner: PublicKey, lamports?: BN, data?: CompressedAccountData, address?: number[]) => CompressedAccountWithMerkleContext;
|
|
202
|
+
/**
|
|
203
|
+
* @deprecated use {@link createCompressedAccountMeta} instead.
|
|
204
|
+
*/
|
|
205
|
+
export declare const createMerkleContextLegacy: (treeInfo: TreeInfo, hash: BN254, leafIndex: number, proveByIndex?: boolean) => MerkleContext;
|