"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_SENT_DISCRIMINATOR = void 0;
exports.getMessageSentDiscriminatorBytes = getMessageSentDiscriminatorBytes;
exports.getMessageSentEncoder = getMessageSentEncoder;
exports.getMessageSentDecoder = getMessageSentDecoder;
exports.getMessageSentCodec = getMessageSentCodec;
exports.decodeMessageSent = decodeMessageSent;
exports.fetchMessageSent = fetchMessageSent;
exports.fetchMaybeMessageSent = fetchMaybeMessageSent;
exports.fetchAllMessageSent = fetchAllMessageSent;
exports.fetchAllMaybeMessageSent = fetchAllMaybeMessageSent;
const kit_1 = require("@solana/kit");
exports.MESSAGE_SENT_DISCRIMINATOR = new Uint8Array([
    131, 100, 133, 56, 166, 225, 151, 60,
]);
function getMessageSentDiscriminatorBytes() {
    return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.MESSAGE_SENT_DISCRIMINATOR);
}
function getMessageSentEncoder() {
    return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
        ['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
        ['rentPayer', (0, kit_1.getAddressEncoder)()],
        ['createdAt', (0, kit_1.getI64Encoder)()],
        ['message', (0, kit_1.addEncoderSizePrefix)((0, kit_1.getBytesEncoder)(), (0, kit_1.getU32Encoder)())],
    ]), (value) => ({ ...value, discriminator: exports.MESSAGE_SENT_DISCRIMINATOR }));
}
function getMessageSentDecoder() {
    return (0, kit_1.getStructDecoder)([
        ['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
        ['rentPayer', (0, kit_1.getAddressDecoder)()],
        ['createdAt', (0, kit_1.getI64Decoder)()],
        ['message', (0, kit_1.addDecoderSizePrefix)((0, kit_1.getBytesDecoder)(), (0, kit_1.getU32Decoder)())],
    ]);
}
function getMessageSentCodec() {
    return (0, kit_1.combineCodec)(getMessageSentEncoder(), getMessageSentDecoder());
}
function decodeMessageSent(encodedAccount) {
    return (0, kit_1.decodeAccount)(encodedAccount, getMessageSentDecoder());
}
async function fetchMessageSent(rpc, address, config) {
    const maybeAccount = await fetchMaybeMessageSent(rpc, address, config);
    (0, kit_1.assertAccountExists)(maybeAccount);
    return maybeAccount;
}
async function fetchMaybeMessageSent(rpc, address, config) {
    const maybeAccount = await (0, kit_1.fetchEncodedAccount)(rpc, address, config);
    return decodeMessageSent(maybeAccount);
}
async function fetchAllMessageSent(rpc, addresses, config) {
    const maybeAccounts = await fetchAllMaybeMessageSent(rpc, addresses, config);
    (0, kit_1.assertAccountsExist)(maybeAccounts);
    return maybeAccounts;
}
async function fetchAllMaybeMessageSent(rpc, addresses, config) {
    const maybeAccounts = await (0, kit_1.fetchEncodedAccounts)(rpc, addresses, config);
    return maybeAccounts.map((maybeAccount) => decodeMessageSent(maybeAccount));
}
