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

Conversation

zzau13
Copy link
Contributor

@zzau13 zzau13 commented Aug 22, 2024

Fixes #7178

@mergify mergify bot added the community Community contribution label Aug 22, 2024
Copy link
Contributor

@joncinque joncinque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! A couple of things to fixup. Could you also add a little unit test to make sure that the output is exactly the same between the new function and the old function?

) {
const associatedToken = getAssociatedTokenAddressSync(mint, owner, allowOwnerOffCurve);

return createAssociatedTokenAccountIdempotentInstruction(payer, owner, mint, programId, associatedTokenProgramId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't using the associated token account address that was just derived, so it's incorrect. You'll need to do:

Suggested change
return createAssociatedTokenAccountIdempotentInstruction(payer, owner, mint, programId, associatedTokenProgramId);
return createAssociatedTokenAccountIdempotentInstruction(payer, associatedToken, owner, mint, programId, associatedTokenProgramId);

*
* @return Instruction to add to a transaction
*/
export function createAssociatedTokenAccountIdempotentInstructionShort(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we rename this to something a bit clearer? maybe createAssociatedTokenAccountIdempotentInstructionWithDerivation?

@@ -64,6 +65,31 @@ export function createAssociatedTokenAccountIdempotentInstruction(
);
}

/**
* Construct a createAssociatedTokenAccountIdempotentInstructionShort instruction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: let's keep the comment correct

Suggested change
* Construct a createAssociatedTokenAccountIdempotentInstructionShort instruction
* Derive the associated token account and construct a CreateAssociatedTokenAccountIdempotent instruction

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community Community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

token-js: createAssociatedTokenAccountIdempotentInstruction shouldn't require client to pass in associatedToken
2 participants