import { EpochInfo } from "./genesis";
import { BinaryReader, BinaryWriter } from "../../../binary";
import { GlobalDecoderRegistry } from "../../../registry";
function createBaseQueryEpochInfosRequest() {
    return {};
}
/**
 * QueryEpochInfosRequest defines the gRPC request structure for
 * querying all epoch info.
 * @name QueryEpochInfosRequest
 * @package cosmos.epochs.v1beta1
 * @see proto type: cosmos.epochs.v1beta1.QueryEpochInfosRequest
 */
export const QueryEpochInfosRequest = {
    typeUrl: "/cosmos.epochs.v1beta1.QueryEpochInfosRequest",
    aminoType: "cosmos-sdk/QueryEpochInfosRequest",
    is(o) {
        return o && o.$typeUrl === QueryEpochInfosRequest.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === QueryEpochInfosRequest.typeUrl;
    },
    encode(_, writer = BinaryWriter.create()) {
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseQueryEpochInfosRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(_) {
        const message = createBaseQueryEpochInfosRequest();
        return message;
    },
    fromAmino(_) {
        const message = createBaseQueryEpochInfosRequest();
        return message;
    },
    toAmino(_) {
        const obj = {};
        return obj;
    },
    fromAminoMsg(object) {
        return QueryEpochInfosRequest.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/QueryEpochInfosRequest",
            value: QueryEpochInfosRequest.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return QueryEpochInfosRequest.decode(message.value);
    },
    toProto(message) {
        return QueryEpochInfosRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.epochs.v1beta1.QueryEpochInfosRequest",
            value: QueryEpochInfosRequest.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
function createBaseQueryEpochInfosResponse() {
    return {
        epochs: []
    };
}
/**
 * QueryEpochInfosRequest defines the gRPC response structure for
 * querying all epoch info.
 * @name QueryEpochInfosResponse
 * @package cosmos.epochs.v1beta1
 * @see proto type: cosmos.epochs.v1beta1.QueryEpochInfosResponse
 */
export const QueryEpochInfosResponse = {
    typeUrl: "/cosmos.epochs.v1beta1.QueryEpochInfosResponse",
    aminoType: "cosmos-sdk/QueryEpochInfosResponse",
    is(o) {
        return o && (o.$typeUrl === QueryEpochInfosResponse.typeUrl || Array.isArray(o.epochs) && (!o.epochs.length || EpochInfo.is(o.epochs[0])));
    },
    isAmino(o) {
        return o && (o.$typeUrl === QueryEpochInfosResponse.typeUrl || Array.isArray(o.epochs) && (!o.epochs.length || EpochInfo.isAmino(o.epochs[0])));
    },
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.epochs) {
            EpochInfo.encode(v, writer.uint32(10).fork()).ldelim();
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseQueryEpochInfosResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.epochs.push(EpochInfo.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseQueryEpochInfosResponse();
        message.epochs = object.epochs?.map(e => EpochInfo.fromPartial(e)) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseQueryEpochInfosResponse();
        message.epochs = object.epochs?.map(e => EpochInfo.fromAmino(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.epochs) {
            obj.epochs = message.epochs.map(e => e ? EpochInfo.toAmino(e) : undefined);
        }
        else {
            obj.epochs = message.epochs;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return QueryEpochInfosResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/QueryEpochInfosResponse",
            value: QueryEpochInfosResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return QueryEpochInfosResponse.decode(message.value);
    },
    toProto(message) {
        return QueryEpochInfosResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.epochs.v1beta1.QueryEpochInfosResponse",
            value: QueryEpochInfosResponse.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!GlobalDecoderRegistry.registerExistingTypeUrl(QueryEpochInfosResponse.typeUrl)) {
            return;
        }
        EpochInfo.registerTypeUrl();
    }
};
function createBaseQueryCurrentEpochRequest() {
    return {
        identifier: ""
    };
}
/**
 * QueryCurrentEpochRequest defines the gRPC request structure for
 * querying an epoch by its identifier.
 * @name QueryCurrentEpochRequest
 * @package cosmos.epochs.v1beta1
 * @see proto type: cosmos.epochs.v1beta1.QueryCurrentEpochRequest
 */
export const QueryCurrentEpochRequest = {
    typeUrl: "/cosmos.epochs.v1beta1.QueryCurrentEpochRequest",
    aminoType: "cosmos-sdk/QueryCurrentEpochRequest",
    is(o) {
        return o && (o.$typeUrl === QueryCurrentEpochRequest.typeUrl || typeof o.identifier === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === QueryCurrentEpochRequest.typeUrl || typeof o.identifier === "string");
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.identifier !== "") {
            writer.uint32(10).string(message.identifier);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseQueryCurrentEpochRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.identifier = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseQueryCurrentEpochRequest();
        message.identifier = object.identifier ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseQueryCurrentEpochRequest();
        if (object.identifier !== undefined && object.identifier !== null) {
            message.identifier = object.identifier;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.identifier = message.identifier === "" ? undefined : message.identifier;
        return obj;
    },
    fromAminoMsg(object) {
        return QueryCurrentEpochRequest.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/QueryCurrentEpochRequest",
            value: QueryCurrentEpochRequest.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return QueryCurrentEpochRequest.decode(message.value);
    },
    toProto(message) {
        return QueryCurrentEpochRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.epochs.v1beta1.QueryCurrentEpochRequest",
            value: QueryCurrentEpochRequest.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
function createBaseQueryCurrentEpochResponse() {
    return {
        currentEpoch: BigInt(0)
    };
}
/**
 * QueryCurrentEpochResponse defines the gRPC response structure for
 * querying an epoch by its identifier.
 * @name QueryCurrentEpochResponse
 * @package cosmos.epochs.v1beta1
 * @see proto type: cosmos.epochs.v1beta1.QueryCurrentEpochResponse
 */
export const QueryCurrentEpochResponse = {
    typeUrl: "/cosmos.epochs.v1beta1.QueryCurrentEpochResponse",
    aminoType: "cosmos-sdk/QueryCurrentEpochResponse",
    is(o) {
        return o && (o.$typeUrl === QueryCurrentEpochResponse.typeUrl || typeof o.currentEpoch === "bigint");
    },
    isAmino(o) {
        return o && (o.$typeUrl === QueryCurrentEpochResponse.typeUrl || typeof o.current_epoch === "bigint");
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.currentEpoch !== BigInt(0)) {
            writer.uint32(8).int64(message.currentEpoch);
        }
        return writer;
    },
    decode(input, length) {
        const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
        let end = length === undefined ? reader.len : reader.pos + length;
        const message = createBaseQueryCurrentEpochResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.currentEpoch = reader.int64();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseQueryCurrentEpochResponse();
        message.currentEpoch = object.currentEpoch !== undefined && object.currentEpoch !== null ? BigInt(object.currentEpoch.toString()) : BigInt(0);
        return message;
    },
    fromAmino(object) {
        const message = createBaseQueryCurrentEpochResponse();
        if (object.current_epoch !== undefined && object.current_epoch !== null) {
            message.currentEpoch = BigInt(object.current_epoch);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.current_epoch = message.currentEpoch !== BigInt(0) ? message.currentEpoch?.toString() : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return QueryCurrentEpochResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/QueryCurrentEpochResponse",
            value: QueryCurrentEpochResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return QueryCurrentEpochResponse.decode(message.value);
    },
    toProto(message) {
        return QueryCurrentEpochResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/cosmos.epochs.v1beta1.QueryCurrentEpochResponse",
            value: QueryCurrentEpochResponse.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
