metaplex-foundation / metaplex-program-library

Smart contracts maintained by the Metaplex team
Other
580 stars 511 forks source link

[Bug]: Metadata.getPDA(..) is now inaccessible #419

Closed zkhalapyan closed 2 years ago

zkhalapyan commented 2 years ago

Which package is this bug report for?

token-metadata

Issue description

I need to get Metadata's PDA. Seems like someone deprecated the function which is not available publically. So how do I get Metadata's PDA?

// Not exported publically.
import { deprecated } from "@metaplex-foundation/mpl-token-metadata";

// So I can't use this...
const metadata = await deprecated.Metadata.getPDA(mint.publicKey);

Relevant log output

No response

Priority this issue should have

Medium (should be fixed soon)

zkhalapyan commented 2 years ago

For now, can use the definition below:

import {
  PROGRAM_ID,
} from "@metaplex-foundation/mpl-token-metadata";

async function getMetadataPDA(
  mint: PublicKey
): Promise<PublicKey> {
  const [publicKey] = await PublicKey.findProgramAddress(
    [Buffer.from("metadata"), 
    PROGRAM_ID.toBuffer(), 
    mint.toBuffer()],
    PROGRAM_ID
  );
  return publicKey;
}
austbot commented 2 years ago

this is a weakness of our new 2.0 code, we will soon be able to generate pda methods, @thlorenz for vis

thlorenz commented 2 years ago

Improving this is on the roadmap. We're tracking ideas on how to implement in this issue.

Please comment here if you have recommendations.