"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MulticallHandlerInstruction = exports.MULTICALL_HANDLER_PROGRAM_ADDRESS = void 0;
exports.identifyMulticallHandlerInstruction = identifyMulticallHandlerInstruction;
exports.parseMulticallHandlerInstruction = parseMulticallHandlerInstruction;
var tslib_1 = require("tslib");
var kit_1 = require("@solana/kit");
var instructions_1 = require("../instructions");
exports.MULTICALL_HANDLER_PROGRAM_ADDRESS = "HaQe51FWtnmaEcuYEfPA7MRCXKrtqptat4oJdJ8zV5Be";
var MulticallHandlerInstruction;
(function (MulticallHandlerInstruction) {
    MulticallHandlerInstruction[MulticallHandlerInstruction["HandleV3AcrossMessage"] = 0] = "HandleV3AcrossMessage";
})(MulticallHandlerInstruction || (exports.MulticallHandlerInstruction = MulticallHandlerInstruction = {}));
function identifyMulticallHandlerInstruction(instruction) {
    var data = "data" in instruction ? instruction.data : instruction;
    if ((0, kit_1.containsBytes)(data, (0, kit_1.fixEncoderSize)((0, kit_1.getBytesEncoder)(), 8).encode(new Uint8Array([131, 141, 52, 71, 16, 59, 196, 92])), 0)) {
        return MulticallHandlerInstruction.HandleV3AcrossMessage;
    }
    throw new Error("The provided instruction could not be identified as a multicallHandler instruction.");
}
function parseMulticallHandlerInstruction(instruction) {
    var instructionType = identifyMulticallHandlerInstruction(instruction);
    switch (instructionType) {
        case MulticallHandlerInstruction.HandleV3AcrossMessage: {
            return tslib_1.__assign({ instructionType: MulticallHandlerInstruction.HandleV3AcrossMessage }, (0, instructions_1.parseHandleV3AcrossMessageInstruction)(instruction));
        }
        default:
            throw new Error("Unrecognized instruction type: ".concat(instructionType));
    }
}
//# sourceMappingURL=multicallHandler.js.map