"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.safeFetchDeprecatedMasterEditionV1FromSeeds = exports.fetchDeprecatedMasterEditionV1FromSeeds = exports.findDeprecatedMasterEditionV1Pda = exports.getDeprecatedMasterEditionV1GpaBuilder = exports.safeFetchAllDeprecatedMasterEditionV1 = exports.fetchAllDeprecatedMasterEditionV1 = exports.safeFetchDeprecatedMasterEditionV1 = exports.fetchDeprecatedMasterEditionV1 = exports.deserializeDeprecatedMasterEditionV1 = exports.getDeprecatedMasterEditionV1AccountDataSerializer = void 0;
const umi_1 = require("@metaplex-foundation/umi");
const serializers_1 = require("@metaplex-foundation/umi/serializers");
const types_1 = require("../types");
function getDeprecatedMasterEditionV1AccountDataSerializer() {
    return (0, serializers_1.mapSerializer)((0, serializers_1.struct)([
        ['key', (0, types_1.getKeySerializer)()],
        ['supply', (0, serializers_1.u64)()],
        ['maxSupply', (0, serializers_1.option)((0, serializers_1.u64)())],
        ['printingMint', (0, serializers_1.publicKey)()],
        ['oneTimePrintingAuthorizationMint', (0, serializers_1.publicKey)()],
    ], { description: 'DeprecatedMasterEditionV1AccountData' }), (value) => ({ ...value, key: types_1.Key.MasterEditionV1 }));
}
exports.getDeprecatedMasterEditionV1AccountDataSerializer = getDeprecatedMasterEditionV1AccountDataSerializer;
function deserializeDeprecatedMasterEditionV1(rawAccount) {
    return (0, umi_1.deserializeAccount)(rawAccount, getDeprecatedMasterEditionV1AccountDataSerializer());
}
exports.deserializeDeprecatedMasterEditionV1 = deserializeDeprecatedMasterEditionV1;
async function fetchDeprecatedMasterEditionV1(context, publicKey, options) {
    const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options);
    (0, umi_1.assertAccountExists)(maybeAccount, 'DeprecatedMasterEditionV1');
    return deserializeDeprecatedMasterEditionV1(maybeAccount);
}
exports.fetchDeprecatedMasterEditionV1 = fetchDeprecatedMasterEditionV1;
async function safeFetchDeprecatedMasterEditionV1(context, publicKey, options) {
    const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options);
    return maybeAccount.exists
        ? deserializeDeprecatedMasterEditionV1(maybeAccount)
        : null;
}
exports.safeFetchDeprecatedMasterEditionV1 = safeFetchDeprecatedMasterEditionV1;
async function fetchAllDeprecatedMasterEditionV1(context, publicKeys, options) {
    const maybeAccounts = await context.rpc.getAccounts(publicKeys.map((key) => (0, umi_1.publicKey)(key, false)), options);
    return maybeAccounts.map((maybeAccount) => {
        (0, umi_1.assertAccountExists)(maybeAccount, 'DeprecatedMasterEditionV1');
        return deserializeDeprecatedMasterEditionV1(maybeAccount);
    });
}
exports.fetchAllDeprecatedMasterEditionV1 = fetchAllDeprecatedMasterEditionV1;
async function safeFetchAllDeprecatedMasterEditionV1(context, publicKeys, options) {
    const maybeAccounts = await context.rpc.getAccounts(publicKeys.map((key) => (0, umi_1.publicKey)(key, false)), options);
    return maybeAccounts
        .filter((maybeAccount) => maybeAccount.exists)
        .map((maybeAccount) => deserializeDeprecatedMasterEditionV1(maybeAccount));
}
exports.safeFetchAllDeprecatedMasterEditionV1 = safeFetchAllDeprecatedMasterEditionV1;
function getDeprecatedMasterEditionV1GpaBuilder(context) {
    const programId = context.programs.getPublicKey('mplTokenMetadata', 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s');
    return (0, umi_1.gpaBuilder)(context, programId)
        .registerFields({
        key: [0, (0, types_1.getKeySerializer)()],
        supply: [1, (0, serializers_1.u64)()],
        maxSupply: [9, (0, serializers_1.option)((0, serializers_1.u64)())],
        printingMint: [null, (0, serializers_1.publicKey)()],
        oneTimePrintingAuthorizationMint: [null, (0, serializers_1.publicKey)()],
    })
        .deserializeUsing((account) => deserializeDeprecatedMasterEditionV1(account))
        .whereField('key', types_1.Key.MasterEditionV1);
}
exports.getDeprecatedMasterEditionV1GpaBuilder = getDeprecatedMasterEditionV1GpaBuilder;
function findDeprecatedMasterEditionV1Pda(context, seeds) {
    const programId = context.programs.getPublicKey('mplTokenMetadata', 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s');
    return context.eddsa.findPda(programId, [
        (0, serializers_1.string)({ size: 'variable' }).serialize('metadata'),
        (0, serializers_1.publicKey)().serialize(programId),
        (0, serializers_1.publicKey)().serialize(seeds.mint),
        (0, serializers_1.string)({ size: 'variable' }).serialize('edition'),
    ]);
}
exports.findDeprecatedMasterEditionV1Pda = findDeprecatedMasterEditionV1Pda;
async function fetchDeprecatedMasterEditionV1FromSeeds(context, seeds, options) {
    return fetchDeprecatedMasterEditionV1(context, findDeprecatedMasterEditionV1Pda(context, seeds), options);
}
exports.fetchDeprecatedMasterEditionV1FromSeeds = fetchDeprecatedMasterEditionV1FromSeeds;
async function safeFetchDeprecatedMasterEditionV1FromSeeds(context, seeds, options) {
    return safeFetchDeprecatedMasterEditionV1(context, findDeprecatedMasterEditionV1Pda(context, seeds), options);
}
exports.safeFetchDeprecatedMasterEditionV1FromSeeds = safeFetchDeprecatedMasterEditionV1FromSeeds;
//# sourceMappingURL=deprecatedMasterEditionV1.js.map