Skip to content

Commit

Permalink
add allowOwnerOffCurve parameter to createAssociatedTokenAccountIdemp…
Browse files Browse the repository at this point in the history
…otent (#7554)

feat: add allowOwnerOffCurve parameter to createAssociatedTokenAccountIdempotent function
  • Loading branch information
wei1769 authored Dec 4, 2024
1 parent d1e018f commit 3547d76
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion token/js/src/actions/createAssociatedTokenAccountIdempotent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { getAssociatedTokenAddressSync } from '../state/mint.js';
* @param confirmOptions Options for confirming the transaction
* @param programId SPL Token program account
* @param associatedTokenProgramId SPL Associated Token program account
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program Derived Address)
*
* @return Address of the new or existing associated token account
*/
Expand All @@ -26,8 +27,15 @@ export async function createAssociatedTokenAccountIdempotent(
confirmOptions?: ConfirmOptions,
programId = TOKEN_PROGRAM_ID,
associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID,
allowOwnerOffCurve = false,
): Promise<PublicKey> {
const associatedToken = getAssociatedTokenAddressSync(mint, owner, false, programId, associatedTokenProgramId);
const associatedToken = getAssociatedTokenAddressSync(
mint,
owner,
allowOwnerOffCurve,
programId,
associatedTokenProgramId,
);

const transaction = new Transaction().add(
createAssociatedTokenAccountIdempotentInstruction(
Expand Down

0 comments on commit 3547d76

Please sign in to comment.