"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.FILL_STATUS_ACCOUNT_DISCRIMINATOR = void 0;
exports.getFillStatusAccountDiscriminatorBytes = getFillStatusAccountDiscriminatorBytes;
exports.getFillStatusAccountEncoder = getFillStatusAccountEncoder;
exports.getFillStatusAccountDecoder = getFillStatusAccountDecoder;
exports.getFillStatusAccountCodec = getFillStatusAccountCodec;
exports.decodeFillStatusAccount = decodeFillStatusAccount;
exports.fetchFillStatusAccount = fetchFillStatusAccount;
exports.fetchMaybeFillStatusAccount = fetchMaybeFillStatusAccount;
exports.fetchAllFillStatusAccount = fetchAllFillStatusAccount;
exports.fetchAllMaybeFillStatusAccount = fetchAllMaybeFillStatusAccount;
exports.getFillStatusAccountSize = getFillStatusAccountSize;
const web3_v2_js_1 = require("@solana/web3-v2.js");
const types_1 = require("../types");
exports.FILL_STATUS_ACCOUNT_DISCRIMINATOR = new Uint8Array([
    105, 89, 88, 35, 24, 147, 178, 137,
]);
function getFillStatusAccountDiscriminatorBytes() {
    return (0, web3_v2_js_1.fixEncoderSize)((0, web3_v2_js_1.getBytesEncoder)(), 8).encode(exports.FILL_STATUS_ACCOUNT_DISCRIMINATOR);
}
function getFillStatusAccountEncoder() {
    return (0, web3_v2_js_1.transformEncoder)((0, web3_v2_js_1.getStructEncoder)([
        ['discriminator', (0, web3_v2_js_1.fixEncoderSize)((0, web3_v2_js_1.getBytesEncoder)(), 8)],
        ['status', (0, types_1.getFillStatusEncoder)()],
        ['relayer', (0, web3_v2_js_1.getAddressEncoder)()],
        ['fillDeadline', (0, web3_v2_js_1.getU32Encoder)()],
    ]), (value) => ({ ...value, discriminator: exports.FILL_STATUS_ACCOUNT_DISCRIMINATOR }));
}
function getFillStatusAccountDecoder() {
    return (0, web3_v2_js_1.getStructDecoder)([
        ['discriminator', (0, web3_v2_js_1.fixDecoderSize)((0, web3_v2_js_1.getBytesDecoder)(), 8)],
        ['status', (0, types_1.getFillStatusDecoder)()],
        ['relayer', (0, web3_v2_js_1.getAddressDecoder)()],
        ['fillDeadline', (0, web3_v2_js_1.getU32Decoder)()],
    ]);
}
function getFillStatusAccountCodec() {
    return (0, web3_v2_js_1.combineCodec)(getFillStatusAccountEncoder(), getFillStatusAccountDecoder());
}
function decodeFillStatusAccount(encodedAccount) {
    return (0, web3_v2_js_1.decodeAccount)(encodedAccount, getFillStatusAccountDecoder());
}
async function fetchFillStatusAccount(rpc, address, config) {
    const maybeAccount = await fetchMaybeFillStatusAccount(rpc, address, config);
    (0, web3_v2_js_1.assertAccountExists)(maybeAccount);
    return maybeAccount;
}
async function fetchMaybeFillStatusAccount(rpc, address, config) {
    const maybeAccount = await (0, web3_v2_js_1.fetchEncodedAccount)(rpc, address, config);
    return decodeFillStatusAccount(maybeAccount);
}
async function fetchAllFillStatusAccount(rpc, addresses, config) {
    const maybeAccounts = await fetchAllMaybeFillStatusAccount(rpc, addresses, config);
    (0, web3_v2_js_1.assertAccountsExist)(maybeAccounts);
    return maybeAccounts;
}
async function fetchAllMaybeFillStatusAccount(rpc, addresses, config) {
    const maybeAccounts = await (0, web3_v2_js_1.fetchEncodedAccounts)(rpc, addresses, config);
    return maybeAccounts.map((maybeAccount) => decodeFillStatusAccount(maybeAccount));
}
function getFillStatusAccountSize() {
    return 45;
}
