@lightprotocol/stateless.js 0.21.0 → 0.22.1-alpha.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/README.md +10 -10
- 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/compressible/action.d.ts +77 -0
- package/dist/cjs/browser/compressible/index.d.ts +13 -0
- package/dist/cjs/browser/compressible/instruction.d.ts +177 -0
- package/dist/cjs/browser/compressible/layout.d.ts +47 -0
- package/dist/cjs/browser/compressible/types.d.ts +112 -0
- package/dist/cjs/browser/compressible/utils.d.ts +16 -0
- package/dist/cjs/browser/constants.d.ts +31 -6
- 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 -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/browser/programs/system/pack.d.ts +143 -0
- 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 +1593 -51
- package/dist/cjs/browser/rpc.d.ts +31 -37
- 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 +20 -40
- package/dist/cjs/browser/utils/address.d.ts +13 -0
- package/dist/cjs/browser/utils/calculate-compute-unit-price.d.ts +1 -1
- package/dist/cjs/browser/utils/conversion.d.ts +3 -0
- package/dist/cjs/browser/utils/get-state-tree-infos.d.ts +16 -9
- package/dist/cjs/browser/utils/index.d.ts +2 -2
- package/dist/cjs/browser/utils/packed-accounts.d.ts +161 -0
- 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/compressible/action.d.ts +77 -0
- package/dist/cjs/node/compressible/index.d.ts +13 -0
- package/dist/cjs/node/compressible/instruction.d.ts +177 -0
- package/dist/cjs/node/compressible/layout.d.ts +47 -0
- package/dist/cjs/node/compressible/types.d.ts +112 -0
- package/dist/cjs/node/compressible/utils.d.ts +16 -0
- package/dist/cjs/node/constants.d.ts +31 -6
- 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 -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/node/programs/system/pack.d.ts +143 -0
- 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 +1593 -51
- package/dist/cjs/node/rpc.d.ts +31 -37
- 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 +20 -40
- package/dist/cjs/node/utils/address.d.ts +13 -0
- package/dist/cjs/node/utils/calculate-compute-unit-price.d.ts +1 -1
- package/dist/cjs/node/utils/conversion.d.ts +3 -0
- package/dist/cjs/node/utils/get-state-tree-infos.d.ts +16 -9
- package/dist/cjs/node/utils/index.d.ts +2 -2
- package/dist/cjs/node/utils/packed-accounts.d.ts +161 -0
- 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 +3391 -864
- package/package.json +13 -6
- package/dist/cjs/browser/instruction/index.d.ts +0 -1
- package/dist/cjs/browser/instruction/pack-compressed-accounts.d.ts +0 -49
- package/dist/cjs/node/instruction/index.d.ts +0 -1
- package/dist/cjs/node/instruction/pack-compressed-accounts.d.ts +0 -49
|
@@ -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
|
};
|
|
@@ -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
|
*
|
|
@@ -1,20 +1,11 @@
|
|
|
1
|
-
import { Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
|
|
1
|
+
import { AccountInfo, Connection, ConnectionConfig, PublicKey } from '@solana/web3.js';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
3
|
import { AddressWithTree, CompressedMintTokenHolders, CompressedTransaction, GetCompressedAccountsByOwnerConfig, PaginatedOptions, HashWithTree, LatestNonVotingSignatures, LatestNonVotingSignaturesPaginated, SignatureWithMetadata, WithContext, WithCursor } from '../../rpc-interface';
|
|
4
4
|
import { ValidityProofWithContext, CompressionApiInterface, GetCompressedTokenAccountsByOwnerOrDelegateOptions, ParsedTokenAccount, TokenBalance } from '../../rpc-interface';
|
|
5
|
-
import { BN254, CompressedAccountWithMerkleContext, MerkleContextWithMerkleProof } from '../../state';
|
|
5
|
+
import { BN254, CompressedAccountWithMerkleContext, MerkleContext, 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.
|
|
@@ -256,4 +232,8 @@ export declare class TestRpc extends Connection implements CompressionApiInterfa
|
|
|
256
232
|
*/
|
|
257
233
|
getValidityProof(hashes?: BN254[], newAddresses?: BN254[]): Promise<ValidityProofWithContext>;
|
|
258
234
|
getValidityProofV0(hashes?: HashWithTree[], newAddresses?: AddressWithTree[]): Promise<ValidityProofWithContext>;
|
|
235
|
+
getCompressibleAccountInfo(address: PublicKey, programId: PublicKey, addressTreeInfo: TreeInfo, rpc: TestRpc): Promise<{
|
|
236
|
+
accountInfo: AccountInfo<Buffer>;
|
|
237
|
+
merkleContext?: MerkleContext;
|
|
238
|
+
} | null>;
|
|
259
239
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Derive an address for a compressed account from a seed and an address Merkle
|
|
4
|
+
* tree public key.
|
|
5
|
+
*
|
|
6
|
+
* @param seed 32 bytes seed to derive the address from
|
|
7
|
+
* @param addressMerkleTreePubkey Address Merkle tree public key as bytes.
|
|
8
|
+
* @param programIdBytes Program ID bytes.
|
|
9
|
+
* @returns Derived address as bytes
|
|
10
|
+
*/
|
|
11
|
+
export declare function deriveAddressV2(seed: Uint8Array, addressMerkleTreePubkey: Uint8Array, programIdBytes: Uint8Array): Uint8Array;
|
|
12
|
+
export declare function hashVWithBumpSeed(bytes: Uint8Array[]): Uint8Array;
|
|
2
13
|
export declare function deriveAddressSeed(seeds: Uint8Array[], programId: PublicKey): Uint8Array;
|
|
3
14
|
/**
|
|
15
|
+
* @deprecated Use {@link deriveAddressV2} instead, unless you're using v1.
|
|
16
|
+
*
|
|
4
17
|
* Derive an address for a compressed account from a seed and an address Merkle
|
|
5
18
|
* tree public key.
|
|
6
19
|
*
|
|
@@ -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
|
|
@@ -21,6 +22,7 @@ export declare const toCamelCase: (object: any) => any;
|
|
|
21
22
|
*/
|
|
22
23
|
export declare function hashToBn254FieldSizeBe(bytes: Buffer): [Buffer, number] | null;
|
|
23
24
|
/**
|
|
25
|
+
* TODO: make consistent with latest rust. (use u8::max bumpseed)
|
|
24
26
|
* Hash the provided `bytes` with Keccak256 and ensure that the result fits in
|
|
25
27
|
* the BN254 prime field by truncating the resulting hash to 31 bytes.
|
|
26
28
|
*
|
|
@@ -31,3 +33,4 @@ export declare function hashToBn254FieldSizeBe(bytes: Buffer): [Buffer, number]
|
|
|
31
33
|
export declare function hashvToBn254FieldSizeBe(bytes: Uint8Array[]): Uint8Array;
|
|
32
34
|
/** Mutates array in place */
|
|
33
35
|
export declare function pushUniqueItems<T>(items: T[], map: T[]): void;
|
|
36
|
+
export declare function convertInvokeCpiWithReadOnlyToInvoke(data: any): InstructionDataInvoke;
|