/**
 * 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, getU64Decoder, getU64Encoder, transformEncoder, } from "@solana/kit";
export var CLAIM_ACCOUNT_DISCRIMINATOR = new Uint8Array([
    113, 109, 47, 96, 242, 219, 61, 165,
]);
export function getClaimAccountDiscriminatorBytes() {
    return fixEncoderSize(getBytesEncoder(), 8).encode(CLAIM_ACCOUNT_DISCRIMINATOR);
}
/** Gets the encoder for {@link ClaimAccountArgs} account data. */
export function getClaimAccountEncoder() {
    return transformEncoder(getStructEncoder([
        ["discriminator", fixEncoderSize(getBytesEncoder(), 8)],
        ["amount", getU64Encoder()],
        ["initializer", getAddressEncoder()],
    ]), function (value) { return (__assign(__assign({}, value), { discriminator: CLAIM_ACCOUNT_DISCRIMINATOR })); });
}
/** Gets the decoder for {@link ClaimAccount} account data. */
export function getClaimAccountDecoder() {
    return getStructDecoder([
        ["discriminator", fixDecoderSize(getBytesDecoder(), 8)],
        ["amount", getU64Decoder()],
        ["initializer", getAddressDecoder()],
    ]);
}
/** Gets the codec for {@link ClaimAccount} account data. */
export function getClaimAccountCodec() {
    return combineCodec(getClaimAccountEncoder(), getClaimAccountDecoder());
}
export function decodeClaimAccount(encodedAccount) {
    return decodeAccount(encodedAccount, getClaimAccountDecoder());
}
export function fetchClaimAccount(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*/, fetchMaybeClaimAccount(rpc, address, config)];
                case 1:
                    maybeAccount = _a.sent();
                    assertAccountExists(maybeAccount);
                    return [2 /*return*/, maybeAccount];
            }
        });
    });
}
export function fetchMaybeClaimAccount(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*/, decodeClaimAccount(maybeAccount)];
            }
        });
    });
}
export function fetchAllClaimAccount(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*/, fetchAllMaybeClaimAccount(rpc, addresses, config)];
                case 1:
                    maybeAccounts = _a.sent();
                    assertAccountsExist(maybeAccounts);
                    return [2 /*return*/, maybeAccounts];
            }
        });
    });
}
export function fetchAllMaybeClaimAccount(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 decodeClaimAccount(maybeAccount); })];
            }
        });
    });
}
export function getClaimAccountSize() {
    return 48;
}
//# sourceMappingURL=claimAccount.js.map