@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
|
@@ -4,7 +4,7 @@ import { ValidityProofWithContext, CompressedTransaction, CompressionApiInterfac
|
|
|
4
4
|
import { MerkleContextWithMerkleProof, BN254, CompressedAccountWithMerkleContext, ValidityProof, AddressTreeInfo } 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;
|
|
@@ -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
|
*
|
|
@@ -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;
|
|
@@ -2,6 +2,7 @@ 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
|
+
import { PackedCompressedAccountWithMerkleContext } from './compressed-account';
|
|
5
6
|
export declare enum TreeType {
|
|
6
7
|
/**
|
|
7
8
|
* v1 state merkle tree
|
|
@@ -21,24 +22,43 @@ export declare enum TreeType {
|
|
|
21
22
|
AddressV2 = 4
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
|
-
* @deprecated Use {@link
|
|
25
|
+
* @deprecated Use {@link TreeInfo} instead.
|
|
25
26
|
*
|
|
26
27
|
* A bundle of active trees for a given tree type.
|
|
27
28
|
*/
|
|
28
29
|
export type ActiveTreeBundle = {
|
|
30
|
+
/**
|
|
31
|
+
* Tree.
|
|
32
|
+
*/
|
|
29
33
|
tree: PublicKey;
|
|
34
|
+
/**
|
|
35
|
+
* Queue.
|
|
36
|
+
*/
|
|
30
37
|
queue: PublicKey | null;
|
|
38
|
+
/**
|
|
39
|
+
* CPI context.
|
|
40
|
+
*/
|
|
31
41
|
cpiContext: PublicKey | null;
|
|
42
|
+
/**
|
|
43
|
+
* Tree type.
|
|
44
|
+
*/
|
|
32
45
|
treeType: TreeType;
|
|
33
46
|
};
|
|
34
47
|
/**
|
|
48
|
+
* @deprecated Use {@link TreeInfo} instead.
|
|
49
|
+
*
|
|
35
50
|
* State tree info, versioned via {@link TreeType}. The protocol
|
|
36
51
|
* stores compressed accounts in state trees.
|
|
52
|
+
*/
|
|
53
|
+
export type StateTreeInfo = TreeInfo;
|
|
54
|
+
/**
|
|
55
|
+
* Tree info, versioned via {@link TreeType}. The protocol
|
|
56
|
+
* stores compressed accounts in state trees, and PDAs in address trees.
|
|
37
57
|
*
|
|
38
58
|
* Onchain Accounts are subject to Solana's write-lock limits.
|
|
39
59
|
*
|
|
40
60
|
* To load balance transactions, use {@link selectStateTreeInfo} to
|
|
41
|
-
* select a
|
|
61
|
+
* randomly select a tree from a range of active trees.
|
|
42
62
|
*
|
|
43
63
|
* Example:
|
|
44
64
|
* ```typescript
|
|
@@ -50,7 +70,7 @@ export type ActiveTreeBundle = {
|
|
|
50
70
|
* });
|
|
51
71
|
* ```
|
|
52
72
|
*/
|
|
53
|
-
export type
|
|
73
|
+
export type TreeInfo = {
|
|
54
74
|
/**
|
|
55
75
|
* Pubkey of the tree account.
|
|
56
76
|
*/
|
|
@@ -68,38 +88,52 @@ export type StateTreeInfo = {
|
|
|
68
88
|
*/
|
|
69
89
|
cpiContext?: PublicKey;
|
|
70
90
|
/**
|
|
71
|
-
*
|
|
91
|
+
* Next tree info. Is `some` if the next tree should be used for the next
|
|
92
|
+
* state transition.
|
|
72
93
|
*/
|
|
73
|
-
nextTreeInfo:
|
|
94
|
+
nextTreeInfo: TreeInfo | null;
|
|
74
95
|
};
|
|
75
96
|
/**
|
|
97
|
+
* @deprecated Use {@link TreeInfo} instead.
|
|
98
|
+
*
|
|
76
99
|
* Address tree info, versioned via {@link TreeType}. The protocol
|
|
77
100
|
* stores PDAs in address trees.
|
|
78
101
|
*/
|
|
79
102
|
export type AddressTreeInfo = Omit<StateTreeInfo, 'cpiContext' | 'nextTreeInfo'> & {
|
|
103
|
+
/**
|
|
104
|
+
* Next tree info.
|
|
105
|
+
*/
|
|
80
106
|
nextTreeInfo: AddressTreeInfo | null;
|
|
81
107
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
108
|
+
/**
|
|
109
|
+
* Packed merkle context.
|
|
110
|
+
*/
|
|
111
|
+
export interface PackedMerkleContextLegacy {
|
|
112
|
+
/**
|
|
113
|
+
* Merkle tree pubkey index.
|
|
114
|
+
*/
|
|
89
115
|
merkleTreePubkeyIndex: number;
|
|
90
|
-
|
|
116
|
+
/**
|
|
117
|
+
* Queue pubkey index in remaining accounts.
|
|
118
|
+
*/
|
|
119
|
+
queuePubkeyIndex: number;
|
|
120
|
+
/**
|
|
121
|
+
* Leaf index.
|
|
122
|
+
*/
|
|
91
123
|
leafIndex: number;
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
index: number;
|
|
124
|
+
/**
|
|
125
|
+
* Whether to prove by index or validity proof.
|
|
126
|
+
*/
|
|
127
|
+
proveByIndex: boolean;
|
|
97
128
|
}
|
|
98
129
|
/**
|
|
130
|
+
* @deprecated Use {@link CompressedAccount} instead.
|
|
131
|
+
*
|
|
99
132
|
* Describe the generic compressed account details applicable to every
|
|
100
133
|
* compressed account.
|
|
134
|
+
*
|
|
101
135
|
* */
|
|
102
|
-
export interface
|
|
136
|
+
export interface CompressedAccountLegacy {
|
|
103
137
|
/**
|
|
104
138
|
* Public key of program or user owning the account.
|
|
105
139
|
*/
|
|
@@ -118,64 +152,217 @@ export interface CompressedAccount {
|
|
|
118
152
|
data: CompressedAccountData | null;
|
|
119
153
|
}
|
|
120
154
|
/**
|
|
155
|
+
* @deprecated Use {@link CompressedAccountMeta} instead.
|
|
156
|
+
*
|
|
121
157
|
* Describe the generic compressed account details applicable to every
|
|
122
158
|
* compressed account.
|
|
123
159
|
*/
|
|
124
160
|
export interface OutputCompressedAccountWithPackedContext {
|
|
125
|
-
compressedAccount:
|
|
161
|
+
compressedAccount: CompressedAccountLegacy;
|
|
126
162
|
merkleTreeIndex: number;
|
|
127
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Compressed account-related proof metadata.
|
|
166
|
+
*/
|
|
167
|
+
export type AccountProofInput = {
|
|
168
|
+
hash: BN;
|
|
169
|
+
treeInfo: TreeInfo;
|
|
170
|
+
leafIndex: number;
|
|
171
|
+
rootIndex: number;
|
|
172
|
+
proveByIndex: boolean;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* New address proof metadata.
|
|
176
|
+
*/
|
|
177
|
+
export type NewAddressProofInput = {
|
|
178
|
+
treeInfo: TreeInfo;
|
|
179
|
+
address: number[];
|
|
180
|
+
rootIndex: number;
|
|
181
|
+
root: BN;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* Describes compressed account data.
|
|
185
|
+
*/
|
|
128
186
|
export interface CompressedAccountData {
|
|
187
|
+
/**
|
|
188
|
+
* 8 bytes.
|
|
189
|
+
*/
|
|
129
190
|
discriminator: number[];
|
|
191
|
+
/**
|
|
192
|
+
* Data.
|
|
193
|
+
*/
|
|
130
194
|
data: Buffer;
|
|
195
|
+
/**
|
|
196
|
+
* 32 bytes.
|
|
197
|
+
*/
|
|
131
198
|
dataHash: number[];
|
|
132
199
|
}
|
|
200
|
+
/**
|
|
201
|
+
* Merkle tree sequence number.
|
|
202
|
+
*/
|
|
133
203
|
export interface MerkleTreeSequenceNumber {
|
|
204
|
+
/**
|
|
205
|
+
* Public key.
|
|
206
|
+
*/
|
|
134
207
|
pubkey: PublicKey;
|
|
208
|
+
/**
|
|
209
|
+
* Sequence number.
|
|
210
|
+
*/
|
|
135
211
|
seq: BN;
|
|
136
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Public transaction event.
|
|
215
|
+
*/
|
|
137
216
|
export interface PublicTransactionEvent {
|
|
217
|
+
/**
|
|
218
|
+
* Input compressed account hashes.
|
|
219
|
+
*/
|
|
138
220
|
inputCompressedAccountHashes: number[][];
|
|
221
|
+
/**
|
|
222
|
+
* Output compressed account hashes.
|
|
223
|
+
*/
|
|
139
224
|
outputCompressedAccountHashes: number[][];
|
|
225
|
+
/**
|
|
226
|
+
* Output compressed accounts.
|
|
227
|
+
*/
|
|
140
228
|
outputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
|
|
229
|
+
/**
|
|
230
|
+
* Output leaf indices.
|
|
231
|
+
*/
|
|
141
232
|
outputLeafIndices: number[];
|
|
233
|
+
/**
|
|
234
|
+
* Sequence numbers.
|
|
235
|
+
*/
|
|
142
236
|
sequenceNumbers: MerkleTreeSequenceNumber[];
|
|
237
|
+
/**
|
|
238
|
+
* Relay fee. Default is null.
|
|
239
|
+
*/
|
|
143
240
|
relayFee: BN | null;
|
|
241
|
+
/**
|
|
242
|
+
* Whether it's a compress or decompress instruction.
|
|
243
|
+
*/
|
|
144
244
|
isCompress: boolean;
|
|
245
|
+
/**
|
|
246
|
+
* If some, it's either a compress or decompress instruction.
|
|
247
|
+
*/
|
|
145
248
|
compressOrDecompressLamports: BN | null;
|
|
249
|
+
/**
|
|
250
|
+
* Public keys.
|
|
251
|
+
*/
|
|
146
252
|
pubkeyArray: PublicKey[];
|
|
253
|
+
/**
|
|
254
|
+
* Message. Default is null.
|
|
255
|
+
*/
|
|
147
256
|
message: Uint8Array | null;
|
|
148
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Instruction data for invoke.
|
|
260
|
+
*/
|
|
149
261
|
export interface InstructionDataInvoke {
|
|
262
|
+
/**
|
|
263
|
+
* Validity proof.
|
|
264
|
+
*/
|
|
150
265
|
proof: ValidityProof | null;
|
|
266
|
+
/**
|
|
267
|
+
* Input compressed accounts with merkle context.
|
|
268
|
+
*/
|
|
151
269
|
inputCompressedAccountsWithMerkleContext: PackedCompressedAccountWithMerkleContext[];
|
|
270
|
+
/**
|
|
271
|
+
* Output compressed accounts.
|
|
272
|
+
*/
|
|
152
273
|
outputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
|
|
274
|
+
/**
|
|
275
|
+
* Relay fee. Default is null.
|
|
276
|
+
*/
|
|
153
277
|
relayFee: BN | null;
|
|
278
|
+
/**
|
|
279
|
+
* Params for creating new addresses.
|
|
280
|
+
*/
|
|
154
281
|
newAddressParams: NewAddressParamsPacked[];
|
|
282
|
+
/**
|
|
283
|
+
* If some, it's either a compress or decompress instruction.
|
|
284
|
+
*/
|
|
155
285
|
compressOrDecompressLamports: BN | null;
|
|
286
|
+
/**
|
|
287
|
+
* Whether it's a compress or decompress instruction.
|
|
288
|
+
*/
|
|
156
289
|
isCompress: boolean;
|
|
157
290
|
}
|
|
291
|
+
/**
|
|
292
|
+
* Instruction data for invoking a CPI.
|
|
293
|
+
*/
|
|
158
294
|
export interface InstructionDataInvokeCpi {
|
|
295
|
+
/**
|
|
296
|
+
* Validity proof.
|
|
297
|
+
*/
|
|
159
298
|
proof: ValidityProof | null;
|
|
299
|
+
/**
|
|
300
|
+
* Input compressed accounts with merkle context.
|
|
301
|
+
*/
|
|
160
302
|
inputCompressedAccountsWithMerkleContext: PackedCompressedAccountWithMerkleContext[];
|
|
303
|
+
/**
|
|
304
|
+
* Output compressed accounts.
|
|
305
|
+
*/
|
|
161
306
|
outputCompressedAccounts: OutputCompressedAccountWithPackedContext[];
|
|
307
|
+
/**
|
|
308
|
+
* Relay fee. Default is null.
|
|
309
|
+
*/
|
|
162
310
|
relayFee: BN | null;
|
|
311
|
+
/**
|
|
312
|
+
* Params for creating new addresses.
|
|
313
|
+
*/
|
|
163
314
|
newAddressParams: NewAddressParamsPacked[];
|
|
315
|
+
/**
|
|
316
|
+
* If some, it's either a compress or decompress instruction.
|
|
317
|
+
*/
|
|
164
318
|
compressOrDecompressLamports: BN | null;
|
|
319
|
+
/**
|
|
320
|
+
* If `compressOrDecompressLamports` is some, whether it's a compress or
|
|
321
|
+
* decompress instruction.
|
|
322
|
+
*/
|
|
165
323
|
isCompress: boolean;
|
|
324
|
+
/**
|
|
325
|
+
* Optional compressed CPI context.
|
|
326
|
+
*/
|
|
166
327
|
compressedCpiContext: CompressedCpiContext | null;
|
|
167
328
|
}
|
|
329
|
+
/**
|
|
330
|
+
* Compressed CPI context.
|
|
331
|
+
*
|
|
332
|
+
* Use if you want to use a single {@link ValidityProof} to update two
|
|
333
|
+
* compressed accounts owned by separate programs.
|
|
334
|
+
*/
|
|
168
335
|
export interface CompressedCpiContext {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
336
|
+
/**
|
|
337
|
+
* Is set by the program that is invoking the CPI to signal that it should
|
|
338
|
+
* set the cpi context.
|
|
339
|
+
*/
|
|
340
|
+
setContext: boolean;
|
|
341
|
+
/**
|
|
342
|
+
* Is set to wipe the cpi context since someone could have set it before
|
|
343
|
+
* with unrelated data.
|
|
344
|
+
*/
|
|
345
|
+
firstSetContext: boolean;
|
|
346
|
+
/**
|
|
347
|
+
* Index of cpi context account in remaining accounts.
|
|
348
|
+
*/
|
|
349
|
+
cpiContextAccountIndex: number;
|
|
172
350
|
}
|
|
173
351
|
/**
|
|
174
352
|
* @deprecated Use {@link ValidityProof} instead.
|
|
175
353
|
*/
|
|
176
354
|
export interface CompressedProof {
|
|
355
|
+
/**
|
|
356
|
+
* 32 bytes.
|
|
357
|
+
*/
|
|
177
358
|
a: number[];
|
|
359
|
+
/**
|
|
360
|
+
* 64 bytes.
|
|
361
|
+
*/
|
|
178
362
|
b: number[];
|
|
363
|
+
/**
|
|
364
|
+
* 32 bytes.
|
|
365
|
+
*/
|
|
179
366
|
c: number[];
|
|
180
367
|
}
|
|
181
368
|
/**
|
|
@@ -184,27 +371,79 @@ export interface CompressedProof {
|
|
|
184
371
|
* You can request proofs via `rpc.getValidityProof` or
|
|
185
372
|
* `rpc.getValidityProofV0`.
|
|
186
373
|
*
|
|
187
|
-
* One proof
|
|
188
|
-
*
|
|
374
|
+
* One proof can prove the existence of N compressed accounts or the uniqueness
|
|
375
|
+
* of N PDAs.
|
|
189
376
|
*/
|
|
190
377
|
export interface ValidityProof {
|
|
378
|
+
/**
|
|
379
|
+
* 32 bytes.
|
|
380
|
+
*/
|
|
191
381
|
a: number[];
|
|
382
|
+
/**
|
|
383
|
+
* 64 bytes.
|
|
384
|
+
*/
|
|
192
385
|
b: number[];
|
|
386
|
+
/**
|
|
387
|
+
* 32 bytes.
|
|
388
|
+
*/
|
|
193
389
|
c: number[];
|
|
194
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Packed token data for input compressed accounts.
|
|
393
|
+
*/
|
|
195
394
|
export interface InputTokenDataWithContext {
|
|
395
|
+
/**
|
|
396
|
+
* Amount of tokens.
|
|
397
|
+
*/
|
|
196
398
|
amount: BN;
|
|
399
|
+
/**
|
|
400
|
+
* Delegate index.
|
|
401
|
+
*/
|
|
197
402
|
delegateIndex: number | null;
|
|
198
|
-
|
|
403
|
+
/**
|
|
404
|
+
* Merkle context.
|
|
405
|
+
*/
|
|
406
|
+
merkleContext: PackedMerkleContextLegacy;
|
|
407
|
+
/**
|
|
408
|
+
* Root index.
|
|
409
|
+
*/
|
|
199
410
|
rootIndex: number;
|
|
411
|
+
/**
|
|
412
|
+
* Lamports.
|
|
413
|
+
*/
|
|
200
414
|
lamports: BN | null;
|
|
415
|
+
/**
|
|
416
|
+
* Tlv.
|
|
417
|
+
*/
|
|
201
418
|
tlv: Buffer | null;
|
|
202
419
|
}
|
|
420
|
+
/**
|
|
421
|
+
* Token data.
|
|
422
|
+
*/
|
|
203
423
|
export type TokenData = {
|
|
424
|
+
/**
|
|
425
|
+
* The mint associated with this account.
|
|
426
|
+
*/
|
|
204
427
|
mint: PublicKey;
|
|
428
|
+
/**
|
|
429
|
+
* The owner of this account.
|
|
430
|
+
*/
|
|
205
431
|
owner: PublicKey;
|
|
432
|
+
/**
|
|
433
|
+
* The amount of tokens this account holds.
|
|
434
|
+
*/
|
|
206
435
|
amount: BN;
|
|
436
|
+
/**
|
|
437
|
+
* If `delegate` is `Some` then `delegated_amount` represents the amount
|
|
438
|
+
* authorized by the delegate.
|
|
439
|
+
*/
|
|
207
440
|
delegate: PublicKey | null;
|
|
441
|
+
/**
|
|
442
|
+
* The account's state.
|
|
443
|
+
*/
|
|
208
444
|
state: number;
|
|
445
|
+
/**
|
|
446
|
+
* Token extension tlv.
|
|
447
|
+
*/
|
|
209
448
|
tlv: Buffer | null;
|
|
210
449
|
};
|