/**
 * 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, getU128Decoder, getU128Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, } from "@solana/kit";
export var LOCAL_TOKEN_DISCRIMINATOR = new Uint8Array([
    159, 131, 58, 170, 193, 84, 128, 182,
]);
export function getLocalTokenDiscriminatorBytes() {
    return fixEncoderSize(getBytesEncoder(), 8).encode(LOCAL_TOKEN_DISCRIMINATOR);
}
/** Gets the encoder for {@link LocalTokenArgs} account data. */
export function getLocalTokenEncoder() {
    return transformEncoder(getStructEncoder([
        ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
        ["custody", getAddressEncoder()],
        ["mint", getAddressEncoder()],
        ["burnLimitPerMessage", getU64Encoder()],
        ["messagesSent", getU64Encoder()],
        ["messagesReceived", getU64Encoder()],
        ["amountSent", getU128Encoder()],
        ["amountReceived", getU128Encoder()],
        ["bump", getU8Encoder()],
        ["custodyBump", getU8Encoder()],
    ]), function (value) { return (__assign(__assign({}, value), { discriminator: LOCAL_TOKEN_DISCRIMINATOR })); });
}
/** Gets the decoder for {@link LocalToken} account data. */
export function getLocalTokenDecoder() {
    return getStructDecoder([
        ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
        ["custody", getAddressDecoder()],
        ["mint", getAddressDecoder()],
        ["burnLimitPerMessage", getU64Decoder()],
        ["messagesSent", getU64Decoder()],
        ["messagesReceived", getU64Decoder()],
        ["amountSent", getU128Decoder()],
        ["amountReceived", getU128Decoder()],
        ["bump", getU8Decoder()],
        ["custodyBump", getU8Decoder()],
    ]);
}
/** Gets the codec for {@link LocalToken} account data. */
export function getLocalTokenCodec() {
    return combineCodec(getLocalTokenEncoder(), getLocalTokenDecoder());
}
export function decodeLocalToken(encodedAccount) {
    return decodeAccount(encodedAccount, getLocalTokenDecoder());
}
export function fetchLocalToken(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*/, fetchMaybeLocalToken(rpc, address, config)];
                case 1:
                    maybeAccount = _a.sent();
                    assertAccountExists(maybeAccount);
                    return [2 /*return*/, maybeAccount];
            }
        });
    });
}
export function fetchMaybeLocalToken(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*/, decodeLocalToken(maybeAccount)];
            }
        });
    });
}
export function fetchAllLocalToken(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*/, fetchAllMaybeLocalToken(rpc, addresses, config)];
                case 1:
                    maybeAccounts = _a.sent();
                    assertAccountsExist(maybeAccounts);
                    return [2 /*return*/, maybeAccounts];
            }
        });
    });
}
export function fetchAllMaybeLocalToken(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 decodeLocalToken(maybeAccount); })];
            }
        });
    });
}
export function getLocalTokenSize() {
    return 130;
}
//# sourceMappingURL=localToken.js.map