"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Checksums = exports.ClientMessage = exports.ConsensusState = exports.ClientState = void 0;
const client_1 = require("../../../core/client/v1/client");
const binary_1 = require("../../../../binary");
const registry_1 = require("../../../../registry");
const helpers_1 = require("../../../../helpers");
function createBaseClientState() {
    return {
        data: new Uint8Array(),
        checksum: new Uint8Array(),
        latestHeight: client_1.Height.fromPartial({})
    };
}
/**
 * Wasm light client's Client state
 * @name ClientState
 * @package ibc.lightclients.wasm.v1
 * @see proto type: ibc.lightclients.wasm.v1.ClientState
 */
exports.ClientState = {
    typeUrl: "/ibc.lightclients.wasm.v1.ClientState",
    aminoType: "cosmos-sdk/ClientState",
    is(o) {
        return o && (o.$typeUrl === exports.ClientState.typeUrl || (o.data instanceof Uint8Array || typeof o.data === "string") && (o.checksum instanceof Uint8Array || typeof o.checksum === "string") && client_1.Height.is(o.latestHeight));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ClientState.typeUrl || (o.data instanceof Uint8Array || typeof o.data === "string") && (o.checksum instanceof Uint8Array || typeof o.checksum === "string") && client_1.Height.isAmino(o.latest_height));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.data.length !== 0) {
            writer.uint32(10).bytes(message.data);
        }
        if (message.checksum.length !== 0) {
            writer.uint32(18).bytes(message.checksum);
        }
        if (message.latestHeight !== undefined) {
            client_1.Height.encode(message.latestHeight, writer.uint32(26).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 = createBaseClientState();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.data = reader.bytes();
                    break;
                case 2:
                    message.checksum = reader.bytes();
                    break;
                case 3:
                    message.latestHeight = client_1.Height.decode(reader, reader.uint32());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseClientState();
        message.data = object.data ?? new Uint8Array();
        message.checksum = object.checksum ?? new Uint8Array();
        message.latestHeight = object.latestHeight !== undefined && object.latestHeight !== null ? client_1.Height.fromPartial(object.latestHeight) : undefined;
        return message;
    },
    fromAmino(object) {
        const message = createBaseClientState();
        if (object.data !== undefined && object.data !== null) {
            message.data = (0, helpers_1.bytesFromBase64)(object.data);
        }
        if (object.checksum !== undefined && object.checksum !== null) {
            message.checksum = (0, helpers_1.bytesFromBase64)(object.checksum);
        }
        if (object.latest_height !== undefined && object.latest_height !== null) {
            message.latestHeight = client_1.Height.fromAmino(object.latest_height);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.data = message.data ? (0, helpers_1.base64FromBytes)(message.data) : undefined;
        obj.checksum = message.checksum ? (0, helpers_1.base64FromBytes)(message.checksum) : undefined;
        obj.latest_height = message.latestHeight ? client_1.Height.toAmino(message.latestHeight) : {};
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ClientState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ClientState",
            value: exports.ClientState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ClientState.decode(message.value);
    },
    toProto(message) {
        return exports.ClientState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.lightclients.wasm.v1.ClientState",
            value: exports.ClientState.encode(message).finish()
        };
    },
    registerTypeUrl() {
        if (!registry_1.GlobalDecoderRegistry.registerExistingTypeUrl(exports.ClientState.typeUrl)) {
            return;
        }
        client_1.Height.registerTypeUrl();
    }
};
function createBaseConsensusState() {
    return {
        data: new Uint8Array()
    };
}
/**
 * Wasm light client's ConsensusState
 * @name ConsensusState
 * @package ibc.lightclients.wasm.v1
 * @see proto type: ibc.lightclients.wasm.v1.ConsensusState
 */
