-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Conversation
There was a problem hiding this 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); |
There was a problem hiding this comment.
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:
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( |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
* Construct a createAssociatedTokenAccountIdempotentInstructionShort instruction | |
* Derive the associated token account and construct a CreateAssociatedTokenAccountIdempotent instruction |
Fixes #7178