"use strict";
/**
 * 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
 */
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;
const web3_v2_js_1 = require("@solana/web3-v2.js");
exports.CLAIM_ACCOUNT_DISCRIMINATOR = new Uint8Array([
    113, 109, 47, 96, 242, 219, 61, 165,
]);
function getClaimAccountDiscriminatorBytes() {
    return (0, web3_v2_js_1.fixEncoderSize)((0, web3_v2_js_1.getBytesEncoder)(), 8).encode(exports.CLAIM_ACCOUNT_DISCRIMINATOR);
}
function getClaimAccountEncoder() {
    return (0, web3_v2_js_1.transformEncoder)((0, web3_v2_js_1.getStructEncoder)([
        ['discriminator', (0, web3_v2_js_1.fixEncoderSize)((0, web3_v2_js_1.getBytesEncoder)(), 8)],
        ['amount', (0, web3_v2_js_1.getU64Encoder)()],
        ['initializer', (0, web3_v2_js_1.getAddressEncoder)()],
    ]), (value) => ({ ...value, discriminator: exports.CLAIM_ACCOUNT_DISCRIMINATOR }));
}
function getClaimAccountDecoder() {
    return (0, web3_v2_js_1.getStructDecoder)([
        ['discriminator', (0, web3_v2_js_1.fixDecoderSize)((0, web3_v2_js_1.getBytesDecoder)(), 8)],
        ['amount', (0, web3_v2_js_1.getU64Decoder)()],
        ['initializer', (0, web3_v2_js_1.getAddressDecoder)()],
    ]);
}
function getClaimAccountCodec() {
    return (0, web3_v2_js_1.combineCodec)(getClaimAccountEncoder(), getClaimAccountDecoder());
}
function decodeClaimAccount(encodedAccount) {
    return (0, web3_v2_js_1.decodeAccount)(encodedAccount, getClaimAccountDecoder());
}
async function fetchClaimAccount(rpc, address, config) {
    const maybeAccount = await fetchMaybeClaimAccount(rpc, address, config);
    (0, web3_v2_js_1.assertAccountExists)(maybeAccount);
    return maybeAccount;
}
async function fetchMaybeClaimAccount(rpc, address, config) {
    const maybeAccount = await (0, web3_v2_js_1.fetchEncodedAccount)(rpc, address, config);
    return decodeClaimAccount(maybeAccount);
}
async function fetchAllClaimAccount(rpc, addresses, config) {
    const maybeAccounts = await fetchAllMaybeClaimAccount(rpc, addresses, config);
    (0, web3_v2_js_1.assertAccountsExist)(maybeAccounts);
    return maybeAccounts;
}
async function fetchAllMaybeClaimAccount(rpc, addresses, config) {
    const maybeAccounts = await (0, web3_v2_js_1.fetchEncodedAccounts)(rpc, addresses, config);
    return maybeAccounts.map((maybeAccount) => decodeClaimAccount(maybeAccount));
}
function getClaimAccountSize() {
    return 48;
}
