Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add short createAssociatedTokenAccountIdempotentInstruction #7181

Closed
wants to merge 0 commits into from

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution
Projects
None yet
2 participants