"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_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR = void 0;
exports.getExecuteSlowRelayLeafParamsDiscriminatorBytes = getExecuteSlowRelayLeafParamsDiscriminatorBytes;
exports.getExecuteSlowRelayLeafParamsEncoder = getExecuteSlowRelayLeafParamsEncoder;
exports.getExecuteSlowRelayLeafParamsDecoder = getExecuteSlowRelayLeafParamsDecoder;
exports.getExecuteSlowRelayLeafParamsCodec = getExecuteSlowRelayLeafParamsCodec;
exports.decodeExecuteSlowRelayLeafParams = decodeExecuteSlowRelayLeafParams;
exports.fetchExecuteSlowRelayLeafParams = fetchExecuteSlowRelayLeafParams;
exports.fetchMaybeExecuteSlowRelayLeafParams = fetchMaybeExecuteSlowRelayLeafParams;
exports.fetchAllExecuteSlowRelayLeafParams = fetchAllExecuteSlowRelayLeafParams;
exports.fetchAllMaybeExecuteSlowRelayLeafParams = fetchAllMaybeExecuteSlowRelayLeafParams;
const web3_v2_js_1 = require("@solana/web3-v2.js");
const types_1 = require("../types");
exports.EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR = new Uint8Array([
    135, 208, 119, 251, 14, 222, 66, 155,
]);
function getExecuteSlowRelayLeafParamsDiscriminatorBytes() {
    return (0, web3_v2_js_1.fixEncoderSize)((0, web3_v2_js_1.getBytesEncoder)(), 8).encode(exports.EXECUTE_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR);
}
function getExecuteSlowRelayLeafParamsEncoder() {
    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)],
        ['slowFillLeaf', (0, types_1.getSlowFillEncoder)()],
        ['rootBundleId', (0, web3_v2_js_1.getU32Encoder)()],
        ['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_SLOW_RELAY_LEAF_PARAMS_DISCRIMINATOR,
    }));
}
function getExecuteSlowRelayLeafParamsDecoder() {
    return (0, web3_v2_js_1.getStructDecoder)([
        ['discriminator', (0, web3_v2_js_1.fixDecoderSize)((0, web3_v2_js_1.getBytesDecoder)(), 8)],
        ['slowFillLeaf', (0, types_1.getSlowFillDecoder)()],
        ['rootBundleId', (0, web3_v2_js_1.getU32Decoder)()],
        ['proof', (0, web3_v2_js_1.getArrayDecoder)((0, web3_v2_js_1.fixDecoderSize)((0, web3_v2_js_1.getBytesDecoder)(), 32))],
    ]);
}
function getExecuteSlowRelayLeafParamsCodec() {
    return (0, web3_v2_js_1.combineCodec)(getExecuteSlowRelayLeafParamsEncoder(), getExecuteSlowRelayLeafParamsDecoder());
}
function decodeExecuteSlowRelayLeafParams(encodedAccount) {
    return (0, web3_v2_js_1.decodeAccount)(encodedAccount, getExecuteSlowRelayLeafParamsDecoder());
}
async function fetchExecuteSlowRelayLeafParams(rpc, address, config) {
    const maybeAccount = await fetchMaybeExecuteSlowRelayLeafParams(rpc, address, config);
    (0, web3_v2_js_1.assertAccountExists)(maybeAccount);
    return maybeAccount;
}
async function fetchMaybeExecuteSlowRelayLeafParams(rpc, address, config) {
    const maybeAccount = await (0, web3_v2_js_1.fetchEncodedAccount)(rpc, address, config);
    return decodeExecuteSlowRelayLeafParams(maybeAccount);
}
async function fetchAllExecuteSlowRelayLeafParams(rpc, addresses, config) {
    const maybeAccounts = await fetchAllMaybeExecuteSlowRelayLeafParams(rpc, addresses, config);
    (0, web3_v2_js_1.assertAccountsExist)(maybeAccounts);
    return maybeAccounts;
}
async function fetchAllMaybeExecuteSlowRelayLeafParams(rpc, addresses, config) {
    const maybeAccounts = await (0, web3_v2_js_1.fetchEncodedAccounts)(rpc, addresses, config);
    return maybeAccounts.map((maybeAccount) => decodeExecuteSlowRelayLeafParams(maybeAccount));
}