exports.ConsensusState = {
    typeUrl: "/ibc.lightclients.wasm.v1.ConsensusState",
    aminoType: "cosmos-sdk/ConsensusState",
    is(o) {
        return o && (o.$typeUrl === exports.ConsensusState.typeUrl || o.data instanceof Uint8Array || typeof o.data === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ConsensusState.typeUrl || o.data instanceof Uint8Array || typeof o.data === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.data.length !== 0) {
            writer.uint32(10).bytes(message.data);
        }
        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 = createBaseConsensusState();
        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 = createBaseConsensusState();
        message.data = object.data ?? new Uint8Array();
        return message;
    },
    fromAmino(object) {
        const message = createBaseConsensusState();
        if (object.data !== undefined && object.data !== null) {
            message.data = (0, helpers_1.bytesFromBase64)(object.data);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.data = message.data ? (0, helpers_1.base64FromBytes)(message.data) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ConsensusState.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ConsensusState",
            value: exports.ConsensusState.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ConsensusState.decode(message.value);
    },
    toProto(message) {
        return exports.ConsensusState.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.lightclients.wasm.v1.ConsensusState",
            value: exports.ConsensusState.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
function createBaseClientMessage() {
    return {
        data: new Uint8Array()
    };
}
/**
 * Wasm light client message (either header(s) or misbehaviour)
 * @name ClientMessage
 * @package ibc.lightclients.wasm.v1
 * @see proto type: ibc.lightclients.wasm.v1.ClientMessage
 */
exports.ClientMessage = {
    typeUrl: "/ibc.lightclients.wasm.v1.ClientMessage",
    aminoType: "cosmos-sdk/ClientMessage",
    is(o) {
        return o && (o.$typeUrl === exports.ClientMessage.typeUrl || o.data instanceof Uint8Array || typeof o.data === "string");
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.ClientMessage.typeUrl || o.data instanceof Uint8Array || typeof o.data === "string");
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        if (message.data.length !== 0) {
            writer.uint32(10).bytes(message.data);
        }
        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 = createBaseClientMessage();
        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 = createBaseClientMessage();
        message.data = object.data ?? new Uint8Array();
        return message;
    },
    fromAmino(object) {
        const message = createBaseClientMessage();
        if (object.data !== undefined && object.data !== null) {
            message.data = (0, helpers_1.bytesFromBase64)(object.data);
        }
        return message;
    },
    toAmino(message) {
        const obj = {};
        obj.data = message.data ? (0, helpers_1.base64FromBytes)(message.data) : undefined;
        return obj;
    },
    fromAminoMsg(object) {
        return exports.ClientMessage.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/ClientMessage",
            value: exports.ClientMessage.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.ClientMessage.decode(message.value);
    },
    toProto(message) {
        return exports.ClientMessage.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.lightclients.wasm.v1.ClientMessage",
            value: exports.ClientMessage.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
function createBaseChecksums() {
    return {
        checksums: []
    };
}
/**
 * Checksums defines a list of all checksums that are stored
 *
 * Deprecated: This message is deprecated in favor of storing the checksums
 * using a Collections.KeySet.
 * @name Checksums
 * @package ibc.lightclients.wasm.v1
 * @see proto type: ibc.lightclients.wasm.v1.Checksums
 * @deprecated
 */
exports.Checksums = {
    typeUrl: "/ibc.lightclients.wasm.v1.Checksums",
    aminoType: "cosmos-sdk/Checksums",
    is(o) {
        return o && (o.$typeUrl === exports.Checksums.typeUrl || Array.isArray(o.checksums) && (!o.checksums.length || o.checksums[0] instanceof Uint8Array || typeof o.checksums[0] === "string"));
    },
    isAmino(o) {
        return o && (o.$typeUrl === exports.Checksums.typeUrl || Array.isArray(o.checksums) && (!o.checksums.length || o.checksums[0] instanceof Uint8Array || typeof o.checksums[0] === "string"));
    },
    encode(message, writer = binary_1.BinaryWriter.create()) {
        for (const v of message.checksums) {
            writer.uint32(10).bytes(v);
        }
        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 = createBaseChecksums();
        while (reader.pos < end) {
            const tag = reader.uint32();
            switch (tag >>> 3) {
                case 1:
                    message.checksums.push(reader.bytes());
                    break;
                default:
                    reader.skipType(tag & 7);
                    break;
            }
        }
        return message;
    },
    fromPartial(object) {
        const message = createBaseChecksums();
        message.checksums = object.checksums?.map(e => e) || [];
        return message;
    },
    fromAmino(object) {
        const message = createBaseChecksums();
        message.checksums = object.checksums?.map(e => (0, helpers_1.bytesFromBase64)(e)) || [];
        return message;
    },
    toAmino(message) {
        const obj = {};
        if (message.checksums) {
            obj.checksums = message.checksums.map(e => (0, helpers_1.base64FromBytes)(e));
        }
        else {
            obj.checksums = message.checksums;
        }
        return obj;
    },
    fromAminoMsg(object) {
        return exports.Checksums.fromAmino(object.value);
    },
    toAminoMsg(message) {
        return {
            type: "cosmos-sdk/Checksums",
            value: exports.Checksums.toAmino(message)
        };
    },
    fromProtoMsg(message) {
        return exports.Checksums.decode(message.value);
    },
    toProto(message) {
        return exports.Checksums.encode(message).finish();
    },
    toProtoMsg(message) {
        return {
            typeUrl: "/ibc.lightclients.wasm.v1.Checksums",
            value: exports.Checksums.encode(message).finish()
        };
    },
    registerTypeUrl() { }
};
