"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CLAIM_ACCOUNT_DISCRIMINATOR = void 0;
exports.getClaimAccountDiscriminatorBytes = getClaimAccountDiscriminatorBytes;
exports.getClaimAccountEncoder = getClaimAccountEncoder;
exports.getClaimAccountDecoder = getClaimAccountDecoder;
exports.getClaimAccountCodec = getClaimAccountCodec;
exports.decodeClaimAccount = decodeClaimAccount;
exports.fetchClaimAccount = fetchClaimAccount;
exports.fetchMaybeClaimAccount = fetchMaybeClaimAccount;
exports.fetchAllClaimAccount = fetchAllClaimAccount;
exports.fetchAllMaybeClaimAccount = fetchAllMaybeClaimAccount;
exports.getClaimAccountSize = getClaimAccountSize;
var tslib_1 = require("tslib");
var kit_1 = require("@solana/kit");
exports.CLAIM_ACCOUNT_DISCRIMINATOR = new Uint8Array([
    113, 109, 47, 96, 242, 219, 61, 165,
]);
function getClaimAccountDiscriminatorBytes() {
    return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.CLAIM_ACCOUNT_DISCRIMINATOR);
}
function getClaimAccountEncoder() {
    return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
        ["discriminator", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
        ["amount", (0, kit_1.getU64Encoder)()],
        ["initializer", (0, kit_1.getAddressEncoder)()],
    ]), function (value) { return (tslib_1.__assign(tslib_1.__assign({}, value), { discriminator: exports.CLAIM_ACCOUNT_DISCRIMINATOR })); });
}
function getClaimAccountDecoder() {
    return (0, kit_1.getStructDecoder)([
        ["discriminator", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
        ["amount", (0, kit_1.getU64Decoder)()],
        ["initializer", (0, kit_1.getAddressDecoder)()],
    ]);
}
function getClaimAccountCodec() {
    return (0, kit_1.combineCodec)(getClaimAccountEncoder(), getClaimAccountDecoder());
}
function decodeClaimAccount(encodedAccount) {
    return (0, kit_1.decodeAccount)(encodedAccount, getClaimAccountDecoder());
}
function fetchClaimAccount(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, fetchMaybeClaimAccount(rpc, address, config)];
                case 1:
                    maybeAccount = _a.sent();
                    (0, kit_1.assertAccountExists)(maybeAccount);
                    return [2, maybeAccount];
            }
        });
    });
}
function fetchMaybeClaimAccount(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, decodeClaimAccount(maybeAccount)];
            }
        });
    });
}
function fetchAllClaimAccount(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, fetchAllMaybeClaimAccount(rpc, addresses, config)];
                case 1:
                    maybeAccounts = _a.sent();
                    (0, kit_1.assertAccountsExist)(maybeAccounts);
                    return [2, maybeAccounts];
            }
        });
    });
}
function fetchAllMaybeClaimAccount(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 decodeClaimAccount(maybeAccount); })];
            }
        });
    });
}
function getClaimAccountSize() {
    return 48;
}
//# sourceMappingURL=claimAccount.js.map