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