"use strict";
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;
var tslib_1 = require("tslib");
var kit_1 = require("@solana/kit");
var programs_1 = require("../programs");
exports.HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR = new Uint8Array([
    131, 141, 52, 71, 16, 59, 196, 92,
]);
function getHandleV3AcrossMessageDiscriminatorBytes() {
    return (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(exports.HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR);
}
function getHandleV3AcrossMessageInstructionDataEncoder() {
    return (0, kit_1.transformEncoder)((0, kit_1.getStructEncoder)([
        ["discriminator", (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8)],
        ["message", (0, kit_1.addEncoderSizePrefix)((0, kit_1.getBytesEncoder)(), (0, kit_1.getU32Encoder)())],
    ]), function (value) { return (tslib_1.__assign(tslib_1.__assign({}, value), { discriminator: exports.HANDLE_V3_ACROSS_MESSAGE_DISCRIMINATOR })); });
}
function getHandleV3AcrossMessageInstructionDataDecoder() {
    return (0, kit_1.getStructDecoder)([
        ["discriminator", (0, kit_1.fixDecoderSize)((0, kit_1.getBytesDecoder)(), 8)],
        ["message", (0, kit_1.addDecoderSizePrefix)((0, kit_1.getBytesDecoder)(), (0, kit_1.getU32Decoder)())],
    ]);
}
function getHandleV3AcrossMessageInstructionDataCodec() {
    return (0, kit_1.combineCodec)(getHandleV3AcrossMessageInstructionDataEncoder(), getHandleV3AcrossMessageInstructionDataDecoder());
}
function getHandleV3AcrossMessageInstruction(input, config) {
    var _a;
    var programAddress = (_a = config === null || config === void 0 ? void 0 : config.programAddress) !== null && _a !== void 0 ? _a : programs_1.MULTICALL_HANDLER_PROGRAM_ADDRESS;
    var args = tslib_1.__assign({}, input);
    return Object.freeze({
        data: getHandleV3AcrossMessageInstructionDataEncoder().encode(args),
        programAddress: programAddress,
    });
}
function parseHandleV3AcrossMessageInstruction(instruction) {
    return {
        programAddress: instruction.programAddress,
        data: getHandleV3AcrossMessageInstructionDataDecoder().decode(instruction.data),
    };
}
//# sourceMappingURL=handleV3AcrossMessage.js.map