"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.getMultisigSize = exports.getMultisigGpaBuilder = exports.safeFetchAllMultisig = exports.fetchAllMultisig = exports.safeFetchMultisig = exports.fetchMultisig = exports.deserializeMultisig = exports.getMultisigAccountDataSerializer = void 0;
const umi_1 = require("@metaplex-foundation/umi");
const serializers_1 = require("@metaplex-foundation/umi/serializers");
function getMultisigAccountDataSerializer() {
    return (0, serializers_1.struct)([
        ['m', (0, serializers_1.u8)()],
        ['n', (0, serializers_1.u8)()],
        ['isInitialized', (0, serializers_1.bool)()],
        ['signers', (0, serializers_1.array)((0, serializers_1.publicKey)(), { size: 11 })],
    ], { description: 'MultisigAccountData' });
}
exports.getMultisigAccountDataSerializer = getMultisigAccountDataSerializer;
function deserializeMultisig(rawAccount) {
    return (0, umi_1.deserializeAccount)(rawAccount, getMultisigAccountDataSerializer());
}
exports.deserializeMultisig = deserializeMultisig;
async function fetchMultisig(context, publicKey, options) {
    const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options);
    (0, umi_1.assertAccountExists)(maybeAccount, 'Multisig');
    return deserializeMultisig(maybeAccount);
}
exports.fetchMultisig = fetchMultisig;
async function safeFetchMultisig(context, publicKey, options) {
    const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options);
    return maybeAccount.exists ? deserializeMultisig(maybeAccount) : null;
}
exports.safeFetchMultisig = safeFetchMultisig;
async function fetchAllMultisig(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, 'Multisig');
        return deserializeMultisig(maybeAccount);
    });
}
exports.fetchAllMultisig = fetchAllMultisig;
async function safeFetchAllMultisig(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) => deserializeMultisig(maybeAccount));
}
exports.safeFetchAllMultisig = safeFetchAllMultisig;
function getMultisigGpaBuilder(context) {
    const programId = context.programs.getPublicKey('splToken', 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');
    return (0, umi_1.gpaBuilder)(context, programId)
        .registerFields({
        m: [0, (0, serializers_1.u8)()],
        n: [1, (0, serializers_1.u8)()],
        isInitialized: [2, (0, serializers_1.bool)()],
        signers: [3, (0, serializers_1.array)((0, serializers_1.publicKey)(), { size: 11 })],
    })
        .deserializeUsing((account) => deserializeMultisig(account))
        .whereSize(355);
}
exports.getMultisigGpaBuilder = getMultisigGpaBuilder;
function getMultisigSize() {
    return 355;
}
exports.getMultisigSize = getMultisigSize;
//# sourceMappingURL=multisig.js.map