Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 3547d76

Browse files
authored
add allowOwnerOffCurve parameter to createAssociatedTokenAccountIdempotent (#7554)
feat: add allowOwnerOffCurve parameter to createAssociatedTokenAccountIdempotent function
1 parent d1e018f commit 3547d76

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

token/js/src/actions/createAssociatedTokenAccountIdempotent.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { getAssociatedTokenAddressSync } from '../state/mint.js';
1515
* @param confirmOptions Options for confirming the transaction
1616
* @param programId SPL Token program account
1717
* @param associatedTokenProgramId SPL Associated Token program account
18+
* @param allowOwnerOffCurve Allow the owner account to be a PDA (Program Derived Address)
1819
*
1920
* @return Address of the new or existing associated token account
2021
*/
@@ -26,8 +27,15 @@ export async function createAssociatedTokenAccountIdempotent(
2627
confirmOptions?: ConfirmOptions,
2728
programId = TOKEN_PROGRAM_ID,
2829
associatedTokenProgramId = ASSOCIATED_TOKEN_PROGRAM_ID,
30+
allowOwnerOffCurve = false,
2931
): Promise<PublicKey> {
30-
const associatedToken = getAssociatedTokenAddressSync(mint, owner, false, programId, associatedTokenProgramId);
32+
const associatedToken = getAssociatedTokenAddressSync(
33+
mint,
34+
owner,
35+
allowOwnerOffCurve,
36+
programId,
37+
associatedTokenProgramId,
38+
);
3139

3240
const transaction = new Transaction().add(
3341
createAssociatedTokenAccountIdempotentInstruction(

0 commit comments

Comments
 (0)