@lightprotocol/compressed-token 0.21.0 → 0.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Signer, PublicKey, ConfirmOptions, TransactionSignature, Commitment, Keypair, AccountMeta, TransactionInstruction, Connection } from '@solana/web3.js';
|
|
2
|
-
import { Rpc,
|
|
2
|
+
import { Rpc, TreeInfo, ParsedTokenAccount, PackedMerkleContextLegacy, CompressedCpiContext, ValidityProof, InputTokenDataWithContext as InputTokenDataWithContext$1, CompressedProof } from '@lightprotocol/stateless.js';
|
|
3
3
|
import BN from 'bn.js';
|
|
4
4
|
import { Buffer } from 'buffer';
|
|
5
5
|
import * as buffer_layout from 'buffer-layout';
|
|
@@ -8,10 +8,10 @@ import * as buffer_layout from 'buffer-layout';
|
|
|
8
8
|
* Approve a delegate to spend tokens
|
|
9
9
|
*
|
|
10
10
|
* @param rpc Rpc to use
|
|
11
|
-
* @param payer
|
|
12
|
-
* @param mint Mint
|
|
11
|
+
* @param payer Fee payer
|
|
12
|
+
* @param mint SPL Mint address
|
|
13
13
|
* @param amount Number of tokens to delegate
|
|
14
|
-
* @param owner Owner of the
|
|
14
|
+
* @param owner Owner of the SPL token account.
|
|
15
15
|
* @param delegate Address of the delegate
|
|
16
16
|
* @param confirmOptions Options for confirming the transaction
|
|
17
17
|
*
|
|
@@ -76,6 +76,10 @@ type TokenPoolInfo = {
|
|
|
76
76
|
* The index of the token pool
|
|
77
77
|
*/
|
|
78
78
|
poolIndex: number;
|
|
79
|
+
/**
|
|
80
|
+
* The bump used to derive the token pool pda
|
|
81
|
+
*/
|
|
82
|
+
bump: number;
|
|
79
83
|
};
|
|
80
84
|
/**
|
|
81
85
|
* @internal
|
|
@@ -86,8 +90,11 @@ declare enum Action {
|
|
|
86
90
|
Transfer = 3
|
|
87
91
|
}
|
|
88
92
|
/**
|
|
93
|
+
* For `compress` and `mintTo` instructions only.
|
|
89
94
|
* Select a random token pool info from the token pool infos.
|
|
90
95
|
*
|
|
96
|
+
* For `decompress`, use {@link selectTokenPoolInfosForDecompression} instead.
|
|
97
|
+
*
|
|
91
98
|
* @param infos The token pool infos
|
|
92
99
|
*
|
|
93
100
|
* @returns A random token pool info
|
|
@@ -111,78 +118,79 @@ declare function selectTokenPoolInfosForDecompression(infos: TokenPoolInfo[], de
|
|
|
111
118
|
* Mint compressed tokens to a solana address from an external mint authority
|
|
112
119
|
*
|
|
113
120
|
* @param rpc Rpc to use
|
|
114
|
-
* @param payer
|
|
115
|
-
* @param mint Mint
|
|
121
|
+
* @param payer Fee payer
|
|
122
|
+
* @param mint SPL Mint address
|
|
116
123
|
* @param toPubkey Address of the account to mint to
|
|
117
124
|
* @param authority Minting authority
|
|
118
125
|
* @param amount Amount to mint
|
|
119
|
-
* @param outputStateTreeInfo State tree
|
|
120
|
-
*
|
|
126
|
+
* @param outputStateTreeInfo Optional: State tree account that the compressed
|
|
127
|
+
* tokens should be inserted into. Defaults to a
|
|
128
|
+
* shared state tree account.
|
|
129
|
+
* @param tokenPoolInfo Optional: Token pool info.
|
|
121
130
|
* @param confirmOptions Options for confirming the transaction
|
|
122
131
|
*
|
|
123
132
|
* @return Signature of the confirmed transaction
|
|
124
133
|
*/
|
|
125
|
-
declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey, authority: Signer, amount: number | BN, outputStateTreeInfo?:
|
|
134
|
+
declare function approveAndMintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey, authority: Signer, amount: number | BN, outputStateTreeInfo?: TreeInfo, tokenPoolInfo?: TokenPoolInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
126
135
|
|
|
127
136
|
/**
|
|
128
137
|
* Compress SPL tokens
|
|
129
138
|
*
|
|
130
139
|
* @param rpc Rpc connection to use
|
|
131
|
-
* @param payer
|
|
132
|
-
* @param mint Mint
|
|
133
|
-
* @param amount Number of tokens to
|
|
134
|
-
* @param owner Owner of the
|
|
135
|
-
* @param sourceTokenAccount Source
|
|
136
|
-
* @param toAddress
|
|
137
|
-
* @param outputStateTreeInfo State tree account that the compressed
|
|
138
|
-
* should be inserted into. Defaults to a
|
|
139
|
-
* state tree account.
|
|
140
|
-
* @param tokenPoolInfo Token pool info
|
|
140
|
+
* @param payer Fee payer
|
|
141
|
+
* @param mint SPL Mint address
|
|
142
|
+
* @param amount Number of tokens to compress.
|
|
143
|
+
* @param owner Owner of the SPL token account.
|
|
144
|
+
* @param sourceTokenAccount Source SPL token account. (ATA)
|
|
145
|
+
* @param toAddress Recipient owner address.
|
|
146
|
+
* @param outputStateTreeInfo Optional: State tree account that the compressed
|
|
147
|
+
* tokens should be inserted into. Defaults to a
|
|
148
|
+
* shared state tree account.
|
|
149
|
+
* @param tokenPoolInfo Optional: Token pool info.
|
|
141
150
|
* @param confirmOptions Options for confirming the transaction
|
|
142
151
|
*
|
|
143
152
|
* @return Signature of the confirmed transaction
|
|
144
153
|
*/
|
|
145
|
-
declare function compress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN | number[] | BN[], owner: Signer, sourceTokenAccount: PublicKey, toAddress: PublicKey | Array<PublicKey>, outputStateTreeInfo?:
|
|
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, tokenPoolInfo?: TokenPoolInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
146
155
|
|
|
147
156
|
/**
|
|
148
157
|
* Compress SPL tokens into compressed token format
|
|
149
158
|
*
|
|
150
159
|
* @param rpc Rpc connection to use
|
|
151
|
-
* @param payer
|
|
152
|
-
* @param mint Mint
|
|
160
|
+
* @param payer Fee payer
|
|
161
|
+
* @param mint SPL Mint address
|
|
153
162
|
* @param owner Owner of the token account
|
|
154
163
|
* @param tokenAccount Token account to compress
|
|
155
164
|
* @param remainingAmount Optional: amount to leave in token account.
|
|
156
165
|
* Default: 0
|
|
157
|
-
* @param outputStateTreeInfo State tree
|
|
166
|
+
* @param outputStateTreeInfo Optional: State tree account that the compressed
|
|
158
167
|
* account into
|
|
159
|
-
* @param tokenPoolInfo Token pool info
|
|
168
|
+
* @param tokenPoolInfo Optional: Token pool info.
|
|
160
169
|
* @param confirmOptions Options for confirming the transaction
|
|
161
170
|
|
|
162
171
|
*
|
|
163
172
|
* @return Signature of the confirmed transaction
|
|
164
173
|
*/
|
|
165
|
-
declare function compressSplTokenAccount(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, tokenAccount: PublicKey, remainingAmount?: BN, outputStateTreeInfo?:
|
|
174
|
+
declare function compressSplTokenAccount(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, tokenAccount: PublicKey, remainingAmount?: BN, outputStateTreeInfo?: TreeInfo, tokenPoolInfo?: TokenPoolInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
166
175
|
|
|
167
176
|
/**
|
|
168
177
|
* Create and initialize a new compressed token mint
|
|
169
178
|
*
|
|
170
|
-
* @param rpc RPC to use
|
|
171
|
-
* @param payer
|
|
172
|
-
* @param mintAuthority Account
|
|
179
|
+
* @param rpc RPC connection to use
|
|
180
|
+
* @param payer Fee payer
|
|
181
|
+
* @param mintAuthority Account that will control minting
|
|
173
182
|
* @param decimals Location of the decimal place
|
|
174
|
-
* @param keypair Optional keypair
|
|
183
|
+
* @param keypair Optional: Mint keypair. Defaults to a random
|
|
184
|
+
* keypair.
|
|
175
185
|
* @param confirmOptions Options for confirming the transaction
|
|
176
|
-
* @param tokenProgramId Program ID for the token. Defaults to
|
|
177
|
-
* TOKEN_PROGRAM_ID.
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
* @param freezeAuthority Account that will control freeze and thaw. Defaults
|
|
181
|
-
* to null.
|
|
186
|
+
* @param tokenProgramId Optional: Program ID for the token. Defaults to
|
|
187
|
+
* TOKEN_PROGRAM_ID.
|
|
188
|
+
* @param freezeAuthority Optional: Account that will control freeze and thaw.
|
|
189
|
+
* Defaults to none.
|
|
182
190
|
*
|
|
183
|
-
* @return
|
|
191
|
+
* @return Object with mint address and transaction signature
|
|
184
192
|
*/
|
|
185
|
-
declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey | boolean, freezeAuthority?: PublicKey): Promise<{
|
|
193
|
+
declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey | Signer, decimals: number, keypair?: Keypair, confirmOptions?: ConfirmOptions, tokenProgramId?: PublicKey | boolean, freezeAuthority?: PublicKey | Signer): Promise<{
|
|
186
194
|
mint: PublicKey;
|
|
187
195
|
transactionSignature: TransactionSignature;
|
|
188
196
|
}>;
|
|
@@ -190,9 +198,9 @@ declare function createMint(rpc: Rpc, payer: Signer, mintAuthority: PublicKey, d
|
|
|
190
198
|
/**
|
|
191
199
|
* Register an existing mint with the CompressedToken program
|
|
192
200
|
*
|
|
193
|
-
* @param rpc RPC to use
|
|
194
|
-
* @param payer
|
|
195
|
-
* @param mint
|
|
201
|
+
* @param rpc RPC connection to use
|
|
202
|
+
* @param payer Fee payer
|
|
203
|
+
* @param mint SPL Mint address
|
|
196
204
|
* @param confirmOptions Options for confirming the transaction
|
|
197
205
|
* @param tokenProgramId Optional: Address of the token program. Default:
|
|
198
206
|
* TOKEN_PROGRAM_ID
|
|
@@ -203,11 +211,12 @@ declare function createTokenPool(rpc: Rpc, payer: Signer, mint: PublicKey, confi
|
|
|
203
211
|
/**
|
|
204
212
|
* Create additional token pools for an existing mint
|
|
205
213
|
*
|
|
206
|
-
* @param rpc RPC to use
|
|
207
|
-
* @param payer
|
|
208
|
-
* @param mint
|
|
209
|
-
* @param numMaxAdditionalPools Number of additional token pools to create. Max
|
|
210
|
-
*
|
|
214
|
+
* @param rpc RPC connection to use
|
|
215
|
+
* @param payer Fee payer
|
|
216
|
+
* @param mint SPL Mint address
|
|
217
|
+
* @param numMaxAdditionalPools Number of additional token pools to create. Max
|
|
218
|
+
* 3.
|
|
219
|
+
* @param confirmOptions Optional: Options for confirming the transaction
|
|
211
220
|
* @param tokenProgramId Optional: Address of the token program. Default:
|
|
212
221
|
* TOKEN_PROGRAM_ID
|
|
213
222
|
*
|
|
@@ -219,14 +228,15 @@ declare function addTokenPools(rpc: Rpc, payer: Signer, mint: PublicKey, numMaxA
|
|
|
219
228
|
* Create a lookup table for the token program's default accounts
|
|
220
229
|
*
|
|
221
230
|
* @param rpc Rpc connection to use
|
|
222
|
-
* @param payer
|
|
231
|
+
* @param payer Fee payer
|
|
223
232
|
* @param authority Authority of the lookup table
|
|
224
233
|
* @param mints Optional array of mint public keys to include in
|
|
225
234
|
* the lookup table
|
|
226
235
|
* @param additionalAccounts Optional array of additional account public keys
|
|
227
236
|
* to include in the lookup table
|
|
228
237
|
*
|
|
229
|
-
* @return
|
|
238
|
+
* @return Object with transaction signatures and the address of the created
|
|
239
|
+
* lookup table
|
|
230
240
|
*/
|
|
231
241
|
declare function createTokenProgramLookupTable(rpc: Rpc, payer: Signer, authority: Signer, mints?: PublicKey[], additionalAccounts?: PublicKey[]): Promise<{
|
|
232
242
|
txIds: TransactionSignature[];
|
|
@@ -236,17 +246,17 @@ declare function createTokenProgramLookupTable(rpc: Rpc, payer: Signer, authorit
|
|
|
236
246
|
/**
|
|
237
247
|
* Decompress compressed tokens
|
|
238
248
|
*
|
|
239
|
-
* @param rpc Rpc to use
|
|
240
|
-
* @param payer
|
|
241
|
-
* @param mint Mint
|
|
249
|
+
* @param rpc Rpc connection to use
|
|
250
|
+
* @param payer Fee payer
|
|
251
|
+
* @param mint SPL Mint address
|
|
242
252
|
* @param amount Number of tokens to transfer
|
|
243
253
|
* @param owner Owner of the compressed tokens
|
|
244
|
-
* @param toAddress Destination **uncompressed**
|
|
245
|
-
*
|
|
246
|
-
* @param tokenPoolInfos Token pool infos
|
|
254
|
+
* @param toAddress Destination **uncompressed** token account
|
|
255
|
+
* address. (ATA)
|
|
256
|
+
* @param tokenPoolInfos Optional: Token pool infos.
|
|
247
257
|
* @param confirmOptions Options for confirming the transaction
|
|
248
258
|
*
|
|
249
|
-
* @return
|
|
259
|
+
* @return confirmed transaction signature
|
|
250
260
|
*/
|
|
251
261
|
declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, tokenPoolInfos?: TokenPoolInfo[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
252
262
|
|
|
@@ -254,44 +264,44 @@ declare function decompress(rpc: Rpc, payer: Signer, mint: PublicKey, amount: nu
|
|
|
254
264
|
* Merge multiple compressed token accounts for a given mint into a single
|
|
255
265
|
* account
|
|
256
266
|
*
|
|
257
|
-
* @param rpc RPC to use
|
|
258
|
-
* @param payer
|
|
259
|
-
* @param mint
|
|
267
|
+
* @param rpc RPC connection to use
|
|
268
|
+
* @param payer Fee payer
|
|
269
|
+
* @param mint SPL Mint address
|
|
260
270
|
* @param owner Owner of the token accounts to be merged
|
|
261
271
|
* @param confirmOptions Options for confirming the transaction
|
|
262
272
|
*
|
|
263
|
-
* @return
|
|
273
|
+
* @return confirmed transaction signature
|
|
264
274
|
*/
|
|
265
275
|
declare function mergeTokenAccounts(rpc: Rpc, payer: Signer, mint: PublicKey, owner: Signer, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
266
276
|
|
|
267
277
|
/**
|
|
268
278
|
* Mint compressed tokens to a solana address
|
|
269
279
|
*
|
|
270
|
-
* @param rpc Rpc to use
|
|
271
|
-
* @param payer
|
|
272
|
-
* @param mint Mint
|
|
280
|
+
* @param rpc Rpc connection to use
|
|
281
|
+
* @param payer Fee payer
|
|
282
|
+
* @param mint SPL Mint address
|
|
273
283
|
* @param toPubkey Address of the account to mint to. Can be an
|
|
274
284
|
* array of addresses if the amount is an array of
|
|
275
285
|
* amounts.
|
|
276
|
-
* @param authority
|
|
277
|
-
* @param amount Amount to mint.
|
|
278
|
-
*
|
|
279
|
-
* @param outputStateTreeInfo State tree account that the compressed
|
|
280
|
-
* should be part of. Defaults to the
|
|
281
|
-
* tree account.
|
|
282
|
-
* @param tokenPoolInfo Token pool information
|
|
286
|
+
* @param authority Mint authority
|
|
287
|
+
* @param amount Amount to mint. Pass an array of amounts if the
|
|
288
|
+
* toPubkey is an array of addresses.
|
|
289
|
+
* @param outputStateTreeInfo Optional: State tree account that the compressed
|
|
290
|
+
* tokens should be part of. Defaults to the
|
|
291
|
+
* default state tree account.
|
|
292
|
+
* @param tokenPoolInfo Optional: Token pool information
|
|
283
293
|
* @param confirmOptions Options for confirming the transaction
|
|
284
294
|
*
|
|
285
295
|
* @return Signature of the confirmed transaction
|
|
286
296
|
*/
|
|
287
|
-
declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey | PublicKey[], authority: Signer, amount: number | BN | number[] | BN[], outputStateTreeInfo?:
|
|
297
|
+
declare function mintTo(rpc: Rpc, payer: Signer, mint: PublicKey, toPubkey: PublicKey | PublicKey[], authority: Signer, amount: number | BN | number[] | BN[], outputStateTreeInfo?: TreeInfo, tokenPoolInfo?: TokenPoolInfo, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
288
298
|
|
|
289
299
|
/**
|
|
290
300
|
* Revoke one or more delegated token accounts
|
|
291
301
|
*
|
|
292
|
-
* @param rpc Rpc to use
|
|
293
|
-
* @param payer
|
|
294
|
-
* @param accounts Delegated
|
|
302
|
+
* @param rpc Rpc connection to use
|
|
303
|
+
* @param payer Fee payer
|
|
304
|
+
* @param accounts Delegated compressed token accounts to revoke
|
|
295
305
|
* @param owner Owner of the compressed tokens
|
|
296
306
|
* @param confirmOptions Options for confirming the transaction
|
|
297
307
|
*
|
|
@@ -302,30 +312,30 @@ declare function revoke(rpc: Rpc, payer: Signer, accounts: ParsedTokenAccount[],
|
|
|
302
312
|
/**
|
|
303
313
|
* Transfer compressed tokens from one owner to another
|
|
304
314
|
*
|
|
305
|
-
* @param rpc Rpc to use
|
|
306
|
-
* @param payer
|
|
307
|
-
* @param mint Mint
|
|
315
|
+
* @param rpc Rpc connection to use
|
|
316
|
+
* @param payer Fee payer
|
|
317
|
+
* @param mint SPL Mint address
|
|
308
318
|
* @param amount Number of tokens to transfer
|
|
309
319
|
* @param owner Owner of the compressed tokens
|
|
310
320
|
* @param toAddress Destination address of the recipient
|
|
311
321
|
* @param confirmOptions Options for confirming the transaction
|
|
312
322
|
*
|
|
313
|
-
* @return
|
|
323
|
+
* @return confirmed transaction signature
|
|
314
324
|
*/
|
|
315
325
|
declare function transfer(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
316
326
|
|
|
317
327
|
/**
|
|
318
328
|
* Transfer delegated compressed tokens to another owner
|
|
319
329
|
*
|
|
320
|
-
* @param rpc Rpc to use
|
|
321
|
-
* @param payer
|
|
322
|
-
* @param mint Mint
|
|
330
|
+
* @param rpc Rpc connection to use
|
|
331
|
+
* @param payer Fee payer
|
|
332
|
+
* @param mint SPL Mint address
|
|
323
333
|
* @param amount Number of tokens to transfer
|
|
324
334
|
* @param owner Owner of the compressed tokens
|
|
325
335
|
* @param toAddress Destination address of the recipient
|
|
326
336
|
* @param confirmOptions Options for confirming the transaction
|
|
327
337
|
*
|
|
328
|
-
* @return
|
|
338
|
+
* @return confirmed transaction signature
|
|
329
339
|
*/
|
|
330
340
|
declare function transferDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
331
341
|
|
|
@@ -333,25 +343,151 @@ declare function transferDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amo
|
|
|
333
343
|
* Decompress delegated compressed tokens. Remaining compressed tokens are
|
|
334
344
|
* returned to the owner without delegation.
|
|
335
345
|
*
|
|
336
|
-
* @param rpc Rpc to use
|
|
337
|
-
* @param payer
|
|
338
|
-
* @param mint Mint
|
|
346
|
+
* @param rpc Rpc connection to use
|
|
347
|
+
* @param payer Fee payer
|
|
348
|
+
* @param mint SPL Mint address
|
|
339
349
|
* @param amount Number of tokens to decompress
|
|
340
350
|
* @param owner Owner of the compressed tokens
|
|
341
|
-
* @param toAddress Destination **uncompressed**
|
|
342
|
-
*
|
|
343
|
-
* @param tokenPoolInfos Token pool infos
|
|
351
|
+
* @param toAddress Destination **uncompressed** token account
|
|
352
|
+
* address. (ATA)
|
|
353
|
+
* @param tokenPoolInfos Optional: Token pool infos.
|
|
344
354
|
* @param confirmOptions Options for confirming the transaction
|
|
345
355
|
*
|
|
346
356
|
* @return Signature of the confirmed transaction
|
|
347
357
|
*/
|
|
348
358
|
declare function decompressDelegated(rpc: Rpc, payer: Signer, mint: PublicKey, amount: number | BN, owner: Signer, toAddress: PublicKey, tokenPoolInfos?: TokenPoolInfo[], confirmOptions?: ConfirmOptions): Promise<TransactionSignature>;
|
|
349
359
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
360
|
+
declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for transfer.";
|
|
361
|
+
/**
|
|
362
|
+
* Selects token accounts for approval, first trying to find an exact match, then falling back to minimum selection.
|
|
363
|
+
*
|
|
364
|
+
* @param {ParsedTokenAccount[]} accounts - Token accounts to choose from.
|
|
365
|
+
* @param {BN} approveAmount - Amount to approve.
|
|
366
|
+
* @param {number} [maxInputs=4] - Max accounts to select when falling back to minimum selection.
|
|
367
|
+
* @returns {[
|
|
368
|
+
* selectedAccounts: ParsedTokenAccount[],
|
|
369
|
+
* total: BN,
|
|
370
|
+
* totalLamports: BN | null,
|
|
371
|
+
* maxPossibleAmount: BN
|
|
372
|
+
* ]} - Returns:
|
|
373
|
+
* - selectedAccounts: Accounts chosen for approval.
|
|
374
|
+
* - total: Total amount from selected accounts.
|
|
375
|
+
* - totalLamports: Total lamports from selected accounts.
|
|
376
|
+
* - maxPossibleAmount: Max approvable amount given maxInputs.
|
|
377
|
+
*/
|
|
378
|
+
declare function selectTokenAccountsForApprove(accounts: ParsedTokenAccount[], approveAmount: BN, maxInputs?: number): [
|
|
379
|
+
selectedAccounts: ParsedTokenAccount[],
|
|
380
|
+
total: BN,
|
|
381
|
+
totalLamports: BN | null,
|
|
382
|
+
maxPossibleAmount: BN
|
|
383
|
+
];
|
|
384
|
+
/**
|
|
385
|
+
* Selects the minimum number of compressed token accounts required for a
|
|
386
|
+
* decompress instruction, up to a specified maximum.
|
|
387
|
+
*
|
|
388
|
+
* @param {ParsedTokenAccount[]} accounts Token accounts to choose from.
|
|
389
|
+
* @param {BN} amount Amount to decompress.
|
|
390
|
+
* @param {number} [maxInputs=4] Max accounts to select. Default
|
|
391
|
+
* is 4.
|
|
392
|
+
*
|
|
393
|
+
* @returns Returns selected accounts and their totals.
|
|
394
|
+
*/
|
|
395
|
+
declare function selectMinCompressedTokenAccountsForDecompression(accounts: ParsedTokenAccount[], amount: BN, maxInputs?: number): {
|
|
396
|
+
selectedAccounts: ParsedTokenAccount[];
|
|
397
|
+
total: BN;
|
|
398
|
+
totalLamports: BN | null;
|
|
399
|
+
maxPossibleAmount: BN;
|
|
354
400
|
};
|
|
401
|
+
/**
|
|
402
|
+
* Selects the minimum number of compressed token accounts required for a
|
|
403
|
+
* transfer or decompression instruction, up to a specified maximum.
|
|
404
|
+
*
|
|
405
|
+
* @param {ParsedTokenAccount[]} accounts Token accounts to choose from.
|
|
406
|
+
* @param {BN} transferAmount Amount to transfer or decompress.
|
|
407
|
+
* @param {number} [maxInputs=4] Max accounts to select. Default
|
|
408
|
+
* is 4.
|
|
409
|
+
*
|
|
410
|
+
* @returns Returns selected accounts and their totals. [
|
|
411
|
+
* selectedAccounts: ParsedTokenAccount[],
|
|
412
|
+
* total: BN,
|
|
413
|
+
* totalLamports: BN | null,
|
|
414
|
+
* maxPossibleAmount: BN
|
|
415
|
+
* ]
|
|
416
|
+
*/
|
|
417
|
+
declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
418
|
+
selectedAccounts: ParsedTokenAccount[],
|
|
419
|
+
total: BN,
|
|
420
|
+
totalLamports: BN | null,
|
|
421
|
+
maxPossibleAmount: BN
|
|
422
|
+
];
|
|
423
|
+
/**
|
|
424
|
+
* Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,
|
|
425
|
+
* returns partial amounts if insufficient accounts are found instead of
|
|
426
|
+
* throwing an error.
|
|
427
|
+
*/
|
|
428
|
+
declare function selectMinCompressedTokenAccountsForTransferOrPartial(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
429
|
+
selectedAccounts: ParsedTokenAccount[],
|
|
430
|
+
total: BN,
|
|
431
|
+
totalLamports: BN | null,
|
|
432
|
+
maxPossibleAmount: BN
|
|
433
|
+
];
|
|
434
|
+
/**
|
|
435
|
+
* Selects compressed token accounts for a transfer, ensuring one extra account
|
|
436
|
+
* if possible, up to maxInputs.
|
|
437
|
+
*
|
|
438
|
+
* 1. Sorts accounts by amount (desc)
|
|
439
|
+
* 2. Selects accounts until transfer amount is met or maxInputs is reached,
|
|
440
|
+
* attempting to add one extra account if possible.
|
|
441
|
+
*
|
|
442
|
+
* @param {ParsedTokenAccount[]} accounts - The list of token accounts to select from.
|
|
443
|
+
* @param {BN} transferAmount - The token amount to be transferred.
|
|
444
|
+
* @param {number} [maxInputs=4] - The maximum number of accounts to select. Default: 4.
|
|
445
|
+
* @returns {[
|
|
446
|
+
* selectedAccounts: ParsedTokenAccount[],
|
|
447
|
+
* total: BN,
|
|
448
|
+
* totalLamports: BN | null,
|
|
449
|
+
* maxPossibleAmount: BN
|
|
450
|
+
* ]} - An array containing:
|
|
451
|
+
* - selectedAccounts: The accounts selected for the transfer.
|
|
452
|
+
* - total: The total amount accumulated from the selected accounts.
|
|
453
|
+
* - totalLamports: The total lamports accumulated from the selected accounts.
|
|
454
|
+
* - maxPossibleAmount: The maximum possible amount that can be transferred considering maxInputs.
|
|
455
|
+
*
|
|
456
|
+
* @example
|
|
457
|
+
* const accounts = [
|
|
458
|
+
* { parsed: { amount: new BN(100) }, compressedAccount: { lamports: new BN(10) } },
|
|
459
|
+
* { parsed: { amount: new BN(50) }, compressedAccount: { lamports: new BN(5) } },
|
|
460
|
+
* { parsed: { amount: new BN(25) }, compressedAccount: { lamports: new BN(2) } },
|
|
461
|
+
* ];
|
|
462
|
+
* const transferAmount = new BN(75);
|
|
463
|
+
* const maxInputs = 2;
|
|
464
|
+
*
|
|
465
|
+
* const [selectedAccounts, total, totalLamports, maxPossibleAmount] =
|
|
466
|
+
* selectSmartCompressedTokenAccountsForTransfer(accounts, transferAmount, maxInputs);
|
|
467
|
+
*
|
|
468
|
+
* console.log(selectedAccounts.length); // 2
|
|
469
|
+
* console.log(total.toString()); // '150'
|
|
470
|
+
* console.log(totalLamports!.toString()); // '15'
|
|
471
|
+
* console.log(maxPossibleAmount.toString()); // '150'
|
|
472
|
+
*/
|
|
473
|
+
declare function selectSmartCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
474
|
+
selectedAccounts: ParsedTokenAccount[],
|
|
475
|
+
total: BN,
|
|
476
|
+
totalLamports: BN | null,
|
|
477
|
+
maxPossibleAmount: BN
|
|
478
|
+
];
|
|
479
|
+
/**
|
|
480
|
+
* Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,
|
|
481
|
+
* returns partial amounts if insufficient accounts are found instead of
|
|
482
|
+
* throwing an error.
|
|
483
|
+
*/
|
|
484
|
+
declare function selectSmartCompressedTokenAccountsForTransferOrPartial(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
485
|
+
selectedAccounts: ParsedTokenAccount[],
|
|
486
|
+
total: BN,
|
|
487
|
+
totalLamports: BN | null,
|
|
488
|
+
maxPossibleAmount: BN
|
|
489
|
+
];
|
|
490
|
+
|
|
355
491
|
type TokenTransferOutputData = {
|
|
356
492
|
/**
|
|
357
493
|
* The owner of the output token account
|
|
@@ -395,7 +531,7 @@ type PackedTokenTransferOutputData = {
|
|
|
395
531
|
type InputTokenDataWithContext = {
|
|
396
532
|
amount: BN;
|
|
397
533
|
delegateIndex: number | null;
|
|
398
|
-
merkleContext:
|
|
534
|
+
merkleContext: PackedMerkleContextLegacy;
|
|
399
535
|
rootIndex: number;
|
|
400
536
|
lamports: BN | null;
|
|
401
537
|
tlv: Buffer | null;
|
|
@@ -404,6 +540,14 @@ type DelegatedTransfer = {
|
|
|
404
540
|
owner: PublicKey;
|
|
405
541
|
delegateChangeAccountIndex: number | null;
|
|
406
542
|
};
|
|
543
|
+
type BatchCompressInstructionData = {
|
|
544
|
+
pubkeys: PublicKey[];
|
|
545
|
+
amounts: BN[] | null;
|
|
546
|
+
lamports: BN | null;
|
|
547
|
+
amount: BN | null;
|
|
548
|
+
index: number;
|
|
549
|
+
bump: number;
|
|
550
|
+
};
|
|
407
551
|
type MintToInstructionData = {
|
|
408
552
|
recipients: PublicKey[];
|
|
409
553
|
amounts: BN[];
|
|
@@ -426,7 +570,6 @@ type CompressedTokenInstructionDataTransfer = {
|
|
|
426
570
|
mint: PublicKey;
|
|
427
571
|
/**
|
|
428
572
|
* Whether the signer is a delegate
|
|
429
|
-
* TODO: implement delegated transfer struct
|
|
430
573
|
*/
|
|
431
574
|
delegatedTransfer: DelegatedTransfer | null;
|
|
432
575
|
/**
|
|
@@ -483,7 +626,7 @@ type TokenData = {
|
|
|
483
626
|
tlv: Buffer | null;
|
|
484
627
|
};
|
|
485
628
|
type CompressedTokenInstructionDataApprove = {
|
|
486
|
-
proof: ValidityProof;
|
|
629
|
+
proof: ValidityProof | null;
|
|
487
630
|
mint: PublicKey;
|
|
488
631
|
inputTokenDataWithContext: InputTokenDataWithContext[];
|
|
489
632
|
cpiContext: CompressedCpiContext | null;
|
|
@@ -494,7 +637,7 @@ type CompressedTokenInstructionDataApprove = {
|
|
|
494
637
|
delegateLamports: BN | null;
|
|
495
638
|
};
|
|
496
639
|
type CompressedTokenInstructionDataRevoke = {
|
|
497
|
-
proof: ValidityProof;
|
|
640
|
+
proof: ValidityProof | null;
|
|
498
641
|
mint: PublicKey;
|
|
499
642
|
inputTokenDataWithContext: InputTokenDataWithContext[];
|
|
500
643
|
cpiContext: CompressedCpiContext | null;
|
|
@@ -509,7 +652,7 @@ type PackCompressedTokenAccountsParams = {
|
|
|
509
652
|
* state tree of the input state. Gets padded to the length of
|
|
510
653
|
* outputCompressedAccounts.
|
|
511
654
|
*/
|
|
512
|
-
outputStateTreeInfo?:
|
|
655
|
+
outputStateTreeInfo?: TreeInfo;
|
|
513
656
|
/** Optional remaining accounts to append to */
|
|
514
657
|
remainingAccounts?: PublicKey[];
|
|
515
658
|
/**
|
|
@@ -528,142 +671,21 @@ declare function packCompressedTokenAccounts(params: PackCompressedTokenAccounts
|
|
|
528
671
|
packedOutputTokenData: PackedTokenTransferOutputData[];
|
|
529
672
|
};
|
|
530
673
|
|
|
531
|
-
declare const ERROR_NO_ACCOUNTS_FOUND = "Could not find accounts to select for transfer.";
|
|
532
|
-
/**
|
|
533
|
-
* Selects token accounts for approval, first trying to find an exact match, then falling back to minimum selection.
|
|
534
|
-
*
|
|
535
|
-
* @param {ParsedTokenAccount[]} accounts - Token accounts to choose from.
|
|
536
|
-
* @param {BN} approveAmount - Amount to approve.
|
|
537
|
-
* @param {number} [maxInputs=4] - Max accounts to select when falling back to minimum selection.
|
|
538
|
-
* @returns {[
|
|
539
|
-
* selectedAccounts: ParsedTokenAccount[],
|
|
540
|
-
* total: BN,
|
|
541
|
-
* totalLamports: BN | null,
|
|
542
|
-
* maxPossibleAmount: BN
|
|
543
|
-
* ]} - Returns:
|
|
544
|
-
* - selectedAccounts: Accounts chosen for approval.
|
|
545
|
-
* - total: Total amount from selected accounts.
|
|
546
|
-
* - totalLamports: Total lamports from selected accounts.
|
|
547
|
-
* - maxPossibleAmount: Max approvable amount given maxInputs.
|
|
548
|
-
*/
|
|
549
|
-
declare function selectTokenAccountsForApprove(accounts: ParsedTokenAccount[], approveAmount: BN, maxInputs?: number): [
|
|
550
|
-
selectedAccounts: ParsedTokenAccount[],
|
|
551
|
-
total: BN,
|
|
552
|
-
totalLamports: BN | null,
|
|
553
|
-
maxPossibleAmount: BN
|
|
554
|
-
];
|
|
555
|
-
/**
|
|
556
|
-
* Selects the minimum number of compressed token accounts required for a
|
|
557
|
-
* decompress instruction, up to a specified maximum.
|
|
558
|
-
*
|
|
559
|
-
* @param {ParsedTokenAccount[]} accounts Token accounts to choose from.
|
|
560
|
-
* @param {BN} amount Amount to decompress.
|
|
561
|
-
* @param {number} [maxInputs=4] Max accounts to select. Default
|
|
562
|
-
* is 4.
|
|
563
|
-
*
|
|
564
|
-
* @returns Returns selected accounts and their totals.
|
|
565
|
-
*/
|
|
566
|
-
declare function selectMinCompressedTokenAccountsForDecompression(accounts: ParsedTokenAccount[], amount: BN, maxInputs?: number): {
|
|
567
|
-
selectedAccounts: ParsedTokenAccount[];
|
|
568
|
-
total: BN;
|
|
569
|
-
totalLamports: BN | null;
|
|
570
|
-
maxPossibleAmount: BN;
|
|
571
|
-
};
|
|
572
674
|
/**
|
|
573
|
-
*
|
|
574
|
-
* transfer or decompression instruction, up to a specified maximum.
|
|
675
|
+
* Check if all input accounts belong to the same mint.
|
|
575
676
|
*
|
|
576
|
-
* @param
|
|
577
|
-
* @param
|
|
578
|
-
* @
|
|
579
|
-
* is 4.
|
|
580
|
-
*
|
|
581
|
-
* @returns Returns selected accounts and their totals. [
|
|
582
|
-
* selectedAccounts: ParsedTokenAccount[],
|
|
583
|
-
* total: BN,
|
|
584
|
-
* totalLamports: BN | null,
|
|
585
|
-
* maxPossibleAmount: BN
|
|
586
|
-
* ]
|
|
587
|
-
*/
|
|
588
|
-
declare function selectMinCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
589
|
-
selectedAccounts: ParsedTokenAccount[],
|
|
590
|
-
total: BN,
|
|
591
|
-
totalLamports: BN | null,
|
|
592
|
-
maxPossibleAmount: BN
|
|
593
|
-
];
|
|
594
|
-
/**
|
|
595
|
-
* Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,
|
|
596
|
-
* returns partial amounts if insufficient accounts are found instead of
|
|
597
|
-
* throwing an error.
|
|
677
|
+
* @param compressedTokenAccounts The compressed token accounts
|
|
678
|
+
* @param mint The mint of the token pool
|
|
679
|
+
* @returns True if all input accounts belong to the same mint
|
|
598
680
|
*/
|
|
599
|
-
declare function
|
|
600
|
-
selectedAccounts: ParsedTokenAccount[],
|
|
601
|
-
total: BN,
|
|
602
|
-
totalLamports: BN | null,
|
|
603
|
-
maxPossibleAmount: BN
|
|
604
|
-
];
|
|
605
|
-
/**
|
|
606
|
-
* Selects compressed token accounts for a transfer, ensuring one extra account
|
|
607
|
-
* if possible, up to maxInputs.
|
|
608
|
-
*
|
|
609
|
-
* 1. Sorts accounts by amount (desc)
|
|
610
|
-
* 2. Selects accounts until transfer amount is met or maxInputs is reached,
|
|
611
|
-
* attempting to add one extra account if possible.
|
|
612
|
-
*
|
|
613
|
-
* @param {ParsedTokenAccount[]} accounts - The list of token accounts to select from.
|
|
614
|
-
* @param {BN} transferAmount - The token amount to be transferred.
|
|
615
|
-
* @param {number} [maxInputs=4] - The maximum number of accounts to select. Default: 4.
|
|
616
|
-
* @returns {[
|
|
617
|
-
* selectedAccounts: ParsedTokenAccount[],
|
|
618
|
-
* total: BN,
|
|
619
|
-
* totalLamports: BN | null,
|
|
620
|
-
* maxPossibleAmount: BN
|
|
621
|
-
* ]} - An array containing:
|
|
622
|
-
* - selectedAccounts: The accounts selected for the transfer.
|
|
623
|
-
* - total: The total amount accumulated from the selected accounts.
|
|
624
|
-
* - totalLamports: The total lamports accumulated from the selected accounts.
|
|
625
|
-
* - maxPossibleAmount: The maximum possible amount that can be transferred considering maxInputs.
|
|
626
|
-
*
|
|
627
|
-
* @example
|
|
628
|
-
* const accounts = [
|
|
629
|
-
* { parsed: { amount: new BN(100) }, compressedAccount: { lamports: new BN(10) } },
|
|
630
|
-
* { parsed: { amount: new BN(50) }, compressedAccount: { lamports: new BN(5) } },
|
|
631
|
-
* { parsed: { amount: new BN(25) }, compressedAccount: { lamports: new BN(2) } },
|
|
632
|
-
* ];
|
|
633
|
-
* const transferAmount = new BN(75);
|
|
634
|
-
* const maxInputs = 2;
|
|
635
|
-
*
|
|
636
|
-
* const [selectedAccounts, total, totalLamports, maxPossibleAmount] =
|
|
637
|
-
* selectSmartCompressedTokenAccountsForTransfer(accounts, transferAmount, maxInputs);
|
|
638
|
-
*
|
|
639
|
-
* console.log(selectedAccounts.length); // 2
|
|
640
|
-
* console.log(total.toString()); // '150'
|
|
641
|
-
* console.log(totalLamports!.toString()); // '15'
|
|
642
|
-
* console.log(maxPossibleAmount.toString()); // '150'
|
|
643
|
-
*/
|
|
644
|
-
declare function selectSmartCompressedTokenAccountsForTransfer(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
645
|
-
selectedAccounts: ParsedTokenAccount[],
|
|
646
|
-
total: BN,
|
|
647
|
-
totalLamports: BN | null,
|
|
648
|
-
maxPossibleAmount: BN
|
|
649
|
-
];
|
|
650
|
-
/**
|
|
651
|
-
* Executes {@link selectMinCompressedTokenAccountsForTransfer} strategy,
|
|
652
|
-
* returns partial amounts if insufficient accounts are found instead of
|
|
653
|
-
* throwing an error.
|
|
654
|
-
*/
|
|
655
|
-
declare function selectSmartCompressedTokenAccountsForTransferOrPartial(accounts: ParsedTokenAccount[], transferAmount: BN, maxInputs?: number): [
|
|
656
|
-
selectedAccounts: ParsedTokenAccount[],
|
|
657
|
-
total: BN,
|
|
658
|
-
totalLamports: BN | null,
|
|
659
|
-
maxPossibleAmount: BN
|
|
660
|
-
];
|
|
681
|
+
declare function checkMint(compressedTokenAccounts: ParsedTokenAccount[], mint: PublicKey): boolean;
|
|
661
682
|
|
|
662
683
|
declare const POOL_SEED: Buffer;
|
|
663
684
|
declare const CPI_AUTHORITY_SEED: Buffer;
|
|
664
685
|
declare const SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE = 1461600;
|
|
665
686
|
declare const CREATE_TOKEN_POOL_DISCRIMINATOR: Buffer;
|
|
666
687
|
declare const MINT_TO_DISCRIMINATOR: Buffer;
|
|
688
|
+
declare const BATCH_COMPRESS_DISCRIMINATOR: Buffer;
|
|
667
689
|
declare const TRANSFER_DISCRIMINATOR: Buffer;
|
|
668
690
|
declare const COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR: Buffer;
|
|
669
691
|
declare const APPROVE_DISCRIMINATOR: Buffer;
|
|
@@ -2153,7 +2175,7 @@ type LightCompressedToken = {
|
|
|
2153
2175
|
type: 'u8';
|
|
2154
2176
|
},
|
|
2155
2177
|
{
|
|
2156
|
-
name: '
|
|
2178
|
+
name: 'queuePubkeyIndex';
|
|
2157
2179
|
type: 'u8';
|
|
2158
2180
|
},
|
|
2159
2181
|
{
|
|
@@ -2161,12 +2183,8 @@ type LightCompressedToken = {
|
|
|
2161
2183
|
type: 'u32';
|
|
2162
2184
|
},
|
|
2163
2185
|
{
|
|
2164
|
-
name: '
|
|
2165
|
-
type:
|
|
2166
|
-
option: {
|
|
2167
|
-
defined: 'QueueIndex';
|
|
2168
|
-
};
|
|
2169
|
-
};
|
|
2186
|
+
name: 'proveByIndex';
|
|
2187
|
+
type: 'bool';
|
|
2170
2188
|
}
|
|
2171
2189
|
];
|
|
2172
2190
|
};
|
|
@@ -2512,9 +2530,12 @@ declare const DelegatedTransferLayout: buffer_layout.Layout<unknown>;
|
|
|
2512
2530
|
declare const CpiContextLayout: buffer_layout.Layout<unknown>;
|
|
2513
2531
|
declare const CompressedTokenInstructionDataTransferLayout: buffer_layout.Layout<unknown>;
|
|
2514
2532
|
declare const mintToLayout: buffer_layout.Layout<unknown>;
|
|
2533
|
+
declare const batchCompressLayout: buffer_layout.Layout<unknown>;
|
|
2515
2534
|
declare const compressSplTokenAccountInstructionDataLayout: buffer_layout.Layout<unknown>;
|
|
2516
2535
|
declare function encodeMintToInstructionData(data: MintToInstructionData): Buffer;
|
|
2517
2536
|
declare function decodeMintToInstructionData(buffer: Buffer): MintToInstructionData;
|
|
2537
|
+
declare function encodeBatchCompressInstructionData(data: BatchCompressInstructionData): Buffer;
|
|
2538
|
+
declare function decodeBatchCompressInstructionData(buffer: Buffer): BatchCompressInstructionData;
|
|
2518
2539
|
declare function encodeCompressSplTokenAccountInstructionData(data: CompressSplTokenAccountInstructionData): Buffer;
|
|
2519
2540
|
declare function decodeCompressSplTokenAccountInstructionData(buffer: Buffer): CompressSplTokenAccountInstructionData;
|
|
2520
2541
|
declare function encodeTransferInstructionData(data: CompressedTokenInstructionDataTransfer): Buffer;
|
|
@@ -2577,109 +2598,105 @@ declare function decodeRevokeInstructionData(buffer: Buffer): CompressedTokenIns
|
|
|
2577
2598
|
|
|
2578
2599
|
type CompressParams = {
|
|
2579
2600
|
/**
|
|
2580
|
-
*
|
|
2601
|
+
* Fee payer
|
|
2581
2602
|
*/
|
|
2582
2603
|
payer: PublicKey;
|
|
2583
2604
|
/**
|
|
2584
|
-
*
|
|
2605
|
+
* Owner of uncompressed token account
|
|
2585
2606
|
*/
|
|
2586
2607
|
owner: PublicKey;
|
|
2587
2608
|
/**
|
|
2588
|
-
*
|
|
2609
|
+
* Source SPL Token account address
|
|
2589
2610
|
*/
|
|
2590
2611
|
source: PublicKey;
|
|
2591
2612
|
/**
|
|
2592
|
-
*
|
|
2593
|
-
* To compress to a batch of recipients, pass an array of PublicKeys.
|
|
2613
|
+
* Recipient address(es)
|
|
2594
2614
|
*/
|
|
2595
2615
|
toAddress: PublicKey | PublicKey[];
|
|
2596
2616
|
/**
|
|
2597
|
-
*
|
|
2617
|
+
* Token amount(s) to compress
|
|
2598
2618
|
*/
|
|
2599
|
-
|
|
2619
|
+
amount: number | BN | number[] | BN[];
|
|
2600
2620
|
/**
|
|
2601
|
-
*
|
|
2621
|
+
* SPL Token mint address
|
|
2602
2622
|
*/
|
|
2603
|
-
|
|
2623
|
+
mint: PublicKey;
|
|
2604
2624
|
/**
|
|
2605
|
-
*
|
|
2606
|
-
* public state tree if unspecified.
|
|
2625
|
+
* State tree to write to
|
|
2607
2626
|
*/
|
|
2608
|
-
outputStateTreeInfo:
|
|
2627
|
+
outputStateTreeInfo: TreeInfo;
|
|
2609
2628
|
/**
|
|
2610
|
-
*
|
|
2629
|
+
* Token pool
|
|
2611
2630
|
*/
|
|
2612
2631
|
tokenPoolInfo: TokenPoolInfo;
|
|
2613
2632
|
};
|
|
2614
2633
|
type CompressSplTokenAccountParams = {
|
|
2615
2634
|
/**
|
|
2616
|
-
*
|
|
2635
|
+
* Fee payer
|
|
2617
2636
|
*/
|
|
2618
2637
|
feePayer: PublicKey;
|
|
2619
2638
|
/**
|
|
2620
|
-
*
|
|
2639
|
+
* SPL Token account owner
|
|
2621
2640
|
*/
|
|
2622
2641
|
authority: PublicKey;
|
|
2623
2642
|
/**
|
|
2624
|
-
* Token account to compress
|
|
2643
|
+
* SPL Token account to compress
|
|
2625
2644
|
*/
|
|
2626
2645
|
tokenAccount: PublicKey;
|
|
2627
2646
|
/**
|
|
2628
|
-
*
|
|
2647
|
+
* SPL Token mint address
|
|
2629
2648
|
*/
|
|
2630
2649
|
mint: PublicKey;
|
|
2631
2650
|
/**
|
|
2632
|
-
*
|
|
2651
|
+
* Amount to leave in token account
|
|
2633
2652
|
*/
|
|
2634
2653
|
remainingAmount?: BN;
|
|
2635
2654
|
/**
|
|
2636
|
-
*
|
|
2655
|
+
* State tree to write to
|
|
2637
2656
|
*/
|
|
2638
|
-
outputStateTreeInfo:
|
|
2657
|
+
outputStateTreeInfo: TreeInfo;
|
|
2639
2658
|
/**
|
|
2640
|
-
*
|
|
2659
|
+
* Token pool
|
|
2641
2660
|
*/
|
|
2642
2661
|
tokenPoolInfo: TokenPoolInfo;
|
|
2643
2662
|
};
|
|
2644
2663
|
type DecompressParams = {
|
|
2645
2664
|
/**
|
|
2646
|
-
*
|
|
2665
|
+
* Fee payer
|
|
2647
2666
|
*/
|
|
2648
2667
|
payer: PublicKey;
|
|
2649
2668
|
/**
|
|
2650
|
-
*
|
|
2669
|
+
* Source compressed token accounts
|
|
2651
2670
|
*/
|
|
2652
2671
|
inputCompressedTokenAccounts: ParsedTokenAccount[];
|
|
2653
2672
|
/**
|
|
2654
|
-
*
|
|
2673
|
+
* Destination uncompressed token account
|
|
2655
2674
|
*/
|
|
2656
2675
|
toAddress: PublicKey;
|
|
2657
2676
|
/**
|
|
2658
|
-
* amount
|
|
2677
|
+
* Token amount to decompress
|
|
2659
2678
|
*/
|
|
2660
2679
|
amount: number | BN;
|
|
2661
2680
|
/**
|
|
2662
|
-
*
|
|
2663
|
-
* the proof.
|
|
2681
|
+
* Validity proof for input state
|
|
2664
2682
|
*/
|
|
2665
|
-
|
|
2683
|
+
recentValidityProof: ValidityProof | CompressedProof | null;
|
|
2666
2684
|
/**
|
|
2667
|
-
*
|
|
2668
|
-
* expires after n slots.
|
|
2685
|
+
* Recent state root indices
|
|
2669
2686
|
*/
|
|
2670
|
-
|
|
2687
|
+
recentInputStateRootIndices: number[];
|
|
2671
2688
|
/**
|
|
2672
|
-
*
|
|
2689
|
+
* Token pool(s)
|
|
2673
2690
|
*/
|
|
2674
2691
|
tokenPoolInfos: TokenPoolInfo | TokenPoolInfo[];
|
|
2675
2692
|
};
|
|
2676
2693
|
type TransferParams = {
|
|
2677
2694
|
/**
|
|
2678
|
-
*
|
|
2695
|
+
* Fee payer
|
|
2679
2696
|
*/
|
|
2680
2697
|
payer: PublicKey;
|
|
2681
2698
|
/**
|
|
2682
|
-
*
|
|
2699
|
+
* Source compressed token accounts
|
|
2683
2700
|
*/
|
|
2684
2701
|
inputCompressedTokenAccounts: ParsedTokenAccount[];
|
|
2685
2702
|
/**
|
|
@@ -2687,65 +2704,86 @@ type TransferParams = {
|
|
|
2687
2704
|
*/
|
|
2688
2705
|
toAddress: PublicKey;
|
|
2689
2706
|
/**
|
|
2690
|
-
*
|
|
2707
|
+
* Token amount to transfer
|
|
2691
2708
|
*/
|
|
2692
2709
|
amount: BN | number;
|
|
2693
2710
|
/**
|
|
2694
|
-
*
|
|
2695
|
-
|
|
2711
|
+
* Validity proof for input state
|
|
2712
|
+
*/
|
|
2713
|
+
recentValidityProof: ValidityProof | CompressedProof | null;
|
|
2714
|
+
/**
|
|
2715
|
+
* Recent state root indices
|
|
2696
2716
|
*/
|
|
2697
2717
|
recentInputStateRootIndices: number[];
|
|
2718
|
+
};
|
|
2719
|
+
type ApproveParams = {
|
|
2698
2720
|
/**
|
|
2699
|
-
*
|
|
2700
|
-
* expires after n slots.
|
|
2721
|
+
* Fee payer
|
|
2701
2722
|
*/
|
|
2702
|
-
|
|
2723
|
+
payer: PublicKey;
|
|
2724
|
+
/**
|
|
2725
|
+
* Source compressed token accounts
|
|
2726
|
+
*/
|
|
2727
|
+
inputCompressedTokenAccounts: ParsedTokenAccount[];
|
|
2728
|
+
/**
|
|
2729
|
+
* Recipient address
|
|
2730
|
+
*/
|
|
2731
|
+
toAddress: PublicKey;
|
|
2732
|
+
/**
|
|
2733
|
+
* Token amount to approve
|
|
2734
|
+
*/
|
|
2735
|
+
amount: BN | number;
|
|
2736
|
+
/**
|
|
2737
|
+
* Validity proof for input state
|
|
2738
|
+
*/
|
|
2739
|
+
recentValidityProof: ValidityProof | CompressedProof | null;
|
|
2740
|
+
/**
|
|
2741
|
+
* Recent state root indices
|
|
2742
|
+
*/
|
|
2743
|
+
recentInputStateRootIndices: number[];
|
|
2703
2744
|
};
|
|
2704
|
-
type ApproveParams = TransferParams;
|
|
2705
2745
|
type RevokeParams = {
|
|
2706
2746
|
/**
|
|
2707
|
-
*
|
|
2747
|
+
* Fee payer
|
|
2708
2748
|
*/
|
|
2709
2749
|
payer: PublicKey;
|
|
2710
2750
|
/**
|
|
2711
|
-
*
|
|
2751
|
+
* Input compressed token accounts
|
|
2712
2752
|
*/
|
|
2713
2753
|
inputCompressedTokenAccounts: ParsedTokenAccount[];
|
|
2714
2754
|
/**
|
|
2715
|
-
*
|
|
2716
|
-
* the proof.
|
|
2755
|
+
* Validity proof for input state
|
|
2717
2756
|
*/
|
|
2718
|
-
|
|
2757
|
+
recentValidityProof: ValidityProof | CompressedProof | null;
|
|
2719
2758
|
/**
|
|
2720
|
-
*
|
|
2721
|
-
* expires after n slots.
|
|
2759
|
+
* Recent state root indices
|
|
2722
2760
|
*/
|
|
2723
|
-
|
|
2761
|
+
recentInputStateRootIndices: number[];
|
|
2724
2762
|
};
|
|
2725
2763
|
/**
|
|
2726
2764
|
* Create Mint account for compressed Tokens
|
|
2727
2765
|
*/
|
|
2728
2766
|
type CreateMintParams = {
|
|
2729
2767
|
/**
|
|
2730
|
-
*
|
|
2768
|
+
* Fee payer
|
|
2731
2769
|
*/
|
|
2732
2770
|
feePayer: PublicKey;
|
|
2771
|
+
/**
|
|
2772
|
+
* SPL Mint address
|
|
2773
|
+
*/
|
|
2774
|
+
mint: PublicKey;
|
|
2733
2775
|
/**
|
|
2734
2776
|
* Mint authority
|
|
2735
2777
|
*/
|
|
2736
2778
|
authority: PublicKey;
|
|
2737
2779
|
/**
|
|
2738
|
-
*
|
|
2780
|
+
* Optional: freeze authority
|
|
2739
2781
|
*/
|
|
2740
|
-
|
|
2782
|
+
freezeAuthority: PublicKey | null;
|
|
2741
2783
|
/**
|
|
2742
2784
|
* Mint decimals
|
|
2743
2785
|
*/
|
|
2744
2786
|
decimals: number;
|
|
2745
|
-
/**
|
|
2746
|
-
* Optional: freeze authority
|
|
2747
|
-
*/
|
|
2748
|
-
freezeAuthority: PublicKey | null;
|
|
2749
2787
|
/**
|
|
2750
2788
|
* lamport amount for mint account rent exemption
|
|
2751
2789
|
*/
|
|
@@ -2764,15 +2802,15 @@ type CreateMintParams = {
|
|
|
2764
2802
|
*/
|
|
2765
2803
|
type MergeTokenAccountsParams = {
|
|
2766
2804
|
/**
|
|
2767
|
-
*
|
|
2805
|
+
* Fee payer
|
|
2768
2806
|
*/
|
|
2769
2807
|
payer: PublicKey;
|
|
2770
2808
|
/**
|
|
2771
|
-
* Owner of the token accounts to be merged
|
|
2809
|
+
* Owner of the compressed token accounts to be merged
|
|
2772
2810
|
*/
|
|
2773
2811
|
owner: PublicKey;
|
|
2774
2812
|
/**
|
|
2775
|
-
*
|
|
2813
|
+
* SPL Token mint address
|
|
2776
2814
|
*/
|
|
2777
2815
|
mint: PublicKey;
|
|
2778
2816
|
/**
|
|
@@ -2780,11 +2818,11 @@ type MergeTokenAccountsParams = {
|
|
|
2780
2818
|
*/
|
|
2781
2819
|
inputCompressedTokenAccounts: ParsedTokenAccount[];
|
|
2782
2820
|
/**
|
|
2783
|
-
*
|
|
2821
|
+
* Validity proof for state inclusion
|
|
2784
2822
|
*/
|
|
2785
|
-
recentValidityProof: ValidityProof;
|
|
2823
|
+
recentValidityProof: ValidityProof | CompressedProof | null;
|
|
2786
2824
|
/**
|
|
2787
|
-
*
|
|
2825
|
+
* State root indices of the input state
|
|
2788
2826
|
*/
|
|
2789
2827
|
recentInputStateRootIndices: number[];
|
|
2790
2828
|
};
|
|
@@ -2793,31 +2831,31 @@ type MergeTokenAccountsParams = {
|
|
|
2793
2831
|
*/
|
|
2794
2832
|
type MintToParams = {
|
|
2795
2833
|
/**
|
|
2796
|
-
*
|
|
2834
|
+
* Fee payer
|
|
2797
2835
|
*/
|
|
2798
2836
|
feePayer: PublicKey;
|
|
2799
2837
|
/**
|
|
2800
|
-
*
|
|
2838
|
+
* Token mint address
|
|
2801
2839
|
*/
|
|
2802
|
-
|
|
2840
|
+
mint: PublicKey;
|
|
2803
2841
|
/**
|
|
2804
|
-
* Mint
|
|
2842
|
+
* Mint authority
|
|
2805
2843
|
*/
|
|
2806
|
-
|
|
2844
|
+
authority: PublicKey;
|
|
2807
2845
|
/**
|
|
2808
|
-
*
|
|
2846
|
+
* Recipient address(es)
|
|
2809
2847
|
*/
|
|
2810
2848
|
toPubkey: PublicKey[] | PublicKey;
|
|
2811
2849
|
/**
|
|
2812
|
-
*
|
|
2850
|
+
* Token amount(s) to mint
|
|
2813
2851
|
*/
|
|
2814
2852
|
amount: BN | BN[] | number | number[];
|
|
2815
2853
|
/**
|
|
2816
|
-
*
|
|
2854
|
+
* State tree for minted tokens
|
|
2817
2855
|
*/
|
|
2818
|
-
outputStateTreeInfo:
|
|
2856
|
+
outputStateTreeInfo: TreeInfo;
|
|
2819
2857
|
/**
|
|
2820
|
-
*
|
|
2858
|
+
* Token pool
|
|
2821
2859
|
*/
|
|
2822
2860
|
tokenPoolInfo: TokenPoolInfo;
|
|
2823
2861
|
};
|
|
@@ -2825,13 +2863,13 @@ type MintToParams = {
|
|
|
2825
2863
|
* Register an existing SPL mint account to the compressed token program
|
|
2826
2864
|
* Creates an omnibus account for the mint
|
|
2827
2865
|
*/
|
|
2828
|
-
type
|
|
2866
|
+
type CreateTokenPoolParams = {
|
|
2829
2867
|
/**
|
|
2830
|
-
*
|
|
2868
|
+
* Fee payer
|
|
2831
2869
|
*/
|
|
2832
2870
|
feePayer: PublicKey;
|
|
2833
2871
|
/**
|
|
2834
|
-
* Mint
|
|
2872
|
+
* SPL Mint address
|
|
2835
2873
|
*/
|
|
2836
2874
|
mint: PublicKey;
|
|
2837
2875
|
/**
|
|
@@ -2841,30 +2879,34 @@ type RegisterMintParams = {
|
|
|
2841
2879
|
};
|
|
2842
2880
|
type AddTokenPoolParams = {
|
|
2843
2881
|
/**
|
|
2844
|
-
*
|
|
2882
|
+
* Fee payer
|
|
2845
2883
|
*/
|
|
2846
2884
|
feePayer: PublicKey;
|
|
2847
2885
|
/**
|
|
2848
|
-
*
|
|
2886
|
+
* Token mint address
|
|
2849
2887
|
*/
|
|
2850
2888
|
mint: PublicKey;
|
|
2851
2889
|
/**
|
|
2852
|
-
*
|
|
2890
|
+
* Token pool index
|
|
2853
2891
|
*/
|
|
2854
|
-
|
|
2892
|
+
poolIndex: number;
|
|
2855
2893
|
/**
|
|
2856
|
-
* Optional:
|
|
2894
|
+
* Optional: Token program ID. Default: SPL Token Program ID
|
|
2857
2895
|
*/
|
|
2858
|
-
|
|
2896
|
+
tokenProgramId?: PublicKey;
|
|
2859
2897
|
};
|
|
2860
2898
|
/**
|
|
2861
2899
|
* Mint from existing SPL mint to compressed token accounts
|
|
2862
2900
|
*/
|
|
2863
2901
|
type ApproveAndMintToParams = {
|
|
2864
2902
|
/**
|
|
2865
|
-
*
|
|
2903
|
+
* Fee payer
|
|
2866
2904
|
*/
|
|
2867
2905
|
feePayer: PublicKey;
|
|
2906
|
+
/**
|
|
2907
|
+
* SPL Mint address
|
|
2908
|
+
*/
|
|
2909
|
+
mint: PublicKey;
|
|
2868
2910
|
/**
|
|
2869
2911
|
* Mint authority
|
|
2870
2912
|
*/
|
|
@@ -2874,46 +2916,41 @@ type ApproveAndMintToParams = {
|
|
|
2874
2916
|
*/
|
|
2875
2917
|
authorityTokenAccount: PublicKey;
|
|
2876
2918
|
/**
|
|
2877
|
-
*
|
|
2878
|
-
*/
|
|
2879
|
-
mint: PublicKey;
|
|
2880
|
-
/**
|
|
2881
|
-
* The Solana Public Key to mint to.
|
|
2919
|
+
* Recipient address
|
|
2882
2920
|
*/
|
|
2883
2921
|
toPubkey: PublicKey;
|
|
2884
2922
|
/**
|
|
2885
|
-
*
|
|
2923
|
+
* Token amount to mint
|
|
2886
2924
|
*/
|
|
2887
2925
|
amount: BN | number;
|
|
2888
2926
|
/**
|
|
2889
|
-
*
|
|
2890
|
-
* tree if unspecified.
|
|
2927
|
+
* State tree to write to
|
|
2891
2928
|
*/
|
|
2892
|
-
outputStateTreeInfo:
|
|
2929
|
+
outputStateTreeInfo: TreeInfo;
|
|
2893
2930
|
/**
|
|
2894
|
-
*
|
|
2931
|
+
* Token pool
|
|
2895
2932
|
*/
|
|
2896
2933
|
tokenPoolInfo: TokenPoolInfo;
|
|
2897
2934
|
};
|
|
2898
2935
|
type CreateTokenProgramLookupTableParams = {
|
|
2899
2936
|
/**
|
|
2900
|
-
*
|
|
2937
|
+
* Fee payer
|
|
2901
2938
|
*/
|
|
2902
2939
|
payer: PublicKey;
|
|
2903
2940
|
/**
|
|
2904
|
-
*
|
|
2941
|
+
* Authority of the transaction
|
|
2905
2942
|
*/
|
|
2906
2943
|
authority: PublicKey;
|
|
2907
2944
|
/**
|
|
2908
|
-
*
|
|
2945
|
+
* Optional Mint addresses to store in the lookup table
|
|
2909
2946
|
*/
|
|
2910
|
-
|
|
2947
|
+
mints?: PublicKey[];
|
|
2911
2948
|
/**
|
|
2912
|
-
*
|
|
2949
|
+
* Recently finalized Solana slot
|
|
2913
2950
|
*/
|
|
2914
|
-
|
|
2951
|
+
recentSlot: number;
|
|
2915
2952
|
/**
|
|
2916
|
-
* Optional additional addresses to store in the lookup table
|
|
2953
|
+
* Optional additional addresses to store in the lookup table
|
|
2917
2954
|
*/
|
|
2918
2955
|
remainingAccounts?: PublicKey[];
|
|
2919
2956
|
};
|
|
@@ -2972,7 +3009,7 @@ declare class CompressedTokenProgram {
|
|
|
2972
3009
|
static setProgramId(programId: PublicKey | string): void;
|
|
2973
3010
|
/**
|
|
2974
3011
|
* Derive the token pool pda.
|
|
2975
|
-
* To derive the token pool pda with bump, use {@link
|
|
3012
|
+
* To derive the token pool pda with bump, use {@link deriveTokenPoolPdaWithIndex}.
|
|
2976
3013
|
*
|
|
2977
3014
|
* @param mint The mint of the token pool
|
|
2978
3015
|
*
|
|
@@ -2980,67 +3017,220 @@ declare class CompressedTokenProgram {
|
|
|
2980
3017
|
*/
|
|
2981
3018
|
static deriveTokenPoolPda(mint: PublicKey): PublicKey;
|
|
2982
3019
|
/**
|
|
2983
|
-
*
|
|
3020
|
+
* Find the index and bump for a given token pool pda and mint.
|
|
2984
3021
|
*
|
|
3022
|
+
* @param poolPda The token pool pda to find the index and bump for
|
|
2985
3023
|
* @param mint The mint of the token pool
|
|
2986
|
-
*
|
|
3024
|
+
*
|
|
3025
|
+
* @returns The index and bump number.
|
|
3026
|
+
*/
|
|
3027
|
+
static findTokenPoolIndexAndBump(poolPda: PublicKey, mint: PublicKey): [number, number];
|
|
3028
|
+
/**
|
|
3029
|
+
* Derive the token pool pda with index.
|
|
3030
|
+
*
|
|
3031
|
+
* @param mint The mint of the token pool
|
|
3032
|
+
* @param index Index. starts at 0. The Protocol supports 4 indexes aka token pools
|
|
2987
3033
|
* per mint.
|
|
2988
3034
|
*
|
|
2989
|
-
* @returns The token pool pda
|
|
3035
|
+
* @returns The token pool pda and bump.
|
|
2990
3036
|
*/
|
|
2991
|
-
static
|
|
3037
|
+
static deriveTokenPoolPdaWithIndex(mint: PublicKey, index: number): [PublicKey, number];
|
|
2992
3038
|
/** @internal */
|
|
2993
3039
|
static get deriveCpiAuthorityPda(): PublicKey;
|
|
2994
3040
|
/**
|
|
2995
3041
|
* Construct createMint instruction for compressed tokens.
|
|
2996
|
-
* @returns [createMintAccountInstruction, initializeMintInstruction, createTokenPoolInstruction]
|
|
2997
3042
|
*
|
|
2998
|
-
*
|
|
3043
|
+
* @param feePayer Fee payer.
|
|
3044
|
+
* @param mint SPL Mint address.
|
|
3045
|
+
* @param authority Mint authority.
|
|
3046
|
+
* @param freezeAuthority Optional: freeze authority.
|
|
3047
|
+
* @param decimals Decimals.
|
|
3048
|
+
* @param rentExemptBalance Lamport amount for mint account rent exemption.
|
|
3049
|
+
* @param tokenProgramId Optional: Token program ID. Default: SPL Token Program ID
|
|
3050
|
+
* @param mintSize Optional: mint size. Default: MINT_SIZE
|
|
3051
|
+
*
|
|
3052
|
+
* @returns [createMintAccountInstruction, initializeMintInstruction,
|
|
3053
|
+
* createTokenPoolInstruction]
|
|
3054
|
+
*
|
|
3055
|
+
* Note that `createTokenPoolInstruction` must be executed after
|
|
3056
|
+
* `initializeMintInstruction`.
|
|
2999
3057
|
*/
|
|
3000
|
-
static createMint(
|
|
3058
|
+
static createMint({ feePayer, mint, authority, freezeAuthority, decimals, rentExemptBalance, tokenProgramId, mintSize, }: CreateMintParams): Promise<TransactionInstruction[]>;
|
|
3001
3059
|
/**
|
|
3002
3060
|
* Enable compression for an existing SPL mint, creating an omnibus account.
|
|
3003
3061
|
* For new mints, use `CompressedTokenProgram.createMint`.
|
|
3062
|
+
*
|
|
3063
|
+
* @param feePayer Fee payer.
|
|
3064
|
+
* @param mint SPL Mint address.
|
|
3065
|
+
* @param tokenProgramId Optional: Token program ID. Default: SPL
|
|
3066
|
+
* Token Program ID
|
|
3067
|
+
*
|
|
3068
|
+
* @returns The createTokenPool instruction
|
|
3004
3069
|
*/
|
|
3005
|
-
static createTokenPool(
|
|
3070
|
+
static createTokenPool({ feePayer, mint, tokenProgramId, }: CreateTokenPoolParams): Promise<TransactionInstruction>;
|
|
3006
3071
|
/**
|
|
3007
|
-
*
|
|
3008
|
-
*
|
|
3072
|
+
* Add a token pool to an existing SPL mint. For new mints, use
|
|
3073
|
+
* {@link createTokenPool}.
|
|
3074
|
+
*
|
|
3075
|
+
* @param feePayer Fee payer.
|
|
3076
|
+
* @param mint SPL Mint address.
|
|
3077
|
+
* @param poolIndex Pool index.
|
|
3078
|
+
* @param tokenProgramId Optional: Token program ID. Default: SPL
|
|
3079
|
+
* Token Program ID
|
|
3080
|
+
*
|
|
3081
|
+
* @returns The addTokenPool instruction
|
|
3009
3082
|
*/
|
|
3010
|
-
static addTokenPool(
|
|
3083
|
+
static addTokenPool({ feePayer, mint, poolIndex, tokenProgramId, }: AddTokenPoolParams): Promise<TransactionInstruction>;
|
|
3011
3084
|
/**
|
|
3012
3085
|
* Construct mintTo instruction for compressed tokens
|
|
3086
|
+
*
|
|
3087
|
+
* @param feePayer Fee payer.
|
|
3088
|
+
* @param mint SPL Mint address.
|
|
3089
|
+
* @param authority Mint authority.
|
|
3090
|
+
* @param toPubkey Recipient owner address.
|
|
3091
|
+
* @param amount Amount of tokens to mint.
|
|
3092
|
+
* @param outputStateTreeInfo State tree to write to.
|
|
3093
|
+
* @param tokenPoolInfo Token pool info.
|
|
3094
|
+
*
|
|
3095
|
+
* @returns The mintTo instruction
|
|
3013
3096
|
*/
|
|
3014
|
-
static mintTo(
|
|
3097
|
+
static mintTo({ feePayer, mint, authority, toPubkey, amount, outputStateTreeInfo, tokenPoolInfo, }: MintToParams): Promise<TransactionInstruction>;
|
|
3015
3098
|
/**
|
|
3016
3099
|
* Mint tokens from registered SPL mint account to a compressed account
|
|
3100
|
+
*
|
|
3101
|
+
* @param feePayer Fee payer.
|
|
3102
|
+
* @param mint SPL Mint address.
|
|
3103
|
+
* @param authority Mint authority.
|
|
3104
|
+
* @param authorityTokenAccount The mint authority's associated token
|
|
3105
|
+
* account (ATA).
|
|
3106
|
+
* @param toPubkey Recipient owner address.
|
|
3107
|
+
* @param amount Amount of tokens to mint.
|
|
3108
|
+
* @param outputStateTreeInfo State tree to write to.
|
|
3109
|
+
* @param tokenPoolInfo Token pool info.
|
|
3110
|
+
*
|
|
3111
|
+
* @returns The mintTo instruction
|
|
3017
3112
|
*/
|
|
3018
|
-
static approveAndMintTo(
|
|
3113
|
+
static approveAndMintTo({ feePayer, mint, authority, authorityTokenAccount, toPubkey, amount, outputStateTreeInfo, tokenPoolInfo, }: ApproveAndMintToParams): Promise<TransactionInstruction[]>;
|
|
3019
3114
|
/**
|
|
3020
3115
|
* Construct transfer instruction for compressed tokens
|
|
3116
|
+
*
|
|
3117
|
+
* @param payer Fee payer.
|
|
3118
|
+
* @param inputCompressedTokenAccounts Source compressed token accounts.
|
|
3119
|
+
* @param toAddress Recipient owner address.
|
|
3120
|
+
* @param amount Amount of tokens to transfer.
|
|
3121
|
+
* @param recentValidityProof Recent validity proof.
|
|
3122
|
+
* @param recentInputStateRootIndices Recent state root indices.
|
|
3123
|
+
*
|
|
3124
|
+
* @returns The transfer instruction
|
|
3021
3125
|
*/
|
|
3022
|
-
static transfer(
|
|
3126
|
+
static transfer({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, }: TransferParams): Promise<TransactionInstruction>;
|
|
3023
3127
|
/**
|
|
3024
|
-
* Create lookup table instructions for the token program's default
|
|
3128
|
+
* Create lookup table instructions for the token program's default
|
|
3129
|
+
* accounts.
|
|
3130
|
+
*
|
|
3131
|
+
* @param payer Fee payer.
|
|
3132
|
+
* @param authority Authority.
|
|
3133
|
+
* @param mints Mints.
|
|
3134
|
+
* @param recentSlot Recent slot.
|
|
3135
|
+
* @param remainingAccounts Remaining accounts.
|
|
3136
|
+
*
|
|
3137
|
+
* @returns [createInstruction, extendInstruction, option(extendInstruction2)]
|
|
3025
3138
|
*/
|
|
3026
|
-
static createTokenProgramLookupTable(
|
|
3139
|
+
static createTokenProgramLookupTable({ payer, authority, mints, recentSlot, remainingAccounts, }: CreateTokenProgramLookupTableParams): Promise<{
|
|
3027
3140
|
instructions: TransactionInstruction[];
|
|
3028
3141
|
address: PublicKey;
|
|
3029
3142
|
}>;
|
|
3030
3143
|
/**
|
|
3031
3144
|
* Create compress instruction
|
|
3032
|
-
*
|
|
3145
|
+
*
|
|
3146
|
+
* @param payer Fee payer.
|
|
3147
|
+
* @param owner Owner of uncompressed token account.
|
|
3148
|
+
* @param source Source SPL Token account address.
|
|
3149
|
+
* @param toAddress Recipient owner address(es).
|
|
3150
|
+
* @param amount Amount of tokens to compress.
|
|
3151
|
+
* @param mint SPL Token mint address.
|
|
3152
|
+
* @param outputStateTreeInfo State tree to write to.
|
|
3153
|
+
* @param tokenPoolInfo Token pool info.
|
|
3154
|
+
*
|
|
3155
|
+
* @returns The compress instruction
|
|
3033
3156
|
*/
|
|
3034
|
-
static compress(
|
|
3157
|
+
static compress({ payer, owner, source, toAddress, amount, mint, outputStateTreeInfo, tokenPoolInfo, }: CompressParams): Promise<TransactionInstruction>;
|
|
3035
3158
|
/**
|
|
3036
3159
|
* Construct decompress instruction
|
|
3160
|
+
*
|
|
3161
|
+
* @param payer Fee payer.
|
|
3162
|
+
* @param inputCompressedTokenAccounts Source compressed token accounts.
|
|
3163
|
+
* @param toAddress Destination **uncompressed** token
|
|
3164
|
+
* account address. (ATA)
|
|
3165
|
+
* @param amount Amount of tokens to decompress.
|
|
3166
|
+
* @param recentValidityProof Recent validity proof.
|
|
3167
|
+
* @param recentInputStateRootIndices Recent state root indices.
|
|
3168
|
+
* @param tokenPoolInfos Token pool info.
|
|
3169
|
+
*
|
|
3170
|
+
* @returns The decompress instruction
|
|
3171
|
+
*/
|
|
3172
|
+
static decompress({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, tokenPoolInfos, }: DecompressParams): Promise<TransactionInstruction>;
|
|
3173
|
+
/**
|
|
3174
|
+
* Create `mergeTokenAccounts` instruction
|
|
3175
|
+
*
|
|
3176
|
+
* @param payer Fee payer.
|
|
3177
|
+
* @param owner Owner of the compressed token
|
|
3178
|
+
* accounts to be merged.
|
|
3179
|
+
* @param inputCompressedTokenAccounts Source compressed token accounts.
|
|
3180
|
+
* @param mint SPL Token mint address.
|
|
3181
|
+
* @param recentValidityProof Recent validity proof.
|
|
3182
|
+
* @param recentInputStateRootIndices Recent state root indices.
|
|
3183
|
+
*
|
|
3184
|
+
* @returns instruction
|
|
3185
|
+
*/
|
|
3186
|
+
static mergeTokenAccounts({ payer, owner, inputCompressedTokenAccounts, mint, recentValidityProof, recentInputStateRootIndices, }: MergeTokenAccountsParams): Promise<TransactionInstruction[]>;
|
|
3187
|
+
/**
|
|
3188
|
+
* Create `compressSplTokenAccount` instruction
|
|
3189
|
+
*
|
|
3190
|
+
* @param feePayer Fee payer.
|
|
3191
|
+
* @param authority SPL Token account owner.
|
|
3192
|
+
* @param tokenAccount SPL Token account to compress.
|
|
3193
|
+
* @param mint SPL Token mint address.
|
|
3194
|
+
* @param remainingAmount Optional: Amount to leave in token account.
|
|
3195
|
+
* @param outputStateTreeInfo State tree to write to.
|
|
3196
|
+
* @param tokenPoolInfo Token pool info.
|
|
3197
|
+
*
|
|
3198
|
+
* @returns instruction
|
|
3199
|
+
*/
|
|
3200
|
+
static compressSplTokenAccount({ feePayer, authority, tokenAccount, mint, remainingAmount, outputStateTreeInfo, tokenPoolInfo, }: CompressSplTokenAccountParams): Promise<TransactionInstruction>;
|
|
3201
|
+
/**
|
|
3202
|
+
* Get the program ID for a mint
|
|
3203
|
+
*
|
|
3204
|
+
* @param mint SPL Token mint address.
|
|
3205
|
+
* @param connection Connection.
|
|
3206
|
+
*
|
|
3207
|
+
* @returns program ID
|
|
3037
3208
|
*/
|
|
3038
|
-
static decompress(params: DecompressParams): Promise<TransactionInstruction>;
|
|
3039
|
-
static mergeTokenAccounts(params: MergeTokenAccountsParams): Promise<TransactionInstruction[]>;
|
|
3040
|
-
static compressSplTokenAccount(params: CompressSplTokenAccountParams): Promise<TransactionInstruction>;
|
|
3041
3209
|
static getMintProgramId(mint: PublicKey, connection: Connection): Promise<PublicKey | undefined>;
|
|
3042
|
-
|
|
3043
|
-
|
|
3210
|
+
/**
|
|
3211
|
+
* Create `approve` instruction to delegate compressed tokens.
|
|
3212
|
+
*
|
|
3213
|
+
* @param payer Fee payer.
|
|
3214
|
+
* @param inputCompressedTokenAccounts Source compressed token accounts.
|
|
3215
|
+
* @param toAddress Owner to delegate to.
|
|
3216
|
+
* @param amount Amount of tokens to delegate.
|
|
3217
|
+
* @param recentValidityProof Recent validity proof.
|
|
3218
|
+
* @param recentInputStateRootIndices Recent state root indices.
|
|
3219
|
+
*
|
|
3220
|
+
* @returns instruction
|
|
3221
|
+
*/
|
|
3222
|
+
static approve({ payer, inputCompressedTokenAccounts, toAddress, amount, recentValidityProof, recentInputStateRootIndices, }: ApproveParams): Promise<TransactionInstruction>;
|
|
3223
|
+
/**
|
|
3224
|
+
* Create `revoke` instruction to revoke delegation of compressed tokens.
|
|
3225
|
+
*
|
|
3226
|
+
* @param payer Fee payer.
|
|
3227
|
+
* @param inputCompressedTokenAccounts Source compressed token accounts.
|
|
3228
|
+
* @param recentValidityProof Recent validity proof.
|
|
3229
|
+
* @param recentInputStateRootIndices Recent state root indices.
|
|
3230
|
+
*
|
|
3231
|
+
* @returns instruction
|
|
3232
|
+
*/
|
|
3233
|
+
static revoke({ payer, inputCompressedTokenAccounts, recentValidityProof, recentInputStateRootIndices, }: RevokeParams): Promise<TransactionInstruction>;
|
|
3044
3234
|
}
|
|
3045
3235
|
|
|
3046
|
-
export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, Action, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type
|
|
3236
|
+
export { ADD_TOKEN_POOL_DISCRIMINATOR, APPROVE_DISCRIMINATOR, Action, type AddTokenPoolParams, type ApproveAndMintToParams, type ApproveParams, BATCH_COMPRESS_DISCRIMINATOR, type BatchCompressInstructionData, COMPRESS_SPL_TOKEN_ACCOUNT_DISCRIMINATOR, CPI_AUTHORITY_SEED, CREATE_TOKEN_POOL_DISCRIMINATOR, type CompressParams, type CompressSplTokenAccountInstructionData, type CompressSplTokenAccountParams, type CompressedTokenInstructionDataApprove, CompressedTokenInstructionDataApproveLayout, type CompressedTokenInstructionDataRevoke, CompressedTokenInstructionDataRevokeLayout, type CompressedTokenInstructionDataTransfer, CompressedTokenInstructionDataTransferLayout, CompressedTokenProgram, CpiContextLayout, type CreateMintParams, type CreateTokenPoolParams, type CreateTokenProgramLookupTableParams, type DecompressParams, type DelegatedTransfer, DelegatedTransferLayout, ERROR_NO_ACCOUNTS_FOUND, IDL, type InputTokenDataWithContext, type LightCompressedToken, MINT_TO_DISCRIMINATOR, type MergeTokenAccountsParams, type MintToInstructionData, type MintToParams, POOL_SEED, type PackCompressedTokenAccountsParams, type PackedTokenTransferOutputData, REVOKE_DISCRIMINATOR, type RevokeParams, SPL_TOKEN_MINT_RENT_EXEMPT_BALANCE, TRANSFER_DISCRIMINATOR, type TokenData, type TokenPoolActivity, type TokenPoolInfo, type TokenTransferOutputData, type TransferParams, addTokenPoolAccountsLayout, type addTokenPoolAccountsLayoutParams, addTokenPools, approve, approveAccountsLayout, type approveAccountsLayoutParams, approveAndMintTo, batchCompressLayout, checkMint, checkTokenPoolInfo, compress, compressSplTokenAccount, compressSplTokenAccountInstructionDataLayout, createDecompressOutputState, createMint, createTokenPool, createTokenPoolAccountsLayout, type createTokenPoolAccountsLayoutParams, createTokenProgramLookupTable, createTransferOutputState, decodeApproveInstructionData, decodeBatchCompressInstructionData, decodeCompressSplTokenAccountInstructionData, decodeMintToInstructionData, decodeRevokeInstructionData, decodeTransferInstructionData, decompress, decompressDelegated, encodeApproveInstructionData, encodeBatchCompressInstructionData, encodeCompressSplTokenAccountInstructionData, encodeMintToInstructionData, encodeRevokeInstructionData, encodeTransferInstructionData, freezeAccountsLayout, type freezeAccountsLayoutParams, getTokenPoolInfos, isSingleTokenPoolInfo, mergeTokenAccounts, mintTo, mintToAccountsLayout, type mintToAccountsLayoutParams, mintToLayout, packCompressedTokenAccounts, parseMaybeDelegatedTransfer, parseTokenData, revoke, revokeAccountsLayout, type revokeAccountsLayoutParams, selectMinCompressedTokenAccountsForDecompression, selectMinCompressedTokenAccountsForTransfer, selectMinCompressedTokenAccountsForTransferOrPartial, selectSmartCompressedTokenAccountsForTransfer, selectSmartCompressedTokenAccountsForTransferOrPartial, selectTokenAccountsForApprove, selectTokenPoolInfo, selectTokenPoolInfosForDecompression, sumUpTokenAmount, thawAccountsLayout, type thawAccountsLayoutParams, transfer, transferAccountsLayout, type transferAccountsLayoutParams, transferDelegated, validateSameTokenOwner };
|