"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.getMintSize = exports.getMintGpaBuilder = exports.safeFetchAllMint = exports.fetchAllMint = exports.safeFetchMint = exports.fetchMint = exports.deserializeMint = exports.getMintAccountDataSerializer = void 0;
const umi_1 = require("@metaplex-foundation/umi");
const serializers_1 = require("@metaplex-foundation/umi/serializers");
function getMintAccountDataSerializer() {
    return (0, serializers_1.struct)([
        [
            'mintAuthority',
            (0, serializers_1.option)((0, serializers_1.publicKey)(), { prefix: (0, serializers_1.u32)(), fixed: true }),
        ],
        ['supply', (0, serializers_1.u64)()],
        ['decimals', (0, serializers_1.u8)()],
        ['isInitialized', (0, serializers_1.bool)()],
        [
            'freezeAuthority',
            (0, serializers_1.option)((0, serializers_1.publicKey)(), { prefix: (0, serializers_1.u32)(), fixed: true }),
        ],
    ], { description: 'MintAccountData' });
}
exports.getMintAccountDataSerializer = getMintAccountDataSerializer;
function deserializeMint(rawAccount) {
    return (0, umi_1.deserializeAccount)(rawAccount, getMintAccountDataSerializer());
}
exports.deserializeMint = deserializeMint;
async function fetchMint(context, publicKey, options) {
    const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options);
    (0, umi_1.assertAccountExists)(maybeAccount, 'Mint');
    return deserializeMint(maybeAccount);
}
exports.fetchMint = fetchMint;
async function safeFetchMint(context, publicKey, options) {
    const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options);
    return maybeAccount.exists ? deserializeMint(maybeAccount) : null;
}
exports.safeFetchMint = safeFetchMint;
async function fetchAllMint(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, 'Mint');
        return deserializeMint(maybeAccount);
    });
}
exports.fetchAllMint = fetchAllMint;
async function safeFetchAllMint(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) => deserializeMint(maybeAccount));
}
exports.safeFetchAllMint = safeFetchAllMint;
function getMintGpaBuilder(context) {
    const programId = context.programs.getPublicKey('splToken', 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
    return (0, umi_1.gpaBuilder)(context, programId)
        .registerFields({
        mintAuthority: [
            0,
            (0, serializers_1.option)((0, serializers_1.publicKey)(), { prefix: (0, serializers_1.u32)(), fixed: true }),
        ],
        supply: [36, (0, serializers_1.u64)()],
        decimals: [44, (0, serializers_1.u8)()],
        isInitialized: [45, (0, serializers_1.bool)()],
        freezeAuthority: [
            46,
            (0, serializers_1.option)((0, serializers_1.publicKey)(), { prefix: (0, serializers_1.u32)(), fixed: true }),
        ],
    })
        .deserializeUsing((account) => deserializeMint(account))
        .whereSize(82);
}
exports.getMintGpaBuilder = getMintGpaBuilder;
function getMintSize() {
    return 82;
}
exports.getMintSize = getMintSize;
//# sourceMappingURL=mint.js.map