"use strict";
/**
 * This code was AUTOGENERATED using the kinobi library.
 * Please DO NOT EDIT THIS FILE, instead use visitors
 * to add features, then rerun kinobi to update it.
 *
 * @see https://github.com/metaplex-foundation/kinobi
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.revokeCollectionAuthority = exports.getRevokeCollectionAuthorityInstructionDataSerializer = void 0;
const umi_1 = require("@metaplex-foundation/umi");
const serializers_1 = require("@metaplex-foundation/umi/serializers");
const accounts_1 = require("../accounts");
const shared_1 = require("../shared");
function getRevokeCollectionAuthorityInstructionDataSerializer() {
    return (0, serializers_1.mapSerializer)((0, serializers_1.struct)([['discriminator', (0, serializers_1.u8)()]], { description: 'RevokeCollectionAuthorityInstructionData' }), (value) => ({ ...value, discriminator: 24 }));
}
exports.getRevokeCollectionAuthorityInstructionDataSerializer = getRevokeCollectionAuthorityInstructionDataSerializer;
// Instruction.
function revokeCollectionAuthority(context, input) {
    // Program ID.
    const programId = context.programs.getPublicKey('mplTokenMetadata', 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s');
    // Accounts.
    const resolvedAccounts = {
        collectionAuthorityRecord: {
            index: 0,
            isWritable: true,
            value: input.collectionAuthorityRecord ?? null,
        },
        delegateAuthority: {
            index: 1,
            isWritable: true,
            value: input.delegateAuthority ?? null,
        },
        revokeAuthority: {
            index: 2,
            isWritable: true,
            value: input.revokeAuthority ?? null,
        },
        metadata: {
            index: 3,
            isWritable: false,
            value: input.metadata ?? null,
        },
        mint: { index: 4, isWritable: false, value: input.mint ?? null },
    };
    // Default values.
    if (!resolvedAccounts.metadata.value) {
        resolvedAccounts.metadata.value = (0, accounts_1.findMetadataPda)(context, {
            mint: (0, shared_1.expectPublicKey)(resolvedAccounts.mint.value),
        });
    }
    // Accounts in order.
    const orderedAccounts = Object.values(resolvedAccounts).sort((a, b) => a.index - b.index);
    // Keys and Signers.
    const [keys, signers] = (0, shared_1.getAccountMetasAndSigners)(orderedAccounts, 'programId', programId);
    // Data.
    const data = getRevokeCollectionAuthorityInstructionDataSerializer().serialize({});
    // Bytes Created On Chain.
    const bytesCreatedOnChain = 0;
    return (0, umi_1.transactionBuilder)([
        { instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
    ]);
}
exports.revokeCollectionAuthority = revokeCollectionAuthority;
//# sourceMappingURL=revokeCollectionAuthority.js.map