"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.EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR = void 0;
exports.getExecuteRelayerRefundLeafParamsDiscriminatorBytes = getExecuteRelayerRefundLeafParamsDiscriminatorBytes;
exports.getExecuteRelayerRefundLeafParamsEncoder = getExecuteRelayerRefundLeafParamsEncoder;
exports.getExecuteRelayerRefundLeafParamsDecoder = getExecuteRelayerRefundLeafParamsDecoder;
exports.getExecuteRelayerRefundLeafParamsCodec = getExecuteRelayerRefundLeafParamsCodec;
exports.decodeExecuteRelayerRefundLeafParams = decodeExecuteRelayerRefundLeafParams;
exports.fetchExecuteRelayerRefundLeafParams = fetchExecuteRelayerRefundLeafParams;
exports.fetchMaybeExecuteRelayerRefundLeafParams = fetchMaybeExecuteRelayerRefundLeafParams;
exports.fetchAllExecuteRelayerRefundLeafParams = fetchAllExecuteRelayerRefundLeafParams;
exports.fetchAllMaybeExecuteRelayerRefundLeafParams = fetchAllMaybeExecuteRelayerRefundLeafParams;
const web3_v2_js_1 = require("@solana/web3-v2.js");
const types_1 = require("../types");
exports.EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR = new Uint8Array([
    192, 59, 93, 9, 171, 77, 28, 250,
]);
function getExecuteRelayerRefundLeafParamsDiscriminatorBytes() {
    return (0, web3_v2_js_1.fixEncoderSize)((0, web3_v2_js_1.getBytesEncoder)(), 8).encode(exports.EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR);
}
function getExecuteRelayerRefundLeafParamsEncoder() {
    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)],
        ['rootBundleId', (0, web3_v2_js_1.getU32Encoder)()],
        ['relayerRefundLeaf', (0, types_1.getRelayerRefundLeafEncoder)()],
        ['proof', (0, web3_v2_js_1.getArrayEncoder)((0, web3_v2_js_1.fixEncoderSize)((0, web3_v2_js_1.getBytesEncoder)(), 32))],
    ]), (value) => ({
        ...value,
        discriminator: exports.EXECUTE_RELAYER_REFUND_LEAF_PARAMS_DISCRIMINATOR,
    }));
}
function getExecuteRelayerRefundLeafParamsDecoder() {
    return (0, web3_v2_js_1.getStructDecoder)([
        ['discriminator', (0, web3_v2_js_1.fixDecoderSize)((0, web3_v2_js_1.getBytesDecoder)(), 8)],
        ['rootBundleId', (0, web3_v2_js_1.getU32Decoder)()],
        ['relayerRefundLeaf', (0, types_1.getRelayerRefundLeafDecoder)()],
        ['proof', (0, web3_v2_js_1.getArrayDecoder)((0, web3_v2_js_1.fixDecoderSize)((0, web3_v2_js_1.getBytesDecoder)(), 32))],
    ]);
}
function getExecuteRelayerRefundLeafParamsCodec() {
    return (0, web3_v2_js_1.combineCodec)(getExecuteRelayerRefundLeafParamsEncoder(), getExecuteRelayerRefundLeafParamsDecoder());
}
function decodeExecuteRelayerRefundLeafParams(encodedAccount) {
    return (0, web3_v2_js_1.decodeAccount)(encodedAccount, getExecuteRelayerRefundLeafParamsDecoder());
}
async function fetchExecuteRelayerRefundLeafParams(rpc, address, config) {
    const maybeAccount = await fetchMaybeExecuteRelayerRefundLeafParams(rpc, address, config);
    (0, web3_v2_js_1.assertAccountExists)(maybeAccount);
    return maybeAccount;
}
async function fetchMaybeExecuteRelayerRefundLeafParams(rpc, address, config) {
    const maybeAccount = await (0, web3_v2_js_1.fetchEncodedAccount)(rpc, address, config);
    return decodeExecuteRelayerRefundLeafParams(maybeAccount);
}
async function fetchAllExecuteRelayerRefundLeafParams(rpc, addresses, config) {
    const maybeAccounts = await fetchAllMaybeExecuteRelayerRefundLeafParams(rpc, addresses, config);
    (0, web3_v2_js_1.assertAccountsExist)(maybeAccounts);
    return maybeAccounts;
}
async function fetchAllMaybeExecuteRelayerRefundLeafParams(rpc, addresses, config) {
    const maybeAccounts = await (0, web3_v2_js_1.fetchEncodedAccounts)(rpc, addresses, config);
    return maybeAccounts.map((maybeAccount) => decodeExecuteRelayerRefundLeafParams(maybeAccount));
}
