import { Buffer } from 'buffer';
import { Pda } from '../../types';
/**
 * This client allows you to build PDAs related to the Candy Machine module.
 *
 * @see {@link CandyMachineClient}
 * @group Module Pdas
 */
export class CandyMachinePdasClient {
    constructor(metaplex) {
        this.metaplex = metaplex;
    }
    /** Finds the Authority PDA for the given Candy Machine. */
    authority({ candyMachine, programs, }) {
        const program = this.metaplex.programs().getCandyMachine(programs);
        return Pda.find(program.address, [
            Buffer.from('candy_machine', 'utf8'),
            candyMachine.toBuffer(),
        ]);
    }
    /** Finds the Candy Guard PDA for the given base address it derives from. */
    candyGuard({ base, programs, }) {
        const program = this.metaplex.programs().getCandyGuard(programs);
        return Pda.find(program.address, [
            Buffer.from('candy_guard', 'utf8'),
            base.toBuffer(),
        ]);
    }
    /**
     * Finds the Mint Limit Counter PDA that keeps track of how many
     * NFTs where minted by a given user on a given Candy Machine.
     */
    mintLimitCounter({ id, user, candyMachine, candyGuard, programs, }) {
        const program = this.metaplex.programs().getCandyGuard(programs);
        return Pda.find(program.address, [
            Buffer.from('mint_limit', 'utf8'),
            Buffer.from([id]),
            user.toBuffer(),
            candyGuard.toBuffer(),
            candyMachine.toBuffer(),
        ]);
    }
    /**
     * Finds the Allow List Proof PDA that keeps track of whether a user
     * has provided the correct Merkle Proof for the given Merkle Root.
     */
    merkleProof({ merkleRoot, user, candyMachine, candyGuard, programs, }) {
        const program = this.metaplex.programs().getCandyGuard(programs);
        return Pda.find(program.address, [
            Buffer.from('allow_list', 'utf8'),
            merkleRoot,
            user.toBuffer(),
            candyGuard.toBuffer(),
            candyMachine.toBuffer(),
        ]);
    }
}
//# sourceMappingURL=CandyMachinePdasClient.js.map