/**
 * 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, getU8Decoder, getU8Encoder, transformEncoder, } from "@solana/kit";
export var TOKEN_MESSENGER_DISCRIMINATOR = new Uint8Array([
    162, 4, 242, 52, 147, 243, 221, 96,
]);
export function getTokenMessengerDiscriminatorBytes() {
    return fixEncoderSize(getBytesEncoder(), 8).encode(TOKEN_MESSENGER_DISCRIMINATOR);
}
/** Gets the encoder for {@link TokenMessengerArgs} account data. */
export function getTokenMessengerEncoder() {
    return transformEncoder(getStructEncoder([
        ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
        ["owner", getAddressEncoder()],
        ["pendingOwner", getAddressEncoder()],
        ["localMessageTransmitter", getAddressEncoder()],
        ["messageBodyVersion", getU32Encoder()],
        ["authorityBump", getU8Encoder()],
    ]), function (value) { return (__assign(__assign({}, value), { discriminator: TOKEN_MESSENGER_DISCRIMINATOR })); });
}
/** Gets the decoder for {@link TokenMessenger} account data. */
export function getTokenMessengerDecoder() {
    return getStructDecoder([
        ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
        ["owner", getAddressDecoder()],
        ["pendingOwner", getAddressDecoder()],
        ["localMessageTransmitter", getAddressDecoder()],
        ["messageBodyVersion", getU32Decoder()],
        ["authorityBump", getU8Decoder()],
    ]);
}
/** Gets the codec for {@link TokenMessenger} account data. */
export function getTokenMessengerCodec() {
    return combineCodec(getTokenMessengerEncoder(), getTokenMessengerDecoder());
}
export function decodeTokenMessenger(encodedAccount) {
    return decodeAccount(encodedAccount, getTokenMessengerDecoder());
}
export function fetchTokenMessenger(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*/, fetchMaybeTokenMessenger(rpc, address, config)];
                case 1:
                    maybeAccount = _a.sent();
                    assertAccountExists(maybeAccount);
                    return [2 /*return*/, maybeAccount];
            }
        });
    });
}
export function fetchMaybeTokenMessenger(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*/, decodeTokenMessenger(maybeAccount)];
            }
        });
    });
}
export function fetchAllTokenMessenger(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*/, fetchAllMaybeTokenMessenger(rpc, addresses, config)];
                case 1:
                    maybeAccounts = _a.sent();
                    assertAccountsExist(maybeAccounts);
                    return [2 /*return*/, maybeAccounts];
            }
        });
    });
}
export function fetchAllMaybeTokenMessenger(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 decodeTokenMessenger(maybeAccount);
                        })];
            }
        });
    });
}
export function getTokenMessengerSize() {
    return 109;
}
//# sourceMappingURL=tokenMessenger.js.map