/**
 * 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, getArrayDecoder, getArrayEncoder, getBooleanDecoder, getBooleanEncoder, getBytesDecoder, getBytesEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, getU64Decoder, getU64Encoder, transformEncoder, } from "@solana/kit";
export var MESSAGE_TRANSMITTER_DISCRIMINATOR = new Uint8Array([
    71, 40, 180, 142, 19, 203, 35, 252,
]);
export function getMessageTransmitterDiscriminatorBytes() {
    return fixEncoderSize(getBytesEncoder(), 8).encode(MESSAGE_TRANSMITTER_DISCRIMINATOR);
}
/** Gets the encoder for {@link MessageTransmitterArgs} account data. */
export function getMessageTransmitterEncoder() {
    return transformEncoder(getStructEncoder([
        ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
        ["owner", getAddressEncoder()],
        ["pendingOwner", getAddressEncoder()],
        ["attesterManager", getAddressEncoder()],
        ["pauser", getAddressEncoder()],
        ["paused", getBooleanEncoder()],
        ["localDomain", getU32Encoder()],
        ["version", getU32Encoder()],
        ["signatureThreshold", getU32Encoder()],
        ["enabledAttesters", getArrayEncoder(getAddressEncoder())],
        ["maxMessageBodySize", getU64Encoder()],
    ]), function (value) { return (__assign(__assign({}, value), { discriminator: MESSAGE_TRANSMITTER_DISCRIMINATOR })); });
}
/** Gets the decoder for {@link MessageTransmitter} account data. */
export function getMessageTransmitterDecoder() {
    return getStructDecoder([
        ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
        ["owner", getAddressDecoder()],
        ["pendingOwner", getAddressDecoder()],
        ["attesterManager", getAddressDecoder()],
        ["pauser", getAddressDecoder()],
        ["paused", getBooleanDecoder()],
        ["localDomain", getU32Decoder()],
        ["version", getU32Decoder()],
        ["signatureThreshold", getU32Decoder()],
        ["enabledAttesters", getArrayDecoder(getAddressDecoder())],
        ["maxMessageBodySize", getU64Decoder()],
    ]);
}
/** Gets the codec for {@link MessageTransmitter} account data. */
export function getMessageTransmitterCodec() {
    return combineCodec(getMessageTransmitterEncoder(), getMessageTransmitterDecoder());
}
export function decodeMessageTransmitter(encodedAccount) {
    return decodeAccount(encodedAccount, getMessageTransmitterDecoder());
}
export function fetchMessageTransmitter(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*/, fetchMaybeMessageTransmitter(rpc, address, config)];
                case 1:
                    maybeAccount = _a.sent();
                    assertAccountExists(maybeAccount);
                    return [2 /*return*/, maybeAccount];
            }
        });
    });
}
export function fetchMaybeMessageTransmitter(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*/, decodeMessageTransmitter(maybeAccount)];
            }
        });
    });
}
export function fetchAllMessageTransmitter(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*/, fetchAllMaybeMessageTransmitter(rpc, addresses, config)];
                case 1:
                    maybeAccounts = _a.sent();
                    assertAccountsExist(maybeAccounts);
                    return [2 /*return*/, maybeAccounts];
            }
        });
    });
}
export function fetchAllMaybeMessageTransmitter(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 decodeMessageTransmitter(maybeAccount);
                        })];
            }
        });
    });
}
//# sourceMappingURL=messageTransmitter.js.map