"use strict";
/**
 * This code was AUTOGENERATED using the codama library.
 * Please DO NOT EDIT THIS FILE, instead use visitors
 * to add features, then rerun codama to update it.
 *
 * @see https://github.com/codama-idl/codama
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.MESSAGE_TRANSMITTER_DISCRIMINATOR = void 0;
exports.getMessageTransmitterDiscriminatorBytes = getMessageTransmitterDiscriminatorBytes;
exports.getMessageTransmitterEncoder = getMessageTransmitterEncoder;
exports.getMessageTransmitterDecoder = getMessageTransmitterDecoder;
exports.getMessageTransmitterCodec = getMessageTransmitterCodec;
exports.decodeMessageTransmitter = decodeMessageTransmitter;
exports.fetchMessageTransmitter = fetchMessageTransmitter;
exports.fetchMaybeMessageTransmitter = fetchMaybeMessageTransmitter;
exports.fetchAllMessageTransmitter = fetchAllMessageTransmitter;
exports.fetchAllMaybeMessageTransmitter = fetchAllMaybeMessageTransmitter;
const kit_1 = require("@solana/kit");
exports.MESSAGE_TRANSMITTER_DISCRIMINATOR = new Uint8Array([
    71, 40, 180, 142, 19, 203, 35, 252,
]);
function getMessageTransmitterDiscriminatorBytes() {
    return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.MESSAGE_TRANSMITTER_DISCRIMINATOR);
}
function getMessageTransmitterEncoder() {
    return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
        ['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
        ['owner', (0, kit_1.getAddressEncoder)()],
        ['pendingOwner', (0, kit_1.getAddressEncoder)()],
        ['attesterManager', (0, kit_1.getAddressEncoder)()],
        ['pauser', (0, kit_1.getAddressEncoder)()],
        ['paused', (0, kit_1.getBooleanEncoder)()],
        ['localDomain', (0, kit_1.getU32Encoder)()],
        ['version', (0, kit_1.getU32Encoder)()],
        ['signatureThreshold', (0, kit_1.getU32Encoder)()],
        ['enabledAttesters', (0, kit_1.getArrayEncoder)((0, kit_1.getAddressEncoder)())],
        ['maxMessageBodySize', (0, kit_1.getU64Encoder)()],
    ]), (value) => ({ ...value, discriminator: exports.MESSAGE_TRANSMITTER_DISCRIMINATOR }));
}
function getMessageTransmitterDecoder() {
    return (0, kit_1.getStructDecoder)([
        ['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
        ['owner', (0, kit_1.getAddressDecoder)()],
        ['pendingOwner', (0, kit_1.getAddressDecoder)()],
        ['attesterManager', (0, kit_1.getAddressDecoder)()],
        ['pauser', (0, kit_1.getAddressDecoder)()],
        ['paused', (0, kit_1.getBooleanDecoder)()],
        ['localDomain', (0, kit_1.getU32Decoder)()],
        ['version', (0, kit_1.getU32Decoder)()],
        ['signatureThreshold', (0, kit_1.getU32Decoder)()],
        ['enabledAttesters', (0, kit_1.getArrayDecoder)((0, kit_1.getAddressDecoder)())],
        ['maxMessageBodySize', (0, kit_1.getU64Decoder)()],
    ]);
}
function getMessageTransmitterCodec() {
    return (0, kit_1.combineCodec)(getMessageTransmitterEncoder(), getMessageTransmitterDecoder());
}
function decodeMessageTransmitter(encodedAccount) {
    return (0, kit_1.decodeAccount)(encodedAccount, getMessageTransmitterDecoder());
}
async function fetchMessageTransmitter(rpc, address, config) {
    const maybeAccount = await fetchMaybeMessageTransmitter(rpc, address, config);
    (0, kit_1.assertAccountExists)(maybeAccount);
    return maybeAccount;
}
async function fetchMaybeMessageTransmitter(rpc, address, config) {
    const maybeAccount = await (0, kit_1.fetchEncodedAccount)(rpc, address, config);
    return decodeMessageTransmitter(maybeAccount);
}
async function fetchAllMessageTransmitter(rpc, addresses, config) {
    const maybeAccounts = await fetchAllMaybeMessageTransmitter(rpc, addresses, config);
    (0, kit_1.assertAccountsExist)(maybeAccounts);
    return maybeAccounts;
}
async function fetchAllMaybeMessageTransmitter(rpc, addresses, config) {
    const maybeAccounts = await (0, kit_1.fetchEncodedAccounts)(rpc, addresses, config);
    return maybeAccounts.map((maybeAccount) => decodeMessageTransmitter(maybeAccount));
}
