"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Handler = exports.ListQueryHandlersResponse = exports.ListQueryHandlersRequest = exports.QueryResponse = exports.QueryRequest = void 0;
const any_1 = require("../../../../google/protobuf/any");
const binary_1 = require("../../../../binary");
const registry_1 = require("../../../../registry");
function createBaseQueryRequest() {
    return {
        request: undefined
    };
}
exports.QueryRequest = {
    typeUrl: "/cosmos.base.grpc.v2.QueryRequest",
    aminoType: "cosmos-sdk/QueryRequest",
    is(o) {
        return o && o.$typeUrl === exports.QueryRequest.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === exports.QueryRequest.typeUrl;
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.request !== undefined) {
            any_1.Any.encode(message.request, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseQueryRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.request = any_1.Any.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseQueryRequest();
        message.request = object.request !== undefined && object.request !== null ? any_1.Any.fromPartial(object.request) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseQueryRequest();
        if (object.request !== undefined && object.request !== null) {
            message.request = any_1.Any.fromAmino(object.request);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.request = message.request ? any_1.Any.toAmino(message.request) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.QueryRequest.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/QueryRequest",
            value: exports.QueryRequest.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.QueryRequest.decode(message.value);
    },
    toProto(message) {
        return exports.QueryRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.base.grpc.v2.QueryRequest",
            value: exports.QueryRequest.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.QueryRequest.typeUrl, exports.QueryRequest);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.QueryRequest.aminoType, exports.QueryRequest.typeUrl);
function createBaseQueryResponse() {
    return {
        response: undefined
    };
}
exports.QueryResponse = {
    typeUrl: "/cosmos.base.grpc.v2.QueryResponse",
    aminoType: "cosmos-sdk/QueryResponse",
    is(o) {
        return o && o.$typeUrl === exports.QueryResponse.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === exports.QueryResponse.typeUrl;
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.response !== undefined) {
            any_1.Any.encode(message.response, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseQueryResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.response = any_1.Any.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseQueryResponse();
        message.response = object.response !== undefined && object.response !== null ? any_1.Any.fromPartial(object.response) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseQueryResponse();
        if (object.response !== undefined && object.response !== null) {
            message.response = any_1.Any.fromAmino(object.response);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.response = message.response ? any_1.Any.toAmino(message.response) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.QueryResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/QueryResponse",
            value: exports.QueryResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.QueryResponse.decode(message.value);
    },
    toProto(message) {
        return exports.QueryResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.base.grpc.v2.QueryResponse",
            value: exports.QueryResponse.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.QueryResponse.typeUrl, exports.QueryResponse);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.QueryResponse.aminoType, exports.QueryResponse.typeUrl);
function createBaseListQueryHandlersRequest() {
    return {};
}
exports.ListQueryHandlersRequest = {
    typeUrl: "/cosmos.base.grpc.v2.ListQueryHandlersRequest",
    aminoType: "cosmos-sdk/ListQueryHandlersRequest",
    is(o) {
        return o && o.$typeUrl === exports.ListQueryHandlersRequest.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === exports.ListQueryHandlersRequest.typeUrl;
    },
    encode(_, writer = binary_1.BinaryWriter.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseListQueryHandlersRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(_) {
        const message = createBaseListQueryHandlersRequest();
        return message;
    },
    fromAmino(_) {
        const message = createBaseListQueryHandlersRequest();
        return message;
    },
    toAmino(_) {
        const obj = {};
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ListQueryHandlersRequest.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ListQueryHandlersRequest",
            value: exports.ListQueryHandlersRequest.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ListQueryHandlersRequest.decode(message.value);
    },
    toProto(message) {
        return exports.ListQueryHandlersRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.base.grpc.v2.ListQueryHandlersRequest",
            value: exports.ListQueryHandlersRequest.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.ListQueryHandlersRequest.typeUrl, exports.ListQueryHandlersRequest);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ListQueryHandlersRequest.aminoType, exports.ListQueryHandlersRequest.typeUrl);
function createBaseListQueryHandlersResponse() {
    return {
        handlers: []
    };
}
exports.ListQueryHandlersResponse = {
    typeUrl: "/cosmos.base.grpc.v2.ListQueryHandlersResponse",
    aminoType: "cosmos-sdk/ListQueryHandlersResponse",
    is(o) {
        return o && (o.$typeUrl === exports.ListQueryHandlersResponse.typeUrl || Array.isArray(o.handlers) && (!o.handlers.length || exports.Handler.is(o.handlers[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ListQueryHandlersResponse.typeUrl || Array.isArray(o.handlers) && (!o.handlers.length || exports.Handler.isAmino(o.handlers[0])));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.handlers) {
            exports.Handler.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseListQueryHandlersResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.handlers.push(exports.Handler.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseListQueryHandlersResponse();
        message.handlers = object.handlers?.map(e => exports.Handler.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseListQueryHandlersResponse();
        message.handlers = object.handlers?.map(e => exports.Handler.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.handlers) {
            obj.handlers = message.handlers.map(e => e ? exports.Handler.toAmino(e) : undefined);
        }
        else {
            obj.handlers = message.handlers;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ListQueryHandlersResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ListQueryHandlersResponse",
            value: exports.ListQueryHandlersResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ListQueryHandlersResponse.decode(message.value);
    },
    toProto(message) {
        return exports.ListQueryHandlersResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.base.grpc.v2.ListQueryHandlersResponse",
            value: exports.ListQueryHandlersResponse.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.ListQueryHandlersResponse.typeUrl, exports.ListQueryHandlersResponse);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.ListQueryHandlersResponse.aminoType, exports.ListQueryHandlersResponse.typeUrl);
function createBaseHandler() {
    return {
        requestName: "",
        responseName: ""
    };
}
exports.Handler = {
    typeUrl: "/cosmos.base.grpc.v2.Handler",
    aminoType: "cosmos-sdk/Handler",
    is(o) {
        return o && (o.$typeUrl === exports.Handler.typeUrl || typeof o.requestName === "string" && typeof o.responseName === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Handler.typeUrl || typeof o.request_name === "string" && typeof o.response_name === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.requestName !== "") {
            writer.uint32(10).string(message.requestName);
        }
        if (message.responseName !== "") {
            writer.uint32(18).string(message.responseName);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof binary_1.BinaryReader ? input : new binary_1.BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseHandler();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.requestName = reader.string();
                    break;
                case 2:
                    message.responseName = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseHandler();
        message.requestName = object.requestName ?? "";
        message.responseName = object.responseName ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseHandler();
        if (object.request_name !== undefined && object.request_name !== null) {
            message.requestName = object.request_name;
        }
        if (object.response_name !== undefined && object.response_name !== null) {
            message.responseName = object.response_name;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.request_name = message.requestName === "" ? undefined : message.requestName;
        obj.response_name = message.responseName === "" ? undefined : message.responseName;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.Handler.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Handler",
            value: exports.Handler.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Handler.decode(message.value);
    },
    toProto(message) {
        return exports.Handler.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.base.grpc.v2.Handler",
            value: exports.Handler.encode(message).finish()
        };
    }
};
registry_1.GlobalDecoderRegistry.register(exports.Handler.typeUrl, exports.Handler);
registry_1.GlobalDecoderRegistry.registerAminoProtoMapping(exports.Handler.aminoType, exports.Handler.typeUrl);
