import { Buffer } from 'buffer';
import { Pda } from '../../types';
/**
 * This client allows you to build PDAs related to the Auction House module.
 *
 * @see {@link AuctionHouseClient}
 * @group Module Pdas
 */
export class AuctionHousePdasClient {
    constructor(metaplex) {
        this.metaplex = metaplex;
    }
    /** Finds the Auction House PDA for a creator and treasury tuple. */
    auctionHouse(input) {
        const programId = this.programId(input.programs);
        return Pda.find(programId, [
            Buffer.from('auction_house', 'utf8'),
            input.creator.toBuffer(),
            input.treasuryMint.toBuffer(),
        ]);
    }
    /** Finds the Auctioneer PDA of an Auction House. */
    auctioneer(input) {
        const programId = this.programId(input.programs);
        return Pda.find(programId, [
            Buffer.from('auctioneer', 'utf8'),
            input.auctionHouse.toBuffer(),
            input.auctioneerAuthority.toBuffer(),
        ]);
    }
    /**
     * Finds the PDA of the Auction House Program
     * itself used to sign transaction.
     */
    programAsSigner(input) {
        const programId = this.programId(input === null || input === void 0 ? void 0 : input.programs);
        return Pda.find(programId, [
            Buffer.from('auction_house', 'utf8'),
            Buffer.from('signer', 'utf8'),
        ]);
    }
    /** Finds the PDA of an Auction House's fee account. */
    fee(input) {
        const programId = this.programId(input.programs);
        return Pda.find(programId, [
            Buffer.from('auction_house', 'utf8'),
            input.auctionHouse.toBuffer(),
            Buffer.from('fee_payer', 'utf8'),
        ]);
    }
    /** Finds the PDA of an Auction House's treasury account. */
    treasury(input) {
        const programId = this.programId(input.programs);
        return Pda.find(programId, [
            Buffer.from('auction_house', 'utf8'),
            input.auctionHouse.toBuffer(),
            Buffer.from('treasury', 'utf8'),
        ]);
    }
    /** Finds the PDA of a buyer's escrow account. */
    buyerEscrow(input) {
        const programId = this.programId(input.programs);
        return Pda.find(programId, [
            Buffer.from('auction_house', 'utf8'),
            input.auctionHouse.toBuffer(),
            input.buyer.toBuffer(),
        ]);
    }
    /** Finds the trade state PDA of a bid or listing. */
    tradeState(input) {
        const programId = this.programId(input.programs);
        return Pda.find(programId, [
            Buffer.from('auction_house', 'utf8'),
            input.wallet.toBuffer(),
            input.auctionHouse.toBuffer(),
            ...(input.tokenAccount ? [input.tokenAccount.toBuffer()] : []),
            input.treasuryMint.toBuffer(),
            input.tokenMint.toBuffer(),
            input.price.toArrayLike(Buffer, 'le', 8),
            input.tokenSize.toArrayLike(Buffer, 'le', 8),
        ]);
    }
    /** Finds the receipt PDA of a Listing trade state. */
    listingReceipt(input) {
        const programId = this.programId(input.programs);
        return Pda.find(programId, [
            Buffer.from('listing_receipt', 'utf8'),
            input.tradeState.toBuffer(),
        ]);
    }
    /** Finds the receipt PDA of a Bid trade state. */
    bidReceipt(input) {
        const programId = this.programId(input.programs);
        return Pda.find(programId, [
            Buffer.from('bid_receipt', 'utf8'),
            input.tradeState.toBuffer(),
        ]);
    }
    /** Finds the receipt PDA of a Purchase. */
    purchaseReceipt(input) {
        const programId = this.programId(input.programs);
        return Pda.find(programId, [
            Buffer.from('purchase_receipt', 'utf8'),
            input.listingTradeState.toBuffer(),
            input.bidTradeState.toBuffer(),
        ]);
    }
    programId(programs) {
        return this.metaplex.programs().getAuctionHouse(programs).address;
    }
}
//# sourceMappingURL=AuctionHousePdasClient.js.map