//@ts-nocheck
import { RequestFinalizeBlock, ResponseFinalizeBlock, ResponseCommit, } from '../../../../tendermint/abci/types.js';
import { StoreKVPair, } from '../../v1beta1/listening.js';
import { BinaryReader, BinaryWriter } from '../../../../binary.js';
import { isSet } from '../../../../helpers.js';
import {} from '../../../../json-safe.js';
function createBaseListenFinalizeBlockRequest() {
    return {
        req: undefined,
        res: undefined,
    };
}
export const ListenFinalizeBlockRequest = {
    typeUrl: '/cosmos.store.streaming.abci.ListenFinalizeBlockRequest',
    encode(message, writer = BinaryWriter.create()) {
        if (message.req !== undefined) {
            RequestFinalizeBlock.encode(message.req, writer.uint32(10).fork()).ldelim();
        }
        if (message.res !== undefined) {
            ResponseFinalizeBlock.encode(message.res, writer.uint32(18).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 = createBaseListenFinalizeBlockRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.req = RequestFinalizeBlock.decode(reader, reader.uint32());
                    break;
                case 2:
                    message.res = ResponseFinalizeBlock.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            req: isSet(object.req)
                ? RequestFinalizeBlock.fromJSON(object.req)
                : undefined,
            res: isSet(object.res)
                ? ResponseFinalizeBlock.fromJSON(object.res)
                : undefined,
        };
    },
    toJSON(message) {
        const obj = {};
        message.req !== undefined &&
            (obj.req = message.req
                ? RequestFinalizeBlock.toJSON(message.req)
                : undefined);
        message.res !== undefined &&
            (obj.res = message.res
                ? ResponseFinalizeBlock.toJSON(message.res)
                : undefined);
        return obj;
    },
    fromPartial(object) {
        const message = createBaseListenFinalizeBlockRequest();
        message.req =
            object.req !== undefined && object.req !== null
                ? RequestFinalizeBlock.fromPartial(object.req)
                : undefined;
        message.res =
            object.res !== undefined && object.res !== null
                ? ResponseFinalizeBlock.fromPartial(object.res)
                : undefined;
        return message;
    },
    fromProtoMsg(message) {
        return ListenFinalizeBlockRequest.decode(message.value);
    },
    toProto(message) {
        return ListenFinalizeBlockRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/cosmos.store.streaming.abci.ListenFinalizeBlockRequest',
            value: ListenFinalizeBlockRequest.encode(message).finish(),
        };
    },
};
function createBaseListenFinalizeBlockResponse() {
    return {};
}
export const ListenFinalizeBlockResponse = {
    typeUrl: '/cosmos.store.streaming.abci.ListenFinalizeBlockResponse',
    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 = createBaseListenFinalizeBlockResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        return {};
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = createBaseListenFinalizeBlockResponse();
        return message;
    },
    fromProtoMsg(message) {
        return ListenFinalizeBlockResponse.decode(message.value);
    },
    toProto(message) {
        return ListenFinalizeBlockResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/cosmos.store.streaming.abci.ListenFinalizeBlockResponse',
            value: ListenFinalizeBlockResponse.encode(message).finish(),
        };
    },
};
function createBaseListenCommitRequest() {
    return {
        blockHeight: BigInt(0),
        res: undefined,
        changeSet: [],
    };
}
export const ListenCommitRequest = {
    typeUrl: '/cosmos.store.streaming.abci.ListenCommitRequest',
    encode(message, writer = BinaryWriter.create()) {
        if (message.blockHeight !== BigInt(0)) {
            writer.uint32(8).int64(message.blockHeight);
        }
        if (message.res !== undefined) {
            ResponseCommit.encode(message.res, writer.uint32(18).fork()).ldelim();
        }
        for (const v of message.changeSet) {
            StoreKVPair.encode(v, writer.uint32(26).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 = createBaseListenCommitRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.blockHeight = reader.int64();
                    break;
                case 2:
                    message.res = ResponseCommit.decode(reader, reader.uint32());
                    break;
                case 3:
                    message.changeSet.push(StoreKVPair.decode(reader, reader.uint32()));
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(object) {
        return {
            blockHeight: isSet(object.blockHeight)
                ? BigInt(object.blockHeight.toString())
                : BigInt(0),
            res: isSet(object.res) ? ResponseCommit.fromJSON(object.res) : undefined,
            changeSet: Array.isArray(object?.changeSet)
                ? object.changeSet.map((e) => StoreKVPair.fromJSON(e))
                : [],
        };
    },
    toJSON(message) {
        const obj = {};
        message.blockHeight !== undefined &&
            (obj.blockHeight = (message.blockHeight || BigInt(0)).toString());
        message.res !== undefined &&
            (obj.res = message.res ? ResponseCommit.toJSON(message.res) : undefined);
        if (message.changeSet) {
            obj.changeSet = message.changeSet.map(e => e ? StoreKVPair.toJSON(e) : undefined);
        }
        else {
            obj.changeSet = [];
        }
        return obj;
    },
    fromPartial(object) {
        const message = createBaseListenCommitRequest();
        message.blockHeight =
            object.blockHeight !== undefined && object.blockHeight !== null
                ? BigInt(object.blockHeight.toString())
                : BigInt(0);
        message.res =
            object.res !== undefined && object.res !== null
                ? ResponseCommit.fromPartial(object.res)
                : undefined;
        message.changeSet =
            object.changeSet?.map(e => StoreKVPair.fromPartial(e)) || [];
        return message;
    },
    fromProtoMsg(message) {
        return ListenCommitRequest.decode(message.value);
    },
    toProto(message) {
        return ListenCommitRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/cosmos.store.streaming.abci.ListenCommitRequest',
            value: ListenCommitRequest.encode(message).finish(),
        };
    },
};
function createBaseListenCommitResponse() {
    return {};
}
export const ListenCommitResponse = {
    typeUrl: '/cosmos.store.streaming.abci.ListenCommitResponse',
    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 = createBaseListenCommitResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromJSON(_) {
        return {};
    },
    toJSON(_) {
        const obj = {};
        return obj;
    },
    fromPartial(_) {
        const message = createBaseListenCommitResponse();
        return message;
    },
    fromProtoMsg(message) {
        return ListenCommitResponse.decode(message.value);
    },
    toProto(message) {
        return ListenCommitResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: '/cosmos.store.streaming.abci.ListenCommitResponse',
            value: ListenCommitResponse.encode(message).finish(),
        };
    },
};
//# sourceMappingURL=grpc.js.map