@lightprotocol/stateless.js 0.18.0 → 0.20.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 +39 -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-interface.d.ts +107 -107
- package/dist/cjs/browser/rpc.d.ts +47 -8
- package/dist/cjs/browser/state/types.d.ts +24 -0
- package/dist/cjs/browser/test-helpers/index.d.ts +1 -0
- package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +14 -0
- package/dist/cjs/browser/utils/get-light-state-tree-info.d.ts +76 -0
- package/dist/cjs/browser/utils/index.d.ts +1 -1
- package/dist/cjs/node/constants.d.ts +39 -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-interface.d.ts +107 -107
- package/dist/cjs/node/rpc.d.ts +47 -8
- package/dist/cjs/node/state/types.d.ts +24 -0
- package/dist/cjs/node/test-helpers/index.d.ts +1 -0
- package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +14 -0
- package/dist/cjs/node/utils/get-light-state-tree-info.d.ts +76 -0
- package/dist/cjs/node/utils/index.d.ts +1 -1
- package/dist/types/index.d.ts +247 -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
|
@@ -2,6 +2,30 @@ import BN from 'bn.js';
|
|
|
2
2
|
import { PublicKey } from '@solana/web3.js';
|
|
3
3
|
import { Buffer } from 'buffer';
|
|
4
4
|
import { NewAddressParamsPacked } from '../utils';
|
|
5
|
+
export declare enum TreeType {
|
|
6
|
+
/**
|
|
7
|
+
* v1 state merkle tree
|
|
8
|
+
*/
|
|
9
|
+
State = 0,
|
|
10
|
+
/**
|
|
11
|
+
* v1 address merkle tree
|
|
12
|
+
*/
|
|
13
|
+
Address = 1,
|
|
14
|
+
/**
|
|
15
|
+
* v2 state merkle tree
|
|
16
|
+
*/
|
|
17
|
+
BatchedState = 2,
|
|
18
|
+
/**
|
|
19
|
+
* v2 address merkle tree
|
|
20
|
+
*/
|
|
21
|
+
BatchedAddress = 3
|
|
22
|
+
}
|
|
23
|
+
export type ActiveTreeBundle = {
|
|
24
|
+
tree: PublicKey;
|
|
25
|
+
queue: PublicKey | null;
|
|
26
|
+
cpiContext: PublicKey | null;
|
|
27
|
+
treeType: TreeType;
|
|
28
|
+
};
|
|
5
29
|
export interface PackedCompressedAccountWithMerkleContext {
|
|
6
30
|
compressedAccount: CompressedAccount;
|
|
7
31
|
merkleContext: PackedMerkleContext;
|
|
@@ -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 { ActiveTreeBundle } from '../../state/types';
|
|
7
8
|
export interface TestRpcConfig {
|
|
8
9
|
/**
|
|
9
10
|
* Address of the state tree to index. Default: public default test state
|
|
@@ -74,6 +75,7 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
74
75
|
lightWasm: LightWasm;
|
|
75
76
|
depth: number;
|
|
76
77
|
log: boolean;
|
|
78
|
+
activeStateTreeInfo: ActiveTreeBundle[] | null;
|
|
77
79
|
/**
|
|
78
80
|
* Establish a Compression-compatible JSON RPC mock-connection
|
|
79
81
|
*
|
|
@@ -87,6 +89,18 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
87
89
|
* @param testRpcConfig Config for the mock rpc
|
|
88
90
|
*/
|
|
89
91
|
constructor(endpoint: string, hasher: LightWasm, compressionApiEndpoint: string, proverEndpoint: string, connectionConfig?: ConnectionConfig, testRpcConfig?: TestRpcConfig);
|
|
92
|
+
/**
|
|
93
|
+
* Manually set state tree addresses
|
|
94
|
+
*/
|
|
95
|
+
setStateTreeInfo(info: ActiveTreeBundle[]): void;
|
|
96
|
+
/**
|
|
97
|
+
* Returns local test state trees.
|
|
98
|
+
*/
|
|
99
|
+
getCachedActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Returns local test state trees.
|
|
102
|
+
*/
|
|
103
|
+
getLatestActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
|
|
90
104
|
/**
|
|
91
105
|
* Fetch the compressed account for the specified account hash
|
|
92
106
|
*/
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { ActiveTreeBundle } from '../state/types';
|
|
3
|
+
/**
|
|
4
|
+
* Create two lookup tables storing all public state tree and queue addresses
|
|
5
|
+
* returns lookup table addresses and txId
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
* @param connection - Connection to the Solana network
|
|
9
|
+
* @param payer - Keypair of the payer
|
|
10
|
+
* @param authority - Keypair of the authority
|
|
11
|
+
* @param recentSlot - Slot of the recent block
|
|
12
|
+
*/
|
|
13
|
+
export declare function createStateTreeLookupTable({ connection, payer, authority, recentSlot, }: {
|
|
14
|
+
connection: Connection;
|
|
15
|
+
payer: Keypair;
|
|
16
|
+
authority: Keypair;
|
|
17
|
+
recentSlot: number;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
address: PublicKey;
|
|
20
|
+
txId: string;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Extend state tree lookup table with new state tree and queue addresses
|
|
24
|
+
* @internal
|
|
25
|
+
* @param connection - Connection to the Solana network
|
|
26
|
+
* @param tableAddress - Address of the lookup table to extend
|
|
27
|
+
* @param newStateTreeAddresses - Addresses of the new state trees to add
|
|
28
|
+
* @param newQueueAddresses - Addresses of the new queues to add
|
|
29
|
+
* @param newCpiContextAddresses - Addresses of the new cpi contexts to add
|
|
30
|
+
* @param payer - Keypair of the payer
|
|
31
|
+
* @param authority - Keypair of the authority
|
|
32
|
+
*/
|
|
33
|
+
export declare function extendStateTreeLookupTable({ connection, tableAddress, newStateTreeAddresses, newQueueAddresses, newCpiContextAddresses, payer, authority, }: {
|
|
34
|
+
connection: Connection;
|
|
35
|
+
tableAddress: PublicKey;
|
|
36
|
+
newStateTreeAddresses: PublicKey[];
|
|
37
|
+
newQueueAddresses: PublicKey[];
|
|
38
|
+
newCpiContextAddresses: PublicKey[];
|
|
39
|
+
payer: Keypair;
|
|
40
|
+
authority: Keypair;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
tableAddress: PublicKey;
|
|
43
|
+
txId: string;
|
|
44
|
+
}>;
|
|
45
|
+
/**
|
|
46
|
+
* Adds state tree address to lookup table. Acts as nullifier lookup for rolled
|
|
47
|
+
* over state trees.
|
|
48
|
+
* @internal
|
|
49
|
+
* @param connection - Connection to the Solana network
|
|
50
|
+
* @param stateTreeAddress - Address of the state tree to nullify
|
|
51
|
+
* @param nullifyTableAddress - Address of the nullifier lookup table to store
|
|
52
|
+
* address in
|
|
53
|
+
* @param stateTreeLookupTableAddress - lookup table storing all state tree
|
|
54
|
+
* addresses
|
|
55
|
+
* @param payer - Keypair of the payer
|
|
56
|
+
* @param authority - Keypair of the authority
|
|
57
|
+
*/
|
|
58
|
+
export declare function nullifyLookupTable({ connection, fullStateTreeAddress, nullifyTableAddress, stateTreeLookupTableAddress, payer, authority, }: {
|
|
59
|
+
connection: Connection;
|
|
60
|
+
fullStateTreeAddress: PublicKey;
|
|
61
|
+
nullifyTableAddress: PublicKey;
|
|
62
|
+
stateTreeLookupTableAddress: PublicKey;
|
|
63
|
+
payer: Keypair;
|
|
64
|
+
authority: Keypair;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
txId: string;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Get most recent , active state tree data
|
|
70
|
+
* we store in lookup table for each public state tree
|
|
71
|
+
*/
|
|
72
|
+
export declare function getLightStateTreeInfo({ connection, stateTreeLookupTableAddress, nullifyTableAddress, }: {
|
|
73
|
+
connection: Connection;
|
|
74
|
+
stateTreeLookupTableAddress: PublicKey;
|
|
75
|
+
nullifyTableAddress: PublicKey;
|
|
76
|
+
}): Promise<ActiveTreeBundle[]>;
|
|
@@ -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';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import BN from 'bn.js';
|
|
2
2
|
import { Buffer } from 'buffer';
|
|
3
3
|
import { ConfirmOptions, PublicKey } from '@solana/web3.js';
|
|
4
|
+
import { ActiveTreeBundle } from './state/types';
|
|
4
5
|
export declare const FIELD_SIZE: BN;
|
|
5
6
|
export declare const HIGHEST_ADDRESS_PLUS_ONE: BN;
|
|
6
7
|
export declare const INVOKE_DISCRIMINATOR: Buffer;
|
|
@@ -17,6 +18,29 @@ export declare const defaultStaticAccountsStruct: () => {
|
|
|
17
18
|
accountCompressionAuthority: PublicKey;
|
|
18
19
|
cpiSignatureAccount: null;
|
|
19
20
|
};
|
|
21
|
+
export type StateTreeLUTPair = {
|
|
22
|
+
stateTreeLookupTable: PublicKey;
|
|
23
|
+
nullifyTable: PublicKey;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Returns the Default Public State Tree LUTs for Devnet and Mainnet-Beta.
|
|
27
|
+
*/
|
|
28
|
+
export declare const defaultStateTreeLookupTables: () => {
|
|
29
|
+
mainnet: StateTreeLUTPair[];
|
|
30
|
+
devnet: StateTreeLUTPair[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* @internal
|
|
34
|
+
*/
|
|
35
|
+
export declare const isLocalTest: (url: string) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare const localTestActiveStateTreeInfo: () => ActiveTreeBundle[];
|
|
40
|
+
/**
|
|
41
|
+
* Use only with Localnet testing.
|
|
42
|
+
* For public networks, fetch via {@link defaultStateTreeLookupTables} and {@link getLightStateTreeInfo}.
|
|
43
|
+
*/
|
|
20
44
|
export declare const defaultTestStateTreeAccounts: () => {
|
|
21
45
|
nullifierQueue: PublicKey;
|
|
22
46
|
merkleTree: PublicKey;
|
|
@@ -24,10 +48,25 @@ export declare const defaultTestStateTreeAccounts: () => {
|
|
|
24
48
|
addressTree: PublicKey;
|
|
25
49
|
addressQueue: PublicKey;
|
|
26
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* @internal testing only
|
|
53
|
+
*/
|
|
54
|
+
export declare const defaultTestStateTreeAccounts2: () => {
|
|
55
|
+
nullifierQueue2: PublicKey;
|
|
56
|
+
merkleTree2: PublicKey;
|
|
57
|
+
};
|
|
58
|
+
export declare const stateTreeLookupTableMainnet = "7i86eQs3GSqHjN47WdWLTCGMW6gde1q96G2EVnUyK2st";
|
|
59
|
+
export declare const nullifiedStateTreeLookupTableMainnet = "H9QD4u1fG7KmkAzn2tDXhheushxFe1EcrjGGyEFXeMqT";
|
|
60
|
+
export declare const stateTreeLookupTableDevnet = "8n8rH2bFRVA6cSGNDpgqcKHCndbFCT1bXxAQG89ejVsh";
|
|
61
|
+
export declare const nullifiedStateTreeLookupTableDevnet = "5dhaJLBjnVBQFErr8oiCJmcVsx3Zj6xDekGB2zULPsnP";
|
|
27
62
|
export declare const nullifierQueuePubkey = "nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148";
|
|
63
|
+
export declare const cpiContextPubkey = "cpi1uHzrEhBG733DoEJNgHCyRS3XmmyVNZx5fonubE4";
|
|
28
64
|
export declare const merkletreePubkey = "smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT";
|
|
29
65
|
export declare const addressTree = "amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2";
|
|
30
66
|
export declare const addressQueue = "aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F";
|
|
67
|
+
export declare const merkleTree2Pubkey = "smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho";
|
|
68
|
+
export declare const nullifierQueue2Pubkey = "nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X";
|
|
69
|
+
export declare const cpiContext2Pubkey = "cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK";
|
|
31
70
|
export declare const confirmConfig: ConfirmOptions;
|
|
32
71
|
export declare const DEFAULT_MERKLE_TREE_HEIGHT = 26;
|
|
33
72
|
export declare const DEFAULT_MERKLE_TREE_ROOTS = 2800;
|