diff --git a/.changeset/crazy-melons-hide.md b/.changeset/crazy-melons-hide.md new file mode 100644 index 00000000..810ead84 --- /dev/null +++ b/.changeset/crazy-melons-hide.md @@ -0,0 +1,5 @@ +--- +"@macalinao/clients-token-metadata": patch +--- + +Add master edition PDA diff --git a/clients/token-metadata/coda.config.mjs b/clients/token-metadata/coda.config.mjs index 53c3f881..a54101f3 100644 --- a/clients/token-metadata/coda.config.mjs +++ b/clients/token-metadata/coda.config.mjs @@ -24,6 +24,23 @@ const addCustomPDAsVisitor = addPdasVisitor({ ), ], }, + { + name: "masterEdition", + seeds: [ + constantPdaSeedNodeFromString("utf8", "metadata"), + variablePdaSeedNode( + "programId", + publicKeyTypeNode(), + "The address of the program", + ), + variablePdaSeedNode( + "mint", + publicKeyTypeNode(), + "The address of the mint account", + ), + constantPdaSeedNodeFromString("utf8", "edition"), + ], + }, ], }); diff --git a/clients/token-metadata/src/generated/pdas/index.ts b/clients/token-metadata/src/generated/pdas/index.ts index bc0ad4d4..67ccdd55 100644 --- a/clients/token-metadata/src/generated/pdas/index.ts +++ b/clients/token-metadata/src/generated/pdas/index.ts @@ -6,4 +6,5 @@ * @see https://github.com/codama-idl/codama */ +export * from "./masterEdition.js"; export * from "./metadata.js"; diff --git a/clients/token-metadata/src/generated/pdas/masterEdition.ts b/clients/token-metadata/src/generated/pdas/masterEdition.ts new file mode 100644 index 00000000..680862f2 --- /dev/null +++ b/clients/token-metadata/src/generated/pdas/masterEdition.ts @@ -0,0 +1,39 @@ +/** + * This code was AUTOGENERATED using the codama library. + * Please DO NOT EDIT THIS FILE, instead use visitors + * to add features, then rerun codama to update it. + * + * @see https://github.com/codama-idl/codama + */ + +import type { Address, ProgramDerivedAddress } from "@solana/kit"; +import { + getAddressEncoder, + getProgramDerivedAddress, + getUtf8Encoder, +} from "@solana/kit"; + +export interface MasterEditionSeeds { + /** The address of the program */ + programId: Address; + /** The address of the mint account */ + mint: Address; +} + +export async function findMasterEditionPda( + seeds: MasterEditionSeeds, + config: { programAddress?: Address | undefined } = {}, +): Promise { + const { + programAddress = "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s" as Address<"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s">, + } = config; + return await getProgramDerivedAddress({ + programAddress, + seeds: [ + getUtf8Encoder().encode("metadata"), + getAddressEncoder().encode(seeds.programId), + getAddressEncoder().encode(seeds.mint), + getUtf8Encoder().encode("edition"), + ], + }); +}