/**
 * 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
 */
import { __assign, __awaiter, __generator } from "tslib";
import { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fixDecoderSize, fixEncoderSize, getAddressDecoder, getAddressEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, transformEncoder, } from "@solana/kit";
import { getFillStatusDecoder, getFillStatusEncoder, } from "../types";
export var FILL_STATUS_ACCOUNT_DISCRIMINATOR = new Uint8Array([
    105, 89, 88, 35, 24, 147, 178, 137,
]);
export function getFillStatusAccountDiscriminatorBytes() {
    return fixEncoderSize(getBytesEncoder(), 8).encode(FILL_STATUS_ACCOUNT_DISCRIMINATOR);
}
/** Gets the encoder for {@link FillStatusAccountArgs} account data. */
export function getFillStatusAccountEncoder() {
    return transformEncoder(getStructEncoder([
        ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
        ["status", getFillStatusEncoder()],
        ["relayer", getAddressEncoder()],
        ["fillDeadline", getU32Encoder()],
    ]), function (value) { return (__assign(__assign({}, value), { discriminator: FILL_STATUS_ACCOUNT_DISCRIMINATOR })); });
}
/** Gets the decoder for {@link FillStatusAccount} account data. */
export function getFillStatusAccountDecoder() {
    return getStructDecoder([
        ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
        ["status", getFillStatusDecoder()],
        ["relayer", getAddressDecoder()],
        ["fillDeadline", getU32Decoder()],
    ]);
}
/** Gets the codec for {@link FillStatusAccount} account data. */
export function getFillStatusAccountCodec() {
    return combineCodec(getFillStatusAccountEncoder(), getFillStatusAccountDecoder());
}
export function decodeFillStatusAccount(encodedAccount) {
    return decodeAccount(encodedAccount, getFillStatusAccountDecoder());
}
export function fetchFillStatusAccount(rpc, address, config) {
    return __awaiter(this, void 0, void 0, function () {
        var maybeAccount;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, fetchMaybeFillStatusAccount(rpc, address, config)];
                case 1:
                    maybeAccount = _a.sent();
                    assertAccountExists(maybeAccount);
                    return [2 /*return*/, maybeAccount];
            }
        });
    });
}
export function fetchMaybeFillStatusAccount(rpc, address, config) {
    return __awaiter(this, void 0, void 0, function () {
        var maybeAccount;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, fetchEncodedAccount(rpc, address, config)];
                case 1:
                    maybeAccount = _a.sent();
                    return [2 /*return*/, decodeFillStatusAccount(maybeAccount)];
            }
        });
    });
}
export function fetchAllFillStatusAccount(rpc, addresses, config) {
    return __awaiter(this, void 0, void 0, function () {
        var maybeAccounts;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, fetchAllMaybeFillStatusAccount(rpc, addresses, config)];
                case 1:
                    maybeAccounts = _a.sent();
                    assertAccountsExist(maybeAccounts);
                    return [2 /*return*/, maybeAccounts];
            }
        });
    });
}
export function fetchAllMaybeFillStatusAccount(rpc, addresses, config) {
    return __awaiter(this, void 0, void 0, function () {
        var maybeAccounts;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, fetchEncodedAccounts(rpc, addresses, config)];
                case 1:
                    maybeAccounts = _a.sent();
                    return [2 /*return*/, maybeAccounts.map(function (maybeAccount) {
                            return decodeFillStatusAccount(maybeAccount);
                        })];
            }
        });
    });
}
export function getFillStatusAccountSize() {
    return 45;
}
//# sourceMappingURL=fillStatusAccount.js.map