"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.ROUTE_DISCRIMINATOR = void 0;
exports.getRouteDiscriminatorBytes = getRouteDiscriminatorBytes;
exports.getRouteEncoder = getRouteEncoder;
exports.getRouteDecoder = getRouteDecoder;
exports.getRouteCodec = getRouteCodec;
exports.decodeRoute = decodeRoute;
exports.fetchRoute = fetchRoute;
exports.fetchMaybeRoute = fetchMaybeRoute;
exports.fetchAllRoute = fetchAllRoute;
exports.fetchAllMaybeRoute = fetchAllMaybeRoute;
exports.getRouteSize = getRouteSize;
const kit_1 = require("@solana/kit");
exports.ROUTE_DISCRIMINATOR = new Uint8Array([
    80, 179, 58, 115, 52, 19, 146, 134,
]);
function getRouteDiscriminatorBytes() {
    return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.ROUTE_DISCRIMINATOR);
}
function getRouteEncoder() {
    return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
        ['discriminator', (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
        ['enabled', (0, kit_1.getBooleanEncoder)()],
    ]), (value) => ({ ...value, discriminator: exports.ROUTE_DISCRIMINATOR }));
}
function getRouteDecoder() {
    return (0, kit_1.getStructDecoder)([
        ['discriminator', (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
        ['enabled', (0, kit_1.getBooleanDecoder)()],
    ]);
}
function getRouteCodec() {
    return (0, kit_1.combineCodec)(getRouteEncoder(), getRouteDecoder());
}
function decodeRoute(encodedAccount) {
    return (0, kit_1.decodeAccount)(encodedAccount, getRouteDecoder());
}
async function fetchRoute(rpc, address, config) {
    const maybeAccount = await fetchMaybeRoute(rpc, address, config);
    (0, kit_1.assertAccountExists)(maybeAccount);
    return maybeAccount;
}
async function fetchMaybeRoute(rpc, address, config) {
    const maybeAccount = await (0, kit_1.fetchEncodedAccount)(rpc, address, config);
    return decodeRoute(maybeAccount);
}
async function fetchAllRoute(rpc, addresses, config) {
    const maybeAccounts = await fetchAllMaybeRoute(rpc, addresses, config);
    (0, kit_1.assertAccountsExist)(maybeAccounts);
    return maybeAccounts;
}
async function fetchAllMaybeRoute(rpc, addresses, config) {
    const maybeAccounts = await (0, kit_1.fetchEncodedAccounts)(rpc, addresses, config);
    return maybeAccounts.map((maybeAccount) => decodeRoute(maybeAccount));
}
function getRouteSize() {
    return 9;
}
