import { Buffer } from 'buffer';
import { Pda, toBigNumber } from '../../types';
/**
 * This client allows you to build PDAs related to the NFT module.
 *
 * @see {@link NftClient}
 * @group Module Pdas
 */
export class NftPdasClient {
    constructor(metaplex) {
        this.metaplex = metaplex;
    }
    /** Finds the Metadata PDA of a given mint address. */
    metadata({ mint, programs }) {
        const programId = this.programId(programs);
        return Pda.find(programId, [
            Buffer.from('metadata', 'utf8'),
            programId.toBuffer(),
            mint.toBuffer(),
        ]);
    }
    /** Finds the Master Edition PDA of a given mint address. */
    masterEdition({ mint, programs }) {
        const programId = this.programId(programs);
        return Pda.find(programId, [
            Buffer.from('metadata', 'utf8'),
            programId.toBuffer(),
            mint.toBuffer(),
            Buffer.from('edition', 'utf8'),
        ]);
    }
    /** Finds the Edition PDA of a given mint address. */
    edition(input) {
        return this.masterEdition(input);
    }
    /** Finds the Edition Marker PDA of a given edition number. */
    editionMarker({ mint, edition, programs, }) {
        const programId = this.programId(programs);
        return Pda.find(programId, [
            Buffer.from('metadata', 'utf8'),
            programId.toBuffer(),
            mint.toBuffer(),
            Buffer.from('edition', 'utf8'),
            Buffer.from(edition.div(toBigNumber(248)).toString()),
        ]);
    }
    /** Finds the collection authority PDA for a given NFT and authority. */
    collectionAuthorityRecord({ mint, collectionAuthority, programs, }) {
        const programId = this.programId(programs);
        return Pda.find(programId, [
            Buffer.from('metadata', 'utf8'),
            programId.toBuffer(),
            mint.toBuffer(),
            Buffer.from('collection_authority', 'utf8'),
            collectionAuthority.toBuffer(),
        ]);
    }
    /** Finds the use authority PDA for a given NFT and user. */
    useAuthorityRecord({ mint, useAuthority, programs, }) {
        const programId = this.programId(programs);
        return Pda.find(programId, [
            Buffer.from('metadata', 'utf8'),
            programId.toBuffer(),
            mint.toBuffer(),
            Buffer.from('user', 'utf8'),
            useAuthority.toBuffer(),
        ]);
    }
    /** Finds the burner PDA of the Token Metadata program. */
    burner({ programs, }) {
        const programId = this.programId(programs);
        return Pda.find(programId, [
            Buffer.from('metadata', 'utf8'),
            programId.toBuffer(),
            Buffer.from('burn', 'utf8'),
        ]);
    }
    programId(programs) {
        return this.metaplex.programs().getTokenMetadata(programs).address;
    }
}
//# sourceMappingURL=NftPdasClient.js.map