"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.HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR = void 0;
exports.getHandleV3AcrossMessageDiscriminatorBytes = getHandleV3AcrossMessageDiscriminatorBytes;
exports.getHandleV3AcrossMessageInstructionDataEncoder = getHandleV3AcrossMessageInstructionDataEncoder;
exports.getHandleV3AcrossMessageInstructionDataDecoder = getHandleV3AcrossMessageInstructionDataDecoder;
exports.getHandleV3AcrossMessageInstructionDataCodec = getHandleV3AcrossMessageInstructionDataCodec;
exports.getHandleV3AcrossMessageInstruction = getHandleV3AcrossMessageInstruction;
exports.parseHandleV3AcrossMessageInstruction = parseHandleV3AcrossMessageInstruction;
const web3_v2_js_1 = require("@solana/web3-v2.js");
const programs_1 = require("../programs");
exports.HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR = new Uint8Array([
    131, 141, 52, 71, 16, 59, 196, 92,
]);
function getHandleV3AcrossMessageDiscriminatorBytes() {
    return (0, web3_v2_js_1.fixEncoderSize)((0, web3_v2_js_1.getBytesEncoder)(), 8).encode(exports.HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR);
}
function getHandleV3AcrossMessageInstructionDataEncoder() {
    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)],
        ['message', (0, web3_v2_js_1.addEncoderSizePrefix)((0, web3_v2_js_1.getBytesEncoder)(), (0, web3_v2_js_1.getU32Encoder)())],
    ]), (value) => ({
        ...value,
        discriminator: exports.HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR,
    }));
}
function getHandleV3AcrossMessageInstructionDataDecoder() {
    return (0, web3_v2_js_1.getStructDecoder)([
        ['discriminator', (0, web3_v2_js_1.fixDecoderSize)((0, web3_v2_js_1.getBytesDecoder)(), 8)],
        ['message', (0, web3_v2_js_1.addDecoderSizePrefix)((0, web3_v2_js_1.getBytesDecoder)(), (0, web3_v2_js_1.getU32Decoder)())],
    ]);
}
function getHandleV3AcrossMessageInstructionDataCodec() {
    return (0, web3_v2_js_1.combineCodec)(getHandleV3AcrossMessageInstructionDataEncoder(), getHandleV3AcrossMessageInstructionDataDecoder());
}
function getHandleV3AcrossMessageInstruction(input, config) {
    // Program address.
    const programAddress = config?.programAddress ?? programs_1.MULTICALL_HANDLER_PROGRAM_ADDRESS;
    // Original args.
    const args = { ...input };
    const instruction = {
        programAddress,
        data: getHandleV3AcrossMessageInstructionDataEncoder().encode(args),
    };
    return instruction;
}
function parseHandleV3AcrossMessageInstruction(instruction) {
    return {
        programAddress: instruction.programAddress,
        data: getHandleV3AcrossMessageInstructionDataDecoder().decode(instruction.data),
    };
}
