@lightprotocol/compressed-token 0.22.1-alpha.2 → 0.22.1-alpha.3
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 +5 -1
- package/dist/cjs/browser/index.cjs +1 -1
- package/dist/cjs/browser/index.cjs.map +1 -1
- package/dist/cjs/browser/types-DZs1jl_2.cjs +2 -0
- package/dist/cjs/browser/types-DZs1jl_2.cjs.map +1 -0
- package/dist/cjs/browser/unified/index.cjs +2 -0
- package/dist/cjs/browser/unified/index.cjs.map +1 -0
- package/dist/cjs/node/index.cjs +1 -1
- package/dist/cjs/node/index.cjs.map +1 -1
- package/dist/cjs/node/types-CxnYquyR.cjs +2 -0
- package/dist/cjs/node/types-CxnYquyR.cjs.map +1 -0
- package/dist/cjs/node/unified/index.cjs +2 -0
- package/dist/cjs/node/unified/index.cjs.map +1 -0
- package/dist/es/browser/index.js +1 -1
- package/dist/es/browser/index.js.map +1 -1
- package/dist/es/browser/types-Drp6Yu8A.js +2 -0
- package/dist/es/browser/types-Drp6Yu8A.js.map +1 -0
- package/dist/es/browser/unified/index.js +2 -0
- package/dist/es/browser/unified/index.js.map +1 -0
- package/dist/types/index.d.ts +2233 -128
- package/dist/types/unified/index.d.ts +5392 -0
- package/package.json +40 -8
package/dist/types/index.d.ts
CHANGED
|
@@ -1,59 +1,1440 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { PublicKey, TransactionInstruction, Commitment, AccountInfo, Signer, ConfirmOptions, TransactionSignature, AccountMeta, Keypair, Connection } from '@solana/web3.js';
|
|
3
|
+
import { ValidityProofWithContext, AddressTreeInfo, TreeInfo, MerkleContext, Rpc, ParsedTokenAccount, CompressedAccountWithMerkleContext, ValidityProof, PackedMerkleContextLegacy, CompressedCpiContext, InputTokenDataWithContext as InputTokenDataWithContext$1, CompressedProof } from '@lightprotocol/stateless.js';
|
|
4
|
+
export { ParsedTokenAccount as ParsedTokenAccountInterface } from '@lightprotocol/stateless.js';
|
|
5
|
+
import { Mint, Account } from '@solana/spl-token';
|
|
6
|
+
export { Account, AccountState } from '@solana/spl-token';
|
|
6
7
|
|
|
8
|
+
declare class Buffer$1 extends Uint8Array {
|
|
9
|
+
length: number
|
|
10
|
+
write(string: string, offset?: number, length?: number, encoding?: string): number;
|
|
11
|
+
toString(encoding?: string, start?: number, end?: number): string;
|
|
12
|
+
toJSON(): { type: 'Buffer', data: any[] };
|
|
13
|
+
equals(otherBuffer: Buffer$1): boolean;
|
|
14
|
+
compare(otherBuffer: Uint8Array, targetStart?: number, targetEnd?: number, sourceStart?: number, sourceEnd?: number): number;
|
|
15
|
+
copy(targetBuffer: Buffer$1, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
|
16
|
+
slice(start?: number, end?: number): Buffer$1;
|
|
17
|
+
writeUIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
|
18
|
+
writeUIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
|
19
|
+
writeIntLE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
|
20
|
+
writeIntBE(value: number, offset: number, byteLength: number, noAssert?: boolean): number;
|
|
21
|
+
readUIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
|
22
|
+
readUIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
|
23
|
+
readIntLE(offset: number, byteLength: number, noAssert?: boolean): number;
|
|
24
|
+
readIntBE(offset: number, byteLength: number, noAssert?: boolean): number;
|
|
25
|
+
readUInt8(offset: number, noAssert?: boolean): number;
|
|
26
|
+
readUInt16LE(offset: number, noAssert?: boolean): number;
|
|
27
|
+
readUInt16BE(offset: number, noAssert?: boolean): number;
|
|
28
|
+
readUInt32LE(offset: number, noAssert?: boolean): number;
|
|
29
|
+
readUInt32BE(offset: number, noAssert?: boolean): number;
|
|
30
|
+
readBigUInt64LE(offset: number): BigInt;
|
|
31
|
+
readBigUInt64BE(offset: number): BigInt;
|
|
32
|
+
readInt8(offset: number, noAssert?: boolean): number;
|
|
33
|
+
readInt16LE(offset: number, noAssert?: boolean): number;
|
|
34
|
+
readInt16BE(offset: number, noAssert?: boolean): number;
|
|
35
|
+
readInt32LE(offset: number, noAssert?: boolean): number;
|
|
36
|
+
readInt32BE(offset: number, noAssert?: boolean): number;
|
|
37
|
+
readBigInt64LE(offset: number): BigInt;
|
|
38
|
+
readBigInt64BE(offset: number): BigInt;
|
|
39
|
+
readFloatLE(offset: number, noAssert?: boolean): number;
|
|
40
|
+
readFloatBE(offset: number, noAssert?: boolean): number;
|
|
41
|
+
readDoubleLE(offset: number, noAssert?: boolean): number;
|
|
42
|
+
readDoubleBE(offset: number, noAssert?: boolean): number;
|
|
43
|
+
reverse(): this;
|
|
44
|
+
swap16(): Buffer$1;
|
|
45
|
+
swap32(): Buffer$1;
|
|
46
|
+
swap64(): Buffer$1;
|
|
47
|
+
writeUInt8(value: number, offset: number, noAssert?: boolean): number;
|
|
48
|
+
writeUInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
|
49
|
+
writeUInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
|
50
|
+
writeUInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
|
51
|
+
writeUInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
|
52
|
+
writeBigUInt64LE(value: number, offset: number): BigInt;
|
|
53
|
+
writeBigUInt64BE(value: number, offset: number): BigInt;
|
|
54
|
+
writeInt8(value: number, offset: number, noAssert?: boolean): number;
|
|
55
|
+
writeInt16LE(value: number, offset: number, noAssert?: boolean): number;
|
|
56
|
+
writeInt16BE(value: number, offset: number, noAssert?: boolean): number;
|
|
57
|
+
writeInt32LE(value: number, offset: number, noAssert?: boolean): number;
|
|
58
|
+
writeInt32BE(value: number, offset: number, noAssert?: boolean): number;
|
|
59
|
+
writeBigInt64LE(value: number, offset: number): BigInt;
|
|
60
|
+
writeBigInt64BE(value: number, offset: number): BigInt;
|
|
61
|
+
writeFloatLE(value: number, offset: number, noAssert?: boolean): number;
|
|
62
|
+
writeFloatBE(value: number, offset: number, noAssert?: boolean): number;
|
|
63
|
+
writeDoubleLE(value: number, offset: number, noAssert?: boolean): number;
|
|
64
|
+
writeDoubleBE(value: number, offset: number, noAssert?: boolean): number;
|
|
65
|
+
fill(value: any, offset?: number, end?: number): this;
|
|
66
|
+
indexOf(value: string | number | Buffer$1, byteOffset?: number, encoding?: string): number;
|
|
67
|
+
lastIndexOf(value: string | number | Buffer$1, byteOffset?: number, encoding?: string): number;
|
|
68
|
+
includes(value: string | number | Buffer$1, byteOffset?: number, encoding?: string): boolean;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Allocates a new buffer containing the given {str}.
|
|
72
|
+
*
|
|
73
|
+
* @param str String to store in buffer.
|
|
74
|
+
* @param encoding encoding to use, optional. Default is 'utf8'
|
|
75
|
+
*/
|
|
76
|
+
constructor (str: string, encoding?: string);
|
|
77
|
+
/**
|
|
78
|
+
* Allocates a new buffer of {size} octets.
|
|
79
|
+
*
|
|
80
|
+
* @param size count of octets to allocate.
|
|
81
|
+
*/
|
|
82
|
+
constructor (size: number);
|
|
83
|
+
/**
|
|
84
|
+
* Allocates a new buffer containing the given {array} of octets.
|
|
85
|
+
*
|
|
86
|
+
* @param array The octets to store.
|
|
87
|
+
*/
|
|
88
|
+
constructor (array: Uint8Array);
|
|
89
|
+
/**
|
|
90
|
+
* Produces a Buffer backed by the same allocated memory as
|
|
91
|
+
* the given {ArrayBuffer}.
|
|
92
|
+
*
|
|
93
|
+
*
|
|
94
|
+
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
|
95
|
+
*/
|
|
96
|
+
constructor (arrayBuffer: ArrayBuffer);
|
|
97
|
+
/**
|
|
98
|
+
* Allocates a new buffer containing the given {array} of octets.
|
|
99
|
+
*
|
|
100
|
+
* @param array The octets to store.
|
|
101
|
+
*/
|
|
102
|
+
constructor (array: any[]);
|
|
103
|
+
/**
|
|
104
|
+
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
|
105
|
+
*
|
|
106
|
+
* @param buffer The buffer to copy.
|
|
107
|
+
*/
|
|
108
|
+
constructor (buffer: Buffer$1);
|
|
109
|
+
prototype: Buffer$1;
|
|
110
|
+
/**
|
|
111
|
+
* Allocates a new Buffer using an {array} of octets.
|
|
112
|
+
*
|
|
113
|
+
* @param array
|
|
114
|
+
*/
|
|
115
|
+
static from(array: any[]): Buffer$1;
|
|
116
|
+
/**
|
|
117
|
+
* When passed a reference to the .buffer property of a TypedArray instance,
|
|
118
|
+
* the newly created Buffer will share the same allocated memory as the TypedArray.
|
|
119
|
+
* The optional {byteOffset} and {length} arguments specify a memory range
|
|
120
|
+
* within the {arrayBuffer} that will be shared by the Buffer.
|
|
121
|
+
*
|
|
122
|
+
* @param arrayBuffer The .buffer property of a TypedArray or a new ArrayBuffer()
|
|
123
|
+
* @param byteOffset
|
|
124
|
+
* @param length
|
|
125
|
+
*/
|
|
126
|
+
static from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer$1;
|
|
127
|
+
/**
|
|
128
|
+
* Copies the passed {buffer} data onto a new Buffer instance.
|
|
129
|
+
*
|
|
130
|
+
* @param buffer
|
|
131
|
+
*/
|
|
132
|
+
static from(buffer: Buffer$1 | Uint8Array): Buffer$1;
|
|
133
|
+
/**
|
|
134
|
+
* Creates a new Buffer containing the given JavaScript string {str}.
|
|
135
|
+
* If provided, the {encoding} parameter identifies the character encoding.
|
|
136
|
+
* If not provided, {encoding} defaults to 'utf8'.
|
|
137
|
+
*
|
|
138
|
+
* @param str
|
|
139
|
+
*/
|
|
140
|
+
static from(str: string, encoding?: string): Buffer$1;
|
|
141
|
+
/**
|
|
142
|
+
* Returns true if {obj} is a Buffer
|
|
143
|
+
*
|
|
144
|
+
* @param obj object to test.
|
|
145
|
+
*/
|
|
146
|
+
static isBuffer(obj: any): obj is Buffer$1;
|
|
147
|
+
/**
|
|
148
|
+
* Returns true if {encoding} is a valid encoding argument.
|
|
149
|
+
* Valid string encodings in Node 0.12: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'binary'(deprecated)|'hex'
|
|
150
|
+
*
|
|
151
|
+
* @param encoding string to test.
|
|
152
|
+
*/
|
|
153
|
+
static isEncoding(encoding: string): boolean;
|
|
154
|
+
/**
|
|
155
|
+
* Gives the actual byte length of a string. encoding defaults to 'utf8'.
|
|
156
|
+
* This is not the same as String.prototype.length since that returns the number of characters in a string.
|
|
157
|
+
*
|
|
158
|
+
* @param string string to test.
|
|
159
|
+
* @param encoding encoding used to evaluate (defaults to 'utf8')
|
|
160
|
+
*/
|
|
161
|
+
static byteLength(string: string, encoding?: string): number;
|
|
162
|
+
/**
|
|
163
|
+
* Returns a buffer which is the result of concatenating all the buffers in the list together.
|
|
164
|
+
*
|
|
165
|
+
* If the list has no items, or if the totalLength is 0, then it returns a zero-length buffer.
|
|
166
|
+
* If the list has exactly one item, then the first item of the list is returned.
|
|
167
|
+
* If the list has more than one item, then a new Buffer is created.
|
|
168
|
+
*
|
|
169
|
+
* @param list An array of Buffer objects to concatenate
|
|
170
|
+
* @param totalLength Total length of the buffers when concatenated.
|
|
171
|
+
* If totalLength is not provided, it is read from the buffers in the list. However, this adds an additional loop to the function, so it is faster to provide the length explicitly.
|
|
172
|
+
*/
|
|
173
|
+
static concat(list: Uint8Array[], totalLength?: number): Buffer$1;
|
|
174
|
+
/**
|
|
175
|
+
* The same as buf1.compare(buf2).
|
|
176
|
+
*/
|
|
177
|
+
static compare(buf1: Uint8Array, buf2: Uint8Array): number;
|
|
178
|
+
/**
|
|
179
|
+
* Allocates a new buffer of {size} octets.
|
|
180
|
+
*
|
|
181
|
+
* @param size count of octets to allocate.
|
|
182
|
+
* @param fill if specified, buffer will be initialized by calling buf.fill(fill).
|
|
183
|
+
* If parameter is omitted, buffer will be filled with zeros.
|
|
184
|
+
* @param encoding encoding used for call to buf.fill while initializing
|
|
185
|
+
*/
|
|
186
|
+
static alloc(size: number, fill?: string | Buffer$1 | number, encoding?: string): Buffer$1;
|
|
187
|
+
/**
|
|
188
|
+
* Allocates a new buffer of {size} octets, leaving memory not initialized, so the contents
|
|
189
|
+
* of the newly created Buffer are unknown and may contain sensitive data.
|
|
190
|
+
*
|
|
191
|
+
* @param size count of octets to allocate
|
|
192
|
+
*/
|
|
193
|
+
static allocUnsafe(size: number): Buffer$1;
|
|
194
|
+
/**
|
|
195
|
+
* Allocates a new non-pooled buffer of {size} octets, leaving memory not initialized, so the contents
|
|
196
|
+
* of the newly created Buffer are unknown and may contain sensitive data.
|
|
197
|
+
*
|
|
198
|
+
* @param size count of octets to allocate
|
|
199
|
+
*/
|
|
200
|
+
static allocUnsafeSlow(size: number): Buffer$1;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
interface LayoutObject {
|
|
204
|
+
[key: string]: any;
|
|
205
|
+
}
|
|
7
206
|
/**
|
|
8
|
-
*
|
|
207
|
+
* Base class for layout objects.
|
|
9
208
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
-
* @param amount Number of tokens to delegate
|
|
14
|
-
* @param owner Owner of the SPL token account.
|
|
15
|
-
* @param delegate Address of the delegate
|
|
16
|
-
* @param confirmOptions Options for confirming the transaction
|
|
209
|
+
* **NOTE** This is an abstract base class; you can create instances
|
|
210
|
+
* if it amuses you, but they won't support the {@link
|
|
211
|
+
* Layout#encode|encode} or {@link Layout#decode|decode} functions.
|
|
17
212
|
*
|
|
18
|
-
* @
|
|
213
|
+
* @param {Number} span - Initializer for {@link Layout#span|span}. The
|
|
214
|
+
* parameter must be an integer; a negative value signifies that the
|
|
215
|
+
* span is {@link Layout#getSpan|value-specific}.
|
|
216
|
+
*
|
|
217
|
+
* @param {string} [property] - Initializer for {@link
|
|
218
|
+
* Layout#property|property}.
|
|
219
|
+
*
|
|
220
|
+
* @abstract
|
|
19
221
|
*/
|
|
20
|
-
declare
|
|
222
|
+
declare abstract class Layout<T> {
|
|
223
|
+
span: number;
|
|
224
|
+
property?: string;
|
|
225
|
+
boundConstructor_?: any;
|
|
226
|
+
constructor(span: number, property?: string);
|
|
227
|
+
/** Function to create an Object into which decoded properties will
|
|
228
|
+
* be written.
|
|
229
|
+
*
|
|
230
|
+
* Used only for layouts that {@link Layout#decode|decode} to Object
|
|
231
|
+
* instances, which means:
|
|
232
|
+
* * {@link Structure}
|
|
233
|
+
* * {@link Union}
|
|
234
|
+
* * {@link VariantLayout}
|
|
235
|
+
* * {@link BitStructure}
|
|
236
|
+
*
|
|
237
|
+
* If left undefined the JavaScript representation of these layouts
|
|
238
|
+
* will be Object instances.
|
|
239
|
+
*
|
|
240
|
+
* See {@link bindConstructorLayout}.
|
|
241
|
+
*/
|
|
242
|
+
makeDestinationObject(): LayoutObject;
|
|
243
|
+
/**
|
|
244
|
+
* Decode from a Uint8Array into a JavaScript value.
|
|
245
|
+
*
|
|
246
|
+
* @param {Uint8Array} b - the buffer from which encoded data is read.
|
|
247
|
+
*
|
|
248
|
+
* @param {Number} [offset] - the offset at which the encoded data
|
|
249
|
+
* starts. If absent a zero offset is inferred.
|
|
250
|
+
*
|
|
251
|
+
* @returns {(Number|Array|Object)} - the value of the decoded data.
|
|
252
|
+
*
|
|
253
|
+
* @abstract
|
|
254
|
+
*/
|
|
255
|
+
abstract decode(b: Uint8Array, offset?: number): T;
|
|
256
|
+
/**
|
|
257
|
+
* Encode a JavaScript value into a Uint8Array.
|
|
258
|
+
*
|
|
259
|
+
* @param {(Number|Array|Object)} src - the value to be encoded into
|
|
260
|
+
* the buffer. The type accepted depends on the (sub-)type of {@link
|
|
261
|
+
* Layout}.
|
|
262
|
+
*
|
|
263
|
+
* @param {Uint8Array} b - the buffer into which encoded data will be
|
|
264
|
+
* written.
|
|
265
|
+
*
|
|
266
|
+
* @param {Number} [offset] - the offset at which the encoded data
|
|
267
|
+
* starts. If absent a zero offset is inferred.
|
|
268
|
+
*
|
|
269
|
+
* @returns {Number} - the number of bytes encoded, including the
|
|
270
|
+
* space skipped for internal padding, but excluding data such as
|
|
271
|
+
* {@link Sequence#count|lengths} when stored {@link
|
|
272
|
+
* ExternalLayout|externally}. This is the adjustment to `offset`
|
|
273
|
+
* producing the offset where data for the next layout would be
|
|
274
|
+
* written.
|
|
275
|
+
*
|
|
276
|
+
* @abstract
|
|
277
|
+
*/
|
|
278
|
+
abstract encode(src: T, b: Uint8Array, offset?: number): number;
|
|
279
|
+
/**
|
|
280
|
+
* Calculate the span of a specific instance of a layout.
|
|
281
|
+
*
|
|
282
|
+
* @param {Uint8Array} b - the buffer that contains an encoded instance.
|
|
283
|
+
*
|
|
284
|
+
* @param {Number} [offset] - the offset at which the encoded instance
|
|
285
|
+
* starts. If absent a zero offset is inferred.
|
|
286
|
+
*
|
|
287
|
+
* @return {Number} - the number of bytes covered by the layout
|
|
288
|
+
* instance. If this method is not overridden in a subclass the
|
|
289
|
+
* definition-time constant {@link Layout#span|span} will be
|
|
290
|
+
* returned.
|
|
291
|
+
*
|
|
292
|
+
* @throws {RangeError} - if the length of the value cannot be
|
|
293
|
+
* determined.
|
|
294
|
+
*/
|
|
295
|
+
getSpan(b?: Uint8Array, offset?: number): number;
|
|
296
|
+
/**
|
|
297
|
+
* Replicate the layout using a new property.
|
|
298
|
+
*
|
|
299
|
+
* This function must be used to get a structurally-equivalent layout
|
|
300
|
+
* with a different name since all {@link Layout} instances are
|
|
301
|
+
* immutable.
|
|
302
|
+
*
|
|
303
|
+
* **NOTE** This is a shallow copy. All fields except {@link
|
|
304
|
+
* Layout#property|property} are strictly equal to the origin layout.
|
|
305
|
+
*
|
|
306
|
+
* @param {String} property - the value for {@link
|
|
307
|
+
* Layout#property|property} in the replica.
|
|
308
|
+
*
|
|
309
|
+
* @returns {Layout} - the copy with {@link Layout#property|property}
|
|
310
|
+
* set to `property`.
|
|
311
|
+
*/
|
|
312
|
+
replicate(property: string): this;
|
|
313
|
+
/**
|
|
314
|
+
* Create an object from layout properties and an array of values.
|
|
315
|
+
*
|
|
316
|
+
* **NOTE** This function returns `undefined` if invoked on a layout
|
|
317
|
+
* that does not return its value as an Object. Objects are
|
|
318
|
+
* returned for things that are a {@link Structure}, which includes
|
|
319
|
+
* {@link VariantLayout|variant layouts} if they are structures, and
|
|
320
|
+
* excludes {@link Union}s. If you want this feature for a union
|
|
321
|
+
* you must use {@link Union.getVariant|getVariant} to select the
|
|
322
|
+
* desired layout.
|
|
323
|
+
*
|
|
324
|
+
* @param {Array} values - an array of values that correspond to the
|
|
325
|
+
* default order for properties. As with {@link Layout#decode|decode}
|
|
326
|
+
* layout elements that have no property name are skipped when
|
|
327
|
+
* iterating over the array values. Only the top-level properties are
|
|
328
|
+
* assigned; arguments are not assigned to properties of contained
|
|
329
|
+
* layouts. Any unused values are ignored.
|
|
330
|
+
*
|
|
331
|
+
* @return {(Object|undefined)}
|
|
332
|
+
*/
|
|
333
|
+
fromArray(values: any[]): LayoutObject | undefined;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
interface AdditionalMetadata {
|
|
337
|
+
key: Buffer$1;
|
|
338
|
+
value: Buffer$1;
|
|
339
|
+
}
|
|
21
340
|
|
|
22
341
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @param mint The mint of the token pool
|
|
25
|
-
* @param tokenPoolInfo The token pool info
|
|
26
|
-
* @returns True if the token pool info is initialized and has a balance
|
|
342
|
+
* Token metadata for creating a c-token mint.
|
|
27
343
|
*/
|
|
28
|
-
|
|
344
|
+
interface TokenMetadataInstructionData {
|
|
345
|
+
name: string;
|
|
346
|
+
symbol: string;
|
|
347
|
+
uri: string;
|
|
348
|
+
updateAuthority?: PublicKey | null;
|
|
349
|
+
additionalMetadata: AdditionalMetadata[] | null;
|
|
350
|
+
}
|
|
351
|
+
declare function createTokenMetadata(name: string, symbol: string, uri: string, updateAuthority?: PublicKey | null, additionalMetadata?: AdditionalMetadata[] | null): TokenMetadataInstructionData;
|
|
29
352
|
/**
|
|
30
|
-
*
|
|
31
|
-
* @param rpc The RPC client
|
|
32
|
-
* @param mint The mint of the token pool
|
|
33
|
-
* @param commitment The commitment to use
|
|
353
|
+
* Create instruction for initializing a c-token mint.
|
|
34
354
|
*
|
|
35
|
-
* @
|
|
355
|
+
* @param mintSigner Mint signer keypair public key.
|
|
356
|
+
* @param decimals Number of decimals for the mint.
|
|
357
|
+
* @param mintAuthority Mint authority public key.
|
|
358
|
+
* @param freezeAuthority Optional freeze authority public key.
|
|
359
|
+
* @param payer Fee payer public key.
|
|
360
|
+
* @param validityProof Validity proof for the mint account.
|
|
361
|
+
* @param addressTreeInfo Address tree info for the mint.
|
|
362
|
+
* @param outputStateTreeInfo Output state tree info.
|
|
363
|
+
* @param metadata Optional token metadata.
|
|
36
364
|
*/
|
|
37
|
-
declare function
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
365
|
+
declare function createMintInstruction(mintSigner: PublicKey, decimals: number, mintAuthority: PublicKey, freezeAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext, addressTreeInfo: AddressTreeInfo, outputStateTreeInfo: TreeInfo, metadata?: TokenMetadataInstructionData): TransactionInstruction;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* SPL-compatible base mint structure
|
|
369
|
+
*/
|
|
370
|
+
interface BaseMint {
|
|
371
|
+
/** Optional authority used to mint new tokens */
|
|
372
|
+
mintAuthority: PublicKey | null;
|
|
373
|
+
/** Total supply of tokens */
|
|
374
|
+
supply: bigint;
|
|
375
|
+
/** Number of base 10 digits to the right of the decimal place */
|
|
376
|
+
decimals: number;
|
|
377
|
+
/** Is initialized - for SPL compatibility */
|
|
378
|
+
isInitialized: boolean;
|
|
379
|
+
/** Optional authority to freeze token accounts */
|
|
380
|
+
freezeAuthority: PublicKey | null;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Compressed mint context (protocol version, SPL mint reference)
|
|
384
|
+
*/
|
|
385
|
+
interface MintContext {
|
|
386
|
+
/** Protocol version for upgradability */
|
|
387
|
+
version: number;
|
|
388
|
+
/** Whether the associated SPL mint is initialized */
|
|
389
|
+
splMintInitialized: boolean;
|
|
390
|
+
/** PDA of the associated SPL mint */
|
|
391
|
+
splMint: PublicKey;
|
|
392
|
+
}
|
|
393
|
+
/**
|
|
394
|
+
* Raw extension data as stored on-chain
|
|
395
|
+
*/
|
|
396
|
+
interface MintExtension {
|
|
397
|
+
extensionType: number;
|
|
398
|
+
data: Uint8Array;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Parsed token metadata matching on-chain TokenMetadata extension.
|
|
402
|
+
* Fields: updateAuthority, mint, name, symbol, uri, additionalMetadata
|
|
403
|
+
*/
|
|
404
|
+
interface TokenMetadata {
|
|
405
|
+
/** Authority that can update metadata (None if zero pubkey) */
|
|
406
|
+
updateAuthority?: PublicKey | null;
|
|
407
|
+
/** Associated mint pubkey */
|
|
408
|
+
mint: PublicKey;
|
|
409
|
+
/** Token name */
|
|
410
|
+
name: string;
|
|
411
|
+
/** Token symbol */
|
|
412
|
+
symbol: string;
|
|
413
|
+
/** URI pointing to off-chain metadata JSON */
|
|
414
|
+
uri: string;
|
|
415
|
+
/** Additional key-value metadata pairs */
|
|
416
|
+
additionalMetadata?: {
|
|
417
|
+
key: string;
|
|
418
|
+
value: string;
|
|
419
|
+
}[];
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Complete compressed mint structure (raw format)
|
|
423
|
+
*/
|
|
424
|
+
interface CompressedMint {
|
|
425
|
+
base: BaseMint;
|
|
426
|
+
mintContext: MintContext;
|
|
427
|
+
extensions: MintExtension[] | null;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Deserialize a compressed mint from buffer
|
|
431
|
+
* Uses SPL's MintLayout for BaseMint and buffer-layout struct for context
|
|
432
|
+
*
|
|
433
|
+
* @param data - The raw account data buffer
|
|
434
|
+
* @returns The deserialized CompressedMint
|
|
435
|
+
*/
|
|
436
|
+
declare function deserializeMint(data: Buffer$1 | Uint8Array): CompressedMint;
|
|
437
|
+
/**
|
|
438
|
+
* Serialize a CompressedMint to buffer
|
|
439
|
+
* Uses SPL's MintLayout for BaseMint, helper functions for context/metadata
|
|
440
|
+
*
|
|
441
|
+
* @param mint - The CompressedMint to serialize
|
|
442
|
+
* @returns The serialized buffer
|
|
443
|
+
*/
|
|
444
|
+
declare function serializeMint(mint: CompressedMint): Buffer$1;
|
|
445
|
+
/**
|
|
446
|
+
* Extension type constants
|
|
447
|
+
*/
|
|
448
|
+
declare enum ExtensionType {
|
|
449
|
+
TokenMetadata = 19
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Decode TokenMetadata from raw extension data using Borsh layout
|
|
453
|
+
* Extension format: updateAuthority (32) + mint (32) + name (Vec) + symbol (Vec) + uri (Vec) + additional (Vec)
|
|
454
|
+
*/
|
|
455
|
+
declare function decodeTokenMetadata(data: Uint8Array): TokenMetadata | null;
|
|
456
|
+
/**
|
|
457
|
+
* Encode TokenMetadata to raw bytes using Borsh layout
|
|
458
|
+
* @param metadata - TokenMetadata to encode
|
|
459
|
+
* @returns Encoded buffer
|
|
460
|
+
*/
|
|
461
|
+
declare function encodeTokenMetadata(metadata: TokenMetadata): Buffer$1;
|
|
462
|
+
/**
|
|
463
|
+
* Extract and parse TokenMetadata from extensions array
|
|
464
|
+
* @param extensions - Array of raw extensions
|
|
465
|
+
* @returns Parsed TokenMetadata or null if not found
|
|
466
|
+
*/
|
|
467
|
+
declare function extractTokenMetadata(extensions: MintExtension[] | null): TokenMetadata | null;
|
|
468
|
+
/**
|
|
469
|
+
* Metadata portion of MintInstructionData
|
|
470
|
+
* Used for instruction encoding when metadata extension is present
|
|
471
|
+
*/
|
|
472
|
+
interface MintMetadataField {
|
|
473
|
+
updateAuthority: PublicKey | null;
|
|
474
|
+
name: string;
|
|
475
|
+
symbol: string;
|
|
476
|
+
uri: string;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Flattened mint data structure for instruction encoding
|
|
480
|
+
* This is the format expected by mint action instructions
|
|
481
|
+
*/
|
|
482
|
+
interface MintInstructionData {
|
|
483
|
+
supply: bigint;
|
|
484
|
+
decimals: number;
|
|
485
|
+
mintAuthority: PublicKey | null;
|
|
486
|
+
freezeAuthority: PublicKey | null;
|
|
487
|
+
splMint: PublicKey;
|
|
488
|
+
splMintInitialized: boolean;
|
|
489
|
+
version: number;
|
|
490
|
+
metadata?: MintMetadataField;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
interface MintInterface {
|
|
494
|
+
mint: Mint;
|
|
495
|
+
programId: PublicKey;
|
|
496
|
+
merkleContext?: MerkleContext;
|
|
497
|
+
mintContext?: MintContext;
|
|
498
|
+
tokenMetadata?: TokenMetadata;
|
|
499
|
+
extensions?: MintExtension[];
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Get unified mint info for SPL/T22/c-token mints.
|
|
503
|
+
*
|
|
504
|
+
* @param rpc RPC connection
|
|
505
|
+
* @param address The mint address
|
|
506
|
+
* @param commitment Optional commitment level
|
|
507
|
+
* @param programId Token program ID. If not provided, tries all programs to
|
|
508
|
+
* auto-detect.
|
|
509
|
+
* @returns Object with mint, optional merkleContext, mintContext, and
|
|
510
|
+
* tokenMetadata
|
|
511
|
+
*/
|
|
512
|
+
declare function getMintInterface(rpc: Rpc, address: PublicKey, commitment?: Commitment, programId?: PublicKey): Promise<MintInterface>;
|
|
513
|
+
/**
|
|
514
|
+
* Unpack mint info from raw account data for SPL/T22/c-token.
|
|
515
|
+
*
|
|
516
|
+
* @param address The mint pubkey
|
|
517
|
+
* @param data The raw account data or AccountInfo
|
|
518
|
+
* @param programId Token program ID. Default c-token.
|
|
519
|
+
* @returns Object with mint, optional mintContext and tokenMetadata.
|
|
520
|
+
*/
|
|
521
|
+
declare function unpackMintInterface(address: PublicKey, data: Buffer$1 | Uint8Array | AccountInfo<Buffer$1>, programId?: PublicKey): Omit<MintInterface, 'merkleContext'>;
|
|
522
|
+
/**
|
|
523
|
+
* Unpack c-token mint context and metadata from raw account data
|
|
524
|
+
*
|
|
525
|
+
* @param data The raw account data
|
|
526
|
+
* @returns Object with mintContext, tokenMetadata, and extensions
|
|
527
|
+
*/
|
|
528
|
+
declare function unpackMintData(data: Buffer$1 | Uint8Array): {
|
|
529
|
+
mintContext: MintContext;
|
|
530
|
+
tokenMetadata?: TokenMetadata;
|
|
531
|
+
extensions?: MintExtension[];
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Create instruction for updating a compressed mint's mint authority.
|
|
536
|
+
*
|
|
537
|
+
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext
|
|
538
|
+
* @param currentMintAuthority Current mint authority public key (must sign)
|
|
539
|
+
* @param newMintAuthority New mint authority (or null to revoke)
|
|
540
|
+
* @param payer Fee payer public key
|
|
541
|
+
* @param validityProof Validity proof for the compressed mint
|
|
542
|
+
*/
|
|
543
|
+
declare function createUpdateMintAuthorityInstruction(mintInterface: MintInterface, currentMintAuthority: PublicKey, newMintAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext): TransactionInstruction;
|
|
544
|
+
/**
|
|
545
|
+
* Create instruction for updating a compressed mint's freeze authority.
|
|
546
|
+
*
|
|
547
|
+
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
|
|
548
|
+
* (preferring nextTreeInfo.queue if available for rollover support).
|
|
549
|
+
*
|
|
550
|
+
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext
|
|
551
|
+
* @param currentFreezeAuthority Current freeze authority public key (must sign)
|
|
552
|
+
* @param newFreezeAuthority New freeze authority (or null to revoke)
|
|
553
|
+
* @param payer Fee payer public key
|
|
554
|
+
* @param validityProof Validity proof for the compressed mint
|
|
555
|
+
*/
|
|
556
|
+
declare function createUpdateFreezeAuthorityInstruction(mintInterface: MintInterface, currentFreezeAuthority: PublicKey, newFreezeAuthority: PublicKey | null, payer: PublicKey, validityProof: ValidityProofWithContext): TransactionInstruction;
|
|
557
|
+
|
|
558
|
+
/**
|
|
559
|
+
* Create instruction for updating a compressed mint's metadata field.
|
|
560
|
+
*
|
|
561
|
+
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
|
|
562
|
+
* (preferring nextTreeInfo.queue if available for rollover support).
|
|
563
|
+
*
|
|
564
|
+
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext and tokenMetadata
|
|
565
|
+
* @param authority Metadata update authority public key (must sign)
|
|
566
|
+
* @param payer Fee payer public key
|
|
567
|
+
* @param validityProof Validity proof for the compressed mint
|
|
568
|
+
* @param fieldType Field to update: 'name', 'symbol', 'uri', or 'custom'
|
|
569
|
+
* @param value New value for the field
|
|
570
|
+
* @param customKey Custom key name (required if fieldType is 'custom')
|
|
571
|
+
* @param extensionIndex Extension index (default: 0)
|
|
572
|
+
*/
|
|
573
|
+
declare function createUpdateMetadataFieldInstruction(mintInterface: MintInterface, authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, fieldType: 'name' | 'symbol' | 'uri' | 'custom', value: string, customKey?: string, extensionIndex?: number): TransactionInstruction;
|
|
574
|
+
/**
|
|
575
|
+
* Create instruction for updating a compressed mint's metadata authority.
|
|
576
|
+
*
|
|
577
|
+
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
|
|
578
|
+
* (preferring nextTreeInfo.queue if available for rollover support).
|
|
579
|
+
*
|
|
580
|
+
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext and tokenMetadata
|
|
581
|
+
* @param currentAuthority Current metadata update authority public key (must sign)
|
|
582
|
+
* @param newAuthority New metadata update authority public key
|
|
583
|
+
* @param payer Fee payer public key
|
|
584
|
+
* @param validityProof Validity proof for the compressed mint
|
|
585
|
+
* @param extensionIndex Extension index (default: 0)
|
|
586
|
+
*/
|
|
587
|
+
declare function createUpdateMetadataAuthorityInstruction(mintInterface: MintInterface, currentAuthority: PublicKey, newAuthority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, extensionIndex?: number): TransactionInstruction;
|
|
588
|
+
/**
|
|
589
|
+
* Create instruction for removing a metadata key from a compressed mint.
|
|
590
|
+
*
|
|
591
|
+
* Output queue is automatically derived from mintInterface.merkleContext.treeInfo
|
|
592
|
+
* (preferring nextTreeInfo.queue if available for rollover support).
|
|
593
|
+
*
|
|
594
|
+
* @param mintInterface MintInterface from getMintInterface() - must have merkleContext and tokenMetadata
|
|
595
|
+
* @param authority Metadata update authority public key (must sign)
|
|
596
|
+
* @param payer Fee payer public key
|
|
597
|
+
* @param validityProof Validity proof for the compressed mint
|
|
598
|
+
* @param key Metadata key to remove
|
|
599
|
+
* @param idempotent If true, don't error if key doesn't exist (default: false)
|
|
600
|
+
* @param extensionIndex Extension index (default: 0)
|
|
601
|
+
*/
|
|
602
|
+
declare function createRemoveMetadataKeyInstruction(mintInterface: MintInterface, authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, key: string, idempotent?: boolean, extensionIndex?: number): TransactionInstruction;
|
|
603
|
+
|
|
604
|
+
interface CompressToPubkey {
|
|
605
|
+
bump: number;
|
|
606
|
+
programId: number[];
|
|
607
|
+
seeds: number[][];
|
|
608
|
+
}
|
|
609
|
+
interface CompressibleConfig {
|
|
610
|
+
tokenAccountVersion: number;
|
|
611
|
+
rentPayment: number;
|
|
612
|
+
hasTopUp: number;
|
|
613
|
+
compressionOnly: number;
|
|
614
|
+
writeTopUp: number;
|
|
615
|
+
compressToAccountPubkey?: CompressToPubkey | null;
|
|
616
|
+
}
|
|
617
|
+
interface CreateAssociatedCTokenAccountParams {
|
|
618
|
+
bump: number;
|
|
619
|
+
compressibleConfig?: CompressibleConfig;
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* Create instruction for creating an associated compressed token account.
|
|
623
|
+
*
|
|
624
|
+
* @param feePayer Fee payer public key.
|
|
625
|
+
* @param owner Owner of the associated token account.
|
|
626
|
+
* @param mint Mint address.
|
|
627
|
+
* @param compressibleConfig Optional compressible configuration.
|
|
628
|
+
* @param configAccount Optional config account.
|
|
629
|
+
* @param rentPayerPda Optional rent payer PDA.
|
|
630
|
+
*/
|
|
631
|
+
declare function createAssociatedCTokenAccountInstruction(feePayer: PublicKey, owner: PublicKey, mint: PublicKey, compressibleConfig?: CompressibleConfig, configAccount?: PublicKey, rentPayerPda?: PublicKey): TransactionInstruction;
|
|
632
|
+
/**
|
|
633
|
+
* Create idempotent instruction for creating an associated compressed token account.
|
|
634
|
+
*
|
|
635
|
+
* @param feePayer Fee payer public key.
|
|
636
|
+
* @param owner Owner of the associated token account.
|
|
637
|
+
* @param mint Mint address.
|
|
638
|
+
* @param compressibleConfig Optional compressible configuration.
|
|
639
|
+
* @param configAccount Optional config account.
|
|
640
|
+
* @param rentPayerPda Optional rent payer PDA.
|
|
641
|
+
*/
|
|
642
|
+
declare function createAssociatedCTokenAccountIdempotentInstruction(feePayer: PublicKey, owner: PublicKey, mint: PublicKey, compressibleConfig?: CompressibleConfig, configAccount?: PublicKey, rentPayerPda?: PublicKey): TransactionInstruction;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* c-token-specific config for createAssociatedTokenAccountInterfaceInstruction
|
|
646
|
+
*/
|
|
647
|
+
interface CTokenConfig {
|
|
648
|
+
compressibleConfig?: CompressibleConfig;
|
|
649
|
+
configAccount?: PublicKey;
|
|
650
|
+
rentPayerPda?: PublicKey;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Create instruction for creating an associated token account (SPL, Token-2022,
|
|
654
|
+
* or c-token). Follows SPL Token API signature with optional c-token config at the
|
|
655
|
+
* end.
|
|
656
|
+
*
|
|
657
|
+
* @param payer Fee payer public key.
|
|
658
|
+
* @param associatedToken Associated token account address.
|
|
659
|
+
* @param owner Owner of the associated token account.
|
|
660
|
+
* @param mint Mint address.
|
|
661
|
+
* @param programId Token program ID (default: TOKEN_PROGRAM_ID).
|
|
662
|
+
* @param associatedTokenProgramId Associated token program ID.
|
|
663
|
+
* @param ctokenConfig Optional c-token-specific configuration.
|
|
664
|
+
*/
|
|
665
|
+
declare function createAssociatedTokenAccountInterfaceInstruction(payer: PublicKey, associatedToken: PublicKey, owner: PublicKey, mint: PublicKey, programId?: PublicKey, associatedTokenProgramId?: PublicKey, ctokenConfig?: CTokenConfig): TransactionInstruction;
|
|
666
|
+
/**
|
|
667
|
+
* Create idempotent instruction for creating an associated token account (SPL,
|
|
668
|
+
* Token-2022, or c-token). Follows SPL Token API signature with optional c-token
|
|
669
|
+
* config at the end.
|
|
670
|
+
*
|
|
671
|
+
* @param payer Fee payer public key.
|
|
672
|
+
* @param associatedToken Associated token account address.
|
|
673
|
+
* @param owner Owner of the associated token account.
|
|
674
|
+
* @param mint Mint address.
|
|
675
|
+
* @param programId Token program ID (default: TOKEN_PROGRAM_ID).
|
|
676
|
+
* @param associatedTokenProgramId Associated token program ID.
|
|
677
|
+
* @param ctokenConfig Optional c-token-specific configuration.
|
|
678
|
+
*/
|
|
679
|
+
declare function createAssociatedTokenAccountInterfaceIdempotentInstruction(payer: PublicKey, associatedToken: PublicKey, owner: PublicKey, mint: PublicKey, programId?: PublicKey, associatedTokenProgramId?: PublicKey, ctokenConfig?: CTokenConfig): TransactionInstruction;
|
|
680
|
+
/**
|
|
681
|
+
* Short alias for createAssociatedTokenAccountInterfaceIdempotentInstruction.
|
|
682
|
+
*/
|
|
683
|
+
declare const createAtaInterfaceIdempotentInstruction: typeof createAssociatedTokenAccountInterfaceIdempotentInstruction;
|
|
684
|
+
|
|
685
|
+
/**
|
|
686
|
+
* Create instruction for minting compressed tokens to an onchain token account.
|
|
687
|
+
*
|
|
688
|
+
* @param authority Mint authority public key.
|
|
689
|
+
* @param payer Fee payer public key.
|
|
690
|
+
* @param validityProof Validity proof for the compressed mint.
|
|
691
|
+
* @param merkleContext Merkle context of the compressed mint.
|
|
692
|
+
* @param mintData Mint instruction data.
|
|
693
|
+
* @param outputStateTreeInfo Output state tree info.
|
|
694
|
+
* @param recipientAccount Recipient onchain token account address.
|
|
695
|
+
* @param amount Amount to mint.
|
|
696
|
+
*/
|
|
697
|
+
declare function createMintToInstruction(authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, merkleContext: MerkleContext, mintData: MintInstructionData, outputStateTreeInfo: TreeInfo, recipientAccount: PublicKey, amount: number | bigint): TransactionInstruction;
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* Token data version enum - mirrors Rust TokenDataVersion
|
|
701
|
+
* Used for compressed token account hashing strategy
|
|
702
|
+
*/
|
|
703
|
+
declare enum TokenDataVersion {
|
|
704
|
+
/** V1: Poseidon hash with little-endian amount, discriminator [2,0,0,0,0,0,0,0] */
|
|
705
|
+
V1 = 1,
|
|
706
|
+
/** V2: Poseidon hash with big-endian amount, discriminator [0,0,0,0,0,0,0,3] */
|
|
707
|
+
V2 = 2,
|
|
708
|
+
/** ShaFlat: SHA256 hash of borsh-serialized data, discriminator [0,0,0,0,0,0,0,4] */
|
|
709
|
+
ShaFlat = 3
|
|
710
|
+
}
|
|
711
|
+
declare const POOL_SEED: Buffer$1<ArrayBuffer>;
|
|
712
|
+
declare const CPI_AUTHORITY_SEED: Buffer$1<ArrayBuffer>;
|
|
713
|
+
declare const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
|
|
714
|
+
declare const CREATE_TOKEN_POOL_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
715
|
+
declare const MINT_TO_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
716
|
+
declare const BATCH_COMPRESS_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
717
|
+
declare const TRANSFER_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
718
|
+
declare const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
719
|
+
declare const APPROVE_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
720
|
+
declare const REVOKE_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
721
|
+
declare const ADD_TOKEN_POOL_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
722
|
+
declare const DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR: Buffer$1<ArrayBuffer>;
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Create instruction for minting tokens from a c-mint to compressed accounts.
|
|
726
|
+
* To mint to onchain token accounts across SPL/T22/c-mints, use
|
|
727
|
+
* {@link createMintToInterfaceInstruction} instead.
|
|
728
|
+
*
|
|
729
|
+
* @param authority Mint authority public key.
|
|
730
|
+
* @param payer Fee payer public key.
|
|
731
|
+
* @param validityProof Validity proof for the compressed mint.
|
|
732
|
+
* @param merkleContext Merkle context of the compressed mint.
|
|
733
|
+
* @param mintData Mint instruction data.
|
|
734
|
+
* @param recipients Array of recipients with amounts.
|
|
735
|
+
* @param outputStateTreeInfo Optional output state tree info. Uses merkle
|
|
736
|
+
* context queue if not provided.
|
|
737
|
+
* @param tokenAccountVersion Token account version (default:
|
|
738
|
+
* TokenDataVersion.ShaFlat).
|
|
739
|
+
*/
|
|
740
|
+
declare function createMintToCompressedInstruction(authority: PublicKey, payer: PublicKey, validityProof: ValidityProofWithContext, merkleContext: MerkleContext, mintData: MintInstructionData, recipients: Array<{
|
|
741
|
+
recipient: PublicKey;
|
|
742
|
+
amount: number | bigint;
|
|
743
|
+
}>, outputStateTreeInfo?: TreeInfo, tokenAccountVersion?: TokenDataVersion): TransactionInstruction;
|
|
744
|
+
|
|
745
|
+
/**
|
|
746
|
+
* Create mint-to instruction for SPL, Token-2022, or compressed token mints.
|
|
747
|
+
* This instruction ONLY mints to decompressed/onchain token accounts.
|
|
748
|
+
*
|
|
749
|
+
* @param mintInterface Mint interface (SPL, Token-2022, or compressed).
|
|
750
|
+
* @param destination Destination onchain token account address.
|
|
751
|
+
* @param authority Mint authority public key.
|
|
752
|
+
* @param payer Fee payer public key.
|
|
753
|
+
* @param amount Amount to mint.
|
|
754
|
+
* @param validityProof Validity proof (required for compressed mints).
|
|
755
|
+
* @param multiSigners Multi-signature signer public keys.
|
|
756
|
+
*/
|
|
757
|
+
declare function createMintToInterfaceInstruction(mintInterface: MintInterface, destination: PublicKey, authority: PublicKey, payer: PublicKey, amount: number | bigint, validityProof?: ValidityProofWithContext, multiSigners?: PublicKey[]): TransactionInstruction;
|
|
758
|
+
|
|
759
|
+
/**
|
|
760
|
+
* Create a c-token transfer instruction.
|
|
761
|
+
*
|
|
762
|
+
* @param source Source c-token account
|
|
763
|
+
* @param destination Destination c-token account
|
|
764
|
+
* @param owner Owner of the source account (signer)
|
|
765
|
+
* @param amount Amount to transfer
|
|
766
|
+
* @param payer Payer for compressible extension top-up (optional)
|
|
767
|
+
* @returns Transaction instruction for c-token transfer
|
|
768
|
+
*/
|
|
769
|
+
declare function createCTokenTransferInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, payer?: PublicKey): TransactionInstruction;
|
|
770
|
+
/**
|
|
771
|
+
* Construct a transfer instruction for SPL/T22/c-token. Defaults to c-token
|
|
772
|
+
* program. For cross-program transfers (SPL <> c-token), use `wrap`/`unwrap`.
|
|
773
|
+
*
|
|
774
|
+
* @param source Source token account
|
|
775
|
+
* @param destination Destination token account
|
|
776
|
+
* @param owner Owner of the source account (signer)
|
|
777
|
+
* @param amount Amount to transfer
|
|
778
|
+
* @param payer Payer for compressible top-up (optional)
|
|
779
|
+
* @returns instruction for c-token transfer
|
|
780
|
+
*/
|
|
781
|
+
declare function createTransferInterfaceInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, amount: number | bigint, multiSigners?: (Signer | PublicKey)[], programId?: PublicKey, payer?: PublicKey): TransactionInstruction;
|
|
782
|
+
|
|
783
|
+
declare namespace BN {
|
|
784
|
+
type Endianness = "le" | "be";
|
|
785
|
+
type IPrimeName = "k256" | "p224" | "p192" | "p25519";
|
|
786
|
+
|
|
787
|
+
interface MPrime {
|
|
788
|
+
name: string;
|
|
789
|
+
p: BN;
|
|
790
|
+
n: number;
|
|
791
|
+
k: BN;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
interface ReductionContext {
|
|
795
|
+
m: number;
|
|
796
|
+
prime: MPrime;
|
|
797
|
+
[key: string]: any;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
declare class BN {
|
|
802
|
+
static BN: typeof BN;
|
|
803
|
+
static wordSize: 26;
|
|
804
|
+
|
|
805
|
+
constructor(
|
|
806
|
+
number: bigint | number | string | number[] | Uint8Array | Buffer | BN,
|
|
807
|
+
base?: number | "hex",
|
|
808
|
+
endian?: BN.Endianness,
|
|
809
|
+
);
|
|
810
|
+
constructor(
|
|
811
|
+
number: bigint | number | string | number[] | Uint8Array | Buffer | BN,
|
|
812
|
+
endian?: BN.Endianness,
|
|
813
|
+
);
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* @description create a reduction context
|
|
817
|
+
*/
|
|
818
|
+
static red(reductionContext: BN | BN.IPrimeName): BN.ReductionContext;
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* @description create a reduction context with the Montgomery trick.
|
|
822
|
+
*/
|
|
823
|
+
static mont(num: BN): BN.ReductionContext;
|
|
824
|
+
|
|
825
|
+
/**
|
|
826
|
+
* @description returns true if the supplied object is a BN.js instance
|
|
827
|
+
*/
|
|
828
|
+
static isBN(b: any): b is BN;
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* @description returns the maximum of 2 BN instances.
|
|
832
|
+
*/
|
|
833
|
+
static max(left: BN, right: BN): BN;
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* @description returns the minimum of 2 BN instances.
|
|
837
|
+
*/
|
|
838
|
+
static min(left: BN, right: BN): BN;
|
|
839
|
+
|
|
840
|
+
/**
|
|
841
|
+
* @description Copy to dest number
|
|
842
|
+
*/
|
|
843
|
+
copy(dest: BN): void;
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* @description clone number
|
|
847
|
+
*/
|
|
848
|
+
clone(): BN;
|
|
849
|
+
|
|
850
|
+
/**
|
|
851
|
+
* @description convert to base-string and pad with zeroes
|
|
852
|
+
*/
|
|
853
|
+
toString(base?: number | "hex", length?: number): string;
|
|
854
|
+
|
|
855
|
+
/**
|
|
856
|
+
* @description convert to Javascript Number (limited to 53 bits)
|
|
857
|
+
*/
|
|
858
|
+
toNumber(): number;
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* @description convert to JSON compatible hex string (alias of toString(16))
|
|
862
|
+
*/
|
|
863
|
+
toJSON(): string;
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* @description convert to byte Array, and optionally zero pad to length, throwing if already exceeding
|
|
867
|
+
*/
|
|
868
|
+
toArray(endian?: BN.Endianness, length?: number): number[];
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* @description convert to an instance of `type`, which must behave like an Array
|
|
872
|
+
*/
|
|
873
|
+
toArrayLike(
|
|
874
|
+
ArrayType: typeof Buffer,
|
|
875
|
+
endian?: BN.Endianness,
|
|
876
|
+
length?: number,
|
|
877
|
+
): Buffer;
|
|
878
|
+
|
|
879
|
+
toArrayLike(
|
|
880
|
+
ArrayType: any[],
|
|
881
|
+
endian?: BN.Endianness,
|
|
882
|
+
length?: number,
|
|
883
|
+
): any[];
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* @description convert to Node.js Buffer (if available). For compatibility with browserify and similar tools, use this instead: a.toArrayLike(Buffer, endian, length)
|
|
887
|
+
*/
|
|
888
|
+
toBuffer(endian?: BN.Endianness, length?: number): Buffer;
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* @description get number of bits occupied
|
|
892
|
+
*/
|
|
893
|
+
bitLength(): number;
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* @description return number of less-significant consequent zero bits (example: 1010000 has 4 zero bits)
|
|
897
|
+
*/
|
|
898
|
+
zeroBits(): number;
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* @description return number of bytes occupied
|
|
902
|
+
*/
|
|
903
|
+
byteLength(): number;
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* @description true if the number is negative
|
|
907
|
+
*/
|
|
908
|
+
isNeg(): boolean;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* @description check if value is even
|
|
912
|
+
*/
|
|
913
|
+
isEven(): boolean;
|
|
914
|
+
|
|
915
|
+
/**
|
|
916
|
+
* @description check if value is odd
|
|
917
|
+
*/
|
|
918
|
+
isOdd(): boolean;
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* @description check if value is zero
|
|
922
|
+
*/
|
|
923
|
+
isZero(): boolean;
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* @description compare numbers and return `-1 (a < b)`, `0 (a == b)`, or `1 (a > b)` depending on the comparison result
|
|
927
|
+
*/
|
|
928
|
+
cmp(b: BN): -1 | 0 | 1;
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* @description compare numbers and return `-1 (a < b)`, `0 (a == b)`, or `1 (a > b)` depending on the comparison result
|
|
932
|
+
*/
|
|
933
|
+
ucmp(b: BN): -1 | 0 | 1;
|
|
934
|
+
|
|
935
|
+
/**
|
|
936
|
+
* @description compare numbers and return `-1 (a < b)`, `0 (a == b)`, or `1 (a > b)` depending on the comparison result
|
|
937
|
+
*/
|
|
938
|
+
cmpn(b: number): -1 | 0 | 1;
|
|
939
|
+
|
|
940
|
+
/**
|
|
941
|
+
* @description a less than b
|
|
942
|
+
*/
|
|
943
|
+
lt(b: BN): boolean;
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* @description a less than b
|
|
947
|
+
*/
|
|
948
|
+
ltn(b: number): boolean;
|
|
949
|
+
|
|
950
|
+
/**
|
|
951
|
+
* @description a less than or equals b
|
|
952
|
+
*/
|
|
953
|
+
lte(b: BN): boolean;
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* @description a less than or equals b
|
|
957
|
+
*/
|
|
958
|
+
lten(b: number): boolean;
|
|
959
|
+
|
|
960
|
+
/**
|
|
961
|
+
* @description a greater than b
|
|
962
|
+
*/
|
|
963
|
+
gt(b: BN): boolean;
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* @description a greater than b
|
|
967
|
+
*/
|
|
968
|
+
gtn(b: number): boolean;
|
|
969
|
+
|
|
970
|
+
/**
|
|
971
|
+
* @description a greater than or equals b
|
|
972
|
+
*/
|
|
973
|
+
gte(b: BN): boolean;
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* @description a greater than or equals b
|
|
977
|
+
*/
|
|
978
|
+
gten(b: number): boolean;
|
|
979
|
+
|
|
980
|
+
/**
|
|
981
|
+
* @description a equals b
|
|
982
|
+
*/
|
|
983
|
+
eq(b: BN): boolean;
|
|
984
|
+
|
|
985
|
+
/**
|
|
986
|
+
* @description a equals b
|
|
987
|
+
*/
|
|
988
|
+
eqn(b: number): boolean;
|
|
989
|
+
|
|
990
|
+
/**
|
|
991
|
+
* @description convert to two's complement representation, where width is bit width
|
|
992
|
+
*/
|
|
993
|
+
toTwos(width: number): BN;
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* @description convert from two's complement representation, where width is the bit width
|
|
997
|
+
*/
|
|
998
|
+
fromTwos(width: number): BN;
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* @description negate sign
|
|
1002
|
+
*/
|
|
1003
|
+
neg(): BN;
|
|
1004
|
+
|
|
1005
|
+
/**
|
|
1006
|
+
* @description negate sign
|
|
1007
|
+
*/
|
|
1008
|
+
ineg(): BN;
|
|
1009
|
+
|
|
1010
|
+
/**
|
|
1011
|
+
* @description absolute value
|
|
1012
|
+
*/
|
|
1013
|
+
abs(): BN;
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* @description absolute value
|
|
1017
|
+
*/
|
|
1018
|
+
iabs(): BN;
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* @description addition
|
|
1022
|
+
*/
|
|
1023
|
+
add(b: BN): BN;
|
|
1024
|
+
|
|
1025
|
+
/**
|
|
1026
|
+
* @description addition
|
|
1027
|
+
*/
|
|
1028
|
+
iadd(b: BN): BN;
|
|
1029
|
+
|
|
1030
|
+
/**
|
|
1031
|
+
* @description addition
|
|
1032
|
+
*/
|
|
1033
|
+
addn(b: number): BN;
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* @description addition
|
|
1037
|
+
*/
|
|
1038
|
+
iaddn(b: number): BN;
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* @description subtraction
|
|
1042
|
+
*/
|
|
1043
|
+
sub(b: BN): BN;
|
|
1044
|
+
|
|
1045
|
+
/**
|
|
1046
|
+
* @description subtraction
|
|
1047
|
+
*/
|
|
1048
|
+
isub(b: BN): BN;
|
|
1049
|
+
|
|
1050
|
+
/**
|
|
1051
|
+
* @description subtraction
|
|
1052
|
+
*/
|
|
1053
|
+
subn(b: number): BN;
|
|
1054
|
+
|
|
1055
|
+
/**
|
|
1056
|
+
* @description subtraction
|
|
1057
|
+
*/
|
|
1058
|
+
isubn(b: number): BN;
|
|
1059
|
+
|
|
1060
|
+
/**
|
|
1061
|
+
* @description multiply
|
|
1062
|
+
*/
|
|
1063
|
+
mul(b: BN): BN;
|
|
1064
|
+
|
|
1065
|
+
/**
|
|
1066
|
+
* @description multiply
|
|
1067
|
+
*/
|
|
1068
|
+
imul(b: BN): BN;
|
|
1069
|
+
|
|
1070
|
+
/**
|
|
1071
|
+
* @description multiply
|
|
1072
|
+
*/
|
|
1073
|
+
muln(b: number): BN;
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* @description multiply
|
|
1077
|
+
*/
|
|
1078
|
+
imuln(b: number): BN;
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* @description square
|
|
1082
|
+
*/
|
|
1083
|
+
sqr(): BN;
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* @description square
|
|
1087
|
+
*/
|
|
1088
|
+
isqr(): BN;
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* @description raise `a` to the power of `b`
|
|
1092
|
+
*/
|
|
1093
|
+
pow(b: BN): BN;
|
|
1094
|
+
|
|
1095
|
+
/**
|
|
1096
|
+
* @description divide
|
|
1097
|
+
*/
|
|
1098
|
+
div(b: BN): BN;
|
|
1099
|
+
|
|
1100
|
+
/**
|
|
1101
|
+
* @description divide
|
|
1102
|
+
*/
|
|
1103
|
+
divn(b: number): BN;
|
|
1104
|
+
|
|
1105
|
+
/**
|
|
1106
|
+
* @description divide
|
|
1107
|
+
*/
|
|
1108
|
+
idivn(b: number): BN;
|
|
1109
|
+
|
|
1110
|
+
/**
|
|
1111
|
+
* @description division with remainder
|
|
1112
|
+
*/
|
|
1113
|
+
divmod(b: BN, mode?: "div" | "mod", positive?: boolean): { div: BN; mod: BN };
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* @description reduct
|
|
1117
|
+
*/
|
|
1118
|
+
mod(b: BN): BN;
|
|
1119
|
+
|
|
1120
|
+
/**
|
|
1121
|
+
* @description reduct
|
|
1122
|
+
*/
|
|
1123
|
+
umod(b: BN): BN;
|
|
1124
|
+
|
|
1125
|
+
/**
|
|
1126
|
+
* @deprecated
|
|
1127
|
+
* @description reduct
|
|
1128
|
+
*/
|
|
1129
|
+
modn(b: number): number;
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* @description reduct
|
|
1133
|
+
*/
|
|
1134
|
+
modrn(b: number): number;
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* @description rounded division
|
|
1138
|
+
*/
|
|
1139
|
+
divRound(b: BN): BN;
|
|
1140
|
+
|
|
1141
|
+
/**
|
|
1142
|
+
* @description or
|
|
1143
|
+
*/
|
|
1144
|
+
or(b: BN): BN;
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* @description or
|
|
1148
|
+
*/
|
|
1149
|
+
ior(b: BN): BN;
|
|
1150
|
+
|
|
1151
|
+
/**
|
|
1152
|
+
* @description or
|
|
1153
|
+
*/
|
|
1154
|
+
uor(b: BN): BN;
|
|
1155
|
+
|
|
1156
|
+
/**
|
|
1157
|
+
* @description or
|
|
1158
|
+
*/
|
|
1159
|
+
iuor(b: BN): BN;
|
|
1160
|
+
|
|
1161
|
+
/**
|
|
1162
|
+
* @description and
|
|
1163
|
+
*/
|
|
1164
|
+
and(b: BN): BN;
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* @description and
|
|
1168
|
+
*/
|
|
1169
|
+
iand(b: BN): BN;
|
|
1170
|
+
|
|
1171
|
+
/**
|
|
1172
|
+
* @description and
|
|
1173
|
+
*/
|
|
1174
|
+
uand(b: BN): BN;
|
|
1175
|
+
|
|
1176
|
+
/**
|
|
1177
|
+
* @description and
|
|
1178
|
+
*/
|
|
1179
|
+
iuand(b: BN): BN;
|
|
1180
|
+
|
|
1181
|
+
/**
|
|
1182
|
+
* @description and (NOTE: `andln` is going to be replaced with `andn` in future)
|
|
1183
|
+
*/
|
|
1184
|
+
andln(b: number): BN;
|
|
1185
|
+
|
|
1186
|
+
/**
|
|
1187
|
+
* @description xor
|
|
1188
|
+
*/
|
|
1189
|
+
xor(b: BN): BN;
|
|
1190
|
+
|
|
1191
|
+
/**
|
|
1192
|
+
* @description xor
|
|
1193
|
+
*/
|
|
1194
|
+
ixor(b: BN): BN;
|
|
1195
|
+
|
|
1196
|
+
/**
|
|
1197
|
+
* @description xor
|
|
1198
|
+
*/
|
|
1199
|
+
uxor(b: BN): BN;
|
|
1200
|
+
|
|
1201
|
+
/**
|
|
1202
|
+
* @description xor
|
|
1203
|
+
*/
|
|
1204
|
+
iuxor(b: BN): BN;
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* @description set specified bit to value
|
|
1208
|
+
*/
|
|
1209
|
+
setn(b: number, value: boolean | 0 | 1): BN;
|
|
1210
|
+
|
|
1211
|
+
/**
|
|
1212
|
+
* @description shift left
|
|
1213
|
+
*/
|
|
1214
|
+
shln(b: number): BN;
|
|
1215
|
+
|
|
1216
|
+
/**
|
|
1217
|
+
* @description shift left
|
|
1218
|
+
*/
|
|
1219
|
+
ishln(b: number): BN;
|
|
1220
|
+
|
|
1221
|
+
/**
|
|
1222
|
+
* @description shift left
|
|
1223
|
+
*/
|
|
1224
|
+
ushln(b: number): BN;
|
|
1225
|
+
|
|
1226
|
+
/**
|
|
1227
|
+
* @description shift left
|
|
1228
|
+
*/
|
|
1229
|
+
iushln(b: number): BN;
|
|
1230
|
+
|
|
1231
|
+
/**
|
|
1232
|
+
* @description shift right
|
|
1233
|
+
*/
|
|
1234
|
+
shrn(b: number): BN;
|
|
1235
|
+
|
|
1236
|
+
/**
|
|
1237
|
+
* @description shift right (unimplemented https://github.com/indutny/bn.js/blob/master/lib/bn.js#L2086)
|
|
1238
|
+
*/
|
|
1239
|
+
ishrn(b: number): BN;
|
|
1240
|
+
|
|
1241
|
+
/**
|
|
1242
|
+
* @description shift right
|
|
1243
|
+
*/
|
|
1244
|
+
ushrn(b: number): BN;
|
|
1245
|
+
/**
|
|
1246
|
+
* @description shift right
|
|
1247
|
+
*/
|
|
1248
|
+
|
|
1249
|
+
iushrn(b: number): BN;
|
|
1250
|
+
/**
|
|
1251
|
+
* @description test if specified bit is set
|
|
1252
|
+
*/
|
|
1253
|
+
|
|
1254
|
+
testn(b: number): boolean;
|
|
1255
|
+
/**
|
|
1256
|
+
* @description clear bits with indexes higher or equal to `b`
|
|
1257
|
+
*/
|
|
1258
|
+
|
|
1259
|
+
maskn(b: number): BN;
|
|
1260
|
+
/**
|
|
1261
|
+
* @description clear bits with indexes higher or equal to `b`
|
|
1262
|
+
*/
|
|
1263
|
+
|
|
1264
|
+
imaskn(b: number): BN;
|
|
1265
|
+
/**
|
|
1266
|
+
* @description add `1 << b` to the number
|
|
1267
|
+
*/
|
|
1268
|
+
bincn(b: number): BN;
|
|
1269
|
+
|
|
1270
|
+
/**
|
|
1271
|
+
* @description not (for the width specified by `w`)
|
|
1272
|
+
*/
|
|
1273
|
+
notn(w: number): BN;
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* @description not (for the width specified by `w`)
|
|
1277
|
+
*/
|
|
1278
|
+
inotn(w: number): BN;
|
|
1279
|
+
|
|
1280
|
+
/**
|
|
1281
|
+
* @description GCD
|
|
1282
|
+
*/
|
|
1283
|
+
gcd(b: BN): BN;
|
|
1284
|
+
|
|
1285
|
+
/**
|
|
1286
|
+
* @description Extended GCD results `({ a: ..., b: ..., gcd: ... })`
|
|
1287
|
+
*/
|
|
1288
|
+
egcd(b: BN): { a: BN; b: BN; gcd: BN };
|
|
1289
|
+
|
|
1290
|
+
/**
|
|
1291
|
+
* @description inverse `a` modulo `b`
|
|
1292
|
+
*/
|
|
1293
|
+
invm(b: BN): BN;
|
|
1294
|
+
|
|
1295
|
+
/**
|
|
1296
|
+
* @description Convert number to red
|
|
1297
|
+
*/
|
|
1298
|
+
toRed(reductionContext: BN.ReductionContext): RedBN;
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
/**
|
|
1302
|
+
* BN operations in a reduction context.
|
|
1303
|
+
*/
|
|
1304
|
+
declare class RedBN extends BN {
|
|
1305
|
+
/**
|
|
1306
|
+
* @description Convert back a number using a reduction context
|
|
1307
|
+
*/
|
|
1308
|
+
fromRed(): BN;
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* @description modular addition
|
|
1312
|
+
*/
|
|
1313
|
+
redAdd(b: RedBN): RedBN;
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* @description in-place modular addition
|
|
1317
|
+
*/
|
|
1318
|
+
redIAdd(b: RedBN): RedBN;
|
|
1319
|
+
|
|
1320
|
+
/**
|
|
1321
|
+
* @description modular subtraction
|
|
1322
|
+
*/
|
|
1323
|
+
redSub(b: RedBN): RedBN;
|
|
1324
|
+
|
|
1325
|
+
/**
|
|
1326
|
+
* @description in-place modular subtraction
|
|
1327
|
+
*/
|
|
1328
|
+
redISub(b: RedBN): RedBN;
|
|
1329
|
+
|
|
1330
|
+
/**
|
|
1331
|
+
* @description modular shift left
|
|
1332
|
+
*/
|
|
1333
|
+
redShl(num: number): RedBN;
|
|
1334
|
+
|
|
1335
|
+
/**
|
|
1336
|
+
* @description modular multiplication
|
|
1337
|
+
*/
|
|
1338
|
+
redMul(b: RedBN): RedBN;
|
|
1339
|
+
|
|
1340
|
+
/**
|
|
1341
|
+
* @description in-place modular multiplication
|
|
1342
|
+
*/
|
|
1343
|
+
redIMul(b: RedBN): RedBN;
|
|
1344
|
+
|
|
1345
|
+
/**
|
|
1346
|
+
* @description modular square
|
|
1347
|
+
*/
|
|
1348
|
+
redSqr(): RedBN;
|
|
1349
|
+
|
|
1350
|
+
/**
|
|
1351
|
+
* @description in-place modular square
|
|
1352
|
+
*/
|
|
1353
|
+
redISqr(): RedBN;
|
|
1354
|
+
|
|
1355
|
+
/**
|
|
1356
|
+
* @description modular square root
|
|
1357
|
+
*/
|
|
1358
|
+
redSqrt(): RedBN;
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* @description modular inverse of the number
|
|
1362
|
+
*/
|
|
1363
|
+
redInvm(): RedBN;
|
|
1364
|
+
|
|
1365
|
+
/**
|
|
1366
|
+
* @description modular negation
|
|
1367
|
+
*/
|
|
1368
|
+
redNeg(): RedBN;
|
|
1369
|
+
|
|
1370
|
+
/**
|
|
1371
|
+
* @description modular exponentiation
|
|
1372
|
+
*/
|
|
1373
|
+
redPow(b: BN): RedBN;
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
/**
|
|
1377
|
+
* SPL interface PDA info.
|
|
1378
|
+
*/
|
|
1379
|
+
type SplInterfaceInfo = {
|
|
1380
|
+
/**
|
|
1381
|
+
* The mint of the SPL interface
|
|
1382
|
+
*/
|
|
1383
|
+
mint: PublicKey;
|
|
1384
|
+
/**
|
|
1385
|
+
* The SPL interface address
|
|
1386
|
+
*/
|
|
1387
|
+
splInterfacePda: PublicKey;
|
|
1388
|
+
/**
|
|
1389
|
+
* The token program of the SPL interface
|
|
1390
|
+
*/
|
|
1391
|
+
tokenProgram: PublicKey;
|
|
1392
|
+
/**
|
|
1393
|
+
* count of txs and volume in the past 60 seconds.
|
|
1394
|
+
*/
|
|
1395
|
+
activity?: {
|
|
1396
|
+
txs: number;
|
|
1397
|
+
amountAdded: BN;
|
|
1398
|
+
amountRemoved: BN;
|
|
1399
|
+
};
|
|
1400
|
+
/**
|
|
1401
|
+
* Whether the SPL interface is initialized
|
|
1402
|
+
*/
|
|
1403
|
+
isInitialized: boolean;
|
|
1404
|
+
/**
|
|
1405
|
+
* The balance of the SPL interface
|
|
1406
|
+
*/
|
|
1407
|
+
balance: BN;
|
|
1408
|
+
/**
|
|
1409
|
+
* The index of the SPL interface
|
|
1410
|
+
*/
|
|
1411
|
+
poolIndex: number;
|
|
1412
|
+
/**
|
|
1413
|
+
* The bump used to derive the SPL interface PDA
|
|
1414
|
+
*/
|
|
1415
|
+
bump: number;
|
|
42
1416
|
};
|
|
43
1417
|
/**
|
|
44
|
-
*
|
|
1418
|
+
* @deprecated Use {@link SplInterfaceInfo} instead.
|
|
1419
|
+
* This type maintains backward compatibility by including both tokenPoolPda and splInterfacePda.
|
|
1420
|
+
* Both properties point to the same PublicKey value.
|
|
45
1421
|
*/
|
|
46
1422
|
type TokenPoolInfo = {
|
|
47
1423
|
/**
|
|
48
|
-
* The mint of the
|
|
1424
|
+
* The mint of the SPL interface
|
|
49
1425
|
*/
|
|
50
1426
|
mint: PublicKey;
|
|
51
1427
|
/**
|
|
52
|
-
*
|
|
1428
|
+
* @deprecated Use splInterfacePda instead.
|
|
53
1429
|
*/
|
|
54
1430
|
tokenPoolPda: PublicKey;
|
|
55
1431
|
/**
|
|
56
|
-
* The
|
|
1432
|
+
* The SPL interface address (new name).
|
|
1433
|
+
* For backward compatibility, tokenPoolPda is also available.
|
|
1434
|
+
*/
|
|
1435
|
+
splInterfacePda: PublicKey;
|
|
1436
|
+
/**
|
|
1437
|
+
* The token program of the SPL interface
|
|
57
1438
|
*/
|
|
58
1439
|
tokenProgram: PublicKey;
|
|
59
1440
|
/**
|
|
@@ -65,22 +1446,60 @@ type TokenPoolInfo = {
|
|
|
65
1446
|
amountRemoved: BN;
|
|
66
1447
|
};
|
|
67
1448
|
/**
|
|
68
|
-
* Whether the
|
|
1449
|
+
* Whether the SPL interface is initialized
|
|
69
1450
|
*/
|
|
70
1451
|
isInitialized: boolean;
|
|
71
1452
|
/**
|
|
72
|
-
* The balance of the
|
|
1453
|
+
* The balance of the SPL interface
|
|
73
1454
|
*/
|
|
74
1455
|
balance: BN;
|
|
75
1456
|
/**
|
|
76
|
-
* The index of the
|
|
1457
|
+
* The index of the SPL interface
|
|
77
1458
|
*/
|
|
78
1459
|
poolIndex: number;
|
|
79
1460
|
/**
|
|
80
|
-
* The bump used to derive the
|
|
1461
|
+
* The bump used to derive the SPL interface PDA
|
|
81
1462
|
*/
|
|
82
1463
|
bump: number;
|
|
83
1464
|
};
|
|
1465
|
+
/**
|
|
1466
|
+
* Convert SplInterfaceInfo to TokenPoolInfo for backward compatibility.
|
|
1467
|
+
* @internal
|
|
1468
|
+
*/
|
|
1469
|
+
declare function toTokenPoolInfo(info: SplInterfaceInfo): TokenPoolInfo;
|
|
1470
|
+
/**
|
|
1471
|
+
* Derive SplInterfaceInfo for an SPL interface that will be initialized in the
|
|
1472
|
+
* same transaction. Use this when you need to create an SPL interface and
|
|
1473
|
+
* compress in a single transaction.
|
|
1474
|
+
*
|
|
1475
|
+
* @param mint The mint of the SPL interface
|
|
1476
|
+
* @param tokenProgramId The token program (TOKEN_PROGRAM_ID or TOKEN_2022_PROGRAM_ID)
|
|
1477
|
+
* @param poolIndex The pool index. Default 0.
|
|
1478
|
+
*
|
|
1479
|
+
* @returns SplInterfaceInfo for the to-be-initialized interface
|
|
1480
|
+
*/
|
|
1481
|
+
declare function deriveSplInterfaceInfo(mint: PublicKey, tokenProgramId: PublicKey, poolIndex?: number): SplInterfaceInfo;
|
|
1482
|
+
/**
|
|
1483
|
+
* Check if the SPL interface info is initialized and has a balance.
|
|
1484
|
+
* @param mint The mint of the SPL interface
|
|
1485
|
+
* @param splInterfaceInfo The SPL interface info (or TokenPoolInfo for backward compatibility)
|
|
1486
|
+
* @returns True if the SPL interface info is initialized and has a balance
|
|
1487
|
+
*/
|
|
1488
|
+
declare function checkSplInterfaceInfo(splInterfaceInfo: SplInterfaceInfo | TokenPoolInfo, mint: PublicKey): boolean;
|
|
1489
|
+
/**
|
|
1490
|
+
* Get the SPL interface infos for a given mint.
|
|
1491
|
+
* @param rpc The RPC client
|
|
1492
|
+
* @param mint The mint of the SPL interface
|
|
1493
|
+
* @param commitment The commitment to use
|
|
1494
|
+
*
|
|
1495
|
+
* @returns The SPL interface infos
|
|
1496
|
+
*/
|
|
1497
|
+
declare function getSplInterfaceInfos(rpc: Rpc, mint: PublicKey, commitment?: Commitment): Promise<SplInterfaceInfo[]>;
|
|
1498
|
+
type SplInterfaceActivity = {
|
|
1499
|
+
signature: string;
|
|
1500
|
+
amount: BN;
|
|
1501
|
+
action: Action;
|
|
1502
|
+
};
|
|
84
1503
|
/**
|
|
85
1504
|
* @internal
|
|
86
1505
|
*/
|
|
@@ -91,29 +1510,656 @@ declare enum Action {
|
|
|
91
1510
|
}
|
|
92
1511
|
/**
|
|
93
1512
|
* For `compress` and `mintTo` instructions only.
|
|
94
|
-
* Select a random
|
|
1513
|
+
* Select a random SPL interface info from the SPL interface infos.
|
|
95
1514
|
*
|
|
96
|
-
* For `decompress`, use {@link
|
|
1515
|
+
* For `decompress`, use {@link selectSplInterfaceInfosForDecompression} instead.
|
|
97
1516
|
*
|
|
98
|
-
* @param infos The
|
|
1517
|
+
* @param infos The SPL interface infos
|
|
99
1518
|
*
|
|
100
|
-
* @returns A random
|
|
1519
|
+
* @returns A random SPL interface info
|
|
101
1520
|
*/
|
|
102
|
-
declare function
|
|
1521
|
+
declare function selectSplInterfaceInfo(infos: SplInterfaceInfo[]): SplInterfaceInfo;
|
|
103
1522
|
/**
|
|
104
|
-
* Select one or multiple
|
|
1523
|
+
* Select one or multiple SPL interface infos from the SPL interface infos.
|
|
105
1524
|
*
|
|
106
1525
|
* Use this function for `decompress`.
|
|
107
1526
|
*
|
|
108
|
-
* For `compress`, `mintTo` use {@link
|
|
1527
|
+
* For `compress`, `mintTo` use {@link selectSplInterfaceInfo} instead.
|
|
109
1528
|
*
|
|
110
|
-
* @param infos The
|
|
1529
|
+
* @param infos The SPL interface infos
|
|
111
1530
|
* @param decompressAmount The amount of tokens to withdraw
|
|
112
1531
|
*
|
|
113
|
-
* @returns Array with one or more
|
|
1532
|
+
* @returns Array with one or more SPL interface infos.
|
|
1533
|
+
*/
|
|
1534
|
+
declare function selectSplInterfaceInfosForDecompression(infos: SplInterfaceInfo[], decompressAmount: number | BN): SplInterfaceInfo[];
|
|
1535
|
+
/**
|
|
1536
|
+
* @deprecated Use {@link SplInterfaceActivity} instead.
|
|
1537
|
+
*/
|
|
1538
|
+
type TokenPoolActivity = SplInterfaceActivity;
|
|
1539
|
+
/**
|
|
1540
|
+
* @deprecated Use {@link deriveSplInterfaceInfo} instead.
|
|
1541
|
+
*/
|
|
1542
|
+
declare function deriveTokenPoolInfo(mint: PublicKey, tokenProgramId: PublicKey, poolIndex?: number): TokenPoolInfo;
|
|
1543
|
+
/**
|
|
1544
|
+
* @deprecated Use {@link checkSplInterfaceInfo} instead.
|
|
1545
|
+
*/
|
|
1546
|
+
declare function checkTokenPoolInfo(tokenPoolInfo: TokenPoolInfo, mint: PublicKey): boolean;
|
|
1547
|
+
/**
|
|
1548
|
+
* @deprecated Use {@link getSplInterfaceInfos} instead.
|
|
1549
|
+
*/
|
|
1550
|
+
declare function getTokenPoolInfos(rpc: Rpc, mint: PublicKey, commitment?: Commitment): Promise<TokenPoolInfo[]>;
|
|
1551
|
+
/**
|
|
1552
|
+
* @deprecated Use {@link selectSplInterfaceInfo} instead.
|
|
1553
|
+
*/
|
|
1554
|
+
declare function selectTokenPoolInfo(infos: TokenPoolInfo[]): TokenPoolInfo;
|
|
1555
|
+
/**
|
|
1556
|
+
* @deprecated Use {@link selectSplInterfaceInfosForDecompression} instead.
|
|
114
1557
|
*/
|
|
115
1558
|
declare function selectTokenPoolInfosForDecompression(infos: TokenPoolInfo[], decompressAmount: number | BN): TokenPoolInfo[];
|
|
116
1559
|
|
|
1560
|
+
/**
|
|
1561
|
+
* Create decompressInterface instruction using Transfer2.
|
|
1562
|
+
*
|
|
1563
|
+
* Supports decompressing to both c-token accounts and SPL token accounts:
|
|
1564
|
+
* - For c-token destinations: No splInterfaceInfo needed
|
|
1565
|
+
* - For SPL destinations: Provide splInterfaceInfo (token pool info)
|
|
1566
|
+
*
|
|
1567
|
+
* @param payer Fee payer public key
|
|
1568
|
+
* @param inputCompressedTokenAccounts Input compressed token accounts
|
|
1569
|
+
* @param toAddress Destination token account address (c-token or SPL ATA)
|
|
1570
|
+
* @param amount Amount to decompress
|
|
1571
|
+
* @param validityProof Validity proof (contains compressedProof and rootIndices)
|
|
1572
|
+
* @param splInterfaceInfo Optional: SPL interface info for SPL destinations
|
|
1573
|
+
* @returns TransactionInstruction
|
|
1574
|
+
*/
|
|
1575
|
+
declare function createDecompressInterfaceInstruction(payer: PublicKey, inputCompressedTokenAccounts: ParsedTokenAccount[], toAddress: PublicKey, amount: bigint, validityProof: ValidityProofWithContext, splInterfaceInfo?: SplInterfaceInfo): TransactionInstruction;
|
|
1576
|
+
|
|
1577
|
+
declare const TokenAccountSourceType: {
|
|
1578
|
+
readonly Spl: "spl";
|
|
1579
|
+
readonly Token2022: "token2022";
|
|
1580
|
+
readonly SplCold: "spl-cold";
|
|
1581
|
+
readonly Token2022Cold: "token2022-cold";
|
|
1582
|
+
readonly CTokenHot: "ctoken-hot";
|
|
1583
|
+
readonly CTokenCold: "ctoken-cold";
|
|
1584
|
+
};
|
|
1585
|
+
type TokenAccountSourceTypeValue = (typeof TokenAccountSourceType)[keyof typeof TokenAccountSourceType];
|
|
1586
|
+
/** @internal */
|
|
1587
|
+
interface TokenAccountSource {
|
|
1588
|
+
type: TokenAccountSourceTypeValue;
|
|
1589
|
+
address: PublicKey;
|
|
1590
|
+
amount: bigint;
|
|
1591
|
+
accountInfo: AccountInfo<Buffer$1>;
|
|
1592
|
+
loadContext?: MerkleContext;
|
|
1593
|
+
parsed: Account;
|
|
1594
|
+
}
|
|
1595
|
+
interface AccountInterface {
|
|
1596
|
+
accountInfo: AccountInfo<Buffer$1>;
|
|
1597
|
+
parsed: Account;
|
|
1598
|
+
isCold: boolean;
|
|
1599
|
+
loadContext?: MerkleContext;
|
|
1600
|
+
_sources?: TokenAccountSource[];
|
|
1601
|
+
_needsConsolidation?: boolean;
|
|
1602
|
+
_hasDelegate?: boolean;
|
|
1603
|
+
_anyFrozen?: boolean;
|
|
1604
|
+
/** True when fetched via getAtaInterface */
|
|
1605
|
+
_isAta?: boolean;
|
|
1606
|
+
/** ATA owner - set by getAtaInterface */
|
|
1607
|
+
_owner?: PublicKey;
|
|
1608
|
+
/** ATA mint - set by getAtaInterface */
|
|
1609
|
+
_mint?: PublicKey;
|
|
1610
|
+
}
|
|
1611
|
+
/** @internal */
|
|
1612
|
+
declare function convertTokenDataToAccount(address: PublicKey, tokenData: {
|
|
1613
|
+
mint: PublicKey;
|
|
1614
|
+
owner: PublicKey;
|
|
1615
|
+
amount: BN;
|
|
1616
|
+
delegate: PublicKey | null;
|
|
1617
|
+
state: number;
|
|
1618
|
+
tlv: Buffer$1 | null;
|
|
1619
|
+
}): Account;
|
|
1620
|
+
/** Convert compressed account to AccountInfo */
|
|
1621
|
+
declare function toAccountInfo(compressedAccount: CompressedAccountWithMerkleContext): AccountInfo<Buffer$1>;
|
|
1622
|
+
/** @internal */
|
|
1623
|
+
declare function parseCTokenHot(address: PublicKey, accountInfo: AccountInfo<Buffer$1>): {
|
|
1624
|
+
accountInfo: AccountInfo<Buffer$1>;
|
|
1625
|
+
loadContext: undefined;
|
|
1626
|
+
parsed: Account;
|
|
1627
|
+
isCold: false;
|
|
1628
|
+
};
|
|
1629
|
+
/** @internal */
|
|
1630
|
+
declare function parseCTokenCold(address: PublicKey, compressedAccount: CompressedAccountWithMerkleContext): {
|
|
1631
|
+
accountInfo: AccountInfo<Buffer$1>;
|
|
1632
|
+
loadContext: MerkleContext;
|
|
1633
|
+
parsed: Account;
|
|
1634
|
+
isCold: true;
|
|
1635
|
+
};
|
|
1636
|
+
/**
|
|
1637
|
+
* Retrieve information about a token account of SPL/T22/c-token.
|
|
1638
|
+
*
|
|
1639
|
+
* @param rpc RPC connection to use
|
|
1640
|
+
* @param address Token account address
|
|
1641
|
+
* @param commitment Desired level of commitment for querying the state
|
|
1642
|
+
* @param programId Token program ID. If not provided, tries all programs concurrently.
|
|
1643
|
+
*
|
|
1644
|
+
* @return Token account information with compression context if applicable
|
|
1645
|
+
*/
|
|
1646
|
+
declare function getAccountInterface(rpc: Rpc, address: PublicKey, commitment?: Commitment, programId?: PublicKey): Promise<AccountInterface>;
|
|
1647
|
+
|
|
1648
|
+
/**
|
|
1649
|
+
* Options for interface operations (load, transfer)
|
|
1650
|
+
*/
|
|
1651
|
+
interface InterfaceOptions {
|
|
1652
|
+
/** SPL interface infos (fetched if not provided) */
|
|
1653
|
+
splInterfaceInfos?: SplInterfaceInfo[];
|
|
1654
|
+
}
|
|
1655
|
+
/**
|
|
1656
|
+
* Transfer tokens using the c-token interface.
|
|
1657
|
+
*
|
|
1658
|
+
* Matches SPL Token's transferChecked signature order. Destination must exist.
|
|
1659
|
+
*
|
|
1660
|
+
* @param rpc RPC connection
|
|
1661
|
+
* @param payer Fee payer (signer)
|
|
1662
|
+
* @param source Source c-token ATA address
|
|
1663
|
+
* @param mint Mint address
|
|
1664
|
+
* @param destination Destination c-token ATA address (must exist)
|
|
1665
|
+
* @param owner Source owner (signer)
|
|
1666
|
+
* @param amount Amount to transfer
|
|
1667
|
+
* @param programId Token program ID (default: CTOKEN_PROGRAM_ID)
|
|
1668
|
+
* @param confirmOptions Optional confirm options
|
|
1669
|
+
* @param options Optional interface options
|
|
1670
|
+
* @param wrap Include SPL/T22 wrapping (default: false)
|
|
1671
|
+
* @returns Transaction signature
|
|
1672
|
+
*/
|
|
1673
|
+
declare function transferInterface(rpc: Rpc, payer: Signer, source: PublicKey, mint: PublicKey, destination: PublicKey, owner: Signer, amount: number | bigint | BN, programId?: PublicKey, confirmOptions?: ConfirmOptions, options?: InterfaceOptions, wrap?: boolean): Promise<TransactionSignature>;
|
|
1674
|
+
|
|
1675
|
+
/**
|
|
1676
|
+
* Account info interface for compressible accounts.
|
|
1677
|
+
* Matches return structure of getAccountInterface/getAtaInterface.
|
|
1678
|
+
*
|
|
1679
|
+
* Integrating programs provide their own fetch/parse - this is just the data shape.
|
|
1680
|
+
*/
|
|
1681
|
+
interface ParsedAccountInfoInterface<T = unknown> {
|
|
1682
|
+
/** Parsed account data (program-specific) */
|
|
1683
|
+
parsed: T;
|
|
1684
|
+
/** Load context - present if account is compressed (cold), undefined if hot */
|
|
1685
|
+
loadContext?: MerkleContext;
|
|
1686
|
+
}
|
|
1687
|
+
/**
|
|
1688
|
+
* Input for createLoadAccountsParams.
|
|
1689
|
+
* Supports both program PDAs and c-token vaults.
|
|
1690
|
+
*
|
|
1691
|
+
* The integrating program is responsible for fetching and parsing their accounts.
|
|
1692
|
+
* This helper just packs them for the decompressAccountsIdempotent instruction.
|
|
1693
|
+
*/
|
|
1694
|
+
interface CompressibleAccountInput<T = unknown> {
|
|
1695
|
+
/** Account address */
|
|
1696
|
+
address: PublicKey;
|
|
1697
|
+
/**
|
|
1698
|
+
* Account type key for packing:
|
|
1699
|
+
* - For PDAs: program-specific type name (e.g., "poolState", "observationState")
|
|
1700
|
+
* - For c-token vaults: "cTokenData"
|
|
1701
|
+
*/
|
|
1702
|
+
accountType: string;
|
|
1703
|
+
/**
|
|
1704
|
+
* Token variant - required when accountType is "cTokenData".
|
|
1705
|
+
* Examples: "lpVault", "token0Vault", "token1Vault"
|
|
1706
|
+
*/
|
|
1707
|
+
tokenVariant?: string;
|
|
1708
|
+
/** Parsed account info (from program-specific fetch) */
|
|
1709
|
+
info: ParsedAccountInfoInterface<T>;
|
|
1710
|
+
}
|
|
1711
|
+
/**
|
|
1712
|
+
* Packed compressed account for decompressAccountsIdempotent instruction
|
|
1713
|
+
*/
|
|
1714
|
+
interface PackedCompressedAccount {
|
|
1715
|
+
[key: string]: unknown;
|
|
1716
|
+
merkleContext: {
|
|
1717
|
+
merkleTreePubkeyIndex: number;
|
|
1718
|
+
queuePubkeyIndex: number;
|
|
1719
|
+
};
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Result from building load params
|
|
1723
|
+
*/
|
|
1724
|
+
interface CompressibleLoadParams {
|
|
1725
|
+
/** Validity proof wrapped in option (null if all proveByIndex) */
|
|
1726
|
+
proofOption: {
|
|
1727
|
+
0: ValidityProof | null;
|
|
1728
|
+
};
|
|
1729
|
+
/** Packed compressed accounts data for instruction */
|
|
1730
|
+
compressedAccounts: PackedCompressedAccount[];
|
|
1731
|
+
/** Offset to system accounts in remainingAccounts */
|
|
1732
|
+
systemAccountsOffset: number;
|
|
1733
|
+
/** Account metas for remaining accounts */
|
|
1734
|
+
remainingAccounts: AccountMeta[];
|
|
1735
|
+
}
|
|
1736
|
+
/**
|
|
1737
|
+
* Result from createLoadAccountsParams
|
|
1738
|
+
*/
|
|
1739
|
+
interface LoadResult {
|
|
1740
|
+
/** Params for decompressAccountsIdempotent (null if no program accounts need decompressing) */
|
|
1741
|
+
decompressParams: CompressibleLoadParams | null;
|
|
1742
|
+
/** Instructions to load ATAs (create ATA, wrap SPL/T22, decompressInterface) */
|
|
1743
|
+
ataInstructions: TransactionInstruction[];
|
|
1744
|
+
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Create params for loading program accounts and ATAs.
|
|
1747
|
+
*
|
|
1748
|
+
* Returns:
|
|
1749
|
+
* - decompressParams: for a caller program's standardized
|
|
1750
|
+
* decompressAccountsIdempotent instruction
|
|
1751
|
+
* - ataInstructions: for loading user ATAs
|
|
1752
|
+
*
|
|
1753
|
+
* @param rpc RPC connection
|
|
1754
|
+
* @param payer Fee payer (needed for ATA instructions)
|
|
1755
|
+
* @param programId Program ID for decompressAccountsIdempotent
|
|
1756
|
+
* @param programAccounts PDAs and vaults (caller pre-fetches)
|
|
1757
|
+
* @param atas User ATAs (fetched via getAtaInterface)
|
|
1758
|
+
* @param options Optional load options
|
|
1759
|
+
* @returns LoadResult with decompressParams and ataInstructions
|
|
1760
|
+
*
|
|
1761
|
+
* @example
|
|
1762
|
+
* ```typescript
|
|
1763
|
+
* const poolInfo = await myProgram.fetchPoolState(rpc, poolAddress);
|
|
1764
|
+
* const vault0Ata = getAssociatedTokenAddressInterface(token0Mint, poolAddress);
|
|
1765
|
+
* const vault0Info = await getAtaInterface(rpc, vault0Ata, poolAddress, token0Mint, undefined, CTOKEN_PROGRAM_ID);
|
|
1766
|
+
* const userAta = getAssociatedTokenAddressInterface(tokenMint, userWallet);
|
|
1767
|
+
* const userAtaInfo = await getAtaInterface(rpc, userAta, userWallet, tokenMint);
|
|
1768
|
+
*
|
|
1769
|
+
* const result = await createLoadAccountsParams(
|
|
1770
|
+
* rpc,
|
|
1771
|
+
* payer.publicKey,
|
|
1772
|
+
* programId,
|
|
1773
|
+
* [
|
|
1774
|
+
* { address: poolAddress, accountType: 'poolState', info: poolInfo },
|
|
1775
|
+
* { address: vault0, accountType: 'cTokenData', tokenVariant: 'token0Vault', info: vault0Info },
|
|
1776
|
+
* ],
|
|
1777
|
+
* [userAta],
|
|
1778
|
+
* );
|
|
1779
|
+
*
|
|
1780
|
+
* // Build transaction with both program decompress and ATA load
|
|
1781
|
+
* const instructions = [...result.ataInstructions];
|
|
1782
|
+
* if (result.decompressParams) {
|
|
1783
|
+
* instructions.push(await program.methods
|
|
1784
|
+
* .decompressAccountsIdempotent(
|
|
1785
|
+
* result.decompressParams.proofOption,
|
|
1786
|
+
* result.decompressParams.compressedAccounts,
|
|
1787
|
+
* result.decompressParams.systemAccountsOffset,
|
|
1788
|
+
* )
|
|
1789
|
+
* .remainingAccounts(result.decompressParams.remainingAccounts)
|
|
1790
|
+
* .instruction());
|
|
1791
|
+
* }
|
|
1792
|
+
* ```
|
|
1793
|
+
*/
|
|
1794
|
+
declare function createLoadAccountsParams(rpc: Rpc, payer: PublicKey, programId: PublicKey, programAccounts?: CompressibleAccountInput[], atas?: AccountInterface[], options?: InterfaceOptions): Promise<LoadResult>;
|
|
1795
|
+
/**
|
|
1796
|
+
* Calculate compute units for compressible load operation
|
|
1797
|
+
*/
|
|
1798
|
+
declare function calculateCompressibleLoadComputeUnits(compressedAccountCount: number, hasValidityProof: boolean): number;
|
|
1799
|
+
|
|
1800
|
+
/**
|
|
1801
|
+
* Create a wrap instruction that moves tokens from an SPL/T22 account to a
|
|
1802
|
+
* c-token account.
|
|
1803
|
+
*
|
|
1804
|
+
* @param source Source SPL/T22 token account
|
|
1805
|
+
* @param destination Destination c-token account
|
|
1806
|
+
* @param owner Owner of the source account (signer)
|
|
1807
|
+
* @param mint Mint address
|
|
1808
|
+
* @param amount Amount to wrap,
|
|
1809
|
+
* @param splInterfaceInfo SPL interface info for the compression
|
|
1810
|
+
* @param payer Fee payer (defaults to owner)
|
|
1811
|
+
* @returns Instruction to wrap tokens
|
|
1812
|
+
*/
|
|
1813
|
+
declare function createWrapInstruction(source: PublicKey, destination: PublicKey, owner: PublicKey, mint: PublicKey, amount: bigint, splInterfaceInfo: SplInterfaceInfo, payer?: PublicKey): TransactionInstruction;
|
|
1814
|
+
|
|
1815
|
+
/**
|
|
1816
|
+
* Create and initialize a new mint for SPL/T22/c-token.
|
|
1817
|
+
*
|
|
1818
|
+
* @param rpc RPC connection to use
|
|
1819
|
+
* @param payer Fee payer
|
|
1820
|
+
* @param mintAuthority Account that will control minting (signer for c-token mints)
|
|
1821
|
+
* @param freezeAuthority Account that will control freeze and thaw (optional)
|
|
1822
|
+
* @param decimals Location of the decimal place
|
|
1823
|
+
* @param keypair Mint keypair (defaults to a random keypair)
|
|
1824
|
+
* @param confirmOptions Confirm options
|
|
1825
|
+
* @param programId Token program ID (defaults to CTOKEN_PROGRAM_ID)
|
|
1826
|
+
* @param tokenMetadata Optional token metadata (c-token mints only)
|
|
1827
|
+
* @param outputStateTreeInfo Optional output state tree info (c-token mints only)
|
|
1828
|
+
* @param addressTreeInfo Optional address tree info (c-token mints only)
|
|
1829
|
+
*
|
|
1830
|
+
* @returns Object with mint address and transaction signature
|
|
1831
|
+
*/
|
|
1832
|
+
declare function createMintInterface(rpc: Rpc, payer: Signer, mintAuthority: PublicKey | Signer, freezeAuthority: PublicKey | Signer | null, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions, programId?: PublicKey, tokenMetadata?: TokenMetadataInstructionData, outputStateTreeInfo?: TreeInfo, addressTreeInfo?: AddressTreeInfo): Promise<{
|
|
1833
|
+
mint: PublicKey;
|
|
1834
|
+
transactionSignature: TransactionSignature;
|
|
1835
|
+
}>;
|
|
1836
|
+
|
|
1837
|
+
/**
|
|
1838
|
+
* Update the mint authority of a compressed token mint.
|
|
1839
|
+
*
|
|
1840
|
+
* @param rpc RPC connection
|
|
1841
|
+
* @param payer Fee payer (signer)
|
|
1842
|
+
* @param mint Mint address
|
|
1843
|
+
* @param currentMintAuthority Current mint authority (signer)
|
|
1844
|
+
* @param newMintAuthority New mint authority (or null to revoke)
|
|
1845
|
+
* @param confirmOptions Optional confirm options
|
|
1846
|
+
*/
|
|
1847
|
+
declare function updateMintAuthority(rpc: Rpc, payer: Signer, mint: PublicKey, currentMintAuthority: Signer, newMintAuthority: PublicKey | null, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1848
|
+
/**
|
|
1849
|
+
* Update the freeze authority of a compressed token mint.
|
|
1850
|
+
*
|
|
1851
|
+
* @param rpc RPC connection
|
|
1852
|
+
* @param payer Fee payer (signer)
|
|
1853
|
+
* @param mint Mint address
|
|
1854
|
+
* @param currentFreezeAuthority Current freeze authority (signer)
|
|
1855
|
+
* @param newFreezeAuthority New freeze authority (or null to revoke)
|
|
1856
|
+
* @param confirmOptions Optional confirm options
|
|
1857
|
+
*/
|
|
1858
|
+
declare function updateFreezeAuthority(rpc: Rpc, payer: Signer, mint: PublicKey, currentFreezeAuthority: Signer, newFreezeAuthority: PublicKey | null, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1859
|
+
|
|
1860
|
+
/**
|
|
1861
|
+
* Update a metadata field on a compressed token mint.
|
|
1862
|
+
*
|
|
1863
|
+
* @param rpc RPC connection
|
|
1864
|
+
* @param payer Fee payer (signer)
|
|
1865
|
+
* @param mint Mint address
|
|
1866
|
+
* @param authority Metadata update authority (signer)
|
|
1867
|
+
* @param fieldType Field to update: 'name', 'symbol', 'uri', or 'custom'
|
|
1868
|
+
* @param value New value for the field
|
|
1869
|
+
* @param customKey Custom key name (required if fieldType is 'custom')
|
|
1870
|
+
* @param extensionIndex Extension index (default: 0)
|
|
1871
|
+
* @param confirmOptions Optional confirm options
|
|
1872
|
+
*/
|
|
1873
|
+
declare function updateMetadataField(rpc: Rpc, payer: Signer, mint: PublicKey, authority: Signer, fieldType: 'name' | 'symbol' | 'uri' | 'custom', value: string, customKey?: string, extensionIndex?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1874
|
+
/**
|
|
1875
|
+
* Update the metadata authority of a compressed token mint.
|
|
1876
|
+
*
|
|
1877
|
+
* @param rpc RPC connection
|
|
1878
|
+
* @param payer Fee payer (signer)
|
|
1879
|
+
* @param mint Mint address
|
|
1880
|
+
* @param currentAuthority Current metadata update authority (signer)
|
|
1881
|
+
* @param newAuthority New metadata update authority
|
|
1882
|
+
* @param extensionIndex Extension index (default: 0)
|
|
1883
|
+
* @param confirmOptions Optional confirm options
|
|
1884
|
+
*/
|
|
1885
|
+
declare function updateMetadataAuthority(rpc: Rpc, payer: Signer, mint: PublicKey, currentAuthority: Signer, newAuthority: PublicKey, extensionIndex?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1886
|
+
/**
|
|
1887
|
+
* Remove a metadata key from a compressed token mint.
|
|
1888
|
+
*
|
|
1889
|
+
* @param rpc RPC connection
|
|
1890
|
+
* @param payer Fee payer (signer)
|
|
1891
|
+
* @param mint Mint address
|
|
1892
|
+
* @param authority Metadata update authority (signer)
|
|
1893
|
+
* @param key Metadata key to remove
|
|
1894
|
+
* @param idempotent If true, don't error if key doesn't exist (default: false)
|
|
1895
|
+
* @param extensionIndex Extension index (default: 0)
|
|
1896
|
+
* @param confirmOptions Optional confirm options
|
|
1897
|
+
*/
|
|
1898
|
+
declare function removeMetadataKey(rpc: Rpc, payer: Signer, mint: PublicKey, authority: Signer, key: string, idempotent?: boolean, extensionIndex?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1899
|
+
|
|
1900
|
+
/**
|
|
1901
|
+
* Create an associated token account for SPL/T22/c-token. Defaults to c-token
|
|
1902
|
+
* program.
|
|
1903
|
+
*
|
|
1904
|
+
* @param rpc RPC connection
|
|
1905
|
+
* @param payer Fee payer and transaction signer
|
|
1906
|
+
* @param mint Mint address
|
|
1907
|
+
* @param owner Owner of the associated token account
|
|
1908
|
+
* @param allowOwnerOffCurve Allow owner to be a PDA (default: false)
|
|
1909
|
+
* @param confirmOptions Options for confirming the transaction
|
|
1910
|
+
* @param programId Token program ID (default:
|
|
1911
|
+
* CTOKEN_PROGRAM_ID)
|
|
1912
|
+
* @param associatedTokenProgramId ATA program ID (auto-derived if not
|
|
1913
|
+
* provided)
|
|
1914
|
+
* @param ctokenConfig Optional rent config
|
|
1915
|
+
* @returns Address of the new associated token account
|
|
1916
|
+
*/
|
|
1917
|
+
declare function createAtaInterface(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey, ctokenConfig?: CTokenConfig): Promise<PublicKey>;
|
|
1918
|
+
/**
|
|
1919
|
+
* Create an associated token account idempotently for SPL/T22/c-token. Defaults
|
|
1920
|
+
* to c-token program.
|
|
1921
|
+
*
|
|
1922
|
+
* If the account already exists, the instruction succeeds without error.
|
|
1923
|
+
*
|
|
1924
|
+
* @param rpc RPC connection
|
|
1925
|
+
* @param payer Fee payer and transaction signer
|
|
1926
|
+
* @param mint Mint address
|
|
1927
|
+
* @param owner Owner of the associated token account
|
|
1928
|
+
* @param allowOwnerOffCurve Allow owner to be a PDA (default: false)
|
|
1929
|
+
* @param confirmOptions Options for confirming the transaction
|
|
1930
|
+
* @param programId Token program ID (default:
|
|
1931
|
+
* CTOKEN_PROGRAM_ID)
|
|
1932
|
+
* @param associatedTokenProgramId ATA program ID (auto-derived if not
|
|
1933
|
+
* provided)
|
|
1934
|
+
* @param ctokenConfig Optional c-token-specific configuration
|
|
1935
|
+
*
|
|
1936
|
+
* @returns Address of the associated token account
|
|
1937
|
+
*/
|
|
1938
|
+
declare function createAtaInterfaceIdempotent(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey, ctokenConfig?: CTokenConfig): Promise<PublicKey>;
|
|
1939
|
+
|
|
1940
|
+
declare function mintTo$1(rpc: Rpc, payer: Signer, mint: PublicKey, recipientAccount: PublicKey, authority: Signer, amount: number | bigint, outputQueue?: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1941
|
+
|
|
1942
|
+
/**
|
|
1943
|
+
* Mint compressed tokens directly to compressed accounts.
|
|
1944
|
+
*
|
|
1945
|
+
* @param rpc RPC connection
|
|
1946
|
+
* @param payer Fee payer
|
|
1947
|
+
* @param mint Mint address
|
|
1948
|
+
* @param authority Mint authority (must sign)
|
|
1949
|
+
* @param recipients Array of recipients with amounts
|
|
1950
|
+
* @param outputStateTreeInfo Optional output state tree info (auto-fetched if not provided)
|
|
1951
|
+
* @param tokenAccountVersion Token account version (default: 3)
|
|
1952
|
+
* @param confirmOptions Optional confirm options
|
|
1953
|
+
*/
|
|
1954
|
+
declare function mintToCompressed(rpc: Rpc, payer: Signer, mint: PublicKey, authority: Signer, recipients: Array<{
|
|
1955
|
+
recipient: PublicKey;
|
|
1956
|
+
amount: number | bigint;
|
|
1957
|
+
}>, outputStateTreeInfo?: TreeInfo, tokenAccountVersion?: number, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
1958
|
+
|
|
1959
|
+
/**
|
|
1960
|
+
* Mint tokens to a decompressed/onchain token account.
|
|
1961
|
+
* Works with SPL, Token-2022, and compressed token (c-token) mints.
|
|
1962
|
+
*
|
|
1963
|
+
* This function ONLY mints to decompressed onchain token accounts, never to compressed accounts.
|
|
1964
|
+
* The signature matches the standard SPL mintTo for simplicity and consistency.
|
|
1965
|
+
*
|
|
1966
|
+
* @param rpc - RPC connection to use
|
|
1967
|
+
* @param payer - Transaction fee payer
|
|
1968
|
+
* @param mint - Mint address (SPL, Token-2022, or compressed mint)
|
|
1969
|
+
* @param destination - Destination token account address (must be an existing onchain token account)
|
|
1970
|
+
* @param authority - Mint authority (can be Signer or PublicKey if multiSigners provided)
|
|
1971
|
+
* @param amount - Amount to mint
|
|
1972
|
+
* @param multiSigners - Optional: Multi-signature signers (default: [])
|
|
1973
|
+
* @param confirmOptions - Optional: Transaction confirmation options
|
|
1974
|
+
* @param programId - Optional: Token program ID (TOKEN_PROGRAM_ID, TOKEN_2022_PROGRAM_ID, or CTOKEN_PROGRAM_ID). If undefined, auto-detects.
|
|
1975
|
+
*
|
|
1976
|
+
* @returns Transaction signature
|
|
1977
|
+
*/
|
|
1978
|
+
declare function mintToInterface(rpc: Rpc, payer: Signer, mint: PublicKey, destination: PublicKey, authority: Signer | PublicKey, amount: number | bigint, multiSigners?: Signer[], confirmOptions?: ConfirmOptions, programId?: PublicKey): Promise<TransactionSignature>;
|
|
1979
|
+
|
|
1980
|
+
/**
|
|
1981
|
+
* Retrieve the associated token account, or create it if it doesn't exist.
|
|
1982
|
+
*
|
|
1983
|
+
* @param rpc Connection to use
|
|
1984
|
+
* @param payer Payer of the transaction and initialization
|
|
1985
|
+
* fees.
|
|
1986
|
+
* @param mint Mint associated with the account to set or
|
|
1987
|
+
* verify.
|
|
1988
|
+
* @param owner Owner of the account. Pass Signer to
|
|
1989
|
+
* auto-load cold (compressed) tokens, or
|
|
1990
|
+
* PublicKey for read-only.
|
|
1991
|
+
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program
|
|
1992
|
+
* Derived Address).
|
|
1993
|
+
* @param commitment Desired level of commitment for querying the
|
|
1994
|
+
* state.
|
|
1995
|
+
* @param confirmOptions Options for confirming the transaction
|
|
1996
|
+
* @param programId Token program ID (defaults to
|
|
1997
|
+
* CTOKEN_PROGRAM_ID)
|
|
1998
|
+
* @param associatedTokenProgramId Associated token program ID (auto-derived if
|
|
1999
|
+
* not provided)
|
|
2000
|
+
*
|
|
2001
|
+
* @returns AccountInterface with aggregated balance and source breakdown
|
|
2002
|
+
*/
|
|
2003
|
+
declare function getOrCreateAtaInterface(rpc: Rpc, payer: Signer, mint: PublicKey, owner: PublicKey | Signer, allowOwnerOffCurve?: boolean, commitment?: Commitment, confirmOptions?: ConfirmOptions, programId?: PublicKey, associatedTokenProgramId?: PublicKey): Promise<AccountInterface>;
|
|
2004
|
+
|
|
2005
|
+
/**
|
|
2006
|
+
* Decompress compressed (cold) tokens to an on-chain token account.
|
|
2007
|
+
*
|
|
2008
|
+
* For unified loading, use {@link loadAta} instead.
|
|
2009
|
+
*
|
|
2010
|
+
* @param rpc RPC connection
|
|
2011
|
+
* @param payer Fee payer (signer)
|
|
2012
|
+
* @param owner Owner of the compressed tokens (signer)
|
|
2013
|
+
* @param mint Mint address
|
|
2014
|
+
* @param amount Amount to decompress (defaults to all)
|
|
2015
|
+
* @param destinationAta Destination token account address
|
|
2016
|
+
* @param destinationOwner Owner of the destination ATA
|
|
2017
|
+
* @param splInterfaceInfo SPL interface info for SPL/T22 destinations
|
|
2018
|
+
* @param confirmOptions Confirm options
|
|
2019
|
+
* @returns Transaction signature, null if nothing to load.
|
|
2020
|
+
*/
|
|
2021
|
+
declare function decompressInterface(rpc: Rpc, payer: Signer, owner: Signer, mint: PublicKey, amount?: number | bigint | BN, destinationAta?: PublicKey, destinationOwner?: PublicKey, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature | null>;
|
|
2022
|
+
|
|
2023
|
+
/**
|
|
2024
|
+
* Wrap tokens from an SPL/T22 account to a c-token account.
|
|
2025
|
+
*
|
|
2026
|
+
* This is an agnostic action that takes explicit account addresses (spl-token style).
|
|
2027
|
+
* Use getAssociatedTokenAddressSync() to derive ATA addresses if needed.
|
|
2028
|
+
*
|
|
2029
|
+
* @param rpc RPC connection
|
|
2030
|
+
* @param payer Fee payer
|
|
2031
|
+
* @param source Source SPL/T22 token account (any token account, not just ATA)
|
|
2032
|
+
* @param destination Destination c-token account
|
|
2033
|
+
* @param owner Owner/authority of the source account (must sign)
|
|
2034
|
+
* @param mint Mint address
|
|
2035
|
+
* @param amount Amount to wrap
|
|
2036
|
+
* @param splInterfaceInfo Optional: SPL interface info (will be fetched if not provided)
|
|
2037
|
+
* @param confirmOptions Optional: Confirm options
|
|
2038
|
+
*
|
|
2039
|
+
* @example
|
|
2040
|
+
* const splAta = getAssociatedTokenAddressSync(mint, owner.publicKey, false, TOKEN_PROGRAM_ID);
|
|
2041
|
+
* const ctokenAta = getAssociatedTokenAddressInterface(mint, owner.publicKey); // defaults to c-token
|
|
2042
|
+
*
|
|
2043
|
+
* await wrap(
|
|
2044
|
+
* rpc,
|
|
2045
|
+
* payer,
|
|
2046
|
+
* splAta,
|
|
2047
|
+
* ctokenAta,
|
|
2048
|
+
* owner,
|
|
2049
|
+
* mint,
|
|
2050
|
+
* 1000n,
|
|
2051
|
+
* );
|
|
2052
|
+
*
|
|
2053
|
+
* @returns Transaction signature
|
|
2054
|
+
*/
|
|
2055
|
+
declare function wrap(rpc: Rpc, payer: Signer, source: PublicKey, destination: PublicKey, owner: Signer, mint: PublicKey, amount: bigint, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2056
|
+
|
|
2057
|
+
/**
|
|
2058
|
+
* Create instructions to load an ATA from its AccountInterface.
|
|
2059
|
+
*
|
|
2060
|
+
* Behavior depends on `wrap` parameter:
|
|
2061
|
+
* - wrap=false (standard): Decompress compressed tokens to the target ATA type
|
|
2062
|
+
* (SPL ATA via pool, T22 ATA via pool, or c-token ATA direct)
|
|
2063
|
+
* - wrap=true (unified): Wrap SPL/T22 + decompress all to c-token ATA
|
|
2064
|
+
*
|
|
2065
|
+
* @param rpc RPC connection
|
|
2066
|
+
* @param payer Fee payer
|
|
2067
|
+
* @param ata AccountInterface from getAtaInterface (must have _isAta, _owner, _mint)
|
|
2068
|
+
* @param options Optional load options
|
|
2069
|
+
* @param wrap Unified mode: wrap SPL/T22 to c-token (default: false)
|
|
2070
|
+
* @param targetAta Target ATA address (used for type detection in standard mode)
|
|
2071
|
+
* @returns Array of instructions (empty if nothing to load)
|
|
2072
|
+
*/
|
|
2073
|
+
declare function createLoadAtaInstructionsFromInterface(rpc: Rpc, payer: PublicKey, ata: AccountInterface, options?: InterfaceOptions, wrap?: boolean, targetAta?: PublicKey): Promise<TransactionInstruction[]>;
|
|
2074
|
+
|
|
2075
|
+
/**
|
|
2076
|
+
* Derive the canonical associated token address for any of SPL/T22/c-token.
|
|
2077
|
+
* Defaults to using c-token as the canonical ATA.
|
|
2078
|
+
*
|
|
2079
|
+
* @param mint Mint public key
|
|
2080
|
+
* @param owner Owner public key
|
|
2081
|
+
* @param allowOwnerOffCurve Allow owner to be a PDA. Default false.
|
|
2082
|
+
* @param programId Token program ID. Default c-token.
|
|
2083
|
+
*
|
|
2084
|
+
* @param associatedTokenProgramId Associated token program ID. Default
|
|
2085
|
+
* auto-detected.
|
|
2086
|
+
* @returns Associated token address.
|
|
2087
|
+
*/
|
|
2088
|
+
declare function getAssociatedTokenAddressInterface(mint: PublicKey, owner: PublicKey, allowOwnerOffCurve?: boolean, programId?: PublicKey, associatedTokenProgramId?: PublicKey): PublicKey;
|
|
2089
|
+
|
|
2090
|
+
/**
|
|
2091
|
+
* Input for creating off-chain metadata JSON.
|
|
2092
|
+
* Compatible with Token-2022 and Metaplex standards.
|
|
2093
|
+
*/
|
|
2094
|
+
interface OffChainTokenMetadata {
|
|
2095
|
+
/** Token name */
|
|
2096
|
+
name: string;
|
|
2097
|
+
/** Token symbol */
|
|
2098
|
+
symbol: string;
|
|
2099
|
+
/** Optional description */
|
|
2100
|
+
description?: string;
|
|
2101
|
+
/** Optional image URI */
|
|
2102
|
+
image?: string;
|
|
2103
|
+
/** Optional additional metadata key-value pairs */
|
|
2104
|
+
additionalMetadata?: Array<{
|
|
2105
|
+
key: string;
|
|
2106
|
+
value: string;
|
|
2107
|
+
}>;
|
|
2108
|
+
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Off-chain JSON format for token metadata.
|
|
2111
|
+
* Standard format compatible with Token-2022 and Metaplex tooling.
|
|
2112
|
+
*/
|
|
2113
|
+
interface OffChainTokenMetadataJson {
|
|
2114
|
+
name: string;
|
|
2115
|
+
symbol: string;
|
|
2116
|
+
description?: string;
|
|
2117
|
+
image?: string;
|
|
2118
|
+
additionalMetadata?: Array<{
|
|
2119
|
+
key: string;
|
|
2120
|
+
value: string;
|
|
2121
|
+
}>;
|
|
2122
|
+
}
|
|
2123
|
+
/**
|
|
2124
|
+
* Format metadata for off-chain storage.
|
|
2125
|
+
*
|
|
2126
|
+
* Returns a plain object ready to be uploaded using any storage provider
|
|
2127
|
+
* (umi uploader, custom IPFS/Arweave/S3 solution, etc.).
|
|
2128
|
+
*
|
|
2129
|
+
* @example
|
|
2130
|
+
* // With umi uploader
|
|
2131
|
+
* import { toOffChainMetadataJson } from '@lightprotocol/compressed-token';
|
|
2132
|
+
* import { irysUploader } from '@metaplex-foundation/umi-uploader-irys';
|
|
2133
|
+
*
|
|
2134
|
+
* const umi = createUmi(connection).use(irysUploader());
|
|
2135
|
+
* const metadataJson = toOffChainMetadataJson({
|
|
2136
|
+
* name: 'My Token',
|
|
2137
|
+
* symbol: 'MTK',
|
|
2138
|
+
* description: 'A compressed token',
|
|
2139
|
+
* image: 'https://example.com/image.png',
|
|
2140
|
+
* });
|
|
2141
|
+
* const uri = await umi.uploader.uploadJson(metadataJson);
|
|
2142
|
+
*
|
|
2143
|
+
* // Then use uri with createMint
|
|
2144
|
+
* await createMint(rpc, payer, { ...params, uri });
|
|
2145
|
+
*/
|
|
2146
|
+
declare function toOffChainMetadataJson(meta: OffChainTokenMetadata): OffChainTokenMetadataJson;
|
|
2147
|
+
|
|
2148
|
+
/**
|
|
2149
|
+
* Approve a delegate to spend tokens
|
|
2150
|
+
*
|
|
2151
|
+
* @param rpc Rpc to use
|
|
2152
|
+
* @param payer Fee payer
|
|
2153
|
+
* @param mint SPL Mint address
|
|
2154
|
+
* @param amount Number of tokens to delegate
|
|
2155
|
+
* @param owner Owner of the SPL token account.
|
|
2156
|
+
* @param delegate Address of the delegate
|
|
2157
|
+
* @param confirmOptions Options for confirming the transaction
|
|
2158
|
+
*
|
|
2159
|
+
* @return Signature of the confirmed transaction
|
|
2160
|
+
*/
|
|
2161
|
+
declare function approve(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, delegate: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
2162
|
+
|
|
117
2163
|
/**
|
|
118
2164
|
* Mint compressed tokens to a solana address from an external mint authority
|
|
119
2165
|
*
|
|
@@ -126,12 +2172,12 @@ declare function selectTokenPoolInfosForDecompression(infos: TokenPoolInfo[], de
|
|
|
126
2172
|
* @param outputStateTreeInfo Optional: State tree account that the compressed
|
|
127
2173
|
* tokens should be inserted into. Defaults to a
|
|
128
2174
|
* shared state tree account.
|
|
129
|
-
* @param
|
|
2175
|
+
* @param splInterfaceInfo Optional: SPL interface info.
|
|
130
2176
|
* @param confirmOptions Options for confirming the transaction
|
|
131
2177
|
*
|
|
132
2178
|
* @return Signature of the confirmed transaction
|
|
133
2179
|
*/
|
|
134
|
-
declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey, authority: Signer, amount: number | BN, outputStateTreeInfo?: TreeInfo,
|
|
2180
|
+
declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey, authority: Signer, amount: number | BN, outputStateTreeInfo?: TreeInfo, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
135
2181
|
|
|
136
2182
|
/**
|
|
137
2183
|
* Compress SPL tokens
|
|
@@ -146,12 +2192,12 @@ declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPu
|
|
|
146
2192
|
* @param outputStateTreeInfo Optional: State tree account that the compressed
|
|
147
2193
|
* tokens should be inserted into. Defaults to a
|
|
148
2194
|
* shared state tree account.
|
|
149
|
-
* @param
|
|
2195
|
+
* @param splInterfaceInfo Optional: SPL interface info.
|
|
150
2196
|
* @param confirmOptions Options for confirming the transaction
|
|
151
2197
|
*
|
|
152
2198
|
* @return Signature of the confirmed transaction
|
|
153
2199
|
*/
|
|
154
|
-
declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN | number[] | BN[], owner: Signer, sourceTokenAccount: PublicKey, toAddress: PublicKey | Array<PublicKey>, outputStateTreeInfo?: TreeInfo,
|
|
2200
|
+
declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN | number[] | BN[], owner: Signer, sourceTokenAccount: PublicKey, toAddress: PublicKey | Array<PublicKey>, outputStateTreeInfo?: TreeInfo, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
155
2201
|
|
|
156
2202
|
/**
|
|
157
2203
|
* Compress SPL tokens into compressed token format
|
|
@@ -165,16 +2211,18 @@ declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: numb
|
|
|
165
2211
|
* Default: 0
|
|
166
2212
|
* @param outputStateTreeInfo Optional: State tree account that the compressed
|
|
167
2213
|
* account into
|
|
168
|
-
* @param
|
|
2214
|
+
* @param splInterfaceInfo Optional: SPL interface info.
|
|
169
2215
|
* @param confirmOptions Options for confirming the transaction
|
|
170
2216
|
|
|
171
2217
|
*
|
|
172
2218
|
* @return Signature of the confirmed transaction
|
|
173
2219
|
*/
|
|
174
|
-
declare function compressSplTokenAccount(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, tokenAccount: PublicKey, remainingAmount?: BN, outputStateTreeInfo?: TreeInfo,
|
|
2220
|
+
declare function compressSplTokenAccount(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, tokenAccount: PublicKey, remainingAmount?: BN, outputStateTreeInfo?: TreeInfo, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
175
2221
|
|
|
176
2222
|
/**
|
|
177
|
-
* Create and initialize a new
|
|
2223
|
+
* Create and initialize a new SPL token mint
|
|
2224
|
+
*
|
|
2225
|
+
* @deprecated Use {@link createMintInterface} instead, which supports both SPL and compressed mints.
|
|
178
2226
|
*
|
|
179
2227
|
* @param rpc RPC connection to use
|
|
180
2228
|
* @param payer Fee payer
|
|
@@ -186,11 +2234,10 @@ declare function compressSplTokenAccount(rpc: Rpc, payer: Signer, mint: PublicKe
|
|
|
186
2234
|
* @param tokenProgramId Optional: Program ID for the token. Defaults to
|
|
187
2235
|
* TOKEN_PROGRAM_ID.
|
|
188
2236
|
* @param freezeAuthority Optional: Account that will control freeze and thaw.
|
|
189
|
-
* Defaults to none.
|
|
190
2237
|
*
|
|
191
2238
|
* @return Object with mint address and transaction signature
|
|
192
2239
|
*/
|
|
193
|
-
declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey | Signer, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey | boolean, freezeAuthority?: PublicKey | Signer): Promise<{
|
|
2240
|
+
declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey | Signer, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey | boolean, freezeAuthority?: PublicKey | Signer | null): Promise<{
|
|
194
2241
|
mint: PublicKey;
|
|
195
2242
|
transactionSignature: TransactionSignature;
|
|
196
2243
|
}>;
|
|
@@ -207,14 +2254,18 @@ declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey |
|
|
|
207
2254
|
*
|
|
208
2255
|
* @return transaction signature
|
|
209
2256
|
*/
|
|
210
|
-
declare function
|
|
2257
|
+
declare function createSplInterface(rpc: Rpc, payer: Signer, mint: PublicKey, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<TransactionSignature>;
|
|
211
2258
|
/**
|
|
212
|
-
*
|
|
2259
|
+
* @deprecated Use {@link createSplInterface} instead.
|
|
2260
|
+
*/
|
|
2261
|
+
declare const createTokenPool: typeof createSplInterface;
|
|
2262
|
+
/**
|
|
2263
|
+
* Create additional SPL interfaces for an existing mint
|
|
213
2264
|
*
|
|
214
2265
|
* @param rpc RPC connection to use
|
|
215
2266
|
* @param payer Fee payer
|
|
216
2267
|
* @param mint SPL Mint address
|
|
217
|
-
* @param numMaxAdditionalPools Number of additional
|
|
2268
|
+
* @param numMaxAdditionalPools Number of additional SPL interfaces to create. Max
|
|
218
2269
|
* 3.
|
|
219
2270
|
* @param confirmOptions Optional: Options for confirming the transaction
|
|
220
2271
|
* @param tokenProgramId Optional: Address of the token program. Default:
|
|
@@ -222,7 +2273,11 @@ declare function createTokenPool(rpc: Rpc, payer: Signer, mint: PublicKey, confi
|
|
|
222
2273
|
*
|
|
223
2274
|
* @return transaction signature
|
|
224
2275
|
*/
|
|
225
|
-
declare function
|
|
2276
|
+
declare function addSplInterfaces(rpc: Rpc, payer: Signer, mint: PublicKey, numMaxAdditionalPools: number, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey): Promise<string>;
|
|
2277
|
+
/**
|
|
2278
|
+
* @deprecated Use {@link addSplInterfaces} instead.
|
|
2279
|
+
*/
|
|
2280
|
+
declare const addTokenPools: typeof addSplInterfaces;
|
|
226
2281
|
|
|
227
2282
|
/**
|
|
228
2283
|
* Create a lookup table for the token program's default accounts
|
|
@@ -253,12 +2308,12 @@ declare function createTokenProgramLookupTable(rpc: Rpc, payer: Signer, authorit
|
|
|
253
2308
|
* @param owner Owner of the compressed tokens
|
|
254
2309
|
* @param toAddress Destination **uncompressed** token account
|
|
255
2310
|
* address. (ATA)
|
|
256
|
-
* @param
|
|
2311
|
+
* @param splInterfaceInfos Optional: SPL interface infos.
|
|
257
2312
|
* @param confirmOptions Options for confirming the transaction
|
|
258
2313
|
*
|
|
259
2314
|
* @return confirmed transaction signature
|
|
260
2315
|
*/
|
|
261
|
-
declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey,
|
|
2316
|
+
declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, splInterfaceInfos?: SplInterfaceInfo[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
262
2317
|
|
|
263
2318
|
/**
|
|
264
2319
|
* Merge multiple compressed token accounts for a given mint into a single
|
|
@@ -289,12 +2344,12 @@ declare function mergeTokenAccounts(rpc: Rpc, payer: Signer, mint: PublicKey, ow
|
|
|
289
2344
|
* @param outputStateTreeInfo Optional: State tree account that the compressed
|
|
290
2345
|
* tokens should be part of. Defaults to the
|
|
291
2346
|
* default state tree account.
|
|
292
|
-
* @param
|
|
2347
|
+
* @param splInterfaceInfo Optional: SPL interface information
|
|
293
2348
|
* @param confirmOptions Options for confirming the transaction
|
|
294
2349
|
*
|
|
295
2350
|
* @return Signature of the confirmed transaction
|
|
296
2351
|
*/
|
|
297
|
-
declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey | PublicKey[], authority: Signer, amount: number | BN | number[] | BN[], outputStateTreeInfo?: TreeInfo,
|
|
2352
|
+
declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey | PublicKey[], authority: Signer, amount: number | BN | number[] | BN[], outputStateTreeInfo?: TreeInfo, splInterfaceInfo?: SplInterfaceInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
298
2353
|
|
|
299
2354
|
/**
|
|
300
2355
|
* Revoke one or more delegated token accounts
|
|
@@ -350,12 +2405,12 @@ declare function transferDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amo
|
|
|
350
2405
|
* @param owner Owner of the compressed tokens
|
|
351
2406
|
* @param toAddress Destination **uncompressed** token account
|
|
352
2407
|
* address. (ATA)
|
|
353
|
-
* @param
|
|
2408
|
+
* @param splInterfaceInfos Optional: SPL interface infos.
|
|
354
2409
|
* @param confirmOptions Options for confirming the transaction
|
|
355
2410
|
*
|
|
356
2411
|
* @return Signature of the confirmed transaction
|
|
357
2412
|
*/
|
|
358
|
-
declare function decompressDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey,
|
|
2413
|
+
declare function decompressDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, splInterfaceInfos?: SplInterfaceInfo[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
359
2414
|
|
|
360
2415
|
declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for transfer.";
|
|
361
2416
|
/**
|
|
@@ -504,7 +2559,7 @@ type TokenTransferOutputData = {
|
|
|
504
2559
|
/**
|
|
505
2560
|
* TokenExtension tlv
|
|
506
2561
|
*/
|
|
507
|
-
tlv: Buffer | null;
|
|
2562
|
+
tlv: Buffer$1 | null;
|
|
508
2563
|
};
|
|
509
2564
|
type PackedTokenTransferOutputData = {
|
|
510
2565
|
/**
|
|
@@ -526,7 +2581,7 @@ type PackedTokenTransferOutputData = {
|
|
|
526
2581
|
/**
|
|
527
2582
|
* TokenExtension tlv
|
|
528
2583
|
*/
|
|
529
|
-
tlv: Buffer | null;
|
|
2584
|
+
tlv: Buffer$1 | null;
|
|
530
2585
|
};
|
|
531
2586
|
type InputTokenDataWithContext = {
|
|
532
2587
|
amount: BN;
|
|
@@ -534,7 +2589,7 @@ type InputTokenDataWithContext = {
|
|
|
534
2589
|
merkleContext: PackedMerkleContextLegacy;
|
|
535
2590
|
rootIndex: number;
|
|
536
2591
|
lamports: BN | null;
|
|
537
|
-
tlv: Buffer | null;
|
|
2592
|
+
tlv: Buffer$1 | null;
|
|
538
2593
|
};
|
|
539
2594
|
type DelegatedTransfer = {
|
|
540
2595
|
owner: PublicKey;
|
|
@@ -558,7 +2613,11 @@ type CompressSplTokenAccountInstructionData = {
|
|
|
558
2613
|
remainingAmount: BN | null;
|
|
559
2614
|
cpiContext: CompressedCpiContext | null;
|
|
560
2615
|
};
|
|
561
|
-
declare function
|
|
2616
|
+
declare function isSingleSplInterfaceInfo(splInterfaceInfos: SplInterfaceInfo | SplInterfaceInfo[]): splInterfaceInfos is SplInterfaceInfo;
|
|
2617
|
+
/**
|
|
2618
|
+
* @deprecated Use {@link isSingleSplInterfaceInfo} instead.
|
|
2619
|
+
*/
|
|
2620
|
+
declare const isSingleTokenPoolInfo: typeof isSingleSplInterfaceInfo;
|
|
562
2621
|
type CompressedTokenInstructionDataTransfer = {
|
|
563
2622
|
/**
|
|
564
2623
|
* Validity proof
|
|
@@ -623,7 +2682,7 @@ type TokenData = {
|
|
|
623
2682
|
/**
|
|
624
2683
|
* TokenExtension tlv
|
|
625
2684
|
*/
|
|
626
|
-
tlv: Buffer | null;
|
|
2685
|
+
tlv: Buffer$1 | null;
|
|
627
2686
|
};
|
|
628
2687
|
type CompressedTokenInstructionDataApprove = {
|
|
629
2688
|
proof: ValidityProof | null;
|
|
@@ -680,18 +2739,6 @@ declare function packCompressedTokenAccounts(params: PackCompressedTokenAccounts
|
|
|
680
2739
|
*/
|
|
681
2740
|
declare function checkMint(compressedTokenAccounts: ParsedTokenAccount[], mint: PublicKey): boolean;
|
|
682
2741
|
|
|
683
|
-
declare const POOL_SEED: Buffer<ArrayBuffer>;
|
|
684
|
-
declare const CPI_AUTHORITY_SEED: Buffer<ArrayBuffer>;
|
|
685
|
-
declare const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
|
|
686
|
-
declare const CREATE_TOKEN_POOL_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
687
|
-
declare const MINT_TO_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
688
|
-
declare const BATCH_COMPRESS_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
689
|
-
declare const TRANSFER_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
690
|
-
declare const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
691
|
-
declare const APPROVE_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
692
|
-
declare const REVOKE_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
693
|
-
declare const ADD_TOKEN_POOL_DISCRIMINATOR: Buffer<ArrayBuffer>;
|
|
694
|
-
|
|
695
2742
|
type LightCompressedToken = {
|
|
696
2743
|
version: '1.2.0';
|
|
697
2744
|
name: 'light_compressed_token';
|
|
@@ -2526,20 +4573,20 @@ type LightCompressedToken = {
|
|
|
2526
4573
|
};
|
|
2527
4574
|
declare const IDL: LightCompressedToken;
|
|
2528
4575
|
|
|
2529
|
-
declare const DelegatedTransferLayout:
|
|
2530
|
-
declare const CpiContextLayout:
|
|
2531
|
-
declare const CompressedTokenInstructionDataTransferLayout:
|
|
2532
|
-
declare const mintToLayout:
|
|
2533
|
-
declare const batchCompressLayout:
|
|
2534
|
-
declare const compressSplTokenAccountInstructionDataLayout:
|
|
2535
|
-
declare function encodeMintToInstructionData(data: MintToInstructionData): Buffer;
|
|
2536
|
-
declare function decodeMintToInstructionData(buffer: Buffer): MintToInstructionData;
|
|
2537
|
-
declare function encodeBatchCompressInstructionData(data: BatchCompressInstructionData): Buffer;
|
|
2538
|
-
declare function decodeBatchCompressInstructionData(buffer: Buffer): BatchCompressInstructionData;
|
|
2539
|
-
declare function encodeCompressSplTokenAccountInstructionData(data: CompressSplTokenAccountInstructionData): Buffer;
|
|
2540
|
-
declare function decodeCompressSplTokenAccountInstructionData(buffer: Buffer): CompressSplTokenAccountInstructionData;
|
|
2541
|
-
declare function encodeTransferInstructionData(data: CompressedTokenInstructionDataTransfer): Buffer;
|
|
2542
|
-
declare function decodeTransferInstructionData(buffer: Buffer): CompressedTokenInstructionDataTransfer;
|
|
4576
|
+
declare const DelegatedTransferLayout: Layout<unknown>;
|
|
4577
|
+
declare const CpiContextLayout: Layout<unknown>;
|
|
4578
|
+
declare const CompressedTokenInstructionDataTransferLayout: Layout<unknown>;
|
|
4579
|
+
declare const mintToLayout: Layout<unknown>;
|
|
4580
|
+
declare const batchCompressLayout: Layout<unknown>;
|
|
4581
|
+
declare const compressSplTokenAccountInstructionDataLayout: Layout<unknown>;
|
|
4582
|
+
declare function encodeMintToInstructionData(data: MintToInstructionData): Buffer$1;
|
|
4583
|
+
declare function decodeMintToInstructionData(buffer: Buffer$1): MintToInstructionData;
|
|
4584
|
+
declare function encodeBatchCompressInstructionData(data: BatchCompressInstructionData): Buffer$1;
|
|
4585
|
+
declare function decodeBatchCompressInstructionData(buffer: Buffer$1): BatchCompressInstructionData;
|
|
4586
|
+
declare function encodeCompressSplTokenAccountInstructionData(data: CompressSplTokenAccountInstructionData): Buffer$1;
|
|
4587
|
+
declare function decodeCompressSplTokenAccountInstructionData(buffer: Buffer$1): CompressSplTokenAccountInstructionData;
|
|
4588
|
+
declare function encodeTransferInstructionData(data: CompressedTokenInstructionDataTransfer): Buffer$1;
|
|
4589
|
+
declare function decodeTransferInstructionData(buffer: Buffer$1): CompressedTokenInstructionDataTransfer;
|
|
2543
4590
|
interface BaseAccountsLayoutParams {
|
|
2544
4591
|
feePayer: PublicKey;
|
|
2545
4592
|
authority: PublicKey;
|
|
@@ -2589,12 +4636,12 @@ declare const approveAccountsLayout: (accounts: approveAccountsLayoutParams) =>
|
|
|
2589
4636
|
declare const revokeAccountsLayout: (accounts: approveAccountsLayoutParams) => AccountMeta[];
|
|
2590
4637
|
declare const freezeAccountsLayout: (accounts: freezeAccountsLayoutParams) => AccountMeta[];
|
|
2591
4638
|
declare const thawAccountsLayout: (accounts: freezeAccountsLayoutParams) => AccountMeta[];
|
|
2592
|
-
declare const CompressedTokenInstructionDataApproveLayout:
|
|
2593
|
-
declare const CompressedTokenInstructionDataRevokeLayout:
|
|
2594
|
-
declare function encodeApproveInstructionData(data: CompressedTokenInstructionDataApprove): Buffer;
|
|
2595
|
-
declare function decodeApproveInstructionData(buffer: Buffer): CompressedTokenInstructionDataApprove;
|
|
2596
|
-
declare function encodeRevokeInstructionData(data: CompressedTokenInstructionDataRevoke): Buffer;
|
|
2597
|
-
declare function decodeRevokeInstructionData(buffer: Buffer): CompressedTokenInstructionDataRevoke;
|
|
4639
|
+
declare const CompressedTokenInstructionDataApproveLayout: Layout<unknown>;
|
|
4640
|
+
declare const CompressedTokenInstructionDataRevokeLayout: Layout<unknown>;
|
|
4641
|
+
declare function encodeApproveInstructionData(data: CompressedTokenInstructionDataApprove): Buffer$1;
|
|
4642
|
+
declare function decodeApproveInstructionData(buffer: Buffer$1): CompressedTokenInstructionDataApprove;
|
|
4643
|
+
declare function encodeRevokeInstructionData(data: CompressedTokenInstructionDataRevoke): Buffer$1;
|
|
4644
|
+
declare function decodeRevokeInstructionData(buffer: Buffer$1): CompressedTokenInstructionDataRevoke;
|
|
2598
4645
|
|
|
2599
4646
|
type CompressParams = {
|
|
2600
4647
|
/**
|
|
@@ -2628,7 +4675,7 @@ type CompressParams = {
|
|
|
2628
4675
|
/**
|
|
2629
4676
|
* Token pool
|
|
2630
4677
|
*/
|
|
2631
|
-
tokenPoolInfo: TokenPoolInfo;
|
|
4678
|
+
tokenPoolInfo: TokenPoolInfo | SplInterfaceInfo;
|
|
2632
4679
|
};
|
|
2633
4680
|
type CompressSplTokenAccountParams = {
|
|
2634
4681
|
/**
|
|
@@ -2658,7 +4705,7 @@ type CompressSplTokenAccountParams = {
|
|
|
2658
4705
|
/**
|
|
2659
4706
|
* Token pool
|
|
2660
4707
|
*/
|
|
2661
|
-
tokenPoolInfo: TokenPoolInfo;
|
|
4708
|
+
tokenPoolInfo: TokenPoolInfo | SplInterfaceInfo;
|
|
2662
4709
|
};
|
|
2663
4710
|
type DecompressParams = {
|
|
2664
4711
|
/**
|
|
@@ -2688,7 +4735,7 @@ type DecompressParams = {
|
|
|
2688
4735
|
/**
|
|
2689
4736
|
* Token pool(s)
|
|
2690
4737
|
*/
|
|
2691
|
-
tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[];
|
|
4738
|
+
tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[] | SplInterfaceInfo | SplInterfaceInfo[];
|
|
2692
4739
|
};
|
|
2693
4740
|
type TransferParams = {
|
|
2694
4741
|
/**
|
|
@@ -2857,13 +4904,13 @@ type MintToParams = {
|
|
|
2857
4904
|
/**
|
|
2858
4905
|
* Token pool
|
|
2859
4906
|
*/
|
|
2860
|
-
tokenPoolInfo: TokenPoolInfo;
|
|
4907
|
+
tokenPoolInfo: TokenPoolInfo | SplInterfaceInfo;
|
|
2861
4908
|
};
|
|
2862
4909
|
/**
|
|
2863
|
-
* Register an existing SPL mint account to the compressed token program
|
|
2864
|
-
* Creates an omnibus account for the mint
|
|
4910
|
+
* Register an existing SPL mint account to the compressed token program.
|
|
4911
|
+
* Creates an omnibus account (SPL interface) for the mint.
|
|
2865
4912
|
*/
|
|
2866
|
-
type
|
|
4913
|
+
type CreateSplInterfaceParams = {
|
|
2867
4914
|
/**
|
|
2868
4915
|
* Fee payer
|
|
2869
4916
|
*/
|
|
@@ -2877,7 +4924,11 @@ type CreateTokenPoolParams = {
|
|
|
2877
4924
|
*/
|
|
2878
4925
|
tokenProgramId?: PublicKey;
|
|
2879
4926
|
};
|
|
2880
|
-
|
|
4927
|
+
/**
|
|
4928
|
+
* @deprecated Use {@link CreateSplInterfaceParams} instead.
|
|
4929
|
+
*/
|
|
4930
|
+
type CreateTokenPoolParams = CreateSplInterfaceParams;
|
|
4931
|
+
type AddSplInterfaceParams = {
|
|
2881
4932
|
/**
|
|
2882
4933
|
* Fee payer
|
|
2883
4934
|
*/
|
|
@@ -2887,7 +4938,7 @@ type AddTokenPoolParams = {
|
|
|
2887
4938
|
*/
|
|
2888
4939
|
mint: PublicKey;
|
|
2889
4940
|
/**
|
|
2890
|
-
*
|
|
4941
|
+
* SPL interface pool index
|
|
2891
4942
|
*/
|
|
2892
4943
|
poolIndex: number;
|
|
2893
4944
|
/**
|
|
@@ -2895,6 +4946,10 @@ type AddTokenPoolParams = {
|
|
|
2895
4946
|
*/
|
|
2896
4947
|
tokenProgramId?: PublicKey;
|
|
2897
4948
|
};
|
|
4949
|
+
/**
|
|
4950
|
+
* @deprecated Use {@link AddSplInterfaceParams} instead.
|
|
4951
|
+
*/
|
|
4952
|
+
type AddTokenPoolParams = AddSplInterfaceParams;
|
|
2898
4953
|
/**
|
|
2899
4954
|
* Mint from existing SPL mint to compressed token accounts
|
|
2900
4955
|
*/
|
|
@@ -2930,7 +4985,7 @@ type ApproveAndMintToParams = {
|
|
|
2930
4985
|
/**
|
|
2931
4986
|
* Token pool
|
|
2932
4987
|
*/
|
|
2933
|
-
tokenPoolInfo: TokenPoolInfo;
|
|
4988
|
+
tokenPoolInfo: TokenPoolInfo | SplInterfaceInfo;
|
|
2934
4989
|
};
|
|
2935
4990
|
type CreateTokenProgramLookupTableParams = {
|
|
2936
4991
|
/**
|
|
@@ -3008,37 +5063,49 @@ declare class CompressedTokenProgram {
|
|
|
3008
5063
|
*/
|
|
3009
5064
|
static setProgramId(programId: PublicKey | string): void;
|
|
3010
5065
|
/**
|
|
3011
|
-
* Derive the
|
|
3012
|
-
* To derive the
|
|
5066
|
+
* Derive the SPL interface PDA.
|
|
5067
|
+
* To derive the SPL interface PDA with bump, use {@link deriveSplInterfacePdaWithIndex}.
|
|
3013
5068
|
*
|
|
3014
|
-
* @param mint The mint of the
|
|
5069
|
+
* @param mint The mint of the SPL interface
|
|
3015
5070
|
*
|
|
3016
|
-
* @returns The
|
|
5071
|
+
* @returns The SPL interface PDA
|
|
5072
|
+
*/
|
|
5073
|
+
static deriveSplInterfacePda(mint: PublicKey): PublicKey;
|
|
5074
|
+
/**
|
|
5075
|
+
* @deprecated Use {@link deriveSplInterfacePda} instead.
|
|
3017
5076
|
*/
|
|
3018
5077
|
static deriveTokenPoolPda(mint: PublicKey): PublicKey;
|
|
3019
5078
|
/**
|
|
3020
|
-
* Find the index and bump for a given
|
|
5079
|
+
* Find the index and bump for a given SPL interface PDA and mint.
|
|
3021
5080
|
*
|
|
3022
|
-
* @param poolPda The
|
|
3023
|
-
* @param mint The mint of the
|
|
5081
|
+
* @param poolPda The SPL interface PDA to find the index and bump for
|
|
5082
|
+
* @param mint The mint of the SPL interface
|
|
3024
5083
|
*
|
|
3025
5084
|
* @returns The index and bump number.
|
|
3026
5085
|
*/
|
|
5086
|
+
static findSplInterfaceIndexAndBump(poolPda: PublicKey, mint: PublicKey): [number, number];
|
|
5087
|
+
/**
|
|
5088
|
+
* @deprecated Use {@link findSplInterfaceIndexAndBump} instead.
|
|
5089
|
+
*/
|
|
3027
5090
|
static findTokenPoolIndexAndBump(poolPda: PublicKey, mint: PublicKey): [number, number];
|
|
3028
5091
|
/**
|
|
3029
|
-
* Derive the
|
|
5092
|
+
* Derive the SPL interface PDA with index.
|
|
3030
5093
|
*
|
|
3031
|
-
* @param mint The mint of the
|
|
3032
|
-
* @param index Index. starts at 0. The Protocol supports 4 indexes aka
|
|
5094
|
+
* @param mint The mint of the SPL interface
|
|
5095
|
+
* @param index Index. starts at 0. The Protocol supports 4 indexes aka SPL interfaces
|
|
3033
5096
|
* per mint.
|
|
3034
5097
|
*
|
|
3035
|
-
* @returns The
|
|
5098
|
+
* @returns The SPL interface PDA and bump.
|
|
5099
|
+
*/
|
|
5100
|
+
static deriveSplInterfacePdaWithIndex(mint: PublicKey, index: number): [PublicKey, number];
|
|
5101
|
+
/**
|
|
5102
|
+
* @deprecated Use {@link deriveSplInterfacePdaWithIndex} instead.
|
|
3036
5103
|
*/
|
|
3037
5104
|
static deriveTokenPoolPdaWithIndex(mint: PublicKey, index: number): [PublicKey, number];
|
|
3038
5105
|
/** @internal */
|
|
3039
5106
|
static get deriveCpiAuthorityPda(): PublicKey;
|
|
3040
5107
|
/**
|
|
3041
|
-
* Construct createMint instruction for
|
|
5108
|
+
* Construct createMint instruction for SPL tokens.
|
|
3042
5109
|
*
|
|
3043
5110
|
* @param feePayer Fee payer.
|
|
3044
5111
|
* @param mint SPL Mint address.
|
|
@@ -3067,7 +5134,7 @@ declare class CompressedTokenProgram {
|
|
|
3067
5134
|
*
|
|
3068
5135
|
* @returns The createTokenPool instruction
|
|
3069
5136
|
*/
|
|
3070
|
-
static createTokenPool({ feePayer, mint, tokenProgramId, }:
|
|
5137
|
+
static createTokenPool({ feePayer, mint, tokenProgramId, }: CreateSplInterfaceParams): Promise<TransactionInstruction>;
|
|
3071
5138
|
/**
|
|
3072
5139
|
* Add a token pool to an existing SPL mint. For new mints, use
|
|
3073
5140
|
* {@link createTokenPool}.
|
|
@@ -3080,7 +5147,7 @@ declare class CompressedTokenProgram {
|
|
|
3080
5147
|
*
|
|
3081
5148
|
* @returns The addTokenPool instruction
|
|
3082
5149
|
*/
|
|
3083
|
-
static addTokenPool({ feePayer, mint, poolIndex, tokenProgramId, }:
|
|
5150
|
+
static addTokenPool({ feePayer, mint, poolIndex, tokenProgramId, }: AddSplInterfaceParams): Promise<TransactionInstruction>;
|
|
3084
5151
|
/**
|
|
3085
5152
|
* Construct mintTo instruction for compressed tokens
|
|
3086
5153
|
*
|
|
@@ -3233,4 +5300,42 @@ declare class CompressedTokenProgram {
|
|
|
3233
5300
|
static revoke({ payer, inputCompressedTokenAccounts, recentValidityProof, recentInputStateRootIndices, }: RevokeParams): Promise<TransactionInstruction>;
|
|
3234
5301
|
}
|
|
3235
5302
|
|
|
3236
|
-
|
|
5303
|
+
/**
|
|
5304
|
+
* Retrieve associated token account for a given owner and mint.
|
|
5305
|
+
*
|
|
5306
|
+
* @param rpc RPC connection
|
|
5307
|
+
* @param ata Associated token address
|
|
5308
|
+
* @param owner Owner public key
|
|
5309
|
+
* @param mint Mint public key
|
|
5310
|
+
* @param commitment Optional commitment level
|
|
5311
|
+
* @param programId Optional program ID
|
|
5312
|
+
* @returns AccountInterface with ATA metadata
|
|
5313
|
+
*/
|
|
5314
|
+
declare function getAtaInterface(rpc: Rpc, ata: PublicKey, owner: PublicKey, mint: PublicKey, commitment?: Commitment, programId?: PublicKey): Promise<AccountInterface>;
|
|
5315
|
+
/**
|
|
5316
|
+
* Create instructions to load token balances into a c-token ATA.
|
|
5317
|
+
*
|
|
5318
|
+
* @param rpc RPC connection
|
|
5319
|
+
* @param ata Associated token address
|
|
5320
|
+
* @param owner Owner public key
|
|
5321
|
+
* @param mint Mint public key
|
|
5322
|
+
* @param payer Fee payer (defaults to owner)
|
|
5323
|
+
* @param options Optional load options
|
|
5324
|
+
* @returns Array of instructions (empty if nothing to load)
|
|
5325
|
+
*/
|
|
5326
|
+
declare function createLoadAtaInstructions(rpc: Rpc, ata: PublicKey, owner: PublicKey, mint: PublicKey, payer?: PublicKey, options?: InterfaceOptions): Promise<TransactionInstruction[]>;
|
|
5327
|
+
/**
|
|
5328
|
+
* Load token balances into a c-token ATA.
|
|
5329
|
+
*
|
|
5330
|
+
* @param rpc RPC connection
|
|
5331
|
+
* @param ata Associated token address
|
|
5332
|
+
* @param owner Owner of the tokens (signer)
|
|
5333
|
+
* @param mint Mint public key
|
|
5334
|
+
* @param payer Fee payer (signer, defaults to owner)
|
|
5335
|
+
* @param confirmOptions Optional confirm options
|
|
5336
|
+
* @param interfaceOptions Optional interface options
|
|
5337
|
+
* @returns Transaction signature, or null if nothing to load
|
|
5338
|
+
*/
|
|
5339
|
+
declare function loadAta(rpc: Rpc, ata: PublicKey, owner: Signer, mint: PublicKey, payer?: Signer, confirmOptions?: ConfirmOptions, interfaceOptions?: InterfaceOptions): Promise<TransactionSignature | null>;
|
|
5340
|
+
|
|
5341
|
+
export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, type AccountInterface, Action, type AddSplInterfaceParams, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, BATCH_COMPRESS_DISCRIMINATOR, type BaseMint, type BatchCompressInstructionData, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CTokenConfig, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedMint, type CompressedTokenInstructionDataApprove, CompressedTokenInstructionDataApproveLayout, type CompressedTokenInstructionDataRevoke, CompressedTokenInstructionDataRevokeLayout, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, type CompressibleAccountInput, type CompressibleConfig, type CompressibleLoadParams, CpiContextLayout, type CreateAssociatedCTokenAccountParams, type CreateMintParams, type CreateSplInterfaceParams, type CreateTokenPoolParams, type CreateTokenProgramLookupTableParams, DECOMPRESS_ACCOUNTS_IDEMPOTENT_DISCRIMINATOR, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_NO_ACCOUNTS_FOUND, ExtensionType, IDL, type InputTokenDataWithContext, type InterfaceOptions, type LightCompressedToken, type LoadResult, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintContext, type MintExtension, type MintInterface, type MintToInstructionData, type MintToParams, type OffChainTokenMetadata, type OffChainTokenMetadataJson, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedCompressedAccount, type PackedTokenTransferOutputData, type ParsedAccountInfoInterface, REVOKE_DISCRIMINATOR, type RevokeParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, type SplInterfaceActivity, type SplInterfaceInfo, TRANSFER_DISCRIMINATOR, type TokenAccountSource, type TokenData, TokenDataVersion, type TokenMetadata, type TokenMetadataInstructionData, type TokenPoolActivity, type TokenPoolInfo, type TokenTransferOutputData, type TransferParams, addSplInterfaces, addTokenPoolAccountsLayout, type addTokenPoolAccountsLayoutParams, addTokenPools, approve, approveAccountsLayout, type approveAccountsLayoutParams, approveAndMintTo, batchCompressLayout, calculateCompressibleLoadComputeUnits, checkMint, checkSplInterfaceInfo, checkTokenPoolInfo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, convertTokenDataToAccount, createAssociatedCTokenAccountIdempotentInstruction, createAssociatedCTokenAccountInstruction, createAssociatedTokenAccountInterfaceIdempotentInstruction, createAssociatedTokenAccountInterfaceInstruction, createAtaInterface, createAtaInterfaceIdempotent, createAtaInterfaceIdempotentInstruction, createCTokenTransferInstruction, createDecompressInterfaceInstruction, createDecompressOutputState, createLoadAccountsParams, createLoadAtaInstructions, createLoadAtaInstructionsFromInterface, createMint, createMintInstruction, createMintInterface, createMintToCompressedInstruction, createMintToInstruction, createMintToInterfaceInstruction, createRemoveMetadataKeyInstruction, createSplInterface, createTokenMetadata, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferInterfaceInstruction, createTransferOutputState, createUpdateFreezeAuthorityInstruction, createUpdateMetadataAuthorityInstruction, createUpdateMetadataFieldInstruction, createUpdateMintAuthorityInstruction, createWrapInstruction, decodeApproveInstructionData, decodeBatchCompressInstructionData, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeRevokeInstructionData, decodeTokenMetadata, decodeTransferInstructionData, decompress, decompressDelegated, decompressInterface, deriveSplInterfaceInfo, deriveTokenPoolInfo, deserializeMint, encodeApproveInstructionData, encodeBatchCompressInstructionData, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeRevokeInstructionData, encodeTokenMetadata, encodeTransferInstructionData, extractTokenMetadata, freezeAccountsLayout, type freezeAccountsLayoutParams, getAccountInterface, getAssociatedTokenAddressInterface, getAtaInterface, getMintInterface, getOrCreateAtaInterface, getSplInterfaceInfos, getTokenPoolInfos, isSingleSplInterfaceInfo, isSingleTokenPoolInfo, loadAta, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintTo$1 as mintToCToken, mintToCompressed, mintToInterface, mintToLayout, packCompressedTokenAccounts, parseCTokenCold, parseCTokenHot, parseMaybeDelegatedTransfer, parseTokenData, removeMetadataKey, revoke, revokeAccountsLayout, type revokeAccountsLayoutParams, selectMinCompressedTokenAccountsForDecompression, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferOrPartial, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferOrPartial, selectSplInterfaceInfo, selectSplInterfaceInfosForDecompression, selectTokenAccountsForApprove, selectTokenPoolInfo, selectTokenPoolInfosForDecompression, serializeMint, sumUpTokenAmount, thawAccountsLayout, type thawAccountsLayoutParams, toAccountInfo, toOffChainMetadataJson, toTokenPoolInfo, transfer, transferAccountsLayout, type transferAccountsLayoutParams, transferDelegated, transferInterface, unpackMintData, unpackMintInterface, updateFreezeAuthority, updateMetadataAuthority, updateMetadataField, updateMintAuthority, validateSameTokenOwner, wrap };
|