"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.TOKEN_MESSENGER_DISCRIMINATOR = void 0;
exports.getTokenMessengerDiscriminatorBytes = getTokenMessengerDiscriminatorBytes;
exports.getTokenMessengerEncoder = getTokenMessengerEncoder;
exports.getTokenMessengerDecoder = getTokenMessengerDecoder;
exports.getTokenMessengerCodec = getTokenMessengerCodec;
exports.decodeTokenMessenger = decodeTokenMessenger;
exports.fetchTokenMessenger = fetchTokenMessenger;
exports.fetchMaybeTokenMessenger = fetchMaybeTokenMessenger;
exports.fetchAllTokenMessenger = fetchAllTokenMessenger;
exports.fetchAllMaybeTokenMessenger = fetchAllMaybeTokenMessenger;
exports.getTokenMessengerSize = getTokenMessengerSize;
const kit_1 = require("@solana/kit");
exports.TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([
    162, 4, 242, 52, 147, 243, 221, 96,
]);
function getTokenMessengerDiscriminatorBytes() {
    return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.TOKEN_MESSENGER_DISCRIMINATOR);
}
function getTokenMessengerEncoder() {
    return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
        ['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
        ['denylister', (0, kit_1.getAddressEncoder)()],
        ['owner', (0, kit_1.getAddressEncoder)()],
        ['pendingOwner', (0, kit_1.getAddressEncoder)()],
        ['messageBodyVersion', (0, kit_1.getU32Encoder)()],
        ['authorityBump', (0, kit_1.getU8Encoder)()],
        ['feeRecipient', (0, kit_1.getAddressEncoder)()],
        ['minFeeController', (0, kit_1.getAddressEncoder)()],
        ['minFee', (0, kit_1.getU32Encoder)()],
    ]), (value) => ({ ...value, discriminator: exports.TOKEN_MESSENGER_DISCRIMINATOR }));
}
function getTokenMessengerDecoder() {
    return (0, kit_1.getStructDecoder)([
        ['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
        ['denylister', (0, kit_1.getAddressDecoder)()],
        ['owner', (0, kit_1.getAddressDecoder)()],
        ['pendingOwner', (0, kit_1.getAddressDecoder)()],
        ['messageBodyVersion', (0, kit_1.getU32Decoder)()],
        ['authorityBump', (0, kit_1.getU8Decoder)()],
        ['feeRecipient', (0, kit_1.getAddressDecoder)()],
        ['minFeeController', (0, kit_1.getAddressDecoder)()],
        ['minFee', (0, kit_1.getU32Decoder)()],
    ]);
}
function getTokenMessengerCodec() {
    return (0, kit_1.combineCodec)(getTokenMessengerEncoder(), getTokenMessengerDecoder());
}
function decodeTokenMessenger(encodedAccount) {
    return (0, kit_1.decodeAccount)(encodedAccount, getTokenMessengerDecoder());
}
async function fetchTokenMessenger(rpc, address, config) {
    const maybeAccount = await fetchMaybeTokenMessenger(rpc, address, config);
    (0, kit_1.assertAccountExists)(maybeAccount);
    return maybeAccount;
}
async function fetchMaybeTokenMessenger(rpc, address, config) {
    const maybeAccount = await (0, kit_1.fetchEncodedAccount)(rpc, address, config);
    return decodeTokenMessenger(maybeAccount);
}
async function fetchAllTokenMessenger(rpc, addresses, config) {
    const maybeAccounts = await fetchAllMaybeTokenMessenger(rpc, addresses, config);
    (0, kit_1.assertAccountsExist)(maybeAccounts);
    return maybeAccounts;
}
async function fetchAllMaybeTokenMessenger(rpc, addresses, config) {
    const maybeAccounts = await (0, kit_1.fetchEncodedAccounts)(rpc, addresses, config);
    return maybeAccounts.map((maybeAccount) => decodeTokenMessenger(maybeAccount));
}
function getTokenMessengerSize() {
    return 177;
}
