@lightprotocol/stateless.js 0.19.0 → 0.20.1
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 +1 -1
- package/dist/cjs/browser/constants.d.ts +33 -16
- 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 -0
- package/dist/cjs/browser/logger.d.ts +1 -0
- package/dist/cjs/browser/programs/layout.d.ts +17 -1
- package/dist/cjs/browser/rpc-interface.d.ts +109 -109
- package/dist/cjs/browser/rpc.d.ts +8 -9
- package/dist/cjs/browser/state/types.d.ts +39 -0
- package/dist/cjs/browser/test-helpers/test-rpc/get-parsed-events.d.ts +3 -1
- package/dist/cjs/browser/test-helpers/test-rpc/test-rpc.d.ts +5 -6
- package/dist/cjs/browser/utils/get-light-state-tree-info.d.ts +11 -9
- package/dist/cjs/node/constants.d.ts +33 -16
- 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 -0
- package/dist/cjs/node/logger.d.ts +1 -0
- package/dist/cjs/node/programs/layout.d.ts +17 -1
- package/dist/cjs/node/rpc-interface.d.ts +109 -109
- package/dist/cjs/node/rpc.d.ts +8 -9
- package/dist/cjs/node/state/types.d.ts +39 -0
- package/dist/cjs/node/test-helpers/test-rpc/get-parsed-events.d.ts +3 -1
- package/dist/cjs/node/test-helpers/test-rpc/test-rpc.d.ts +5 -6
- package/dist/cjs/node/utils/get-light-state-tree-info.d.ts +11 -9
- package/dist/types/index.d.ts +116 -43
- package/package.json +7 -2
|
@@ -4,7 +4,7 @@ import { CompressedProofWithContext, CompressedTransaction, CompressionApiInterf
|
|
|
4
4
|
import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, CompressedProof } from './state';
|
|
5
5
|
import BN from 'bn.js';
|
|
6
6
|
import { LightWasm } from './test-helpers';
|
|
7
|
-
import {
|
|
7
|
+
import { ActiveTreeBundle } from './state/types';
|
|
8
8
|
/** @internal */
|
|
9
9
|
export declare function parseAccountData({ discriminator, data, dataHash, }: {
|
|
10
10
|
discriminator: BN;
|
|
@@ -70,7 +70,7 @@ export declare function getPublicInputHash(accountProofs: MerkleContextWithMerkl
|
|
|
70
70
|
* @param tree - The tree to get the queue for
|
|
71
71
|
* @returns The queue for the given tree, or undefined if not found
|
|
72
72
|
*/
|
|
73
|
-
export declare function getQueueForTree(info:
|
|
73
|
+
export declare function getQueueForTree(info: ActiveTreeBundle[], tree: PublicKey): PublicKey;
|
|
74
74
|
/**
|
|
75
75
|
* Get the tree for a given queue
|
|
76
76
|
*
|
|
@@ -78,7 +78,7 @@ export declare function getQueueForTree(info: ActiveStateTreeAddresses, tree: Pu
|
|
|
78
78
|
* @param queue - The queue to get the tree for
|
|
79
79
|
* @returns The tree for the given queue, or undefined if not found
|
|
80
80
|
*/
|
|
81
|
-
export declare function getTreeForQueue(info:
|
|
81
|
+
export declare function getTreeForQueue(info: ActiveTreeBundle[], queue: PublicKey): PublicKey;
|
|
82
82
|
/**
|
|
83
83
|
* Get a random tree and queue from the active state tree addresses.
|
|
84
84
|
*
|
|
@@ -87,7 +87,7 @@ export declare function getTreeForQueue(info: ActiveStateTreeAddresses, queue: P
|
|
|
87
87
|
* @param info - The active state tree addresses
|
|
88
88
|
* @returns A random tree and queue
|
|
89
89
|
*/
|
|
90
|
-
export declare function pickRandomTreeAndQueue(info:
|
|
90
|
+
export declare function pickRandomTreeAndQueue(info: ActiveTreeBundle[]): {
|
|
91
91
|
tree: PublicKey;
|
|
92
92
|
queue: PublicKey;
|
|
93
93
|
};
|
|
@@ -97,22 +97,21 @@ export declare function pickRandomTreeAndQueue(info: ActiveStateTreeAddresses):
|
|
|
97
97
|
export declare class Rpc extends Connection implements CompressionApiInterface {
|
|
98
98
|
compressionApiEndpoint: string;
|
|
99
99
|
proverEndpoint: string;
|
|
100
|
-
activeStateTreeInfo:
|
|
101
|
-
fetchStateTreePromise: Promise<ActiveStateTreeAddresses> | null;
|
|
100
|
+
activeStateTreeInfo: ActiveTreeBundle[] | null;
|
|
102
101
|
constructor(endpoint: string, compressionApiEndpoint: string, proverEndpoint: string, config?: ConnectionConfig);
|
|
103
102
|
/**
|
|
104
103
|
* Manually set state tree addresses
|
|
105
104
|
*/
|
|
106
|
-
setStateTreeInfo(info:
|
|
105
|
+
setStateTreeInfo(info: ActiveTreeBundle[]): void;
|
|
107
106
|
/**
|
|
108
107
|
* Get the active state tree addresses from the cluster.
|
|
109
108
|
* If not already cached, fetches from the cluster.
|
|
110
109
|
*/
|
|
111
|
-
getCachedActiveStateTreeInfo(): Promise<
|
|
110
|
+
getCachedActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
|
|
112
111
|
/**
|
|
113
112
|
* Fetch the latest state tree addresses from the cluster.
|
|
114
113
|
*/
|
|
115
|
-
getLatestActiveStateTreeInfo(): Promise<
|
|
114
|
+
getLatestActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
|
|
116
115
|
/**
|
|
117
116
|
* Fetch the compressed account for the specified account address or hash
|
|
118
117
|
*/
|
|
@@ -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;
|
|
@@ -73,6 +97,21 @@ export interface InstructionDataInvoke {
|
|
|
73
97
|
compressOrDecompressLamports: BN | null;
|
|
74
98
|
isCompress: boolean;
|
|
75
99
|
}
|
|
100
|
+
export interface InstructionDataInvokeCpi {
|
|
101
|
+
proof: CompressedProof | null;
|
|
102
|
+
inputCompressedAccountsWithMerkleContext: PackedCompressedAccountWithMerkleContext[];
|
|
103
|
+
outputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
|
|
104
|
+
relayFee: BN | null;
|
|
105
|
+
newAddressParams: NewAddressParamsPacked[];
|
|
106
|
+
compressOrDecompressLamports: BN | null;
|
|
107
|
+
isCompress: boolean;
|
|
108
|
+
compressedCpiContext: CompressedCpiContext | null;
|
|
109
|
+
}
|
|
110
|
+
export interface CompressedCpiContext {
|
|
111
|
+
set_context: boolean;
|
|
112
|
+
first_set_context: boolean;
|
|
113
|
+
cpi_context_account_index: number;
|
|
114
|
+
}
|
|
76
115
|
export interface CompressedProof {
|
|
77
116
|
a: number[];
|
|
78
117
|
b: number[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ParsedTransactionWithMeta } from '@solana/web3.js';
|
|
1
|
+
import { ParsedTransactionWithMeta, PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { Rpc } from '../../rpc';
|
|
3
3
|
import { PublicTransactionEvent } from '../../state';
|
|
4
|
+
import { Buffer } from 'buffer';
|
|
4
5
|
type Deserializer<T> = (data: Buffer, tx: ParsedTransactionWithMeta) => T;
|
|
5
6
|
/**
|
|
6
7
|
* @internal
|
|
@@ -10,4 +11,5 @@ type Deserializer<T> = (data: Buffer, tx: ParsedTransactionWithMeta) => T;
|
|
|
10
11
|
export declare function getParsedEvents(rpc: Rpc): Promise<PublicTransactionEvent[]>;
|
|
11
12
|
export declare const parseEvents: <T>(indexerEventsTransactions: (ParsedTransactionWithMeta | null)[], deserializeFn: Deserializer<T>) => NonNullable<T>[];
|
|
12
13
|
export declare const parsePublicTransactionEventWithIdl: (data: Buffer) => PublicTransactionEvent | null;
|
|
14
|
+
export declare function parseLightTransaction(dataVec: Uint8Array[], accountKeys: PublicKey[][]): PublicTransactionEvent | null | undefined;
|
|
13
15
|
export {};
|
|
@@ -4,7 +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 {
|
|
7
|
+
import { ActiveTreeBundle } from '../../state/types';
|
|
8
8
|
export interface TestRpcConfig {
|
|
9
9
|
/**
|
|
10
10
|
* Address of the state tree to index. Default: public default test state
|
|
@@ -75,8 +75,7 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
75
75
|
lightWasm: LightWasm;
|
|
76
76
|
depth: number;
|
|
77
77
|
log: boolean;
|
|
78
|
-
activeStateTreeInfo:
|
|
79
|
-
fetchStateTreePromise: Promise<ActiveStateTreeAddresses> | null;
|
|
78
|
+
activeStateTreeInfo: ActiveTreeBundle[] | null;
|
|
80
79
|
/**
|
|
81
80
|
* Establish a Compression-compatible JSON RPC mock-connection
|
|
82
81
|
*
|
|
@@ -93,15 +92,15 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
93
92
|
/**
|
|
94
93
|
* Manually set state tree addresses
|
|
95
94
|
*/
|
|
96
|
-
setStateTreeInfo(info:
|
|
95
|
+
setStateTreeInfo(info: ActiveTreeBundle[]): void;
|
|
97
96
|
/**
|
|
98
97
|
* Returns local test state trees.
|
|
99
98
|
*/
|
|
100
|
-
getCachedActiveStateTreeInfo(): Promise<
|
|
99
|
+
getCachedActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
|
|
101
100
|
/**
|
|
102
101
|
* Returns local test state trees.
|
|
103
102
|
*/
|
|
104
|
-
getLatestActiveStateTreeInfo(): Promise<
|
|
103
|
+
getLatestActiveStateTreeInfo(): Promise<ActiveTreeBundle[]>;
|
|
105
104
|
/**
|
|
106
105
|
* Fetch the compressed account for the specified account hash
|
|
107
106
|
*/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Connection, Keypair, PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { ActiveTreeBundle } from '../state/types';
|
|
2
3
|
/**
|
|
3
4
|
* Create two lookup tables storing all public state tree and queue addresses
|
|
4
5
|
* returns lookup table addresses and txId
|
|
@@ -25,14 +26,16 @@ export declare function createStateTreeLookupTable({ connection, payer, authorit
|
|
|
25
26
|
* @param tableAddress - Address of the lookup table to extend
|
|
26
27
|
* @param newStateTreeAddresses - Addresses of the new state trees to add
|
|
27
28
|
* @param newQueueAddresses - Addresses of the new queues to add
|
|
29
|
+
* @param newCpiContextAddresses - Addresses of the new cpi contexts to add
|
|
28
30
|
* @param payer - Keypair of the payer
|
|
29
31
|
* @param authority - Keypair of the authority
|
|
30
32
|
*/
|
|
31
|
-
export declare function extendStateTreeLookupTable({ connection, tableAddress, newStateTreeAddresses, newQueueAddresses, payer, authority, }: {
|
|
33
|
+
export declare function extendStateTreeLookupTable({ connection, tableAddress, newStateTreeAddresses, newQueueAddresses, newCpiContextAddresses, payer, authority, }: {
|
|
32
34
|
connection: Connection;
|
|
33
35
|
tableAddress: PublicKey;
|
|
34
36
|
newStateTreeAddresses: PublicKey[];
|
|
35
37
|
newQueueAddresses: PublicKey[];
|
|
38
|
+
newCpiContextAddresses: PublicKey[];
|
|
36
39
|
payer: Keypair;
|
|
37
40
|
authority: Keypair;
|
|
38
41
|
}): Promise<{
|
|
@@ -40,12 +43,15 @@ export declare function extendStateTreeLookupTable({ connection, tableAddress, n
|
|
|
40
43
|
txId: string;
|
|
41
44
|
}>;
|
|
42
45
|
/**
|
|
43
|
-
* Adds
|
|
46
|
+
* Adds state tree address to lookup table. Acts as nullifier lookup for rolled
|
|
47
|
+
* over state trees.
|
|
44
48
|
* @internal
|
|
45
49
|
* @param connection - Connection to the Solana network
|
|
46
50
|
* @param stateTreeAddress - Address of the state tree to nullify
|
|
47
|
-
* @param nullifyTableAddress - Address nullifier lookup table to store
|
|
48
|
-
*
|
|
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
|
|
49
55
|
* @param payer - Keypair of the payer
|
|
50
56
|
* @param authority - Keypair of the authority
|
|
51
57
|
*/
|
|
@@ -59,10 +65,6 @@ export declare function nullifyLookupTable({ connection, fullStateTreeAddress, n
|
|
|
59
65
|
}): Promise<{
|
|
60
66
|
txId: string;
|
|
61
67
|
}>;
|
|
62
|
-
export type ActiveStateTreeAddresses = {
|
|
63
|
-
activeStateTrees: PublicKey[];
|
|
64
|
-
activeQueues: PublicKey[];
|
|
65
|
-
};
|
|
66
68
|
/**
|
|
67
69
|
* Get most recent , active state tree data
|
|
68
70
|
* we store in lookup table for each public state tree
|
|
@@ -71,4 +73,4 @@ export declare function getLightStateTreeInfo({ connection, stateTreeLookupTable
|
|
|
71
73
|
connection: Connection;
|
|
72
74
|
stateTreeLookupTableAddress: PublicKey;
|
|
73
75
|
nullifyTableAddress: PublicKey;
|
|
74
|
-
}): Promise<
|
|
76
|
+
}): Promise<ActiveTreeBundle[]>;
|
|
@@ -1,9 +1,13 @@
|
|
|
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;
|
|
7
|
+
export declare const COMPUTE_BUDGET_PATTERN: number[];
|
|
6
8
|
export declare const INVOKE_DISCRIMINATOR: Buffer;
|
|
9
|
+
export declare const INVOKE_CPI_DISCRIMINATOR: Buffer;
|
|
10
|
+
export declare const INSERT_INTO_QUEUES_DISCRIMINATOR: Buffer;
|
|
7
11
|
export declare const noopProgram = "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV";
|
|
8
12
|
export declare const lightProgram = "SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7";
|
|
9
13
|
export declare const accountCompressionProgram = "compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq";
|
|
@@ -17,21 +21,29 @@ export declare const defaultStaticAccountsStruct: () => {
|
|
|
17
21
|
accountCompressionAuthority: PublicKey;
|
|
18
22
|
cpiSignatureAccount: null;
|
|
19
23
|
};
|
|
24
|
+
export type StateTreeLUTPair = {
|
|
25
|
+
stateTreeLookupTable: PublicKey;
|
|
26
|
+
nullifyTable: PublicKey;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Returns the Default Public State Tree LUTs for Devnet and Mainnet-Beta.
|
|
30
|
+
*/
|
|
20
31
|
export declare const defaultStateTreeLookupTables: () => {
|
|
21
|
-
mainnet:
|
|
22
|
-
|
|
23
|
-
nullifyTable: PublicKey;
|
|
24
|
-
};
|
|
25
|
-
devnet: {
|
|
26
|
-
stateTreeLookupTable: PublicKey;
|
|
27
|
-
nullifyTable: PublicKey;
|
|
28
|
-
};
|
|
32
|
+
mainnet: StateTreeLUTPair[];
|
|
33
|
+
devnet: StateTreeLUTPair[];
|
|
29
34
|
};
|
|
35
|
+
/**
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
30
38
|
export declare const isLocalTest: (url: string) => boolean;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
export declare const localTestActiveStateTreeInfo: () => ActiveTreeBundle[];
|
|
43
|
+
/**
|
|
44
|
+
* Use only with Localnet testing.
|
|
45
|
+
* For public networks, fetch via {@link defaultStateTreeLookupTables} and {@link getLightStateTreeInfo}.
|
|
46
|
+
*/
|
|
35
47
|
export declare const defaultTestStateTreeAccounts: () => {
|
|
36
48
|
nullifierQueue: PublicKey;
|
|
37
49
|
merkleTree: PublicKey;
|
|
@@ -39,20 +51,25 @@ export declare const defaultTestStateTreeAccounts: () => {
|
|
|
39
51
|
addressTree: PublicKey;
|
|
40
52
|
addressQueue: PublicKey;
|
|
41
53
|
};
|
|
54
|
+
/**
|
|
55
|
+
* @internal testing only
|
|
56
|
+
*/
|
|
42
57
|
export declare const defaultTestStateTreeAccounts2: () => {
|
|
43
58
|
nullifierQueue2: PublicKey;
|
|
44
59
|
merkleTree2: PublicKey;
|
|
45
60
|
};
|
|
46
|
-
export declare const stateTreeLookupTableMainnet = "
|
|
47
|
-
export declare const nullifiedStateTreeLookupTableMainnet = "
|
|
48
|
-
export declare const stateTreeLookupTableDevnet = "
|
|
49
|
-
export declare const nullifiedStateTreeLookupTableDevnet = "
|
|
61
|
+
export declare const stateTreeLookupTableMainnet = "7i86eQs3GSqHjN47WdWLTCGMW6gde1q96G2EVnUyK2st";
|
|
62
|
+
export declare const nullifiedStateTreeLookupTableMainnet = "H9QD4u1fG7KmkAzn2tDXhheushxFe1EcrjGGyEFXeMqT";
|
|
63
|
+
export declare const stateTreeLookupTableDevnet = "8n8rH2bFRVA6cSGNDpgqcKHCndbFCT1bXxAQG89ejVsh";
|
|
64
|
+
export declare const nullifiedStateTreeLookupTableDevnet = "5dhaJLBjnVBQFErr8oiCJmcVsx3Zj6xDekGB2zULPsnP";
|
|
50
65
|
export declare const nullifierQueuePubkey = "nfq1NvQDJ2GEgnS8zt9prAe8rjjpAW1zFkrvZoBR148";
|
|
66
|
+
export declare const cpiContextPubkey = "cpi1uHzrEhBG733DoEJNgHCyRS3XmmyVNZx5fonubE4";
|
|
51
67
|
export declare const merkletreePubkey = "smt1NamzXdq4AMqS2fS2F1i5KTYPZRhoHgWx38d8WsT";
|
|
52
68
|
export declare const addressTree = "amt1Ayt45jfbdw5YSo7iz6WZxUmnZsQTYXy82hVwyC2";
|
|
53
69
|
export declare const addressQueue = "aq1S9z4reTSQAdgWHGD2zDaS39sjGrAxbR31vxJ2F4F";
|
|
54
70
|
export declare const merkleTree2Pubkey = "smt2rJAFdyJJupwMKAqTNAJwvjhmiZ4JYGZmbVRw1Ho";
|
|
55
71
|
export declare const nullifierQueue2Pubkey = "nfq2hgS7NYemXsFaFUCe3EMXSDSfnZnAe27jC6aPP1X";
|
|
72
|
+
export declare const cpiContext2Pubkey = "cpi2cdhkH5roePvcudTgUL8ppEBfTay1desGh8G8QxK";
|
|
56
73
|
export declare const confirmConfig: ConfirmOptions;
|
|
57
74
|
export declare const DEFAULT_MERKLE_TREE_HEIGHT = 26;
|
|
58
75
|
export declare const DEFAULT_MERKLE_TREE_ROOTS = 2800;
|