@lightprotocol/stateless.js 0.21.0 → 0.22.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/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/constants.d.ts +26 -3
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/index.d.ts +0 -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/{node/instruction/pack-compressed-accounts.d.ts → browser/programs/system/pack.d.ts} +28 -3
- 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 +1553 -11
- package/dist/cjs/browser/rpc.d.ts +14 -34
- 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 +14 -38
- package/dist/cjs/browser/utils/calculate-compute-unit-price.d.ts +1 -1
- package/dist/cjs/browser/utils/conversion.d.ts +2 -0
- package/dist/cjs/browser/utils/get-state-tree-infos.d.ts +16 -9
- package/dist/cjs/browser/utils/index.d.ts +1 -2
- 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/constants.d.ts +26 -3
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/index.d.ts +0 -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/{browser/instruction/pack-compressed-accounts.d.ts → node/programs/system/pack.d.ts} +28 -3
- 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 +1553 -11
- package/dist/cjs/node/rpc.d.ts +14 -34
- 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 +14 -38
- package/dist/cjs/node/utils/calculate-compute-unit-price.d.ts +1 -1
- package/dist/cjs/node/utils/conversion.d.ts +2 -0
- package/dist/cjs/node/utils/get-state-tree-infos.d.ts +16 -9
- package/dist/cjs/node/utils/index.d.ts +1 -2
- 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 +2784 -877
- package/package.json +13 -6
- package/dist/cjs/browser/instruction/index.d.ts +0 -1
- package/dist/cjs/node/instruction/index.d.ts +0 -1
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
3
|
import { Rpc } from '../../rpc';
|
|
4
|
-
import { CompressedAccountWithMerkleContext
|
|
5
|
-
/**
|
|
6
|
-
* Get the info for a given tree or queue
|
|
7
|
-
*
|
|
8
|
-
* @param info The active state tree addresses
|
|
9
|
-
* @param treeOrQueue The tree or queue to get the info for
|
|
10
|
-
* @returns The info for the given tree or queue, or throws an error if not
|
|
11
|
-
* found
|
|
12
|
-
*/
|
|
13
|
-
export declare function getStateTreeInfoByPubkey(treeInfos: StateTreeInfo[], treeOrQueue: PublicKey): StateTreeInfo;
|
|
4
|
+
import { CompressedAccountWithMerkleContext } from '../../state';
|
|
14
5
|
export declare function getCompressedAccountsByOwnerTest(rpc: Rpc, owner: PublicKey): Promise<CompressedAccountWithMerkleContext[]>;
|
|
15
6
|
export declare function getCompressedAccountByHashTest(rpc: Rpc, hash: BN): Promise<CompressedAccountWithMerkleContext | undefined>;
|
|
16
7
|
export declare function getMultipleCompressedAccountsByHashTest(rpc: Rpc, hashes: BN[]): Promise<CompressedAccountWithMerkleContext[]>;
|
|
@@ -2,7 +2,7 @@ import { PublicKey } from '@solana/web3.js';
|
|
|
2
2
|
import BN from 'bn.js';
|
|
3
3
|
import { Rpc } from '../../rpc';
|
|
4
4
|
import { ParsedTokenAccount, WithCursor } from '../../rpc-interface';
|
|
5
|
-
import {
|
|
5
|
+
import { PublicTransactionEvent, CompressedAccountLegacy } from '../../state';
|
|
6
6
|
import { Layout } from '@coral-xyz/borsh';
|
|
7
7
|
type TokenData = {
|
|
8
8
|
mint: PublicKey;
|
|
@@ -22,7 +22,7 @@ export type EventWithParsedTokenTlvData = {
|
|
|
22
22
|
* @param compressedAccount - The compressed account
|
|
23
23
|
* @returns The parsed token data
|
|
24
24
|
*/
|
|
25
|
-
export declare function parseTokenLayoutWithIdl(compressedAccount:
|
|
25
|
+
export declare function parseTokenLayoutWithIdl(compressedAccount: CompressedAccountLegacy, programId?: PublicKey): TokenData | null;
|
|
26
26
|
/**
|
|
27
27
|
* Retrieves all compressed token accounts for a given mint and owner.
|
|
28
28
|
*
|
|
@@ -4,17 +4,8 @@ import { AddressWithTree, CompressedMintTokenHolders, CompressedTransaction, Get
|
|
|
4
4
|
import { ValidityProofWithContext, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, ParsedTokenAccount, TokenBalance } from '../../rpc-interface';
|
|
5
5
|
import { BN254, CompressedAccountWithMerkleContext, MerkleContextWithMerkleProof } from '../../state';
|
|
6
6
|
import { MerkleContextWithNewAddressProof } from '../../rpc';
|
|
7
|
-
import {
|
|
7
|
+
import { TreeInfo } from '../../state/types';
|
|
8
8
|
export interface TestRpcConfig {
|
|
9
|
-
/**
|
|
10
|
-
* Address of the state tree to index. Default: public default test state
|
|
11
|
-
* tree.
|
|
12
|
-
*/
|
|
13
|
-
merkleTreeAddress?: PublicKey;
|
|
14
|
-
/**
|
|
15
|
-
* Nullifier queue associated with merkleTreeAddress
|
|
16
|
-
*/
|
|
17
|
-
nullifierQueueAddress?: PublicKey;
|
|
18
9
|
/**
|
|
19
10
|
* Depth of state tree. Defaults to the public default test state tree depth
|
|
20
11
|
*/
|
|
@@ -23,15 +14,6 @@ export interface TestRpcConfig {
|
|
|
23
14
|
* Log proof generation time
|
|
24
15
|
*/
|
|
25
16
|
log?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Address of the address tree to index. Default: public default test
|
|
28
|
-
* address tree.
|
|
29
|
-
*/
|
|
30
|
-
addressTreeAddress?: PublicKey;
|
|
31
|
-
/**
|
|
32
|
-
* Address queue associated with addressTreeAddress
|
|
33
|
-
*/
|
|
34
|
-
addressQueueAddress?: PublicKey;
|
|
35
17
|
}
|
|
36
18
|
export type ClientSubscriptionId = number;
|
|
37
19
|
export interface LightWasm {
|
|
@@ -57,13 +39,13 @@ export interface LightWasm {
|
|
|
57
39
|
*/
|
|
58
40
|
export declare function getTestRpc(lightWasm: LightWasm, endpoint?: string, compressionApiEndpoint?: string, proverEndpoint?: string, depth?: number, log?: boolean): Promise<TestRpc>;
|
|
59
41
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
42
|
+
* Mock RPC for unit tests that simulates the ZK Compression RPC interface.
|
|
43
|
+
* Parses events and builds merkletree on-demand. It does not persist state.
|
|
62
44
|
* Constraints:
|
|
63
|
-
* - Can only index 1 merkletree
|
|
64
45
|
* - Can only index up to 1000 transactions
|
|
65
46
|
*
|
|
66
|
-
* For advanced testing use photon:
|
|
47
|
+
* For advanced testing use `Rpc` class which uses photon:
|
|
48
|
+
* https://github.com/helius-labs/photon
|
|
67
49
|
*/
|
|
68
50
|
export declare class TestRpc extends Connection implements CompressionApiInterface {
|
|
69
51
|
compressionApiEndpoint: string;
|
|
@@ -71,9 +53,9 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
71
53
|
lightWasm: LightWasm;
|
|
72
54
|
depth: number;
|
|
73
55
|
log: boolean;
|
|
74
|
-
allStateTreeInfos:
|
|
56
|
+
allStateTreeInfos: TreeInfo[] | null;
|
|
75
57
|
lastStateTreeFetchTime: number | null;
|
|
76
|
-
fetchPromise: Promise<
|
|
58
|
+
fetchPromise: Promise<TreeInfo[]> | null;
|
|
77
59
|
CACHE_TTL: number;
|
|
78
60
|
/**
|
|
79
61
|
* Establish a Compression-compatible JSON RPC mock-connection
|
|
@@ -88,6 +70,10 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
88
70
|
* @param testRpcConfig Config for the mock rpc
|
|
89
71
|
*/
|
|
90
72
|
constructor(endpoint: string, hasher: LightWasm, compressionApiEndpoint: string, proverEndpoint: string, connectionConfig?: ConnectionConfig, testRpcConfig?: TestRpcConfig);
|
|
73
|
+
/**
|
|
74
|
+
* @deprecated Use {@link getStateTreeInfos} instead
|
|
75
|
+
*/
|
|
76
|
+
getCachedActiveStateTreeInfo(): Promise<void>;
|
|
91
77
|
/**
|
|
92
78
|
* @deprecated Use {@link getStateTreeInfos} instead
|
|
93
79
|
*/
|
|
@@ -95,8 +81,8 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
95
81
|
/**
|
|
96
82
|
* Returns local test state trees.
|
|
97
83
|
*/
|
|
98
|
-
getStateTreeInfos(): Promise<
|
|
99
|
-
doFetch(): Promise<
|
|
84
|
+
getStateTreeInfos(): Promise<TreeInfo[]>;
|
|
85
|
+
doFetch(): Promise<TreeInfo[]>;
|
|
100
86
|
/**
|
|
101
87
|
* Fetch the compressed account for the specified account hash
|
|
102
88
|
*/
|
|
@@ -184,7 +170,7 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
184
170
|
* Fetch a confirmed or finalized transaction from the cluster. Return with
|
|
185
171
|
* CompressionInfo
|
|
186
172
|
*/
|
|
187
|
-
getTransactionWithCompressionInfo(_signature: string): Promise<CompressedTransaction
|
|
173
|
+
getTransactionWithCompressionInfo(_signature: string): Promise<CompressedTransaction>;
|
|
188
174
|
/**
|
|
189
175
|
* Returns confirmed signatures for transactions involving the specified
|
|
190
176
|
* address forward in time from genesis to the most recent confirmed
|
|
@@ -225,16 +211,6 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
225
211
|
*/
|
|
226
212
|
getMultipleNewAddressProofs(addresses: BN254[]): Promise<MerkleContextWithNewAddressProof[]>;
|
|
227
213
|
getCompressedMintTokenHolders(_mint: PublicKey, _options?: PaginatedOptions): Promise<WithContext<WithCursor<CompressedMintTokenHolders[]>>>;
|
|
228
|
-
/**
|
|
229
|
-
* Advanced usage of getValidityProof: fetches ZKP directly from a custom
|
|
230
|
-
* non-rpcprover. Note: This uses the proverEndpoint specified in the
|
|
231
|
-
* constructor. For normal usage, please use {@link getValidityProof}
|
|
232
|
-
* instead.
|
|
233
|
-
*
|
|
234
|
-
* Note: Use RPC class for forested trees. TestRpc is only for custom
|
|
235
|
-
* testing purposes.
|
|
236
|
-
*/
|
|
237
|
-
getValidityProofDirect(hashes?: BN254[], newAddresses?: BN254[]): Promise<ValidityProofWithContext>;
|
|
238
214
|
/**
|
|
239
215
|
* @deprecated This method is not available for TestRpc. Please use
|
|
240
216
|
* {@link getValidityProof} instead.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
* @param targetLamports - Target priority fee in lamports
|
|
3
3
|
* @param computeUnits - Expected compute units used by the transaction
|
|
4
4
|
* @returns microLamports per compute unit (use in
|
|
5
|
-
*
|
|
5
|
+
* {@link https://github.com/solana-foundation/solana-web3.js/blob/maintenance/v1.x/src/programs/compute-budget.ts#L218})
|
|
6
6
|
*/
|
|
7
7
|
export declare function calculateComputeUnitPrice(targetLamports: number, computeUnits: number): number;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Buffer } from 'buffer';
|
|
2
2
|
import { Keypair } from '@solana/web3.js';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
|
+
import { InstructionDataInvoke } from '../state';
|
|
4
5
|
export declare function byteArrayToKeypair(byteArray: number[]): Keypair;
|
|
5
6
|
/**
|
|
6
7
|
* @internal
|
|
@@ -31,3 +32,4 @@ export declare function hashToBn254FieldSizeBe(bytes: Buffer): [Buffer, number]
|
|
|
31
32
|
export declare function hashvToBn254FieldSizeBe(bytes: Uint8Array[]): Uint8Array;
|
|
32
33
|
/** Mutates array in place */
|
|
33
34
|
export declare function pushUniqueItems<T>(items: T[], map: T[]): void;
|
|
35
|
+
export declare function convertInvokeCpiWithReadOnlyToInvoke(data: any): InstructionDataInvoke;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Connection, PublicKey } from '@solana/web3.js';
|
|
2
|
-
import {
|
|
2
|
+
import { TreeInfo, TreeType } from '../state/types';
|
|
3
3
|
import { StateTreeLUTPair } from '../constants';
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated use {@link getTreeInfoByPubkey} instead
|
|
6
|
+
*/
|
|
7
|
+
export declare function getStateTreeInfoByPubkey(treeInfos: TreeInfo[], treeOrQueue: PublicKey): TreeInfo;
|
|
8
|
+
export declare function getTreeInfoByPubkey(treeInfos: TreeInfo[], treeOrQueue: PublicKey): TreeInfo;
|
|
4
9
|
/**
|
|
5
10
|
* @deprecated use {@link selectStateTreeInfo} instead.
|
|
6
11
|
*
|
|
@@ -9,24 +14,26 @@ import { StateTreeLUTPair } from '../constants';
|
|
|
9
14
|
* @param infos Set of state tree infos
|
|
10
15
|
* @returns A random tree and queue
|
|
11
16
|
*/
|
|
12
|
-
export declare function pickRandomTreeAndQueue(infos:
|
|
17
|
+
export declare function pickRandomTreeAndQueue(infos: TreeInfo[]): {
|
|
13
18
|
tree: PublicKey;
|
|
14
19
|
queue: PublicKey;
|
|
15
20
|
};
|
|
16
21
|
/**
|
|
17
|
-
*
|
|
22
|
+
* Select a pseudo-random active state tree info from the set of provided state
|
|
18
23
|
* tree infos.
|
|
19
24
|
*
|
|
20
|
-
* Using this
|
|
25
|
+
* Using this reduces write-lock contention on state trees.
|
|
21
26
|
*
|
|
22
27
|
* @param infos Set of state tree infos
|
|
23
|
-
*
|
|
24
|
-
* @param
|
|
25
|
-
*
|
|
28
|
+
*
|
|
29
|
+
* @param treeType Optional: Only use if you know what you are
|
|
30
|
+
* doing. The type of tree.
|
|
31
|
+
* @param useMaxConcurrency Optional: Only use if you know what you are
|
|
32
|
+
* doing. If true, select from all infos.
|
|
26
33
|
*
|
|
27
34
|
* @returns A pseudo-randomly selected tree info
|
|
28
35
|
*/
|
|
29
|
-
export declare function selectStateTreeInfo(infos:
|
|
36
|
+
export declare function selectStateTreeInfo(infos: TreeInfo[], treeType?: TreeType, useMaxConcurrency?: boolean): TreeInfo;
|
|
30
37
|
/**
|
|
31
38
|
* Get active state tree infos from LUTs.
|
|
32
39
|
*
|
|
@@ -38,4 +45,4 @@ export declare function selectStateTreeInfo(infos: StateTreeInfo[], treeType?: T
|
|
|
38
45
|
export declare function getAllStateTreeInfos({ connection, stateTreeLUTPairs, }: {
|
|
39
46
|
connection: Connection;
|
|
40
47
|
stateTreeLUTPairs: StateTreeLUTPair[];
|
|
41
|
-
}): Promise<
|
|
48
|
+
}): Promise<TreeInfo[]>;
|
|
@@ -3,11 +3,10 @@ export * from './airdrop';
|
|
|
3
3
|
export * from './calculate-compute-unit-price';
|
|
4
4
|
export * from './conversion';
|
|
5
5
|
export * from './dedupe-signer';
|
|
6
|
-
export * from './get-state-tree-infos';
|
|
7
6
|
export * from './parse-validity-proof';
|
|
8
7
|
export * from './pipe';
|
|
9
8
|
export * from './send-and-confirm';
|
|
10
9
|
export * from './sleep';
|
|
11
|
-
export * from './state-tree-lookup-table';
|
|
12
10
|
export * from './validation';
|
|
11
|
+
export * from './state-tree-lookup-table';
|
|
13
12
|
export * from './get-state-tree-infos';
|
|
@@ -34,7 +34,7 @@ export declare function sendAndConfirmTx(rpc: Rpc, tx: VersionedTransaction, con
|
|
|
34
34
|
* @param blockHashCtx blockhash context for confirmation
|
|
35
35
|
* @return SignatureResult
|
|
36
36
|
*/
|
|
37
|
-
export declare function confirmTx(rpc: Rpc, txId: string, confirmOptions?: ConfirmOptions,
|
|
37
|
+
export declare function confirmTx(rpc: Rpc, txId: string, confirmOptions?: ConfirmOptions, _blockHashCtx?: {
|
|
38
38
|
blockhash: string;
|
|
39
39
|
lastValidBlockHeight: number;
|
|
40
40
|
}): Promise<RpcResponseAndContext<SignatureResult>>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BN from 'bn.js';
|
|
2
|
-
import {
|
|
2
|
+
import { CompressedAccountLegacy, CompressedAccountWithMerkleContext } from '../state';
|
|
3
3
|
export declare const validateSufficientBalance: (balance: BN) => void;
|
|
4
|
-
export declare const validateSameOwner: (compressedAccounts:
|
|
4
|
+
export declare const validateSameOwner: (compressedAccounts: CompressedAccountLegacy[] | CompressedAccountWithMerkleContext[]) => void;
|
|
5
5
|
export declare const validateNumbersForProof: (hashesLength: number, newAddressesLength: number) => void;
|
|
6
6
|
export declare const validateNumbersForInclusionProof: (hashesLength: number) => void;
|
|
7
7
|
export declare const validateNumbersForNonInclusionProof: (newAddressesLength: number) => void;
|