"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.safeFetchEditionMarkerV2FromSeeds = exports.fetchEditionMarkerV2FromSeeds = exports.findEditionMarkerV2Pda = exports.getEditionMarkerV2GpaBuilder = exports.safeFetchAllEditionMarkerV2 = exports.fetchAllEditionMarkerV2 = exports.safeFetchEditionMarkerV2 = exports.fetchEditionMarkerV2 = exports.deserializeEditionMarkerV2 = exports.getEditionMarkerV2AccountDataSerializer = void 0;
const umi_1 = require("@metaplex-foundation/umi");
const serializers_1 = require("@metaplex-foundation/umi/serializers");
const types_1 = require("../types");
function getEditionMarkerV2AccountDataSerializer() {
    return (0, serializers_1.struct)([
        ['key', (0, types_1.getKeySerializer)()],
        ['ledger', (0, serializers_1.bytes)({ size: (0, serializers_1.u32)() })],
    ], { description: 'EditionMarkerV2AccountData' });
}
exports.getEditionMarkerV2AccountDataSerializer = getEditionMarkerV2AccountDataSerializer;
function deserializeEditionMarkerV2(rawAccount) {
    return (0, umi_1.deserializeAccount)(rawAccount, getEditionMarkerV2AccountDataSerializer());
}
exports.deserializeEditionMarkerV2 = deserializeEditionMarkerV2;
async function fetchEditionMarkerV2(context, publicKey, options) {
    const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options);
    (0, umi_1.assertAccountExists)(maybeAccount, 'EditionMarkerV2');
    return deserializeEditionMarkerV2(maybeAccount);
}
exports.fetchEditionMarkerV2 = fetchEditionMarkerV2;
async function safeFetchEditionMarkerV2(context, publicKey, options) {
    const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options);
    return maybeAccount.exists ? deserializeEditionMarkerV2(maybeAccount) : null;
}
exports.safeFetchEditionMarkerV2 = safeFetchEditionMarkerV2;
async function fetchAllEditionMarkerV2(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, 'EditionMarkerV2');
        return deserializeEditionMarkerV2(maybeAccount);
    });
}
exports.fetchAllEditionMarkerV2 = fetchAllEditionMarkerV2;
async function safeFetchAllEditionMarkerV2(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) => deserializeEditionMarkerV2(maybeAccount));
}
exports.safeFetchAllEditionMarkerV2 = safeFetchAllEditionMarkerV2;
function getEditionMarkerV2GpaBuilder(context) {
    const programId = context.programs.getPublicKey('mplTokenMetadata', 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s');
    return (0, umi_1.gpaBuilder)(context, programId)
        .registerFields({
        key: [0, (0, types_1.getKeySerializer)()],
        ledger: [1, (0, serializers_1.bytes)({ size: (0, serializers_1.u32)() })],
    })
        .deserializeUsing((account) => deserializeEditionMarkerV2(account));
}
exports.getEditionMarkerV2GpaBuilder = getEditionMarkerV2GpaBuilder;
function findEditionMarkerV2Pda(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'),
        (0, serializers_1.string)({ size: 'variable' }).serialize('marker'),
    ]);
}
exports.findEditionMarkerV2Pda = findEditionMarkerV2Pda;
async function fetchEditionMarkerV2FromSeeds(context, seeds, options) {
    return fetchEditionMarkerV2(context, findEditionMarkerV2Pda(context, seeds), options);
}
exports.fetchEditionMarkerV2FromSeeds = fetchEditionMarkerV2FromSeeds;
async function safeFetchEditionMarkerV2FromSeeds(context, seeds, options) {
    return safeFetchEditionMarkerV2(context, findEditionMarkerV2Pda(context, seeds), options);
}
exports.safeFetchEditionMarkerV2FromSeeds = safeFetchEditionMarkerV2FromSeeds;
//# sourceMappingURL=editionMarkerV2.js.map