@@ -135,7 +135,7 @@ export interface CreateAssociatedLightTokenAccountInstructionParams {
135135 feePayer : PublicKey ;
136136 owner : PublicKey ;
137137 mint : PublicKey ;
138- compressibleConfig ?: CompressibleConfig ;
138+ compressibleConfig ?: CompressibleConfig | null ;
139139 configAccount ?: PublicKey ;
140140 rentPayerPda ?: PublicKey ;
141141}
@@ -144,20 +144,23 @@ export interface CreateAssociatedLightTokenAccountInstructionParams {
144144 * Create instruction for creating an associated light-token account.
145145 * Uses the default rent sponsor PDA by default.
146146 *
147- * @param feePayer Fee payer public key.
148- * @param owner Owner of the associated token account.
149- * @param mint Mint address.
150- * @param compressibleConfig Compressible configuration (defaults to rent sponsor config).
151- * @param configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
152- * @param rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
147+ * @param input Associated light-token account input.
148+ * @param input.feePayer Fee payer public key.
149+ * @param input.owner Owner of the associated token account.
150+ * @param input.mint Mint address.
151+ * @param input.compressibleConfig Compressible configuration (defaults to rent sponsor config).
152+ * @param input.configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
153+ * @param input.rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
153154 */
154155export function createAssociatedLightTokenAccountInstruction (
155- feePayer : PublicKey ,
156- owner : PublicKey ,
157- mint : PublicKey ,
158- compressibleConfig : CompressibleConfig | null = DEFAULT_COMPRESSIBLE_CONFIG ,
159- configAccount : PublicKey = LIGHT_TOKEN_CONFIG ,
160- rentPayerPda : PublicKey = LIGHT_TOKEN_RENT_SPONSOR ,
156+ {
157+ feePayer,
158+ owner,
159+ mint,
160+ compressibleConfig = DEFAULT_COMPRESSIBLE_CONFIG ,
161+ configAccount = LIGHT_TOKEN_CONFIG ,
162+ rentPayerPda = LIGHT_TOKEN_RENT_SPONSOR ,
163+ } : CreateAssociatedLightTokenAccountInstructionParams ,
161164) : TransactionInstruction {
162165 const associatedTokenAccount = getAssociatedLightTokenAddress ( owner , mint ) ;
163166
@@ -215,20 +218,23 @@ export function createAssociatedLightTokenAccountInstruction(
215218 * Create idempotent instruction for creating an associated light-token account.
216219 * Uses the default rent sponsor PDA by default.
217220 *
218- * @param feePayer Fee payer public key.
219- * @param owner Owner of the associated token account.
220- * @param mint Mint address.
221- * @param compressibleConfig Compressible configuration (defaults to rent sponsor config).
222- * @param configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
223- * @param rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
221+ * @param input Associated light-token account input.
222+ * @param input.feePayer Fee payer public key.
223+ * @param input.owner Owner of the associated token account.
224+ * @param input.mint Mint address.
225+ * @param input.compressibleConfig Compressible configuration (defaults to rent sponsor config).
226+ * @param input.configAccount Config account (defaults to LIGHT_TOKEN_CONFIG).
227+ * @param input.rentPayerPda Rent payer PDA (defaults to LIGHT_TOKEN_RENT_SPONSOR).
224228 */
225229export function createAssociatedLightTokenAccountIdempotentInstruction (
226- feePayer : PublicKey ,
227- owner : PublicKey ,
228- mint : PublicKey ,
229- compressibleConfig : CompressibleConfig | null = DEFAULT_COMPRESSIBLE_CONFIG ,
230- configAccount : PublicKey = LIGHT_TOKEN_CONFIG ,
231- rentPayerPda : PublicKey = LIGHT_TOKEN_RENT_SPONSOR ,
230+ {
231+ feePayer,
232+ owner,
233+ mint,
234+ compressibleConfig = DEFAULT_COMPRESSIBLE_CONFIG ,
235+ configAccount = LIGHT_TOKEN_CONFIG ,
236+ rentPayerPda = LIGHT_TOKEN_RENT_SPONSOR ,
237+ } : CreateAssociatedLightTokenAccountInstructionParams ,
232238) : TransactionInstruction {
233239 const associatedTokenAccount = getAssociatedLightTokenAddress ( owner , mint ) ;
234240
@@ -282,40 +288,50 @@ export interface LightTokenConfig {
282288 rentPayerPda ?: PublicKey ;
283289}
284290
291+ export interface CreateAssociatedTokenAccountInstructionInput {
292+ payer : PublicKey ;
293+ associatedToken : PublicKey ;
294+ owner : PublicKey ;
295+ mint : PublicKey ;
296+ programId ?: PublicKey ;
297+ associatedTokenProgramId ?: PublicKey ;
298+ lightTokenConfig ?: LightTokenConfig ;
299+ }
300+
285301/**
286302 * Create instruction for creating an associated token account (SPL, Token-2022,
287- * or light-token). Follows SPL Token API signature with optional light-token config at the
288- * end.
303+ * or light-token).
289304 *
290- * @param payer Fee payer public key.
291- * @param associatedToken Associated token account address.
292- * @param owner Owner of the associated token account.
293- * @param mint Mint address.
294- * @param programId Token program ID (default: TOKEN_PROGRAM_ID).
295- * @param associatedTokenProgramId Associated token program ID.
296- * @param lightTokenConfig Optional light-token-specific configuration.
305+ * @param input Associated token account input.
306+ * @param input.payer Fee payer public key.
307+ * @param input.associatedToken Associated token account address.
308+ * @param input.owner Owner of the associated token account.
309+ * @param input.mint Mint address.
310+ * @param input.programId Token program ID (default: TOKEN_PROGRAM_ID).
311+ * @param input.associatedTokenProgramId Associated token program ID.
312+ * @param input.lightTokenConfig Optional light-token-specific configuration.
297313 */
298- function createAssociatedTokenAccountInstruction (
299- payer : PublicKey ,
300- associatedToken : PublicKey ,
301- owner : PublicKey ,
302- mint : PublicKey ,
303- programId : PublicKey = TOKEN_PROGRAM_ID ,
304- associatedTokenProgramId ?: PublicKey ,
305- lightTokenConfig ?: LightTokenConfig ,
306- ) : TransactionInstruction {
314+ function createAssociatedTokenAccountInstruction ( {
315+ payer,
316+ associatedToken,
317+ owner,
318+ mint,
319+ programId = TOKEN_PROGRAM_ID ,
320+ associatedTokenProgramId,
321+ lightTokenConfig,
322+ } : CreateAssociatedTokenAccountInstructionInput ) : TransactionInstruction {
307323 const effectiveAssociatedTokenProgramId =
308324 associatedTokenProgramId ?? getAtaProgramId ( programId ) ;
309325
310326 if ( programId . equals ( LIGHT_TOKEN_PROGRAM_ID ) ) {
311- return createAssociatedLightTokenAccountInstruction (
312- payer ,
327+ return createAssociatedLightTokenAccountInstruction ( {
328+ feePayer : payer ,
313329 owner,
314330 mint,
315- lightTokenConfig ?. compressibleConfig ,
316- lightTokenConfig ?. configAccount ,
317- lightTokenConfig ?. rentPayerPda ,
318- ) ;
331+ compressibleConfig : lightTokenConfig ?. compressibleConfig ,
332+ configAccount : lightTokenConfig ?. configAccount ,
333+ rentPayerPda : lightTokenConfig ?. rentPayerPda ,
334+ } ) ;
319335 } else {
320336 return createSplAssociatedTokenAccountInstruction (
321337 payer ,
@@ -330,38 +346,38 @@ function createAssociatedTokenAccountInstruction(
330346
331347/**
332348 * Create idempotent instruction for creating an associated token account (SPL,
333- * Token-2022, or light-token). Follows SPL Token API signature with optional light-token
334- * config at the end.
349+ * Token-2022, or light-token).
335350 *
336- * @param payer Fee payer public key.
337- * @param associatedToken Associated token account address.
338- * @param owner Owner of the associated token account.
339- * @param mint Mint address.
340- * @param programId Token program ID (default: TOKEN_PROGRAM_ID).
341- * @param associatedTokenProgramId Associated token program ID.
342- * @param lightTokenConfig Optional light-token-specific configuration.
351+ * @param input Associated token account input.
352+ * @param input.payer Fee payer public key.
353+ * @param input.associatedToken Associated token account address.
354+ * @param input.owner Owner of the associated token account.
355+ * @param input.mint Mint address.
356+ * @param input.programId Token program ID (default: TOKEN_PROGRAM_ID).
357+ * @param input.associatedTokenProgramId Associated token program ID.
358+ * @param input.lightTokenConfig Optional light-token-specific configuration.
343359 */
344- function createAssociatedTokenAccountIdempotentInstruction (
345- payer : PublicKey ,
346- associatedToken : PublicKey ,
347- owner : PublicKey ,
348- mint : PublicKey ,
349- programId : PublicKey = TOKEN_PROGRAM_ID ,
350- associatedTokenProgramId ?: PublicKey ,
351- lightTokenConfig ?: LightTokenConfig ,
352- ) : TransactionInstruction {
360+ function createAssociatedTokenAccountIdempotentInstruction ( {
361+ payer,
362+ associatedToken,
363+ owner,
364+ mint,
365+ programId = TOKEN_PROGRAM_ID ,
366+ associatedTokenProgramId,
367+ lightTokenConfig,
368+ } : CreateAssociatedTokenAccountInstructionInput ) : TransactionInstruction {
353369 const effectiveAssociatedTokenProgramId =
354370 associatedTokenProgramId ?? getAtaProgramId ( programId ) ;
355371
356372 if ( programId . equals ( LIGHT_TOKEN_PROGRAM_ID ) ) {
357- return createAssociatedLightTokenAccountIdempotentInstruction (
358- payer ,
373+ return createAssociatedLightTokenAccountIdempotentInstruction ( {
374+ feePayer : payer ,
359375 owner,
360376 mint,
361- lightTokenConfig ?. compressibleConfig ,
362- lightTokenConfig ?. configAccount ,
363- lightTokenConfig ?. rentPayerPda ,
364- ) ;
377+ compressibleConfig : lightTokenConfig ?. compressibleConfig ,
378+ configAccount : lightTokenConfig ?. configAccount ,
379+ rentPayerPda : lightTokenConfig ?. rentPayerPda ,
380+ } ) ;
365381 } else {
366382 return createSplAssociatedTokenAccountIdempotentInstruction (
367383 payer ,
@@ -391,13 +407,13 @@ export function createAtaInstruction({
391407 programId : targetProgramId ,
392408 } ) ;
393409
394- return createAtaIdempotent (
410+ return createAtaIdempotent ( {
395411 payer,
396412 associatedToken,
397413 owner,
398414 mint,
399- targetProgramId ,
400- ) ;
415+ programId : targetProgramId ,
416+ } ) ;
401417}
402418
403419export async function createAtaInstructions ( {
0 commit comments