fix: reject off-curve owners during ATA creation

This commit is contained in:
Trent Nelson 2021-04-29 19:57:26 -06:00 committed by Trent Nelson
parent 975b524487
commit 7320cf404b
1 changed files with 3 additions and 0 deletions

View File

@ -2239,6 +2239,9 @@ export class Token {
mint: PublicKey,
owner: PublicKey,
): Promise<PublicKey> {
if (!PublicKey.isOnCurve(owner.toBuffer())) {
throw new Error(`Owner cannot sign: ${owner.toString()}`);
}
return (
await PublicKey.findProgramAddress(
[owner.toBuffer(), programId.toBuffer(), mint.toBuffer()],