@lightprotocol/stateless.js 0.18.0 → 0.19.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/constants.d.ts +25 -0
- package/dist/cjs/browser/idl.d.ts +4 -0
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/instruction/pack-compressed-accounts.d.ts +17 -1
- package/dist/cjs/browser/rpc.d.ts +48 -8
- package/dist/cjs/browser/test-helpers/index.d.ts +1 -0
- package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +15 -0
- package/dist/cjs/browser/utils/get-light-state-tree-info.d.ts +74 -0
- package/dist/cjs/browser/utils/index.d.ts +1 -1
- package/dist/cjs/node/constants.d.ts +25 -0
- package/dist/cjs/node/idl.d.ts +4 -0
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/instruction/pack-compressed-accounts.d.ts +17 -1
- package/dist/cjs/node/rpc.d.ts +48 -8
- package/dist/cjs/node/test-helpers/index.d.ts +1 -0
- package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +15 -0
- package/dist/cjs/node/utils/get-light-state-tree-info.d.ts +74 -0
- package/dist/cjs/node/utils/index.d.ts +1 -1
- package/dist/types/index.d.ts +211 -40
- package/package.json +3 -2
- /package/dist/cjs/browser/{utils → test-helpers}/test-utils.d.ts +0 -0
- /package/dist/cjs/node/{utils → test-helpers}/test-utils.d.ts +0 -0
|
@@ -6,7 +6,22 @@ import { CompressedAccountWithMerkleContext } from '../state/compressed-account'
|
|
|
6
6
|
* present
|
|
7
7
|
* */
|
|
8
8
|
export declare function getIndexOrAdd(accountsArray: PublicKey[], key: PublicKey): number;
|
|
9
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* @internal
|
|
11
|
+
* Pads output state trees with the 0th state tree of the input state.
|
|
12
|
+
*
|
|
13
|
+
* @param outputStateMerkleTrees Optional output state trees to be
|
|
14
|
+
* inserted into the output state.
|
|
15
|
+
* Defaults to the 0th state tree of
|
|
16
|
+
* the input state. Gets padded to the
|
|
17
|
+
* length of outputCompressedAccounts.
|
|
18
|
+
* @param numberOfOutputCompressedAccounts The number of output compressed
|
|
19
|
+
* accounts.
|
|
20
|
+
* @param inputCompressedAccountsWithMerkleContext The input compressed accounts
|
|
21
|
+
* with merkle context.
|
|
22
|
+
*
|
|
23
|
+
* @returns Padded output state trees.
|
|
24
|
+
*/
|
|
10
25
|
export declare function padOutputStateMerkleTrees(outputStateMerkleTrees: PublicKey[] | PublicKey | undefined, numberOfOutputCompressedAccounts: number, inputCompressedAccountsWithMerkleContext: CompressedAccountWithMerkleContext[]): PublicKey[];
|
|
11
26
|
export declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountMeta[];
|
|
12
27
|
/**
|
|
@@ -14,6 +29,7 @@ export declare function toAccountMetas(remainingAccounts: PublicKey[]): AccountM
|
|
|
14
29
|
*
|
|
15
30
|
* Replaces PublicKey with index pointer to remaining accounts.
|
|
16
31
|
*
|
|
32
|
+
*
|
|
17
33
|
* @param inputCompressedAccounts Ix input state to be consumed
|
|
18
34
|
* @param inputStateRootIndices The recent state root indices of the
|
|
19
35
|
* input state. The expiry is tied to
|
|
@@ -3,6 +3,8 @@ import { Buffer } from 'buffer';
|
|
|
3
3
|
import { CompressedProofWithContext, CompressedTransaction, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, HexInputsForProver, ParsedTokenAccount, SignatureWithMetadata, LatestNonVotingSignatures, LatestNonVotingSignaturesPaginated, WithContext, GetCompressedAccountsByOwnerConfig, WithCursor, AddressWithTree, HashWithTree, CompressedMintTokenHolders, TokenBalance, PaginatedOptions } from './rpc-interface';
|
|
4
4
|
import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, CompressedProof } from './state';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
|
+
import { LightWasm } from './test-helpers';
|
|
7
|
+
import { ActiveStateTreeAddresses } from './utils/get-light-state-tree-info';
|
|
6
8
|
/** @internal */
|
|
7
9
|
export declare function parseAccountData({ discriminator, data, dataHash, }: {
|
|
8
10
|
discriminator: BN;
|
|
@@ -60,23 +62,57 @@ export type NonInclusionJsonStruct = {
|
|
|
60
62
|
};
|
|
61
63
|
export declare function convertMerkleProofsWithContextToHex(merkleProofsWithContext: MerkleContextWithMerkleProof[]): HexInputsForProver[];
|
|
62
64
|
export declare function convertNonInclusionMerkleProofInputsToHex(nonInclusionMerkleProofInputs: MerkleContextWithNewAddressProof[]): NonInclusionJsonStruct[];
|
|
63
|
-
import { LightWasm } from './test-helpers';
|
|
64
65
|
export declare function getPublicInputHash(accountProofs: MerkleContextWithMerkleProof[], accountHashes: BN254[], newAddressProofs: MerkleContextWithNewAddressProof[], lightWasm: LightWasm): BN;
|
|
66
|
+
/**
|
|
67
|
+
* Get the queue for a given tree
|
|
68
|
+
*
|
|
69
|
+
* @param info - The active state tree addresses
|
|
70
|
+
* @param tree - The tree to get the queue for
|
|
71
|
+
* @returns The queue for the given tree, or undefined if not found
|
|
72
|
+
*/
|
|
73
|
+
export declare function getQueueForTree(info: ActiveStateTreeAddresses, tree: PublicKey): PublicKey;
|
|
74
|
+
/**
|
|
75
|
+
* Get the tree for a given queue
|
|
76
|
+
*
|
|
77
|
+
* @param info - The active state tree addresses
|
|
78
|
+
* @param queue - The queue to get the tree for
|
|
79
|
+
* @returns The tree for the given queue, or undefined if not found
|
|
80
|
+
*/
|
|
81
|
+
export declare function getTreeForQueue(info: ActiveStateTreeAddresses, queue: PublicKey): PublicKey;
|
|
82
|
+
/**
|
|
83
|
+
* Get a random tree and queue from the active state tree addresses.
|
|
84
|
+
*
|
|
85
|
+
* Prevents write lock contention on state trees.
|
|
86
|
+
*
|
|
87
|
+
* @param info - The active state tree addresses
|
|
88
|
+
* @returns A random tree and queue
|
|
89
|
+
*/
|
|
90
|
+
export declare function pickRandomTreeAndQueue(info: ActiveStateTreeAddresses): {
|
|
91
|
+
tree: PublicKey;
|
|
92
|
+
queue: PublicKey;
|
|
93
|
+
};
|
|
65
94
|
/**
|
|
66
95
|
*
|
|
67
96
|
*/
|
|
68
97
|
export declare class Rpc extends Connection implements CompressionApiInterface {
|
|
69
98
|
compressionApiEndpoint: string;
|
|
70
99
|
proverEndpoint: string;
|
|
100
|
+
activeStateTreeInfo: ActiveStateTreeAddresses | null;
|
|
101
|
+
fetchStateTreePromise: Promise<ActiveStateTreeAddresses> | null;
|
|
102
|
+
constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
|
|
71
103
|
/**
|
|
72
|
-
*
|
|
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
|
|
104
|
+
* Manually set state tree addresses
|
|
78
105
|
*/
|
|
79
|
-
|
|
106
|
+
setStateTreeInfo(info: ActiveStateTreeAddresses): void;
|
|
107
|
+
/**
|
|
108
|
+
* Get the active state tree addresses from the cluster.
|
|
109
|
+
* If not already cached, fetches from the cluster.
|
|
110
|
+
*/
|
|
111
|
+
getCachedActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
|
|
112
|
+
/**
|
|
113
|
+
* Fetch the latest state tree addresses from the cluster.
|
|
114
|
+
*/
|
|
115
|
+
getLatestActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
|
|
80
116
|
/**
|
|
81
117
|
* Fetch the compressed account for the specified account address or hash
|
|
82
118
|
*/
|
|
@@ -226,6 +262,10 @@ export declare class Rpc extends Connection implements CompressionApiInterface {
|
|
|
226
262
|
*/
|
|
227
263
|
getValidityProofDirect(hashes?: BN254[], newAddresses?: BN254[]): Promise<CompressedProofWithContext>;
|
|
228
264
|
/**
|
|
265
|
+
* @deprecated use {@link getValidityProofV0} instead.
|
|
266
|
+
*
|
|
267
|
+
*
|
|
268
|
+
*
|
|
229
269
|
* Fetch the latest validity proof for (1) compressed accounts specified by
|
|
230
270
|
* an array of account hashes. (2) new unique addresses specified by an
|
|
231
271
|
* array of addresses.
|
|
@@ -4,6 +4,7 @@ import { AddressWithTree, CompressedMintTokenHolders, CompressedTransaction, Get
|
|
|
4
4
|
import { CompressedProofWithContext, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, ParsedTokenAccount, TokenBalance } from '../../rpc-interface';
|
|
5
5
|
import { BN254, CompressedAccountWithMerkleContext, MerkleContextWithMerkleProof } from '../../state';
|
|
6
6
|
import { MerkleContextWithNewAddressProof } from '../../rpc';
|
|
7
|
+
import { ActiveStateTreeAddresses } from '../../utils/get-light-state-tree-info';
|
|
7
8
|
export interface TestRpcConfig {
|
|
8
9
|
/**
|
|
9
10
|
* Address of the state tree to index. Default: public default test state
|
|
@@ -74,6 +75,8 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
74
75
|
lightWasm: LightWasm;
|
|
75
76
|
depth: number;
|
|
76
77
|
log: boolean;
|
|
78
|
+
activeStateTreeInfo: ActiveStateTreeAddresses | null;
|
|
79
|
+
fetchStateTreePromise: Promise<ActiveStateTreeAddresses> | null;
|
|
77
80
|
/**
|
|
78
81
|
* Establish a Compression-compatible JSON RPC mock-connection
|
|
79
82
|
*
|
|
@@ -87,6 +90,18 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
87
90
|
* @param testRpcConfig Config for the mock rpc
|
|
88
91
|
*/
|
|
89
92
|
constructor(endpoint: string, hasher: LightWasm, compressionApiEndpoint: string, proverEndpoint: string, connectionConfig?: ConnectionConfig, testRpcConfig?: TestRpcConfig);
|
|
93
|
+
/**
|
|
94
|
+
* Manually set state tree addresses
|
|
95
|
+
*/
|
|
96
|
+
setStateTreeInfo(info: ActiveStateTreeAddresses): void;
|
|
97
|
+
/**
|
|
98
|
+
* Returns local test state trees.
|
|
99
|
+
*/
|
|
100
|
+
getCachedActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
|
|
101
|
+
/**
|
|
102
|
+
* Returns local test state trees.
|
|
103
|
+
*/
|
|
104
|
+
getLatestActiveStateTreeInfo(): Promise<ActiveStateTreeAddresses>;
|
|
90
105
|
/**
|
|
91
106
|
* Fetch the compressed account for the specified account hash
|
|
92
107
|
*/
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Create two lookup tables storing all public state tree and queue addresses
|
|
4
|
+
* returns lookup table addresses and txId
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
* @param connection - Connection to the Solana network
|
|
8
|
+
* @param payer - Keypair of the payer
|
|
9
|
+
* @param authority - Keypair of the authority
|
|
10
|
+
* @param recentSlot - Slot of the recent block
|
|
11
|
+
*/
|
|
12
|
+
export declare function createStateTreeLookupTable({ connection, payer, authority, recentSlot, }: {
|
|
13
|
+
connection: Connection;
|
|
14
|
+
payer: Keypair;
|
|
15
|
+
authority: Keypair;
|
|
16
|
+
recentSlot: number;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
address: PublicKey;
|
|
19
|
+
txId: string;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Extend state tree lookup table with new state tree and queue addresses
|
|
23
|
+
* @internal
|
|
24
|
+
* @param connection - Connection to the Solana network
|
|
25
|
+
* @param tableAddress - Address of the lookup table to extend
|
|
26
|
+
* @param newStateTreeAddresses - Addresses of the new state trees to add
|
|
27
|
+
* @param newQueueAddresses - Addresses of the new queues to add
|
|
28
|
+
* @param payer - Keypair of the payer
|
|
29
|
+
* @param authority - Keypair of the authority
|
|
30
|
+
*/
|
|
31
|
+
export declare function extendStateTreeLookupTable({ connection, tableAddress, newStateTreeAddresses, newQueueAddresses, payer, authority, }: {
|
|
32
|
+
connection: Connection;
|
|
33
|
+
tableAddress: PublicKey;
|
|
34
|
+
newStateTreeAddresses: PublicKey[];
|
|
35
|
+
newQueueAddresses: PublicKey[];
|
|
36
|
+
payer: Keypair;
|
|
37
|
+
authority: Keypair;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
tableAddress: PublicKey;
|
|
40
|
+
txId: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Adds full state tree address to lookup table. Acts as nullifier
|
|
44
|
+
* @internal
|
|
45
|
+
* @param connection - Connection to the Solana network
|
|
46
|
+
* @param stateTreeAddress - Address of the state tree to nullify
|
|
47
|
+
* @param nullifyTableAddress - Address nullifier lookup table to store address in
|
|
48
|
+
* @param stateTreeLookupTableAddress - lookup table storing all state tree addresses
|
|
49
|
+
* @param payer - Keypair of the payer
|
|
50
|
+
* @param authority - Keypair of the authority
|
|
51
|
+
*/
|
|
52
|
+
export declare function nullifyLookupTable({ connection, fullStateTreeAddress, nullifyTableAddress, stateTreeLookupTableAddress, payer, authority, }: {
|
|
53
|
+
connection: Connection;
|
|
54
|
+
fullStateTreeAddress: PublicKey;
|
|
55
|
+
nullifyTableAddress: PublicKey;
|
|
56
|
+
stateTreeLookupTableAddress: PublicKey;
|
|
57
|
+
payer: Keypair;
|
|
58
|
+
authority: Keypair;
|
|
59
|
+
}): Promise<{
|
|
60
|
+
txId: string;
|
|
61
|
+
}>;
|
|
62
|
+
export type ActiveStateTreeAddresses = {
|
|
63
|
+
activeStateTrees: PublicKey[];
|
|
64
|
+
activeQueues: PublicKey[];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Get most recent , active state tree data
|
|
68
|
+
* we store in lookup table for each public state tree
|
|
69
|
+
*/
|
|
70
|
+
export declare function getLightStateTreeInfo({ connection, stateTreeLookupTableAddress, nullifyTableAddress, }: {
|
|
71
|
+
connection: Connection;
|
|
72
|
+
stateTreeLookupTableAddress: PublicKey;
|
|
73
|
+
nullifyTableAddress: PublicKey;
|
|
74
|
+
}): Promise<ActiveStateTreeAddresses>;
|
|
@@ -5,6 +5,6 @@ export * from './parse-validity-proof';
|
|
|
5
5
|
export * from './pipe';
|
|
6
6
|
export * from './send-and-confirm';
|
|
7
7
|
export * from './sleep';
|
|
8
|
-
export * from './test-utils';
|
|
9
8
|
export * from './validation';
|
|
10
9
|
export * from './calculate-compute-unit-price';
|
|
10
|
+
export * from './get-light-state-tree-info';
|
|
@@ -17,6 +17,21 @@ export declare const defaultStaticAccountsStruct: () => {
|
|
|
17
17
|
accountCompressionAuthority: PublicKey;
|
|
18
18
|
cpiSignatureAccount: null;
|
|
19
19
|
};
|
|
20
|
+
export declare const defaultStateTreeLookupTables: () => {
|
|
21
|
+
mainnet: {
|
|
22
|
+
stateTreeLookupTable: PublicKey;
|
|
23
|
+
nullifyTable: PublicKey;
|
|
24
|
+
};
|
|
25
|
+
devnet: {
|
|
26
|
+
stateTreeLookupTable: PublicKey;
|
|
27
|
+
nullifyTable: PublicKey;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export declare const isLocalTest: (url: string) => boolean;
|
|
31
|
+
export declare const localTestActiveStateTreeInfo: () => {
|
|
32
|
+
activeStateTrees: PublicKey[];
|
|
33
|
+
activeQueues: PublicKey[];
|
|
34
|
+
};
|
|
20
35
|
export declare const defaultTestStateTreeAccounts: () => {
|
|
21
36
|
nullifierQueue: PublicKey;
|
|
22
37
|
merkleTree: PublicKey;
|
|
@@ -24,10 +39,20 @@ export declare const defaultTestStateTreeAccounts: () => {
|
|
|
24
39
|
addressTree: PublicKey;
|
|
25
40
|
addressQueue: PublicKey;
|
|
26
41
|
};
|
|
42
|
+
export declare const defaultTestStateTreeAccounts2: () => {
|
|
43
|
+
nullifierQueue2: PublicKey;
|
|
44
|
+
merkleTree2: PublicKey;
|
|
45
|
+
};
|
|
46
|
+
export declare const stateTreeLookupTableMainnet = "ABwZ1gQYCrj74azGZvtSk6eBQ9PD7Ch1FCcETcjr9QcC";
|
|
47
|
+
export declare const nullifiedStateTreeLookupTableMainnet = "9cnE7YBEUQXDf7gbapCCnRR7cERYqac6ip1g1cfdF2nb";
|
|
48
|
+
export declare const stateTreeLookupTableDevnet = "zpuJRGT84P9nMzTwpBihvWrRwazj8caUJTya8JAVQnv";
|
|
49
|
+
export declare const nullifiedStateTreeLookupTableDevnet = "3rsYNhcaosPZcMrSiQubjbE3rTLuAYJQvSe78NCruqCB";
|
|
27
50
|
export declare const nullifierQueuePubkey = "nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148";
|
|
28
51
|
export declare const merkletreePubkey = "smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT";
|
|
29
52
|
export declare const addressTree = "amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2";
|
|
30
53
|
export declare const addressQueue = "aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F";
|
|
54
|
+
export declare const merkleTree2Pubkey = "smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho";
|
|
55
|
+
export declare const nullifierQueue2Pubkey = "nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X";
|
|
31
56
|
export declare const confirmConfig: ConfirmOptions;
|
|
32
57
|
export declare const DEFAULT_MERKLE_TREE_HEIGHT = 26;
|
|
33
58
|
export declare const DEFAULT_MERKLE_TREE_ROOTS = 2800;
|