import { PageRequest, PageResponse } from "../../../../cosmos/base/query/v1beta1/pagination";
import { BinaryReader, BinaryWriter } from "../../../../binary";
import { GlobalDecoderRegistry } from "../../../../registry";
import { bytesFromBase64, base64FromBytes } from "../../../../helpers";
function createBaseQueryChecksumsRequest() {
    return {
        pagination: undefined
    };
}
export const QueryChecksumsRequest = {
    typeUrl: "/ibc.lightclients.wasm.v1.QueryChecksumsRequest",
    aminoType: "cosmos-sdk/QueryChecksumsRequest",
    is(o) {
        return o && o.$typeUrl === QueryChecksumsRequest.typeUrl;
    },
    isAmino(o) {
        return o && o.$typeUrl === QueryChecksumsRequest.typeUrl;
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.pagination !== undefined) {
            PageRequest.encode(message.pagination, 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 = createBaseQueryChecksumsRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.pagination = PageRequest.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseQueryChecksumsRequest();
        message.pagination = object.pagination !== undefined && object.pagination !== null ? PageRequest.fromPartial(object.pagination) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseQueryChecksumsRequest();
        if (object.pagination !== undefined && object.pagination !== null) {
            message.pagination = PageRequest.fromAmino(object.pagination);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.pagination = message.pagination ? PageRequest.toAmino(message.pagination) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return QueryChecksumsRequest.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/QueryChecksumsRequest",
            value: QueryChecksumsRequest.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return QueryChecksumsRequest.decode(message.value);
    },
    toProto(message) {
        return QueryChecksumsRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.lightclients.wasm.v1.QueryChecksumsRequest",
            value: QueryChecksumsRequest.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(QueryChecksumsRequest.typeUrl, QueryChecksumsRequest);
GlobalDecoderRegistry.registerAminoProtoMapping(QueryChecksumsRequest.aminoType, QueryChecksumsRequest.typeUrl);
function createBaseQueryChecksumsResponse() {
    return {
        checksums: [],
        pagination: undefined
    };
}
export const QueryChecksumsResponse = {
    typeUrl: "/ibc.lightclients.wasm.v1.QueryChecksumsResponse",
    aminoType: "cosmos-sdk/QueryChecksumsResponse",
    is(o) {
        return o && (o.$typeUrl === QueryChecksumsResponse.typeUrl || Array.isArray(o.checksums) && (!o.checksums.length || typeof o.checksums[0] === "string"));
    },
    isAmino(o) {
        return o && (o.$typeUrl === QueryChecksumsResponse.typeUrl || Array.isArray(o.checksums) && (!o.checksums.length || typeof o.checksums[0] === "string"));
    },
    encode(message, writer = BinaryWriter.create()) {
        for (const v of message.checksums) {
            writer.uint32(10).string(v);
        }
        if (message.pagination !== undefined) {
            PageResponse.encode(message.pagination, 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 = createBaseQueryChecksumsResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.checksums.push(reader.string());
                    break;
                case 2:
                    message.pagination = PageResponse.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseQueryChecksumsResponse();
        message.checksums = object.checksums?.map(e => e) || [];
        message.pagination = object.pagination !== undefined && object.pagination !== null ? PageResponse.fromPartial(object.pagination) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseQueryChecksumsResponse();
        message.checksums = object.checksums?.map(e => e) || [];
        if (object.pagination !== undefined && object.pagination !== null) {
            message.pagination = PageResponse.fromAmino(object.pagination);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.checksums) {
            obj.checksums = message.checksums.map(e => e);
        }
        else {
            obj.checksums = message.checksums;
        }
        obj.pagination = message.pagination ? PageResponse.toAmino(message.pagination) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return QueryChecksumsResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/QueryChecksumsResponse",
            value: QueryChecksumsResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return QueryChecksumsResponse.decode(message.value);
    },
    toProto(message) {
        return QueryChecksumsResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.lightclients.wasm.v1.QueryChecksumsResponse",
            value: QueryChecksumsResponse.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(QueryChecksumsResponse.typeUrl, QueryChecksumsResponse);
GlobalDecoderRegistry.registerAminoProtoMapping(QueryChecksumsResponse.aminoType, QueryChecksumsResponse.typeUrl);
function createBaseQueryCodeRequest() {
    return {
        checksum: ""
    };
}
export const QueryCodeRequest = {
    typeUrl: "/ibc.lightclients.wasm.v1.QueryCodeRequest",
    aminoType: "cosmos-sdk/QueryCodeRequest",
    is(o) {
        return o && (o.$typeUrl === QueryCodeRequest.typeUrl || typeof o.checksum === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === QueryCodeRequest.typeUrl || typeof o.checksum === "string");
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.checksum !== "") {
            writer.uint32(10).string(message.checksum);
        }
        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 = createBaseQueryCodeRequest();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.checksum = reader.string();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseQueryCodeRequest();
        message.checksum = object.checksum ?? "";
        return message;
    },
    fromAmino(object) {
        const message = createBaseQueryCodeRequest();
        if (object.checksum !== undefined && object.checksum !== null) {
            message.checksum = object.checksum;
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.checksum = message.checksum === "" ? undefined : message.checksum;
        return obj;
    },
    fromAminoMsg(object) {
        return QueryCodeRequest.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/QueryCodeRequest",
            value: QueryCodeRequest.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return QueryCodeRequest.decode(message.value);
    },
    toProto(message) {
        return QueryCodeRequest.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.lightclients.wasm.v1.QueryCodeRequest",
            value: QueryCodeRequest.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(QueryCodeRequest.typeUrl, QueryCodeRequest);
GlobalDecoderRegistry.registerAminoProtoMapping(QueryCodeRequest.aminoType, QueryCodeRequest.typeUrl);
function createBaseQueryCodeResponse() {
    return {
        data: new Uint8Array()
    };
}
export const QueryCodeResponse = {
    typeUrl: "/ibc.lightclients.wasm.v1.QueryCodeResponse",
    aminoType: "cosmos-sdk/QueryCodeResponse",
    is(o) {
        return o && (o.$typeUrl === QueryCodeResponse.typeUrl || o.data instanceof Uint8Array || typeof o.data === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === QueryCodeResponse.typeUrl || o.data instanceof Uint8Array || typeof o.data === "string");
    },
    encode(message, writer = BinaryWriter.create()) {
        if (message.data.length !== 0) {
            writer.uint32(10).bytes(message.data);
        }
        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 = createBaseQueryCodeResponse();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.data = reader.bytes();
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseQueryCodeResponse();
        message.data = object.data ?? new Uint8Array();
        return message;
    },
    fromAmino(object) {
        const message = createBaseQueryCodeResponse();
        if (object.data !== undefined && object.data !== null) {
            message.data = bytesFromBase64(object.data);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.data = message.data ? base64FromBytes(message.data) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return QueryCodeResponse.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/QueryCodeResponse",
            value: QueryCodeResponse.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return QueryCodeResponse.decode(message.value);
    },
    toProto(message) {
        return QueryCodeResponse.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.lightclients.wasm.v1.QueryCodeResponse",
            value: QueryCodeResponse.encode(message).finish()
        };
    }
};
GlobalDecoderRegistry.register(QueryCodeResponse.typeUrl, QueryCodeResponse);
GlobalDecoderRegistry.registerAminoProtoMapping(QueryCodeResponse.aminoType, QueryCodeResponse.typeUrl);
